diff options
author | Samuel Pitoiset <[email protected]> | 2020-02-26 14:05:15 +0100 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2020-03-10 09:57:59 +0100 |
commit | 31ecf0b17dc0dfcc70eb96295e52339e9f176c8b (patch) | |
tree | 27566ee99a1a3a9729817bc0725f8e49570c8243 /src/amd/vulkan | |
parent | be700775dc2e97a414d14bc764cd2eb72a639306 (diff) |
radv: initial implementation of the driver internal layer SQTT
This layer is used to emit SQTT user markers to command buffers. It
currently only emits API markers but it will consolidated soon with
barrier markers and more.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4031>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r-- | src/amd/vulkan/Makefile.sources | 4 | ||||
-rw-r--r-- | src/amd/vulkan/layers/radv_sqtt_layer.c | 342 | ||||
-rw-r--r-- | src/amd/vulkan/meson.build | 1 |
3 files changed, 347 insertions, 0 deletions
diff --git a/src/amd/vulkan/Makefile.sources b/src/amd/vulkan/Makefile.sources index 11bd6e4aa67..4035ca52dee 100644 --- a/src/amd/vulkan/Makefile.sources +++ b/src/amd/vulkan/Makefile.sources @@ -39,6 +39,9 @@ RADV_WS_NULL_FILES := \ winsys/null/radv_null_winsys.h \ winsys/null/radv_null_winsys_public.h +RADV_LAYER_SQTT_FILES := \ + layers/radv_sqtt_layer.c + VULKAN_FILES := \ radv_cmd_buffer.c \ radv_cs.h \ @@ -85,6 +88,7 @@ VULKAN_FILES := \ radv_wsi.c \ si_cmd_buffer.c \ vk_format.h \ + $(RADV_LAYER_SQTT_FILES) \ $(RADV_WS_AMDGPU_FILES) \ $(RADV_WS_NULL_FILES) diff --git a/src/amd/vulkan/layers/radv_sqtt_layer.c b/src/amd/vulkan/layers/radv_sqtt_layer.c new file mode 100644 index 00000000000..18131cc0efb --- /dev/null +++ b/src/amd/vulkan/layers/radv_sqtt_layer.c @@ -0,0 +1,342 @@ +/* + * Copyright © 2020 Valve Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "radv_private.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 +}; + +/** + * 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, + ApiCmdDrawIndirectCountKHR = 44, + ApiCmdDrawIndexedIndirectCountKHR = 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"); + +static void +radv_write_begin_general_api_marker(struct radv_cmd_buffer *cmd_buffer, + enum rgp_sqtt_marker_general_api_type api_type) +{ + struct rgp_sqtt_marker_general_api marker = {}; + struct radeon_cmdbuf *cs = cmd_buffer->cs; + + marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_GENERAL_API; + marker.api_type = api_type; + + radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4); +} + +static void +radv_write_end_general_api_marker(struct radv_cmd_buffer *cmd_buffer, + enum rgp_sqtt_marker_general_api_type api_type) +{ + struct rgp_sqtt_marker_general_api marker = {}; + struct radeon_cmdbuf *cs = cmd_buffer->cs; + + marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_GENERAL_API; + marker.api_type = api_type; + marker.is_end = 1; + + radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4); +} + +#define API_MARKER(cmd_name, args...) \ + RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); \ + radv_write_begin_general_api_marker(cmd_buffer, ApiCmd##cmd_name); \ + radv_Cmd##cmd_name(args); \ + radv_write_end_general_api_marker(cmd_buffer, ApiCmd##cmd_name); + +void sqtt_CmdBindPipeline( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipeline pipeline) +{ + API_MARKER(BindPipeline, commandBuffer, pipelineBindPoint, pipeline); +} + +void sqtt_CmdBindDescriptorSets( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t firstSet, + uint32_t descriptorSetCount, + const VkDescriptorSet* pDescriptorSets, + uint32_t dynamicOffsetCount, + const uint32_t* pDynamicOffsets) +{ + API_MARKER(BindDescriptorSets, commandBuffer, pipelineBindPoint, + layout, firstSet, descriptorSetCount, + pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); +} + +void sqtt_CmdBindIndexBuffer( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkIndexType indexType) +{ + API_MARKER(BindIndexBuffer, commandBuffer, buffer, offset, indexType); +} + +void sqtt_CmdBindVertexBuffers( + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBuffer* pBuffers, + const VkDeviceSize* pOffsets) +{ + API_MARKER(BindVertexBuffers, commandBuffer, firstBinding, bindingCount, + pBuffers, pOffsets); +} + +void sqtt_CmdBeginQuery( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query, + VkQueryControlFlags flags) +{ + API_MARKER(BeginQuery, commandBuffer, queryPool, query, flags); +} + +void sqtt_CmdEndQuery( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query) +{ + API_MARKER(EndQuery, commandBuffer, queryPool, query); +} + +void sqtt_CmdWriteTimestamp( + VkCommandBuffer commandBuffer, + VkPipelineStageFlagBits pipelineStage, + VkQueryPool queryPool, + uint32_t flags) +{ + API_MARKER(WriteTimestamp, commandBuffer, pipelineStage, queryPool, flags); +} + +void sqtt_CmdPushConstants( + VkCommandBuffer commandBuffer, + VkPipelineLayout layout, + VkShaderStageFlags stageFlags, + uint32_t offset, + uint32_t size, + const void* pValues) +{ + API_MARKER(PushConstants, commandBuffer, layout, stageFlags, offset, + size, pValues); +} + +void sqtt_CmdBeginRenderPass( + VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + VkSubpassContents contents) +{ + API_MARKER(BeginRenderPass, commandBuffer, pRenderPassBegin, contents); +} + +void sqtt_CmdNextSubpass( + VkCommandBuffer commandBuffer, + VkSubpassContents contents) +{ + API_MARKER(NextSubpass, commandBuffer, contents); +} + +void sqtt_CmdEndRenderPass( + VkCommandBuffer commandBuffer) +{ + API_MARKER(EndRenderPass, commandBuffer); +} + +void sqtt_CmdExecuteCommands( + VkCommandBuffer commandBuffer, + uint32_t commandBufferCount, + const VkCommandBuffer* pCmdBuffers) +{ + API_MARKER(ExecuteCommands, commandBuffer, commandBufferCount, + pCmdBuffers); +} + +void sqtt_CmdSetViewport( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewport* pViewports) +{ + API_MARKER(SetViewport, commandBuffer, firstViewport, viewportCount, + pViewports); +} + +void sqtt_CmdSetScissor( + VkCommandBuffer commandBuffer, + uint32_t firstScissor, + uint32_t scissorCount, + const VkRect2D* pScissors) +{ + API_MARKER(SetScissor, commandBuffer, firstScissor, scissorCount, + pScissors); +} + +void sqtt_CmdSetLineWidth( + VkCommandBuffer commandBuffer, + float lineWidth) +{ + API_MARKER(SetLineWidth, commandBuffer, lineWidth); +} + +void sqtt_CmdSetDepthBias( + VkCommandBuffer commandBuffer, + float depthBiasConstantFactor, + float depthBiasClamp, + float depthBiasSlopeFactor) +{ + API_MARKER(SetDepthBias, commandBuffer, depthBiasConstantFactor, + depthBiasClamp, depthBiasSlopeFactor); +} + +void sqtt_CmdSetBlendConstants( + VkCommandBuffer commandBuffer, + const float blendConstants[4]) +{ + API_MARKER(SetBlendConstants, commandBuffer, blendConstants); +} + +void sqtt_CmdSetDepthBounds( + VkCommandBuffer commandBuffer, + float minDepthBounds, + float maxDepthBounds) +{ + API_MARKER(SetDepthBounds, commandBuffer, minDepthBounds, + maxDepthBounds); +} + +void sqtt_CmdSetStencilCompareMask( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t compareMask) +{ + API_MARKER(SetStencilCompareMask, commandBuffer, faceMask, compareMask); +} + +void sqtt_CmdSetStencilWriteMask( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t writeMask) +{ + API_MARKER(SetStencilWriteMask, commandBuffer, faceMask, writeMask); +} + +void sqtt_CmdSetStencilReference( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t reference) +{ + API_MARKER(SetStencilReference, commandBuffer, faceMask, reference); +} + +#undef API_MARKER diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build index 6f89b433513..2a3df6803d5 100644 --- a/src/amd/vulkan/meson.build +++ b/src/amd/vulkan/meson.build @@ -58,6 +58,7 @@ radv_gfx10_format_table_h = custom_target( ) libradv_files = files( + 'layers/radv_sqtt_layer.c', 'winsys/amdgpu/radv_amdgpu_bo.c', 'winsys/amdgpu/radv_amdgpu_bo.h', 'winsys/amdgpu/radv_amdgpu_cs.c', |