diff --git a/qrenderdoc/Code/CommonPipelineState.cpp b/qrenderdoc/Code/CommonPipelineState.cpp index b35cde4e6..9c6965445 100644 --- a/qrenderdoc/Code/CommonPipelineState.cpp +++ b/qrenderdoc/Code/CommonPipelineState.cpp @@ -139,7 +139,7 @@ Viewport CommonPipelineState::GetViewport(int index) return ret; } -ShaderBindpointMapping CommonPipelineState::GetBindpointMapping(ShaderStageType stage) +const ShaderBindpointMapping &CommonPipelineState::GetBindpointMapping(ShaderStageType stage) { if(LogLoaded()) { @@ -197,10 +197,12 @@ ShaderBindpointMapping CommonPipelineState::GetBindpointMapping(ShaderStageType } } - return ShaderBindpointMapping(); + static ShaderBindpointMapping empty; + + return empty; } -ShaderReflection *CommonPipelineState::GetShaderReflection(ShaderStageType stage) +const ShaderReflection *CommonPipelineState::GetShaderReflection(ShaderStageType stage) { if(LogLoaded()) { diff --git a/qrenderdoc/Code/CommonPipelineState.h b/qrenderdoc/Code/CommonPipelineState.h index c6aa92692..f03779e7b 100644 --- a/qrenderdoc/Code/CommonPipelineState.h +++ b/qrenderdoc/Code/CommonPipelineState.h @@ -153,8 +153,8 @@ public: QString OutputAbbrev(); Viewport GetViewport(int index); - ShaderBindpointMapping GetBindpointMapping(ShaderStageType stage); - ShaderReflection *GetShaderReflection(ShaderStageType stage); + const ShaderBindpointMapping &GetBindpointMapping(ShaderStageType stage); + const ShaderReflection *GetShaderReflection(ShaderStageType stage); QString GetShaderEntryPoint(ShaderStageType stage); ResourceId GetShader(ShaderStageType stage); QString GetShaderName(ShaderStageType stage); diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index dd138d8ae..faf480b2f 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -1153,7 +1153,7 @@ void BufferViewer::ConfigureMeshColumns() m_VSIn.compType = vinputs[0].Format.compType; } - ShaderReflection *vs = m_Ctx.CurPipelineState.GetShaderReflection(eShaderStage_Vertex); + const ShaderReflection *vs = m_Ctx.CurPipelineState.GetShaderReflection(eShaderStage_Vertex); m_ModelVSOut->columns.clear(); diff --git a/qrenderdoc/Windows/ConstantBufferPreviewer.cpp b/qrenderdoc/Windows/ConstantBufferPreviewer.cpp index 3f09ff016..baa14fcb2 100644 --- a/qrenderdoc/Windows/ConstantBufferPreviewer.cpp +++ b/qrenderdoc/Windows/ConstantBufferPreviewer.cpp @@ -99,7 +99,7 @@ void ConstantBufferPreviewer::OnEventChanged(uint32_t eventID) m_shader = m_Ctx.CurPipelineState.GetShader(m_stage); QString entryPoint = m_Ctx.CurPipelineState.GetShaderEntryPoint(m_stage); - ShaderReflection *reflection = m_Ctx.CurPipelineState.GetShaderReflection(m_stage); + const ShaderReflection *reflection = m_Ctx.CurPipelineState.GetShaderReflection(m_stage); updateLabels(); @@ -219,7 +219,7 @@ void ConstantBufferPreviewer::updateLabels() needName = false; } - ShaderReflection *reflection = m_Ctx.CurPipelineState.GetShaderReflection(m_stage); + const ShaderReflection *reflection = m_Ctx.CurPipelineState.GetShaderReflection(m_stage); if(reflection != NULL) { diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index e8ff192d6..aedc9ac6e 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -271,7 +271,7 @@ QMap> Following::GetReadOnlyResources(Captu return GetReadOnlyResources(ctx, Stage); } -ShaderReflection *Following::GetReflection(CaptureContext &ctx, ShaderStageType stage) +const ShaderReflection *Following::GetReflection(CaptureContext &ctx, ShaderStageType stage) { bool copy = false, compute = false; GetDrawContext(ctx, copy, compute); @@ -284,23 +284,25 @@ ShaderReflection *Following::GetReflection(CaptureContext &ctx, ShaderStageType return ctx.CurPipelineState.GetShaderReflection(stage); } -ShaderReflection *Following::GetReflection(CaptureContext &ctx) +const ShaderReflection *Following::GetReflection(CaptureContext &ctx) { return GetReflection(ctx, Stage); } -ShaderBindpointMapping Following::GetMapping(CaptureContext &ctx, ShaderStageType stage) +const ShaderBindpointMapping &Following::GetMapping(CaptureContext &ctx, ShaderStageType stage) { bool copy = false, compute = false; GetDrawContext(ctx, copy, compute); if(copy) { - ShaderBindpointMapping mapping; + static ShaderBindpointMapping mapping; // for PS only add a single mapping to get the copy source if(stage == eShaderStage_Pixel) mapping.ReadOnlyResources = {BindpointMap(0, 0)}; + else + mapping.ReadOnlyResources.clear(); return mapping; } @@ -314,7 +316,7 @@ ShaderBindpointMapping Following::GetMapping(CaptureContext &ctx, ShaderStageTyp } } -ShaderBindpointMapping Following::GetMapping(CaptureContext &ctx) +const ShaderBindpointMapping &Following::GetMapping(CaptureContext &ctx) { return GetMapping(ctx, Stage); } @@ -2632,8 +2634,8 @@ void TextureViewer::OnEventChanged(uint32_t eventID) QMap> RWs = Following::GetReadWriteResources(m_Ctx, stage); QMap> ROs = Following::GetReadOnlyResources(m_Ctx, stage); - ShaderReflection *details = Following::GetReflection(m_Ctx, stage); - ShaderBindpointMapping mapping = Following::GetMapping(m_Ctx, stage); + const ShaderReflection *details = Following::GetReflection(m_Ctx, stage); + const ShaderBindpointMapping &mapping = Following::GetMapping(m_Ctx, stage); InitStageResourcePreviews(stage, details != NULL ? details->ReadWriteResources : empty, mapping.ReadWriteResources, RWs, ui->outputThumbs, outIndex, copy, diff --git a/qrenderdoc/Windows/TextureViewer.h b/qrenderdoc/Windows/TextureViewer.h index b8f76d3f0..bc69a6e67 100644 --- a/qrenderdoc/Windows/TextureViewer.h +++ b/qrenderdoc/Windows/TextureViewer.h @@ -84,11 +84,11 @@ struct Following static QMap> GetReadOnlyResources(CaptureContext &ctx, ShaderStageType stage); - ShaderReflection *GetReflection(CaptureContext &ctx); - static ShaderReflection *GetReflection(CaptureContext &ctx, ShaderStageType stage); + const ShaderReflection *GetReflection(CaptureContext &ctx); + static const ShaderReflection *GetReflection(CaptureContext &ctx, ShaderStageType stage); - ShaderBindpointMapping GetMapping(CaptureContext &ctx); - static ShaderBindpointMapping GetMapping(CaptureContext &ctx, ShaderStageType stage); + const ShaderBindpointMapping &GetMapping(CaptureContext &ctx); + static const ShaderBindpointMapping &GetMapping(CaptureContext &ctx, ShaderStageType stage); }; struct TexSettings