[Mesa-dev] [PATCH] anv/cmd_buffer: Reuse gen8 Cmd{Set, Reset}Event on gen7

Jason Ekstrand jason at jlekstrand.net
Tue Jun 11 15:58:51 UTC 2019


Feel free to call it a bugfix and CC stable if you'd like.

On Tue, Jun 11, 2019 at 10:54 AM Jason Ekstrand <jason at jlekstrand.net>
wrote:

>
>
> On Mon, Jun 10, 2019 at 6:21 AM Ville Syrjala <
> ville.syrjala at linux.intel.com> wrote:
>
>> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>>
>> Modern DXVK requires event support [1], but looks like it only
>> uses vkCmdSetEvent() + vkGetEventStatus(). So we can just
>> borrow the relevant code from gen8, leaving CmdWaitEvents still
>> unimplemented.
>>
>> [1]
>> https://github.com/doitsujin/dxvk/commit/8c3900c533d83d12c970b905183d17a1d3e8df1f
>>
>> v2: Also move CmdWaitEvents into genX_cmd_buffer.c (Jason)
>>
>> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
>> ---
>>  src/intel/vulkan/gen7_cmd_buffer.c |  38 ----------
>>  src/intel/vulkan/gen8_cmd_buffer.c | 102 ---------------------------
>>  src/intel/vulkan/genX_cmd_buffer.c | 107 +++++++++++++++++++++++++++++
>>  3 files changed, 107 insertions(+), 140 deletions(-)
>>
>> diff --git a/src/intel/vulkan/gen7_cmd_buffer.c
>> b/src/intel/vulkan/gen7_cmd_buffer.c
>> index 380283bdd563..115d12b35362 100644
>> --- a/src/intel/vulkan/gen7_cmd_buffer.c
>> +++ b/src/intel/vulkan/gen7_cmd_buffer.c
>> @@ -286,41 +286,3 @@ genX(cmd_buffer_enable_pma_fix)(struct
>> anv_cmd_buffer *cmd_buffer,
>>  {
>>     /* The NP PMA fix doesn't exist on gen7 */
>>  }
>> -
>> -void genX(CmdSetEvent)(
>> -    VkCommandBuffer                             commandBuffer,
>> -    VkEvent                                     event,
>> -    VkPipelineStageFlags                        stageMask)
>> -{
>> -   anv_finishme("Implement events on gen7");
>> -}
>> -
>> -void genX(CmdResetEvent)(
>> -    VkCommandBuffer                             commandBuffer,
>> -    VkEvent                                     event,
>> -    VkPipelineStageFlags                        stageMask)
>> -{
>> -   anv_finishme("Implement events on gen7");
>> -}
>> -
>> -void genX(CmdWaitEvents)(
>> -    VkCommandBuffer                             commandBuffer,
>> -    uint32_t                                    eventCount,
>> -    const VkEvent*                              pEvents,
>> -    VkPipelineStageFlags                        srcStageMask,
>> -    VkPipelineStageFlags                        destStageMask,
>> -    uint32_t                                    memoryBarrierCount,
>> -    const VkMemoryBarrier*                      pMemoryBarriers,
>> -    uint32_t                                    bufferMemoryBarrierCount,
>> -    const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
>> -    uint32_t                                    imageMemoryBarrierCount,
>> -    const VkImageMemoryBarrier*                 pImageMemoryBarriers)
>> -{
>> -   anv_finishme("Implement events on gen7");
>> -
>> -   genX(CmdPipelineBarrier)(commandBuffer, srcStageMask, destStageMask,
>> -                            false, /* byRegion */
>> -                            memoryBarrierCount, pMemoryBarriers,
>> -                            bufferMemoryBarrierCount,
>> pBufferMemoryBarriers,
>> -                            imageMemoryBarrierCount,
>> pImageMemoryBarriers);
>> -}
>> diff --git a/src/intel/vulkan/gen8_cmd_buffer.c
>> b/src/intel/vulkan/gen8_cmd_buffer.c
>> index 6568d2c75113..2e6d9de9f4a8 100644
>> --- a/src/intel/vulkan/gen8_cmd_buffer.c
>> +++ b/src/intel/vulkan/gen8_cmd_buffer.c
>> @@ -565,105 +565,3 @@ void genX(CmdBindIndexBuffer)(
>>
>>     cmd_buffer->state.gfx.dirty |= ANV_CMD_DIRTY_INDEX_BUFFER;
>>  }
>> -
>> -/* Set of stage bits for which are pipelined, i.e. they get queued by the
>> - * command streamer for later execution.
>> - */
>> -#define ANV_PIPELINE_STAGE_PIPELINED_BITS \
>> -   (VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | \
>> -    VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | \
>> -    VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT | \
>> -    VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT | \
>> -    VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | \
>> -    VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | \
>> -    VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | \
>> -    VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | \
>> -    VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | \
>> -    VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | \
>> -    VK_PIPELINE_STAGE_TRANSFER_BIT | \
>> -    VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT | \
>> -    VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT | \
>> -    VK_PIPELINE_STAGE_ALL_COMMANDS_BIT)
>> -
>> -void genX(CmdSetEvent)(
>> -    VkCommandBuffer                             commandBuffer,
>> -    VkEvent                                     _event,
>> -    VkPipelineStageFlags                        stageMask)
>> -{
>> -   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
>> -   ANV_FROM_HANDLE(anv_event, event, _event);
>> -
>> -   anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
>> -      if (stageMask & ANV_PIPELINE_STAGE_PIPELINED_BITS) {
>> -         pc.StallAtPixelScoreboard = true;
>> -         pc.CommandStreamerStallEnable = true;
>> -      }
>> -
>> -      pc.DestinationAddressType  = DAT_PPGTT,
>> -      pc.PostSyncOperation       = WriteImmediateData,
>> -      pc.Address = (struct anv_address) {
>> -         cmd_buffer->device->dynamic_state_pool.block_pool.bo,
>> -         event->state.offset
>> -      };
>> -      pc.ImmediateData           = VK_EVENT_SET;
>> -   }
>> -}
>> -
>> -void genX(CmdResetEvent)(
>> -    VkCommandBuffer                             commandBuffer,
>> -    VkEvent                                     _event,
>> -    VkPipelineStageFlags                        stageMask)
>> -{
>> -   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
>> -   ANV_FROM_HANDLE(anv_event, event, _event);
>> -
>> -   anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
>> -      if (stageMask & ANV_PIPELINE_STAGE_PIPELINED_BITS) {
>> -         pc.StallAtPixelScoreboard = true;
>> -         pc.CommandStreamerStallEnable = true;
>> -      }
>> -
>> -      pc.DestinationAddressType  = DAT_PPGTT;
>> -      pc.PostSyncOperation       = WriteImmediateData;
>> -      pc.Address = (struct anv_address) {
>> -         cmd_buffer->device->dynamic_state_pool.block_pool.bo,
>> -         event->state.offset
>> -      };
>> -      pc.ImmediateData           = VK_EVENT_RESET;
>> -   }
>> -}
>> -
>> -void genX(CmdWaitEvents)(
>> -    VkCommandBuffer                             commandBuffer,
>> -    uint32_t                                    eventCount,
>> -    const VkEvent*                              pEvents,
>> -    VkPipelineStageFlags                        srcStageMask,
>> -    VkPipelineStageFlags                        destStageMask,
>> -    uint32_t                                    memoryBarrierCount,
>> -    const VkMemoryBarrier*                      pMemoryBarriers,
>> -    uint32_t                                    bufferMemoryBarrierCount,
>> -    const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
>> -    uint32_t                                    imageMemoryBarrierCount,
>> -    const VkImageMemoryBarrier*                 pImageMemoryBarriers)
>> -{
>> -   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
>> -   for (uint32_t i = 0; i < eventCount; i++) {
>> -      ANV_FROM_HANDLE(anv_event, event, pEvents[i]);
>> -
>> -      anv_batch_emit(&cmd_buffer->batch, GENX(MI_SEMAPHORE_WAIT), sem) {
>> -         sem.WaitMode            = PollingMode,
>> -         sem.CompareOperation    = COMPARE_SAD_EQUAL_SDD,
>> -         sem.SemaphoreDataDword  = VK_EVENT_SET,
>> -         sem.SemaphoreAddress = (struct anv_address) {
>> -            cmd_buffer->device->dynamic_state_pool.block_pool.bo,
>> -            event->state.offset
>> -         };
>> -      }
>> -   }
>> -
>> -   genX(CmdPipelineBarrier)(commandBuffer, srcStageMask, destStageMask,
>> -                            false, /* byRegion */
>> -                            memoryBarrierCount, pMemoryBarriers,
>> -                            bufferMemoryBarrierCount,
>> pBufferMemoryBarriers,
>> -                            imageMemoryBarrierCount,
>> pImageMemoryBarriers);
>> -}
>> diff --git a/src/intel/vulkan/genX_cmd_buffer.c
>> b/src/intel/vulkan/genX_cmd_buffer.c
>> index f171d02dab72..c57c02a08da7 100644
>> --- a/src/intel/vulkan/genX_cmd_buffer.c
>> +++ b/src/intel/vulkan/genX_cmd_buffer.c
>> @@ -4729,3 +4729,110 @@ void genX(CmdEndConditionalRenderingEXT)(
>>     cmd_state->conditional_render_enabled = false;
>>  }
>>  #endif
>> +
>> +/* Set of stage bits for which are pipelined, i.e. they get queued by the
>> + * command streamer for later execution.
>> + */
>> +#define ANV_PIPELINE_STAGE_PIPELINED_BITS \
>> +   (VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | \
>> +    VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | \
>> +    VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT | \
>> +    VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT | \
>> +    VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | \
>> +    VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | \
>> +    VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | \
>> +    VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | \
>> +    VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | \
>> +    VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | \
>> +    VK_PIPELINE_STAGE_TRANSFER_BIT | \
>> +    VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT | \
>> +    VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT | \
>> +    VK_PIPELINE_STAGE_ALL_COMMANDS_BIT)
>> +
>> +void genX(CmdSetEvent)(
>> +    VkCommandBuffer                             commandBuffer,
>> +    VkEvent                                     _event,
>> +    VkPipelineStageFlags                        stageMask)
>> +{
>> +   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
>> +   ANV_FROM_HANDLE(anv_event, event, _event);
>> +
>> +   anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
>> +      if (stageMask & ANV_PIPELINE_STAGE_PIPELINED_BITS) {
>> +         pc.StallAtPixelScoreboard = true;
>> +         pc.CommandStreamerStallEnable = true;
>> +      }
>> +
>> +      pc.DestinationAddressType  = DAT_PPGTT,
>> +      pc.PostSyncOperation       = WriteImmediateData,
>> +      pc.Address = (struct anv_address) {
>> +         cmd_buffer->device->dynamic_state_pool.block_pool.bo,
>> +         event->state.offset
>> +      };
>> +      pc.ImmediateData           = VK_EVENT_SET;
>> +   }
>> +}
>> +
>> +void genX(CmdResetEvent)(
>> +    VkCommandBuffer                             commandBuffer,
>> +    VkEvent                                     _event,
>> +    VkPipelineStageFlags                        stageMask)
>> +{
>> +   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
>> +   ANV_FROM_HANDLE(anv_event, event, _event);
>> +
>> +   anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), pc) {
>> +      if (stageMask & ANV_PIPELINE_STAGE_PIPELINED_BITS) {
>> +         pc.StallAtPixelScoreboard = true;
>> +         pc.CommandStreamerStallEnable = true;
>> +      }
>> +
>> +      pc.DestinationAddressType  = DAT_PPGTT;
>> +      pc.PostSyncOperation       = WriteImmediateData;
>> +      pc.Address = (struct anv_address) {
>> +         cmd_buffer->device->dynamic_state_pool.block_pool.bo,
>> +         event->state.offset
>> +      };
>> +      pc.ImmediateData           = VK_EVENT_RESET;
>> +   }
>> +}
>> +
>> +void genX(CmdWaitEvents)(
>> +    VkCommandBuffer                             commandBuffer,
>> +    uint32_t                                    eventCount,
>> +    const VkEvent*                              pEvents,
>> +    VkPipelineStageFlags                        srcStageMask,
>> +    VkPipelineStageFlags                        destStageMask,
>> +    uint32_t                                    memoryBarrierCount,
>> +    const VkMemoryBarrier*                      pMemoryBarriers,
>> +    uint32_t                                    bufferMemoryBarrierCount,
>> +    const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
>> +    uint32_t                                    imageMemoryBarrierCount,
>> +    const VkImageMemoryBarrier*                 pImageMemoryBarriers)
>> +{
>> +#if GEN_GEN >= 8
>> +   ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
>> +
>> +   for (uint32_t i = 0; i < eventCount; i++) {
>> +      ANV_FROM_HANDLE(anv_event, event, pEvents[i]);
>> +
>> +      anv_batch_emit(&cmd_buffer->batch, GENX(MI_SEMAPHORE_WAIT), sem) {
>> +         sem.WaitMode            = PollingMode,
>> +         sem.CompareOperation    = COMPARE_SAD_EQUAL_SDD,
>> +         sem.SemaphoreDataDword  = VK_EVENT_SET,
>> +         sem.SemaphoreAddress = (struct anv_address) {
>> +            cmd_buffer->device->dynamic_state_pool.block_pool.bo,
>> +            event->state.offset
>> +         };
>> +      }
>> +   }
>> +#else
>> +   anv_finishme("Implement events on gen7");
>>
>
> Maybe change this to "implement event GPU waits on host signals on gen7"
> to be more specific.  Assuming you did your copy+paste correctly,
>
> Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
>
>
>> +#endif
>> +
>> +   genX(CmdPipelineBarrier)(commandBuffer, srcStageMask, destStageMask,
>> +                            false, /* byRegion */
>> +                            memoryBarrierCount, pMemoryBarriers,
>> +                            bufferMemoryBarrierCount,
>> pBufferMemoryBarriers,
>> +                            imageMemoryBarrierCount,
>> pImageMemoryBarriers);
>> +}
>> --
>> 2.21.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190611/217b4d12/attachment-0001.html>


More information about the mesa-dev mailing list