Add video texture format YUY2

This commit is contained in:
Wojtek Figat
2024-04-25 10:26:23 +02:00
parent ebe05d4a51
commit 3ebf73ec22
8 changed files with 49 additions and 74 deletions

View File

@@ -298,14 +298,13 @@ void RenderTools::ComputePitch(PixelFormat format, int32 width, int32 height, ui
case PixelFormat::BC4_Typeless:
case PixelFormat::BC4_UNorm:
case PixelFormat::BC4_SNorm:
ASSERT(PixelFormatExtensions::IsCompressed(format));
{
uint32 nbw = Math::Max<uint32>(1, (width + 3) / 4);
uint32 nbh = Math::Max<uint32>(1, (height + 3) / 4);
rowPitch = nbw * 8;
slicePitch = rowPitch * nbh;
}
break;
{
const uint32 nbw = Math::Max<uint32>(1, (width + 3) / 4);
const uint32 nbh = Math::Max<uint32>(1, (height + 3) / 4);
rowPitch = nbw * 8;
slicePitch = rowPitch * nbh;
}
break;
case PixelFormat::BC2_Typeless:
case PixelFormat::BC2_UNorm:
case PixelFormat::BC2_UNorm_sRGB:
@@ -321,14 +320,13 @@ void RenderTools::ComputePitch(PixelFormat format, int32 width, int32 height, ui
case PixelFormat::BC7_Typeless:
case PixelFormat::BC7_UNorm:
case PixelFormat::BC7_UNorm_sRGB:
ASSERT(PixelFormatExtensions::IsCompressed(format));
{
uint32 nbw = Math::Max<uint32>(1, (width + 3) / 4);
uint32 nbh = Math::Max<uint32>(1, (height + 3) / 4);
rowPitch = nbw * 16;
slicePitch = rowPitch * nbh;
}
break;
{
const uint32 nbw = Math::Max<uint32>(1, (width + 3) / 4);
const uint32 nbh = Math::Max<uint32>(1, (height + 3) / 4);
rowPitch = nbw * 16;
slicePitch = rowPitch * nbh;
}
break;
case PixelFormat::ASTC_4x4_UNorm:
case PixelFormat::ASTC_4x4_UNorm_sRGB:
case PixelFormat::ASTC_6x6_UNorm:
@@ -339,28 +337,22 @@ void RenderTools::ComputePitch(PixelFormat format, int32 width, int32 height, ui
case PixelFormat::ASTC_10x10_UNorm_sRGB:
{
const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(format);
uint32 nbw = Math::Max<uint32>(1, Math::DivideAndRoundUp(width, blockSize));
uint32 nbh = Math::Max<uint32>(1, Math::DivideAndRoundUp(height, blockSize));
const uint32 nbw = Math::Max<uint32>(1, Math::DivideAndRoundUp(width, blockSize));
const uint32 nbh = Math::Max<uint32>(1, Math::DivideAndRoundUp(height, blockSize));
rowPitch = nbw * 16; // All ASTC blocks use 128 bits
slicePitch = rowPitch * nbh;
}
break;
case PixelFormat::R8G8_B8G8_UNorm:
case PixelFormat::G8R8_G8B8_UNorm:
ASSERT(PixelFormatExtensions::IsPacked(format));
case PixelFormat::YUY2:
rowPitch = ((width + 1) >> 1) * 4;
slicePitch = rowPitch * height;
break;
default:
ASSERT(PixelFormatExtensions::IsValid(format));
ASSERT(!PixelFormatExtensions::IsCompressed(format) && !PixelFormatExtensions::IsPacked(format) && !PixelFormatExtensions::IsPlanar(format));
{
uint32 bpp = PixelFormatExtensions::SizeInBits(format);
// Default byte alignment
rowPitch = (width * bpp + 7) / 8;
slicePitch = rowPitch * height;
}
// Default byte alignment
rowPitch = (width * PixelFormatExtensions::SizeInBits(format) + 7) / 8;
slicePitch = rowPitch * height;
break;
}
}