Fetch shader messages from DebugPrintf

This commit is contained in:
baldurk
2021-05-11 16:15:31 +01:00
parent 968fd249c0
commit 4eb2621bca
13 changed files with 1251 additions and 56 deletions
+1
View File
@@ -360,6 +360,7 @@ TEMPLATE_ARRAY_INSTANTIATE(rdcarray, LineColumnInfo)
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderCompileFlag)
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderConstant)
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderDebugState)
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderMessage)
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderResource)
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderSampler)
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderSourceFile)
+175
View File
@@ -487,3 +487,178 @@ from the vertex buffer before advancing to the next value.
};
DECLARE_REFLECTION_STRUCT(VertexInputAttribute);
DOCUMENT("A compute shader message's location.");
struct ShaderComputeMessageLocation
{
DOCUMENT("");
ShaderComputeMessageLocation() = default;
ShaderComputeMessageLocation(const ShaderComputeMessageLocation &) = default;
ShaderComputeMessageLocation &operator=(const ShaderComputeMessageLocation &) = default;
bool operator==(const ShaderComputeMessageLocation &o) const
{
return workgroup == o.workgroup && thread == o.thread;
}
bool operator<(const ShaderComputeMessageLocation &o) const
{
if(!(workgroup == o.workgroup))
return workgroup < o.workgroup;
if(!(thread == o.thread))
return thread < o.thread;
return false;
}
DOCUMENT(R"(The workgroup index within the dispatch.
:type: Tuple[int,int,int]
)");
rdcfixedarray<uint32_t, 3> workgroup;
DOCUMENT(R"(The thread index within the workgroup.
:type: Tuple[int,int,int]
)");
rdcfixedarray<uint32_t, 3> thread;
};
DECLARE_REFLECTION_STRUCT(ShaderComputeMessageLocation);
DOCUMENT("A vertex shader message's location.");
struct ShaderVertexMessageLocation
{
DOCUMENT(R"(The vertex or index for this vertex.
:type: int
)");
uint32_t vertexIndex;
DOCUMENT(R"(The instance for this vertex.
:type: int
)");
uint32_t instance;
DOCUMENT(R"(The multiview view for this vertex, or ``0`` if multiview is disabled.
:type: int
)");
uint32_t view;
};
DECLARE_REFLECTION_STRUCT(ShaderVertexMessageLocation);
DOCUMENT(R"(A pixel shader message's location.
.. data:: NoLocation
No frame number is available.
)");
struct ShaderPixelMessageLocation
{
DOCUMENT(R"(The x co-ordinate of the pixel.
:type: int
)");
uint32_t x;
DOCUMENT(R"(The y co-ordinate of the pixel.
:type: int
)");
uint32_t y;
DOCUMENT(R"(The sample, or :data:`NoLocation` if sample shading is disabled.
:type: int
)");
uint32_t sample;
DOCUMENT(R"(The generating primitive, or :data:`NoLocation` if the primitive ID is unavailable.
:type: int
)");
uint32_t primitive;
static const uint32_t NoLocation = ~0U;
};
DECLARE_REFLECTION_STRUCT(ShaderPixelMessageLocation);
DOCUMENT("A shader message's location.");
union ShaderMessageLocation
{
DOCUMENT(R"(The location if the shader is a compute shader.
:type: ShaderComputeMessageLocation
)");
ShaderComputeMessageLocation compute;
DOCUMENT(R"(The location if the shader is a vertex shader.
:type: ShaderVertexMessageLocation
)");
ShaderVertexMessageLocation vertex;
DOCUMENT(R"(The location if the shader is a pixel shader.
:type: ShaderPixelMessageLocation
)");
ShaderPixelMessageLocation pixel;
};
DECLARE_REFLECTION_STRUCT(ShaderMessageLocation);
DOCUMENT("A shader printed message.");
struct ShaderMessage
{
DOCUMENT("");
ShaderMessage() = default;
ShaderMessage(const ShaderMessage &) = default;
ShaderMessage &operator=(const ShaderMessage &) = default;
bool operator==(const ShaderMessage &o) const
{
return stage == o.stage && disassemblyLine == o.disassemblyLine &&
location.compute == o.location.compute && message == o.message;
}
bool operator<(const ShaderMessage &o) const
{
if(!(stage == o.stage))
return stage < o.stage;
if(!(disassemblyLine == o.disassemblyLine))
return disassemblyLine < o.disassemblyLine;
if(!(location.compute == o.location.compute))
return location.compute < o.location.compute;
if(!(message == o.message))
return message < o.message;
return false;
}
DOCUMENT(R"(The shader stage this message comes from.
:type: ShaderStage
)");
ShaderStage stage;
DOCUMENT(R"(The line (starting from 1) of the disassembly where this message came from, or -1 if
it is not associated with any line.
:type: int
)");
int32_t disassemblyLine;
DOCUMENT(R"(The location (thread/invocation) of the shader that this message comes from.
:type: ShaderMessageLocation
)");
ShaderMessageLocation location;
DOCUMENT(R"(The formatted message.
:type: str
)");
rdcstr message;
};
DECLARE_REFLECTION_STRUCT(ShaderMessage);
+7
View File
@@ -385,6 +385,13 @@ For some APIs that don't distinguish by entry point, this may be empty.
)");
bool IsIndependentBlendingEnabled() const;
DOCUMENT(R"(Retrieves the shader messages obtained for the current draw.
:return: The shader messages obtained for the current draw.
:rtype: List[ShaderMessage]
)");
const rdcarray<ShaderMessage> &GetShaderMessages() const;
private:
const D3D11Pipe::State *m_D3D11 = NULL;
const D3D12Pipe::State *m_D3D12 = NULL;
+15
View File
@@ -1758,6 +1758,21 @@ rdcpair<StencilFace, StencilFace> PipeState::GetStencilFaces() const
return {StencilFace(), StencilFace()};
}
const rdcarray<ShaderMessage> &PipeState::GetShaderMessages() const
{
if(IsCaptureLoaded())
{
if(IsCaptureVK())
{
return m_Vulkan->shaderMessages;
}
}
static rdcarray<ShaderMessage> empty;
return empty;
}
bool PipeState::IsIndependentBlendingEnabled() const
{
if(IsCaptureLoaded())
+6
View File
@@ -1297,6 +1297,12 @@ struct State
)");
rdcarray<ImageData> images;
DOCUMENT(R"(The shader messages retrieved for this draw.
:type: List[ShaderMessage]
)");
rdcarray<ShaderMessage> shaderMessages;
DOCUMENT(R"(The current conditional rendering state.
:type: VKConditionalRendering
@@ -2363,6 +2363,15 @@ void Debugger::RegisterOp(Iter it)
idDeathOffset[id] = RDCMAX(it.offs() + 1, idDeathOffset[id]);
}
}
else if(extSets[extinst.set] == "NonSemantic.DebugPrintf")
{
// all parameters to NonSemantic.DebugPrintf are Ids, extend idDeathOffset appropriately
for(const uint32_t param : extinst.params)
{
Id id = Id::fromWord(param);
idDeathOffset[id] = RDCMAX(it.offs() + 1, idDeathOffset[id]);
}
}
}
if(opdata.op == Op::Source)
+1 -1
View File
@@ -8,7 +8,7 @@ set(sources
vk_debug.h
vk_debug.cpp
vk_postvs.cpp
vk_bindless_feedback.cpp
vk_shader_feedback.cpp
vk_overlay.cpp
vk_msaa_array_conv.cpp
vk_outputwindow.cpp
@@ -109,7 +109,7 @@
<ClCompile Include="vk_apple.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="vk_bindless_feedback.cpp" />
<ClCompile Include="vk_shader_feedback.cpp" />
<ClCompile Include="vk_image_states.cpp" />
<ClCompile Include="vk_msaa_array_conv.cpp" />
<ClCompile Include="vk_next_chains.cpp" />
@@ -133,9 +133,6 @@
<ClCompile Include="vk_next_chains.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="vk_bindless_feedback.cpp">
<Filter>Replay</Filter>
</ClCompile>
<ClCompile Include="imgrefs_tests.cpp">
<Filter>Util</Filter>
</ClCompile>
@@ -151,6 +148,9 @@
<ClCompile Include="vk_shaderdebug.cpp">
<Filter>Replay</Filter>
</ClCompile>
<ClCompile Include="vk_shader_feedback.cpp">
<Filter>Replay</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="vk_replay.h">
+4 -1
View File
@@ -1623,6 +1623,10 @@ void VulkanReplay::SavePipelineState(uint32_t eventId)
&state.graphics.descSets, &state.compute.descSets,
};
const DynamicShaderFeedback &usage = m_BindlessFeedback.Usage[eventId];
m_VulkanPipelineState.shaderMessages = usage.messages;
for(size_t p = 0; p < ARRAY_COUNT(srcs); p++)
{
bool hasUsedBinds = false;
@@ -1630,7 +1634,6 @@ void VulkanReplay::SavePipelineState(uint32_t eventId)
size_t usedBindsSize = 0;
{
const DynamicUsedBinds &usage = m_BindlessFeedback.Usage[eventId];
bool curCompute = (p == 1);
if(usage.valid && usage.compute == curCompute)
{
+3 -2
View File
@@ -209,10 +209,11 @@ struct VulkanPostVSData
}
};
struct DynamicUsedBinds
struct DynamicShaderFeedback
{
bool compute = false, valid = false;
rdcarray<BindpointIndex> used;
rdcarray<ShaderMessage> messages;
};
enum TexDisplayFlags
@@ -742,7 +743,7 @@ private:
GPUBuffer FeedbackBuffer;
std::map<uint32_t, DynamicUsedBinds> Usage;
std::map<uint32_t, DynamicShaderFeedback> Usage;
} m_BindlessFeedback;
ShaderDebugData m_ShaderDebugData;
+49 -1
View File
@@ -1023,6 +1023,54 @@ void DoSerialise(SerialiserType &ser, StencilFace &el)
SIZE_CHECK(28);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderComputeMessageLocation &el)
{
SERIALISE_MEMBER(workgroup);
SERIALISE_MEMBER(thread);
SIZE_CHECK(24);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderVertexMessageLocation &el)
{
SERIALISE_MEMBER(vertexIndex);
SERIALISE_MEMBER(instance);
SERIALISE_MEMBER(view);
SIZE_CHECK(12);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderPixelMessageLocation &el)
{
SERIALISE_MEMBER(x);
SERIALISE_MEMBER(y);
SERIALISE_MEMBER(sample);
SERIALISE_MEMBER(primitive);
SIZE_CHECK(16);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderMessageLocation &el)
{
SERIALISE_MEMBER(compute);
SIZE_CHECK(24);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderMessage &el)
{
SERIALISE_MEMBER(stage);
SERIALISE_MEMBER(location);
SERIALISE_MEMBER(message);
SIZE_CHECK(52);
}
#pragma endregion
#pragma region D3D11 pipeline state
@@ -2274,7 +2322,7 @@ void DoSerialise(SerialiserType &ser, VKPipe::State &el)
SERIALISE_MEMBER(conditionalRendering);
SIZE_CHECK(1976);
SIZE_CHECK(2000);
}
#pragma endregion Vulkan pipeline state