From 981436b75f5eb84c7246567786b55cc3a753da97 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 18 Aug 2017 17:23:00 +0100 Subject: [PATCH] Don't pass around string name of ResourceFormat, request it when needed --- .../D3D11PipelineStateViewer.cpp | 24 ++--- .../D3D12PipelineStateViewer.cpp | 24 ++--- .../PipelineState/GLPipelineStateViewer.cpp | 16 ++-- .../VulkanPipelineStateViewer.cpp | 16 ++-- qrenderdoc/Windows/ShaderViewer.cpp | 2 +- qrenderdoc/Windows/TextureViewer.cpp | 2 +- renderdoc/api/replay/data_types.h | 18 +++- renderdoc/core/replay_proxy.cpp | 31 ++++--- renderdoc/driver/dxgi/dxgi_common.cpp | 1 - renderdoc/driver/gl/gl_common.cpp | 57 ++++++------ renderdoc/driver/gl/gl_replay.cpp | 35 +------- renderdoc/driver/vulkan/vk_common.cpp | 33 ++++--- renderdoc/replay/entry_points.cpp | 87 +++++++++++++++++++ 13 files changed, 204 insertions(+), 142 deletions(-) diff --git a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp index b170845e4..3ca30f2c1 100644 --- a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp @@ -494,8 +494,8 @@ void D3D11PipelineStateViewer::setViewDetails(RDTreeWidgetItem *node, const D3D1 if(res.Format != tex->format) { text += tr("The texture is format %1, the view treats it as %2.\n") - .arg(tex->format.strname) - .arg(res.Format.strname); + .arg(tex->format.Name()) + .arg(res.Format.Name()); viewdetails = true; } @@ -626,7 +626,7 @@ void D3D11PipelineStateViewer::addResourceRow(const D3D11ViewTag &view, h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); @@ -636,7 +636,7 @@ void D3D11PipelineStateViewer::addResourceRow(const D3D11ViewTag &view, } if(tex->format != r.Format) - format = tr("Viewed as %1").arg(r.Format.strname); + format = tr("Viewed as %1").arg(r.Format.Name()); if(HasImportantViewParams(r, tex)) viewDetails = true; @@ -684,7 +684,7 @@ void D3D11PipelineStateViewer::addResourceRow(const D3D11ViewTag &view, } else { - format = r.Format.strname; + format = r.Format.Name(); } } @@ -1245,7 +1245,7 @@ void D3D11PipelineStateViewer::setState() if(showNode(usedSlot, filledSlot)) { RDTreeWidgetItem *node = - new RDTreeWidgetItem({i, l.SemanticName, l.SemanticIndex, l.Format.strname, l.InputSlot, + new RDTreeWidgetItem({i, l.SemanticName, l.SemanticIndex, l.Format.Name(), l.InputSlot, byteOffs, l.PerInstance ? lit("PER_INSTANCE") : lit("PER_VERTEX"), l.InstanceDataStepRate, QString()}); @@ -1924,7 +1924,7 @@ void D3D11PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in { const auto &desc = res.variableType.descriptor; - if(view.res.Format.strname.empty()) + if(view.res.Format.Name().empty()) { format = QString(); if(desc.rowMajorStorage) @@ -2297,7 +2297,7 @@ QVariantList D3D11PipelineStateViewer::exportViewHTML(D3D11Pipe::View &view, int uint32_t h = 1, d = 1; uint32_t a = 0; - QString viewFormat = view.Format.strname; + QString viewFormat = view.Format.Name(); TextureDescription *tex = m_Ctx.GetTexture(view.Resource); BufferDescription *buf = m_Ctx.GetBuffer(view.Resource); @@ -2311,7 +2311,7 @@ QVariantList D3D11PipelineStateViewer::exportViewHTML(D3D11Pipe::View &view, int h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); @@ -2334,7 +2334,7 @@ QVariantList D3D11PipelineStateViewer::exportViewHTML(D3D11Pipe::View &view, int h = 0; d = 0; a = 0; - format = view.Format.strname; + format = view.Format.Name(); name = buf->name; typeName = lit("Buffer"); @@ -2366,7 +2366,7 @@ QVariantList D3D11PipelineStateViewer::exportViewHTML(D3D11Pipe::View &view, int } else { - format = view.Format.strname; + format = view.Format.Name(); } } @@ -2397,7 +2397,7 @@ void D3D11PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, D3D11Pipe::IA & int i = 0; for(const D3D11Pipe::Layout &l : ia.layouts) { - rows.push_back({i, l.SemanticName, l.SemanticIndex, l.Format.strname, l.InputSlot, + rows.push_back({i, l.SemanticName, l.SemanticIndex, l.Format.Name(), l.InputSlot, l.ByteOffset, (bool)l.PerInstance, l.InstanceDataStepRate}); i++; diff --git a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp index 897f94ba2..52c4378a5 100644 --- a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp @@ -517,8 +517,8 @@ void D3D12PipelineStateViewer::setViewDetails(RDTreeWidgetItem *node, const D3D1 if(res.Format != tex->format) { text += tr("The texture is format %1, the view treats it as %2.\n") - .arg(tex->format.strname) - .arg(res.Format.strname); + .arg(tex->format.Name()) + .arg(res.Format.Name()); viewdetails = true; } @@ -704,7 +704,7 @@ void D3D12PipelineStateViewer::addResourceRow(const D3D12ViewTag &view, h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); @@ -714,7 +714,7 @@ void D3D12PipelineStateViewer::addResourceRow(const D3D12ViewTag &view, } if(tex->format != r.Format) - format = tr("Viewed as %1").arg(r.Format.strname); + format = tr("Viewed as %1").arg(r.Format.Name()); if(HasImportantViewParams(r, tex)) viewDetails = true; @@ -756,7 +756,7 @@ void D3D12PipelineStateViewer::addResourceRow(const D3D12ViewTag &view, else if(r.Format.compType == CompType::Typeless) format = shaderInput->variableType.descriptor.name; else - format = r.Format.strname; + format = r.Format.Name(); } if(HasImportantViewParams(r, buf)) @@ -1257,7 +1257,7 @@ void D3D12PipelineStateViewer::setState() if(showNode(usedSlot, filledSlot)) { RDTreeWidgetItem *node = - new RDTreeWidgetItem({i, l.SemanticName, l.SemanticIndex, l.Format.strname, l.InputSlot, + new RDTreeWidgetItem({i, l.SemanticName, l.SemanticIndex, l.Format.Name(), l.InputSlot, byteOffs, l.PerInstance ? lit("PER_INSTANCE") : lit("PER_VERTEX"), l.InstanceDataStepRate, QString()}); @@ -1797,7 +1797,7 @@ void D3D12PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in { const auto &desc = res.variableType.descriptor; - if(view.res.Format.strname.empty()) + if(view.res.Format.Name().empty()) { format = QString(); if(desc.rowMajorStorage) @@ -2140,7 +2140,7 @@ QVariantList D3D12PipelineStateViewer::exportViewHTML(const D3D12Pipe::View &vie uint32_t h = 1, d = 1; uint32_t a = 0; - QString viewFormat = view.Format.strname; + QString viewFormat = view.Format.Name(); TextureDescription *tex = m_Ctx.GetTexture(view.Resource); BufferDescription *buf = m_Ctx.GetBuffer(view.Resource); @@ -2154,7 +2154,7 @@ QVariantList D3D12PipelineStateViewer::exportViewHTML(const D3D12Pipe::View &vie h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); @@ -2194,7 +2194,7 @@ QVariantList D3D12PipelineStateViewer::exportViewHTML(const D3D12Pipe::View &vie h = 0; d = 0; a = 0; - format = view.Format.strname; + format = view.Format.Name(); name = buf->name; typeName = lit("Buffer"); @@ -2226,7 +2226,7 @@ QVariantList D3D12PipelineStateViewer::exportViewHTML(const D3D12Pipe::View &vie } else { - format = view.Format.strname; + format = view.Format.Name(); } } @@ -2266,7 +2266,7 @@ void D3D12PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, D3D12Pipe::IA & int i = 0; for(const D3D12Pipe::Layout &l : ia.layouts) { - rows.push_back({i, l.SemanticName, l.SemanticIndex, l.Format.strname, l.InputSlot, + rows.push_back({i, l.SemanticName, l.SemanticIndex, l.Format.Name(), l.InputSlot, l.ByteOffset, (bool)l.PerInstance, l.InstanceDataStepRate}); i++; diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp index 8b153025d..469d78cb0 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp @@ -672,7 +672,7 @@ void GLPipelineStateViewer::setShaderState(const GLPipe::Shader &stage, QLabel * h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); @@ -940,7 +940,7 @@ void GLPipelineStateViewer::setShaderState(const GLPipe::Shader &stage, QLabel * access = tr("Read-Only"); if(!im->readAllowed && im->writeAllowed) access = tr("Write-Only"); - format = im->Format.strname; + format = im->Format.Name(); } QVariant tag; @@ -1143,7 +1143,7 @@ void GLPipelineStateViewer::setState() RDTreeWidgetItem *node = new RDTreeWidgetItem( {i, a.Enabled ? tr("Enabled") : tr("Disabled"), name, - a.Enabled ? a.Format.strname : genericVal, a.BufferSlot, a.RelativeOffset}); + a.Enabled ? a.Format.Name() : genericVal, a.BufferSlot, a.RelativeOffset}); if(a.Enabled) usedBindings[a.BufferSlot] = true; @@ -1651,7 +1651,7 @@ void GLPipelineStateViewer::setState() h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); @@ -1736,7 +1736,7 @@ void GLPipelineStateViewer::setState() h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); } @@ -2280,7 +2280,7 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, GLPipe::VertexInpu QString generic; if(!a.Enabled) generic = MakeGenericValueString(a.Format.compCount, a.Format.compType, a); - rows.push_back({i, (bool)a.Enabled, a.BufferSlot, a.Format.strname, a.RelativeOffset, generic}); + rows.push_back({i, (bool)a.Enabled, a.BufferSlot, a.Format.Name(), a.RelativeOffset, generic}); i++; } @@ -2531,7 +2531,7 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, GLPipe::Shader &sh h = tex->height; d = tex->depth; a = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; typeName = ToQStr(tex->resType); @@ -2756,7 +2756,7 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, GLPipe::Shader &sh access = tr("Read-Only"); if(!im->readAllowed && im->writeAllowed) access = tr("Write-Only"); - format = im->Format.strname; + format = im->Format.Name(); } // check to see if it's a texture diff --git a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp index a5e35cec9..b3117e2dc 100644 --- a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp @@ -398,8 +398,8 @@ void VulkanPipelineStateViewer::setViewDetails(RDTreeWidgetItem *node, const bin if(view.viewfmt != tex->format) { text += tr("The texture is format %1, the view treats it as %2.\n") - .arg(tex->format.strname) - .arg(view.viewfmt.strname); + .arg(tex->format.Name()) + .arg(view.viewfmt.Name()); viewdetails = true; } @@ -816,7 +816,7 @@ void VulkanPipelineStateViewer::addResourceRow(ShaderReflection *shaderDetails, { name = tr("Object %1").arg(ToQStr(descriptorBind->res)); - format = descriptorBind->viewfmt.strname; + format = descriptorBind->viewfmt.Name(); // check to see if it's a texture tex = m_Ctx.GetTexture(descriptorBind->res); @@ -1444,7 +1444,7 @@ void VulkanPipelineStateViewer::setState() if(showNode(usedSlot, filledSlot)) { RDTreeWidgetItem *node = - new RDTreeWidgetItem({i, name, a.location, a.binding, a.format.strname, a.byteoffset}); + new RDTreeWidgetItem({i, name, a.location, a.binding, a.format.Name(), a.byteoffset}); usedBindings[a.binding] = true; @@ -1744,7 +1744,7 @@ void VulkanPipelineStateViewer::setState() { uint32_t w = 1, h = 1, d = 1; uint32_t a = 1; - QString format = p.viewfmt.strname; + QString format = p.viewfmt.Name(); QString name = tr("Texture ") + ToQStr(p.img); QString typeName = tr("Unknown"); @@ -2413,7 +2413,7 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, VKPipe::Vertex QList rows; for(const VKPipe::VertexAttribute &attr : vi.attrs) - rows.push_back({attr.location, attr.binding, attr.format.strname, attr.byteoffset}); + rows.push_back({attr.location, attr.binding, attr.format.Name(), attr.byteoffset}); m_Common.exportHTMLTable(xml, {tr("Location"), tr("Binding"), tr("Format"), tr("Offset")}, rows); } @@ -2688,7 +2688,7 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, VKPipe::Shader h = tex->height; d = tex->depth; arr = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; if(tex->mips > 1) @@ -2812,7 +2812,7 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, VKPipe::Shader h = tex->height; d = tex->depth; arr = tex->arraysize; - format = tex->format.strname; + format = tex->format.Name(); name = tex->name; if(tex->mips > 1) diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index 88406f29c..cb34c4854 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -1053,7 +1053,7 @@ RDTreeWidgetItem *ShaderViewer::makeResourceRegister(const BindpointMap &bind, u .arg(tex->height) .arg(tex->depth > 1 ? tex->depth : tex->arraysize) .arg(tex->mips) - .arg(tex->format.strname) + .arg(tex->format.Name()) .arg(tex->name); return new RDTreeWidgetItem({regname + name, lit("Texture"), type}); diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 392c0fb29..047f4c0d1 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -1026,7 +1026,7 @@ void TextureViewer::UI_UpdateTextureDetails() status += QFormatStr(" %1 mips").arg(current.mips); - status += lit(" - ") + ToQStr(current.format.strname); + status += lit(" - ") + current.format.Name(); if(current.format.compType != m_TexDisplay.typeHint && m_TexDisplay.typeHint != CompType::Typeless) { diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index d5d963e83..baf9ac579 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -64,6 +64,12 @@ struct PathEntry DECLARE_REFLECTION_STRUCT(PathEntry); +struct ResourceFormat; + +DOCUMENT("Internal function for getting the name for a resource format."); +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_ResourceFormatName(const ResourceFormat &fmt, + rdctype::str &name); + DOCUMENT("Description of the format of a resource or element."); struct ResourceFormat { @@ -89,6 +95,15 @@ struct ResourceFormat bgraOrder == r.bgraOrder && srgbCorrected == r.srgbCorrected; } + DOCUMENT(R"(:return: The name of the format. +:rtype: str +)"); + rdctype::str Name() const + { + rdctype::str ret; + 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 @@ -98,9 +113,6 @@ struct ResourceFormat DOCUMENT("The :class:`SpecialFormat` if it's a non-uniform layout like block-compressed."); SpecialFormat specialFormat; - DOCUMENT("The name of the format."); - rdctype::str strname; - DOCUMENT("The number of components in each vertex."); uint32_t compCount; DOCUMENT("The width in bytes of each component."); diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index 53841205a..b556dc834 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -104,14 +104,13 @@ void Serialiser::Serialise(const char *name, ResourceFormat &el) { Serialise("", el.special); Serialise("", el.specialFormat); - Serialise("", el.strname); Serialise("", el.compCount); Serialise("", el.compByteWidth); Serialise("", el.compType); Serialise("", el.bgraOrder); Serialise("", el.srgbCorrected); - SIZE_CHECK(48); + SIZE_CHECK(28); } template <> @@ -308,7 +307,7 @@ void Serialiser::Serialise(const char *name, D3D11Pipe::Layout &el) Serialise("", el.PerInstance); Serialise("", el.InstanceDataStepRate); - SIZE_CHECK(88); + SIZE_CHECK(64); } template <> @@ -345,7 +344,7 @@ void Serialiser::Serialise(const char *name, D3D11Pipe::View &el) Serialise("", el.ArraySize); Serialise("", el.FirstArraySlice); - SIZE_CHECK(112); + SIZE_CHECK(88); } template <> @@ -462,7 +461,7 @@ void Serialiser::Serialise(const char *name, D3D11Pipe::OM &el) Serialise("", el.DepthReadOnly); Serialise("", el.StencilReadOnly); - SIZE_CHECK(280); + SIZE_CHECK(256); } template <> @@ -482,7 +481,7 @@ void Serialiser::Serialise(const char *name, D3D11Pipe::State &el) Serialise("", el.m_RS); Serialise("", el.m_OM); - SIZE_CHECK(1624); + SIZE_CHECK(1600); } #pragma endregion D3D11 pipeline state @@ -500,7 +499,7 @@ void Serialiser::Serialise(const char *name, D3D12Pipe::Layout &el) Serialise("", el.PerInstance); Serialise("", el.InstanceDataStepRate); - SIZE_CHECK(88); + SIZE_CHECK(64); } template <> @@ -580,7 +579,7 @@ void Serialiser::Serialise(const char *name, D3D12Pipe::View &el) Serialise("", el.MinLODClamp); - SIZE_CHECK(168); + SIZE_CHECK(144); } template <> @@ -675,7 +674,7 @@ void Serialiser::Serialise(const char *name, D3D12Pipe::OM &el) Serialise("", el.multiSampleCount); Serialise("", el.multiSampleQuality); - SIZE_CHECK(296); + SIZE_CHECK(272); } template <> @@ -721,7 +720,7 @@ void Serialiser::Serialise(const char *name, D3D12Pipe::State &el) Serialise("", el.Resources); - SIZE_CHECK(1144); + SIZE_CHECK(1120); } #pragma endregion D3D12 pipeline state @@ -737,7 +736,7 @@ void Serialiser::Serialise(const char *name, GLPipe::VertexAttribute &el) Serialise("", el.BufferSlot); Serialise("", el.RelativeOffset); - SIZE_CHECK(80); + SIZE_CHECK(56); } template <> @@ -809,7 +808,7 @@ void Serialiser::Serialise(const char *name, GLPipe::ImageLoadStore &el) Serialise("", el.writeAllowed); Serialise("", el.Format); - SIZE_CHECK(80); + SIZE_CHECK(64); } template <> @@ -993,7 +992,7 @@ void Serialiser::Serialise(const char *name, VKPipe::BindingElement &el) SerialisePODArray<4>("", el.BorderColor); Serialise("", el.unnormalized); - SIZE_CHECK(224); + SIZE_CHECK(200); }; template <> @@ -1038,7 +1037,7 @@ void Serialiser::Serialise(const char *name, VKPipe::VertexAttribute &el) Serialise("", el.format); Serialise("", el.byteoffset); - SIZE_CHECK(64); + SIZE_CHECK(40); } template <> @@ -1134,7 +1133,7 @@ void Serialiser::Serialise(const char *name, VKPipe::Attachment &el) Serialise("", el.numMip); Serialise("", el.numLayer); - SIZE_CHECK(96); + SIZE_CHECK(80); } template <> @@ -1264,7 +1263,7 @@ void Serialiser::Serialise(const char *name, TextureDescription &el) Serialise("", el.msSamp); Serialise("", el.byteSize); - SIZE_CHECK(136); + SIZE_CHECK(112); } template <> diff --git a/renderdoc/driver/dxgi/dxgi_common.cpp b/renderdoc/driver/dxgi/dxgi_common.cpp index 34acbf252..ece23a117 100644 --- a/renderdoc/driver/dxgi/dxgi_common.cpp +++ b/renderdoc/driver/dxgi/dxgi_common.cpp @@ -1489,7 +1489,6 @@ ResourceFormat MakeResourceFormat(DXGI_FORMAT fmt) ResourceFormat ret; ret.special = false; - ret.strname = ToStr::Get(fmt).substr(12); // 12 == strlen("DXGI_FORMAT_") ret.compCount = ret.compByteWidth = 0; ret.compType = CompType::Float; diff --git a/renderdoc/driver/gl/gl_common.cpp b/renderdoc/driver/gl/gl_common.cpp index c6b98e5bc..dd8f120df 100644 --- a/renderdoc/driver/gl/gl_common.cpp +++ b/renderdoc/driver/gl/gl_common.cpp @@ -1211,7 +1211,6 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt ret.special = false; ret.specialFormat = SpecialFormat::Unknown; - ret.strname = ToStr::Get(fmt).substr(3); // 3 == strlen("GL_") // special handling for formats that don't query neatly if(fmt == eGL_LUMINANCE8_EXT || fmt == eGL_INTENSITY8_EXT || fmt == eGL_ALPHA8_EXT) @@ -1333,34 +1332,34 @@ ResourceFormat MakeResourceFormat(const GLHookSet &gl, GLenum target, GLenum fmt ret.specialFormat = SpecialFormat::EAC; break; // ASTC - case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: - case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: - case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: - case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: - case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: - case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: - case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: - case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: - case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: - case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: - case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: - case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: - case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: - case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + case eGL_COMPRESSED_RGBA_ASTC_4x4_KHR: + case eGL_COMPRESSED_RGBA_ASTC_5x4_KHR: + case eGL_COMPRESSED_RGBA_ASTC_5x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_6x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_6x6_KHR: + case eGL_COMPRESSED_RGBA_ASTC_8x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_8x6_KHR: + case eGL_COMPRESSED_RGBA_ASTC_8x8_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x5_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x6_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x8_KHR: + case eGL_COMPRESSED_RGBA_ASTC_10x10_KHR: + case eGL_COMPRESSED_RGBA_ASTC_12x10_KHR: + case eGL_COMPRESSED_RGBA_ASTC_12x12_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + 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; default: RDCERR("Unexpected compressed format %#x", fmt); break; diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 50def50f7..a833b23f2 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -951,83 +951,56 @@ void GLReplay::SavePipelineState() case eGL_BYTE: fmt.compByteWidth = 1; fmt.compType = intComponent ? CompType::SInt : CompType::SNorm; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_BYTE%d", fmt.compCount) - : string("GL_BYTE")) + - (intComponent ? "" : "_SNORM"); break; case eGL_UNSIGNED_BYTE: fmt.compByteWidth = 1; fmt.compType = intComponent ? CompType::UInt : CompType::UNorm; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_UNSIGNED_BYTE%d", fmt.compCount) - : string("GL_UNSIGNED_BYTE")) + - (intComponent ? "" : "_UNORM"); break; case eGL_SHORT: fmt.compByteWidth = 2; fmt.compType = intComponent ? CompType::SInt : CompType::SNorm; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_SHORT%d", fmt.compCount) - : string("GL_SHORT")) + - (intComponent ? "" : "_SNORM"); break; case eGL_UNSIGNED_SHORT: fmt.compByteWidth = 2; fmt.compType = intComponent ? CompType::UInt : CompType::UNorm; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_UNSIGNED_SHORT%d", fmt.compCount) - : string("GL_UNSIGNED_SHORT")) + - (intComponent ? "" : "_UNORM"); break; case eGL_INT: fmt.compByteWidth = 4; fmt.compType = intComponent ? CompType::SInt : CompType::SNorm; - fmt.strname = - (fmt.compCount > 1 ? StringFormat::Fmt("GL_INT%d", fmt.compCount) : string("GL_INT")) + - (intComponent ? "" : "_SNORM"); break; case eGL_UNSIGNED_INT: fmt.compByteWidth = 4; fmt.compType = intComponent ? CompType::UInt : CompType::UNorm; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_UNSIGNED_INT%d", fmt.compCount) - : string("GL_UNSIGNED_INT")) + - (intComponent ? "" : "_UNORM"); break; case eGL_FLOAT: fmt.compByteWidth = 4; fmt.compType = CompType::Float; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_FLOAT%d", fmt.compCount) - : string("GL_FLOAT")); break; case eGL_DOUBLE: fmt.compByteWidth = 8; fmt.compType = CompType::Double; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_DOUBLE%d", fmt.compCount) - : string("GL_DOUBLE")); break; case eGL_HALF_FLOAT: fmt.compByteWidth = 2; fmt.compType = CompType::Float; - fmt.strname = (fmt.compCount > 1 ? StringFormat::Fmt("GL_HALF_FLOAT%d", fmt.compCount) - : string("GL_HALF_FLOAT")); break; case eGL_INT_2_10_10_10_REV: fmt.special = true; fmt.specialFormat = SpecialFormat::R10G10B10A2; fmt.compCount = 4; fmt.compType = CompType::UInt; - fmt.strname = "GL_INT_2_10_10_10_REV"; break; case eGL_UNSIGNED_INT_2_10_10_10_REV: fmt.special = true; fmt.specialFormat = SpecialFormat::R10G10B10A2; fmt.compCount = 4; fmt.compType = CompType::SInt; - fmt.strname = "GL_UNSIGNED_INT_2_10_10_10_REV"; break; case eGL_UNSIGNED_INT_10F_11F_11F_REV: fmt.special = true; fmt.specialFormat = SpecialFormat::R11G11B10; fmt.compCount = 3; fmt.compType = CompType::Float; - fmt.strname = "GL_UNSIGNED_INT_10F_11F_11F_REV"; break; } @@ -1038,16 +1011,10 @@ void GLReplay::SavePipelineState() fmt.bgraOrder = true; fmt.compType = CompType::UNorm; - if(type == eGL_UNSIGNED_BYTE) - { - fmt.strname = "GL_BGRA8"; - } - else if(type == eGL_UNSIGNED_INT_2_10_10_10_REV || type == eGL_INT_2_10_10_10_REV) + if(type == eGL_UNSIGNED_INT_2_10_10_10_REV || type == eGL_INT_2_10_10_10_REV) { fmt.specialFormat = SpecialFormat::R10G10B10A2; fmt.compType = type == eGL_UNSIGNED_INT_2_10_10_10_REV ? CompType::UInt : CompType::SInt; - fmt.strname = type == eGL_UNSIGNED_INT_2_10_10_10_REV ? "GL_UNSIGNED_INT_2_10_10_10_REV" - : "GL_INT_2_10_10_10_REV"; } else { diff --git a/renderdoc/driver/vulkan/vk_common.cpp b/renderdoc/driver/vulkan/vk_common.cpp index fe6d86302..65775d5cb 100644 --- a/renderdoc/driver/vulkan/vk_common.cpp +++ b/renderdoc/driver/vulkan/vk_common.cpp @@ -246,7 +246,6 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) ret.special = false; ret.specialFormat = SpecialFormat::Unknown; - ret.strname = ToStr::Get(fmt).substr(10); // 3 == strlen("VK_FORMAT_") ret.compByteWidth = 0; ret.compCount = 0; ret.compType = CompType::Typeless; @@ -414,12 +413,12 @@ ResourceFormat MakeResourceFormat(VkFormat fmt) case VK_FORMAT_B8G8R8A8_UINT: case VK_FORMAT_B8G8R8A8_SINT: case VK_FORMAT_B8G8R8A8_SRGB: - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: - case VK_FORMAT_A2B10G10R10_SNORM_PACK32: - case VK_FORMAT_A2B10G10R10_USCALED_PACK32: - case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: - case VK_FORMAT_A2B10G10R10_UINT_PACK32: - case VK_FORMAT_A2B10G10R10_SINT_PACK32: ret.bgraOrder = true; break; + case VK_FORMAT_A2R10G10B10_UNORM_PACK32: + case VK_FORMAT_A2R10G10B10_SNORM_PACK32: + case VK_FORMAT_A2R10G10B10_USCALED_PACK32: + case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: + case VK_FORMAT_A2R10G10B10_UINT_PACK32: + case VK_FORMAT_A2R10G10B10_SINT_PACK32: ret.bgraOrder = true; break; default: break; } @@ -945,21 +944,21 @@ VkFormat MakeVkFormat(ResourceFormat fmt) } case SpecialFormat::R10G10B10A2: if(fmt.compType == CompType::UNorm) - ret = fmt.bgraOrder ? VK_FORMAT_A2B10G10R10_UNORM_PACK32 - : VK_FORMAT_A2R10G10B10_UNORM_PACK32; + ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_UNORM_PACK32 + : VK_FORMAT_A2B10G10R10_UNORM_PACK32; else if(fmt.compType == CompType::UInt) - ret = fmt.bgraOrder ? VK_FORMAT_A2B10G10R10_UINT_PACK32 : VK_FORMAT_A2R10G10B10_UINT_PACK32; + ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_UINT_PACK32 : VK_FORMAT_A2B10G10R10_UINT_PACK32; else if(fmt.compType == CompType::UScaled) - ret = fmt.bgraOrder ? VK_FORMAT_A2B10G10R10_USCALED_PACK32 - : VK_FORMAT_A2R10G10B10_USCALED_PACK32; + ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_USCALED_PACK32 + : VK_FORMAT_A2B10G10R10_USCALED_PACK32; else if(fmt.compType == CompType::SNorm) - ret = fmt.bgraOrder ? VK_FORMAT_A2B10G10R10_SNORM_PACK32 - : VK_FORMAT_A2R10G10B10_SNORM_PACK32; + ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_SNORM_PACK32 + : VK_FORMAT_A2B10G10R10_SNORM_PACK32; else if(fmt.compType == CompType::SInt) - ret = fmt.bgraOrder ? VK_FORMAT_A2B10G10R10_SINT_PACK32 : VK_FORMAT_A2R10G10B10_SINT_PACK32; + ret = fmt.bgraOrder ? VK_FORMAT_A2R10G10B10_SINT_PACK32 : VK_FORMAT_A2B10G10R10_SINT_PACK32; else if(fmt.compType == CompType::SScaled) - ret = fmt.bgraOrder ? VK_FORMAT_A2B10G10R10_SSCALED_PACK32 - : VK_FORMAT_A2R10G10B10_SSCALED_PACK32; + 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; diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index 355e40c40..dc51964eb 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -511,3 +511,90 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_UpdateVulkanLayerRegistrati { RenderDoc::Inst().UpdateVulkanLayerRegistration(systemLevel); } + +static std::string ResourceFormatName(const ResourceFormat &fmt) +{ + std::string ret; + + if(fmt.special) + { + switch(fmt.specialFormat) + { + 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: + { + 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: + 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"; + } + } + else if(fmt.compType == CompType::Depth) + { + ret = StringFormat::Fmt("D%u", fmt.compByteWidth * 8); + } + else + { + char comps[] = "RGBA"; + + if(fmt.bgraOrder) + std::swap(comps[0], comps[2]); + + for(uint32_t i = 0; i < fmt.compCount; i++) + ret += StringFormat::Fmt("%c%u", comps[i], fmt.compByteWidth * 8); + } + + if(fmt.srgbCorrected) + return ret + "_SRGB"; + + switch(fmt.compType) + { + case CompType::Typeless: return ret + "_TYPELESS"; + case CompType::Float: + case CompType::Double: return ret + "_FLOAT"; + case CompType::UNorm: return ret + "_UNORM"; + case CompType::SNorm: return ret + "_SNORM"; + case CompType::UInt: return ret + "_UINT"; + case CompType::SInt: return ret + "_SINT"; + case CompType::UScaled: return ret + "_USCALED"; + case CompType::SScaled: return ret + "_SSCALED"; + case CompType::Depth: + // we already special-cased depth component type above to be Dx instead of Rx + return ret; + } + + // should never get here + RDCERR("Unhandled format component type"); + return ret + "_UNKNOWN"; +} + +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_ResourceFormatName(const ResourceFormat &fmt, + rdctype::str &name) +{ + name = ResourceFormatName(fmt); +}