From ffdfe136e6746dfa8b237f9827eae757e1facaa8 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 8 Dec 2020 11:46:15 +0100 Subject: [PATCH] ac/sqtt: move rgp/sqtt def to ac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Acked-by: Samuel Pitoiset Part-of: --- src/amd/common/ac_sqtt.h | 333 ++++++++++++++++++++++++ src/amd/vulkan/layers/radv_sqtt_layer.c | 329 +---------------------- 2 files changed, 334 insertions(+), 328 deletions(-) diff --git a/src/amd/common/ac_sqtt.h b/src/amd/common/ac_sqtt.h index 9680be4c661..7fe875870cf 100644 --- a/src/amd/common/ac_sqtt.h +++ b/src/amd/common/ac_sqtt.h @@ -28,6 +28,8 @@ #include +#include "c11_compat.h" + struct ac_thread_trace_data { struct radeon_cmdbuf *start_cs[2]; struct radeon_cmdbuf *stop_cs[2]; @@ -73,4 +75,335 @@ ac_thread_trace_get_info_va(uint64_t va, unsigned se); uint64_t ac_thread_trace_get_data_va(struct ac_thread_trace_data *data, uint64_t va, unsigned se); +/** + * Identifiers for RGP SQ thread-tracing markers (Table 1) + */ +enum rgp_sqtt_marker_identifier +{ + RGP_SQTT_MARKER_IDENTIFIER_EVENT = 0x0, + RGP_SQTT_MARKER_IDENTIFIER_CB_START = 0x1, + RGP_SQTT_MARKER_IDENTIFIER_CB_END = 0x2, + RGP_SQTT_MARKER_IDENTIFIER_BARRIER_START = 0x3, + RGP_SQTT_MARKER_IDENTIFIER_BARRIER_END = 0x4, + RGP_SQTT_MARKER_IDENTIFIER_USER_EVENT = 0x5, + RGP_SQTT_MARKER_IDENTIFIER_GENERAL_API = 0x6, + RGP_SQTT_MARKER_IDENTIFIER_SYNC = 0x7, + RGP_SQTT_MARKER_IDENTIFIER_PRESENT = 0x8, + RGP_SQTT_MARKER_IDENTIFIER_LAYOUT_TRANSITION = 0x9, + RGP_SQTT_MARKER_IDENTIFIER_RENDER_PASS = 0xA, + RGP_SQTT_MARKER_IDENTIFIER_RESERVED2 = 0xB, + RGP_SQTT_MARKER_IDENTIFIER_BIND_PIPELINE = 0xC, + RGP_SQTT_MARKER_IDENTIFIER_RESERVED4 = 0xD, + RGP_SQTT_MARKER_IDENTIFIER_RESERVED5 = 0xE, + RGP_SQTT_MARKER_IDENTIFIER_RESERVED6 = 0xF +}; + +/** + * RGP SQ thread-tracing marker for the start of a command buffer. (Table 2) + */ +struct rgp_sqtt_marker_cb_start { + union { + struct { + uint32_t identifier : 4; + uint32_t ext_dwords : 3; + uint32_t cb_id : 20; + uint32_t queue : 5; + }; + uint32_t dword01; + }; + union { + uint32_t device_id_low; + uint32_t dword02; + }; + union { + uint32_t device_id_high; + uint32_t dword03; + }; + union { + uint32_t queue_flags; + uint32_t dword04; + }; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_cb_start) == 16, + "rgp_sqtt_marker_cb_start doesn't match RGP spec"); + +/** + * + * RGP SQ thread-tracing marker for the end of a command buffer. (Table 3) + */ +struct rgp_sqtt_marker_cb_end { + union { + struct { + uint32_t identifier : 4; + uint32_t ext_dwords : 3; + uint32_t cb_id : 20; + uint32_t reserved : 5; + }; + uint32_t dword01; + }; + union { + uint32_t device_id_low; + uint32_t dword02; + }; + union { + uint32_t device_id_high; + uint32_t dword03; + }; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_cb_end) == 12, + "rgp_sqtt_marker_cb_end doesn't match RGP spec"); + +/** + * API types used in RGP SQ thread-tracing markers for the "General API" + * packet. + */ +enum rgp_sqtt_marker_general_api_type +{ + ApiCmdBindPipeline = 0, + ApiCmdBindDescriptorSets = 1, + ApiCmdBindIndexBuffer = 2, + ApiCmdBindVertexBuffers = 3, + ApiCmdDraw = 4, + ApiCmdDrawIndexed = 5, + ApiCmdDrawIndirect = 6, + ApiCmdDrawIndexedIndirect = 7, + ApiCmdDrawIndirectCountAMD = 8, + ApiCmdDrawIndexedIndirectCountAMD = 9, + ApiCmdDispatch = 10, + ApiCmdDispatchIndirect = 11, + ApiCmdCopyBuffer = 12, + ApiCmdCopyImage = 13, + ApiCmdBlitImage = 14, + ApiCmdCopyBufferToImage = 15, + ApiCmdCopyImageToBuffer = 16, + ApiCmdUpdateBuffer = 17, + ApiCmdFillBuffer = 18, + ApiCmdClearColorImage = 19, + ApiCmdClearDepthStencilImage = 20, + ApiCmdClearAttachments = 21, + ApiCmdResolveImage = 22, + ApiCmdWaitEvents = 23, + ApiCmdPipelineBarrier = 24, + ApiCmdBeginQuery = 25, + ApiCmdEndQuery = 26, + ApiCmdResetQueryPool = 27, + ApiCmdWriteTimestamp = 28, + ApiCmdCopyQueryPoolResults = 29, + ApiCmdPushConstants = 30, + ApiCmdBeginRenderPass = 31, + ApiCmdNextSubpass = 32, + ApiCmdEndRenderPass = 33, + ApiCmdExecuteCommands = 34, + ApiCmdSetViewport = 35, + ApiCmdSetScissor = 36, + ApiCmdSetLineWidth = 37, + ApiCmdSetDepthBias = 38, + ApiCmdSetBlendConstants = 39, + ApiCmdSetDepthBounds = 40, + ApiCmdSetStencilCompareMask = 41, + ApiCmdSetStencilWriteMask = 42, + ApiCmdSetStencilReference = 43, + ApiCmdDrawIndirectCount = 44, + ApiCmdDrawIndexedIndirectCount = 45, + ApiInvalid = 0xffffffff +}; + +/** + * RGP SQ thread-tracing marker for a "General API" instrumentation packet. + */ +struct rgp_sqtt_marker_general_api { + union { + struct { + uint32_t identifier : 4; + uint32_t ext_dwords : 3; + uint32_t api_type : 20; + uint32_t is_end : 1; + uint32_t reserved : 4; + }; + uint32_t dword01; + }; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_general_api) == 4, + "rgp_sqtt_marker_general_api doesn't match RGP spec"); + +/** + * API types used in RGP SQ thread-tracing markers (Table 16). + */ +enum rgp_sqtt_marker_event_type +{ + EventCmdDraw = 0, + EventCmdDrawIndexed = 1, + EventCmdDrawIndirect = 2, + EventCmdDrawIndexedIndirect = 3, + EventCmdDrawIndirectCountAMD = 4, + EventCmdDrawIndexedIndirectCountAMD = 5, + EventCmdDispatch = 6, + EventCmdDispatchIndirect = 7, + EventCmdCopyBuffer = 8, + EventCmdCopyImage = 9, + EventCmdBlitImage = 10, + EventCmdCopyBufferToImage = 11, + EventCmdCopyImageToBuffer = 12, + EventCmdUpdateBuffer = 13, + EventCmdFillBuffer = 14, + EventCmdClearColorImage = 15, + EventCmdClearDepthStencilImage = 16, + EventCmdClearAttachments = 17, + EventCmdResolveImage = 18, + EventCmdWaitEvents = 19, + EventCmdPipelineBarrier = 20, + EventCmdResetQueryPool = 21, + EventCmdCopyQueryPoolResults = 22, + EventRenderPassColorClear = 23, + EventRenderPassDepthStencilClear = 24, + EventRenderPassResolve = 25, + EventInternalUnknown = 26, + EventCmdDrawIndirectCount = 27, + EventCmdDrawIndexedIndirectCount = 28, + EventInvalid = 0xffffffff +}; + +/** + * "Event (Per-draw/dispatch)" RGP SQ thread-tracing marker. (Table 4) + */ +struct rgp_sqtt_marker_event { + union { + struct { + uint32_t identifier : 4; + uint32_t ext_dwords : 3; + uint32_t api_type : 24; + uint32_t has_thread_dims : 1; + }; + uint32_t dword01; + }; + union { + struct { + uint32_t cb_id : 20; + uint32_t vertex_offset_reg_idx : 4; + uint32_t instance_offset_reg_idx : 4; + uint32_t draw_index_reg_idx : 4; + }; + uint32_t dword02; + }; + union { + uint32_t cmd_id; + uint32_t dword03; + }; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_event) == 12, + "rgp_sqtt_marker_event doesn't match RGP spec"); + +/** + * Per-dispatch specific marker where workgroup dims are included. + */ +struct rgp_sqtt_marker_event_with_dims { + struct rgp_sqtt_marker_event event; + uint32_t thread_x; + uint32_t thread_y; + uint32_t thread_z; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_event_with_dims) == 24, + "rgp_sqtt_marker_event_with_dims doesn't match RGP spec"); + +/** + * "Barrier Start" RGP SQTT instrumentation marker (Table 5) + */ +struct rgp_sqtt_marker_barrier_start { + union { + struct { + uint32_t identifier : 4; + uint32_t ext_dwords : 3; + uint32_t cb_id : 20; + uint32_t reserved : 5; + }; + uint32_t dword01; + }; + union { + struct { + uint32_t driver_reason : 31; + uint32_t internal : 1; + }; + uint32_t dword02; + }; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_barrier_start) == 8, + "rgp_sqtt_marker_barrier_start doesn't match RGP spec"); + +/** + * "Barrier End" RGP SQTT instrumentation marker (Table 6) + */ +struct rgp_sqtt_marker_barrier_end { + union { + struct { + uint32_t identifier : 4; + uint32_t ext_dwords : 3; + uint32_t cb_id : 20; + uint32_t wait_on_eop_ts : 1; + uint32_t vs_partial_flush : 1; + uint32_t ps_partial_flush : 1; + uint32_t cs_partial_flush : 1; + uint32_t pfp_sync_me : 1; + }; + uint32_t dword01; + }; + union { + struct { + uint32_t sync_cp_dma : 1; + uint32_t inval_tcp : 1; + uint32_t inval_sqI : 1; + uint32_t inval_sqK : 1; + uint32_t flush_tcc : 1; + uint32_t inval_tcc : 1; + uint32_t flush_cb : 1; + uint32_t inval_cb : 1; + uint32_t flush_db : 1; + uint32_t inval_db : 1; + uint32_t num_layout_transitions : 16; + uint32_t inval_gl1 : 1; + uint32_t reserved : 5; + }; + uint32_t dword02; + }; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_barrier_end) == 8, + "rgp_sqtt_marker_barrier_end doesn't match RGP spec"); + +/** + * "Layout Transition" RGP SQTT instrumentation marker (Table 7) + */ +struct rgp_sqtt_marker_layout_transition { + union { + struct { + uint32_t identifier : 4; + uint32_t ext_dwords : 3; + uint32_t depth_stencil_expand : 1; + uint32_t htile_hiz_range_expand : 1; + uint32_t depth_stencil_resummarize : 1; + uint32_t dcc_decompress : 1; + uint32_t fmask_decompress : 1; + uint32_t fast_clear_eliminate : 1; + uint32_t fmask_color_expand : 1; + uint32_t init_mask_ram : 1; + uint32_t reserved1 : 17; + }; + uint32_t dword01; + }; + union { + struct { + uint32_t reserved2 : 32; + }; + uint32_t dword02; + }; +}; + +static_assert(sizeof(struct rgp_sqtt_marker_layout_transition) == 8, + "rgp_sqtt_marker_layout_transition doesn't match RGP spec"); + #endif diff --git a/src/amd/vulkan/layers/radv_sqtt_layer.c b/src/amd/vulkan/layers/radv_sqtt_layer.c index 33e2bb775fc..520f184d355 100644 --- a/src/amd/vulkan/layers/radv_sqtt_layer.c +++ b/src/amd/vulkan/layers/radv_sqtt_layer.c @@ -24,334 +24,7 @@ #include "radv_private.h" #include "ac_rgp.h" - -/** - * Identifiers for RGP SQ thread-tracing markers (Table 1) - */ -enum rgp_sqtt_marker_identifier { - RGP_SQTT_MARKER_IDENTIFIER_EVENT = 0x0, - RGP_SQTT_MARKER_IDENTIFIER_CB_START = 0x1, - RGP_SQTT_MARKER_IDENTIFIER_CB_END = 0x2, - RGP_SQTT_MARKER_IDENTIFIER_BARRIER_START = 0x3, - RGP_SQTT_MARKER_IDENTIFIER_BARRIER_END = 0x4, - RGP_SQTT_MARKER_IDENTIFIER_USER_EVENT = 0x5, - RGP_SQTT_MARKER_IDENTIFIER_GENERAL_API = 0x6, - RGP_SQTT_MARKER_IDENTIFIER_SYNC = 0x7, - RGP_SQTT_MARKER_IDENTIFIER_PRESENT = 0x8, - RGP_SQTT_MARKER_IDENTIFIER_LAYOUT_TRANSITION = 0x9, - RGP_SQTT_MARKER_IDENTIFIER_RENDER_PASS = 0xA, - RGP_SQTT_MARKER_IDENTIFIER_RESERVED2 = 0xB, - RGP_SQTT_MARKER_IDENTIFIER_BIND_PIPELINE = 0xC, - RGP_SQTT_MARKER_IDENTIFIER_RESERVED4 = 0xD, - RGP_SQTT_MARKER_IDENTIFIER_RESERVED5 = 0xE, - RGP_SQTT_MARKER_IDENTIFIER_RESERVED6 = 0xF -}; - -/** - * RGP SQ thread-tracing marker for the start of a command buffer. (Table 2) - */ -struct rgp_sqtt_marker_cb_start { - union { - struct { - uint32_t identifier : 4; - uint32_t ext_dwords : 3; - uint32_t cb_id : 20; - uint32_t queue : 5; - }; - uint32_t dword01; - }; - union { - uint32_t device_id_low; - uint32_t dword02; - }; - union { - uint32_t device_id_high; - uint32_t dword03; - }; - union { - uint32_t queue_flags; - uint32_t dword04; - }; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_cb_start) == 16, - "rgp_sqtt_marker_cb_start doesn't match RGP spec"); - -/** - * - * RGP SQ thread-tracing marker for the end of a command buffer. (Table 3) - */ -struct rgp_sqtt_marker_cb_end { - union { - struct { - uint32_t identifier : 4; - uint32_t ext_dwords : 3; - uint32_t cb_id : 20; - uint32_t reserved : 5; - }; - uint32_t dword01; - }; - union { - uint32_t device_id_low; - uint32_t dword02; - }; - union { - uint32_t device_id_high; - uint32_t dword03; - }; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_cb_end) == 12, - "rgp_sqtt_marker_cb_end doesn't match RGP spec"); - -/** - * API types used in RGP SQ thread-tracing markers for the "General API" - * packet. - */ -enum rgp_sqtt_marker_general_api_type { - ApiCmdBindPipeline = 0, - ApiCmdBindDescriptorSets = 1, - ApiCmdBindIndexBuffer = 2, - ApiCmdBindVertexBuffers = 3, - ApiCmdDraw = 4, - ApiCmdDrawIndexed = 5, - ApiCmdDrawIndirect = 6, - ApiCmdDrawIndexedIndirect = 7, - ApiCmdDrawIndirectCountAMD = 8, - ApiCmdDrawIndexedIndirectCountAMD = 9, - ApiCmdDispatch = 10, - ApiCmdDispatchIndirect = 11, - ApiCmdCopyBuffer = 12, - ApiCmdCopyImage = 13, - ApiCmdBlitImage = 14, - ApiCmdCopyBufferToImage = 15, - ApiCmdCopyImageToBuffer = 16, - ApiCmdUpdateBuffer = 17, - ApiCmdFillBuffer = 18, - ApiCmdClearColorImage = 19, - ApiCmdClearDepthStencilImage = 20, - ApiCmdClearAttachments = 21, - ApiCmdResolveImage = 22, - ApiCmdWaitEvents = 23, - ApiCmdPipelineBarrier = 24, - ApiCmdBeginQuery = 25, - ApiCmdEndQuery = 26, - ApiCmdResetQueryPool = 27, - ApiCmdWriteTimestamp = 28, - ApiCmdCopyQueryPoolResults = 29, - ApiCmdPushConstants = 30, - ApiCmdBeginRenderPass = 31, - ApiCmdNextSubpass = 32, - ApiCmdEndRenderPass = 33, - ApiCmdExecuteCommands = 34, - ApiCmdSetViewport = 35, - ApiCmdSetScissor = 36, - ApiCmdSetLineWidth = 37, - ApiCmdSetDepthBias = 38, - ApiCmdSetBlendConstants = 39, - ApiCmdSetDepthBounds = 40, - ApiCmdSetStencilCompareMask = 41, - ApiCmdSetStencilWriteMask = 42, - ApiCmdSetStencilReference = 43, - ApiCmdDrawIndirectCount = 44, - ApiCmdDrawIndexedIndirectCount = 45, - ApiInvalid = 0xffffffff -}; - -/** - * RGP SQ thread-tracing marker for a "General API" instrumentation packet. - */ -struct rgp_sqtt_marker_general_api { - union { - struct { - uint32_t identifier : 4; - uint32_t ext_dwords : 3; - uint32_t api_type : 20; - uint32_t is_end : 1; - uint32_t reserved : 4; - }; - uint32_t dword01; - }; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_general_api) == 4, - "rgp_sqtt_marker_general_api doesn't match RGP spec"); - -/** - * API types used in RGP SQ thread-tracing markers (Table 16). - */ -enum rgp_sqtt_marker_event_type { - EventCmdDraw = 0, - EventCmdDrawIndexed = 1, - EventCmdDrawIndirect = 2, - EventCmdDrawIndexedIndirect = 3, - EventCmdDrawIndirectCountAMD = 4, - EventCmdDrawIndexedIndirectCountAMD = 5, - EventCmdDispatch = 6, - EventCmdDispatchIndirect = 7, - EventCmdCopyBuffer = 8, - EventCmdCopyImage = 9, - EventCmdBlitImage = 10, - EventCmdCopyBufferToImage = 11, - EventCmdCopyImageToBuffer = 12, - EventCmdUpdateBuffer = 13, - EventCmdFillBuffer = 14, - EventCmdClearColorImage = 15, - EventCmdClearDepthStencilImage = 16, - EventCmdClearAttachments = 17, - EventCmdResolveImage = 18, - EventCmdWaitEvents = 19, - EventCmdPipelineBarrier = 20, - EventCmdResetQueryPool = 21, - EventCmdCopyQueryPoolResults = 22, - EventRenderPassColorClear = 23, - EventRenderPassDepthStencilClear = 24, - EventRenderPassResolve = 25, - EventInternalUnknown = 26, - EventCmdDrawIndirectCount = 27, - EventCmdDrawIndexedIndirectCount = 28, - EventInvalid = 0xffffffff -}; - -/** - * "Event (Per-draw/dispatch)" RGP SQ thread-tracing marker. (Table 4) - */ -struct rgp_sqtt_marker_event { - union { - struct { - uint32_t identifier : 4; - uint32_t ext_dwords : 3; - uint32_t api_type : 24; - uint32_t has_thread_dims : 1; - }; - uint32_t dword01; - }; - union { - struct { - uint32_t cb_id : 20; - uint32_t vertex_offset_reg_idx : 4; - uint32_t instance_offset_reg_idx : 4; - uint32_t draw_index_reg_idx : 4; - }; - uint32_t dword02; - }; - union { - uint32_t cmd_id; - uint32_t dword03; - }; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_event) == 12, - "rgp_sqtt_marker_event doesn't match RGP spec"); - -/** - * Per-dispatch specific marker where workgroup dims are included. - */ -struct rgp_sqtt_marker_event_with_dims { - struct rgp_sqtt_marker_event event; - uint32_t thread_x; - uint32_t thread_y; - uint32_t thread_z; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_event_with_dims) == 24, - "rgp_sqtt_marker_event_with_dims doesn't match RGP spec"); - -/** - * "Barrier Start" RGP SQTT instrumentation marker (Table 5) - */ -struct rgp_sqtt_marker_barrier_start { - union { - struct { - uint32_t identifier : 4; - uint32_t ext_dwords : 3; - uint32_t cb_id : 20; - uint32_t reserved : 5; - }; - uint32_t dword01; - }; - union { - struct { - uint32_t driver_reason : 31; - uint32_t internal : 1; - }; - uint32_t dword02; - }; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_barrier_start) == 8, - "rgp_sqtt_marker_barrier_start doesn't match RGP spec"); - -/** - * "Barrier End" RGP SQTT instrumentation marker (Table 6) - */ -struct rgp_sqtt_marker_barrier_end { - union { - struct { - uint32_t identifier : 4; - uint32_t ext_dwords : 3; - uint32_t cb_id : 20; - uint32_t wait_on_eop_ts : 1; - uint32_t vs_partial_flush : 1; - uint32_t ps_partial_flush : 1; - uint32_t cs_partial_flush : 1; - uint32_t pfp_sync_me : 1; - }; - uint32_t dword01; - }; - union { - struct { - uint32_t sync_cp_dma : 1; - uint32_t inval_tcp : 1; - uint32_t inval_sqI : 1; - uint32_t inval_sqK : 1; - uint32_t flush_tcc : 1; - uint32_t inval_tcc : 1; - uint32_t flush_cb : 1; - uint32_t inval_cb : 1; - uint32_t flush_db : 1; - uint32_t inval_db : 1; - uint32_t num_layout_transitions : 16; - uint32_t inval_gl1 : 1; - uint32_t reserved : 5; - }; - uint32_t dword02; - }; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_barrier_end) == 8, - "rgp_sqtt_marker_barrier_end doesn't match RGP spec"); - -/** - * "Layout Transition" RGP SQTT instrumentation marker (Table 7) - */ -struct rgp_sqtt_marker_layout_transition { - union { - struct { - uint32_t identifier : 4; - uint32_t ext_dwords : 3; - uint32_t depth_stencil_expand : 1; - uint32_t htile_hiz_range_expand : 1; - uint32_t depth_stencil_resummarize : 1; - uint32_t dcc_decompress : 1; - uint32_t fmask_decompress : 1; - uint32_t fast_clear_eliminate : 1; - uint32_t fmask_color_expand : 1; - uint32_t init_mask_ram : 1; - uint32_t reserved1 : 17; - }; - uint32_t dword01; - }; - union { - struct { - uint32_t reserved2 : 32; - }; - uint32_t dword02; - }; -}; - -static_assert(sizeof(struct rgp_sqtt_marker_layout_transition) == 8, - "rgp_sqtt_marker_layout_transition doesn't match RGP spec"); +#include "ac_sqtt.h" static void radv_write_begin_general_api_marker(struct radv_cmd_buffer *cmd_buffer,