From 998837764ffd19795a78dc6fe1e864e6b17ed712 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 26 May 2015 09:40:10 -0700 Subject: [PATCH] vk: Program depth bias This makes 3DSTATE_RASTER a split state command. --- src/vulkan/device.c | 21 +++++++++++++++++---- src/vulkan/pipeline.c | 17 ++++++++++------- src/vulkan/private.h | 1 + 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/vulkan/device.c b/src/vulkan/device.c index a64772ae1bc..de68fa551a5 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -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))) diff --git a/src/vulkan/pipeline.c b/src/vulkan/pipeline.c index 3e0dc15c1ae..ca11ca8b343 100644 --- a/src/vulkan/pipeline.c +++ b/src/vulkan/pipeline.c @@ -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, diff --git a/src/vulkan/private.h b/src/vulkan/private.h index ec7ffb49dc7..4e18a434828 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -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 { -- 2.30.2