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);
});
+4
View File
@@ -521,6 +521,10 @@ struct ShaderReflection
DOCUMENT("The entry point in the shader for this reflection, if multiple entry points exist.");
rdcstr EntryPoint;
DOCUMENT(
"The :class:`ShaderStage` that this shader corresponds to, if multiple entry points exist.");
ShaderStage Stage;
DOCUMENT(
"A :class:`ShaderDebugChunk` containing any embedded debugging information in this shader.");
ShaderDebugChunk DebugInfo;
@@ -185,9 +185,6 @@ void WrappedShader::ShaderEntry::BuildReflection()
MakeShaderReflection(m_DXBCFile, &m_Details, &m_Mapping);
m_Details.ID = m_ID;
m_Details.EntryPoint = m_DXBCFile->m_DebugInfo ? m_DXBCFile->m_DebugInfo->GetEntryFunction() : "";
if(m_Details.EntryPoint.empty())
m_Details.EntryPoint = "main";
}
UINT GetMipForSubresource(ID3D11Resource *res, int Subresource)
@@ -492,7 +492,4 @@ void WrappedID3D12PipelineState::ShaderEntry::BuildReflection()
MakeShaderReflection(m_DXBCFile, &m_Details, &m_Mapping);
m_Details.ID = GetResourceID();
m_Details.EntryPoint = m_DXBCFile->m_DebugInfo ? m_DXBCFile->m_DebugInfo->GetEntryFunction() : "";
if(m_Details.EntryPoint.empty())
m_Details.EntryPoint = "main";
}
@@ -117,6 +117,21 @@ void WrappedOpenGL::ShaderData::Compile(WrappedOpenGL &gl, ResourceId id, GLuint
reflection.ID = id;
reflection.EntryPoint = "main";
switch(settings.stage)
{
case SPIRVShaderStage::Vertex: reflection.Stage = ShaderStage::Vertex; break;
case SPIRVShaderStage::TessControl: reflection.Stage = ShaderStage::Tess_Control; break;
case SPIRVShaderStage::TessEvaluation: reflection.Stage = ShaderStage::Tess_Eval; break;
case SPIRVShaderStage::Geometry: reflection.Stage = ShaderStage::Geometry; break;
case SPIRVShaderStage::Fragment: reflection.Stage = ShaderStage::Fragment; break;
case SPIRVShaderStage::Compute: reflection.Stage = ShaderStage::Compute; break;
case SPIRVShaderStage::Invalid:
default:
RDCERR("Unexpected shader stage %u", settings.stage);
reflection.Stage = ShaderStage::Vertex;
break;
}
// TODO sort these so that the first file contains the entry point
reflection.DebugInfo.files.resize(sources.size());
for(size_t i = 0; i < sources.size(); i++)
@@ -206,8 +206,26 @@ void MakeShaderReflection(DXBC::DXBCFile *dxbc, ShaderReflection *refl,
if(dxbc == NULL || !RenderDoc::Inst().IsReplayApp())
return;
switch(dxbc->m_Type)
{
case D3D11_ShaderType_Pixel: refl->Stage = ShaderStage::Pixel; break;
case D3D11_ShaderType_Vertex: refl->Stage = ShaderStage::Vertex; break;
case D3D11_ShaderType_Geometry: refl->Stage = ShaderStage::Geometry; break;
case D3D11_ShaderType_Hull: refl->Stage = ShaderStage::Hull; break;
case D3D11_ShaderType_Domain: refl->Stage = ShaderStage::Domain; break;
case D3D11_ShaderType_Compute: refl->Stage = ShaderStage::Compute; break;
default:
RDCERR("Unexpected DXBC shader type %u", dxbc->m_Type);
refl->Stage = ShaderStage::Vertex;
break;
}
refl->EntryPoint = "main";
if(dxbc->m_DebugInfo)
{
refl->EntryPoint = dxbc->m_DebugInfo->GetEntryFunction();
refl->DebugInfo.compileFlags = DXBC::EncodeFlags(dxbc->m_DebugInfo);
refl->DebugInfo.files.resize(dxbc->m_DebugInfo->Files.size());
@@ -3910,6 +3910,8 @@ void SPVModule::MakeReflection(ShaderStage stage, const string &entryPoint,
vector<shaderrespair> samplers, roresources, rwresources;
// VKTODOLOW filter to only functions/resources used by entryPoint
reflection.EntryPoint = entryPoint;
reflection.Stage = stage;
// TODO sort these so that the entry point is in the first file
if(!sourceFiles.empty())
+2 -4
View File
@@ -141,13 +141,12 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, Vulk
if(reflData.entryPoint.empty())
{
SPVModule &spv = info.m_ShaderModule[id].spirv;
spv.MakeReflection(ShaderStage(reflData.stage), reflData.entryPoint, reflData.refl,
spv.MakeReflection(ShaderStage(reflData.stage), shad.entryPoint, reflData.refl,
reflData.mapping, reflData.patchData);
reflData.entryPoint = shad.entryPoint;
reflData.stage = stageIndex;
reflData.refl.ID = resourceMan->GetOriginalID(id);
reflData.refl.EntryPoint = shad.entryPoint;
if(!spv.spirv.empty())
{
@@ -369,10 +368,9 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, Vulk
reflData.entryPoint = shad.entryPoint;
reflData.stage = StageIndex(pCreateInfo->stage.stage);
SPVModule &spv = info.m_ShaderModule[id].spirv;
spv.MakeReflection(ShaderStage::Compute, reflData.entryPoint, reflData.refl, reflData.mapping,
spv.MakeReflection(ShaderStage::Compute, shad.entryPoint, reflData.refl, reflData.mapping,
reflData.patchData);
reflData.refl.ID = resourceMan->GetOriginalID(id);
reflData.refl.EntryPoint = shad.entryPoint;
if(!spv.spirv.empty())
{
+3 -1
View File
@@ -265,6 +265,8 @@ void DoSerialise(SerialiserType &ser, ShaderReflection &el)
SERIALISE_MEMBER(ID);
SERIALISE_MEMBER(EntryPoint);
SERIALISE_MEMBER(Stage);
SERIALISE_MEMBER(DebugInfo);
SERIALISE_MEMBER(DispatchThreadsDimension);
@@ -283,7 +285,7 @@ void DoSerialise(SerialiserType &ser, ShaderReflection &el)
SERIALISE_MEMBER(Interfaces);
SIZE_CHECK(200);
SIZE_CHECK(208);
}
template <typename SerialiserType>