Avoid copying large structs, prefer to pass by reference

This commit is contained in:
baldurk
2017-02-10 21:48:46 +00:00
parent 0dfe6e3a8e
commit 354a2707ae
6 changed files with 23 additions and 19 deletions
+5 -3
View File
@@ -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())
{
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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();
@@ -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)
{
+9 -7
View File
@@ -271,7 +271,7 @@ QMap<BindpointMap, QVector<BoundResource>> 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<BindpointMap, QVector<BoundResource>> RWs = Following::GetReadWriteResources(m_Ctx, stage);
QMap<BindpointMap, QVector<BoundResource>> 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,
+4 -4
View File
@@ -84,11 +84,11 @@ struct Following
static QMap<BindpointMap, QVector<BoundResource>> 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