vk: Program depth bias
authorKristian Høgsberg <kristian.h.kristensen@intel.com>
Tue, 26 May 2015 16:40:10 +0000 (09:40 -0700)
committerKristian Høgsberg <kristian.h.kristensen@intel.com>
Tue, 26 May 2015 18:27:31 +0000 (11:27 -0700)
This makes 3DSTATE_RASTER a split state command.

src/vulkan/device.c
src/vulkan/pipeline.c
src/vulkan/private.h

index a64772ae1bcb7c306ff5689111fbee1324a306d3..de68fa551a5f79a05ceb518765c65ff9b475cc06 100644 (file)
@@ -2042,9 +2042,6 @@ VkResult anv_CreateDynamicRasterState(
       return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
    /* Missing these:
-    * float                                       depthBias;
-    * float                                       depthBiasClamp;
-    * float                                       slopeScaledDepthBias;
     * float                                       pointFadeThreshold;
     *                            // optional (GL45) - Size of point fade threshold
     */
@@ -2057,6 +2054,19 @@ VkResult anv_CreateDynamicRasterState(
 
    GEN8_3DSTATE_SF_pack(NULL, state->state_sf, &sf);
 
+   bool enable_bias = pCreateInfo->depthBias != 0.0f ||
+      pCreateInfo->slopeScaledDepthBias != 0.0f;
+   struct GEN8_3DSTATE_RASTER raster = {
+      .GlobalDepthOffsetEnableSolid = enable_bias,
+      .GlobalDepthOffsetEnableWireframe = enable_bias,
+      .GlobalDepthOffsetEnablePoint = enable_bias,
+      .GlobalDepthOffsetConstant = pCreateInfo->depthBias,
+      .GlobalDepthOffsetScale = pCreateInfo->slopeScaledDepthBias,
+      .GlobalDepthOffsetClamp = pCreateInfo->depthBiasClamp
+   };
+
+   GEN8_3DSTATE_RASTER_pack(NULL, state->state_raster, &raster);
+
    *pState = (VkDynamicRsState) state;
 
    return VK_SUCCESS;
@@ -2708,9 +2718,12 @@ anv_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer)
    if (cmd_buffer->dirty & ANV_CMD_BUFFER_DESCRIPTOR_SET_DIRTY)
       flush_descriptor_sets(cmd_buffer);
 
-   if (cmd_buffer->dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_RS_DIRTY))
+   if (cmd_buffer->dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_RS_DIRTY)) {
       anv_batch_emit_merge(&cmd_buffer->batch,
                            cmd_buffer->rs_state->state_sf, pipeline->state_sf);
+      anv_batch_emit_merge(&cmd_buffer->batch,
+                           cmd_buffer->rs_state->state_raster, pipeline->state_raster);
+   }
 
    if (cmd_buffer->ds_state &&
        (cmd_buffer->dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_DS_DIRTY)))
index 3e0dc15c1aed465bc3ab7f94ff96ff23ae72349e..ca11ca8b343aed598e2d9d77d3e02d478340bafd 100644 (file)
@@ -197,13 +197,16 @@ emit_rs_state(struct anv_pipeline *pipeline, VkPipelineRsStateCreateInfo *info,
 
    GEN8_3DSTATE_SF_pack(NULL, pipeline->state_sf, &sf);
 
-   anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_RASTER,
-                  .FrontWinding = vk_to_gen_front_face[info->frontFace],
-                  .CullMode = vk_to_gen_cullmode[info->cullMode],
-                  .FrontFaceFillMode = vk_to_gen_fillmode[info->fillMode],
-                  .BackFaceFillMode = vk_to_gen_fillmode[info->fillMode],
-                  .ScissorRectangleEnable = !(extra && extra->disable_scissor),
-                  .ViewportZClipTestEnable = info->depthClipEnable);
+   struct GEN8_3DSTATE_RASTER raster = {
+      .FrontWinding = vk_to_gen_front_face[info->frontFace],
+      .CullMode = vk_to_gen_cullmode[info->cullMode],
+      .FrontFaceFillMode = vk_to_gen_fillmode[info->fillMode],
+      .BackFaceFillMode = vk_to_gen_fillmode[info->fillMode],
+      .ScissorRectangleEnable = !(extra && extra->disable_scissor),
+      .ViewportZClipTestEnable = info->depthClipEnable
+   };
+
+   GEN8_3DSTATE_RASTER_pack(NULL, pipeline->state_raster, &raster);
 
    anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_SBE,
                   .ForceVertexURBEntryReadLength = false,
index ec7ffb49dc71fba317f582df87482c2dae381515..4e18a434828b6b6c1c7751577466f4b158a01aa2 100644 (file)
@@ -468,6 +468,7 @@ 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 anv_dynamic_ds_state {