anv: Distinguish between subpass setup and subpass start
authorChad Versace <chad.versace@intel.com>
Thu, 14 Jan 2016 23:18:20 +0000 (15:18 -0800)
committerChad Versace <chad.versace@intel.com>
Fri, 15 Jan 2016 06:53:05 +0000 (22:53 -0800)
vkCmdBeginRenderPass, vkCmdNextSubpass, and vkBeginCommandBuffer with
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, all *setup* the
command buffer for recording commands for some subpass.  But only the
first two, vkCmdBeginRenderPass and vkCmdNextSubpass, can *start*
a subpass.

Therefore, calling anv_cmd_buffer_begin_subpass() inside
vkCmdBeginCommandBuffer is misleading. Clarify its purpose by renaming
it to anv_cmd_buffer_set_subpass() and adding comments.

src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_private.h
src/vulkan/gen7_cmd_buffer.c
src/vulkan/gen8_cmd_buffer.c

index 065c2f6492271546b8ec5f459b1922c13835c2a4..070b8490e321896d75d37dc34642a7f8f087d942 100644 (file)
@@ -386,7 +386,7 @@ VkResult anv_BeginCommandBuffer(
       struct anv_subpass *subpass =
          &cmd_buffer->state.pass->subpasses[pBeginInfo->pInheritanceInfo->subpass];
 
-      anv_cmd_buffer_begin_subpass(cmd_buffer, subpass);
+      anv_cmd_buffer_set_subpass(cmd_buffer, subpass);
    }
 
    anv_cmd_buffer_emit_state_base_address(cmd_buffer);
@@ -954,19 +954,31 @@ anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer,
    return state;
 }
 
+/**
+ * @brief Setup the command buffer for recording commands inside the given
+ * subpass.
+ *
+ * This does not record all commands needed for starting the subpass.
+ * Starting the subpass may require additional commands.
+ *
+ * Note that vkCmdBeginRenderPass, vkCmdNextSubpass, and vkBeginCommandBuffer
+ * with VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, all setup the
+ * command buffer for recording commands for some subpass.  But only the first
+ * two, vkCmdBeginRenderPass and vkCmdNextSubpass, can start a subpass.
+ */
 void
-anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
-                             struct anv_subpass *subpass)
+anv_cmd_buffer_set_subpass(struct anv_cmd_buffer *cmd_buffer,
+                           struct anv_subpass *subpass)
 {
    switch (cmd_buffer->device->info.gen) {
    case 7:
-      gen7_cmd_buffer_begin_subpass(cmd_buffer, subpass);
+      gen7_cmd_buffer_set_subpass(cmd_buffer, subpass);
       break;
    case 8:
-      gen8_cmd_buffer_begin_subpass(cmd_buffer, subpass);
+      gen8_cmd_buffer_set_subpass(cmd_buffer, subpass);
       break;
    case 9:
-      gen9_cmd_buffer_begin_subpass(cmd_buffer, subpass);
+      gen9_cmd_buffer_set_subpass(cmd_buffer, subpass);
       break;
    default:
       unreachable("unsupported gen\n");
index a76e78aa8e48510bf6ed581241a3451f759f223f..e8ac70dc49801bdb43ed56bae38b2f247f92fa54 100644 (file)
@@ -1243,15 +1243,14 @@ void anv_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer);
 
 void anv_cmd_state_setup_attachments(struct anv_cmd_buffer *cmd_buffer,
                                      const VkRenderPassBeginInfo *info);
-void gen7_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
-                                   struct anv_subpass *subpass);
 
-void gen8_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
+void gen7_cmd_buffer_set_subpass(struct anv_cmd_buffer *cmd_buffer,
                                    struct anv_subpass *subpass);
-void gen9_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
+void gen8_cmd_buffer_set_subpass(struct anv_cmd_buffer *cmd_buffer,
                                    struct anv_subpass *subpass);
-
-void anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
+void gen9_cmd_buffer_set_subpass(struct anv_cmd_buffer *cmd_buffer,
+                                   struct anv_subpass *subpass);
+void anv_cmd_buffer_set_subpass(struct anv_cmd_buffer *cmd_buffer,
                                   struct anv_subpass *subpass);
 
 struct anv_state
index bea0abea1cc2bd3b95605a0df896ca86403108f6..b83bfdadbaeab701cfaa816569d3855a1edd1b7d 100644 (file)
@@ -794,9 +794,12 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
    anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_CLEAR_PARAMS);
 }
 
+/**
+ * @see anv_cmd_buffer_set_subpass()
+ */
 GENX_FUNC(GEN7, GEN7) void
-genX(cmd_buffer_begin_subpass)(struct anv_cmd_buffer *cmd_buffer,
-                               struct anv_subpass *subpass)
+genX(cmd_buffer_set_subpass)(struct anv_cmd_buffer *cmd_buffer,
+                             struct anv_subpass *subpass)
 {
    cmd_buffer->state.subpass = subpass;
    cmd_buffer->state.descriptors_dirty |= VK_SHADER_STAGE_FRAGMENT_BIT;
@@ -830,7 +833,7 @@ void genX(CmdBeginRenderPass)(
                   .DrawingRectangleOriginY = 0,
                   .DrawingRectangleOriginX = 0);
 
-   gen7_cmd_buffer_begin_subpass(cmd_buffer, pass->subpasses);
+   gen7_cmd_buffer_set_subpass(cmd_buffer, pass->subpasses);
    anv_cmd_buffer_clear_subpass(cmd_buffer);
 }
 
@@ -842,7 +845,7 @@ void genX(CmdNextSubpass)(
 
    assert(cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY);
 
-   gen7_cmd_buffer_begin_subpass(cmd_buffer, cmd_buffer->state.subpass + 1);
+   gen7_cmd_buffer_set_subpass(cmd_buffer, cmd_buffer->state.subpass + 1);
    anv_cmd_buffer_clear_subpass(cmd_buffer);
 }
 
index 10bc8f7bf54c9ff3c050cb949ea925fbdda6b166..e2bbd94ddf87c9eea20e0077dab6a41f3a293bac 100644 (file)
@@ -791,9 +791,12 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
    anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CLEAR_PARAMS));
 }
 
+/**
+ * @see anv_cmd_buffer_set_subpass()
+ */
 void
-genX(cmd_buffer_begin_subpass)(struct anv_cmd_buffer *cmd_buffer,
-                               struct anv_subpass *subpass)
+genX(cmd_buffer_set_subpass)(struct anv_cmd_buffer *cmd_buffer,
+                             struct anv_subpass *subpass)
 {
    cmd_buffer->state.subpass = subpass;
 
@@ -829,7 +832,7 @@ void genX(CmdBeginRenderPass)(
                   .DrawingRectangleOriginY = 0,
                   .DrawingRectangleOriginX = 0);
 
-   genX(cmd_buffer_begin_subpass)(cmd_buffer, pass->subpasses);
+   genX(cmd_buffer_set_subpass)(cmd_buffer, pass->subpasses);
    anv_cmd_buffer_clear_subpass(cmd_buffer);
 }
 
@@ -841,7 +844,7 @@ void genX(CmdNextSubpass)(
 
    assert(cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY);
 
-   genX(cmd_buffer_begin_subpass)(cmd_buffer, cmd_buffer->state.subpass + 1);
+   genX(cmd_buffer_set_subpass)(cmd_buffer, cmd_buffer->state.subpass + 1);
    anv_cmd_buffer_clear_subpass(cmd_buffer);
 }