vk: Move gen8 specific state into gen8 sub-structs
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 21 Aug 2015 05:41:22 +0000 (22:41 -0700)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Mon, 24 Aug 2015 20:45:41 +0000 (13:45 -0700)
This commit moves all occurances of gen8 specific state into a gen8
substruct. This clearly identifies the state as gen8 specific and
prepares for adding gen7 state structs. In the process we also rename
the field names to exactly match the command or state packet name,
without the 3DSTATE prefix, eg:

  3DSTATE_VF -> gen8.vf
  3DSTATE_WM_DEPTH_STENCIL -> gen8.wm_depth_stencil

Signed-off-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
src/vulkan/anv_device.c
src/vulkan/anv_private.h
src/vulkan/gen8_cmd_buffer.c
src/vulkan/gen8_pipeline.c
src/vulkan/gen8_state.c

index bf256765bdfa3ea7589a233fb31e3db9bc0d904b..27a51129a74186eaeff03aff04586f42443b4eb5 100644 (file)
@@ -1909,7 +1909,7 @@ VkResult anv_CreateDynamicColorBlendState(
       .BlendConstantColorAlpha = pCreateInfo->blendConst[3]
    };
 
-   GEN7_COLOR_CALC_STATE_pack(NULL, state->state_color_calc, &color_calc_state);
+   GEN7_COLOR_CALC_STATE_pack(NULL, state->color_calc_state, &color_calc_state);
 
    *pState = anv_dynamic_cb_state_to_handle(state);
 
index 58480aca818c630fcb7f2c79fa54218b732dabb8..4d30bcb68ff3033a6555c0c422ac6070fd327806 100644 (file)
@@ -569,17 +569,21 @@ struct anv_dynamic_vp_state {
 };
 
 struct anv_dynamic_rs_state {
-   uint32_t state_sf[GEN8_3DSTATE_SF_length];
-   uint32_t state_raster[GEN8_3DSTATE_RASTER_length];
+   struct {
+      uint32_t sf[GEN8_3DSTATE_SF_length];
+      uint32_t raster[GEN8_3DSTATE_RASTER_length];
+   } gen8;
 };
 
 struct anv_dynamic_ds_state {
-   uint32_t state_wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];
-   uint32_t state_color_calc[GEN8_COLOR_CALC_STATE_length];
+   struct {
+      uint32_t wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];
+      uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length];
+   } gen8;
 };
 
 struct anv_dynamic_cb_state {
-   uint32_t state_color_calc[GEN8_COLOR_CALC_STATE_length];
+   uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length];
 
 };
 
@@ -861,13 +865,15 @@ struct anv_pipeline {
    uint32_t                                     vb_used;
    uint32_t                                     binding_stride[MAX_VBS];
 
-   uint32_t                                     state_sf[GEN8_3DSTATE_SF_length];
-   uint32_t                                     state_vf[GEN8_3DSTATE_VF_length];
-   uint32_t                                     state_raster[GEN8_3DSTATE_RASTER_length];
-   uint32_t                                     state_wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];
-
    uint32_t                                     cs_thread_width_max;
    uint32_t                                     cs_right_mask;
+
+   struct {
+      uint32_t                                  sf[GEN8_3DSTATE_SF_length];
+      uint32_t                                  vf[GEN8_3DSTATE_VF_length];
+      uint32_t                                  raster[GEN8_3DSTATE_RASTER_length];
+      uint32_t                                  wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];
+   } gen8;
 };
 
 struct anv_graphics_pipeline_create_info {
index 68d6d4a42d38c67730505ae0db3a0f5d9605c5e1..6d5004a1ca24d5ebf9125bcb3361f27f4f332dc8 100644 (file)
@@ -97,19 +97,19 @@ gen8_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
    if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY |
                                   ANV_CMD_BUFFER_RS_DIRTY)) {
       anv_batch_emit_merge(&cmd_buffer->batch,
-                           cmd_buffer->state.rs_state->state_sf,
-                           pipeline->state_sf);
+                           cmd_buffer->state.rs_state->gen8.sf,
+                           pipeline->gen8.sf);
       anv_batch_emit_merge(&cmd_buffer->batch,
-                           cmd_buffer->state.rs_state->state_raster,
-                           pipeline->state_raster);
+                           cmd_buffer->state.rs_state->gen8.raster,
+                           pipeline->gen8.raster);
    }
 
    if (cmd_buffer->state.ds_state &&
        (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY |
                                    ANV_CMD_BUFFER_DS_DIRTY))) {
       anv_batch_emit_merge(&cmd_buffer->batch,
-                           cmd_buffer->state.ds_state->state_wm_depth_stencil,
-                           pipeline->state_wm_depth_stencil);
+                           cmd_buffer->state.ds_state->gen8.wm_depth_stencil,
+                           pipeline->gen8.wm_depth_stencil);
    }
 
    if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_CB_DIRTY |
@@ -117,16 +117,16 @@ gen8_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
       struct anv_state state;
       if (cmd_buffer->state.ds_state == NULL)
          state = anv_cmd_buffer_emit_dynamic(cmd_buffer,
-                                             cmd_buffer->state.cb_state->state_color_calc,
+                                             cmd_buffer->state.cb_state->color_calc_state,
                                              GEN8_COLOR_CALC_STATE_length, 64);
       else if (cmd_buffer->state.cb_state == NULL)
          state = anv_cmd_buffer_emit_dynamic(cmd_buffer,
-                                             cmd_buffer->state.ds_state->state_color_calc,
+                                             cmd_buffer->state.ds_state->gen8.color_calc_state,
                                              GEN8_COLOR_CALC_STATE_length, 64);
       else
          state = anv_cmd_buffer_merge_dynamic(cmd_buffer,
-                                              cmd_buffer->state.ds_state->state_color_calc,
-                                              cmd_buffer->state.cb_state->state_color_calc,
+                                              cmd_buffer->state.ds_state->gen8.color_calc_state,
+                                              cmd_buffer->state.cb_state->color_calc_state,
                                               GEN8_COLOR_CALC_STATE_length, 64);
 
       anv_batch_emit(&cmd_buffer->batch,
@@ -138,7 +138,7 @@ gen8_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
    if (cmd_buffer->state.dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY |
                                   ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY)) {
       anv_batch_emit_merge(&cmd_buffer->batch,
-                           cmd_buffer->state.state_vf, pipeline->state_vf);
+                           cmd_buffer->state.state_vf, pipeline->gen8.vf);
    }
 
    cmd_buffer->state.vb_dirty &= ~vb_emit;
