From 3dbdeba5e6263018b426ac437db8eb70cc46c88c Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 7 Oct 2018 08:52:04 -0700 Subject: Added debug names for D3D11 command lists, shaders, samplers, depth-stencil, rasterizer, and blend states --- .../src/CommandListD3D11Impl.cpp | 5 ++++ .../src/PipelineStateD3D11Impl.cpp | 31 ++++++++++++++++++++-- .../GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp | 5 ++++ .../GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp | 6 +++++ 4 files changed, 45 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp index 06e476c1..bff165fa 100644 --- a/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp @@ -36,6 +36,11 @@ CommandListD3D11Impl :: CommandListD3D11Impl(IReferenceCounters* pRefCounters TCommandListBase(pRefCounters, pDevice), m_pd3d11CommandList(pd3d11CommandList) { + if (*m_Desc.Name != 0) + { + auto hr = m_pd3d11CommandList->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(strlen(m_Desc.Name)), m_Desc.Name); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to set command list name"); + } } CommandListD3D11Impl :: ~CommandListD3D11Impl() diff --git a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp index a76e4fcf..ec672ca8 100644 --- a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp @@ -96,8 +96,7 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pRefCoun CHECK_D3D_RESULT_THROW( pDeviceD3D11->CreateDepthStencilState( &D3D11DSSDesc, &m_pd3d11DepthStencilState ), "Failed to create D3D11 depth stencil state" ); - - // Create input layout + // Create input layout if( m_LayoutElements.size() > 0 ) { std::vector > d311InputElements(STD_ALLOCATOR_RAW_MEM(D3D11_INPUT_ELEMENT_DESC, GetRawAllocator(), "Allocator for vector") ); @@ -110,6 +109,34 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pRefCoun CHECK_D3D_RESULT_THROW( pDeviceD3D11->CreateInputLayout(d311InputElements.data(), static_cast(d311InputElements.size()), pVSByteCode->GetBufferPointer(), pVSByteCode->GetBufferSize(), &m_pd3d11InputLayout ), "Failed to create the Direct3D11 input layout"); } + + if (*m_Desc.Name != 0) + { + { + String BSName = String(m_Desc.Name) + " - Blend State"; + auto hr = m_pd3d11BlendState->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(BSName.length()), BSName.c_str()); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to set blend state name"); + } + + { + String DSSName = String(m_Desc.Name) + " - Depth-Stencil State"; + auto hr = m_pd3d11DepthStencilState->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(DSSName.length()), DSSName.c_str()); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to set depth-stencil state name"); + } + + { + String RSName = String(m_Desc.Name) + " - Raterizer State"; + auto hr = m_pd3d11RasterizerState->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(RSName.length()), RSName.c_str()); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to set rasterizer state name"); + } + + if (m_pd3d11InputLayout) + { + String LayoutName = String(m_Desc.Name) + " - Input Layout"; + auto hr = m_pd3d11InputLayout->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(LayoutName.length()), LayoutName.c_str()); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to set input layout state name"); + } + } } if(PipelineDesc.SRBAllocationGranularity > 1) diff --git a/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp index a2777163..73a6785e 100644 --- a/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp @@ -50,6 +50,11 @@ SamplerD3D11Impl::SamplerD3D11Impl(IReferenceCounters* pRefCounters, }; CHECK_D3D_RESULT_THROW( pd3d11Device->CreateSamplerState(&D3D11SamplerDesc, &m_pd3dSampler), "Failed to create the Direct3D11 sampler"); + if (*m_Desc.Name != 0) + { + auto hr = m_pd3dSampler->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(strlen(m_Desc.Name)), m_Desc.Name); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to set sampler name"); + } } SamplerD3D11Impl::~SamplerD3D11Impl() diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp index 9da40de3..ebdf0d23 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp @@ -69,6 +69,12 @@ ShaderD3D11Impl::ShaderD3D11Impl(IReferenceCounters* pRefCounters, if(!m_pShader) LOG_ERROR_AND_THROW("Failed to create the shader from the byte code"); + if (*m_Desc.Name != 0) + { + auto hr = m_pShader->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast(strlen(m_Desc.Name)), m_Desc.Name); + DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to set shader name"); + } + // Load shader resources auto &Allocator = GetRawAllocator(); auto *pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", sizeof(ShaderResourcesD3D11)); -- cgit v1.2.3