From c2a8e19d07c35e94c922a1f6ca4d0cb0c32d0f06 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 30 Oct 2017 10:45:51 +0000 Subject: [PATCH] Split D3D12 struct serialisers separately&serialise interfaces directly * Interface objects are serialised by type as their ResourceId - see the D3D11 code that does the same thing for more explanation. --- renderdoc/driver/d3d12/d3d12_common.cpp | 1057 ----------------- renderdoc/driver/d3d12/d3d12_common.h | 195 ++- renderdoc/driver/d3d12/d3d12_device_wrap.cpp | 2 +- renderdoc/driver/d3d12/d3d12_manager.cpp | 40 +- renderdoc/driver/d3d12/d3d12_manager.h | 44 +- renderdoc/driver/d3d12/d3d12_replay.cpp | 16 +- renderdoc/driver/d3d12/d3d12_resources.cpp | 41 +- renderdoc/driver/d3d12/d3d12_resources.h | 18 +- renderdoc/driver/d3d12/d3d12_serialise.cpp | 1004 ++++++++++++++++ renderdoc/driver/d3d12/d3d12_state.cpp | 6 +- renderdoc/driver/d3d12/d3d12_stringise.cpp | 18 +- .../driver/d3d12/renderdoc_d3d12.vcxproj | 1 + .../d3d12/renderdoc_d3d12.vcxproj.filters | 3 + 13 files changed, 1257 insertions(+), 1188 deletions(-) create mode 100644 renderdoc/driver/d3d12/d3d12_serialise.cpp diff --git a/renderdoc/driver/d3d12/d3d12_common.cpp b/renderdoc/driver/d3d12/d3d12_common.cpp index d55a1a546..725b330d5 100644 --- a/renderdoc/driver/d3d12/d3d12_common.cpp +++ b/renderdoc/driver/d3d12/d3d12_common.cpp @@ -363,24 +363,6 @@ StencilOp MakeStencilOp(D3D12_STENCIL_OP op) return StencilOp::Keep; } -enum D3D12ResourceBarrierSubresource -{ - D3D12AllSubresources = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES -}; - -template <> -std::string DoStringise(const D3D12ResourceBarrierSubresource &el) -{ - if(el == D3D12AllSubresources) - return "All Subresources"; - - return ToStr(uint32_t(el)); -} - -enum D3D12ComponentMapping -{ -}; - UINT GetResourceNumMipLevels(const D3D12_RESOURCE_DESC *desc) { switch(desc->Dimension) @@ -478,1042 +460,3 @@ ShaderStageMask ConvertVisibility(D3D12_SHADER_VISIBILITY ShaderVisibility) return ShaderStageMask::Vertex; } - -template <> -std::string DoStringise(const D3D12ComponentMapping &el) -{ - std::string ret; - - // value should always be <= 5, see D3D12_SHADER_COMPONENT_MAPPING - const char mapping[] = {'R', 'G', 'B', 'A', '0', '1', '?', '!'}; - - uint32_t swizzle = (uint32_t)el; - - for(int i = 0; i < 4; i++) - ret += mapping[D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(i, swizzle)]; - - return ret; -} - -#define SerialiseObject(type, name, obj) \ - { \ - D3D12ResourceManager *rm = (D3D12ResourceManager *)GetUserData(); \ - ResourceId id; \ - if(m_Mode >= WRITING) \ - id = GetResID(obj); \ - Serialise(name, id); \ - if(m_Mode < WRITING) \ - obj = (id == ResourceId() || !rm->HasLiveResource(id)) ? NULL \ - : Unwrap(rm->GetLiveAs(id)); \ - } - -#define SerialiseWrappedObject(type, name, obj) \ - { \ - D3D12ResourceManager *rm = (D3D12ResourceManager *)GetUserData(); \ - ResourceId id; \ - if(m_Mode >= WRITING) \ - id = GetResID(obj); \ - Serialise(name, id); \ - if(m_Mode < WRITING) \ - obj = (id == ResourceId() || !rm->HasLiveResource(id)) ? NULL : rm->GetLiveAs(id); \ - } - -template <> -void Serialiser::Serialise(const char *name, D3D12Descriptor &el) -{ - ScopedContext scope(this, name, "D3D12Descriptor", 0, true); - - D3D12Descriptor::DescriptorType type = el.GetType(); - Serialise("type", type); - - // we serialise the heap by hand because we want to keep it wrapped - { - D3D12ResourceManager *rm = (D3D12ResourceManager *)GetUserData(); - - PortableHandle handle; - - if(m_Mode >= WRITING) - handle = - PortableHandle(el.samp.heap ? el.samp.heap->GetResourceID() : ResourceId(), el.samp.idx); - - Serialise("handle", handle); - - if(m_Mode < WRITING) - { - el.samp.heap = (handle.heap == ResourceId() || !rm->HasLiveResource(handle.heap)) - ? NULL - : rm->GetLiveAs(handle.heap); - el.samp.idx = handle.index; - } - } - - // for sampler types, this will be overwritten when serialising the sampler descriptor - if(m_Mode < WRITING) - el.nonsamp.type = type; - - switch(type) - { - case D3D12Descriptor::TypeSampler: - { - Serialise("Descriptor", el.samp.desc); - RDCASSERTEQUAL(el.GetType(), D3D12Descriptor::TypeSampler); - break; - } - case D3D12Descriptor::TypeCBV: - { - Serialise("Descriptor", el.nonsamp.cbv); - break; - } - case D3D12Descriptor::TypeSRV: - { - SerialiseWrappedObject(ID3D12Resource, "Resource", el.nonsamp.resource); - Serialise("Descriptor", el.nonsamp.srv); - break; - } - case D3D12Descriptor::TypeRTV: - { - SerialiseWrappedObject(ID3D12Resource, "Resource", el.nonsamp.resource); - Serialise("Descriptor", el.nonsamp.rtv); - break; - } - case D3D12Descriptor::TypeDSV: - { - SerialiseWrappedObject(ID3D12Resource, "Resource", el.nonsamp.resource); - Serialise("Descriptor", el.nonsamp.dsv); - break; - } - case D3D12Descriptor::TypeUAV: - { - SerialiseWrappedObject(ID3D12Resource, "Resource", el.nonsamp.resource); - SerialiseWrappedObject(ID3D12Resource, "CounterResource", el.nonsamp.uav.counterResource); - - // special case because of extra resource and squeezed descriptor - D3D12_UNORDERED_ACCESS_VIEW_DESC desc = el.nonsamp.uav.desc.AsDesc(); - Serialise("Descriptor", desc); - el.nonsamp.uav.desc.Init(desc); - break; - } - case D3D12Descriptor::TypeUndefined: - { - el.nonsamp.type = type; - break; - } - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_RESOURCE_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_RESOURCE_DESC", 0, true); - - Serialise("Dimension", el.Dimension); - Serialise("Alignment", el.Alignment); - Serialise("Width", el.Width); - Serialise("Height", el.Height); - Serialise("DepthOrArraySize", el.DepthOrArraySize); - Serialise("MipLevels", el.MipLevels); - Serialise("Format", el.Format); - Serialise("SampleDesc", el.SampleDesc); - Serialise("Layout", el.Layout); - Serialise("Flags", el.Flags); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_COMMAND_QUEUE_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_COMMAND_QUEUE_DESC", 0, true); - - Serialise("Type", el.Type); - Serialise("Priority", el.Priority); - Serialise("Flags", el.Flags); - Serialise("NodeMask", el.NodeMask); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_SHADER_BYTECODE &el) -{ - ScopedContext scope(this, name, "D3D12_SHADER_BYTECODE", 0, true); - - uint64_t dataSize = el.BytecodeLength; - Serialise("BytecodeLength", dataSize); - size_t sz = (size_t)dataSize; - if(m_Mode == READING) - { - el.pShaderBytecode = NULL; - el.BytecodeLength = sz; - } - - if(dataSize > 0) - SerialiseBuffer("pShaderBytecode", (byte *&)el.pShaderBytecode, sz); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_SO_DECLARATION_ENTRY &el) -{ - ScopedContext scope(this, name, "D3D12_SO_DECLARATION_ENTRY", 0, true); - - Serialise("Stream", el.Stream); - - { - string s = ""; - if(m_Mode == WRITING && el.SemanticName) - s = el.SemanticName; - - Serialise("SemanticName", s); - - if(m_Mode == READING) - { - m_StringDB.insert(s); - el.SemanticName = m_StringDB.find(s)->c_str(); - } - } - - Serialise("SemanticIndex", el.SemanticIndex); - Serialise("StartComponent", el.StartComponent); - Serialise("ComponentCount", el.ComponentCount); - Serialise("OutputSlot", el.OutputSlot); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_STREAM_OUTPUT_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_STREAM_OUTPUT_DESC", 0, true); - - if(m_Mode == READING) - { - el.pSODeclaration = NULL; - el.pBufferStrides = NULL; - } - - SerialiseComplexArray("pSODeclaration", (D3D12_SO_DECLARATION_ENTRY *&)el.pSODeclaration, - el.NumEntries); - SerialisePODArray("pBufferStrides", (UINT *&)el.pBufferStrides, el.NumStrides); - Serialise("RasterizedStream", el.RasterizedStream); -} - -template <> -void Serialiser::Deserialise(const D3D12_STREAM_OUTPUT_DESC *const el) const -{ - if(m_Mode == READING) - { - delete[] el->pSODeclaration; - delete[] el->pBufferStrides; - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_RENDER_TARGET_BLEND_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_RENDER_TARGET_BLEND_DESC", 0, true); - - Serialise("BlendEnable", el.BlendEnable); - Serialise("LogicOpEnable", el.LogicOpEnable); - Serialise("SrcBlend", el.SrcBlend); - Serialise("DestBlend", el.DestBlend); - Serialise("BlendOp", el.BlendOp); - Serialise("SrcBlendAlpha", el.SrcBlendAlpha); - Serialise("DestBlendAlpha", el.DestBlendAlpha); - Serialise("BlendOpAlpha", el.BlendOpAlpha); - Serialise("LogicOp", el.LogicOp); - Serialise("RenderTargetWriteMask", el.RenderTargetWriteMask); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_BLEND_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_BLEND_DESC", 0, true); - - Serialise("AlphaToCoverageEnable", el.AlphaToCoverageEnable); - Serialise("IndependentBlendEnable", el.IndependentBlendEnable); - for(int i = 0; i < 8; i++) - { - ScopedContext targetscope(this, name, "D3D12_RENDER_TARGET_BLEND_DESC", 0, true); - - bool enable = el.RenderTarget[i].BlendEnable == TRUE; - Serialise("BlendEnable", enable); - el.RenderTarget[i].BlendEnable = enable; - - enable = el.RenderTarget[i].LogicOpEnable == TRUE; - Serialise("LogicOpEnable", enable); - el.RenderTarget[i].LogicOpEnable = enable; - - Serialise("SrcBlend", el.RenderTarget[i].SrcBlend); - Serialise("DestBlend", el.RenderTarget[i].DestBlend); - Serialise("BlendOp", el.RenderTarget[i].BlendOp); - Serialise("SrcBlendAlpha", el.RenderTarget[i].SrcBlendAlpha); - Serialise("DestBlendAlpha", el.RenderTarget[i].DestBlendAlpha); - Serialise("BlendOpAlpha", el.RenderTarget[i].BlendOpAlpha); - Serialise("LogicOp", el.RenderTarget[i].LogicOp); - Serialise("RenderTargetWriteMask", el.RenderTarget[i].RenderTargetWriteMask); - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_RASTERIZER_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_RASTERIZER_DESC", 0, true); - - Serialise("FillMode", el.FillMode); - Serialise("CullMode", el.CullMode); - Serialise("FrontCounterClockwise", el.FrontCounterClockwise); - Serialise("DepthBias", el.DepthBias); - Serialise("DepthBiasClamp", el.DepthBiasClamp); - Serialise("SlopeScaledDepthBias", el.SlopeScaledDepthBias); - Serialise("DepthClipEnable", el.DepthClipEnable); - Serialise("MultisampleEnable", el.MultisampleEnable); - Serialise("AntialiasedLineEnable", el.AntialiasedLineEnable); - Serialise("ForcedSampleCount", el.ForcedSampleCount); - Serialise("ConservativeRaster", el.ConservativeRaster); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_DEPTH_STENCILOP_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_DEPTH_STENCILOP_DESC", 0, true); - - Serialise("StencilFailOp", el.StencilFailOp); - Serialise("StencilDepthFailOp", el.StencilDepthFailOp); - Serialise("StencilPassOp", el.StencilPassOp); - Serialise("StencilFunc", el.StencilFunc); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_DEPTH_STENCIL_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_DEPTH_STENCIL_DESC", 0, true); - - Serialise("DepthEnable", el.DepthEnable); - Serialise("DepthWriteMask", el.DepthWriteMask); - Serialise("DepthFunc", el.DepthFunc); - Serialise("StencilEnable", el.StencilEnable); - Serialise("StencilReadMask", el.StencilReadMask); - Serialise("StencilWriteMask", el.StencilWriteMask); - Serialise("FrontFace", el.FrontFace); - Serialise("BackFace", el.BackFace); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_INPUT_ELEMENT_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_INPUT_ELEMENT_DESC", 0, true); - - { - string s = ""; - if(m_Mode == WRITING && el.SemanticName) - s = el.SemanticName; - - Serialise("SemanticName", s); - - if(m_Mode == READING) - { - m_StringDB.insert(s); - el.SemanticName = m_StringDB.find(s)->c_str(); - } - } - - Serialise("SemanticIndex", el.SemanticIndex); - Serialise("Format", el.Format); - Serialise("InputSlot", el.InputSlot); - Serialise("AlignedByteOffset", el.AlignedByteOffset); - Serialise("InputSlotClass", el.InputSlotClass); - Serialise("InstanceDataStepRate", el.InstanceDataStepRate); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_INPUT_LAYOUT_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_INPUT_LAYOUT_DESC", 0, true); - - SerialiseComplexArray("pInputElementDescs", (D3D12_INPUT_ELEMENT_DESC *&)el.pInputElementDescs, - el.NumElements); -} - -template <> -void Serialiser::Deserialise(const D3D12_INPUT_LAYOUT_DESC *const el) const -{ - if(m_Mode == READING) - delete[] el->pInputElementDescs; -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_INDIRECT_ARGUMENT_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_INDIRECT_ARGUMENT_DESC", 0, true); - - Serialise("Type", el.Type); - - switch(el.Type) - { - case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW: - case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED: - case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH: - case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW: - // nothing to serialise - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW: - Serialise("VertexBuffer.Slot", el.VertexBuffer.Slot); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT: - Serialise("Constant.RootParameterIndex", el.Constant.RootParameterIndex); - Serialise("Constant.DestOffsetIn32BitValues", el.Constant.DestOffsetIn32BitValues); - Serialise("Constant.Num32BitValuesToSet", el.Constant.Num32BitValuesToSet); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW: - Serialise("ConstantBufferView.RootParameterIndex", el.ConstantBufferView.RootParameterIndex); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW: - Serialise("ShaderResourceView.RootParameterIndex", el.ShaderResourceView.RootParameterIndex); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW: - Serialise("UnorderedAccessView.RootParameterIndex", el.UnorderedAccessView.RootParameterIndex); - break; - default: RDCERR("Unexpected indirect argument type: %u", el.Type); break; - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_COMMAND_SIGNATURE_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_COMMAND_SIGNATURE_DESC", 0, true); - - Serialise("ByteStride", el.ByteStride); - Serialise("NodeMask", el.NodeMask); - SerialiseComplexArray("pArgumentDescs", (D3D12_INDIRECT_ARGUMENT_DESC *&)el.pArgumentDescs, - el.NumArgumentDescs); -} - -template <> -void Serialiser::Deserialise(const D3D12_COMMAND_SIGNATURE_DESC *const el) const -{ - if(m_Mode == READING) - delete[] el->pArgumentDescs; -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_GRAPHICS_PIPELINE_STATE_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_GRAPHICS_PIPELINE_STATE_DESC", 0, true); - - SerialiseObject(ID3D12RootSignature, "pRootSignature", el.pRootSignature); - Serialise("VS", el.VS); - Serialise("PS", el.PS); - Serialise("DS", el.DS); - Serialise("HS", el.HS); - Serialise("GS", el.GS); - Serialise("StreamOutput", el.StreamOutput); - Serialise("BlendState", el.BlendState); - Serialise("SampleMask", el.SampleMask); - Serialise("RasterizerState", el.RasterizerState); - Serialise("DepthStencilState", el.DepthStencilState); - Serialise("InputLayout", el.InputLayout); - Serialise("IBStripCutValue", el.IBStripCutValue); - Serialise("PrimitiveTopologyType", el.PrimitiveTopologyType); - Serialise("NumRenderTargets", el.NumRenderTargets); - SerialisePODArray<8>("RTVFormats", el.RTVFormats); - Serialise("DSVFormat", el.DSVFormat); - Serialise("SampleDesc", el.SampleDesc); - Serialise("NodeMask", el.NodeMask); - Serialise("Flags", el.Flags); - - if(m_Mode == READING) - { - el.CachedPSO.CachedBlobSizeInBytes = 0; - el.CachedPSO.pCachedBlob = NULL; - } -} - -template <> -void Serialiser::Deserialise(const D3D12_GRAPHICS_PIPELINE_STATE_DESC *const el) const -{ - if(m_Mode == READING) - { - delete[](byte *)(el->VS.pShaderBytecode); - delete[](byte *)(el->PS.pShaderBytecode); - delete[](byte *)(el->DS.pShaderBytecode); - delete[](byte *)(el->HS.pShaderBytecode); - delete[](byte *)(el->GS.pShaderBytecode); - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_COMPUTE_PIPELINE_STATE_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_COMPUTE_PIPELINE_STATE_DESC", 0, true); - - SerialiseObject(ID3D12RootSignature, "pRootSignature", el.pRootSignature); - Serialise("CS", el.CS); - Serialise("NodeMask", el.NodeMask); - Serialise("Flags", el.Flags); - - if(m_Mode == READING) - { - el.CachedPSO.CachedBlobSizeInBytes = 0; - el.CachedPSO.pCachedBlob = NULL; - } -} - -template <> -void Serialiser::Deserialise(const D3D12_COMPUTE_PIPELINE_STATE_DESC *const el) const -{ - if(m_Mode == READING) - delete[](byte *)(el->CS.pShaderBytecode); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_VERTEX_BUFFER_VIEW &el) -{ - ScopedContext scope(this, name, "D3D12_VERTEX_BUFFER_VIEW", 0, true); - - D3D12ResourceManager *rm = (D3D12ResourceManager *)GetUserData(); - - ResourceId buffer; - UINT64 offs = 0; - - if(m_Mode == WRITING) - WrappedID3D12Resource::GetResIDFromAddr(el.BufferLocation, buffer, offs); - - Serialise("BufferLocation", buffer); - Serialise("BufferLocation_Offset", offs); - - if(m_Mode == READING) - { - ID3D12Resource *res = rm->GetLiveAs(buffer); - if(res) - el.BufferLocation = res->GetGPUVirtualAddress() + offs; - else - el.BufferLocation = 0; - } - - Serialise("SizeInBytes", el.SizeInBytes); - Serialise("StrideInBytes", el.StrideInBytes); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_INDEX_BUFFER_VIEW &el) -{ - ScopedContext scope(this, name, "D3D12_INDEX_BUFFER_VIEW", 0, true); - - D3D12ResourceManager *rm = (D3D12ResourceManager *)GetUserData(); - - ResourceId buffer; - UINT64 offs = 0; - - if(m_Mode == WRITING) - WrappedID3D12Resource::GetResIDFromAddr(el.BufferLocation, buffer, offs); - - Serialise("BufferLocation", buffer); - Serialise("BufferLocation_Offset", offs); - - if(m_Mode == READING) - { - ID3D12Resource *res = rm->GetLiveAs(buffer); - if(res) - el.BufferLocation = res->GetGPUVirtualAddress() + offs; - else - el.BufferLocation = 0; - } - - Serialise("SizeInBytes", el.SizeInBytes); - Serialise("Format", el.Format); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_STREAM_OUTPUT_BUFFER_VIEW &el) -{ - ScopedContext scope(this, name, "D3D12_STREAM_OUTPUT_BUFFER_VIEW", 0, true); - - D3D12ResourceManager *rm = (D3D12ResourceManager *)GetUserData(); - - ResourceId buffer; - UINT64 offs = 0; - - if(m_Mode == WRITING) - WrappedID3D12Resource::GetResIDFromAddr(el.BufferLocation, buffer, offs); - - Serialise("BufferLocation", buffer); - Serialise("BufferLocation_Offset", offs); - - if(m_Mode == READING) - { - ID3D12Resource *res = rm->GetLiveAs(buffer); - if(res) - el.BufferLocation = res->GetGPUVirtualAddress() + offs; - else - el.BufferLocation = 0; - } - - if(m_Mode == WRITING) - WrappedID3D12Resource::GetResIDFromAddr(el.BufferFilledSizeLocation, buffer, offs); - - Serialise("BufferFilledSizeLocation", buffer); - Serialise("BufferFilledSizeLocation_Offset", offs); - - if(m_Mode == READING) - { - ID3D12Resource *res = rm->GetLiveAs(buffer); - if(res) - el.BufferFilledSizeLocation = res->GetGPUVirtualAddress() + offs; - else - el.BufferFilledSizeLocation = 0; - } - - Serialise("SizeInBytes", el.SizeInBytes); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_CONSTANT_BUFFER_VIEW_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_CONSTANT_BUFFER_VIEW_DESC", 0, true); - - D3D12ResourceManager *rm = (D3D12ResourceManager *)GetUserData(); - - ResourceId buffer; - UINT64 offs = 0; - - if(m_Mode == WRITING) - WrappedID3D12Resource::GetResIDFromAddr(el.BufferLocation, buffer, offs); - - Serialise("BufferLocation", buffer); - Serialise("BufferLocation_Offset", offs); - - if(m_Mode == READING) - { - ID3D12Resource *res = NULL; - - if(buffer != ResourceId() && rm->HasLiveResource(buffer)) - res = rm->GetLiveAs(buffer); - - if(res) - el.BufferLocation = res->GetGPUVirtualAddress() + offs; - else - el.BufferLocation = 0; - } - - Serialise("SizeInBytes", el.SizeInBytes); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_SHADER_RESOURCE_VIEW_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_SHADER_RESOURCE_VIEW_DESC", 0, true); - - Serialise("Format", el.Format); - Serialise("ViewDimension", el.ViewDimension); - // cast to a special enum so we print nicely - Serialise("Shader4ComponentMapping", (D3D12ComponentMapping &)el.Shader4ComponentMapping); - - switch(el.ViewDimension) - { - case D3D12_SRV_DIMENSION_UNKNOWN: - // indicates an empty descriptor, which comes from a NULL parameter to Create. - break; - case D3D12_SRV_DIMENSION_BUFFER: - Serialise("Buffer.FirstElement", el.Buffer.FirstElement); - Serialise("Buffer.NumElements", el.Buffer.NumElements); - Serialise("Buffer.StructureByteStride", el.Buffer.StructureByteStride); - Serialise("Buffer.Flags", el.Buffer.Flags); - break; - case D3D12_SRV_DIMENSION_TEXTURE1D: - Serialise("Texture1D.MostDetailedMip", el.Texture1D.MostDetailedMip); - Serialise("Texture1D.MipLevels", el.Texture1D.MipLevels); - Serialise("Texture1D.ResourceMinLODClamp", el.Texture1D.ResourceMinLODClamp); - break; - case D3D12_SRV_DIMENSION_TEXTURE1DARRAY: - Serialise("Texture1DArray.MostDetailedMip", el.Texture1DArray.MostDetailedMip); - Serialise("Texture1DArray.MipLevels", el.Texture1DArray.MipLevels); - Serialise("Texture1DArray.FirstArraySlice", el.Texture1DArray.FirstArraySlice); - Serialise("Texture1DArray.ArraySize", el.Texture1DArray.ArraySize); - Serialise("Texture1DArray.ResourceMinLODClamp", el.Texture1DArray.ResourceMinLODClamp); - break; - case D3D12_SRV_DIMENSION_TEXTURE2D: - Serialise("Texture2D.MostDetailedMip", el.Texture2D.MostDetailedMip); - Serialise("Texture2D.MipLevels", el.Texture2D.MipLevels); - Serialise("Texture2D.PlaneSlice", el.Texture2D.PlaneSlice); - Serialise("Texture2D.ResourceMinLODClamp", el.Texture2D.ResourceMinLODClamp); - break; - case D3D12_SRV_DIMENSION_TEXTURE2DARRAY: - Serialise("Texture2DArray.MostDetailedMip", el.Texture2DArray.MostDetailedMip); - Serialise("Texture2DArray.MipLevels", el.Texture2DArray.MipLevels); - Serialise("Texture2DArray.FirstArraySlice", el.Texture2DArray.FirstArraySlice); - Serialise("Texture2DArray.ArraySize", el.Texture2DArray.ArraySize); - Serialise("Texture2DArray.PlaneSlice", el.Texture2DArray.PlaneSlice); - Serialise("Texture2DArray.ResourceMinLODClamp", el.Texture2DArray.ResourceMinLODClamp); - break; - case D3D12_SRV_DIMENSION_TEXTURE2DMS: - // el.Texture2DMS.UnusedField_NothingToDefine - break; - case D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY: - Serialise("Texture2DMSArray.FirstArraySlice", el.Texture2DMSArray.FirstArraySlice); - Serialise("Texture2DMSArray.ArraySize", el.Texture2DMSArray.ArraySize); - break; - case D3D12_SRV_DIMENSION_TEXTURE3D: - Serialise("Texture3D.MipLevels", el.Texture3D.MipLevels); - Serialise("Texture3D.MostDetailedMip", el.Texture3D.MostDetailedMip); - Serialise("Texture3D.ResourceMinLODClamp", el.Texture3D.ResourceMinLODClamp); - break; - case D3D12_SRV_DIMENSION_TEXTURECUBE: - Serialise("TextureCube.MostDetailedMip", el.TextureCube.MostDetailedMip); - Serialise("TextureCube.MipLevels", el.TextureCube.MipLevels); - Serialise("TextureCube.ResourceMinLODClamp", el.TextureCube.ResourceMinLODClamp); - break; - case D3D12_SRV_DIMENSION_TEXTURECUBEARRAY: - Serialise("TextureCubeArray.MostDetailedMip", el.TextureCubeArray.MostDetailedMip); - Serialise("TextureCubeArray.MipLevels", el.TextureCubeArray.MipLevels); - Serialise("TextureCubeArray.First2DArrayFace", el.TextureCubeArray.First2DArrayFace); - Serialise("TextureCubeArray.NumCubes", el.TextureCubeArray.NumCubes); - Serialise("TextureCubeArray.ResourceMinLODClamp", el.TextureCubeArray.ResourceMinLODClamp); - break; - default: RDCERR("Unrecognised SRV Dimension %d", el.ViewDimension); break; - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_RENDER_TARGET_VIEW_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_RENDER_TARGET_VIEW_DESC", 0, true); - - Serialise("Format", el.Format); - Serialise("ViewDimension", el.ViewDimension); - - switch(el.ViewDimension) - { - case D3D12_RTV_DIMENSION_UNKNOWN: - // indicates an empty descriptor, which comes from a NULL parameter to Create. - break; - case D3D12_RTV_DIMENSION_BUFFER: - Serialise("Buffer.FirstElement", el.Buffer.FirstElement); - Serialise("Buffer.NumElements", el.Buffer.NumElements); - break; - case D3D12_RTV_DIMENSION_TEXTURE1D: - Serialise("Texture1D.MipSlice", el.Texture1D.MipSlice); - break; - case D3D12_RTV_DIMENSION_TEXTURE1DARRAY: - Serialise("Texture1DArray.MipSlice", el.Texture1DArray.MipSlice); - Serialise("Texture1DArray.FirstArraySlice", el.Texture1DArray.FirstArraySlice); - Serialise("Texture1DArray.ArraySize", el.Texture1DArray.ArraySize); - break; - case D3D12_RTV_DIMENSION_TEXTURE2D: - Serialise("Texture2D.MipSlice", el.Texture2D.MipSlice); - Serialise("Texture2D.PlaneSlice", el.Texture2D.PlaneSlice); - break; - case D3D12_RTV_DIMENSION_TEXTURE2DARRAY: - Serialise("Texture2DArray.MipSlice", el.Texture2DArray.MipSlice); - Serialise("Texture2DArray.FirstArraySlice", el.Texture2DArray.FirstArraySlice); - Serialise("Texture2DArray.ArraySize", el.Texture2DArray.ArraySize); - Serialise("Texture2DArray.PlaneSlice", el.Texture2DArray.PlaneSlice); - break; - case D3D12_RTV_DIMENSION_TEXTURE2DMS: - // el.Texture2DMS.UnusedField_NothingToDefine - break; - case D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY: - Serialise("Texture2DMSArray.FirstArraySlice", el.Texture2DMSArray.FirstArraySlice); - Serialise("Texture2DMSArray.ArraySize", el.Texture2DMSArray.ArraySize); - break; - case D3D12_RTV_DIMENSION_TEXTURE3D: - Serialise("Texture3D.MipSlice", el.Texture3D.MipSlice); - Serialise("Texture3D.FirstWSlice", el.Texture3D.FirstWSlice); - Serialise("Texture3D.WSize", el.Texture3D.WSize); - break; - default: RDCERR("Unrecognised RTV Dimension %d", el.ViewDimension); break; - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_DEPTH_STENCIL_VIEW_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_DEPTH_STENCIL_VIEW_DESC", 0, true); - - Serialise("Format", el.Format); - Serialise("Flags", el.Flags); - Serialise("ViewDimension", el.ViewDimension); - - switch(el.ViewDimension) - { - case D3D12_DSV_DIMENSION_UNKNOWN: - // indicates an empty descriptor, which comes from a NULL parameter to Create. - break; - case D3D12_DSV_DIMENSION_TEXTURE1D: - Serialise("Texture1D.MipSlice", el.Texture1D.MipSlice); - break; - case D3D12_DSV_DIMENSION_TEXTURE1DARRAY: - Serialise("Texture1DArray.MipSlice", el.Texture1DArray.MipSlice); - Serialise("Texture1DArray.FirstArraySlice", el.Texture1DArray.FirstArraySlice); - Serialise("Texture1DArray.ArraySize", el.Texture1DArray.ArraySize); - break; - case D3D12_DSV_DIMENSION_TEXTURE2D: - Serialise("Texture2D.MipSlice", el.Texture2D.MipSlice); - break; - case D3D12_DSV_DIMENSION_TEXTURE2DARRAY: - Serialise("Texture2DArray.MipSlice", el.Texture2DArray.MipSlice); - Serialise("Texture2DArray.FirstArraySlice", el.Texture2DArray.FirstArraySlice); - Serialise("Texture2DArray.ArraySize", el.Texture2DArray.ArraySize); - break; - case D3D12_DSV_DIMENSION_TEXTURE2DMS: - // el.Texture2DMS.UnusedField_NothingToDefine - break; - case D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY: - Serialise("Texture2DMSArray.FirstArraySlice", el.Texture2DMSArray.FirstArraySlice); - Serialise("Texture2DMSArray.ArraySize", el.Texture2DMSArray.ArraySize); - break; - default: RDCERR("Unrecognised DSV Dimension %d", el.ViewDimension); break; - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_UNORDERED_ACCESS_VIEW_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_UNORDERED_ACCESS_VIEW_DESC", 0, true); - - Serialise("Format", el.Format); - Serialise("ViewDimension", el.ViewDimension); - - switch(el.ViewDimension) - { - case D3D12_UAV_DIMENSION_UNKNOWN: - // indicates an empty descriptor, which comes from a NULL parameter to Create. - break; - case D3D12_UAV_DIMENSION_BUFFER: - Serialise("Buffer.FirstElement", el.Buffer.FirstElement); - Serialise("Buffer.NumElements", el.Buffer.NumElements); - Serialise("Buffer.StructureByteStride", el.Buffer.StructureByteStride); - Serialise("Buffer.CounterOffsetInBytes", el.Buffer.CounterOffsetInBytes); - Serialise("Buffer.Flags", el.Buffer.Flags); - break; - case D3D12_UAV_DIMENSION_TEXTURE1D: - Serialise("Texture1D.MipSlice", el.Texture1D.MipSlice); - break; - case D3D12_UAV_DIMENSION_TEXTURE1DARRAY: - Serialise("Texture1DArray.MipSlice", el.Texture1DArray.MipSlice); - Serialise("Texture1DArray.FirstArraySlice", el.Texture1DArray.FirstArraySlice); - Serialise("Texture1DArray.ArraySize", el.Texture1DArray.ArraySize); - break; - case D3D12_UAV_DIMENSION_TEXTURE2D: - Serialise("Texture2D.MipSlice", el.Texture2D.MipSlice); - Serialise("Texture2D.PlaneSlice", el.Texture2D.PlaneSlice); - break; - case D3D12_UAV_DIMENSION_TEXTURE2DARRAY: - Serialise("Texture2DArray.MipSlice", el.Texture2DArray.MipSlice); - Serialise("Texture2DArray.FirstArraySlice", el.Texture2DArray.FirstArraySlice); - Serialise("Texture2DArray.ArraySize", el.Texture2DArray.ArraySize); - Serialise("Texture2DArray.PlaneSlice", el.Texture2DArray.PlaneSlice); - break; - case D3D12_UAV_DIMENSION_TEXTURE3D: - Serialise("Texture3D.MipSlice", el.Texture3D.MipSlice); - Serialise("Texture3D.FirstWSlice", el.Texture3D.FirstWSlice); - Serialise("Texture3D.WSize", el.Texture3D.WSize); - break; - default: RDCERR("Unrecognised RTV Dimension %d", el.ViewDimension); break; - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_RESOURCE_BARRIER &el) -{ - ScopedContext scope(this, name, "D3D12_RESOURCE_BARRIER", 0, true); - - Serialise("Type", el.Type); - Serialise("Flags", el.Flags); - - switch(el.Type) - { - case D3D12_RESOURCE_BARRIER_TYPE_TRANSITION: - { - SerialiseObject(ID3D12Resource, "Transition.pResource", el.Transition.pResource); - // cast to a special enum so we print 'all subresources' nicely - RDCCOMPILE_ASSERT(sizeof(D3D12ResourceBarrierSubresource) == sizeof(UINT), - "Enum isn't uint sized"); - Serialise("Transition.Subresource", - (D3D12ResourceBarrierSubresource &)el.Transition.Subresource); - Serialise("Transition.StateBefore", el.Transition.StateBefore); - Serialise("Transition.StateAfter", el.Transition.StateAfter); - break; - } - case D3D12_RESOURCE_BARRIER_TYPE_ALIASING: - { - SerialiseObject(ID3D12Resource, "Aliasing.pResourceBefore", el.Aliasing.pResourceBefore); - SerialiseObject(ID3D12Resource, "Aliasing.pResourceAfter", el.Aliasing.pResourceAfter); - break; - } - case D3D12_RESOURCE_BARRIER_TYPE_UAV: - { - SerialiseObject(ID3D12Resource, "UAV.pResource", el.UAV.pResource); - break; - } - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_HEAP_PROPERTIES &el) -{ - ScopedContext scope(this, name, "D3D12_HEAP_PROPERTIES", 0, true); - - Serialise("Type", el.Type); - Serialise("CPUPageProperty", el.CPUPageProperty); - Serialise("MemoryPoolPreference", el.MemoryPoolPreference); - Serialise("CreationNodeMask", el.CreationNodeMask); - Serialise("VisibleNodeMask", el.VisibleNodeMask); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_HEAP_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_HEAP_DESC", 0, true); - - Serialise("SizeInBytes", el.SizeInBytes); - Serialise("Properties", el.Properties); - Serialise("Alignment", el.Alignment); - Serialise("Flags", el.Flags); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_DESCRIPTOR_HEAP_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_DESCRIPTOR_HEAP_DESC", 0, true); - - Serialise("Type", el.Type); - Serialise("NumDescriptors", el.NumDescriptors); - Serialise("Flags", el.Flags); - Serialise("NodeMask", el.NodeMask); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_QUERY_HEAP_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_QUERY_HEAP_DESC", 0, true); - - Serialise("Type", el.Type); - Serialise("Count", el.Count); - Serialise("NodeMask", el.NodeMask); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_CLEAR_VALUE &el) -{ - ScopedContext scope(this, name, "D3D12_CLEAR_VALUE", 0, true); - - Serialise("Format", el.Format); - - if(!IsDepthFormat(el.Format)) - { - SerialisePODArray<4>("Color", el.Color); - } - else - { - Serialise("Depth", el.DepthStencil.Depth); - Serialise("Stencil", el.DepthStencil.Stencil); - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_SUBRESOURCE_FOOTPRINT &el) -{ - ScopedContext scope(this, name, "D3D12_SUBRESOURCE_FOOTPRINT", 0, true); - - Serialise("Format", el.Format); - Serialise("Width", el.Width); - Serialise("Height", el.Height); - Serialise("Depth", el.Depth); - Serialise("RowPitch", el.RowPitch); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_TEXTURE_COPY_LOCATION &el) -{ - ScopedContext scope(this, name, "D3D12_TEXTURE_COPY_LOCATION", 0, true); - - SerialiseObject(ID3D12Resource, "pResource", el.pResource); - Serialise("Type", el.Type); - - switch(el.Type) - { - case D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT: - Serialise("PlacedFootprint.Footprint", el.PlacedFootprint.Footprint); - Serialise("PlacedFootprint.Offset", el.PlacedFootprint.Offset); - break; - case D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX: - Serialise("SubresourceIndex", el.SubresourceIndex); - break; - default: RDCERR("Unexpected texture copy type %d", el.Type); break; - } -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_TILED_RESOURCE_COORDINATE &el) -{ - ScopedContext scope(this, name, "D3D12_TILED_RESOURCE_COORDINATE", 0, true); - - Serialise("X", el.X); - Serialise("Y", el.Y); - Serialise("Z", el.Z); - Serialise("Subresource", el.Subresource); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_TILE_REGION_SIZE &el) -{ - ScopedContext scope(this, name, "D3D12_TILE_REGION_SIZE", 0, true); - - Serialise("NumTiles", el.NumTiles); - Serialise("UseBox", el.UseBox); - Serialise("Width", el.Width); - Serialise("Height", el.Height); - Serialise("Depth", el.Depth); -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_DISCARD_REGION &el) -{ - ScopedContext scope(this, name, "D3D12_DISCARD_REGION", 0, true); - - Serialise("FirstSubresource", el.FirstSubresource); - Serialise("NumSubresources", el.NumSubresources); - - SerialiseComplexArray("pRects", (D3D12_RECT *&)el.pRects, el.NumRects); -} - -template <> -void Serialiser::Deserialise(const D3D12_DISCARD_REGION *const el) const -{ - if(m_Mode == READING) - delete[] el->pRects; -} - -template <> -void Serialiser::Serialise(const char *name, D3D12_SAMPLER_DESC &el) -{ - ScopedContext scope(this, name, "D3D12_SAMPLER_DESC", 0, true); - - Serialise("Filter", el.Filter); - Serialise("AddressU", el.AddressU); - Serialise("AddressV", el.AddressV); - Serialise("AddressW", el.AddressW); - Serialise("MipLODBias", el.MipLODBias); - Serialise("MaxAnisotropy", el.MaxAnisotropy); - Serialise("ComparisonFunc", el.ComparisonFunc); - SerialisePODArray<4>("BorderColor", el.BorderColor); - Serialise("MinLOD", el.MinLOD); - Serialise("MaxLOD", el.MaxLOD); -} - -template <> -std::string DoStringise(const D3D12_VIEWPORT &el) -{ - return StringFormat::Fmt("Viewport<%.0fx%.0f+%.0f+%.0f z=%f->%f>", el.Width, el.Height, - el.TopLeftX, el.TopLeftY, el.MinDepth, el.MaxDepth); -} - -template <> -std::string DoStringise(const D3D12_BOX &el) -{ - return StringFormat::Fmt("Box<%u,%u,%u -> %u,%u,%u>", el.left, el.top, el.front, el.right, - el.bottom, el.back); -} - -template <> -std::string DoStringise(const PortableHandle &el) -{ - if(el.heap == ResourceId()) - return "NULL"; - - return StringFormat::Fmt("D3D12_CPU_DESCRIPTOR_HANDLE(%s, %u)", ToStr(el.heap).c_str(), el.index); -} diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index 436741baf..e5c3d8a23 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -297,70 +297,139 @@ struct D3D12CommandSignature ret func; \ bool CONCAT(Serialise_, func); -template <> -void Serialiser::Serialise(const char *name, D3D12_RESOURCE_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_COMMAND_QUEUE_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_SHADER_BYTECODE &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_GRAPHICS_PIPELINE_STATE_DESC &el); -template <> -void Serialiser::Deserialise(const D3D12_GRAPHICS_PIPELINE_STATE_DESC *const el) const; -template <> -void Serialiser::Serialise(const char *name, D3D12_COMPUTE_PIPELINE_STATE_DESC &el); -template <> -void Serialiser::Deserialise(const D3D12_COMPUTE_PIPELINE_STATE_DESC *const el) const; -template <> -void Serialiser::Serialise(const char *name, D3D12_INDEX_BUFFER_VIEW &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_VERTEX_BUFFER_VIEW &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_STREAM_OUTPUT_BUFFER_VIEW &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_RESOURCE_BARRIER &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_HEAP_PROPERTIES &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_HEAP_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_DESCRIPTOR_HEAP_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_INDIRECT_ARGUMENT_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_COMMAND_SIGNATURE_DESC &el); -template <> -void Serialiser::Deserialise(const D3D12_COMMAND_SIGNATURE_DESC *const el) const; -template <> -void Serialiser::Serialise(const char *name, D3D12_QUERY_HEAP_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_SAMPLER_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_CONSTANT_BUFFER_VIEW_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_SHADER_RESOURCE_VIEW_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_RENDER_TARGET_VIEW_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_DEPTH_STENCIL_VIEW_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_UNORDERED_ACCESS_VIEW_DESC &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_CLEAR_VALUE &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_TEXTURE_COPY_LOCATION &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_TILED_RESOURCE_COORDINATE &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_TILE_REGION_SIZE &el); -template <> -void Serialiser::Serialise(const char *name, D3D12_DISCARD_REGION &el); -template <> -void Serialiser::Deserialise(const D3D12_DISCARD_REGION *const el) const; +// this is special - these serialise overloads will fetch the ID during capture, serialise the ID +// directly as-if it were the original type, then on replay load up the resource if available. +// Really this is only one type of serialisation, but we declare a couple of overloads to account +// for resources being accessed through different interfaces in different functions +#define SERIALISE_D3D_INTERFACES() \ + SERIALISE_INTERFACE(ID3D12Object); \ + SERIALISE_INTERFACE(ID3D12DeviceChild); \ + SERIALISE_INTERFACE(ID3D12Pageable); \ + SERIALISE_INTERFACE(ID3D12CommandList); \ + SERIALISE_INTERFACE(ID3D12GraphicsCommandList); \ + SERIALISE_INTERFACE(ID3D12RootSignature); \ + SERIALISE_INTERFACE(ID3D12Resource); \ + SERIALISE_INTERFACE(ID3D12QueryHeap); \ + SERIALISE_INTERFACE(ID3D12PipelineState); \ + SERIALISE_INTERFACE(ID3D12Heap); \ + SERIALISE_INTERFACE(ID3D12Fence); \ + SERIALISE_INTERFACE(ID3D12DescriptorHeap); \ + SERIALISE_INTERFACE(ID3D12CommandSignature); \ + SERIALISE_INTERFACE(ID3D12CommandQueue); \ + SERIALISE_INTERFACE(ID3D12CommandAllocator); -struct D3D12Descriptor; -template <> -void Serialiser::Serialise(const char *name, D3D12Descriptor &el); +#define SERIALISE_INTERFACE(iface) DECLARE_REFLECTION_STRUCT(iface *) + +SERIALISE_D3D_INTERFACES(); + +// a thin utility wrapper around a UINT64, that serialises a BufferLocation as an Id + Offset. +struct D3D12BufferLocation +{ + D3D12BufferLocation(UINT64 l) : Location(l) {} + operator UINT64() const { return Location; } + UINT64 Location; +}; + +DECLARE_REFLECTION_STRUCT(D3D12BufferLocation); + +DECLARE_REFLECTION_STRUCT(D3D12_CPU_DESCRIPTOR_HANDLE); +DECLARE_REFLECTION_STRUCT(D3D12_GPU_DESCRIPTOR_HANDLE); + +DECLARE_REFLECTION_ENUM(D3D12_COMMAND_LIST_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_HEAP_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_CPU_PAGE_PROPERTY); +DECLARE_REFLECTION_ENUM(D3D12_MEMORY_POOL); +DECLARE_REFLECTION_ENUM(D3D12_QUERY_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_QUERY_HEAP_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_DESCRIPTOR_HEAP_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_DESCRIPTOR_HEAP_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_PREDICATION_OP); +DECLARE_REFLECTION_ENUM(D3D12_CLEAR_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_DSV_DIMENSION); +DECLARE_REFLECTION_ENUM(D3D12_UAV_DIMENSION); +DECLARE_REFLECTION_ENUM(D3D12_SRV_DIMENSION); +DECLARE_REFLECTION_ENUM(D3D12_RTV_DIMENSION); +DECLARE_REFLECTION_ENUM(D3D12_DSV_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_BUFFER_SRV_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_BUFFER_UAV_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_STATES); +DECLARE_REFLECTION_ENUM(D3D12_HEAP_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_FENCE_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_PRIMITIVE_TOPOLOGY_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_PRIMITIVE_TOPOLOGY); +DECLARE_REFLECTION_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_PIPELINE_STATE_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_BARRIER_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_BARRIER_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_INPUT_CLASSIFICATION); +DECLARE_REFLECTION_ENUM(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE); +DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_DIMENSION); +DECLARE_REFLECTION_ENUM(D3D12_TEXTURE_LAYOUT); +DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_COMMAND_QUEUE_FLAGS); +DECLARE_REFLECTION_ENUM(D3D12_TEXTURE_COPY_TYPE); +DECLARE_REFLECTION_ENUM(D3D12_FILL_MODE); +DECLARE_REFLECTION_ENUM(D3D12_CULL_MODE); +DECLARE_REFLECTION_ENUM(D3D12_FILTER); +DECLARE_REFLECTION_ENUM(D3D12_COMPARISON_FUNC); +DECLARE_REFLECTION_ENUM(D3D12_TEXTURE_ADDRESS_MODE); +DECLARE_REFLECTION_ENUM(D3D12_CONSERVATIVE_RASTERIZATION_MODE); +DECLARE_REFLECTION_ENUM(D3D12_LOGIC_OP); +DECLARE_REFLECTION_ENUM(D3D12_BLEND); +DECLARE_REFLECTION_ENUM(D3D12_BLEND_OP); +DECLARE_REFLECTION_ENUM(D3D12_STENCIL_OP); +DECLARE_REFLECTION_ENUM(D3D12_COLOR_WRITE_ENABLE); +DECLARE_REFLECTION_ENUM(D3D12_DEPTH_WRITE_MASK); + +DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_COMMAND_QUEUE_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_SHADER_BYTECODE); +DECLARE_REFLECTION_STRUCT(D3D12_SO_DECLARATION_ENTRY); +DECLARE_REFLECTION_STRUCT(D3D12_STREAM_OUTPUT_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_RASTERIZER_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCILOP_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCIL_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_INPUT_ELEMENT_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_INPUT_LAYOUT_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_RENDER_TARGET_BLEND_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_BLEND_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_GRAPHICS_PIPELINE_STATE_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_COMPUTE_PIPELINE_STATE_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_INDEX_BUFFER_VIEW); +DECLARE_REFLECTION_STRUCT(D3D12_VERTEX_BUFFER_VIEW); +DECLARE_REFLECTION_STRUCT(D3D12_STREAM_OUTPUT_BUFFER_VIEW); +DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_TRANSITION_BARRIER); +DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_ALIASING_BARRIER); +DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_UAV_BARRIER); +DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_BARRIER); +DECLARE_REFLECTION_STRUCT(D3D12_HEAP_PROPERTIES); +DECLARE_REFLECTION_STRUCT(D3D12_HEAP_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_DESCRIPTOR_HEAP_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_INDIRECT_ARGUMENT_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_COMMAND_SIGNATURE_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_QUERY_HEAP_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_SAMPLER_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_CONSTANT_BUFFER_VIEW_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_SHADER_RESOURCE_VIEW_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_RENDER_TARGET_VIEW_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCIL_VIEW_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_UNORDERED_ACCESS_VIEW_DESC); +DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCIL_VALUE); +DECLARE_REFLECTION_STRUCT(D3D12_CLEAR_VALUE); +DECLARE_REFLECTION_STRUCT(D3D12_SUBRESOURCE_FOOTPRINT); +DECLARE_REFLECTION_STRUCT(D3D12_TEXTURE_COPY_LOCATION); +DECLARE_REFLECTION_STRUCT(D3D12_TILED_RESOURCE_COORDINATE); +DECLARE_REFLECTION_STRUCT(D3D12_TILE_REGION_SIZE); +DECLARE_REFLECTION_STRUCT(D3D12_DISCARD_REGION); +DECLARE_REFLECTION_STRUCT(D3D12_RANGE); +DECLARE_REFLECTION_STRUCT(D3D12_RECT); +DECLARE_REFLECTION_STRUCT(D3D12_BOX); +DECLARE_REFLECTION_STRUCT(D3D12_VIEWPORT); + +DECLARE_DESERIALISE_TYPE(D3D12_DISCARD_REGION); +DECLARE_DESERIALISE_TYPE(D3D12_GRAPHICS_PIPELINE_STATE_DESC); +DECLARE_DESERIALISE_TYPE(D3D12_COMPUTE_PIPELINE_STATE_DESC); +DECLARE_DESERIALISE_TYPE(D3D12_COMMAND_SIGNATURE_DESC); enum class D3D12Chunk : uint32_t { diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index a9a8f4cbf..f9c72ce4d 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -656,7 +656,7 @@ bool WrappedID3D12Device::Serialise_DynamicDescriptorWrite(Serialiser *localSeri { // safe to pass an invalid heap type to Create() as these descriptors will by definition not // be undefined - RDCASSERT(desc.GetType() != D3D12Descriptor::TypeUndefined); + RDCASSERT(desc.GetType() != D3D12DescriptorType::Undefined); desc.Create(D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES, this, *handle); } } diff --git a/renderdoc/driver/d3d12/d3d12_manager.cpp b/renderdoc/driver/d3d12/d3d12_manager.cpp index 337dce615..91a21a261 100644 --- a/renderdoc/driver/d3d12/d3d12_manager.cpp +++ b/renderdoc/driver/d3d12/d3d12_manager.cpp @@ -39,7 +39,7 @@ void D3D12Descriptor::Init(const D3D12_SAMPLER_DESC *pDesc) void D3D12Descriptor::Init(const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc) { - nonsamp.type = TypeCBV; + nonsamp.type = D3D12DescriptorType::CBV; nonsamp.resource = NULL; if(pDesc) nonsamp.cbv = *pDesc; @@ -49,7 +49,7 @@ void D3D12Descriptor::Init(const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc) void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc) { - nonsamp.type = TypeSRV; + nonsamp.type = D3D12DescriptorType::SRV; nonsamp.resource = pResource; if(pDesc) nonsamp.srv = *pDesc; @@ -60,7 +60,7 @@ void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_SHADER_RESOURC void D3D12Descriptor::Init(ID3D12Resource *pResource, ID3D12Resource *pCounterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc) { - nonsamp.type = TypeUAV; + nonsamp.type = D3D12DescriptorType::UAV; nonsamp.resource = pResource; nonsamp.uav.counterResource = pCounterResource; if(pDesc) @@ -71,7 +71,7 @@ void D3D12Descriptor::Init(ID3D12Resource *pResource, ID3D12Resource *pCounterRe void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_RENDER_TARGET_VIEW_DESC *pDesc) { - nonsamp.type = TypeRTV; + nonsamp.type = D3D12DescriptorType::RTV; nonsamp.resource = pResource; if(pDesc) nonsamp.rtv = *pDesc; @@ -81,7 +81,7 @@ void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_RENDER_TARGET_ void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc) { - nonsamp.type = TypeDSV; + nonsamp.type = D3D12DescriptorType::DSV; nonsamp.resource = pResource; if(pDesc) nonsamp.dsv = *pDesc; @@ -127,21 +127,21 @@ static D3D12_UNORDERED_ACCESS_VIEW_DESC *defaultUAV() void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12Device *dev, D3D12_CPU_DESCRIPTOR_HANDLE handle) { - D3D12Descriptor::DescriptorType type = GetType(); + D3D12DescriptorType type = GetType(); switch(type) { - case D3D12Descriptor::TypeSampler: + case D3D12DescriptorType::Sampler: { dev->CreateSampler(&samp.desc, handle); break; } - case D3D12Descriptor::TypeCBV: + case D3D12DescriptorType::CBV: { dev->CreateConstantBufferView(&nonsamp.cbv, handle); break; } - case D3D12Descriptor::TypeSRV: + case D3D12DescriptorType::SRV: { D3D12_SHADER_RESOURCE_VIEW_DESC *desc = &nonsamp.srv; if(desc->ViewDimension == D3D12_SRV_DIMENSION_UNKNOWN) @@ -264,7 +264,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D dev->CreateShaderResourceView(nonsamp.resource, desc, handle); break; } - case D3D12Descriptor::TypeRTV: + case D3D12DescriptorType::RTV: { D3D12_RENDER_TARGET_VIEW_DESC *desc = &nonsamp.rtv; if(desc->ViewDimension == D3D12_RTV_DIMENSION_UNKNOWN) @@ -366,7 +366,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D dev->CreateRenderTargetView(nonsamp.resource, desc, handle); break; } - case D3D12Descriptor::TypeDSV: + case D3D12DescriptorType::DSV: { D3D12_DEPTH_STENCIL_VIEW_DESC *desc = &nonsamp.dsv; if(desc->ViewDimension == D3D12_DSV_DIMENSION_UNKNOWN) @@ -410,7 +410,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D dev->CreateDepthStencilView(nonsamp.resource, desc, handle); break; } - case D3D12Descriptor::TypeUAV: + case D3D12DescriptorType::UAV: { D3D12_UNORDERED_ACCESS_VIEW_DESC uavdesc = nonsamp.uav.desc.AsDesc(); @@ -524,7 +524,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D dev->CreateUnorderedAccessView(nonsamp.resource, counter, desc, handle); break; } - case D3D12Descriptor::TypeUndefined: + case D3D12DescriptorType::Undefined: { // initially descriptors are undefined. This way we just init with // a null descriptor so it's valid to copy around etc but is no @@ -562,19 +562,19 @@ void D3D12Descriptor::GetRefIDs(ResourceId &id, ResourceId &id2, FrameRefType &r switch(GetType()) { - case D3D12Descriptor::TypeUndefined: - case D3D12Descriptor::TypeSampler: + case D3D12DescriptorType::Undefined: + case D3D12DescriptorType::Sampler: // nothing to do - no resource here break; - case D3D12Descriptor::TypeCBV: + case D3D12DescriptorType::CBV: id = WrappedID3D12Resource::GetResIDFromAddr(nonsamp.cbv.BufferLocation); break; - case D3D12Descriptor::TypeSRV: id = GetResID(nonsamp.resource); break; - case D3D12Descriptor::TypeUAV: + case D3D12DescriptorType::SRV: id = GetResID(nonsamp.resource); break; + case D3D12DescriptorType::UAV: id2 = GetResID(nonsamp.uav.counterResource); // deliberate fall-through - case D3D12Descriptor::TypeRTV: - case D3D12Descriptor::TypeDSV: + case D3D12DescriptorType::RTV: + case D3D12DescriptorType::DSV: ref = eFrameRef_Write; id = GetResID(nonsamp.resource); break; diff --git a/renderdoc/driver/d3d12/d3d12_manager.h b/renderdoc/driver/d3d12/d3d12_manager.h index bc27c1384..17f8e22ce 100644 --- a/renderdoc/driver/d3d12/d3d12_manager.h +++ b/renderdoc/driver/d3d12/d3d12_manager.h @@ -50,6 +50,8 @@ enum D3D12ResourceType Resource_PipelineLibrary, }; +DECLARE_REFLECTION_ENUM(D3D12ResourceType); + class WrappedID3D12DescriptorHeap; // squeeze the descriptor a bit so that the below struct fits in 64 bytes @@ -117,27 +119,29 @@ struct D3D12_UNORDERED_ACCESS_VIEW_DESC_SQUEEZED } }; +enum class D3D12DescriptorType +{ + // we start at 0x1000 since this element will alias with the filter + // in the sampler, to save space + Sampler, + CBV = 0x1000, + SRV, + UAV, + RTV, + DSV, + Undefined, +}; + +DECLARE_REFLECTION_ENUM(D3D12DescriptorType); + struct D3D12Descriptor { - enum DescriptorType - { - // we start at 0x1000 since this element will alias with the filter - // in the sampler, to save space - TypeSampler, - TypeCBV = 0x1000, - TypeSRV, - TypeUAV, - TypeRTV, - TypeDSV, - TypeUndefined, - }; - - DescriptorType GetType() const + D3D12DescriptorType GetType() const { RDCCOMPILE_ASSERT(sizeof(D3D12Descriptor) <= 64, "D3D12Descriptor has gotten larger"); - if(nonsamp.type < TypeCBV) - return TypeSampler; + if(nonsamp.type < D3D12DescriptorType::CBV) + return D3D12DescriptorType::Sampler; return nonsamp.type; } @@ -189,7 +193,7 @@ struct D3D12Descriptor // this element overlaps with the D3D12_FILTER in D3D12_SAMPLER_DESC, // with values that are invalid for filter - DescriptorType type; + D3D12DescriptorType type; ID3D12Resource *resource; @@ -209,6 +213,8 @@ struct D3D12Descriptor }; }; +DECLARE_REFLECTION_STRUCT(D3D12Descriptor); + inline D3D12Descriptor *GetWrapped(D3D12_CPU_DESCRIPTOR_HANDLE handle) { return (D3D12Descriptor *)handle.ptr; @@ -233,6 +239,8 @@ struct PortableHandle uint32_t index; }; +DECLARE_REFLECTION_STRUCT(PortableHandle); + class D3D12ResourceManager; PortableHandle ToPortableHandle(D3D12Descriptor *handle); @@ -264,6 +272,8 @@ struct DynamicDescriptorCopy D3D12_DESCRIPTOR_HEAP_TYPE type; }; +DECLARE_REFLECTION_STRUCT(DynamicDescriptorCopy); + struct D3D12ResourceRecord; struct CmdListRecordingInfo diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index 54b937c6f..652bc9793 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -324,7 +324,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc) { D3D12ResourceManager *rm = m_pDevice->GetResourceManager(); - if(desc->GetType() == D3D12Descriptor::TypeSampler || desc->GetType() == D3D12Descriptor::TypeCBV) + if(desc->GetType() == D3D12DescriptorType::Sampler || desc->GetType() == D3D12DescriptorType::CBV) { return; } @@ -339,11 +339,11 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc) { DXGI_FORMAT fmt = DXGI_FORMAT_UNKNOWN; - if(desc->GetType() == D3D12Descriptor::TypeRTV) + if(desc->GetType() == D3D12DescriptorType::RTV) fmt = desc->nonsamp.rtv.Format; - else if(desc->GetType() == D3D12Descriptor::TypeSRV) + else if(desc->GetType() == D3D12DescriptorType::SRV) fmt = desc->nonsamp.srv.Format; - else if(desc->GetType() == D3D12Descriptor::TypeUAV) + else if(desc->GetType() == D3D12DescriptorType::UAV) fmt = (DXGI_FORMAT)desc->nonsamp.uav.desc.Format; if(fmt == DXGI_FORMAT_UNKNOWN) @@ -353,7 +353,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc) view.Format = MakeResourceFormat(fmt); - if(desc->GetType() == D3D12Descriptor::TypeRTV) + if(desc->GetType() == D3D12DescriptorType::RTV) { view.Type = MakeTextureDim(desc->nonsamp.rtv.ViewDimension); @@ -397,7 +397,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc) view.HighestMip = desc->nonsamp.rtv.Texture3D.MipSlice; } } - else if(desc->GetType() == D3D12Descriptor::TypeDSV) + else if(desc->GetType() == D3D12DescriptorType::DSV) { view.Type = MakeTextureDim(desc->nonsamp.dsv.ViewDimension); @@ -430,7 +430,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc) view.FirstArraySlice = desc->nonsamp.dsv.Texture2DArray.FirstArraySlice; } } - else if(desc->GetType() == D3D12Descriptor::TypeSRV) + else if(desc->GetType() == D3D12DescriptorType::SRV) { view.Type = MakeTextureDim(desc->nonsamp.srv.ViewDimension); @@ -495,7 +495,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc) view.MinLODClamp = desc->nonsamp.srv.Texture3D.ResourceMinLODClamp; } } - else if(desc->GetType() == D3D12Descriptor::TypeUAV) + else if(desc->GetType() == D3D12DescriptorType::UAV) { D3D12_UNORDERED_ACCESS_VIEW_DESC uav = desc->nonsamp.uav.desc.AsDesc(); diff --git a/renderdoc/driver/d3d12/d3d12_resources.cpp b/renderdoc/driver/d3d12/d3d12_resources.cpp index 7624de79c..118feb914 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.cpp +++ b/renderdoc/driver/d3d12/d3d12_resources.cpp @@ -147,7 +147,7 @@ ALL_D3D12_TYPES; WRAPPED_POOL_INST(WrappedID3D12Shader); -D3D12ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr) +D3D12ResourceType IdentifyTypeByPtr(ID3D12Object *ptr) { if(ptr == NULL) return Resource_Unknown; @@ -169,7 +169,7 @@ D3D12ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr) return Resource_Unknown; } -TrackedResource12 *GetTracked(ID3D12DeviceChild *ptr) +TrackedResource12 *GetTracked(ID3D12Object *ptr) { if(ptr == NULL) return NULL; @@ -188,7 +188,7 @@ TrackedResource12 *GetTracked(ID3D12DeviceChild *ptr) } template <> -ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr) +ID3D12Object *Unwrap(ID3D12Object *ptr) { if(ptr == NULL) return NULL; @@ -196,14 +196,14 @@ ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr) #undef D3D12_TYPE_MACRO #define D3D12_TYPE_MACRO(iface) \ if(UnwrapHelper::IsAlloc(ptr)) \ - return (ID3D12DeviceChild *)GetWrapped((iface *)ptr)->GetReal(); + return (ID3D12Object *)GetWrapped((iface *)ptr)->GetReal(); ALL_D3D12_TYPES; if(WrappedID3D12GraphicsCommandList::IsAlloc(ptr)) - return (ID3D12DeviceChild *)(((WrappedID3D12GraphicsCommandList *)ptr)->GetReal()); + return (ID3D12Object *)(((WrappedID3D12GraphicsCommandList *)ptr)->GetReal()); if(WrappedID3D12CommandQueue::IsAlloc(ptr)) - return (ID3D12DeviceChild *)(((WrappedID3D12CommandQueue *)ptr)->GetReal()); + return (ID3D12Object *)(((WrappedID3D12CommandQueue *)ptr)->GetReal()); RDCERR("Unknown type of ptr 0x%p", ptr); @@ -211,7 +211,7 @@ ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr) } template <> -ResourceId GetResID(ID3D12DeviceChild *ptr) +ResourceId GetResID(ID3D12Object *ptr) { if(ptr == NULL) return ResourceId(); @@ -234,7 +234,7 @@ ResourceId GetResID(ID3D12DeviceChild *ptr) } template <> -D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr) +D3D12ResourceRecord *GetRecord(ID3D12Object *ptr) { if(ptr == NULL) return NULL; @@ -256,6 +256,29 @@ D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr) return res->GetResourceRecord(); } +template <> +ResourceId GetResID(ID3D12DeviceChild *ptr) +{ + return GetResID((ID3D12Object *)ptr); +} + +template <> +ResourceId GetResID(ID3D12Pageable *ptr) +{ + return GetResID((ID3D12Object *)ptr); +} + +template <> +D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr) +{ + return GetRecord((ID3D12Object *)ptr); +} +template <> +ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr) +{ + return (ID3D12DeviceChild *)Unwrap((ID3D12Object *)ptr); +} + WrappedID3D12Resource::~WrappedID3D12Resource() { // perform an implicit unmap on release @@ -450,7 +473,7 @@ WrappedID3D12DescriptorHeap::WrappedID3D12DescriptorHeap(ID3D12DescriptorHeap *r // initially descriptors are undefined. This way we just fill them with // some null SRV descriptor so it's safe to copy around etc but is no // less undefined for the application to use - descriptors[i].nonsamp.type = D3D12Descriptor::TypeUndefined; + descriptors[i].nonsamp.type = D3D12DescriptorType::Undefined; } } diff --git a/renderdoc/driver/d3d12/d3d12_resources.h b/renderdoc/driver/d3d12/d3d12_resources.h index 4efb451f7..39466ebc8 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.h +++ b/renderdoc/driver/d3d12/d3d12_resources.h @@ -963,7 +963,7 @@ struct UnwrapHelper ALL_D3D12_TYPES; -D3D12ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr); +D3D12ResourceType IdentifyTypeByPtr(ID3D12Object *ptr); #define WRAPPING_DEBUG 0 @@ -1014,9 +1014,25 @@ D3D12ResourceRecord *GetRecord(ifaceptr obj) } // specialisations that use the IsAlloc() function to identify the real type +template <> +ResourceId GetResID(ID3D12Object *ptr); +template <> +ID3D12Object *Unwrap(ID3D12Object *ptr); +template <> +D3D12ResourceRecord *GetRecord(ID3D12Object *ptr); + template <> ResourceId GetResID(ID3D12DeviceChild *ptr); template <> +ResourceId GetResID(ID3D12Pageable *ptr); +template <> +ResourceId GetResID(ID3D12CommandList *ptr); +template <> +ResourceId GetResID(ID3D12GraphicsCommandList *ptr); +template <> +ResourceId GetResID(ID3D12CommandQueue *ptr); +template <> ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr); + template <> D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr); diff --git a/renderdoc/driver/d3d12/d3d12_serialise.cpp b/renderdoc/driver/d3d12/d3d12_serialise.cpp new file mode 100644 index 000000000..02f6d44a8 --- /dev/null +++ b/renderdoc/driver/d3d12/d3d12_serialise.cpp @@ -0,0 +1,1004 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2017 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include "driver/dxgi/dxgi_common.h" +#include "d3d12_common.h" +#include "d3d12_resources.h" + +// some helper enums with custom stringise to handle special cases +enum D3D12ResourceBarrierSubresource +{ + D3D12AllSubresources = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES +}; + +DECLARE_REFLECTION_ENUM(D3D12ResourceBarrierSubresource); + +template <> +std::string DoStringise(const D3D12ResourceBarrierSubresource &el) +{ + RDCCOMPILE_ASSERT(sizeof(D3D12ResourceBarrierSubresource) == sizeof(uint32_t), + "Enum isn't uint sized"); + + if(el == D3D12AllSubresources) + return "All Subresources"; + + return ToStr(uint32_t(el)); +} + +enum D3D12ComponentMapping +{ +}; + +DECLARE_REFLECTION_ENUM(D3D12ComponentMapping); + +template <> +std::string DoStringise(const D3D12ComponentMapping &el) +{ + RDCCOMPILE_ASSERT(sizeof(D3D12ComponentMapping) == sizeof(uint32_t), "Enum isn't uint sized"); + + std::string ret; + + // value should always be <= 5, see D3D12_SHADER_COMPONENT_MAPPING + const char mapping[] = {'R', 'G', 'B', 'A', '0', '1', '?', '!'}; + + uint32_t swizzle = (uint32_t)el; + + for(int i = 0; i < 4; i++) + ret += mapping[D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(i, swizzle)]; + + return ret; +} + +// serialisation of object handles via IDs. +template +void DoSerialiseViaResourceId(SerialiserType &ser, Interface *&el) +{ + D3D12ResourceManager *rm = (D3D12ResourceManager *)ser.GetUserData(); + + ResourceId id; + + if(ser.IsWriting()) + id = GetResID(el); + + DoSerialise(ser, id); + + if(ser.IsReading()) + { + if(id != ResourceId() && rm && rm->HasLiveResource(id)) + el = rm->GetLiveAs(id); + else + el = NULL; + } +} + +#undef SERIALISE_INTERFACE +#define SERIALISE_INTERFACE(iface) \ + template \ + void DoSerialise(SerialiserType &ser, iface *&el) \ + { \ + DoSerialiseViaResourceId(ser, el); \ + } \ + INSTANTIATE_SERIALISE_TYPE(iface *); + +SERIALISE_D3D_INTERFACES(); + +// similarly we serialise handles, buffer locations, through Id + indices + +template +void DoSerialise(SerialiserType &ser, PortableHandle &el) +{ + SERIALISE_MEMBER(heap); + SERIALISE_MEMBER(index); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_CPU_DESCRIPTOR_HANDLE &el) +{ + D3D12ResourceManager *rm = (D3D12ResourceManager *)ser.GetUserData(); + + PortableHandle ph; + + if(ser.IsWriting()) + ph = ToPortableHandle(el); + + DoSerialise(ser, ph); + + if(ser.IsReading()) + { + if(rm) + el.ptr = (SIZE_T)DescriptorFromPortableHandle(rm, ph); + else + el.ptr = 0; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_GPU_DESCRIPTOR_HANDLE &el) +{ + D3D12ResourceManager *rm = (D3D12ResourceManager *)ser.GetUserData(); + + PortableHandle ph; + + if(ser.IsWriting()) + ph = ToPortableHandle(el); + + DoSerialise(ser, ph); + + if(ser.IsReading()) + { + if(rm) + el.ptr = (SIZE_T)DescriptorFromPortableHandle(rm, ph); + else + el.ptr = 0; + } +} + +template +void DoSerialise(SerialiserType &ser, DynamicDescriptorCopy &el) +{ + D3D12ResourceManager *rm = (D3D12ResourceManager *)ser.GetUserData(); + + SERIALISE_MEMBER(type); + + PortableHandle dst, src; + + if(ser.IsWriting()) + { + dst = ToPortableHandle(el.dst); + src = ToPortableHandle(el.src); + } + + ser.Serialise("dst", dst); + ser.Serialise("src", src); + + if(ser.IsReading()) + { + if(rm) + { + el.dst = DescriptorFromPortableHandle(rm, dst); + el.src = DescriptorFromPortableHandle(rm, src); + } + else + { + el.dst = NULL; + el.src = NULL; + } + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12BufferLocation &el) +{ + D3D12ResourceManager *rm = (D3D12ResourceManager *)ser.GetUserData(); + + ResourceId buffer; + UINT64 offs = 0; + + if(ser.IsWriting()) + WrappedID3D12Resource::GetResIDFromAddr(el.Location, buffer, offs); + + ser.Serialise("Buffer", buffer); + ser.Serialise("Offset", offs); + + if(ser.IsReading()) + { + if(rm && buffer != ResourceId() && rm->HasLiveResource(buffer)) + el.Location = rm->GetLiveAs(buffer)->GetGPUVirtualAddress() + offs; + else + el.Location = 0; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12Descriptor &el) +{ + D3D12DescriptorType type = el.GetType(); + ser.Serialise("type", type); + + ID3D12DescriptorHeap *heap = (ID3D12DescriptorHeap *)el.samp.heap; + + ser.Serialise("heap", heap); + ser.Serialise("index", el.samp.idx); + + if(ser.IsReading()) + { + el.samp.heap = (WrappedID3D12DescriptorHeap *)heap; + + // for sampler types, this will be overwritten when serialising the sampler descriptor + el.nonsamp.type = type; + } + + switch(type) + { + case D3D12DescriptorType::Sampler: + { + ser.Serialise("Descriptor", el.samp.desc); + RDCASSERTEQUAL(el.GetType(), D3D12DescriptorType::Sampler); + break; + } + case D3D12DescriptorType::CBV: + { + ser.Serialise("Descriptor", el.nonsamp.cbv); + break; + } + case D3D12DescriptorType::SRV: + { + ser.Serialise("Resource", el.nonsamp.resource); + ser.Serialise("Descriptor", el.nonsamp.srv); + break; + } + case D3D12DescriptorType::RTV: + { + ser.Serialise("Resource", el.nonsamp.resource); + ser.Serialise("Descriptor", el.nonsamp.rtv); + break; + } + case D3D12DescriptorType::DSV: + { + ser.Serialise("Resource", el.nonsamp.resource); + ser.Serialise("Descriptor", el.nonsamp.dsv); + break; + } + case D3D12DescriptorType::UAV: + { + ser.Serialise("Resource", el.nonsamp.resource); + ser.Serialise("CounterResource", el.nonsamp.uav.counterResource); + + // special case because of extra resource and squeezed descriptor + D3D12_UNORDERED_ACCESS_VIEW_DESC desc = el.nonsamp.uav.desc.AsDesc(); + ser.Serialise("Descriptor", desc); + el.nonsamp.uav.desc.Init(desc); + break; + } + case D3D12DescriptorType::Undefined: + { + el.nonsamp.type = type; + break; + } + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RESOURCE_DESC &el) +{ + SERIALISE_MEMBER(Dimension); + SERIALISE_MEMBER(Alignment); + SERIALISE_MEMBER(Width); + SERIALISE_MEMBER(Height); + SERIALISE_MEMBER(DepthOrArraySize); + SERIALISE_MEMBER(MipLevels); + SERIALISE_MEMBER(Format); + SERIALISE_MEMBER(SampleDesc); + SERIALISE_MEMBER(Layout); + SERIALISE_MEMBER(Flags); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_COMMAND_QUEUE_DESC &el) +{ + SERIALISE_MEMBER(Type); + SERIALISE_MEMBER(Priority); + SERIALISE_MEMBER(Flags); + SERIALISE_MEMBER(NodeMask); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_SHADER_BYTECODE &el) +{ + // don't serialise size_t, otherwise capture/replay between different bit-ness won't work + { + uint64_t BytecodeLength = el.BytecodeLength; + ser.Serialise("BytecodeLength", BytecodeLength); + if(ser.IsReading()) + el.BytecodeLength = (size_t)BytecodeLength; + } + + SERIALISE_MEMBER_ARRAY(pShaderBytecode, BytecodeLength); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_SO_DECLARATION_ENTRY &el) +{ + SERIALISE_MEMBER(Stream); + SERIALISE_MEMBER(SemanticName); + SERIALISE_MEMBER(SemanticIndex); + SERIALISE_MEMBER(StartComponent); + SERIALISE_MEMBER(ComponentCount); + SERIALISE_MEMBER(OutputSlot); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_STREAM_OUTPUT_DESC &el) +{ + SERIALISE_MEMBER_ARRAY(pSODeclaration, NumEntries); + SERIALISE_MEMBER_ARRAY(pBufferStrides, NumStrides); + SERIALISE_MEMBER(RasterizedStream); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RENDER_TARGET_BLEND_DESC &el) +{ + SERIALISE_MEMBER_TYPED(bool, BlendEnable); + SERIALISE_MEMBER_TYPED(bool, LogicOpEnable); + + SERIALISE_MEMBER(SrcBlend); + SERIALISE_MEMBER(DestBlend); + SERIALISE_MEMBER(BlendOp); + SERIALISE_MEMBER(SrcBlendAlpha); + SERIALISE_MEMBER(DestBlendAlpha); + SERIALISE_MEMBER(BlendOpAlpha); + SERIALISE_MEMBER(LogicOp); + SERIALISE_MEMBER_TYPED(D3D12_COLOR_WRITE_ENABLE, RenderTargetWriteMask); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_BLEND_DESC &el) +{ + SERIALISE_MEMBER(AlphaToCoverageEnable); + SERIALISE_MEMBER(IndependentBlendEnable); + SERIALISE_MEMBER(RenderTarget); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RASTERIZER_DESC &el) +{ + SERIALISE_MEMBER(FillMode); + SERIALISE_MEMBER(CullMode); + SERIALISE_MEMBER(FrontCounterClockwise); + SERIALISE_MEMBER(DepthBias); + SERIALISE_MEMBER(DepthBiasClamp); + SERIALISE_MEMBER(SlopeScaledDepthBias); + SERIALISE_MEMBER(DepthClipEnable); + SERIALISE_MEMBER(MultisampleEnable); + SERIALISE_MEMBER(AntialiasedLineEnable); + SERIALISE_MEMBER(ForcedSampleCount); + SERIALISE_MEMBER(ConservativeRaster); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_DEPTH_STENCILOP_DESC &el) +{ + SERIALISE_MEMBER(StencilFailOp); + SERIALISE_MEMBER(StencilDepthFailOp); + SERIALISE_MEMBER(StencilPassOp); + SERIALISE_MEMBER(StencilFunc); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_DEPTH_STENCIL_DESC &el) +{ + SERIALISE_MEMBER(DepthEnable); + SERIALISE_MEMBER(DepthWriteMask); + SERIALISE_MEMBER(DepthFunc); + SERIALISE_MEMBER(StencilEnable); + SERIALISE_MEMBER(StencilReadMask); + SERIALISE_MEMBER(StencilWriteMask); + SERIALISE_MEMBER(FrontFace); + SERIALISE_MEMBER(BackFace); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_INPUT_ELEMENT_DESC &el) +{ + SERIALISE_MEMBER(SemanticName); + SERIALISE_MEMBER(SemanticIndex); + SERIALISE_MEMBER(Format); + SERIALISE_MEMBER(InputSlot); + SERIALISE_MEMBER(AlignedByteOffset); + SERIALISE_MEMBER(InputSlotClass); + SERIALISE_MEMBER(InstanceDataStepRate); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_INPUT_LAYOUT_DESC &el) +{ + SERIALISE_MEMBER_ARRAY(pInputElementDescs, NumElements); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_INDIRECT_ARGUMENT_DESC &el) +{ + SERIALISE_MEMBER(Type); + + switch(el.Type) + { + case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW: + case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED: + case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH: + case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW: + // nothing to serialise + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW: + SERIALISE_MEMBER(VertexBuffer.Slot); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT: + SERIALISE_MEMBER(Constant.RootParameterIndex); + SERIALISE_MEMBER(Constant.DestOffsetIn32BitValues); + SERIALISE_MEMBER(Constant.Num32BitValuesToSet); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW: + SERIALISE_MEMBER(ConstantBufferView.RootParameterIndex); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW: + SERIALISE_MEMBER(ShaderResourceView.RootParameterIndex); + break; + case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW: + SERIALISE_MEMBER(UnorderedAccessView.RootParameterIndex); + break; + default: RDCERR("Unexpected indirect argument type: %u", el.Type); break; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_COMMAND_SIGNATURE_DESC &el) +{ + SERIALISE_MEMBER(ByteStride); + SERIALISE_MEMBER(NodeMask); + SERIALISE_MEMBER_ARRAY(pArgumentDescs, NumArgumentDescs); +} + +template <> +void Deserialise(const D3D12_COMMAND_SIGNATURE_DESC &el) +{ + delete[] el.pArgumentDescs; +} + +template +void DoSerialise(SerialiserType &ser, D3D12_GRAPHICS_PIPELINE_STATE_DESC &el) +{ + SERIALISE_MEMBER(pRootSignature); + SERIALISE_MEMBER(VS); + SERIALISE_MEMBER(PS); + SERIALISE_MEMBER(DS); + SERIALISE_MEMBER(HS); + SERIALISE_MEMBER(GS); + SERIALISE_MEMBER(StreamOutput); + SERIALISE_MEMBER(BlendState); + SERIALISE_MEMBER(SampleMask); + SERIALISE_MEMBER(RasterizerState); + SERIALISE_MEMBER(DepthStencilState); + SERIALISE_MEMBER(InputLayout); + SERIALISE_MEMBER(IBStripCutValue); + SERIALISE_MEMBER(PrimitiveTopologyType); + SERIALISE_MEMBER(NumRenderTargets); + SERIALISE_MEMBER(RTVFormats); + SERIALISE_MEMBER(DSVFormat); + SERIALISE_MEMBER(SampleDesc); + SERIALISE_MEMBER(NodeMask); + SERIALISE_MEMBER(Flags); + + if(ser.IsReading()) + { + el.CachedPSO.CachedBlobSizeInBytes = 0; + el.CachedPSO.pCachedBlob = NULL; + } +} + +template <> +void Deserialise(const D3D12_GRAPHICS_PIPELINE_STATE_DESC &el) +{ + delete[] el.StreamOutput.pSODeclaration; + delete[] el.StreamOutput.pBufferStrides; + delete[] el.InputLayout.pInputElementDescs; + FreeAlignedBuffer((byte *)(el.VS.pShaderBytecode)); + FreeAlignedBuffer((byte *)(el.PS.pShaderBytecode)); + FreeAlignedBuffer((byte *)(el.DS.pShaderBytecode)); + FreeAlignedBuffer((byte *)(el.HS.pShaderBytecode)); + FreeAlignedBuffer((byte *)(el.GS.pShaderBytecode)); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_COMPUTE_PIPELINE_STATE_DESC &el) +{ + SERIALISE_MEMBER(pRootSignature); + SERIALISE_MEMBER(CS); + SERIALISE_MEMBER(NodeMask); + SERIALISE_MEMBER(Flags); + + if(ser.IsReading()) + { + el.CachedPSO.CachedBlobSizeInBytes = 0; + el.CachedPSO.pCachedBlob = NULL; + } +} + +template <> +void Deserialise(const D3D12_COMPUTE_PIPELINE_STATE_DESC &el) +{ + FreeAlignedBuffer((byte *)(el.CS.pShaderBytecode)); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_VERTEX_BUFFER_VIEW &el) +{ + SERIALISE_MEMBER_TYPED(D3D12BufferLocation, BufferLocation); + SERIALISE_MEMBER(SizeInBytes); + SERIALISE_MEMBER(StrideInBytes); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_INDEX_BUFFER_VIEW &el) +{ + SERIALISE_MEMBER_TYPED(D3D12BufferLocation, BufferLocation); + SERIALISE_MEMBER(SizeInBytes); + SERIALISE_MEMBER(Format); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_STREAM_OUTPUT_BUFFER_VIEW &el) +{ + SERIALISE_MEMBER_TYPED(D3D12BufferLocation, BufferLocation); + SERIALISE_MEMBER_TYPED(D3D12BufferLocation, BufferFilledSizeLocation); + SERIALISE_MEMBER(SizeInBytes); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_CONSTANT_BUFFER_VIEW_DESC &el) +{ + SERIALISE_MEMBER_TYPED(D3D12BufferLocation, BufferLocation); + SERIALISE_MEMBER(SizeInBytes); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_SHADER_RESOURCE_VIEW_DESC &el) +{ + SERIALISE_MEMBER(Format); + SERIALISE_MEMBER(ViewDimension); + // cast to a special enum so we print nicely + SERIALISE_MEMBER_TYPED(D3D12ComponentMapping, Shader4ComponentMapping); + + switch(el.ViewDimension) + { + case D3D12_SRV_DIMENSION_UNKNOWN: + // indicates an empty descriptor, which comes from a NULL parameter to Create. + break; + case D3D12_SRV_DIMENSION_BUFFER: + SERIALISE_MEMBER(Buffer.FirstElement); + SERIALISE_MEMBER(Buffer.NumElements); + SERIALISE_MEMBER(Buffer.StructureByteStride); + SERIALISE_MEMBER(Buffer.Flags); + break; + case D3D12_SRV_DIMENSION_TEXTURE1D: + SERIALISE_MEMBER(Texture1D.MostDetailedMip); + SERIALISE_MEMBER(Texture1D.MipLevels); + SERIALISE_MEMBER(Texture1D.ResourceMinLODClamp); + break; + case D3D12_SRV_DIMENSION_TEXTURE1DARRAY: + SERIALISE_MEMBER(Texture1DArray.MostDetailedMip); + SERIALISE_MEMBER(Texture1DArray.MipLevels); + SERIALISE_MEMBER(Texture1DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture1DArray.ArraySize); + SERIALISE_MEMBER(Texture1DArray.ResourceMinLODClamp); + break; + case D3D12_SRV_DIMENSION_TEXTURE2D: + SERIALISE_MEMBER(Texture2D.MostDetailedMip); + SERIALISE_MEMBER(Texture2D.MipLevels); + SERIALISE_MEMBER(Texture2D.PlaneSlice); + SERIALISE_MEMBER(Texture2D.ResourceMinLODClamp); + break; + case D3D12_SRV_DIMENSION_TEXTURE2DARRAY: + SERIALISE_MEMBER(Texture2DArray.MostDetailedMip); + SERIALISE_MEMBER(Texture2DArray.MipLevels); + SERIALISE_MEMBER(Texture2DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture2DArray.ArraySize); + SERIALISE_MEMBER(Texture2DArray.PlaneSlice); + SERIALISE_MEMBER(Texture2DArray.ResourceMinLODClamp); + break; + case D3D12_SRV_DIMENSION_TEXTURE2DMS: + // el.Texture2DMS.UnusedField_NothingToDefine + break; + case D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY: + SERIALISE_MEMBER(Texture2DMSArray.FirstArraySlice); + SERIALISE_MEMBER(Texture2DMSArray.ArraySize); + break; + case D3D12_SRV_DIMENSION_TEXTURE3D: + SERIALISE_MEMBER(Texture3D.MipLevels); + SERIALISE_MEMBER(Texture3D.MostDetailedMip); + SERIALISE_MEMBER(Texture3D.ResourceMinLODClamp); + break; + case D3D12_SRV_DIMENSION_TEXTURECUBE: + SERIALISE_MEMBER(TextureCube.MostDetailedMip); + SERIALISE_MEMBER(TextureCube.MipLevels); + SERIALISE_MEMBER(TextureCube.ResourceMinLODClamp); + break; + case D3D12_SRV_DIMENSION_TEXTURECUBEARRAY: + SERIALISE_MEMBER(TextureCubeArray.MostDetailedMip); + SERIALISE_MEMBER(TextureCubeArray.MipLevels); + SERIALISE_MEMBER(TextureCubeArray.First2DArrayFace); + SERIALISE_MEMBER(TextureCubeArray.NumCubes); + SERIALISE_MEMBER(TextureCubeArray.ResourceMinLODClamp); + break; + default: RDCERR("Unrecognised SRV Dimension %d", el.ViewDimension); break; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RENDER_TARGET_VIEW_DESC &el) +{ + SERIALISE_MEMBER(Format); + SERIALISE_MEMBER(ViewDimension); + + switch(el.ViewDimension) + { + case D3D12_RTV_DIMENSION_UNKNOWN: + // indicates an empty descriptor, which comes from a NULL parameter to Create. + break; + case D3D12_RTV_DIMENSION_BUFFER: + SERIALISE_MEMBER(Buffer.FirstElement); + SERIALISE_MEMBER(Buffer.NumElements); + break; + case D3D12_RTV_DIMENSION_TEXTURE1D: SERIALISE_MEMBER(Texture1D.MipSlice); break; + case D3D12_RTV_DIMENSION_TEXTURE1DARRAY: + SERIALISE_MEMBER(Texture1DArray.MipSlice); + SERIALISE_MEMBER(Texture1DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture1DArray.ArraySize); + break; + case D3D12_RTV_DIMENSION_TEXTURE2D: + SERIALISE_MEMBER(Texture2D.MipSlice); + SERIALISE_MEMBER(Texture2D.PlaneSlice); + break; + case D3D12_RTV_DIMENSION_TEXTURE2DARRAY: + SERIALISE_MEMBER(Texture2DArray.MipSlice); + SERIALISE_MEMBER(Texture2DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture2DArray.ArraySize); + SERIALISE_MEMBER(Texture2DArray.PlaneSlice); + break; + case D3D12_RTV_DIMENSION_TEXTURE2DMS: + // el.Texture2DMS.UnusedField_NothingToDefine + break; + case D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY: + SERIALISE_MEMBER(Texture2DMSArray.FirstArraySlice); + SERIALISE_MEMBER(Texture2DMSArray.ArraySize); + break; + case D3D12_RTV_DIMENSION_TEXTURE3D: + SERIALISE_MEMBER(Texture3D.MipSlice); + SERIALISE_MEMBER(Texture3D.FirstWSlice); + SERIALISE_MEMBER(Texture3D.WSize); + break; + default: RDCERR("Unrecognised RTV Dimension %d", el.ViewDimension); break; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_DEPTH_STENCIL_VIEW_DESC &el) +{ + SERIALISE_MEMBER(Format); + SERIALISE_MEMBER(Flags); + SERIALISE_MEMBER(ViewDimension); + + switch(el.ViewDimension) + { + case D3D12_DSV_DIMENSION_UNKNOWN: + // indicates an empty descriptor, which comes from a NULL parameter to Create. + break; + case D3D12_DSV_DIMENSION_TEXTURE1D: SERIALISE_MEMBER(Texture1D.MipSlice); break; + case D3D12_DSV_DIMENSION_TEXTURE1DARRAY: + SERIALISE_MEMBER(Texture1DArray.MipSlice); + SERIALISE_MEMBER(Texture1DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture1DArray.ArraySize); + break; + case D3D12_DSV_DIMENSION_TEXTURE2D: SERIALISE_MEMBER(Texture2D.MipSlice); break; + case D3D12_DSV_DIMENSION_TEXTURE2DARRAY: + SERIALISE_MEMBER(Texture2DArray.MipSlice); + SERIALISE_MEMBER(Texture2DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture2DArray.ArraySize); + break; + case D3D12_DSV_DIMENSION_TEXTURE2DMS: + // el.Texture2DMS.UnusedField_NothingToDefine + break; + case D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY: + SERIALISE_MEMBER(Texture2DMSArray.FirstArraySlice); + SERIALISE_MEMBER(Texture2DMSArray.ArraySize); + break; + default: RDCERR("Unrecognised DSV Dimension %d", el.ViewDimension); break; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_UNORDERED_ACCESS_VIEW_DESC &el) +{ + SERIALISE_MEMBER(Format); + SERIALISE_MEMBER(ViewDimension); + + switch(el.ViewDimension) + { + case D3D12_UAV_DIMENSION_UNKNOWN: + // indicates an empty descriptor, which comes from a NULL parameter to Create. + break; + case D3D12_UAV_DIMENSION_BUFFER: + SERIALISE_MEMBER(Buffer.FirstElement); + SERIALISE_MEMBER(Buffer.NumElements); + SERIALISE_MEMBER(Buffer.StructureByteStride); + SERIALISE_MEMBER(Buffer.CounterOffsetInBytes); + SERIALISE_MEMBER(Buffer.Flags); + break; + case D3D12_UAV_DIMENSION_TEXTURE1D: SERIALISE_MEMBER(Texture1D.MipSlice); break; + case D3D12_UAV_DIMENSION_TEXTURE1DARRAY: + SERIALISE_MEMBER(Texture1DArray.MipSlice); + SERIALISE_MEMBER(Texture1DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture1DArray.ArraySize); + break; + case D3D12_UAV_DIMENSION_TEXTURE2D: + SERIALISE_MEMBER(Texture2D.MipSlice); + SERIALISE_MEMBER(Texture2D.PlaneSlice); + break; + case D3D12_UAV_DIMENSION_TEXTURE2DARRAY: + SERIALISE_MEMBER(Texture2DArray.MipSlice); + SERIALISE_MEMBER(Texture2DArray.FirstArraySlice); + SERIALISE_MEMBER(Texture2DArray.ArraySize); + SERIALISE_MEMBER(Texture2DArray.PlaneSlice); + break; + case D3D12_UAV_DIMENSION_TEXTURE3D: + SERIALISE_MEMBER(Texture3D.MipSlice); + SERIALISE_MEMBER(Texture3D.FirstWSlice); + SERIALISE_MEMBER(Texture3D.WSize); + break; + default: RDCERR("Unrecognised RTV Dimension %d", el.ViewDimension); break; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RESOURCE_TRANSITION_BARRIER &el) +{ + SERIALISE_MEMBER(pResource); + // cast to a special enum so we print 'all subresources' nicely + SERIALISE_MEMBER_TYPED(D3D12ResourceBarrierSubresource, Subresource); + SERIALISE_MEMBER(StateBefore); + SERIALISE_MEMBER(StateAfter); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RESOURCE_ALIASING_BARRIER &el) +{ + SERIALISE_MEMBER(pResourceBefore); + SERIALISE_MEMBER(pResourceAfter); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RESOURCE_UAV_BARRIER &el) +{ + SERIALISE_MEMBER(pResource); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RESOURCE_BARRIER &el) +{ + SERIALISE_MEMBER(Type); + SERIALISE_MEMBER(Flags); + + switch(el.Type) + { + case D3D12_RESOURCE_BARRIER_TYPE_TRANSITION: SERIALISE_MEMBER(Transition); break; + case D3D12_RESOURCE_BARRIER_TYPE_ALIASING: SERIALISE_MEMBER(Aliasing); break; + case D3D12_RESOURCE_BARRIER_TYPE_UAV: SERIALISE_MEMBER(UAV); break; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_HEAP_PROPERTIES &el) +{ + SERIALISE_MEMBER(Type); + SERIALISE_MEMBER(CPUPageProperty); + SERIALISE_MEMBER(MemoryPoolPreference); + SERIALISE_MEMBER(CreationNodeMask); + SERIALISE_MEMBER(VisibleNodeMask); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_HEAP_DESC &el) +{ + SERIALISE_MEMBER(SizeInBytes); + SERIALISE_MEMBER(Properties); + SERIALISE_MEMBER(Alignment); + SERIALISE_MEMBER(Flags); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_DESCRIPTOR_HEAP_DESC &el) +{ + SERIALISE_MEMBER(Type); + SERIALISE_MEMBER(NumDescriptors); + SERIALISE_MEMBER(Flags); + SERIALISE_MEMBER(NodeMask); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_QUERY_HEAP_DESC &el) +{ + SERIALISE_MEMBER(Type); + SERIALISE_MEMBER(Count); + SERIALISE_MEMBER(NodeMask); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_DEPTH_STENCIL_VALUE &el) +{ + SERIALISE_MEMBER(Depth); + SERIALISE_MEMBER(Stencil); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_CLEAR_VALUE &el) +{ + SERIALISE_MEMBER(Format); + + if(IsDepthFormat(el.Format)) + SERIALISE_MEMBER(DepthStencil); + else + SERIALISE_MEMBER(Color); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_SUBRESOURCE_FOOTPRINT &el) +{ + SERIALISE_MEMBER(Format); + SERIALISE_MEMBER(Width); + SERIALISE_MEMBER(Height); + SERIALISE_MEMBER(Depth); + SERIALISE_MEMBER(RowPitch); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_TEXTURE_COPY_LOCATION &el) +{ + SERIALISE_MEMBER(pResource); + SERIALISE_MEMBER(Type); + + switch(el.Type) + { + case D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT: + SERIALISE_MEMBER(PlacedFootprint.Footprint); + SERIALISE_MEMBER(PlacedFootprint.Offset); + break; + case D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX: SERIALISE_MEMBER(SubresourceIndex); break; + default: RDCERR("Unexpected texture copy type %d", el.Type); break; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_TILED_RESOURCE_COORDINATE &el) +{ + SERIALISE_MEMBER(X); + SERIALISE_MEMBER(Y); + SERIALISE_MEMBER(Z); + SERIALISE_MEMBER(Subresource); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_TILE_REGION_SIZE &el) +{ + SERIALISE_MEMBER(NumTiles); + SERIALISE_MEMBER(UseBox); + SERIALISE_MEMBER(Width); + SERIALISE_MEMBER(Height); + SERIALISE_MEMBER(Depth); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_DISCARD_REGION &el) +{ + SERIALISE_MEMBER(FirstSubresource); + SERIALISE_MEMBER(NumSubresources); + SERIALISE_MEMBER_ARRAY(pRects, NumRects); +} + +template <> +void Deserialise(const D3D12_DISCARD_REGION &el) +{ + delete[] el.pRects; +} + +template +void DoSerialise(SerialiserType &ser, D3D12_RANGE &el) +{ + // serialise as uint64, so we're 32-bit/64-bit compatible + + uint64_t Begin = el.Begin; + uint64_t End = el.End; + + ser.Serialise("Begin", Begin); + ser.Serialise("End", End); + + if(ser.IsReading()) + { + el.Begin = (SIZE_T)Begin; + el.End = (SIZE_T)End; + } +} + +template +void DoSerialise(SerialiserType &ser, D3D12_VIEWPORT &el) +{ + SERIALISE_MEMBER(TopLeftX); + SERIALISE_MEMBER(TopLeftY); + SERIALISE_MEMBER(Width); + SERIALISE_MEMBER(Height); + SERIALISE_MEMBER(MinDepth); + SERIALISE_MEMBER(MaxDepth); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_BOX &el) +{ + SERIALISE_MEMBER(left); + SERIALISE_MEMBER(top); + SERIALISE_MEMBER(front); + SERIALISE_MEMBER(right); + SERIALISE_MEMBER(bottom); + SERIALISE_MEMBER(back); +} + +template +void DoSerialise(SerialiserType &ser, D3D12_SAMPLER_DESC &el) +{ + SERIALISE_MEMBER(Filter); + SERIALISE_MEMBER(AddressU); + SERIALISE_MEMBER(AddressV); + SERIALISE_MEMBER(AddressW); + SERIALISE_MEMBER(MipLODBias); + SERIALISE_MEMBER(MaxAnisotropy); + SERIALISE_MEMBER(ComparisonFunc); + SERIALISE_MEMBER(BorderColor); + SERIALISE_MEMBER(MinLOD); + SERIALISE_MEMBER(MaxLOD); +} + +INSTANTIATE_SERIALISE_TYPE(PortableHandle); +INSTANTIATE_SERIALISE_TYPE(D3D12_CPU_DESCRIPTOR_HANDLE); +INSTANTIATE_SERIALISE_TYPE(D3D12_GPU_DESCRIPTOR_HANDLE); +INSTANTIATE_SERIALISE_TYPE(DynamicDescriptorCopy); +INSTANTIATE_SERIALISE_TYPE(D3D12BufferLocation); +INSTANTIATE_SERIALISE_TYPE(D3D12Descriptor); + +INSTANTIATE_SERIALISE_TYPE(D3D12_RESOURCE_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_COMMAND_QUEUE_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_SHADER_BYTECODE); +INSTANTIATE_SERIALISE_TYPE(D3D12_GRAPHICS_PIPELINE_STATE_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_COMPUTE_PIPELINE_STATE_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_INDEX_BUFFER_VIEW); +INSTANTIATE_SERIALISE_TYPE(D3D12_VERTEX_BUFFER_VIEW); +INSTANTIATE_SERIALISE_TYPE(D3D12_STREAM_OUTPUT_BUFFER_VIEW); +INSTANTIATE_SERIALISE_TYPE(D3D12_RESOURCE_BARRIER); +INSTANTIATE_SERIALISE_TYPE(D3D12_HEAP_PROPERTIES); +INSTANTIATE_SERIALISE_TYPE(D3D12_HEAP_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_DESCRIPTOR_HEAP_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_INDIRECT_ARGUMENT_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_COMMAND_SIGNATURE_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_QUERY_HEAP_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_SAMPLER_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_CONSTANT_BUFFER_VIEW_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_SHADER_RESOURCE_VIEW_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_RENDER_TARGET_VIEW_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_DEPTH_STENCIL_VIEW_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_UNORDERED_ACCESS_VIEW_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_CLEAR_VALUE); +INSTANTIATE_SERIALISE_TYPE(D3D12_BLEND_DESC); +INSTANTIATE_SERIALISE_TYPE(D3D12_TEXTURE_COPY_LOCATION); +INSTANTIATE_SERIALISE_TYPE(D3D12_TILED_RESOURCE_COORDINATE); +INSTANTIATE_SERIALISE_TYPE(D3D12_TILE_REGION_SIZE); +INSTANTIATE_SERIALISE_TYPE(D3D12_DISCARD_REGION); +INSTANTIATE_SERIALISE_TYPE(D3D12_RANGE); +INSTANTIATE_SERIALISE_TYPE(D3D12_RECT); +INSTANTIATE_SERIALISE_TYPE(D3D12_BOX); +INSTANTIATE_SERIALISE_TYPE(D3D12_VIEWPORT); \ No newline at end of file diff --git a/renderdoc/driver/d3d12/d3d12_state.cpp b/renderdoc/driver/d3d12/d3d12_state.cpp index fed561be0..3ec206682 100644 --- a/renderdoc/driver/d3d12/d3d12_state.cpp +++ b/renderdoc/driver/d3d12/d3d12_state.cpp @@ -93,7 +93,7 @@ vector D3D12RenderState::GetRTVIDs() const for(UINT i = 0; i < rts.size(); i++) { - RDCASSERT(descs[i].GetType() == D3D12Descriptor::TypeRTV); + RDCASSERT(descs[i].GetType() == D3D12DescriptorType::RTV); ret.push_back(GetResID(descs[i].nonsamp.resource)); } } @@ -107,7 +107,7 @@ vector D3D12RenderState::GetRTVIDs() const const D3D12Descriptor &desc = heap->GetDescriptors()[rts[i].index]; - RDCASSERT(desc.GetType() == D3D12Descriptor::TypeRTV); + RDCASSERT(desc.GetType() == D3D12DescriptorType::RTV); ret.push_back(GetResID(desc.nonsamp.resource)); } } @@ -121,7 +121,7 @@ ResourceId D3D12RenderState::GetDSVID() const { const D3D12Descriptor *desc = DescriptorFromPortableHandle(GetResourceManager(), dsv); - RDCASSERT(desc->GetType() == D3D12Descriptor::TypeDSV); + RDCASSERT(desc->GetType() == D3D12DescriptorType::DSV); return GetResID(desc->nonsamp.resource); } diff --git a/renderdoc/driver/d3d12/d3d12_stringise.cpp b/renderdoc/driver/d3d12/d3d12_stringise.cpp index db8954a5d..61a7c38cf 100644 --- a/renderdoc/driver/d3d12/d3d12_stringise.cpp +++ b/renderdoc/driver/d3d12/d3d12_stringise.cpp @@ -164,19 +164,19 @@ std::string DoStringise(const D3D12Chunk &el) } template <> -std::string DoStringise(const D3D12Descriptor::DescriptorType &el) +std::string DoStringise(const D3D12DescriptorType &el) { - if((uint32_t)el < D3D12Descriptor::TypeCBV) + if((uint32_t)el < (uint32_t)D3D12DescriptorType::CBV) return "Sampler"; - BEGIN_ENUM_STRINGISE(D3D12Descriptor::DescriptorType); + BEGIN_ENUM_STRINGISE(D3D12DescriptorType); { - STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeCBV, "CBV"); - STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeSRV, "SRV"); - STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeUAV, "UAV"); - STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeRTV, "RTV"); - STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeDSV, "DSV"); - STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeUndefined, "Undefined"); + STRINGISE_ENUM_CLASS_NAMED(CBV, "CBV"); + STRINGISE_ENUM_CLASS_NAMED(SRV, "SRV"); + STRINGISE_ENUM_CLASS_NAMED(UAV, "UAV"); + STRINGISE_ENUM_CLASS_NAMED(RTV, "RTV"); + STRINGISE_ENUM_CLASS_NAMED(DSV, "DSV"); + STRINGISE_ENUM_CLASS_NAMED(Undefined, "Undefined"); } END_ENUM_STRINGISE(); } diff --git a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj index 0062e2bb1..4cec487e4 100644 --- a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj +++ b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj @@ -111,6 +111,7 @@ + diff --git a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters index ec90c3e39..d6abff1d1 100644 --- a/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters +++ b/renderdoc/driver/d3d12/renderdoc_d3d12.vcxproj.filters @@ -113,5 +113,8 @@ Util + + Util + \ No newline at end of file