anv/cmd_buffer: Pack the 3DSTATE_VF packet on-demand
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 17 Nov 2015 00:29:33 +0000 (16:29 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 17 Nov 2015 16:27:51 +0000 (08:27 -0800)
src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_private.h
src/vulkan/gen8_cmd_buffer.c
src/vulkan/gen8_pipeline.c

index c0de376da255fcbb5038740303df9cd128cd7406..1a37d8124d9a9b38b8482ed8cb86e18d14f0454a 100644 (file)
@@ -113,7 +113,6 @@ anv_dynamic_state_copy(struct anv_dynamic_state *dest,
 static void
 anv_cmd_state_init(struct anv_cmd_state *state)
 {
-   memset(&state->state_vf, 0, sizeof(state->state_vf));
    memset(&state->descriptors, 0, sizeof(state->descriptors));
    memset(&state->push_constants, 0, sizeof(state->push_constants));
 
@@ -122,6 +121,7 @@ anv_cmd_state_init(struct anv_cmd_state *state)
    state->descriptors_dirty = 0;
    state->push_constants_dirty = 0;
    state->pipeline = NULL;
+   state->restart_index = UINT32_MAX;
    state->dynamic = default_dynamic_state;
 
    state->gen7.index_buffer = NULL;
index a8ed5e8a7e266e18d3f3962b390a697204529ff1..55f562d06b88ca4c2d4dc2723f4febf3bcee87ac 100644 (file)
@@ -918,7 +918,7 @@ struct anv_cmd_state {
    struct anv_framebuffer *                     framebuffer;
    struct anv_render_pass *                     pass;
    struct anv_subpass *                         subpass;
-   uint32_t                                     state_vf[2];
+   uint32_t                                     restart_index;
    struct anv_vertex_binding                    vertex_bindings[MAX_VBS];
    struct anv_descriptor_set *                  descriptors[MAX_SETS];
    struct anv_push_constants *                  push_constants[VK_SHADER_STAGE_NUM];
@@ -1151,7 +1151,6 @@ struct anv_pipeline {
 
    struct {
       uint32_t                                  sf[4];
-      uint32_t                                  vf[2];
       uint32_t                                  raster[5];
       uint32_t                                  wm_depth_stencil[3];
    } gen8;
index 2e4a618bad1c48114fea12d8e82bbed70be50210..9a3e3b5e06126bf3d0629d76fcb59da89e08c97e 100644 (file)
@@ -283,8 +283,10 @@ gen8_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
 
    if (cmd_buffer->state.dirty & (ANV_CMD_DIRTY_PIPELINE |
                                   ANV_CMD_DIRTY_INDEX_BUFFER)) {
-      anv_batch_emit_merge(&cmd_buffer->batch,
-                           cmd_buffer->state.state_vf, pipeline->gen8.vf);
+      anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VF,
+         .IndexedDrawCutIndexEnable = pipeline->primitive_restart,
+         .CutIndex = cmd_buffer->state.restart_index,
+      );
    }
 
    cmd_buffer->state.vb_dirty &= ~vb_emit;
@@ -396,19 +398,20 @@ void gen8_CmdBindIndexBuffer(
       [VK_INDEX_TYPE_UINT32]                    = INDEX_DWORD,
    };
 
-   struct GEN8_3DSTATE_VF vf = {
-      GEN8_3DSTATE_VF_header,
-      .CutIndex = (indexType == VK_INDEX_TYPE_UINT16) ? UINT16_MAX : UINT32_MAX,
+   static const uint32_t restart_index_for_type[] = {
+      [VK_INDEX_TYPE_UINT16]                    = UINT16_MAX,
+      [VK_INDEX_TYPE_UINT32]                    = UINT32_MAX,
    };
-   GEN8_3DSTATE_VF_pack(NULL, cmd_buffer->state.state_vf, &vf);
 
-   cmd_buffer->state.dirty |= ANV_CMD_DIRTY_INDEX_BUFFER;
+   cmd_buffer->state.restart_index = restart_index_for_type[indexType];
 
    anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_INDEX_BUFFER,
                   .IndexFormat = vk_to_gen_index_type[indexType],
                   .MemoryObjectControlState = GEN8_MOCS,
                   .BufferStartingAddress = { buffer->bo, buffer->offset + offset },
                   .BufferSize = buffer->size - offset);
+
+   cmd_buffer->state.dirty |= ANV_CMD_DIRTY_INDEX_BUFFER;
 }
 
 static VkResult
index 81bc254b3f7246235907745e8b48e1c4edff6d67..9d4ee9927cf16234ffda794efda366dc7577f1a6 100644 (file)
@@ -83,12 +83,6 @@ emit_ia_state(struct anv_pipeline *pipeline,
               const VkPipelineInputAssemblyStateCreateInfo *info,
               const struct anv_graphics_pipeline_create_info *extra)
 {
-   struct GEN8_3DSTATE_VF vf = {
-      GEN8_3DSTATE_VF_header,
-      .IndexedDrawCutIndexEnable = pipeline->primitive_restart
-   };
-   GEN8_3DSTATE_VF_pack(NULL, pipeline->gen8.vf, &vf);
-
    anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_TOPOLOGY,
                   .PrimitiveTopologyType = pipeline->topology);
 }