diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index 651ced317..851f9642a 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -1878,6 +1878,71 @@ void D3D12DebugManager::GetBufferData(ID3D12Resource *buffer, uint64_t offset, u } } +void D3D12DebugManager::RenderHighlightBox(float w, float h, float scale) +{ + OutputWindow &outw = m_OutputWindows[m_CurrentOutputWindow]; + + { + ID3D12GraphicsCommandList *list = m_WrappedDevice->GetNewList(); + + float black[] = {0.0f, 0.0f, 0.0f, 1.0f}; + float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + + // size of box + LONG sz = LONG(scale); + + // top left, x and y + LONG tlx = LONG(w / 2.0f + 0.5f); + LONG tly = LONG(h / 2.0f + 0.5f); + + D3D12_RECT rect[4] = { + {tlx, tly, tlx + 1, tly + sz}, + + {tlx + sz, tly, tlx + sz + 1, tly + sz + 1}, + + {tlx, tly, tlx + sz, tly + 1}, + + {tlx, tly + sz, tlx + sz, tly + sz + 1}, + }; + + // inner + list->ClearRenderTargetView(outw.rtv, white, 4, rect); + + // shift both sides to just translate the rect without changing its size + rect[0].left--; + rect[0].right--; + rect[1].left++; + rect[1].right++; + rect[2].left--; + rect[2].right--; + rect[3].left--; + rect[3].right--; + + rect[0].top--; + rect[0].bottom--; + rect[1].top--; + rect[1].bottom--; + rect[2].top--; + rect[2].bottom--; + rect[3].top++; + rect[3].bottom++; + + // now increase the 'size' of the rects + rect[0].bottom += 2; + rect[1].bottom += 2; + rect[2].right += 2; + rect[3].right += 2; + + // outer + list->ClearRenderTargetView(outw.rtv, black, 4, rect); + + list->Close(); + + m_WrappedDevice->ExecuteLists(); + m_WrappedDevice->FlushLists(); + } +} + void D3D12DebugManager::RenderCheckerboard(Vec3f light, Vec3f dark) { DebugVertexCBuffer vertexData; diff --git a/renderdoc/driver/d3d12/d3d12_debug.h b/renderdoc/driver/d3d12/d3d12_debug.h index c99917eee..ae98a7b41 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.h +++ b/renderdoc/driver/d3d12/d3d12_debug.h @@ -68,6 +68,8 @@ public: int GetHeight() { return m_height; } void RenderText(ID3D12GraphicsCommandList *list, float x, float y, const char *textfmt, ...); + void RenderHighlightBox(float w, float h, float scale); + void RenderCheckerboard(Vec3f light, Vec3f dark); bool RenderTexture(TextureDisplay cfg, bool blendAlpha); diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index 4599674ae..d6590153a 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -1144,11 +1144,21 @@ void D3D12Replay::RenderCheckerboard(Vec3f light, Vec3f dark) m_pDevice->GetDebugManager()->RenderCheckerboard(light, dark); } +void D3D12Replay::RenderHighlightBox(float w, float h, float scale) +{ + m_pDevice->GetDebugManager()->RenderHighlightBox(w, h, scale); +} + bool D3D12Replay::RenderTexture(TextureDisplay cfg) { return m_pDevice->GetDebugManager()->RenderTexture(cfg, true); } +bool D3D12Replay::IsTextureSupported(const ResourceFormat &format) +{ + return MakeDXGIFormat(format) != DXGI_FORMAT_UNKNOWN; +} + void D3D12Replay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector &retData) { m_pDevice->GetDebugManager()->GetBufferData(buff, offset, len, retData); @@ -1161,6 +1171,89 @@ void D3D12Replay::PickPixel(ResourceId texture, uint32_t x, uint32_t y, uint32_t m_pDevice->GetDebugManager()->PickPixel(texture, x, y, sliceFace, mip, sample, typeHint, pixel); } +void D3D12Replay::FillCBufferVariables(ResourceId shader, string entryPoint, uint32_t cbufSlot, + vector &outvars, const vector &data) +{ + if(shader == ResourceId()) + return; + + ID3D12DeviceChild *res = m_pDevice->GetResourceManager()->GetCurrentResource(shader); + + if(!WrappedID3D12PipelineState::ShaderEntry::IsAlloc(res)) + { + RDCERR("Shader ID %llu does not correspond to a known fake shader", shader); + return; + } + + WrappedID3D12PipelineState::ShaderEntry *sh = (WrappedID3D12PipelineState::ShaderEntry *)res; + + DXBC::DXBCFile *dxbc = sh->GetDXBC(); + const ShaderBindpointMapping &bindMap = sh->GetMapping(); + + RDCASSERT(dxbc); + + DXBC::CBuffer *cb = NULL; + + uint32_t idx = 0; + for(size_t i = 0; i < dxbc->m_CBuffers.size(); i++) + { + if(dxbc->m_CBuffers[i].descriptor.type != DXBC::CBuffer::Descriptor::TYPE_CBUFFER) + continue; + + if(idx == cbufSlot) + cb = &dxbc->m_CBuffers[i]; + + idx++; + } + + if(cb && cbufSlot < (uint32_t)bindMap.ConstantBlocks.count) + { + // check if the data actually comes from root constants + + const D3D12RenderState &rs = m_pDevice->GetQueue()->GetCommandData()->m_RenderState; + BindpointMap bind = bindMap.ConstantBlocks[cbufSlot]; + + WrappedID3D12RootSignature *sig = NULL; + const vector *sigElems = NULL; + + if(dxbc->m_Type == D3D11_ShaderType_Compute && rs.compute.rootsig != ResourceId()) + { + sig = m_pDevice->GetResourceManager()->GetCurrentAs( + rs.compute.rootsig); + sigElems = &rs.compute.sigelems; + } + else if(dxbc->m_Type != D3D11_ShaderType_Compute && rs.graphics.rootsig != ResourceId()) + { + sig = m_pDevice->GetResourceManager()->GetCurrentAs( + rs.graphics.rootsig); + sigElems = &rs.graphics.sigelems; + } + + vector rootData; + + for(size_t i = 0; sig && i < sig->sig.params.size(); i++) + { + const D3D12RootSignatureParameter &p = sig->sig.params[i]; + + if(p.ParameterType == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS && + p.Constants.RegisterSpace == (UINT)bind.bindset && + p.Constants.ShaderRegister == (UINT)bind.bind) + { + rootData.resize(sig->sig.params[i].Constants.Num32BitValues); + + if(i < sigElems->size() && (*sigElems)[i].type == eRootConst) + { + memcpy(&rootData[0], &(*sigElems)[i].constants[0], + RDCMIN((*sigElems)[i].constants.size() * sizeof(uint32_t), rootData.size())); + } + } + } + + m_pDevice->GetDebugManager()->FillCBufferVariables(cb->variables, outvars, false, + rootData.empty() ? data : rootData); + } +} + uint64_t D3D12Replay::MakeOutputWindow(WindowingSystem system, void *data, bool depth) { return m_pDevice->GetDebugManager()->MakeOutputWindow(system, data, depth); @@ -1311,93 +1404,6 @@ void D3D12Replay::BuildCustomShader(string source, string entry, const uint32_t { } -void D3D12Replay::RenderHighlightBox(float w, float h, float scale) -{ -} - -void D3D12Replay::FillCBufferVariables(ResourceId shader, string entryPoint, uint32_t cbufSlot, - vector &outvars, const vector &data) -{ - if(shader == ResourceId()) - return; - - ID3D12DeviceChild *res = m_pDevice->GetResourceManager()->GetCurrentResource(shader); - - if(!WrappedID3D12PipelineState::ShaderEntry::IsAlloc(res)) - { - RDCERR("Shader ID %llu does not correspond to a known fake shader", shader); - return; - } - - WrappedID3D12PipelineState::ShaderEntry *sh = (WrappedID3D12PipelineState::ShaderEntry *)res; - - DXBC::DXBCFile *dxbc = sh->GetDXBC(); - const ShaderBindpointMapping &bindMap = sh->GetMapping(); - - RDCASSERT(dxbc); - - DXBC::CBuffer *cb = NULL; - - uint32_t idx = 0; - for(size_t i = 0; i < dxbc->m_CBuffers.size(); i++) - { - if(dxbc->m_CBuffers[i].descriptor.type != DXBC::CBuffer::Descriptor::TYPE_CBUFFER) - continue; - - if(idx == cbufSlot) - cb = &dxbc->m_CBuffers[i]; - - idx++; - } - - if(cb && cbufSlot < (uint32_t)bindMap.ConstantBlocks.count) - { - // check if the data actually comes from root constants - - const D3D12RenderState &rs = m_pDevice->GetQueue()->GetCommandData()->m_RenderState; - BindpointMap bind = bindMap.ConstantBlocks[cbufSlot]; - - WrappedID3D12RootSignature *sig = NULL; - const vector *sigElems = NULL; - - if(dxbc->m_Type == D3D11_ShaderType_Compute && rs.compute.rootsig != ResourceId()) - { - sig = m_pDevice->GetResourceManager()->GetCurrentAs( - rs.compute.rootsig); - sigElems = &rs.compute.sigelems; - } - else if(dxbc->m_Type != D3D11_ShaderType_Compute && rs.graphics.rootsig != ResourceId()) - { - sig = m_pDevice->GetResourceManager()->GetCurrentAs( - rs.graphics.rootsig); - sigElems = &rs.graphics.sigelems; - } - - vector rootData; - - for(size_t i = 0; sig && i < sig->sig.params.size(); i++) - { - const D3D12RootSignatureParameter &p = sig->sig.params[i]; - - if(p.ParameterType == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS && - p.Constants.RegisterSpace == (UINT)bind.bindset && - p.Constants.ShaderRegister == (UINT)bind.bind) - { - rootData.resize(sig->sig.params[i].Constants.Num32BitValues); - - if(i < sigElems->size() && (*sigElems)[i].type == eRootConst) - { - memcpy(&rootData[0], &(*sigElems)[i].constants[0], - RDCMIN((*sigElems)[i].constants.size() * sizeof(uint32_t), rootData.size())); - } - } - } - - m_pDevice->GetDebugManager()->FillCBufferVariables(cb->variables, outvars, false, - rootData.empty() ? data : rootData); - } -} - vector D3D12Replay::PixelHistory(vector events, ResourceId target, uint32_t x, uint32_t y, uint32_t slice, uint32_t mip, uint32_t sampleIdx, @@ -1457,11 +1463,6 @@ void D3D12Replay::SetProxyTextureData(ResourceId texid, uint32_t arrayIdx, uint3 { } -bool D3D12Replay::IsTextureSupported(const ResourceFormat &format) -{ - return MakeDXGIFormat(format) != DXGI_FORMAT_UNKNOWN; -} - ResourceId D3D12Replay::CreateProxyBuffer(const FetchBuffer &templateBuf) { return ResourceId();