From e85c8d19bfa2d545245ff61180e37a5f6d92ef8f Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 24 Aug 2017 10:37:16 +0100 Subject: [PATCH] Combine 'special' with 'specialFormat' as single resource format type * There was no good reason to have a flag indicating if the special format was valid or not. Now it's a single enum, with a value 'Regular' indicating that the compCount/compWidth/compType fully describe the format itself. * This makes code patterns easier as you no longer need to check for special then check for specialFormat, you can just test the type directly. --- qrenderdoc/Code/FormatElement.cpp | 34 +-- .../Code/Interface/CommonPipelineState.cpp | 2 +- qrenderdoc/Windows/BufferViewer.cpp | 52 ++-- qrenderdoc/Windows/MainWindow.cpp | 5 +- .../D3D11PipelineStateViewer.cpp | 21 +- .../D3D12PipelineStateViewer.cpp | 21 +- .../PipelineState/GLPipelineStateViewer.cpp | 12 +- qrenderdoc/Windows/PixelHistoryView.cpp | 15 +- qrenderdoc/Windows/TextureViewer.cpp | 73 +++--- renderdoc/api/replay/data_types.h | 33 ++- renderdoc/api/replay/replay_enums.h | 15 +- renderdoc/common/dds_readwrite.cpp | 242 +++++++++--------- renderdoc/core/image_viewer.cpp | 2 +- renderdoc/core/replay_proxy.cpp | 48 ++-- renderdoc/driver/d3d11/d3d11_analyse.cpp | 45 ++-- renderdoc/driver/d3d11/d3d11_debug.cpp | 9 +- renderdoc/driver/d3d11/d3d11_device.cpp | 2 +- renderdoc/driver/d3d12/d3d12_debug.cpp | 6 +- renderdoc/driver/d3d12/d3d12_device.cpp | 2 +- renderdoc/driver/dxgi/dxgi_common.cpp | 237 +++++++++-------- renderdoc/driver/gl/gl_common.cpp | 154 +++++------ renderdoc/driver/gl/gl_debug.cpp | 20 +- renderdoc/driver/gl/gl_replay.cpp | 21 +- renderdoc/driver/vulkan/vk_common.cpp | 146 ++++------- renderdoc/driver/vulkan/vk_core.cpp | 31 +-- renderdoc/driver/vulkan/vk_debug.cpp | 3 +- renderdoc/driver/vulkan/vk_replay.cpp | 3 +- renderdoc/replay/entry_points.cpp | 55 ++-- renderdoc/replay/replay_controller.cpp | 61 +++-- renderdoc/replay/replay_driver.cpp | 4 +- 30 files changed, 641 insertions(+), 733 deletions(-) diff --git a/qrenderdoc/Code/FormatElement.cpp b/qrenderdoc/Code/FormatElement.cpp index 635eee259..6fcf568e6 100644 --- a/qrenderdoc/Code/FormatElement.cpp +++ b/qrenderdoc/Code/FormatElement.cpp @@ -334,24 +334,21 @@ QList FormatElement::ParseFormatString(const QString &formatStrin fmt.compType = CompType::UInt; fmt.compCount = 4 * count; fmt.compByteWidth = 1; - fmt.special = true; - fmt.specialFormat = SpecialFormat::R10G10B10A2; + fmt.type = ResourceFormatType::R10G10B10A2; } else if(basetype == lit("unormten")) { fmt.compType = CompType::UInt; fmt.compCount = 4 * count; fmt.compByteWidth = 1; - fmt.special = true; - fmt.specialFormat = SpecialFormat::R10G10B10A2; + fmt.type = ResourceFormatType::R10G10B10A2; } else if(basetype == lit("floateleven")) { fmt.compType = CompType::Float; fmt.compCount = 3 * count; fmt.compByteWidth = 1; - fmt.special = true; - fmt.specialFormat = SpecialFormat::R11G11B10; + fmt.type = ResourceFormatType::R11G11B10; } else { @@ -467,7 +464,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons bool ok = true; - if(format.special && format.specialFormat == SpecialFormat::R5G5B5A1) + if(format.type == ResourceFormatType::R5G5B5A1) { uint16_t packed = readObj(data, end, ok); @@ -483,7 +480,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons ret[0] = tmp; } } - else if(format.special && format.specialFormat == SpecialFormat::R5G6B5) + else if(format.type == ResourceFormatType::R5G6B5) { uint16_t packed = readObj(data, end, ok); @@ -498,7 +495,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons ret[0] = tmp; } } - else if(format.special && format.specialFormat == SpecialFormat::R4G4B4A4) + else if(format.type == ResourceFormatType::R4G4B4A4) { uint16_t packed = readObj(data, end, ok); @@ -514,7 +511,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons ret[0] = tmp; } } - else if(format.special && format.specialFormat == SpecialFormat::R10G10B10A2) + else if(format.type == ResourceFormatType::R10G10B10A2) { // allow for vectors of this format - for raw buffer viewer for(int i = 0; i < int(format.compCount / 4); i++) @@ -597,7 +594,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons } } } - else if(format.special && format.specialFormat == SpecialFormat::R11G11B10) + else if(format.type == ResourceFormatType::R11G11B10) { uint32_t packed = readObj(data, end, ok); @@ -813,17 +810,12 @@ uint32_t FormatElement::byteSize() const { uint32_t vecSize = format.compByteWidth * format.compCount; - if(format.special) - { - if(format.specialFormat == SpecialFormat::R5G5B5A1 || - format.specialFormat == SpecialFormat::R5G6B5 || - format.specialFormat == SpecialFormat::R4G4B4A4) - vecSize = 2; + if(format.type == ResourceFormatType::R5G5B5A1 || format.type == ResourceFormatType::R5G6B5 || + format.type == ResourceFormatType::R4G4B4A4) + vecSize = 2; - if(format.specialFormat == SpecialFormat::R10G10B10A2 || - format.specialFormat == SpecialFormat::R11G11B10) - vecSize = 4; - } + if(format.type == ResourceFormatType::R10G10B10A2 || format.type == ResourceFormatType::R11G11B10) + vecSize = 4; return vecSize * matrixdim; } diff --git a/qrenderdoc/Code/Interface/CommonPipelineState.cpp b/qrenderdoc/Code/Interface/CommonPipelineState.cpp index 06e3d4500..8000a20be 100644 --- a/qrenderdoc/Code/Interface/CommonPipelineState.cpp +++ b/qrenderdoc/Code/Interface/CommonPipelineState.cpp @@ -808,7 +808,7 @@ QVector CommonPipelineState::GetVertexInputs() ret[a].Format.compByteWidth = 4; ret[a].Format.compCount = compCount; ret[a].Format.compType = compType; - ret[a].Format.special = false; + ret[a].Format.type = ResourceFormatType::Regular; ret[a].Format.srgbCorrected = false; } } diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 0456e68bc..1ca60efab 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -794,30 +794,30 @@ private: uint32_t compCount; - switch(fmt.format.specialFormat) + switch(fmt.format.type) { - case SpecialFormat::BC6: - case SpecialFormat::ETC2: - case SpecialFormat::R11G11B10: - case SpecialFormat::R5G6B5: - case SpecialFormat::R9G9B9E5: compCount = 3; break; - case SpecialFormat::BC1: - case SpecialFormat::BC7: - case SpecialFormat::BC3: - case SpecialFormat::BC2: - case SpecialFormat::R10G10B10A2: - case SpecialFormat::R5G5B5A1: - case SpecialFormat::R4G4B4A4: - case SpecialFormat::ASTC: compCount = 4; break; - case SpecialFormat::BC5: - case SpecialFormat::R4G4: - case SpecialFormat::D16S8: - case SpecialFormat::D24S8: - case SpecialFormat::D32S8: compCount = 2; break; - case SpecialFormat::BC4: - case SpecialFormat::S8: compCount = 1; break; - case SpecialFormat::YUV: - case SpecialFormat::EAC: + case ResourceFormatType::BC6: + case ResourceFormatType::ETC2: + case ResourceFormatType::R11G11B10: + case ResourceFormatType::R5G6B5: + case ResourceFormatType::R9G9B9E5: compCount = 3; break; + case ResourceFormatType::BC1: + case ResourceFormatType::BC7: + case ResourceFormatType::BC3: + case ResourceFormatType::BC2: + case ResourceFormatType::R10G10B10A2: + case ResourceFormatType::R5G5B5A1: + case ResourceFormatType::R4G4B4A4: + case ResourceFormatType::ASTC: compCount = 4; break; + case ResourceFormatType::BC5: + case ResourceFormatType::R4G4: + case ResourceFormatType::D16S8: + case ResourceFormatType::D24S8: + case ResourceFormatType::D32S8: compCount = 2; break; + case ResourceFormatType::BC4: + case ResourceFormatType::S8: compCount = 1; break; + case ResourceFormatType::YUV: + case ResourceFormatType::EAC: default: compCount = fmt.format.compCount; } @@ -866,7 +866,7 @@ private: else if(vt == QMetaType::UInt || vt == QMetaType::UShort || vt == QMetaType::UChar) { uint u = v.toUInt(); - if(el.hex && el.format.specialFormat == SpecialFormat::Unknown) + if(el.hex && el.format.type == ResourceFormatType::Regular) ret = Formatter::HexFormat(u, el.format.compByteWidth); else ret = Formatter::Format(u, el.hex); @@ -2208,7 +2208,7 @@ void BufferViewer::configureMeshColumns() f.format.compByteWidth = sizeof(float); f.format.compCount = sig.compCount; f.format.compType = sig.compType; - f.format.special = false; + f.format.type = ResourceFormatType::Regular; f.perinstance = false; f.instancerate = 1; f.rowmajor = false; @@ -2275,7 +2275,7 @@ void BufferViewer::configureMeshColumns() f.format.compByteWidth = sizeof(float); f.format.compCount = sig.compCount; f.format.compType = sig.compType; - f.format.special = false; + f.format.type = ResourceFormatType::Regular; f.perinstance = false; f.instancerate = 1; f.rowmajor = false; diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index e3a86f721..283929688 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -1553,9 +1553,8 @@ void MainWindow::on_action_Start_Replay_Loop_triggered() for(const TextureDescription &tex : m_Ctx.GetTextures()) { if((tex.creationFlags & TextureCategory::SwapBuffer) && - tex.format.compType != CompType::Depth && tex.format.specialFormat != SpecialFormat::D16S8 && - tex.format.specialFormat != SpecialFormat::D24S8 && - tex.format.specialFormat != SpecialFormat::D32S8) + tex.format.compType != CompType::Depth && tex.format.type != ResourceFormatType::D16S8 && + tex.format.type != ResourceFormatType::D24S8 && tex.format.type != ResourceFormatType::D32S8) { displayTex = &tex; break; diff --git a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp index 604485ab6..1ef805c8c 100644 --- a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp @@ -1945,19 +1945,16 @@ void D3D11PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in else { const ResourceFormat &fmt = view.res.Format; - if(fmt.special) + if(fmt.type == ResourceFormatType::R10G10B10A2) { - if(fmt.specialFormat == SpecialFormat::R10G10B10A2) - { - if(fmt.compType == CompType::UInt) - format = lit("uintten"); - if(fmt.compType == CompType::UNorm) - format = lit("unormten"); - } - else if(fmt.specialFormat == SpecialFormat::R11G11B10) - { - format = lit("floateleven"); - } + if(fmt.compType == CompType::UInt) + format = lit("uintten"); + if(fmt.compType == CompType::UNorm) + format = lit("unormten"); + } + else if(fmt.type == ResourceFormatType::R11G11B10) + { + format = lit("floateleven"); } else { diff --git a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp index 6adbe96fa..fd47a19e5 100644 --- a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp @@ -1818,19 +1818,16 @@ void D3D12PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in else { const ResourceFormat &fmt = view.res.Format; - if(fmt.special) + if(fmt.type == ResourceFormatType::R10G10B10A2) { - if(fmt.specialFormat == SpecialFormat::R10G10B10A2) - { - if(fmt.compType == CompType::UInt) - format = lit("uintten"); - if(fmt.compType == CompType::UNorm) - format = lit("unormten"); - } - else if(fmt.specialFormat == SpecialFormat::R11G11B10) - { - format = lit("floateleven"); - } + if(fmt.compType == CompType::UInt) + format = lit("uintten"); + if(fmt.compType == CompType::UNorm) + format = lit("unormten"); + } + else if(fmt.type == ResourceFormatType::R11G11B10) + { + format = lit("floateleven"); } else { diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp index ef12d4754..7b7141e2e 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp @@ -676,9 +676,9 @@ void GLPipelineStateViewer::setShaderState(const GLPipe::Shader &stage, QLabel * name = tex->name; typeName = ToQStr(tex->resType); - if(tex->format.special && (tex->format.specialFormat == SpecialFormat::D16S8 || - tex->format.specialFormat == SpecialFormat::D24S8 || - tex->format.specialFormat == SpecialFormat::D32S8)) + if(tex->format.type == ResourceFormatType::D16S8 || + tex->format.type == ResourceFormatType::D24S8 || + tex->format.type == ResourceFormatType::D32S8) { if(r.DepthReadChannel == 0) format += tr(" Depth-Read"); @@ -2535,9 +2535,9 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const GLPipe::Shad name = tex->name; typeName = ToQStr(tex->resType); - if(tex->format.special && (tex->format.specialFormat == SpecialFormat::D16S8 || - tex->format.specialFormat == SpecialFormat::D24S8 || - tex->format.specialFormat == SpecialFormat::D32S8)) + if(tex->format.type == ResourceFormatType::D16S8 || + tex->format.type == ResourceFormatType::D24S8 || + tex->format.type == ResourceFormatType::D32S8) { if(r.DepthReadChannel == 0) format += tr(" Depth-Repipead"); diff --git a/qrenderdoc/Windows/PixelHistoryView.cpp b/qrenderdoc/Windows/PixelHistoryView.cpp index 79e57edda..c501ea811 100644 --- a/qrenderdoc/Windows/PixelHistoryView.cpp +++ b/qrenderdoc/Windows/PixelHistoryView.cpp @@ -60,16 +60,13 @@ public: if(compType == CompType::Depth) m_IsDepth = true; - if(m_Tex->format.special) + switch(m_Tex->format.type) { - switch(m_Tex->format.specialFormat) - { - case SpecialFormat::D16S8: - case SpecialFormat::D24S8: - case SpecialFormat::D32S8: - case SpecialFormat::S8: m_IsDepth = true; break; - default: break; - } + case ResourceFormatType::D16S8: + case ResourceFormatType::D24S8: + case ResourceFormatType::D32S8: + case ResourceFormatType::S8: m_IsDepth = true; break; + default: break; } } diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 047f4c0d1..1a0cfe12a 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -1344,7 +1344,7 @@ void TextureViewer::UI_UpdateChannels() // swapbuffer is always srgb for 8-bit types, linear for 16-bit types DISABLE(ui->gammaDisplay); - if(tex->format.compByteWidth == 2 && !tex->format.special) + if(tex->format.compByteWidth == 2 && tex->format.type == ResourceFormatType::Regular) m_TexDisplay.linearDisplayAsGamma = false; else m_TexDisplay.linearDisplayAsGamma = true; @@ -3264,27 +3264,27 @@ void TextureViewer::on_viewTexBuffer_clicked() uint32_t w = texptr->width; - switch(texptr->format.specialFormat) + switch(texptr->format.type) { - case SpecialFormat::BC1: - case SpecialFormat::BC2: - case SpecialFormat::BC3: - case SpecialFormat::BC4: - case SpecialFormat::BC5: - case SpecialFormat::BC6: - case SpecialFormat::BC7: - case SpecialFormat::ETC2: - case SpecialFormat::EAC: - case SpecialFormat::ASTC: + case ResourceFormatType::BC1: + case ResourceFormatType::BC2: + case ResourceFormatType::BC3: + case ResourceFormatType::BC4: + case ResourceFormatType::BC5: + case ResourceFormatType::BC6: + case ResourceFormatType::BC7: + case ResourceFormatType::ETC2: + case ResourceFormatType::EAC: + case ResourceFormatType::ASTC: varName = lit("block"); // display a 4x4 block at a time w /= 4; default: break; } - switch(texptr->format.specialFormat) + switch(texptr->format.type) { - case SpecialFormat::Unknown: + case ResourceFormatType::Regular: { if(texptr->format.compByteWidth == 1) baseType = lit("byte"); @@ -3298,31 +3298,32 @@ void TextureViewer::on_viewTexBuffer_clicked() break; } // 2x4 byte block, for 64-bit block formats - case SpecialFormat::BC1: - case SpecialFormat::BC4: - case SpecialFormat::ETC2: - case SpecialFormat::EAC: + case ResourceFormatType::BC1: + case ResourceFormatType::BC4: + case ResourceFormatType::ETC2: + case ResourceFormatType::EAC: baseType = lit("row_major xint2x1"); break; // 4x4 byte block, for 128-bit block formats - case SpecialFormat::BC2: - case SpecialFormat::BC3: - case SpecialFormat::BC5: - case SpecialFormat::BC6: - case SpecialFormat::BC7: - case SpecialFormat::ASTC: baseType = lit("row_major xint4x1"); break; - case SpecialFormat::R10G10B10A2: baseType = lit("uintten"); break; - case SpecialFormat::R11G11B10: baseType = lit("rgb floateleven"); break; - case SpecialFormat::R5G6B5: - case SpecialFormat::R5G5B5A1: baseType = lit("xshort"); break; - case SpecialFormat::R9G9B9E5: baseType = lit("xint"); break; - case SpecialFormat::R4G4B4A4: baseType = lit("xbyte2"); break; - case SpecialFormat::R4G4: baseType = lit("xbyte"); break; - case SpecialFormat::D16S8: - case SpecialFormat::D24S8: - case SpecialFormat::D32S8: - case SpecialFormat::YUV: baseType = lit("xint4"); break; - case SpecialFormat::S8: baseType = lit("xbyte"); break; + case ResourceFormatType::BC2: + case ResourceFormatType::BC3: + case ResourceFormatType::BC5: + case ResourceFormatType::BC6: + case ResourceFormatType::BC7: + case ResourceFormatType::ASTC: baseType = lit("row_major xint4x1"); break; + case ResourceFormatType::R10G10B10A2: baseType = lit("uintten"); break; + case ResourceFormatType::R11G11B10: baseType = lit("rgb floateleven"); break; + case ResourceFormatType::R5G6B5: + case ResourceFormatType::R5G5B5A1: baseType = lit("xshort"); break; + case ResourceFormatType::R9G9B9E5: baseType = lit("xint"); break; + case ResourceFormatType::R4G4B4A4: baseType = lit("xbyte2"); break; + case ResourceFormatType::R4G4: baseType = lit("xbyte"); break; + case ResourceFormatType::D16S8: + case ResourceFormatType::D24S8: + case ResourceFormatType::D32S8: + case ResourceFormatType::YUV: baseType = lit("xint4"); break; + case ResourceFormatType::S8: + case ResourceFormatType::Undefined: baseType = lit("xbyte"); break; } QString format = QFormatStr("%1 %2[%3];").arg(baseType).arg(varName).arg(w); diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index baf9ac579..47d872592 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -75,11 +75,10 @@ struct ResourceFormat { ResourceFormat() { - special = true; - specialFormat = SpecialFormat::Unknown; + type = ResourceFormatType::Undefined; compCount = compByteWidth = 0; - compType = CompType::Float; + compType = CompType::Typeless; bgraOrder = false; srgbCorrected = false; @@ -88,13 +87,12 @@ struct ResourceFormat DOCUMENT("Compares two ``ResourceFormat`` objects for equality."); bool operator==(const ResourceFormat &r) const { - if(special || r.special) - return special == r.special && specialFormat == r.specialFormat && compType == r.compType; - - return compCount == r.compCount && compByteWidth == r.compByteWidth && compType == r.compType && - bgraOrder == r.bgraOrder && srgbCorrected == r.srgbCorrected; + return type == r.type && compCount == r.compCount && compByteWidth == r.compByteWidth && + compType == r.compType && bgraOrder == r.bgraOrder && srgbCorrected == r.srgbCorrected; } + DOCUMENT("Compares two ``ResourceFormat`` objects for inequality."); + bool operator!=(const ResourceFormat &r) const { return !(*this == r); } DOCUMENT(R"(:return: The name of the format. :rtype: str )"); @@ -104,16 +102,17 @@ struct ResourceFormat RENDERDOC_ResourceFormatName(*this, ret); return ret; } - DOCUMENT("Compares two ``ResourceFormat`` objects for inequality."); - bool operator!=(const ResourceFormat &r) const { return !(*this == r); } - // indicates it's not a type represented with the members below - // usually this means non-uniform across components or block compressed - DOCUMENT("``True`` if :data:`specialFormat` is valid."); - bool32 special; - DOCUMENT("The :class:`SpecialFormat` if it's a non-uniform layout like block-compressed."); - SpecialFormat specialFormat; - DOCUMENT("The number of components in each vertex."); + DOCUMENT(R"(:return: ``True`` if the ``ResourceFormat`` is a 'special' non-regular type. +:type: bool +)"); + bool Special() const { return type != ResourceFormatType::Regular; } + DOCUMENT(R"(The :class:`ResourceFormatType` of this format. If the value is not +:data:`ResourceFormatType.Regular` then it's a non-uniform layout like block-compressed. +)"); + ResourceFormatType type; + + DOCUMENT("The number of components in each element."); uint32_t compCount; DOCUMENT("The width in bytes of each component."); uint32_t compByteWidth; diff --git a/renderdoc/api/replay/replay_enums.h b/renderdoc/api/replay/replay_enums.h index d81ea6480..d66c55cc1 100644 --- a/renderdoc/api/replay/replay_enums.h +++ b/renderdoc/api/replay/replay_enums.h @@ -978,14 +978,18 @@ enum class AlphaMapping : uint32_t ITERABLE_OPERATORS(AlphaMapping); -DOCUMENT(R"(A particular special texture format. This accounts for either block-compressed formats +DOCUMENT(R"(A resource format's particular type. This accounts for either block-compressed textures or formats that don't have equal byte-multiple sizes for each channel. -.. data:: Unknown +.. data:: Regular - This texture has no special layout, so its format is described by a number of components, a + This format has no special layout, so its format is described by a number of components, a :class:`CompType` and a byte width per component. +.. data:: Undefined + + This format is undefined or unknown, or does not map to any known regular format. + .. data:: BC1 A block-compressed texture in ``BC1`` format (RGB with 1-bit alpha, 0.5 bytes per pixel) @@ -1112,9 +1116,10 @@ or formats that don't have equal byte-multiple sizes for each channel. The pixel data is in an opaque YUV format. )"); -enum class SpecialFormat : uint32_t +enum class ResourceFormatType : uint32_t { - Unknown = 0, + Regular = 0, + Undefined, BC1, BC2, BC3, diff --git a/renderdoc/common/dds_readwrite.cpp b/renderdoc/common/dds_readwrite.cpp index 7af62dfdc..bd4d3f659 100644 --- a/renderdoc/common/dds_readwrite.cpp +++ b/renderdoc/common/dds_readwrite.cpp @@ -235,84 +235,78 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format) fmt32.compByteWidth = 4; fmt32.compCount = 1; fmt32.compType = CompType::Float; - fmt32.special = false; + fmt32.type = ResourceFormatType::Regular; fmt16.compByteWidth = 2; fmt16.compCount = 1; fmt16.compType = CompType::Float; - fmt16.special = false; + fmt16.type = ResourceFormatType::Regular; fmt8.compByteWidth = 1; fmt8.compCount = 1; fmt8.compType = CompType::UNorm; - fmt8.special = false; + fmt8.type = ResourceFormatType::Regular; switch(format) { case DXGI_FORMAT_BC1_UNORM: case DXGI_FORMAT_BC1_UNORM_SRGB: - special.specialFormat = SpecialFormat::BC1; + special.type = ResourceFormatType::BC1; special.srgbCorrected = (format == DXGI_FORMAT_BC1_UNORM_SRGB ? true : false); return special; case DXGI_FORMAT_BC2_UNORM: case DXGI_FORMAT_BC2_UNORM_SRGB: - special.specialFormat = SpecialFormat::BC2; + special.type = ResourceFormatType::BC2; special.srgbCorrected = (format == DXGI_FORMAT_BC2_UNORM_SRGB ? true : false); return special; case DXGI_FORMAT_BC3_UNORM: case DXGI_FORMAT_BC3_UNORM_SRGB: - special.specialFormat = SpecialFormat::BC3; + special.type = ResourceFormatType::BC3; special.srgbCorrected = (format == DXGI_FORMAT_BC3_UNORM_SRGB ? true : false); return special; case DXGI_FORMAT_BC4_UNORM: case DXGI_FORMAT_BC4_SNORM: - special.specialFormat = SpecialFormat::BC4; + special.type = ResourceFormatType::BC4; special.compType = (format == DXGI_FORMAT_BC4_UNORM ? CompType::UNorm : CompType::SNorm); return special; case DXGI_FORMAT_BC5_UNORM: case DXGI_FORMAT_BC5_SNORM: - special.specialFormat = SpecialFormat::BC5; + special.type = ResourceFormatType::BC5; special.compType = (format == DXGI_FORMAT_BC5_UNORM ? CompType::UNorm : CompType::SNorm); return special; case DXGI_FORMAT_BC6H_UF16: case DXGI_FORMAT_BC6H_SF16: - special.specialFormat = SpecialFormat::BC6; + special.type = ResourceFormatType::BC6; special.compType = (format == DXGI_FORMAT_BC6H_UF16 ? CompType::UNorm : CompType::SNorm); return special; case DXGI_FORMAT_BC7_UNORM: case DXGI_FORMAT_BC7_UNORM_SRGB: - special.specialFormat = SpecialFormat::BC7; + special.type = ResourceFormatType::BC7; special.srgbCorrected = (format == DXGI_FORMAT_BC7_UNORM_SRGB ? true : false); return special; case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT: - special.specialFormat = SpecialFormat::R10G10B10A2; + special.type = ResourceFormatType::R10G10B10A2; special.compType = (format == DXGI_FORMAT_R10G10B10A2_UNORM ? CompType::UNorm : CompType::UInt); return special; - case DXGI_FORMAT_R11G11B10_FLOAT: - special.specialFormat = SpecialFormat::R11G11B10; - return special; + case DXGI_FORMAT_R11G11B10_FLOAT: special.type = ResourceFormatType::R11G11B10; return special; case DXGI_FORMAT_B5G6R5_UNORM: fmt8.bgraOrder = true; - special.specialFormat = SpecialFormat::R5G6B5; + special.type = ResourceFormatType::R5G6B5; return special; case DXGI_FORMAT_B5G5R5A1_UNORM: fmt8.bgraOrder = true; - special.specialFormat = SpecialFormat::R5G5B5A1; + special.type = ResourceFormatType::R5G5B5A1; return special; case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - special.specialFormat = SpecialFormat::R9G9B9E5; + special.type = ResourceFormatType::R9G9B9E5; return special; case DXGI_FORMAT_B4G4R4A4_UNORM: fmt8.bgraOrder = true; - special.specialFormat = SpecialFormat::R4G4B4A4; - return special; - case DXGI_FORMAT_D24_UNORM_S8_UINT: - special.specialFormat = SpecialFormat::D24S8; - return special; - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - special.specialFormat = SpecialFormat::D32S8; + special.type = ResourceFormatType::R4G4B4A4; return special; + case DXGI_FORMAT_D24_UNORM_S8_UINT: special.type = ResourceFormatType::D24S8; return special; + case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: special.type = ResourceFormatType::D32S8; return special; case DXGI_FORMAT_R32G32B32A32_UINT: fmt32.compType = CompType::UInt; @@ -443,43 +437,47 @@ ResourceFormat DXGIFormat2ResourceFormat(DXGI_FORMAT format) DXGI_FORMAT ResourceFormat2DXGIFormat(ResourceFormat format) { - if(format.special) + if(format.Special()) { - switch(format.specialFormat) + switch(format.type) { - case SpecialFormat::BC1: + case ResourceFormatType::BC1: return format.srgbCorrected ? DXGI_FORMAT_BC1_UNORM_SRGB : DXGI_FORMAT_BC1_UNORM; - case SpecialFormat::BC2: + case ResourceFormatType::BC2: return format.srgbCorrected ? DXGI_FORMAT_BC2_UNORM_SRGB : DXGI_FORMAT_BC2_UNORM; - case SpecialFormat::BC3: + case ResourceFormatType::BC3: return format.srgbCorrected ? DXGI_FORMAT_BC3_UNORM_SRGB : DXGI_FORMAT_BC3_UNORM; - case SpecialFormat::BC4: + case ResourceFormatType::BC4: return format.compType == CompType::UNorm ? DXGI_FORMAT_BC4_UNORM : DXGI_FORMAT_BC4_SNORM; - case SpecialFormat::BC5: + case ResourceFormatType::BC5: return format.compType == CompType::UNorm ? DXGI_FORMAT_BC5_UNORM : DXGI_FORMAT_BC5_SNORM; - case SpecialFormat::BC6: + case ResourceFormatType::BC6: return format.compType == CompType::UNorm ? DXGI_FORMAT_BC6H_UF16 : DXGI_FORMAT_BC6H_SF16; - case SpecialFormat::BC7: + case ResourceFormatType::BC7: return format.srgbCorrected ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; - case SpecialFormat::R10G10B10A2: + case ResourceFormatType::R10G10B10A2: return format.compType == CompType::UNorm ? DXGI_FORMAT_R10G10B10A2_UNORM : DXGI_FORMAT_R10G10B10A2_UINT; - case SpecialFormat::R11G11B10: return DXGI_FORMAT_R11G11B10_FLOAT; - case SpecialFormat::R5G6B5: RDCASSERT(format.bgraOrder); return DXGI_FORMAT_B5G6R5_UNORM; - case SpecialFormat::R5G5B5A1: RDCASSERT(format.bgraOrder); return DXGI_FORMAT_B5G5R5A1_UNORM; - case SpecialFormat::R9G9B9E5: return DXGI_FORMAT_R9G9B9E5_SHAREDEXP; - case SpecialFormat::R4G4B4A4: RDCASSERT(format.bgraOrder); return DXGI_FORMAT_B4G4R4A4_UNORM; - case SpecialFormat::D24S8: return DXGI_FORMAT_D24_UNORM_S8_UINT; - case SpecialFormat::D32S8: return DXGI_FORMAT_D32_FLOAT_S8X24_UINT; - case SpecialFormat::S8: return DXGI_FORMAT_R8_UINT; + case ResourceFormatType::R11G11B10: return DXGI_FORMAT_R11G11B10_FLOAT; + case ResourceFormatType::R5G6B5: RDCASSERT(format.bgraOrder); return DXGI_FORMAT_B5G6R5_UNORM; + case ResourceFormatType::R5G5B5A1: + RDCASSERT(format.bgraOrder); + return DXGI_FORMAT_B5G5R5A1_UNORM; + case ResourceFormatType::R9G9B9E5: return DXGI_FORMAT_R9G9B9E5_SHAREDEXP; + case ResourceFormatType::R4G4B4A4: + RDCASSERT(format.bgraOrder); + return DXGI_FORMAT_B4G4R4A4_UNORM; + 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; default: - case SpecialFormat::R4G4: - case SpecialFormat::D16S8: - case SpecialFormat::ETC2: - case SpecialFormat::EAC: - case SpecialFormat::ASTC: - case SpecialFormat::YUV: - RDCERR("Unsupported writing format %u", format.specialFormat); + case ResourceFormatType::R4G4: + case ResourceFormatType::D16S8: + case ResourceFormatType::ETC2: + case ResourceFormatType::EAC: + case ResourceFormatType::ASTC: + case ResourceFormatType::YUV: + RDCERR("Unsupported writing format %u", format.type); return DXGI_FORMAT_UNKNOWN; } } @@ -651,22 +649,22 @@ bool write_dds_to_file(FILE *f, const dds_data &data) bool blockFormat = false; - if(data.format.special) + if(data.format.Special()) { - switch(data.format.specialFormat) + switch(data.format.type) { - case SpecialFormat::BC1: - case SpecialFormat::BC2: - case SpecialFormat::BC3: - case SpecialFormat::BC4: - case SpecialFormat::BC5: - case SpecialFormat::BC6: - case SpecialFormat::BC7: blockFormat = true; break; - case SpecialFormat::ETC2: - case SpecialFormat::EAC: - case SpecialFormat::ASTC: - case SpecialFormat::YUV: - RDCERR("Unsupported file format, %u", data.format.specialFormat); + case ResourceFormatType::BC1: + case ResourceFormatType::BC2: + case ResourceFormatType::BC3: + case ResourceFormatType::BC4: + case ResourceFormatType::BC5: + case ResourceFormatType::BC6: + case ResourceFormatType::BC7: blockFormat = true; break; + case ResourceFormatType::ETC2: + case ResourceFormatType::EAC: + case ResourceFormatType::ASTC: + case ResourceFormatType::YUV: + RDCERR("Unsupported file format, %u", data.format.type); return false; default: break; } @@ -713,29 +711,29 @@ bool write_dds_to_file(FILE *f, const dds_data &data) if(blockFormat) { - int blockSize = (data.format.specialFormat == SpecialFormat::BC1 || - data.format.specialFormat == SpecialFormat::BC4) - ? 8 - : 16; + int blockSize = + (data.format.type == ResourceFormatType::BC1 || data.format.type == ResourceFormatType::BC4) + ? 8 + : 16; header.dwPitchOrLinearSize = RDCMAX(1U, ((header.dwWidth + 3) / 4)) * blockSize; } else { - switch(data.format.specialFormat) + switch(data.format.type) { - case SpecialFormat::S8: bytesPerPixel = 1; break; - case SpecialFormat::R10G10B10A2: - case SpecialFormat::R9G9B9E5: - case SpecialFormat::R11G11B10: - case SpecialFormat::D24S8: bytesPerPixel = 4; break; - case SpecialFormat::R5G6B5: - case SpecialFormat::R5G5B5A1: - case SpecialFormat::R4G4B4A4: bytesPerPixel = 2; break; - case SpecialFormat::D32S8: bytesPerPixel = 8; break; - case SpecialFormat::D16S8: - case SpecialFormat::YUV: - case SpecialFormat::R4G4: - RDCERR("Unsupported file format %u", data.format.specialFormat); + case ResourceFormatType::S8: bytesPerPixel = 1; break; + case ResourceFormatType::R10G10B10A2: + case ResourceFormatType::R9G9B9E5: + case ResourceFormatType::R11G11B10: + case ResourceFormatType::D24S8: bytesPerPixel = 4; break; + case ResourceFormatType::R5G6B5: + case ResourceFormatType::R5G5B5A1: + case ResourceFormatType::R4G4B4A4: bytesPerPixel = 2; break; + case ResourceFormatType::D32S8: bytesPerPixel = 8; break; + case ResourceFormatType::D16S8: + case ResourceFormatType::YUV: + case ResourceFormatType::R4G4: + RDCERR("Unsupported file format %u", data.format.type); return false; default: bytesPerPixel = data.format.compCount * data.format.compByteWidth; } @@ -758,37 +756,37 @@ bool write_dds_to_file(FILE *f, const dds_data &data) if(data.format.bgraOrder) std::swap(header.ddspf.dwRBitMask, header.ddspf.dwBBitMask); } - else if(data.format.specialFormat == SpecialFormat::BC1) + else if(data.format.type == ResourceFormatType::BC1) { header.ddspf.dwFlags = DDPF_FOURCC; header.ddspf.dwFourCC = MAKE_FOURCC('D', 'X', 'T', '1'); } - else if(data.format.specialFormat == SpecialFormat::BC2) + else if(data.format.type == ResourceFormatType::BC2) { header.ddspf.dwFlags = DDPF_FOURCC; header.ddspf.dwFourCC = MAKE_FOURCC('D', 'X', 'T', '3'); } - else if(data.format.specialFormat == SpecialFormat::BC3) + else if(data.format.type == ResourceFormatType::BC3) { header.ddspf.dwFlags = DDPF_FOURCC; header.ddspf.dwFourCC = MAKE_FOURCC('D', 'X', 'T', '5'); } - else if(data.format.specialFormat == SpecialFormat::BC4 && data.format.compType == CompType::UNorm) + else if(data.format.type == ResourceFormatType::BC4 && data.format.compType == CompType::UNorm) { header.ddspf.dwFlags = DDPF_FOURCC; header.ddspf.dwFourCC = MAKE_FOURCC('B', 'C', '4', 'U'); } - else if(data.format.specialFormat == SpecialFormat::BC4 && data.format.compType == CompType::SNorm) + else if(data.format.type == ResourceFormatType::BC4 && data.format.compType == CompType::SNorm) { header.ddspf.dwFlags = DDPF_FOURCC; header.ddspf.dwFourCC = MAKE_FOURCC('B', 'C', '4', 'S'); } - else if(data.format.specialFormat == SpecialFormat::BC5 && data.format.compType == CompType::UNorm) + else if(data.format.type == ResourceFormatType::BC5 && data.format.compType == CompType::UNorm) { header.ddspf.dwFlags = DDPF_FOURCC; header.ddspf.dwFourCC = MAKE_FOURCC('A', 'T', 'I', '2'); } - else if(data.format.specialFormat == SpecialFormat::BC5 && data.format.compType == CompType::SNorm) + else if(data.format.type == ResourceFormatType::BC5 && data.format.compType == CompType::SNorm) { header.ddspf.dwFlags = DDPF_FOURCC; header.ddspf.dwFourCC = MAKE_FOURCC('B', 'C', '5', 'S'); @@ -830,8 +828,8 @@ bool write_dds_to_file(FILE *f, const dds_data &data) { numRows = RDCMAX(1, numRows / 4); - int blockSize = (data.format.specialFormat == SpecialFormat::BC1 || - data.format.specialFormat == SpecialFormat::BC4) + int blockSize = (data.format.type == ResourceFormatType::BC1 || + data.format.type == ResourceFormatType::BC4) ? 8 : 16; @@ -908,7 +906,7 @@ dds_data load_dds_from_file(FILE *f) if(dx10Header) { ret.format = DXGIFormat2ResourceFormat(headerDXT10.dxgiFormat); - if(ret.format.special && ret.format.specialFormat == SpecialFormat::Unknown) + if(ret.format.type == ResourceFormatType::Undefined) { RDCWARN("Unsupported DXGI_FORMAT: %u", (uint32_t)headerDXT10.dxgiFormat); return error; @@ -970,50 +968,50 @@ dds_data load_dds_from_file(FILE *f) ret.format.compByteWidth = 1; ret.format.compCount = header.ddspf.dwRGBBitCount / 8; ret.format.compType = CompType::UNorm; - ret.format.special = false; + ret.format.type = ResourceFormatType::Regular; if(header.ddspf.dwBBitMask < header.ddspf.dwRBitMask) ret.format.bgraOrder = true; } uint32_t bytesPerPixel = 1; - switch(ret.format.specialFormat) + switch(ret.format.type) { - case SpecialFormat::S8: bytesPerPixel = 1; break; - case SpecialFormat::R10G10B10A2: - case SpecialFormat::R9G9B9E5: - case SpecialFormat::R11G11B10: - case SpecialFormat::D24S8: bytesPerPixel = 4; break; - case SpecialFormat::R5G6B5: - case SpecialFormat::R5G5B5A1: - case SpecialFormat::R4G4B4A4: bytesPerPixel = 2; break; - case SpecialFormat::D32S8: bytesPerPixel = 8; break; - case SpecialFormat::D16S8: - case SpecialFormat::YUV: - case SpecialFormat::R4G4: - RDCERR("Unsupported file format %u", ret.format.specialFormat); + case ResourceFormatType::S8: bytesPerPixel = 1; break; + case ResourceFormatType::R10G10B10A2: + case ResourceFormatType::R9G9B9E5: + case ResourceFormatType::R11G11B10: + case ResourceFormatType::D24S8: bytesPerPixel = 4; break; + case ResourceFormatType::R5G6B5: + case ResourceFormatType::R5G5B5A1: + case ResourceFormatType::R4G4B4A4: bytesPerPixel = 2; break; + case ResourceFormatType::D32S8: bytesPerPixel = 8; break; + case ResourceFormatType::D16S8: + case ResourceFormatType::YUV: + case ResourceFormatType::R4G4: + RDCERR("Unsupported file format %u", ret.format.type); return error; default: bytesPerPixel = ret.format.compCount * ret.format.compByteWidth; } bool blockFormat = false; - if(ret.format.special) + if(ret.format.Special()) { - switch(ret.format.specialFormat) + switch(ret.format.type) { - case SpecialFormat::BC1: - case SpecialFormat::BC2: - case SpecialFormat::BC3: - case SpecialFormat::BC4: - case SpecialFormat::BC5: - case SpecialFormat::BC6: - case SpecialFormat::BC7: blockFormat = true; break; - case SpecialFormat::ETC2: - case SpecialFormat::EAC: - case SpecialFormat::ASTC: - case SpecialFormat::YUV: - RDCERR("Unsupported file format, %u", ret.format.specialFormat); + case ResourceFormatType::BC1: + case ResourceFormatType::BC2: + case ResourceFormatType::BC3: + case ResourceFormatType::BC4: + case ResourceFormatType::BC5: + case ResourceFormatType::BC6: + case ResourceFormatType::BC7: blockFormat = true; break; + case ResourceFormatType::ETC2: + case ResourceFormatType::EAC: + case ResourceFormatType::ASTC: + case ResourceFormatType::YUV: + RDCERR("Unsupported file format, %u", ret.format.type); return error; default: break; } @@ -1037,8 +1035,8 @@ dds_data load_dds_from_file(FILE *f) { numRows = RDCMAX(1, numRows / 4); - int blockSize = (ret.format.specialFormat == SpecialFormat::BC1 || - ret.format.specialFormat == SpecialFormat::BC4) + int blockSize = (ret.format.type == ResourceFormatType::BC1 || + ret.format.type == ResourceFormatType::BC4) ? 8 : 16; diff --git a/renderdoc/core/image_viewer.cpp b/renderdoc/core/image_viewer.cpp index b23589a67..cbb9e3999 100644 --- a/renderdoc/core/image_viewer.cpp +++ b/renderdoc/core/image_viewer.cpp @@ -418,7 +418,7 @@ void ImageViewer::RefreshFile() rgba8_unorm.compByteWidth = 1; rgba8_unorm.compCount = 4; rgba8_unorm.compType = CompType::UNorm; - rgba8_unorm.special = false; + rgba8_unorm.type = ResourceFormatType::Regular; ResourceFormat rgba32_float = rgba8_unorm; rgba32_float.compByteWidth = 4; diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index acfbc0b76..092039df1 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -102,15 +102,14 @@ string ToStrHelper::Get(const ShaderBuiltin &el) template <> void Serialiser::Serialise(const char *name, ResourceFormat &el) { - Serialise("", el.special); - Serialise("", el.specialFormat); + Serialise("", el.type); Serialise("", el.compCount); Serialise("", el.compByteWidth); Serialise("", el.compType); Serialise("", el.bgraOrder); Serialise("", el.srgbCorrected); - SIZE_CHECK(28); + SIZE_CHECK(24); } template <> @@ -579,7 +578,7 @@ void Serialiser::Serialise(const char *name, D3D12Pipe::View &el) Serialise("", el.MinLODClamp); - SIZE_CHECK(144); + SIZE_CHECK(136); } template <> @@ -674,7 +673,7 @@ void Serialiser::Serialise(const char *name, D3D12Pipe::OM &el) Serialise("", el.multiSampleCount); Serialise("", el.multiSampleQuality); - SIZE_CHECK(272); + SIZE_CHECK(264); } template <> @@ -720,7 +719,7 @@ void Serialiser::Serialise(const char *name, D3D12Pipe::State &el) Serialise("", el.Resources); - SIZE_CHECK(1120); + SIZE_CHECK(1112); } #pragma endregion D3D12 pipeline state @@ -736,7 +735,7 @@ void Serialiser::Serialise(const char *name, GLPipe::VertexAttribute &el) Serialise("", el.BufferSlot); Serialise("", el.RelativeOffset); - SIZE_CHECK(56); + SIZE_CHECK(52); } template <> @@ -808,7 +807,7 @@ void Serialiser::Serialise(const char *name, GLPipe::ImageLoadStore &el) Serialise("", el.writeAllowed); Serialise("", el.Format); - SIZE_CHECK(64); + SIZE_CHECK(56); } template <> @@ -1037,7 +1036,7 @@ void Serialiser::Serialise(const char *name, VKPipe::VertexAttribute &el) Serialise("", el.format); Serialise("", el.byteoffset); - SIZE_CHECK(40); + SIZE_CHECK(36); } template <> @@ -1133,7 +1132,7 @@ void Serialiser::Serialise(const char *name, VKPipe::Attachment &el) Serialise("", el.numMip); Serialise("", el.numLayer); - SIZE_CHECK(80); + SIZE_CHECK(72); } template <> @@ -1263,7 +1262,7 @@ void Serialiser::Serialise(const char *name, TextureDescription &el) Serialise("", el.msSamp); Serialise("", el.byteSize); - SIZE_CHECK(112); + SIZE_CHECK(104); } template <> @@ -1637,7 +1636,7 @@ void Serialiser::Serialise(const char *name, PixelModification &el) // don't need string representation of these enums template <> -string ToStrHelper::Get(const SpecialFormat &el) +string ToStrHelper::Get(const ResourceFormatType &el) { return "<...>"; } @@ -2014,8 +2013,7 @@ void ReplayProxy::RemapProxyTextureIfNeeded(TextureDescription &tex, GetTextureD tex.format.compCount = 4; tex.format.compByteWidth = 4; tex.format.compType = CompType::Float; - tex.format.special = false; - tex.format.specialFormat = SpecialFormat::Unknown; + tex.format.type = ResourceFormatType::Regular; tex.creationFlags &= ~TextureCategory::DepthTarget; return; } @@ -2023,23 +2021,23 @@ void ReplayProxy::RemapProxyTextureIfNeeded(TextureDescription &tex, GetTextureD if(m_Proxy->IsTextureSupported(tex.format)) return; - if(tex.format.special) + if(tex.format.Special()) { - switch(tex.format.specialFormat) + switch(tex.format.type) { - case SpecialFormat::S8: - case SpecialFormat::D16S8: params.remap = eRemap_D32S8; break; - case SpecialFormat::ASTC: - case SpecialFormat::EAC: - case SpecialFormat::R5G6B5: - case SpecialFormat::ETC2: params.remap = eRemap_RGBA8; break; + case ResourceFormatType::S8: + case ResourceFormatType::D16S8: params.remap = eRemap_D32S8; break; + case ResourceFormatType::ASTC: + case ResourceFormatType::EAC: + case ResourceFormatType::R5G6B5: + case ResourceFormatType::ETC2: params.remap = eRemap_RGBA8; break; default: - RDCERR("Don't know how to remap special format %u, falling back to RGBA32", - tex.format.specialFormat); + RDCERR("Don't know how to remap resource format type %u, falling back to RGBA32", + tex.format.type); params.remap = eRemap_RGBA32; break; } - tex.format.special = false; + tex.format.type = ResourceFormatType::Regular; } else { diff --git a/renderdoc/driver/d3d11/d3d11_analyse.cpp b/renderdoc/driver/d3d11/d3d11_analyse.cpp index 0881c206c..9657806d2 100644 --- a/renderdoc/driver/d3d11/d3d11_analyse.cpp +++ b/renderdoc/driver/d3d11/d3d11_analyse.cpp @@ -1145,18 +1145,18 @@ ShaderDebugTrace D3D11DebugManager::DebugVertex(uint32_t eventID, uint32_t verti ret.inputs[i].value.f.w = 1.0f; } - // interpret special formats - if(fmt.special) + // interpret resource format types + if(fmt.Special()) { Vec3f *v3 = (Vec3f *)ret.inputs[i].value.fv; Vec4f *v4 = (Vec4f *)ret.inputs[i].value.fv; // only pull in all or nothing from these, // if there's only e.g. 3 bytes remaining don't read and unpack some of - // a 4-byte special format + // a 4-byte resource format type size_t packedsize = 4; - if(fmt.specialFormat == SpecialFormat::R5G5B5A1 || - fmt.specialFormat == SpecialFormat::R5G6B5 || fmt.specialFormat == SpecialFormat::R4G4B4A4) + if(fmt.type == ResourceFormatType::R5G5B5A1 || fmt.type == ResourceFormatType::R5G6B5 || + fmt.type == ResourceFormatType::R4G4B4A4) packedsize = 2; if(srcData == NULL || packedsize > dataSize) @@ -1164,25 +1164,25 @@ ShaderDebugTrace D3D11DebugManager::DebugVertex(uint32_t eventID, uint32_t verti ret.inputs[i].value.u.x = ret.inputs[i].value.u.y = ret.inputs[i].value.u.z = ret.inputs[i].value.u.w = 0; } - else if(fmt.specialFormat == SpecialFormat::R5G5B5A1) + else if(fmt.type == ResourceFormatType::R5G5B5A1) { RDCASSERT(fmt.bgraOrder); uint16_t packed = ((uint16_t *)srcData)[0]; *v4 = ConvertFromB5G5R5A1(packed); } - else if(fmt.specialFormat == SpecialFormat::R5G6B5) + else if(fmt.type == ResourceFormatType::R5G6B5) { RDCASSERT(fmt.bgraOrder); uint16_t packed = ((uint16_t *)srcData)[0]; *v3 = ConvertFromB5G6R5(packed); } - else if(fmt.specialFormat == SpecialFormat::R4G4B4A4) + else if(fmt.type == ResourceFormatType::R4G4B4A4) { RDCASSERT(fmt.bgraOrder); uint16_t packed = ((uint16_t *)srcData)[0]; *v4 = ConvertFromB4G4R4A4(packed); } - else if(fmt.specialFormat == SpecialFormat::R10G10B10A2) + else if(fmt.type == ResourceFormatType::R10G10B10A2) { uint32_t packed = ((uint32_t *)srcData)[0]; @@ -1198,7 +1198,7 @@ ShaderDebugTrace D3D11DebugManager::DebugVertex(uint32_t eventID, uint32_t verti *v4 = ConvertFromR10G10B10A2(packed); } } - else if(fmt.special && fmt.specialFormat == SpecialFormat::R11G11B10) + else if(fmt.type == ResourceFormatType::R11G11B10) { uint32_t packed = ((uint32_t *)srcData)[0]; *v3 = ConvertFromR11G11B10(packed); @@ -6387,7 +6387,7 @@ vector D3D11DebugManager::PixelHistory(vector eve uint32_t storex = uint32_t(pre % (2048 / pixstoreStride)); uint32_t storey = uint32_t(pre / (2048 / pixstoreStride)); - if(!fmt.special && fmt.compCount > 0 && fmt.compByteWidth > 0) + if(fmt.type == ResourceFormatType::Regular && fmt.compCount > 0 && fmt.compByteWidth > 0) { byte *rowdata = pixstoreData + mapped.RowPitch * storey; @@ -6429,8 +6429,7 @@ vector D3D11DebugManager::PixelHistory(vector eve } else { - if(fmt.special && (fmt.specialFormat == SpecialFormat::R10G10B10A2 || - fmt.specialFormat == SpecialFormat::R11G11B10)) + if(fmt.type == ResourceFormatType::R10G10B10A2 || fmt.type == ResourceFormatType::R11G11B10) { byte *rowdata = pixstoreData + mapped.RowPitch * storey; @@ -6443,9 +6442,9 @@ vector D3D11DebugManager::PixelHistory(vector eve ModificationValue *val = (p == 0 ? &mod.preMod : &mod.postMod); Vec4f v; - if(fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(fmt.type == ResourceFormatType::R10G10B10A2) v = ConvertFromR10G10B10A2(*u); - if(fmt.specialFormat == SpecialFormat::R11G11B10) + if(fmt.type == ResourceFormatType::R11G11B10) { Vec3f v3 = ConvertFromR11G11B10(*u); v = Vec4f(v3.x, v3.y, v3.z); @@ -6456,7 +6455,7 @@ vector D3D11DebugManager::PixelHistory(vector eve } else { - RDCWARN("need to fetch pixel values from special formats"); + RDCWARN("need to fetch pixel values from packed resource format types"); } } @@ -6800,7 +6799,7 @@ vector D3D11DebugManager::PixelHistory(vector eve { // colour { - if(!fmt.special && fmt.compCount > 0 && fmt.compByteWidth > 0) + if(fmt.type == ResourceFormatType::Regular && fmt.compCount > 0 && fmt.compByteWidth > 0) { byte *rowdata = pixstoreData + mapped.RowPitch * (postColSlot / 2048); byte *data = rowdata + fmt.compCount * fmt.compByteWidth * (postColSlot % 2048); @@ -6837,8 +6836,7 @@ vector D3D11DebugManager::PixelHistory(vector eve } else { - if(fmt.special && (fmt.specialFormat == SpecialFormat::R10G10B10A2 || - fmt.specialFormat == SpecialFormat::R11G11B10)) + if(fmt.type == ResourceFormatType::R10G10B10A2 || fmt.type == ResourceFormatType::R11G11B10) { byte *rowdata = pixstoreData + mapped.RowPitch * (postColSlot / 2048); byte *data = rowdata + sizeof(uint32_t) * (postColSlot % 2048); @@ -6846,9 +6844,9 @@ vector D3D11DebugManager::PixelHistory(vector eve uint32_t *u = (uint32_t *)data; Vec4f v; - if(fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(fmt.type == ResourceFormatType::R10G10B10A2) v = ConvertFromR10G10B10A2(*u); - if(fmt.specialFormat == SpecialFormat::R11G11B10) + if(fmt.type == ResourceFormatType::R11G11B10) { Vec3f v3 = ConvertFromR11G11B10(*u); v = Vec4f(v3.x, v3.y, v3.z); @@ -6858,7 +6856,7 @@ vector D3D11DebugManager::PixelHistory(vector eve } else { - RDCWARN("need to fetch pixel values from special formats"); + RDCWARN("need to fetch pixel values from packed resource format types"); } } } @@ -7056,7 +7054,8 @@ vector D3D11DebugManager::PixelHistory(vector eve m_pImmediateContext->Unmap(pixstoreDepthReadback, 0); // interpret float/unorm values - if(!fmt.special && fmt.compType != CompType::UInt && fmt.compType != CompType::SInt) + if(fmt.type == ResourceFormatType::Regular && fmt.compType != CompType::UInt && + fmt.compType != CompType::SInt) { for(size_t h = 0; h < history.size(); h++) { diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index 6e6e3413e..61dedd64d 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -3840,8 +3840,7 @@ MeshFormat D3D11DebugManager::GetPostVSBuffers(uint32_t eventID, uint32_t instID ret.fmt.compCount = 4; ret.fmt.compByteWidth = 4; ret.fmt.compType = CompType::Float; - ret.fmt.special = false; - ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.type = ResourceFormatType::Regular; ret.fmt.bgraOrder = false; ret.showAlpha = false; @@ -4818,8 +4817,7 @@ void D3D11DebugManager::RenderMesh(uint32_t eventID, const vector &s layoutdesc[0].SemanticName = "pos"; layoutdesc[0].SemanticIndex = 0; layoutdesc[0].Format = DXGI_FORMAT_R8G8B8A8_UNORM; - if(cfg.position.buf != ResourceId() && - (resFmt.specialFormat != SpecialFormat::Unknown || resFmt.compCount > 0)) + if(cfg.position.buf != ResourceId() && (resFmt.Special() || resFmt.compCount > 0)) layoutdesc[0].Format = MakeDXGIFormat(resFmt); layoutdesc[0].AlignedByteOffset = 0; // offset will be handled by vertex buffer offset layoutdesc[0].InputSlot = 0; @@ -4829,8 +4827,7 @@ void D3D11DebugManager::RenderMesh(uint32_t eventID, const vector &s layoutdesc[1].SemanticName = "sec"; layoutdesc[1].SemanticIndex = 0; layoutdesc[1].Format = DXGI_FORMAT_R8G8B8A8_UNORM; - if(cfg.second.buf != ResourceId() && - (resFmt2.specialFormat != SpecialFormat::Unknown || resFmt2.compCount > 0)) + if(cfg.second.buf != ResourceId() && (resFmt2.Special() || resFmt2.compCount > 0)) layoutdesc[1].Format = MakeDXGIFormat(resFmt2); layoutdesc[1].AlignedByteOffset = 0; layoutdesc[1].InputSlot = 1; diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 473c4cfee..54ace93a1 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -2917,7 +2917,7 @@ bool WrappedID3D11Device::EndFrameCapture(void *dev, void *wnd) bool buf1010102 = false; bool bufBGRA = (fmt.bgraOrder != false); - if(fmt.special && fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(fmt.type == ResourceFormatType::R10G10B10A2) { stride = 4; buf1010102 = true; diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index 6c5d959ab..56317770a 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -4982,8 +4982,7 @@ MeshFormat D3D12DebugManager::GetPostVSBuffers(uint32_t eventID, uint32_t instID ret.fmt.compCount = 4; ret.fmt.compByteWidth = 4; ret.fmt.compType = CompType::Float; - ret.fmt.special = false; - ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.type = ResourceFormatType::Regular; ret.fmt.bgraOrder = false; ret.showAlpha = false; @@ -5679,8 +5678,7 @@ void D3D12DebugManager::RenderMesh(uint32_t eventID, const vector &s helper.idxByteWidth = 2; helper.topo = Topology::LineList; - helper.fmt.special = false; - helper.fmt.specialFormat = SpecialFormat::Unknown; + helper.fmt.type = ResourceFormatType::Regular; helper.fmt.compByteWidth = 4; helper.fmt.compCount = 4; helper.fmt.compType = CompType::Float; diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 09ff62bc4..c3f472ff3 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -1512,7 +1512,7 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd) bool buf1010102 = false; bool bufBGRA = (fmt.bgraOrder != false); - if(fmt.special && fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(fmt.type == ResourceFormatType::R10G10B10A2) { stride = 4; buf1010102 = true; diff --git a/renderdoc/driver/dxgi/dxgi_common.cpp b/renderdoc/driver/dxgi/dxgi_common.cpp index ece23a117..c3635460e 100644 --- a/renderdoc/driver/dxgi/dxgi_common.cpp +++ b/renderdoc/driver/dxgi/dxgi_common.cpp @@ -1364,52 +1364,52 @@ DXGI_FORMAT MakeDXGIFormat(ResourceFormat fmt) { DXGI_FORMAT ret = DXGI_FORMAT_UNKNOWN; - if(fmt.special) + if(fmt.Special()) { - switch(fmt.specialFormat) + switch(fmt.type) { - case SpecialFormat::BC1: ret = DXGI_FORMAT_BC1_UNORM; break; - case SpecialFormat::BC2: ret = DXGI_FORMAT_BC2_UNORM; break; - case SpecialFormat::BC3: ret = DXGI_FORMAT_BC3_UNORM; break; - case SpecialFormat::BC4: ret = DXGI_FORMAT_BC4_UNORM; break; - case SpecialFormat::BC5: ret = DXGI_FORMAT_BC5_UNORM; break; - case SpecialFormat::BC6: ret = DXGI_FORMAT_BC6H_UF16; break; - case SpecialFormat::BC7: ret = DXGI_FORMAT_BC7_UNORM; break; - case SpecialFormat::R10G10B10A2: + case ResourceFormatType::BC1: ret = DXGI_FORMAT_BC1_UNORM; break; + case ResourceFormatType::BC2: ret = DXGI_FORMAT_BC2_UNORM; break; + case ResourceFormatType::BC3: ret = DXGI_FORMAT_BC3_UNORM; break; + case ResourceFormatType::BC4: ret = DXGI_FORMAT_BC4_UNORM; break; + case ResourceFormatType::BC5: ret = DXGI_FORMAT_BC5_UNORM; break; + case ResourceFormatType::BC6: ret = DXGI_FORMAT_BC6H_UF16; break; + case ResourceFormatType::BC7: ret = DXGI_FORMAT_BC7_UNORM; break; + case ResourceFormatType::R10G10B10A2: if(fmt.compType == CompType::UNorm) ret = DXGI_FORMAT_R10G10B10A2_UNORM; else ret = DXGI_FORMAT_R10G10B10A2_UINT; break; - case SpecialFormat::R11G11B10: ret = DXGI_FORMAT_R11G11B10_FLOAT; break; - case SpecialFormat::R5G6B5: + case ResourceFormatType::R11G11B10: ret = DXGI_FORMAT_R11G11B10_FLOAT; break; + case ResourceFormatType::R5G6B5: // only support bgra order if(!fmt.bgraOrder) return DXGI_FORMAT_UNKNOWN; ret = DXGI_FORMAT_B5G6R5_UNORM; break; - case SpecialFormat::R5G5B5A1: + case ResourceFormatType::R5G5B5A1: // only support bgra order if(!fmt.bgraOrder) return DXGI_FORMAT_UNKNOWN; ret = DXGI_FORMAT_B5G5R5A1_UNORM; break; - case SpecialFormat::R9G9B9E5: ret = DXGI_FORMAT_R9G9B9E5_SHAREDEXP; break; - case SpecialFormat::R4G4B4A4: + case ResourceFormatType::R9G9B9E5: ret = DXGI_FORMAT_R9G9B9E5_SHAREDEXP; break; + case ResourceFormatType::R4G4B4A4: // only support bgra order if(!fmt.bgraOrder) return DXGI_FORMAT_UNKNOWN; ret = DXGI_FORMAT_B4G4R4A4_UNORM; break; - case SpecialFormat::D24S8: ret = DXGI_FORMAT_R24G8_TYPELESS; break; - case SpecialFormat::D32S8: ret = DXGI_FORMAT_R32G8X24_TYPELESS; break; - case SpecialFormat::YUV: + case ResourceFormatType::D24S8: ret = DXGI_FORMAT_R24G8_TYPELESS; break; + case ResourceFormatType::D32S8: ret = DXGI_FORMAT_R32G8X24_TYPELESS; break; + case ResourceFormatType::YUV: // just claim all YUV formats as unsupported. In theory we could add more - // special format enums to identify all the types, and return support for + // resource format type enums to identify all the types, and return support for // the ones that exist in D3D return DXGI_FORMAT_UNKNOWN; - case SpecialFormat::S8: // D3D has no stencil-only format - case SpecialFormat::D16S8: // D3D has no D16S8 format + case ResourceFormatType::S8: // D3D has no stencil-only format + case ResourceFormatType::D16S8: // D3D has no D16S8 format default: return DXGI_FORMAT_UNKNOWN; } } @@ -1488,8 +1488,6 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) { ResourceFormat ret; - ret.special = false; - ret.compCount = ret.compByteWidth = 0; ret.compType = CompType::Float; @@ -1512,7 +1510,8 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: ret.compCount = 4; break; + case DXGI_FORMAT_R8G8B8A8_SINT: + case DXGI_FORMAT_B4G4R4A4_UNORM: ret.compCount = 4; break; case DXGI_FORMAT_R32G32B32_TYPELESS: case DXGI_FORMAT_R32G32B32_FLOAT: case DXGI_FORMAT_R32G32B32_UINT: @@ -1605,9 +1604,27 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_BC4_UNORM: case DXGI_FORMAT_BC4_SNORM: ret.compCount = 1; break; - case DXGI_FORMAT_UNKNOWN: ret.compCount = 0; break; + case DXGI_FORMAT_AYUV: + case DXGI_FORMAT_Y410: + case DXGI_FORMAT_Y416: + case DXGI_FORMAT_NV12: + case DXGI_FORMAT_P010: + case DXGI_FORMAT_P016: + case DXGI_FORMAT_420_OPAQUE: + case DXGI_FORMAT_YUY2: + case DXGI_FORMAT_Y210: + case DXGI_FORMAT_Y216: + case DXGI_FORMAT_NV11: + case DXGI_FORMAT_AI44: + case DXGI_FORMAT_IA44: + case DXGI_FORMAT_P8: + case DXGI_FORMAT_A8P8: + case DXGI_FORMAT_P208: + case DXGI_FORMAT_V208: + case DXGI_FORMAT_V408: ret.compCount = 3; break; - default: ret.special = true; + case DXGI_FORMAT_UNKNOWN: + case DXGI_FORMAT_FORCE_UINT: ret.compCount = 0; break; } switch(fmt) @@ -1672,9 +1689,7 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: ret.compByteWidth = 1; break; - case DXGI_FORMAT_UNKNOWN: ret.compByteWidth = 0; break; - - default: ret.special = true; + default: ret.compByteWidth = 0; break; } switch(fmt) @@ -1765,6 +1780,7 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_R8G8_B8G8_UNORM: case DXGI_FORMAT_G8R8_G8B8_UNORM: case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_B4G4R4A4_UNORM: case DXGI_FORMAT_B5G6R5_UNORM: case DXGI_FORMAT_B5G5R5A1_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM: @@ -1784,71 +1800,8 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_BC3_UNORM_SRGB: case DXGI_FORMAT_BC7_UNORM_SRGB: ret.compType = CompType::UNorm; break; - case DXGI_FORMAT_UNKNOWN: ret.compType = CompType::Typeless; break; - - default: ret.special = true; - } - - switch(fmt) - { - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: ret.bgraOrder = true; break; - } - - ret.specialFormat = SpecialFormat::Unknown; - - switch(fmt) - { - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24G8_TYPELESS: ret.specialFormat = SpecialFormat::D24S8; break; - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: ret.specialFormat = SpecialFormat::D32S8; break; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC1_UNORM: ret.specialFormat = SpecialFormat::BC1; break; - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC2_UNORM: ret.specialFormat = SpecialFormat::BC2; break; - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM: ret.specialFormat = SpecialFormat::BC3; break; - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: ret.specialFormat = SpecialFormat::BC4; break; - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: ret.specialFormat = SpecialFormat::BC5; break; - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC6H_TYPELESS: ret.specialFormat = SpecialFormat::BC6; break; - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM_SRGB: - case DXGI_FORMAT_BC7_UNORM: ret.specialFormat = SpecialFormat::BC7; break; - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - ret.specialFormat = SpecialFormat::R10G10B10A2; - break; - case DXGI_FORMAT_R11G11B10_FLOAT: ret.specialFormat = SpecialFormat::R11G11B10; break; - case DXGI_FORMAT_B5G6R5_UNORM: - ret.specialFormat = SpecialFormat::R5G6B5; - ret.bgraOrder = true; - break; - case DXGI_FORMAT_B5G5R5A1_UNORM: - ret.specialFormat = SpecialFormat::R5G5B5A1; - ret.bgraOrder = true; - break; - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: ret.specialFormat = SpecialFormat::R9G9B9E5; break; + case DXGI_FORMAT_UNKNOWN: + case DXGI_FORMAT_FORCE_UINT: ret.compType = CompType::Typeless; break; case DXGI_FORMAT_AYUV: case DXGI_FORMAT_Y410: @@ -1867,21 +1820,99 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) case DXGI_FORMAT_A8P8: case DXGI_FORMAT_P208: case DXGI_FORMAT_V208: - case DXGI_FORMAT_V408: ret.specialFormat = SpecialFormat::YUV; break; + case DXGI_FORMAT_V408: ret.compType = CompType::UNorm; break; + } + switch(fmt) + { case DXGI_FORMAT_B4G4R4A4_UNORM: - ret.specialFormat = SpecialFormat::R4G4B4A4; - ret.bgraOrder = true; - break; - - case DXGI_FORMAT_UNKNOWN: ret.specialFormat = SpecialFormat::Unknown; break; - + case DXGI_FORMAT_B5G6R5_UNORM: + case DXGI_FORMAT_B5G5R5A1_UNORM: + case DXGI_FORMAT_B8G8R8A8_UNORM: + case DXGI_FORMAT_B8G8R8X8_UNORM: + case DXGI_FORMAT_B8G8R8A8_TYPELESS: + case DXGI_FORMAT_B8G8R8X8_TYPELESS: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: ret.bgraOrder = true; break; default: break; } - if(ret.specialFormat != SpecialFormat::Unknown) + ret.type = ResourceFormatType::Regular; + + switch(fmt) { - ret.special = true; + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case DXGI_FORMAT_X24_TYPELESS_G8_UINT: + case DXGI_FORMAT_D24_UNORM_S8_UINT: + case DXGI_FORMAT_R24G8_TYPELESS: ret.type = ResourceFormatType::D24S8; break; + case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: + case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: + case DXGI_FORMAT_R32G8X24_TYPELESS: ret.type = ResourceFormatType::D32S8; break; + + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC1_UNORM: ret.type = ResourceFormatType::BC1; break; + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC2_UNORM: ret.type = ResourceFormatType::BC2; break; + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC3_UNORM: ret.type = ResourceFormatType::BC3; break; + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: ret.type = ResourceFormatType::BC4; break; + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + case DXGI_FORMAT_BC5_SNORM: ret.type = ResourceFormatType::BC5; break; + case DXGI_FORMAT_BC6H_UF16: + case DXGI_FORMAT_BC6H_SF16: + case DXGI_FORMAT_BC6H_TYPELESS: ret.type = ResourceFormatType::BC6; break; + case DXGI_FORMAT_BC7_TYPELESS: + case DXGI_FORMAT_BC7_UNORM_SRGB: + case DXGI_FORMAT_BC7_UNORM: ret.type = ResourceFormatType::BC7; break; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R10G10B10A2_UINT: + case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: ret.type = ResourceFormatType::R10G10B10A2; break; + case DXGI_FORMAT_R11G11B10_FLOAT: ret.type = ResourceFormatType::R11G11B10; break; + case DXGI_FORMAT_B5G6R5_UNORM: + ret.type = ResourceFormatType::R5G6B5; + ret.bgraOrder = true; + break; + case DXGI_FORMAT_B5G5R5A1_UNORM: + ret.type = ResourceFormatType::R5G5B5A1; + ret.bgraOrder = true; + break; + case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: ret.type = ResourceFormatType::R9G9B9E5; break; + + case DXGI_FORMAT_AYUV: + case DXGI_FORMAT_Y410: + case DXGI_FORMAT_Y416: + case DXGI_FORMAT_NV12: + case DXGI_FORMAT_P010: + case DXGI_FORMAT_P016: + case DXGI_FORMAT_420_OPAQUE: + case DXGI_FORMAT_YUY2: + case DXGI_FORMAT_Y210: + case DXGI_FORMAT_Y216: + case DXGI_FORMAT_NV11: + case DXGI_FORMAT_AI44: + case DXGI_FORMAT_IA44: + case DXGI_FORMAT_P8: + case DXGI_FORMAT_A8P8: + case DXGI_FORMAT_P208: + case DXGI_FORMAT_V208: + case DXGI_FORMAT_V408: ret.type = ResourceFormatType::YUV; break; + + case DXGI_FORMAT_B4G4R4A4_UNORM: + ret.type = ResourceFormatType::R4G4B4A4; + ret.bgraOrder = true; + break; + + case DXGI_FORMAT_UNKNOWN: ret.type = ResourceFormatType::Undefined; break; + + default: break; } return ret; diff --git a/renderdoc/driver/gl/gl_common.cpp b/renderdoc/driver/gl/gl_common.cpp index dd8f120df..5d1d721c4 100644 --- a/renderdoc/driver/gl/gl_common.cpp +++ b/renderdoc/driver/gl/gl_common.cpp @@ -1209,8 +1209,7 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt { ResourceFormat ret; - ret.special = false; - ret.specialFormat = SpecialFormat::Unknown; + ret.type = ResourceFormatType::Regular; // special handling for formats that don't query neatly if(fmt == eGL_LUMINANCE8_EXT || fmt == eGL_INTENSITY8_EXT || fmt == eGL_ALPHA8_EXT) @@ -1224,8 +1223,6 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt if(IsCompressedFormat(fmt)) { - ret.special = true; - switch(fmt) { case eGL_COMPRESSED_RGB_S3TC_DXT1_EXT: @@ -1274,6 +1271,8 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt default: break; } + ret.type = ResourceFormatType::Undefined; + switch(fmt) { // BC1 @@ -1281,37 +1280,37 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt case eGL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case eGL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - ret.specialFormat = SpecialFormat::BC1; + ret.type = ResourceFormatType::BC1; break; // BC2 case eGL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - ret.specialFormat = SpecialFormat::BC2; + ret.type = ResourceFormatType::BC2; break; // BC3 case eGL_COMPRESSED_RGBA_S3TC_DXT5_EXT: case eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - ret.specialFormat = SpecialFormat::BC3; + ret.type = ResourceFormatType::BC3; break; // BC4 case eGL_COMPRESSED_RED_RGTC1: case eGL_COMPRESSED_SIGNED_RED_RGTC1: - ret.specialFormat = SpecialFormat::BC4; + ret.type = ResourceFormatType::BC4; break; // BC5 case eGL_COMPRESSED_RG_RGTC2: case eGL_COMPRESSED_SIGNED_RG_RGTC2: - ret.specialFormat = SpecialFormat::BC5; + ret.type = ResourceFormatType::BC5; break; // BC6 case eGL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB: case eGL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB: - ret.specialFormat = SpecialFormat::BC6; + ret.type = ResourceFormatType::BC6; break; // BC7 case eGL_COMPRESSED_RGBA_BPTC_UNORM_ARB: case eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: - ret.specialFormat = SpecialFormat::BC7; + ret.type = ResourceFormatType::BC7; break; // ETC1 case eGL_ETC1_RGB8_OES: // handle it as ETC2 @@ -1320,7 +1319,7 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt case eGL_COMPRESSED_SRGB8_ETC2: case eGL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: case eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - ret.specialFormat = SpecialFormat::ETC2; + ret.type = ResourceFormatType::ETC2; break; // EAC case eGL_COMPRESSED_RGBA8_ETC2_EAC: @@ -1329,7 +1328,7 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt case eGL_COMPRESSED_SIGNED_R11_EAC: case eGL_COMPRESSED_RG11_EAC: case eGL_COMPRESSED_SIGNED_RG11_EAC: - ret.specialFormat = SpecialFormat::EAC; + ret.type = ResourceFormatType::EAC; break; // ASTC case eGL_COMPRESSED_RGBA_ASTC_4x4_KHR: @@ -1359,57 +1358,30 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - ret.specialFormat = SpecialFormat::ASTC; - break; + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: ret.type = ResourceFormatType::ASTC; break; default: RDCERR("Unexpected compressed format %#x", fmt); break; } + return ret; } // handle certain non compressed but special formats - if(fmt == eGL_R11F_G11F_B10F) + switch(fmt) { - ret.special = true; - ret.specialFormat = SpecialFormat::R11G11B10; - return ret; + case eGL_R11F_G11F_B10F: ret.type = ResourceFormatType::R11G11B10; break; + case eGL_RGB565: ret.type = ResourceFormatType::R5G6B5; break; + case eGL_RGB5_A1: ret.type = ResourceFormatType::R5G5B5A1; break; + case eGL_RGB9_E5: ret.type = ResourceFormatType::R9G9B9E5; break; + case eGL_RGBA4: ret.type = ResourceFormatType::R4G4B4A4; break; + case eGL_RGB10_A2: + case eGL_RGB10_A2UI: + ret.type = ResourceFormatType::R10G10B10A2; + ret.compType = fmt == eGL_RGB10_A2 ? CompType::UNorm : CompType::UInt; + break; } - if(fmt == eGL_RGB565) - { - ret.special = true; - ret.specialFormat = SpecialFormat::R5G6B5; + if(ret.Special()) return ret; - } - - if(fmt == eGL_RGB5_A1) - { - ret.special = true; - ret.specialFormat = SpecialFormat::R5G5B5A1; - return ret; - } - - if(fmt == eGL_RGB9_E5) - { - ret.special = true; - ret.specialFormat = SpecialFormat::R9G9B9E5; - return ret; - } - - if(fmt == eGL_RGBA4) - { - ret.special = true; - ret.specialFormat = SpecialFormat::R4G4B4A4; - return ret; - } - - if(fmt == eGL_RGB10_A2 || fmt == eGL_RGB10_A2UI) - { - ret.special = true; - ret.specialFormat = SpecialFormat::R10G10B10A2; - ret.compType = fmt == eGL_RGB10_A2 ? CompType::UNorm : CompType::UInt; - return ret; - } ret.compByteWidth = 1; ret.compCount = 4; @@ -1446,11 +1418,15 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt // wasn't a byte format (8, 16, 32) if(ret.compByteWidth * 8 != (uint32_t)data[0]) - ret.special = true; + { + ret.type = ResourceFormatType::Undefined; + RDCERR("Unexpected/unhandled non-uniform format: '%s'", ToStr::Get(fmt).c_str()); + } } else { - ret.special = true; + ret.type = ResourceFormatType::Undefined; + RDCERR("Unexpected/unhandled non-uniform format: '%s'", ToStr::Get(fmt).c_str()); } gl.glGetInternalformativ(target, fmt, eGL_INTERNALFORMAT_RED_TYPE, sizeof(GLint), &data[0]); @@ -1476,7 +1452,8 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt } else { - ret.special = true; + ret.type = ResourceFormatType::Undefined; + RDCERR("Unexpected/unhandled non-uniform format: '%s'", ToStr::Get(fmt).c_str()); } gl.glGetInternalformativ(target, fmt, eGL_COLOR_ENCODING, sizeof(GLint), &data[0]); @@ -1502,25 +1479,16 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt ret.compByteWidth = 4; ret.compCount = 1; break; - case eGL_DEPTH24_STENCIL8: - ret.specialFormat = SpecialFormat::D24S8; - ret.special = true; - break; - case eGL_DEPTH32F_STENCIL8: - ret.specialFormat = SpecialFormat::D32S8; - ret.special = true; - break; - case eGL_STENCIL_INDEX8: - ret.specialFormat = SpecialFormat::S8; - ret.special = true; - break; - default: RDCERR("Unexpected depth or stencil format %x", fmt); + case eGL_DEPTH24_STENCIL8: ret.type = ResourceFormatType::D24S8; break; + case eGL_DEPTH32F_STENCIL8: ret.type = ResourceFormatType::D32S8; break; + case eGL_STENCIL_INDEX8: ret.type = ResourceFormatType::S8; break; + default: RDCERR("Unexpected depth or stencil format '%s'", ToStr::Get(fmt).c_str()); } } else { // not colour or depth! - RDCERR("Unexpected texture type, not colour or depth"); + RDCERR("Unexpected texture type, not colour or depth: '%s'", ToStr::Get(fmt).c_str()); } return ret; @@ -1530,11 +1498,11 @@ GLenum MakeGLFormat(WrappedOpenGL &gl, ResourceFormat fmt) { GLenum ret = eGL_NONE; - if(fmt.special) + if(fmt.Special()) { - switch(fmt.specialFormat) + switch(fmt.type) { - case SpecialFormat::BC1: + case ResourceFormatType::BC1: { if(fmt.compCount == 3) ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_S3TC_DXT1_EXT @@ -1544,31 +1512,31 @@ GLenum MakeGLFormat(WrappedOpenGL &gl, ResourceFormat fmt) : eGL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break; } - case SpecialFormat::BC2: + case ResourceFormatType::BC2: ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT : eGL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break; - case SpecialFormat::BC3: + case ResourceFormatType::BC3: ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : eGL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break; - case SpecialFormat::BC4: + case ResourceFormatType::BC4: ret = fmt.compType == CompType::SNorm ? eGL_COMPRESSED_SIGNED_RED_RGTC1 : eGL_COMPRESSED_RED_RGTC1; break; - case SpecialFormat::BC5: + case ResourceFormatType::BC5: ret = fmt.compType == CompType::SNorm ? eGL_COMPRESSED_SIGNED_RG_RGTC2 : eGL_COMPRESSED_RG_RGTC2; break; - case SpecialFormat::BC6: + case ResourceFormatType::BC6: ret = fmt.compType == CompType::SNorm ? eGL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB : eGL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; break; - case SpecialFormat::BC7: + case ResourceFormatType::BC7: ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB : eGL_COMPRESSED_RGBA_BPTC_UNORM_ARB; break; - case SpecialFormat::ETC2: + case ResourceFormatType::ETC2: { if(fmt.compCount == 3) ret = fmt.srgbCorrected ? eGL_COMPRESSED_SRGB8_ETC2 : eGL_COMPRESSED_RGB8_ETC2; @@ -1577,7 +1545,7 @@ GLenum MakeGLFormat(WrappedOpenGL &gl, ResourceFormat fmt) : eGL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; break; } - case SpecialFormat::EAC: + case ResourceFormatType::EAC: { if(fmt.compCount == 1) ret = fmt.compType == CompType::SNorm ? eGL_COMPRESSED_SIGNED_R11_EAC @@ -1590,22 +1558,22 @@ GLenum MakeGLFormat(WrappedOpenGL &gl, ResourceFormat fmt) : eGL_COMPRESSED_RGBA8_ETC2_EAC; break; } - case SpecialFormat::R10G10B10A2: + case ResourceFormatType::R10G10B10A2: if(fmt.compType == CompType::UNorm) ret = eGL_RGB10_A2; else ret = eGL_RGB10_A2UI; break; - case SpecialFormat::R11G11B10: ret = eGL_R11F_G11F_B10F; break; - case SpecialFormat::R5G6B5: ret = eGL_RGB565; break; - case SpecialFormat::R5G5B5A1: ret = eGL_RGB5_A1; break; - case SpecialFormat::R9G9B9E5: ret = eGL_RGB9_E5; break; - case SpecialFormat::R4G4B4A4: ret = eGL_RGBA4; break; - case SpecialFormat::D24S8: ret = eGL_DEPTH24_STENCIL8; break; - case SpecialFormat::D32S8: ret = eGL_DEPTH32F_STENCIL8; break; - case SpecialFormat::ASTC: RDCERR("ASTC can't be decoded unambiguously"); break; - case SpecialFormat::S8: ret = eGL_STENCIL_INDEX8; break; - default: RDCERR("Unsupported special format %u", fmt.specialFormat); break; + case ResourceFormatType::R11G11B10: ret = eGL_R11F_G11F_B10F; break; + case ResourceFormatType::R5G6B5: ret = eGL_RGB565; break; + case ResourceFormatType::R5G5B5A1: ret = eGL_RGB5_A1; break; + case ResourceFormatType::R9G9B9E5: ret = eGL_RGB9_E5; break; + case ResourceFormatType::R4G4B4A4: ret = eGL_RGBA4; break; + case ResourceFormatType::D24S8: ret = eGL_DEPTH24_STENCIL8; break; + case ResourceFormatType::D32S8: ret = eGL_DEPTH32F_STENCIL8; break; + case ResourceFormatType::ASTC: RDCERR("ASTC can't be decoded unambiguously"); break; + case ResourceFormatType::S8: ret = eGL_STENCIL_INDEX8; break; + default: RDCERR("Unsupported resource format type %u", fmt.type); break; } } else if(fmt.compCount == 4) diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index 7dfd21ea8..591070f86 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -2892,23 +2892,22 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeHint, DebugOve gl.glBindVertexArray(tempVAO); { - if(postvs.fmt.specialFormat != SpecialFormat::Unknown) + if(postvs.fmt.Special()) { - if(postvs.fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(postvs.fmt.type == ResourceFormatType::R10G10B10A2) { if(postvs.fmt.compType == CompType::UInt) gl.glVertexAttribIFormat(0, 4, eGL_UNSIGNED_INT_2_10_10_10_REV, 0); if(postvs.fmt.compType == CompType::SInt) gl.glVertexAttribIFormat(0, 4, eGL_INT_2_10_10_10_REV, 0); } - else if(postvs.fmt.specialFormat == SpecialFormat::R11G11B10) + else if(postvs.fmt.type == ResourceFormatType::R11G11B10) { gl.glVertexAttribFormat(0, 4, eGL_UNSIGNED_INT_10F_11F_11F_REV, GL_FALSE, 0); } else { - RDCWARN("Unsupported special vertex attribute format: %x", - postvs.fmt.specialFormat); + RDCWARN("Unsupported vertex attribute format: %x", postvs.fmt.type); } } else if(postvs.fmt.compType == CompType::Float || @@ -4686,8 +4685,7 @@ MeshFormat GLReplay::GetPostVSBuffers(uint32_t eventID, uint32_t instID, MeshDat ret.fmt.compCount = 4; ret.fmt.compByteWidth = 4; ret.fmt.compType = CompType::Float; - ret.fmt.special = false; - ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.type = ResourceFormatType::Regular; ret.fmt.bgraOrder = false; ret.showAlpha = false; @@ -4825,22 +4823,22 @@ void GLReplay::RenderMesh(uint32_t eventID, const vector &secondaryD if(meshData[i]->buf == ResourceId()) continue; - if(meshData[i]->fmt.specialFormat != SpecialFormat::Unknown) + if(meshData[i]->fmt.Special()) { - if(meshData[i]->fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(meshData[i]->fmt.type == ResourceFormatType::R10G10B10A2) { if(meshData[i]->fmt.compType == CompType::UInt) gl.glVertexAttribIFormat(i, 4, eGL_UNSIGNED_INT_2_10_10_10_REV, 0); if(meshData[i]->fmt.compType == CompType::SInt) gl.glVertexAttribIFormat(i, 4, eGL_INT_2_10_10_10_REV, 0); } - else if(meshData[i]->fmt.specialFormat == SpecialFormat::R11G11B10) + else if(meshData[i]->fmt.type == ResourceFormatType::R11G11B10) { gl.glVertexAttribFormat(i, 4, eGL_UNSIGNED_INT_10F_11F_11F_REV, GL_FALSE, 0); } else { - RDCWARN("Unsupported special vertex attribute format: %x", meshData[i]->fmt.specialFormat); + RDCWARN("Unsupported vertex attribute format: %x", meshData[i]->fmt.type); } } else if(meshData[i]->fmt.compType == CompType::Float || diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 13fcd0cae..88e4175cd 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -731,7 +731,7 @@ void GLReplay::CacheTexture(ResourceId id) tex.byteSize += (uint64_t)GetCompressedByteSize( RDCMAX(1U, tex.width >> m), RDCMAX(1U, tex.height >> m), 1, (GLenum)fmt); } - else if(tex.format.special) + else if(tex.format.Special()) { tex.byteSize += GetByteSize(RDCMAX(1U, tex.width >> m), RDCMAX(1U, tex.height >> m), RDCMAX(1U, tex.depth >> m), GetBaseFormat((GLenum)fmt), @@ -939,7 +939,7 @@ void GLReplay::SavePipelineState() ResourceFormat fmt; - fmt.special = false; + fmt.type = ResourceFormatType::Regular; fmt.compCount = 4; gl.glGetVertexAttribiv(i, eGL_VERTEX_ATTRIB_ARRAY_SIZE, (GLint *)&fmt.compCount); @@ -985,20 +985,17 @@ void GLReplay::SavePipelineState() fmt.compType = CompType::Float; break; case eGL_INT_2_10_10_10_REV: - fmt.special = true; - fmt.specialFormat = SpecialFormat::R10G10B10A2; + fmt.type = ResourceFormatType::R10G10B10A2; fmt.compCount = 4; fmt.compType = CompType::UInt; break; case eGL_UNSIGNED_INT_2_10_10_10_REV: - fmt.special = true; - fmt.specialFormat = SpecialFormat::R10G10B10A2; + fmt.type = ResourceFormatType::R10G10B10A2; fmt.compCount = 4; fmt.compType = CompType::SInt; break; case eGL_UNSIGNED_INT_10F_11F_11F_REV: - fmt.special = true; - fmt.specialFormat = SpecialFormat::R11G11B10; + fmt.type = ResourceFormatType::R11G11B10; fmt.compCount = 3; fmt.compType = CompType::Float; break; @@ -1013,7 +1010,7 @@ void GLReplay::SavePipelineState() if(type == eGL_UNSIGNED_INT_2_10_10_10_REV || type == eGL_INT_2_10_10_10_REV) { - fmt.specialFormat = SpecialFormat::R10G10B10A2; + fmt.type = ResourceFormatType::R10G10B10A2; fmt.compType = type == eGL_UNSIGNED_INT_2_10_10_10_REV ? CompType::UInt : CompType::SInt; } else @@ -3264,10 +3261,8 @@ bool GLReplay::IsTextureSupported(const ResourceFormat &format) bool GLReplay::NeedRemapForFetch(const ResourceFormat &format) { - if(format.compType == CompType::Depth || - (format.special && (format.specialFormat == SpecialFormat::D16S8 || - format.specialFormat == SpecialFormat::D24S8 || - format.specialFormat == SpecialFormat::D32S8))) + if(format.compType == CompType::Depth || format.type == ResourceFormatType::D16S8 || + format.type == ResourceFormatType::D24S8 || format.type == ResourceFormatType::D32S8) return IsGLES && !HasExt[NV_read_depth]; return false; } diff --git a/renderdoc/driver/vulkan/vk_common.cpp b/renderdoc/driver/vulkan/vk_common.cpp index 65775d5cb..bd2eed134 100644 --- a/renderdoc/driver/vulkan/vk_common.cpp +++ b/renderdoc/driver/vulkan/vk_common.cpp @@ -244,8 +244,7 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) { ResourceFormat ret; - ret.special = false; - ret.specialFormat = SpecialFormat::Unknown; + ret.type = ResourceFormatType::Regular; ret.compByteWidth = 0; ret.compCount = 0; ret.compType = CompType::Typeless; @@ -253,20 +252,15 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) if(fmt == VK_FORMAT_UNDEFINED) { + ret.type = ResourceFormatType::Undefined; return ret; } switch(fmt) { - case VK_FORMAT_R4G4_UNORM_PACK8: - ret.special = true; - ret.specialFormat = SpecialFormat::R4G4; - break; + case VK_FORMAT_R4G4_UNORM_PACK8: ret.type = ResourceFormatType::R4G4; break; case VK_FORMAT_R4G4B4A4_UNORM_PACK16: - case VK_FORMAT_B4G4R4A4_UNORM_PACK16: - ret.special = true; - ret.specialFormat = SpecialFormat::R4G4B4A4; - break; + case VK_FORMAT_B4G4R4A4_UNORM_PACK16: ret.type = ResourceFormatType::R4G4B4A4; break; case VK_FORMAT_A2B10G10R10_UNORM_PACK32: case VK_FORMAT_A2R10G10B10_UNORM_PACK32: case VK_FORMAT_A2B10G10R10_SNORM_PACK32: @@ -278,94 +272,43 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) case VK_FORMAT_A2B10G10R10_UINT_PACK32: case VK_FORMAT_A2R10G10B10_UINT_PACK32: case VK_FORMAT_A2B10G10R10_SINT_PACK32: - case VK_FORMAT_A2R10G10B10_SINT_PACK32: - ret.special = true; - ret.specialFormat = SpecialFormat::R10G10B10A2; - break; - case VK_FORMAT_B10G11R11_UFLOAT_PACK32: - ret.special = true; - ret.specialFormat = SpecialFormat::R11G11B10; - break; - case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: - ret.special = true; - ret.specialFormat = SpecialFormat::R9G9B9E5; - break; + case VK_FORMAT_A2R10G10B10_SINT_PACK32: ret.type = ResourceFormatType::R10G10B10A2; break; + case VK_FORMAT_B10G11R11_UFLOAT_PACK32: ret.type = ResourceFormatType::R11G11B10; break; + case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: ret.type = ResourceFormatType::R9G9B9E5; break; case VK_FORMAT_R5G6B5_UNORM_PACK16: - case VK_FORMAT_B5G6R5_UNORM_PACK16: - ret.special = true; - ret.specialFormat = SpecialFormat::R5G6B5; - break; + case VK_FORMAT_B5G6R5_UNORM_PACK16: ret.type = ResourceFormatType::R5G6B5; break; case VK_FORMAT_R5G5B5A1_UNORM_PACK16: case VK_FORMAT_B5G5R5A1_UNORM_PACK16: - case VK_FORMAT_A1R5G5B5_UNORM_PACK16: - ret.special = true; - ret.specialFormat = SpecialFormat::R5G5B5A1; - break; - case VK_FORMAT_D16_UNORM_S8_UINT: - ret.special = true; - ret.specialFormat = SpecialFormat::D16S8; - break; - case VK_FORMAT_D24_UNORM_S8_UINT: - ret.special = true; - ret.specialFormat = SpecialFormat::D24S8; - break; - case VK_FORMAT_D32_SFLOAT_S8_UINT: - ret.special = true; - ret.specialFormat = SpecialFormat::D32S8; - break; + case VK_FORMAT_A1R5G5B5_UNORM_PACK16: ret.type = ResourceFormatType::R5G5B5A1; break; + case VK_FORMAT_D16_UNORM_S8_UINT: ret.type = ResourceFormatType::D16S8; break; + case VK_FORMAT_D24_UNORM_S8_UINT: ret.type = ResourceFormatType::D24S8; break; + case VK_FORMAT_D32_SFLOAT_S8_UINT: ret.type = ResourceFormatType::D32S8; break; case VK_FORMAT_BC1_RGB_UNORM_BLOCK: case VK_FORMAT_BC1_RGB_SRGB_BLOCK: case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::BC1; - break; + case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: ret.type = ResourceFormatType::BC1; break; case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::BC2; - break; + case VK_FORMAT_BC2_SRGB_BLOCK: ret.type = ResourceFormatType::BC2; break; case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::BC3; - break; + case VK_FORMAT_BC3_SRGB_BLOCK: ret.type = ResourceFormatType::BC3; break; case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::BC4; - break; + case VK_FORMAT_BC4_SNORM_BLOCK: ret.type = ResourceFormatType::BC4; break; case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::BC5; - break; + case VK_FORMAT_BC5_SNORM_BLOCK: ret.type = ResourceFormatType::BC5; break; case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::BC6; - break; + case VK_FORMAT_BC6H_SFLOAT_BLOCK: ret.type = ResourceFormatType::BC6; break; case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::BC7; - break; + case VK_FORMAT_BC7_SRGB_BLOCK: ret.type = ResourceFormatType::BC7; break; case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::ETC2; - break; + case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: ret.type = ResourceFormatType::ETC2; break; case VK_FORMAT_EAC_R11_UNORM_BLOCK: case VK_FORMAT_EAC_R11_SNORM_BLOCK: case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::EAC; - break; + case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: ret.type = ResourceFormatType::EAC; break; case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: @@ -393,10 +336,7 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - ret.special = true; - ret.specialFormat = SpecialFormat::ASTC; - break; + case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: ret.type = ResourceFormatType::ASTC; break; default: break; } @@ -891,11 +831,11 @@ VkFormat MakeVkFormat(ResourceFormat fmt) { VkFormat ret = VK_FORMAT_UNDEFINED; - if(fmt.special) + if(fmt.Special()) { - switch(fmt.specialFormat) + switch(fmt.type) { - case SpecialFormat::BC1: + case ResourceFormatType::BC1: { if(fmt.compCount == 3) ret = fmt.srgbCorrected ? VK_FORMAT_BC1_RGB_SRGB_BLOCK : VK_FORMAT_BC1_RGB_UNORM_BLOCK; @@ -903,26 +843,26 @@ VkFormat MakeVkFormat(ResourceFormat fmt) ret = fmt.srgbCorrected ? VK_FORMAT_BC1_RGBA_SRGB_BLOCK : VK_FORMAT_BC1_RGBA_UNORM_BLOCK; break; } - case SpecialFormat::BC2: + case ResourceFormatType::BC2: ret = fmt.srgbCorrected ? VK_FORMAT_BC2_SRGB_BLOCK : VK_FORMAT_BC2_UNORM_BLOCK; break; - case SpecialFormat::BC3: + case ResourceFormatType::BC3: ret = fmt.srgbCorrected ? VK_FORMAT_BC3_SRGB_BLOCK : VK_FORMAT_BC3_UNORM_BLOCK; break; - case SpecialFormat::BC4: + case ResourceFormatType::BC4: ret = fmt.compType == CompType::SNorm ? VK_FORMAT_BC4_SNORM_BLOCK : VK_FORMAT_BC4_UNORM_BLOCK; break; - case SpecialFormat::BC5: + case ResourceFormatType::BC5: ret = fmt.compType == CompType::SNorm ? VK_FORMAT_BC5_SNORM_BLOCK : VK_FORMAT_BC5_UNORM_BLOCK; break; - case SpecialFormat::BC6: + case ResourceFormatType::BC6: ret = fmt.compType == CompType::SNorm ? VK_FORMAT_BC6H_SFLOAT_BLOCK : VK_FORMAT_BC6H_UFLOAT_BLOCK; break; - case SpecialFormat::BC7: + case ResourceFormatType::BC7: ret = fmt.srgbCorrected ? VK_FORMAT_BC7_SRGB_BLOCK : VK_FORMAT_BC7_UNORM_BLOCK; break; - case SpecialFormat::ETC2: + case ResourceFormatType::ETC2: { if(fmt.compCount == 3) ret = fmt.srgbCorrected ? VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK @@ -932,7 +872,7 @@ VkFormat MakeVkFormat(ResourceFormat fmt) : VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; break; } - case SpecialFormat::EAC: + case ResourceFormatType::EAC: { if(fmt.compCount == 1) ret = fmt.compType == CompType::SNorm ? VK_FORMAT_EAC_R11_SNORM_BLOCK @@ -942,7 +882,7 @@ VkFormat MakeVkFormat(ResourceFormat fmt) : VK_FORMAT_EAC_R11G11_UNORM_BLOCK; break; } - case SpecialFormat::R10G10B10A2: + case ResourceFormatType::R10G10B10A2: if(fmt.compType == CompType::UNorm) ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_UNORM_PACK32 : VK_FORMAT_A2B10G10R10_UNORM_PACK32; @@ -960,19 +900,19 @@ VkFormat MakeVkFormat(ResourceFormat fmt) ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_SSCALED_PACK32 : VK_FORMAT_A2B10G10R10_SSCALED_PACK32; break; - case SpecialFormat::R11G11B10: ret = VK_FORMAT_B10G11R11_UFLOAT_PACK32; break; - case SpecialFormat::R5G6B5: ret = VK_FORMAT_B5G6R5_UNORM_PACK16; break; - case SpecialFormat::R5G5B5A1: + case ResourceFormatType::R11G11B10: ret = VK_FORMAT_B10G11R11_UFLOAT_PACK32; break; + case ResourceFormatType::R5G6B5: ret = VK_FORMAT_B5G6R5_UNORM_PACK16; break; + case ResourceFormatType::R5G5B5A1: ret = fmt.bgraOrder ? VK_FORMAT_B5G5R5A1_UNORM_PACK16 : VK_FORMAT_R5G5B5A1_UNORM_PACK16; break; - case SpecialFormat::R9G9B9E5: ret = VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; break; - case SpecialFormat::R4G4B4A4: + case ResourceFormatType::R9G9B9E5: ret = VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; break; + case ResourceFormatType::R4G4B4A4: ret = fmt.bgraOrder ? VK_FORMAT_R4G4B4A4_UNORM_PACK16 : VK_FORMAT_B4G4R4A4_UNORM_PACK16; break; - case SpecialFormat::R4G4: ret = VK_FORMAT_R4G4_UNORM_PACK8; break; - case SpecialFormat::D24S8: ret = VK_FORMAT_D24_UNORM_S8_UINT; break; - case SpecialFormat::D32S8: ret = VK_FORMAT_D32_SFLOAT_S8_UINT; break; - default: RDCERR("Unsupported special format %u", fmt.specialFormat); break; + case ResourceFormatType::R4G4: ret = VK_FORMAT_R4G4_UNORM_PACK8; break; + case ResourceFormatType::D24S8: ret = VK_FORMAT_D24_UNORM_S8_UINT; break; + case ResourceFormatType::D32S8: ret = VK_FORMAT_D32_SFLOAT_S8_UINT; break; + default: RDCERR("Unsupported resource format type %u", fmt.type); break; } } else if(fmt.compCount == 4) diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index b8f9b466d..3f3bcbbfb 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -1410,24 +1410,21 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd) bool buf565 = false, buf5551 = false; bool bufBGRA = (fmt.bgraOrder != false); - if(fmt.special) + switch(fmt.type) { - switch(fmt.specialFormat) - { - case SpecialFormat::R10G10B10A2: - stride = 4; - buf1010102 = true; - break; - case SpecialFormat::R5G6B5: - stride = 2; - buf565 = true; - break; - case SpecialFormat::R5G5B5A1: - stride = 2; - buf5551 = true; - break; - default: break; - } + case ResourceFormatType::R10G10B10A2: + stride = 4; + buf1010102 = true; + break; + case ResourceFormatType::R5G6B5: + stride = 2; + buf565 = true; + break; + case ResourceFormatType::R5G5B5A1: + stride = 2; + buf5551 = true; + break; + default: break; } byte *dst = thpixels; diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index 5740e0118..08a060d40 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -8701,8 +8701,7 @@ MeshFormat VulkanDebugManager::GetPostVSBuffers(uint32_t eventID, uint32_t instI ret.fmt.compCount = 4; ret.fmt.compByteWidth = 4; ret.fmt.compType = CompType::Float; - ret.fmt.special = false; - ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.type = ResourceFormatType::Regular; ret.fmt.bgraOrder = false; ret.showAlpha = false; diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index e8aa427f0..cdfb88e15 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -2009,8 +2009,7 @@ void VulkanReplay::RenderMesh(uint32_t eventID, const vector &second helper.idxByteWidth = 2; helper.topo = Topology::LineList; - helper.fmt.special = false; - helper.fmt.specialFormat = SpecialFormat::Unknown; + helper.fmt.type = ResourceFormatType::Regular; helper.fmt.compByteWidth = 4; helper.fmt.compCount = 4; helper.fmt.compType = CompType::Float; diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index dc51964eb..eb211a0e0 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -516,42 +516,47 @@ static std::string ResourceFormatName(const ResourceFormat &fmt) { std::string ret; - if(fmt.special) + if(fmt.Special()) { - switch(fmt.specialFormat) + switch(fmt.type) { - case SpecialFormat::Unknown: return "Unknown"; - case SpecialFormat::BC1: return fmt.srgbCorrected ? "BC1_SRGB" : "BC1_UNORM"; - case SpecialFormat::BC2: return fmt.srgbCorrected ? "BC2_SRGB" : "BC2_UNORM"; - case SpecialFormat::BC3: return fmt.srgbCorrected ? "BC3_SRGB" : "BC3_UNORM"; - case SpecialFormat::BC4: return fmt.compType == CompType::UNorm ? "BC4_UNORM" : "BC4_SNORM"; - case SpecialFormat::BC5: return fmt.compType == CompType::UNorm ? "BC5_UNORM" : "BC5_SNORM"; - case SpecialFormat::BC6: return fmt.compType == CompType::UNorm ? "BC6_UFLOAT" : "BC6_SFLOAT"; - case SpecialFormat::BC7: return fmt.srgbCorrected ? "BC7_SRGB" : "BC7_UNORM"; - case SpecialFormat::ETC2: return fmt.srgbCorrected ? "ETC2_SRGB" : "ETC_UNORM"; - case SpecialFormat::EAC: + case ResourceFormatType::Undefined: return "Undefined"; + case ResourceFormatType::BC1: return fmt.srgbCorrected ? "BC1_SRGB" : "BC1_UNORM"; + case ResourceFormatType::BC2: return fmt.srgbCorrected ? "BC2_SRGB" : "BC2_UNORM"; + case ResourceFormatType::BC3: return fmt.srgbCorrected ? "BC3_SRGB" : "BC3_UNORM"; + case ResourceFormatType::BC4: + return fmt.compType == CompType::UNorm ? "BC4_UNORM" : "BC4_SNORM"; + case ResourceFormatType::BC5: + return fmt.compType == CompType::UNorm ? "BC5_UNORM" : "BC5_SNORM"; + case ResourceFormatType::BC6: + return fmt.compType == CompType::UNorm ? "BC6_UFLOAT" : "BC6_SFLOAT"; + case ResourceFormatType::BC7: return fmt.srgbCorrected ? "BC7_SRGB" : "BC7_UNORM"; + case ResourceFormatType::ETC2: return fmt.srgbCorrected ? "ETC2_SRGB" : "ETC_UNORM"; + case ResourceFormatType::EAC: { if(fmt.compCount == 1) return fmt.compType == CompType::UNorm ? "EAC_R_UNORM" : "EAC_R_SNORM"; else return fmt.compType == CompType::UNorm ? "EAC_RG_UNORM" : "EAC_RG_SNORM"; } - case SpecialFormat::ASTC: + case ResourceFormatType::ASTC: return fmt.srgbCorrected ? "ASTC_SRGB" : "ASTC_UNORM"; // 10:10:10 A2 is the only format that can have all the usual format types (unorm, snorm, // etc). So we break and handle it like any other format below. - case SpecialFormat::R10G10B10A2: ret = fmt.bgraOrder ? "B10G10R10A2" : "R10G10B10A2"; break; - case SpecialFormat::R11G11B10: return "R11G11B10_FLOAT"; - case SpecialFormat::R5G6B5: return fmt.bgraOrder ? "R5G6B5_UNORM" : "B5G6R5_UNORM"; - case SpecialFormat::R5G5B5A1: return fmt.bgraOrder ? "R5G5B5A1_UNORM" : "R5G5B5A1_UNORM"; - case SpecialFormat::R9G9B9E5: return "R9G9B9E5_FLOAT"; - case SpecialFormat::R4G4B4A4: return fmt.bgraOrder ? "R4G4B4A4_UNORM" : "B4G4R4A4_UNORM"; - case SpecialFormat::R4G4: return "R4G4_UNORM"; - case SpecialFormat::D16S8: return "D16S8"; - case SpecialFormat::D24S8: return "D24S8"; - case SpecialFormat::D32S8: return "D32S8"; - case SpecialFormat::S8: return "S8"; - case SpecialFormat::YUV: return "YUV"; + case ResourceFormatType::R10G10B10A2: + ret = fmt.bgraOrder ? "B10G10R10A2" : "R10G10B10A2"; + break; + case ResourceFormatType::R11G11B10: return "R11G11B10_FLOAT"; + case ResourceFormatType::R5G6B5: return fmt.bgraOrder ? "R5G6B5_UNORM" : "B5G6R5_UNORM"; + case ResourceFormatType::R5G5B5A1: return fmt.bgraOrder ? "R5G5B5A1_UNORM" : "R5G5B5A1_UNORM"; + case ResourceFormatType::R9G9B9E5: return "R9G9B9E5_FLOAT"; + case ResourceFormatType::R4G4B4A4: return fmt.bgraOrder ? "R4G4B4A4_UNORM" : "B4G4R4A4_UNORM"; + case ResourceFormatType::R4G4: return "R4G4_UNORM"; + case ResourceFormatType::D16S8: return "D16S8"; + case ResourceFormatType::D24S8: return "D24S8"; + case ResourceFormatType::D32S8: return "D32S8"; + case ResourceFormatType::S8: return "S8"; + case ResourceFormatType::YUV: return "YUV"; } } else if(fmt.compType == CompType::Depth) diff --git a/renderdoc/replay/replay_controller.cpp b/renderdoc/replay/replay_controller.cpp index 6e4d92b75..df6a7c237 100644 --- a/renderdoc/replay/replay_controller.cpp +++ b/renderdoc/replay/replay_controller.cpp @@ -592,8 +592,8 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path downcast = true; // we don't support any file formats that handle these block compression formats - if(td.format.specialFormat == SpecialFormat::ETC2 || - td.format.specialFormat == SpecialFormat::EAC || td.format.specialFormat == SpecialFormat::ASTC) + if(td.format.type == ResourceFormatType::ETC2 || td.format.type == ResourceFormatType::EAC || + td.format.type == ResourceFormatType::ASTC) downcast = true; // for DDS don't downcast, for non-HDR always downcast if we're not already RGBA8 unorm @@ -601,16 +601,15 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path if((sd.destType != FileType::DDS && sd.destType != FileType::HDR && sd.destType != FileType::EXR && (td.format.compByteWidth != 1 || td.format.compCount != 4 || td.format.compType != CompType::UNorm || td.format.bgraOrder)) || - downcast || (sd.destType != FileType::DDS && td.format.special && - td.format.specialFormat != SpecialFormat::R10G10B10A2 && - td.format.specialFormat != SpecialFormat::R11G11B10)) + downcast || (sd.destType != FileType::DDS && td.format.Special() && + td.format.type != ResourceFormatType::R10G10B10A2 && + td.format.type != ResourceFormatType::R11G11B10)) { downcast = true; td.format.compByteWidth = 1; td.format.compCount = 4; td.format.compType = CompType::UNorm; - td.format.special = false; - td.format.specialFormat = SpecialFormat::Unknown; + td.format.type = ResourceFormatType::Regular; } uint32_t rowPitch = 0; @@ -624,36 +623,36 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path td.height = RDCMAX(1U, td.height >> mipOffset); td.depth = RDCMAX(1U, td.depth >> mipOffset); - if(td.format.specialFormat == SpecialFormat::BC1 || - td.format.specialFormat == SpecialFormat::BC2 || td.format.specialFormat == SpecialFormat::BC3 || - td.format.specialFormat == SpecialFormat::BC4 || td.format.specialFormat == SpecialFormat::BC5 || - td.format.specialFormat == SpecialFormat::BC6 || td.format.specialFormat == SpecialFormat::BC7) + if(td.format.type == ResourceFormatType::BC1 || td.format.type == ResourceFormatType::BC2 || + td.format.type == ResourceFormatType::BC3 || td.format.type == ResourceFormatType::BC4 || + td.format.type == ResourceFormatType::BC5 || td.format.type == ResourceFormatType::BC6 || + td.format.type == ResourceFormatType::BC7) { - blockSize = (td.format.specialFormat == SpecialFormat::BC1 || - td.format.specialFormat == SpecialFormat::BC4) - ? 8 - : 16; + blockSize = + (td.format.type == ResourceFormatType::BC1 || td.format.type == ResourceFormatType::BC4) + ? 8 + : 16; rowPitch = RDCMAX(1U, ((td.width + 3) / 4)) * blockSize; slicePitch = rowPitch * RDCMAX(1U, td.height / 4); blockformat = true; } else { - switch(td.format.specialFormat) + switch(td.format.type) { - case SpecialFormat::S8: bytesPerPixel = 1; break; - case SpecialFormat::R10G10B10A2: - case SpecialFormat::R9G9B9E5: - case SpecialFormat::R11G11B10: - case SpecialFormat::D24S8: bytesPerPixel = 4; break; - case SpecialFormat::R5G6B5: - case SpecialFormat::R5G5B5A1: - case SpecialFormat::R4G4B4A4: bytesPerPixel = 2; break; - case SpecialFormat::D32S8: bytesPerPixel = 8; break; - case SpecialFormat::D16S8: - case SpecialFormat::YUV: - case SpecialFormat::R4G4: - RDCERR("Unsupported file format %u", td.format.specialFormat); + case ResourceFormatType::S8: bytesPerPixel = 1; break; + case ResourceFormatType::R10G10B10A2: + case ResourceFormatType::R9G9B9E5: + case ResourceFormatType::R11G11B10: + case ResourceFormatType::D24S8: bytesPerPixel = 4; break; + case ResourceFormatType::R5G6B5: + case ResourceFormatType::R5G5B5A1: + case ResourceFormatType::R4G4B4A4: bytesPerPixel = 2; break; + case ResourceFormatType::D32S8: bytesPerPixel = 8; break; + case ResourceFormatType::D16S8: + case ResourceFormatType::YUV: + case ResourceFormatType::R4G4: + RDCERR("Unsupported file format %u", td.format.type); return false; default: bytesPerPixel = td.format.compCount * td.format.compByteWidth; } @@ -1081,7 +1080,7 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path float b = 0.0f; float a = 1.0f; - if(saveFmt.special && saveFmt.specialFormat == SpecialFormat::R10G10B10A2) + if(saveFmt.type == ResourceFormatType::R10G10B10A2) { uint32_t *u32 = (uint32_t *)srcData; @@ -1094,7 +1093,7 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path srcData += 4; } - else if(saveFmt.special && saveFmt.specialFormat == SpecialFormat::R11G11B10) + else if(saveFmt.type == ResourceFormatType::R11G11B10) { uint32_t *u32 = (uint32_t *)srcData; diff --git a/renderdoc/replay/replay_driver.cpp b/renderdoc/replay/replay_driver.cpp index 45adb9e53..c40327450 100644 --- a/renderdoc/replay/replay_driver.cpp +++ b/renderdoc/replay/replay_driver.cpp @@ -112,7 +112,7 @@ FloatVector HighlightCache::InterpretVertex(byte *data, uint32_t vert, const Mes const ResourceFormat &fmt = cfg.position.fmt; - if(fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(fmt.type == ResourceFormatType::R10G10B10A2) { if(data + 4 >= end) { @@ -127,7 +127,7 @@ FloatVector HighlightCache::InterpretVertex(byte *data, uint32_t vert, const Mes ret.w = v.w; return ret; } - else if(fmt.specialFormat == SpecialFormat::R11G11B10) + else if(fmt.type == ResourceFormatType::R11G11B10) { if(data + 4 >= end) {