Reduce parameters that need to be passed for viewing shaders

This commit is contained in:
baldurk
2017-11-22 16:45:50 +00:00
parent 38acc56084
commit 602511bf33
21 changed files with 79 additions and 67 deletions
+4 -7
View File
@@ -1403,18 +1403,15 @@ IShaderViewer *CaptureContext::EditShader(bool customShader, const QString &entr
IShaderViewer *CaptureContext::DebugShader(const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage, ShaderDebugTrace *trace,
const QString &debugContext)
ShaderDebugTrace *trace, const QString &debugContext)
{
return ShaderViewer::DebugShader(*this, bind, shader, pipeline, stage, trace, debugContext,
return ShaderViewer::DebugShader(*this, bind, shader, pipeline, trace, debugContext,
m_MainWindow->Widget());
}
IShaderViewer *CaptureContext::ViewShader(const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage)
IShaderViewer *CaptureContext::ViewShader(const ShaderReflection *shader, ResourceId pipeline)
{
return ShaderViewer::ViewShader(*this, bind, shader, pipeline, stage, m_MainWindow->Widget());
return ShaderViewer::ViewShader(*this, shader, pipeline, m_MainWindow->Widget());
}
IBufferViewer *CaptureContext::ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id,
+2 -3
View File
@@ -192,11 +192,10 @@ public:
IShaderViewer::CloseCallback closeCallback) override;
IShaderViewer *DebugShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader,
ResourceId pipeline, ShaderStage stage, ShaderDebugTrace *trace,
ResourceId pipeline, ShaderDebugTrace *trace,
const QString &debugContext) override;
IShaderViewer *ViewShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader,
ResourceId pipeline, ShaderStage stage) override;
IShaderViewer *ViewShader(const ShaderReflection *shader, ResourceId pipeline) override;
IBufferViewer *ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id,
const QString &format = QString()) override;
+2 -8
View File
@@ -1618,7 +1618,6 @@ through the execution of a given shader.
:param ~renderdoc.ShaderReflection shader: The reflection data for the shader to view.
:param ~renderdoc.ResourceId pipeline: The pipeline state object, if applicable, that this shader is
bound to.
:param ~renderdoc.ShaderStage stage: The stage that the shader is bound to.
:param ~renderdoc.ShaderDebugTrace trace: The execution trace of the debugged shader.
:param str debugContext: A human-readable context string describing which invocation of this shader
was debugged. For example 'Pixel 12,34 at EID 678'.
@@ -1627,22 +1626,17 @@ through the execution of a given shader.
)");
virtual IShaderViewer *DebugShader(const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage, ShaderDebugTrace *trace,
const QString &debugContext) = 0;
ShaderDebugTrace *trace, const QString &debugContext) = 0;
DOCUMENT(R"(Show a new :class:`ShaderViewer` window, showing a read-only view of a given shader.
:param ~renderdoc.ShaderBindpointMapping bind: The bindpoint mapping for the shader to view.
:param ~renderdoc.ShaderReflection shader: The reflection data for the shader to view.
:param ~renderdoc.ResourceId pipeline: The pipeline state object, if applicable, that this shader is
bound to.
:param ~renderdoc.ShaderStage stage: The stage that the shader is bound to.
:return: The new :class:`ShaderViewer` window opened, but not shown.
:rtype: ShaderViewer
)");
virtual IShaderViewer *ViewShader(const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage) = 0;
virtual IShaderViewer *ViewShader(const ShaderReflection *shader, ResourceId pipeline) = 0;
DOCUMENT(R"(Show a new :class:`BufferViewer` window, showing a read-only view of buffer data.
+2 -2
View File
@@ -3208,8 +3208,8 @@ void BufferViewer::debugVertex()
ResourceId pipeline = m_Ctx.CurPipelineState().GetGraphicsPipelineObject();
// viewer takes ownership of the trace
IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, pipeline,
ShaderStage::Vertex, trace, debugContext);
IShaderViewer *s =
m_Ctx.DebugShader(&bindMapping, shaderDetails, pipeline, trace, debugContext);
m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this);
});
@@ -2208,15 +2208,12 @@ void D3D11PipelineStateViewer::vertex_leave(QEvent *e)
void D3D11PipelineStateViewer::shaderView_clicked()
{
ShaderStage shaderStage = ShaderStage::Vertex;
ShaderReflection *shaderDetails = NULL;
const ShaderBindpointMapping *bindMap = NULL;
QWidget *sender = qobject_cast<QWidget *>(QObject::sender());
if(sender == ui->iaBytecode || sender == ui->iaBytecodeViewButton)
{
shaderDetails = m_Ctx.CurD3D11PipelineState().m_IA.Bytecode;
bindMap = NULL;
}
else
{
@@ -2225,12 +2222,10 @@ void D3D11PipelineStateViewer::shaderView_clicked()
if(stage == NULL || stage->Object == ResourceId())
return;
bindMap = &stage->BindpointMapping;
shaderDetails = stage->ShaderDetails;
shaderStage = stage->stage;
}
IShaderViewer *shad = m_Ctx.ViewShader(bindMap, shaderDetails, ResourceId(), shaderStage);
IShaderViewer *shad = m_Ctx.ViewShader(shaderDetails, ResourceId());
m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this);
}
@@ -3130,8 +3125,8 @@ void D3D11PipelineStateViewer::on_debugThread_clicked()
m_Ctx.CurPipelineState().GetBindpointMapping(ShaderStage::Compute);
// viewer takes ownership of the trace
IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, ResourceId(),
ShaderStage::Compute, trace, debugContext);
IShaderViewer *s =
m_Ctx.DebugShader(&bindMapping, shaderDetails, ResourceId(), trace, debugContext);
m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this);
});
@@ -2059,8 +2059,8 @@ void D3D12PipelineStateViewer::shaderView_clicked()
if(stage == NULL || stage->Object == ResourceId())
return;
IShaderViewer *shad = m_Ctx.ViewShader(&stage->BindpointMapping, stage->ShaderDetails,
m_Ctx.CurD3D12PipelineState().pipeline, stage->stage);
IShaderViewer *shad =
m_Ctx.ViewShader(stage->ShaderDetails, m_Ctx.CurD3D12PipelineState().pipeline);
m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this);
}
@@ -2162,8 +2162,7 @@ void GLPipelineStateViewer::shaderView_clicked()
ShaderReflection *shaderDetails = stage->ShaderDetails;
IShaderViewer *shad =
m_Ctx.ViewShader(&stage->BindpointMapping, shaderDetails, ResourceId(), stage->stage);
IShaderViewer *shad = m_Ctx.ViewShader(shaderDetails, ResourceId());
m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this);
}
@@ -2285,7 +2285,7 @@ void VulkanPipelineStateViewer::shaderView_clicked()
? m_Ctx.CurVulkanPipelineState().compute.obj
: m_Ctx.CurVulkanPipelineState().graphics.obj;
IShaderViewer *shad = m_Ctx.ViewShader(&stage->BindpointMapping, shaderDetails, pipe, stage->stage);
IShaderViewer *shad = m_Ctx.ViewShader(shaderDetails, pipe);
m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this);
}
+1 -2
View File
@@ -702,8 +702,7 @@ void PixelHistoryView::startDebug(EventTag tag)
ResourceId pipeline = m_Ctx.CurPipelineState().GetGraphicsPipelineObject();
// viewer takes ownership of the trace
IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, pipeline, ShaderStage::Pixel,
trace, debugContext);
IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, pipeline, trace, debugContext);
m_Ctx.AddDockWindow(s->Widget(), DockReference::MainToolArea, NULL);
});
+4 -8
View File
@@ -365,19 +365,15 @@ struct CaptureContextInvoker : ICaptureContext
virtual IShaderViewer *DebugShader(const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage, ShaderDebugTrace *trace,
const QString &debugContext) override
ShaderDebugTrace *trace, const QString &debugContext) override
{
return InvokeRetFunction<IShaderViewer *>(&ICaptureContext::DebugShader, bind, shader, pipeline,
stage, trace, debugContext);
trace, debugContext);
}
virtual IShaderViewer *ViewShader(const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage) override
virtual IShaderViewer *ViewShader(const ShaderReflection *shader, ResourceId pipeline) override
{
return InvokeRetFunction<IShaderViewer *>(&ICaptureContext::ViewShader, bind, shader, pipeline,
stage);
return InvokeRetFunction<IShaderViewer *>(&ICaptureContext::ViewShader, shader, pipeline);
}
virtual IBufferViewer *ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id,
+4 -2
View File
@@ -282,14 +282,14 @@ void ShaderViewer::editShader(bool customShader, const QString &entryPoint, cons
}
void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader,
ResourceId pipeline, ShaderStage stage, ShaderDebugTrace *trace,
ResourceId pipeline, ShaderDebugTrace *trace,
const QString &debugContext)
{
m_Mapping = bind;
m_ShaderDetails = shader;
m_Pipeline = pipeline;
m_Trace = trace;
m_Stage = stage;
m_Stage = ShaderStage::Vertex;
m_DebugContext = debugContext;
// no replacing allowed, stay in find mode
@@ -301,6 +301,8 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
if(shader)
{
m_Stage = shader->Stage;
m_Ctx.Replay().AsyncInvoke([this](IReplayController *r) {
rdcarray<rdcstr> targets = r->GetDisassemblyTargets();
+7 -9
View File
@@ -72,19 +72,18 @@ public:
static IShaderViewer *DebugShader(ICaptureContext &ctx, const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage, ShaderDebugTrace *trace,
const QString &debugContext, QWidget *parent)
ShaderDebugTrace *trace, const QString &debugContext,
QWidget *parent)
{
ShaderViewer *ret = new ShaderViewer(ctx, parent);
ret->debugShader(bind, shader, pipeline, stage, trace, debugContext);
ret->debugShader(bind, shader, pipeline, trace, debugContext);
return ret;
}
static IShaderViewer *ViewShader(ICaptureContext &ctx, const ShaderBindpointMapping *bind,
const ShaderReflection *shader, ResourceId pipeline,
ShaderStage stage, QWidget *parent)
static IShaderViewer *ViewShader(ICaptureContext &ctx, const ShaderReflection *shader,
ResourceId pipeline, QWidget *parent)
{
return DebugShader(ctx, bind, shader, pipeline, stage, NULL, QString(), parent);
return DebugShader(ctx, NULL, shader, pipeline, NULL, QString(), parent);
}
~ShaderViewer();
@@ -149,8 +148,7 @@ private:
explicit ShaderViewer(ICaptureContext &ctx, QWidget *parent = 0);
void editShader(bool customShader, const QString &entryPoint, const QStringMap &files);
void debugShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader,
ResourceId pipeline, ShaderStage stage, ShaderDebugTrace *trace,
const QString &debugContext);
ResourceId pipeline, ShaderDebugTrace *trace, const QString &debugContext);
bool eventFilter(QObject *watched, QEvent *event) override;
const rdcarray<ShaderVariable> *GetVariableList(VariableCategory varCat, int arrayIdx);
+2 -2
View File
@@ -3403,8 +3403,8 @@ void TextureViewer::on_debugPixelContext_clicked()
ResourceId pipeline = m_Ctx.CurPipelineState().GetGraphicsPipelineObject();
// viewer takes ownership of the trace
IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, pipeline,
ShaderStage::Pixel, trace, debugContext);
IShaderViewer *s =
m_Ctx.DebugShader(&bindMapping, shaderDetails, pipeline, trace, debugContext);
m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this);
});