mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add special resource type for A8_UNORM. Closes #1426
* While it's redundant this format is still valid in D3D so needs to be handled correctly.
This commit is contained in:
@@ -657,6 +657,7 @@ QString FormatElement::GenerateTextureBufferFormat(const TextureDescription &tex
|
||||
case ResourceFormatType::YUV10:
|
||||
case ResourceFormatType::YUV12:
|
||||
case ResourceFormatType::YUV16: baseType = lit("xshort4"); break;
|
||||
case ResourceFormatType::A8:
|
||||
case ResourceFormatType::S8:
|
||||
case ResourceFormatType::Undefined: baseType = lit("xbyte"); break;
|
||||
}
|
||||
|
||||
@@ -1039,7 +1039,8 @@ private:
|
||||
case ResourceFormatType::D24S8:
|
||||
case ResourceFormatType::D32S8: compCount = 2; break;
|
||||
case ResourceFormatType::BC4:
|
||||
case ResourceFormatType::S8: compCount = 1; break;
|
||||
case ResourceFormatType::S8:
|
||||
case ResourceFormatType::A8: compCount = 1; break;
|
||||
case ResourceFormatType::YUV8:
|
||||
case ResourceFormatType::YUV10:
|
||||
case ResourceFormatType::YUV12:
|
||||
|
||||
@@ -70,6 +70,7 @@ static uint32_t byteSize(const ResourceFormat &fmt)
|
||||
case ResourceFormatType::YUV12:
|
||||
case ResourceFormatType::YUV16:
|
||||
case ResourceFormatType::PVRTC: return ~0U;
|
||||
case ResourceFormatType::A8: return 1;
|
||||
case ResourceFormatType::R10G10B10A2:
|
||||
case ResourceFormatType::R11G11B10: return 4;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ rdcstr DoStringise(const ResourceFormatType &el)
|
||||
STRINGISE_ENUM_CLASS(YUV10);
|
||||
STRINGISE_ENUM_CLASS(YUV12);
|
||||
STRINGISE_ENUM_CLASS(YUV16);
|
||||
STRINGISE_ENUM_CLASS(PVRTC);
|
||||
STRINGISE_ENUM_CLASS(A8);
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
|
||||
@@ -1312,6 +1312,10 @@ or formats that don't have equal byte-multiple sizes for each channel.
|
||||
.. data:: PVRTC
|
||||
|
||||
PowerVR properitary texture compression format.
|
||||
|
||||
.. data:: A8
|
||||
|
||||
8-bit unsigned normalised alpha - equivalent to standard R8 with a pre-baked swizzle.
|
||||
)");
|
||||
enum class ResourceFormatType : uint8_t
|
||||
{
|
||||
@@ -1343,6 +1347,7 @@ enum class ResourceFormatType : uint8_t
|
||||
YUV12,
|
||||
YUV16,
|
||||
PVRTC,
|
||||
A8,
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_ENUM(ResourceFormatType);
|
||||
|
||||
@@ -305,6 +305,7 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format)
|
||||
case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
|
||||
special.type = ResourceFormatType::R9G9B9E5;
|
||||
return special;
|
||||
case DXGI_FORMAT_A8_UNORM: special.type = ResourceFormatType::A8; return special;
|
||||
case DXGI_FORMAT_B4G4R4A4_UNORM:
|
||||
fmt8.SetBGRAOrder(true);
|
||||
special.type = ResourceFormatType::R4G4B4A4;
|
||||
@@ -475,6 +476,7 @@ DXGI_FORMAT ResourceFormat2DXGIFormat(ResourceFormat format)
|
||||
case ResourceFormatType::D24S8: return DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
case ResourceFormatType::D32S8: return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
|
||||
case ResourceFormatType::S8: return DXGI_FORMAT_R8_UINT;
|
||||
case ResourceFormatType::A8: return DXGI_FORMAT_A8_UNORM;
|
||||
default:
|
||||
case ResourceFormatType::R4G4:
|
||||
case ResourceFormatType::D16S8:
|
||||
@@ -733,7 +735,8 @@ bool write_dds_to_file(FILE *f, const dds_data &data)
|
||||
{
|
||||
switch(data.format.type)
|
||||
{
|
||||
case ResourceFormatType::S8: bytesPerPixel = 1; break;
|
||||
case ResourceFormatType::S8:
|
||||
case ResourceFormatType::A8: bytesPerPixel = 1; break;
|
||||
case ResourceFormatType::R10G10B10A2:
|
||||
case ResourceFormatType::R9G9B9E5:
|
||||
case ResourceFormatType::R11G11B10:
|
||||
@@ -992,7 +995,8 @@ dds_data load_dds_from_file(FILE *f)
|
||||
uint32_t bytesPerPixel = 1;
|
||||
switch(ret.format.type)
|
||||
{
|
||||
case ResourceFormatType::S8: bytesPerPixel = 1; break;
|
||||
case ResourceFormatType::S8:
|
||||
case ResourceFormatType::A8: bytesPerPixel = 1; break;
|
||||
case ResourceFormatType::R10G10B10A2:
|
||||
case ResourceFormatType::R9G9B9E5:
|
||||
case ResourceFormatType::R11G11B10:
|
||||
|
||||
@@ -816,8 +816,7 @@ DXGI_FORMAT GetSnormTypedFormat(DXGI_FORMAT f)
|
||||
case DXGI_FORMAT_R8_TYPELESS:
|
||||
case DXGI_FORMAT_R8_UNORM:
|
||||
case DXGI_FORMAT_R8_UINT:
|
||||
case DXGI_FORMAT_R8_SINT:
|
||||
case DXGI_FORMAT_A8_UNORM: return DXGI_FORMAT_R8_SNORM;
|
||||
case DXGI_FORMAT_R8_SINT: return DXGI_FORMAT_R8_SNORM;
|
||||
|
||||
case DXGI_FORMAT_BC4_TYPELESS:
|
||||
case DXGI_FORMAT_BC4_UNORM: return DXGI_FORMAT_BC4_SNORM;
|
||||
@@ -897,8 +896,7 @@ DXGI_FORMAT GetUIntTypedFormat(DXGI_FORMAT f)
|
||||
case DXGI_FORMAT_R8_TYPELESS:
|
||||
case DXGI_FORMAT_R8_UNORM:
|
||||
case DXGI_FORMAT_R8_SNORM:
|
||||
case DXGI_FORMAT_R8_SINT:
|
||||
case DXGI_FORMAT_A8_UNORM: return DXGI_FORMAT_R8_UINT;
|
||||
case DXGI_FORMAT_R8_SINT: return DXGI_FORMAT_R8_UINT;
|
||||
|
||||
default: break;
|
||||
}
|
||||
@@ -1344,8 +1342,7 @@ DXGI_FORMAT GetTypelessFormat(DXGI_FORMAT f)
|
||||
case DXGI_FORMAT_R8_UNORM:
|
||||
case DXGI_FORMAT_R8_UINT:
|
||||
case DXGI_FORMAT_R8_SNORM:
|
||||
case DXGI_FORMAT_R8_SINT:
|
||||
case DXGI_FORMAT_A8_UNORM: return DXGI_FORMAT_R8_TYPELESS;
|
||||
case DXGI_FORMAT_R8_SINT: return DXGI_FORMAT_R8_TYPELESS;
|
||||
|
||||
case DXGI_FORMAT_BC1_TYPELESS:
|
||||
case DXGI_FORMAT_BC1_UNORM:
|
||||
@@ -2404,6 +2401,8 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt)
|
||||
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
|
||||
case DXGI_FORMAT_R32G8X24_TYPELESS: ret.type = ResourceFormatType::D32S8; break;
|
||||
|
||||
case DXGI_FORMAT_A8_UNORM: ret.type = ResourceFormatType::A8; break;
|
||||
|
||||
case DXGI_FORMAT_BC1_TYPELESS:
|
||||
case DXGI_FORMAT_BC1_UNORM_SRGB:
|
||||
case DXGI_FORMAT_BC1_UNORM: ret.type = ResourceFormatType::BC1; break;
|
||||
@@ -2575,13 +2574,12 @@ TEST_CASE("DXGI formats", "[format][d3d]")
|
||||
// gap in DXGI_FORMAT enum
|
||||
if(f > DXGI_FORMAT_B4G4R4A4_UNORM && f < DXGI_FORMAT_P208)
|
||||
return true;
|
||||
return (f == DXGI_FORMAT_R1_UNORM || f == DXGI_FORMAT_A8_UNORM ||
|
||||
f == DXGI_FORMAT_R8G8_B8G8_UNORM || f == DXGI_FORMAT_G8R8_G8B8_UNORM ||
|
||||
f == DXGI_FORMAT_B8G8R8X8_TYPELESS || f == DXGI_FORMAT_B8G8R8X8_UNORM ||
|
||||
f == DXGI_FORMAT_B8G8R8X8_UNORM_SRGB || f == DXGI_FORMAT_NV11 ||
|
||||
f == DXGI_FORMAT_AI44 || f == DXGI_FORMAT_IA44 || f == DXGI_FORMAT_P8 ||
|
||||
f == DXGI_FORMAT_A8P8 || f == DXGI_FORMAT_P208 || f == DXGI_FORMAT_V208 ||
|
||||
f == DXGI_FORMAT_V408 || f == DXGI_FORMAT_420_OPAQUE);
|
||||
return (f == DXGI_FORMAT_R1_UNORM || f == DXGI_FORMAT_R8G8_B8G8_UNORM ||
|
||||
f == DXGI_FORMAT_G8R8_G8B8_UNORM || f == DXGI_FORMAT_B8G8R8X8_TYPELESS ||
|
||||
f == DXGI_FORMAT_B8G8R8X8_UNORM || f == DXGI_FORMAT_B8G8R8X8_UNORM_SRGB ||
|
||||
f == DXGI_FORMAT_NV11 || f == DXGI_FORMAT_AI44 || f == DXGI_FORMAT_IA44 ||
|
||||
f == DXGI_FORMAT_P8 || f == DXGI_FORMAT_A8P8 || f == DXGI_FORMAT_P208 ||
|
||||
f == DXGI_FORMAT_V208 || f == DXGI_FORMAT_V408 || f == DXGI_FORMAT_420_OPAQUE);
|
||||
};
|
||||
|
||||
SECTION("Only DXGI_FORMAT_UNKNOWN is ResourceFormatType::Undefined")
|
||||
|
||||
@@ -1731,14 +1731,21 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt)
|
||||
}
|
||||
|
||||
// special handling for formats that don't query neatly
|
||||
if(fmt == eGL_LUMINANCE8_EXT || fmt == eGL_INTENSITY8_EXT || fmt == eGL_ALPHA8_EXT ||
|
||||
fmt == eGL_LUMINANCE || fmt == eGL_ALPHA)
|
||||
if(fmt == eGL_LUMINANCE8_EXT || fmt == eGL_INTENSITY8_EXT || fmt == eGL_LUMINANCE)
|
||||
{
|
||||
ret.compByteWidth = 1;
|
||||
ret.compCount = 1;
|
||||
ret.compType = CompType::UNorm;
|
||||
return ret;
|
||||
}
|
||||
else if(fmt == eGL_ALPHA || fmt == eGL_ALPHA8_EXT)
|
||||
{
|
||||
ret.compByteWidth = 1;
|
||||
ret.compCount = 1;
|
||||
ret.compType = CompType::UNorm;
|
||||
ret.type = ResourceFormatType::A8;
|
||||
return ret;
|
||||
}
|
||||
else if(fmt == eGL_LUMINANCE8_ALPHA8_EXT || fmt == eGL_LUMINANCE_ALPHA)
|
||||
{
|
||||
ret.compByteWidth = 1;
|
||||
@@ -2132,6 +2139,7 @@ GLenum MakeGLFormat(ResourceFormat fmt)
|
||||
case ResourceFormatType::ASTC: RDCERR("ASTC can't be decoded unambiguously"); break;
|
||||
case ResourceFormatType::PVRTC: RDCERR("PVRTC can't be decoded unambiguously"); break;
|
||||
case ResourceFormatType::S8: ret = eGL_STENCIL_INDEX8; break;
|
||||
case ResourceFormatType::A8: ret = eGL_ALPHA8_EXT; break;
|
||||
case ResourceFormatType::Undefined: return eGL_NONE;
|
||||
default: RDCERR("Unsupported resource format type %u", fmt.type); break;
|
||||
}
|
||||
|
||||
@@ -704,6 +704,7 @@ static std::string ResourceFormatName(const ResourceFormat &fmt)
|
||||
case ResourceFormatType::D32S8:
|
||||
return fmt.compType == CompType::Typeless ? "D32S8_TYPELESS" : "D32S8";
|
||||
case ResourceFormatType::S8: return "S8";
|
||||
case ResourceFormatType::A8: return "A8_UNORM";
|
||||
case ResourceFormatType::YUV8:
|
||||
case ResourceFormatType::YUV10:
|
||||
case ResourceFormatType::YUV12:
|
||||
|
||||
@@ -918,7 +918,8 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
{
|
||||
switch(td.format.type)
|
||||
{
|
||||
case ResourceFormatType::S8: bytesPerPixel = 1; break;
|
||||
case ResourceFormatType::S8:
|
||||
case ResourceFormatType::A8: bytesPerPixel = 1; break;
|
||||
case ResourceFormatType::R10G10B10A2:
|
||||
case ResourceFormatType::R9G9B9E5:
|
||||
case ResourceFormatType::R11G11B10:
|
||||
|
||||
Reference in New Issue
Block a user