vk: Fix 3DSTATE_WM_DEPTH_STENCIL for gen8
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 26 Nov 2015 18:11:52 +0000 (10:11 -0800)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Thu, 26 Nov 2015 18:11:52 +0000 (10:11 -0800)
This packet is a different size on gen8 and we hit an assertion when we
try to merge a gen9 size dword array from the pipeline with the gen8
sized array we create from dynamic state.

Use a static assert in the merge macro and fix this issue by using different
wm_depth_stencil arrays on gen8 and gen9.

src/vulkan/anv_private.h
src/vulkan/gen8_cmd_buffer.c
src/vulkan/gen8_pipeline.c

index 36cee88602d70ac9b427e7d1331b4ba5d498039c..d208b2d74a0c76da12841329f0bc4cad1f26bfad 100644 (file)
@@ -677,7 +677,7 @@ __gen_combine_address(struct anv_batch *batch, void *location,
    do {                                                                 \
       uint32_t *dw;                                                     \
                                                                         \
-      assert(ARRAY_SIZE(dwords0) == ARRAY_SIZE(dwords1));               \
+      static_assert(ARRAY_SIZE(dwords0) == ARRAY_SIZE(dwords1), "mismatch merge"); \
       dw = anv_batch_emit_dwords((batch), ARRAY_SIZE(dwords0));         \
       for (uint32_t i = 0; i < ARRAY_SIZE(dwords0); i++)                \
          dw[i] = (dwords0)[i] | (dwords1)[i];                           \
@@ -1201,8 +1201,12 @@ struct anv_pipeline {
    struct {
       uint32_t                                  sf[4];
       uint32_t                                  raster[5];
-      uint32_t                                  wm_depth_stencil[4];
+      uint32_t                                  wm_depth_stencil[3];
    } gen8;
+
+   struct {
+      uint32_t                                  wm_depth_stencil[4];
+   } gen9;
 };
 
 struct anv_graphics_pipeline_create_info {
index 093153190013ad1b559f1c44c81539c2abed8ba5..1d1433817d97befccde32293169a86f5b36f65e7 100644 (file)
@@ -248,7 +248,7 @@ cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
                            pipeline->gen8.raster);
    }
 
-   /* Stencil reference values were moves from COLOR_CALC_STATE in gen8 to
+   /* Stencil reference values moved from COLOR_CALC_STATE in gen8 to
     * 3DSTATE_WM_DEPTH_STENCIL in gen9. That means the dirty bits gets split
     * across different state packets for gen8 and gen9. We handle that by
     * using a big old #if switch here.
@@ -347,7 +347,7 @@ cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
       GEN9_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, dwords, &wm_depth_stencil);
 
       anv_batch_emit_merge(&cmd_buffer->batch, dwords,
-                           pipeline->gen8.wm_depth_stencil);
+                           pipeline->gen9.wm_depth_stencil);
    }
 #endif
 
index 0038bca01b46ee4ca0df75246c9c59dd58db28e5..b62bc44e7106baa808bde7c7c095a1e5aa4bfc0d 100644 (file)
@@ -290,13 +290,17 @@ static void
 emit_ds_state(struct anv_pipeline *pipeline,
               const VkPipelineDepthStencilStateCreateInfo *info)
 {
+   uint32_t *dw = ANV_GEN == 8 ?
+      pipeline->gen8.wm_depth_stencil : pipeline->gen9.wm_depth_stencil;
+
    if (info == NULL) {
       /* We're going to OR this together with the dynamic state.  We need
        * to make sure it's initialized to something useful.
        */
-      /* FIXME: gen9 wm_depth_stencil */
       memset(pipeline->gen8.wm_depth_stencil, 0,
              sizeof(pipeline->gen8.wm_depth_stencil));
+      memset(pipeline->gen9.wm_depth_stencil, 0,
+             sizeof(pipeline->gen9.wm_depth_stencil));
       return;
    }
 
@@ -319,7 +323,7 @@ emit_ds_state(struct anv_pipeline *pipeline,
       .BackfaceStencilTestFunction = vk_to_gen_compare_op[info->back.stencilCompareOp],
    };
 
-   GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, pipeline->gen8.wm_depth_stencil, &wm_depth_stencil);
+   GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, dw, &wm_depth_stencil);
 }
 
 VkResult