vk: Make barriers more precise (rev. 133)
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 14 Jul 2015 21:50:35 +0000 (14:50 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 14 Jul 2015 21:50:35 +0000 (14:50 -0700)
include/vulkan/vulkan.h
src/vulkan/device.c

index a2410d1ff5cde7ebe8e2678c8e6c9be49615a15e..2ace82ed3a043731a4bfb4bb9410a6416b4d2e0e 100644 (file)
@@ -813,15 +813,6 @@ typedef enum {
     VK_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF
 } VkPipelineBindPoint;
 
-typedef enum {
-    VK_WAIT_EVENT_TOP_OF_PIPE = 1,
-    VK_WAIT_EVENT_BEFORE_RASTERIZATION = 2,
-    VK_WAIT_EVENT_BEGIN_RANGE = VK_WAIT_EVENT_TOP_OF_PIPE,
-    VK_WAIT_EVENT_END_RANGE = VK_WAIT_EVENT_BEFORE_RASTERIZATION,
-    VK_WAIT_EVENT_NUM = (VK_WAIT_EVENT_BEFORE_RASTERIZATION - VK_WAIT_EVENT_TOP_OF_PIPE + 1),
-    VK_WAIT_EVENT_MAX_ENUM = 0x7FFFFFFF
-} VkWaitEvent;
-
 typedef enum {
     VK_CMD_BUFFER_LEVEL_PRIMARY = 0,
     VK_CMD_BUFFER_LEVEL_SECONDARY = 1,
@@ -840,22 +831,6 @@ typedef enum {
     VK_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF
 } VkIndexType;
 
-typedef enum {
-    VK_PIPE_EVENT_TOP_OF_PIPE = 0,
-    VK_PIPE_EVENT_VERTEX_PROCESSING_COMPLETE = 1,
-    VK_PIPE_EVENT_LOCAL_FRAGMENT_PROCESSING_COMPLETE = 2,
-    VK_PIPE_EVENT_FRAGMENT_PROCESSING_COMPLETE = 3,
-    VK_PIPE_EVENT_GRAPHICS_PIPELINE_COMPLETE = 4,
-    VK_PIPE_EVENT_COMPUTE_PIPELINE_COMPLETE = 5,
-    VK_PIPE_EVENT_TRANSFER_COMPLETE = 6,
-    VK_PIPE_EVENT_COMMANDS_COMPLETE = 7,
-    VK_PIPE_EVENT_CPU_SIGNAL = 8,
-    VK_PIPE_EVENT_BEGIN_RANGE = VK_PIPE_EVENT_TOP_OF_PIPE,
-    VK_PIPE_EVENT_END_RANGE = VK_PIPE_EVENT_CPU_SIGNAL,
-    VK_PIPE_EVENT_NUM = (VK_PIPE_EVENT_CPU_SIGNAL - VK_PIPE_EVENT_TOP_OF_PIPE + 1),
-    VK_PIPE_EVENT_MAX_ENUM = 0x7FFFFFFF
-} VkPipeEvent;
-
 typedef enum {
     VK_TIMESTAMP_TYPE_TOP = 0,
     VK_TIMESTAMP_TYPE_BOTTOM = 1,
@@ -1029,17 +1004,25 @@ typedef enum {
 typedef VkFlags VkSubpassDescriptionFlags;
 
 typedef enum {
-    VK_PIPE_EVENT_TOP_OF_PIPE_BIT = 0x00000001,
-    VK_PIPE_EVENT_VERTEX_PROCESSING_COMPLETE_BIT = 0x00000002,
-    VK_PIPE_EVENT_LOCAL_FRAGMENT_PROCESSING_COMPLETE_BIT = 0x00000004,
-    VK_PIPE_EVENT_FRAGMENT_PROCESSING_COMPLETE_BIT = 0x00000008,
-    VK_PIPE_EVENT_GRAPHICS_PIPELINE_COMPLETE_BIT = 0x00000010,
-    VK_PIPE_EVENT_COMPUTE_PIPELINE_COMPLETE_BIT = 0x00000020,
-    VK_PIPE_EVENT_TRANSFER_COMPLETE_BIT = 0x00000040,
-    VK_PIPE_EVENT_COMMANDS_COMPLETE_BIT = 0x00000080,
-    VK_PIPE_EVENT_CPU_SIGNAL_BIT = 0x00000100,
-} VkPipeEventFlagBits;
-typedef VkFlags VkPipeEventFlags;
+    VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001,
+    VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002,
+    VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004,
+    VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 0x00000008,
+    VK_PIPELINE_STAGE_TESS_CONTROL_SHADER_BIT = 0x00000010,
+    VK_PIPELINE_STAGE_TESS_EVALUATION_SHADER_BIT = 0x00000020,
+    VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 0x00000040,
+    VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 0x00000080,
+    VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 0x00000100,
+    VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 0x00000200,
+    VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400,
+    VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800,
+    VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000,
+    VK_PIPELINE_STAGE_TRANSITION_BIT = 0x00002000,
+    VK_PIPELINE_STAGE_HOST_BIT = 0x00004000,
+    VK_PIPELINE_STAGE_ALL_GRAPHICS = 0x000007FF,
+    VK_PIPELINE_STAGE_ALL_GPU_COMMANDS = 0x00003FFF,
+} VkPipelineStageFlagBits;
+typedef VkFlags VkPipelineStageFlags;
 
 typedef enum {
     VK_MEMORY_OUTPUT_HOST_WRITE_BIT = 0x00000001,
@@ -1842,10 +1825,11 @@ typedef struct {
     const void*                                 pNext;
     uint32_t                                    srcSubpass;
     uint32_t                                    dstSubpass;
-    VkWaitEvent                                 waitEvent;
-    VkPipeEventFlags                            pipeEventMask;
+    VkPipelineStageFlags                        srcStageMask;
+    VkPipelineStageFlags                        destStageMask;
     VkMemoryOutputFlags                         outputMask;
     VkMemoryInputFlags                          inputMask;
+    VkBool32                                    byRegion;
 } VkSubpassDependency;
 
 typedef struct {
@@ -2132,10 +2116,10 @@ typedef void (VKAPI *PFN_vkCmdClearDepthStencilImage)(VkCmdBuffer cmdBuffer, VkI
 typedef void (VKAPI *PFN_vkCmdClearColorAttachment)(VkCmdBuffer cmdBuffer, uint32_t colorAttachment, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rectCount, const VkRect3D* pRects);
 typedef void (VKAPI *PFN_vkCmdClearDepthStencilAttachment)(VkCmdBuffer cmdBuffer, VkImageAspectFlags imageAspectMask, VkImageLayout imageLayout, float depth, uint32_t stencil, uint32_t rectCount, const VkRect3D* pRects);
 typedef void (VKAPI *PFN_vkCmdResolveImage)(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions);
-typedef void (VKAPI *PFN_vkCmdSetEvent)(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent);
-typedef void (VKAPI *PFN_vkCmdResetEvent)(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent);
-typedef void (VKAPI *PFN_vkCmdWaitEvents)(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, uint32_t eventCount, const VkEvent* pEvents, VkPipeEventFlags pipeEventMask, uint32_t memBarrierCount, const void* const* ppMemBarriers);
-typedef void (VKAPI *PFN_vkCmdPipelineBarrier)(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, VkPipeEventFlags pipeEventMask, uint32_t memBarrierCount, const void* const* ppMemBarriers);
+typedef void (VKAPI *PFN_vkCmdSetEvent)(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask);
+typedef void (VKAPI *PFN_vkCmdResetEvent)(VkCmdBuffer cmdBuffer, VkEvent event, VkPipelineStageFlags stageMask);
+typedef void (VKAPI *PFN_vkCmdWaitEvents)(VkCmdBuffer cmdBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, uint32_t memBarrierCount, const void* const* ppMemBarriers);
+typedef void (VKAPI *PFN_vkCmdPipelineBarrier)(VkCmdBuffer cmdBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, VkBool32 byRegion, uint32_t memBarrierCount, const void* const* ppMemBarriers);
 typedef void (VKAPI *PFN_vkCmdBeginQuery)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkQueryControlFlags flags);
 typedef void (VKAPI *PFN_vkCmdEndQuery)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot);
 typedef void (VKAPI *PFN_vkCmdResetQueryPool)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount);
@@ -2825,26 +2809,27 @@ void VKAPI vkCmdResolveImage(
 void VKAPI vkCmdSetEvent(
     VkCmdBuffer                                 cmdBuffer,
     VkEvent                                     event,
-    VkPipeEvent                                 pipeEvent);
+    VkPipelineStageFlags                        stageMask);
 
 void VKAPI vkCmdResetEvent(
     VkCmdBuffer                                 cmdBuffer,
     VkEvent                                     event,
-    VkPipeEvent                                 pipeEvent);
+    VkPipelineStageFlags                        stageMask);
 
 void VKAPI vkCmdWaitEvents(
     VkCmdBuffer                                 cmdBuffer,
-    VkWaitEvent                                 waitEvent,
     uint32_t                                    eventCount,
     const VkEvent*                              pEvents,
-    VkPipeEventFlags                            pipeEventMask,
+    VkPipelineStageFlags                        srcStageMask,
+    VkPipelineStageFlags                        destStageMask,
     uint32_t                                    memBarrierCount,
     const void* const*                          ppMemBarriers);
 
 void VKAPI vkCmdPipelineBarrier(
     VkCmdBuffer                                 cmdBuffer,
-    VkWaitEvent                                 waitEvent,
-    VkPipeEventFlags                            pipeEventMask,
+    VkPipelineStageFlags                        srcStageMask,
+    VkPipelineStageFlags                        destStageMask,
+    VkBool32                                    byRegion,
     uint32_t                                    memBarrierCount,
     const void* const*                          ppMemBarriers);
 
index d29e35ba20c44692672088783b948cc2090238c4..2aa9aee9e506497ccee2e57891d199b3d40c45c2 100644 (file)
@@ -3702,7 +3702,7 @@ void anv_CmdDispatchIndirect(
 void anv_CmdSetEvent(
     VkCmdBuffer                                 cmdBuffer,
     VkEvent                                     event,
-    VkPipeEvent                                 pipeEvent)
+    VkPipelineStageFlags                        stageMask)
 {
    stub();
 }
@@ -3710,17 +3710,17 @@ void anv_CmdSetEvent(
 void anv_CmdResetEvent(
     VkCmdBuffer                                 cmdBuffer,
     VkEvent                                     event,
-    VkPipeEvent                                 pipeEvent)
+    VkPipelineStageFlags                        stageMask)
 {
    stub();
 }
 
 void anv_CmdWaitEvents(
     VkCmdBuffer                                 cmdBuffer,
-    VkWaitEvent                                 waitEvent,
     uint32_t                                    eventCount,
     const VkEvent*                              pEvents,
-    VkPipeEventFlags                            pipeEventMask,
+    VkPipelineStageFlags                        srcStageMask,
+    VkPipelineStageFlags                        destStageMask,
     uint32_t                                    memBarrierCount,
     const void* const*                          ppMemBarriers)
 {
@@ -3729,8 +3729,9 @@ void anv_CmdWaitEvents(
 
 void anv_CmdPipelineBarrier(
     VkCmdBuffer                                 cmdBuffer,
-    VkWaitEvent                                 waitEvent,
-    VkPipeEventFlags                            pipeEventMask,
+    VkPipelineStageFlags                        srcStageMask,
+    VkPipelineStageFlags                        destStageMask,
+    VkBool32                                    byRegion,
     uint32_t                                    memBarrierCount,
     const void* const*                          ppMemBarriers)
 {
@@ -3744,32 +3745,41 @@ void anv_CmdPipelineBarrier(
 
    /* XXX: I think waitEvent is a no-op on our HW.  We should verify that. */
 
-   if (anv_clear_mask(&pipeEventMask, VK_PIPE_EVENT_TOP_OF_PIPE_BIT)) {
+   if (anv_clear_mask(&srcStageMask, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT)) {
       /* This is just what PIPE_CONTROL does */
    }
 
-   if (anv_clear_mask(&pipeEventMask,
-                      VK_PIPE_EVENT_VERTEX_PROCESSING_COMPLETE_BIT |
-                      VK_PIPE_EVENT_LOCAL_FRAGMENT_PROCESSING_COMPLETE_BIT |
-                      VK_PIPE_EVENT_FRAGMENT_PROCESSING_COMPLETE_BIT)) {
+   if (anv_clear_mask(&srcStageMask,
+                      VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT |
+                      VK_PIPELINE_STAGE_VERTEX_INPUT_BIT |
+                      VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
+                      VK_PIPELINE_STAGE_TESS_CONTROL_SHADER_BIT |
+                      VK_PIPELINE_STAGE_TESS_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)) {
       cmd.StallAtPixelScoreboard = true;
    }
 
 
-   if (anv_clear_mask(&pipeEventMask,
-                      VK_PIPE_EVENT_GRAPHICS_PIPELINE_COMPLETE_BIT |
-                      VK_PIPE_EVENT_COMPUTE_PIPELINE_COMPLETE_BIT |
-                      VK_PIPE_EVENT_TRANSFER_COMPLETE_BIT |
-                      VK_PIPE_EVENT_COMMANDS_COMPLETE_BIT)) {
+   if (anv_clear_mask(&srcStageMask,
+                      VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT |
+                      VK_PIPELINE_STAGE_TRANSFER_BIT |
+                      VK_PIPELINE_STAGE_TRANSITION_BIT)) {
       cmd.CommandStreamerStallEnable = true;
    }
 
-   if (anv_clear_mask(&pipeEventMask, VK_PIPE_EVENT_CPU_SIGNAL_BIT)) {
+   if (anv_clear_mask(&srcStageMask, VK_PIPELINE_STAGE_HOST_BIT)) {
       anv_finishme("VK_PIPE_EVENT_CPU_SIGNAL_BIT");
    }
 
+   /* On our hardware, all stages will wait for execution as needed. */
+   (void)destStageMask;
+
    /* We checked all known VkPipeEventFlags. */
-   anv_assert(pipeEventMask == 0);
+   anv_assert(srcStageMask == 0);
 
    /* XXX: Right now, we're really dumb and just flush whatever categories
     * the app asks for.  One of these days we may make this a bit better