debug: Add concept of implicit instance index to debug ring.
For internal debug shaders, it is helpful to ensure in-order logs when sorted for later inspection. Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This commit is contained in:
parent
bcdac3180a
commit
4a07d9c038
|
@ -97,6 +97,14 @@ void DEBUG_CHANNEL_INIT(uvec3 id)
|
|||
#endif
|
||||
}
|
||||
|
||||
void DEBUG_CHANNEL_INIT_IMPLICIT_INSTANCE(uvec3 id, uint inst)
|
||||
{
|
||||
if (!DEBUG_SHADER_RING_ACTIVE)
|
||||
return;
|
||||
DEBUG_CHANNEL_ID = id;
|
||||
DEBUG_CHANNEL_INSTANCE_COUNTER = inst;
|
||||
}
|
||||
|
||||
void DEBUG_CHANNEL_UNLOCK_MESSAGE(RingBuffer buf, uint offset, uint num_words)
|
||||
{
|
||||
memoryBarrierBuffer();
|
||||
|
|
|
@ -9707,6 +9707,15 @@ static void d3d12_command_list_execute_indirect_state_template(
|
|||
patch_args.dst_indirect_count_va = count_buffer ? count_allocation.va : 0;
|
||||
patch_args.api_buffer_word_stride = signature->desc.ByteStride / sizeof(uint32_t);
|
||||
patch_args.device_generated_commands_word_stride = signature->state_template.stride / sizeof(uint32_t);
|
||||
patch_args.debug_tag = 0; /* Modify to non-zero value as desired when debugging. */
|
||||
|
||||
if (patch_args.debug_tag != 0)
|
||||
{
|
||||
/* Makes log easier to understand since a sorted log will appear in-order. */
|
||||
static uint32_t vkd3d_implicit_instance_count;
|
||||
patch_args.implicit_instance = vkd3d_atomic_uint32_increment(
|
||||
&vkd3d_implicit_instance_count, vkd3d_memory_order_relaxed) - 1;
|
||||
}
|
||||
|
||||
barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
|
||||
barrier.pNext = NULL;
|
||||
|
|
|
@ -130,9 +130,10 @@ static bool vkd3d_shader_debug_ring_print_message(struct vkd3d_shader_debug_ring
|
|||
if (shader_hash == 0)
|
||||
{
|
||||
/* We got this from our internal debug shaders. Pretty-print.
|
||||
* Make sure the log is sortable for easier debug.
|
||||
* TODO: Might consider a callback system that listeners from different subsystems can listen to and print their own messages,
|
||||
* but that is overengineering at this time ... */
|
||||
snprintf(message_buffer, sizeof(message_buffer), "ExecuteIndirect: Instance %010u, Debug tag %u, DrawID %u (ThreadID %u): ",
|
||||
snprintf(message_buffer, sizeof(message_buffer), "ExecuteIndirect: GlobalCommandIndex %010u, Debug tag %010u, DrawID %04u (ThreadID %04u): ",
|
||||
debug_instance, debug_thread_id[0], debug_thread_id[1], debug_thread_id[2]);
|
||||
|
||||
if (message_word_count == 2)
|
||||
|
|
|
@ -51,12 +51,13 @@ layout(push_constant) uniform Registers
|
|||
|
||||
// Debug metadata here
|
||||
uint debug_tag;
|
||||
uint implicit_instance;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
if (debug_tag != 0u)
|
||||
DEBUG_CHANNEL_INIT(uvec3(debug_tag, gl_WorkGroupID.x, gl_LocalInvocationIndex));
|
||||
DEBUG_CHANNEL_INIT_IMPLICIT_INSTANCE(uvec3(debug_tag, gl_WorkGroupID.x, gl_LocalInvocationIndex), implicit_instance);
|
||||
|
||||
Command cmd = commands_va.commands[gl_LocalInvocationIndex];
|
||||
|
||||
|
|
|
@ -3081,6 +3081,7 @@ struct vkd3d_execute_indirect_args
|
|||
|
||||
/* Arbitrary tag used for debug version of state patcher. Debug messages from tag 0 are ignored. */
|
||||
uint32_t debug_tag;
|
||||
uint32_t implicit_instance;
|
||||
};
|
||||
|
||||
struct vkd3d_execute_indirect_pipeline
|
||||
|
|
Loading…
Reference in New Issue