Query which shader disassembly formats require a pipeline

* This allows us to be a bit more friendly in the UI when we don't have a
  particular pipeline associated with a shader.
This commit is contained in:
baldurk
2020-09-01 14:03:59 +01:00
parent 6b2f763bfa
commit 83f7a26ee9
19 changed files with 65 additions and 25 deletions
@@ -3270,7 +3270,8 @@ void D3D12PipelineStateViewer::on_debugThread_clicked()
// viewer takes ownership of the trace
IShaderViewer *s =
m_Ctx.DebugShader(&bindMapping, shaderDetails, ResourceId(), trace, debugContext);
m_Ctx.DebugShader(&bindMapping, shaderDetails,
m_Ctx.CurPipelineState().GetComputePipelineObject(), trace, debugContext);
m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this);
}
@@ -3968,7 +3968,8 @@ void VulkanPipelineStateViewer::on_debugThread_clicked()
// viewer takes ownership of the trace
IShaderViewer *s =
m_Ctx.DebugShader(&bindMapping, shaderDetails, ResourceId(), trace, debugContext);
m_Ctx.DebugShader(&bindMapping, shaderDetails,
m_Ctx.CurPipelineState().GetComputePipelineObject(), trace, debugContext);
m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this);
}
+35 -1
View File
@@ -385,7 +385,18 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
if(!me)
return;
rdcarray<rdcstr> targets = r->GetDisassemblyTargets();
rdcarray<rdcstr> targets = r->GetDisassemblyTargets(m_Pipeline != ResourceId());
if(m_Pipeline == ResourceId())
{
rdcarray<rdcstr> pipelineTargets = r->GetDisassemblyTargets(true);
if(pipelineTargets.size() > targets.size())
{
m_PipelineTargets = pipelineTargets;
m_PipelineTargets.removeIf([&targets](const rdcstr &t) { return targets.contains(t); });
}
}
rdcstr disasm = r->DisassembleShader(m_Pipeline, m_ShaderDetails, "");
@@ -410,6 +421,9 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
}
}
if(!m_PipelineTargets.empty())
targetNames << tr("More disassembly formats...");
m_DisassemblyType->clear();
m_DisassemblyType->addItems(targetNames);
m_DisassemblyType->setCurrentIndex(0);
@@ -1385,6 +1399,26 @@ void ShaderViewer::disassemble_typeChanged(int index)
}
}
if(targetStr == tr("More disassembly formats..."))
{
QString text;
text =
tr("; More disassembly formats are available with a pipeline. This shader view is not\n"
"; associated with any specific pipeline and shows only the shader itself.\n\n"
"; Viewing the shader from the pipeline state view with a pipeline bound will expose\n"
"; these other formats:\n\n");
for(const rdcstr &t : m_PipelineTargets)
text += QFormatStr("%1\n").arg(QString(t));
m_DisassemblyView->setReadOnly(false);
SetTextAndUpdateMargin0(m_DisassemblyView, text);
m_DisassemblyView->setReadOnly(true);
m_DisassemblyView->emptyUndoBuffer();
return;
}
QPointer<ShaderViewer> me(this);
m_Ctx.Replay().AsyncInvoke([me, this, target](IReplayController *r) {
+1
View File
@@ -212,6 +212,7 @@ private:
ShaderStage m_Stage;
QString m_DebugContext;
ResourceId m_Pipeline;
rdcarray<rdcstr> m_PipelineTargets;
ScintillaEdit *m_DisassemblyView = NULL;
QFrame *m_DisassemblyToolbar = NULL;
QWidget *m_DisassemblyFrame = NULL;
+2 -1
View File
@@ -520,10 +520,11 @@ values are implementation dependent but will always include a default target fir
native disassembly of the shader. Further options may be available for additional diassembly views
or hardware-specific ISA formats.
:param bool withPipeline: More disassembly may be available when a pipeline is specified.
:return: The list of disassembly targets available.
:rtype: ``list`` of ``str``
)");
virtual rdcarray<rdcstr> GetDisassemblyTargets() = 0;
virtual rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline) = 0;
DOCUMENT(R"(Retrieve the disassembly for a given shader, for the given disassembly target.
+1 -1
View File
@@ -262,7 +262,7 @@ public:
{
return NULL;
}
rdcarray<rdcstr> GetDisassemblyTargets() { return {"N/A"}; }
rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline) { return {"N/A"}; }
rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target)
{
return "";
+7 -5
View File
@@ -1223,7 +1223,8 @@ rdcstr ReplayProxy::DisassembleShader(ResourceId pipeline, const ShaderReflectio
template <typename ParamSerialiser, typename ReturnSerialiser>
rdcarray<rdcstr> ReplayProxy::Proxied_GetDisassemblyTargets(ParamSerialiser &paramser,
ReturnSerialiser &retser)
ReturnSerialiser &retser,
bool withPipeline)
{
const ReplayProxyPacket expectedPacket = eReplayProxy_GetDisassemblyTargets;
ReplayProxyPacket packet = eReplayProxy_GetDisassemblyTargets;
@@ -1231,13 +1232,14 @@ rdcarray<rdcstr> ReplayProxy::Proxied_GetDisassemblyTargets(ParamSerialiser &par
{
BEGIN_PARAMS();
SERIALISE_ELEMENT(withPipeline);
END_PARAMS();
}
{
REMOTE_EXECUTION();
if(paramser.IsReading() && !paramser.IsErrored() && !m_IsErrored)
ret = m_Remote->GetDisassemblyTargets();
ret = m_Remote->GetDisassemblyTargets(withPipeline);
}
SERIALISE_RETURN(ret);
@@ -1245,9 +1247,9 @@ rdcarray<rdcstr> ReplayProxy::Proxied_GetDisassemblyTargets(ParamSerialiser &par
return ret;
}
rdcarray<rdcstr> ReplayProxy::GetDisassemblyTargets()
rdcarray<rdcstr> ReplayProxy::GetDisassemblyTargets(bool withPipeline)
{
PROXY_FUNCTION(GetDisassemblyTargets);
PROXY_FUNCTION(GetDisassemblyTargets, withPipeline);
}
template <typename ParamSerialiser, typename ReturnSerialiser>
@@ -2835,7 +2837,7 @@ bool ReplayProxy::Tick(int type)
PixelHistory(rdcarray<EventUsage>(), ResourceId(), 0, 0, Subresource(), CompType::Typeless);
break;
case eReplayProxy_DisassembleShader: DisassembleShader(ResourceId(), NULL, ""); break;
case eReplayProxy_GetDisassemblyTargets: GetDisassemblyTargets(); break;
case eReplayProxy_GetDisassemblyTargets: GetDisassemblyTargets(false); break;
case eReplayProxy_GetTargetShaderEncodings: GetTargetShaderEncodings(); break;
case eReplayProxy_GetDriverInfo: GetDriverInfo(); break;
case eReplayProxy_GetAvailableGPUs: GetAvailableGPUs(); break;
+1 -1
View File
@@ -514,7 +514,7 @@ public:
IMPLEMENT_FUNCTION_PROXIED(ShaderReflection *, GetShader, ResourceId pipeline, ResourceId,
ShaderEntryPoint entry);
IMPLEMENT_FUNCTION_PROXIED(rdcarray<rdcstr>, GetDisassemblyTargets);
IMPLEMENT_FUNCTION_PROXIED(rdcarray<rdcstr>, GetDisassemblyTargets, bool withPipeline);
IMPLEMENT_FUNCTION_PROXIED(rdcstr, DisassembleShader, ResourceId pipeline,
const ShaderReflection *refl, const rdcstr &target);
+1 -1
View File
@@ -284,7 +284,7 @@ ShaderReflection *D3D11Replay::GetShader(ResourceId pipeline, ResourceId shader,
return &ret;
}
rdcarray<rdcstr> D3D11Replay::GetDisassemblyTargets()
rdcarray<rdcstr> D3D11Replay::GetDisassemblyTargets(bool withPipeline)
{
return {DXBCDisassemblyTarget};
}
+1 -1
View File
@@ -130,7 +130,7 @@ public:
rdcarray<ShaderEntryPoint> GetShaderEntryPoints(ResourceId shader);
ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry);
rdcarray<rdcstr> GetDisassemblyTargets();
rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline);
rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target);
rdcarray<EventUsage> GetUsage(ResourceId id);
+1 -1
View File
@@ -434,7 +434,7 @@ ShaderReflection *D3D12Replay::GetShader(ResourceId pipeline, ResourceId shader,
return NULL;
}
rdcarray<rdcstr> D3D12Replay::GetDisassemblyTargets()
rdcarray<rdcstr> D3D12Replay::GetDisassemblyTargets(bool withPipeline)
{
rdcarray<rdcstr> ret;
+1 -1
View File
@@ -83,7 +83,7 @@ public:
rdcarray<ShaderEntryPoint> GetShaderEntryPoints(ResourceId shader);
ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry);
rdcarray<rdcstr> GetDisassemblyTargets();
rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline);
rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target);
rdcarray<EventUsage> GetUsage(ResourceId id);
+1 -1
View File
@@ -766,7 +766,7 @@ ShaderReflection *GLReplay::GetShader(ResourceId pipeline, ResourceId shader, Sh
return &shaderDetails.reflection;
}
rdcarray<rdcstr> GLReplay::GetDisassemblyTargets()
rdcarray<rdcstr> GLReplay::GetDisassemblyTargets(bool withPipeline)
{
return {SPIRVDisassemblyTarget};
}
+1 -1
View File
@@ -129,7 +129,7 @@ public:
rdcarray<ShaderEntryPoint> GetShaderEntryPoints(ResourceId shader);
ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry);
rdcarray<rdcstr> GetDisassemblyTargets();
rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline);
rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target);
rdcarray<DebugMessage> GetDebugMessages();
+3 -3
View File
@@ -443,14 +443,14 @@ ShaderReflection *VulkanReplay::GetShader(ResourceId pipeline, ResourceId shader
return &shad->second.GetReflection(entry.name, pipeline).refl;
}
rdcarray<rdcstr> VulkanReplay::GetDisassemblyTargets()
rdcarray<rdcstr> VulkanReplay::GetDisassemblyTargets(bool withPipeline)
{
rdcarray<rdcstr> ret;
if(m_pDriver->GetExtensions(NULL).ext_AMD_shader_info)
if(withPipeline && m_pDriver->GetExtensions(NULL).ext_AMD_shader_info)
ret.push_back(AMDShaderInfoTarget);
if(m_pDriver->GetExtensions(NULL).ext_KHR_pipeline_executable_properties)
if(withPipeline && m_pDriver->GetExtensions(NULL).ext_KHR_pipeline_executable_properties)
ret.push_back(KHRExecutablePropertiesTarget);
// default is always first
+1 -1
View File
@@ -273,7 +273,7 @@ public:
rdcarray<ShaderEntryPoint> GetShaderEntryPoints(ResourceId shader);
ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader, ShaderEntryPoint entry);
rdcarray<rdcstr> GetDisassemblyTargets();
rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline);
rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const rdcstr &target);
rdcarray<EventUsage> GetUsage(ResourceId id);
+2 -2
View File
@@ -142,13 +142,13 @@ const PipeState &ReplayController::GetPipelineState()
return m_PipeState;
}
rdcarray<rdcstr> ReplayController::GetDisassemblyTargets()
rdcarray<rdcstr> ReplayController::GetDisassemblyTargets(bool withPipeline)
{
CHECK_REPLAY_THREAD();
rdcarray<rdcstr> ret;
rdcarray<rdcstr> targets = m_pDevice->GetDisassemblyTargets();
rdcarray<rdcstr> targets = m_pDevice->GetDisassemblyTargets(withPipeline);
ret.reserve(targets.size());
for(const rdcstr &t : targets)
+1 -1
View File
@@ -143,7 +143,7 @@ public:
const VKPipe::State *GetVulkanPipelineState();
const PipeState &GetPipelineState();
rdcarray<rdcstr> GetDisassemblyTargets();
rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline);
rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const char *target);
rdcpair<ResourceId, rdcstr> BuildCustomShader(const char *entry, ShaderEncoding sourceEncoding,
+1 -1
View File
@@ -148,7 +148,7 @@ public:
virtual ShaderReflection *GetShader(ResourceId pipeline, ResourceId shader,
ShaderEntryPoint entry) = 0;
virtual rdcarray<rdcstr> GetDisassemblyTargets() = 0;
virtual rdcarray<rdcstr> GetDisassemblyTargets(bool withPipeline) = 0;
virtual rdcstr DisassembleShader(ResourceId pipeline, const ShaderReflection *refl,
const rdcstr &target) = 0;