index 220317c2d4895dc6fa03498124cb88c8f7fd544f..a993552cfd3feb653bbd69466ed85255b7eda582 100644 (file)
@@ -124,7 +124,7 @@ emit_ia_state(struct anv_pipeline *pipeline,
       GEN8_3DSTATE_VF_header,
       .IndexedDrawCutIndexEnable = info->primitiveRestartEnable,
    };
-   GEN8_3DSTATE_VF_pack(NULL, pipeline->state_vf, &vf);
+   GEN8_3DSTATE_VF_pack(NULL, pipeline->gen8.vf, &vf);
 
    anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_TOPOLOGY,
                   .PrimitiveTopologyType = topology);
@@ -165,7 +165,7 @@ emit_rs_state(struct anv_pipeline *pipeline,
 
    /* FINISHME: VkBool32 rasterizerDiscardEnable; */
 
-   GEN8_3DSTATE_SF_pack(NULL, pipeline->state_sf, &sf);
+   GEN8_3DSTATE_SF_pack(NULL, pipeline->gen8.sf, &sf);
 
    struct GEN8_3DSTATE_RASTER raster = {
       GEN8_3DSTATE_RASTER_header,
@@ -177,8 +177,6 @@ emit_rs_state(struct anv_pipeline *pipeline,
       .ViewportZClipTestEnable = info->depthClipEnable
    };
 
-   GEN8_3DSTATE_RASTER_pack(NULL, pipeline->state_raster, &raster);
-
    anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_SBE,
                   .ForceVertexURBEntryReadLength = false,
                   .ForceVertexURBEntryReadOffset = false,
@@ -186,6 +184,7 @@ emit_rs_state(struct anv_pipeline *pipeline,
                   .NumberofSFOutputAttributes =
                      pipeline->wm_prog_data.num_varying_inputs);
 
+   GEN8_3DSTATE_RASTER_pack(NULL, pipeline->gen8.raster, &raster);
 }
 
 static void
@@ -311,8 +310,8 @@ emit_ds_state(struct anv_pipeline *pipeline,
       /* We're going to OR this together with the dynamic state.  We need
        * to make sure it's initialized to something useful.
        */
-      memset(pipeline->state_wm_depth_stencil, 0,
-             sizeof(pipeline->state_wm_depth_stencil));
+      memset(pipeline->gen8.wm_depth_stencil, 0,
+             sizeof(pipeline->gen8.wm_depth_stencil));
       return;
    }
 
@@ -335,7 +334,7 @@ emit_ds_state(struct anv_pipeline *pipeline,
       .BackfaceStencilTestFunction = vk_to_gen_compare_op[info->back.stencilCompareOp],
    };
 
-   GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, pipeline->state_wm_depth_stencil, &wm_depth_stencil);
+   GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, pipeline->gen8.wm_depth_stencil, &wm_depth_stencil);
 }
 
 VkResult
index 736a1d9455f270bb58e2e49d0e8803cdb60987b3..f035baabf742c4c9193e54235208a53ce208a5c8 100644 (file)
@@ -49,7 +49,7 @@ VkResult gen8_CreateDynamicRasterState(
       .LineWidth = pCreateInfo->lineWidth,
    };
 
-   GEN8_3DSTATE_SF_pack(NULL, state->state_sf, &sf);
+   GEN8_3DSTATE_SF_pack(NULL, state->gen8.sf, &sf);
 
    bool enable_bias = pCreateInfo->depthBias != 0.0f ||
       pCreateInfo->slopeScaledDepthBias != 0.0f;
@@ -62,7 +62,7 @@ VkResult gen8_CreateDynamicRasterState(
       .GlobalDepthOffsetClamp = pCreateInfo->depthBiasClamp
    };
 
-   GEN8_3DSTATE_RASTER_pack(NULL, state->state_raster, &raster);
+   GEN8_3DSTATE_RASTER_pack(NULL, state->gen8.raster, &raster);
 
    *pState = anv_dynamic_rs_state_to_handle(state);
 
@@ -506,7 +506,7 @@ VkResult gen8_CreateDynamicDepthStencilState(
       .BackfaceStencilWriteMask = pCreateInfo->stencilWriteMask & 0xff,
    };
 
-   GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, state->state_wm_depth_stencil,
+   GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, state->gen8.wm_depth_stencil,
                                       &wm_depth_stencil);
 
    struct GEN8_COLOR_CALC_STATE color_calc_state = {
@@ -514,7 +514,7 @@ VkResult gen8_CreateDynamicDepthStencilState(
       .BackFaceStencilReferenceValue = pCreateInfo->stencilBackRef
    };
 
-   GEN8_COLOR_CALC_STATE_pack(NULL, state->state_color_calc, &color_calc_state);
+   GEN8_COLOR_CALC_STATE_pack(NULL, state->gen8.color_calc_state, &color_calc_state);
 
    *pState = anv_dynamic_ds_state_to_handle(state);