diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 4c9e3490bac..fa66c8b526b 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -302,6 +302,7 @@ get_device_extensions(const struct anv_physical_device *device, .EXT_conditional_rendering = true, .EXT_conservative_rasterization = true, .EXT_custom_border_color = true, + .EXT_depth_bias_control = true, .EXT_depth_clamp_zero_one = true, .EXT_depth_clip_control = true, .EXT_depth_clip_enable = true, @@ -815,6 +816,12 @@ get_features(const struct anv_physical_device *pdevice, /* VK_EXT_dynamic_rendering_unused_attachments */ .dynamicRenderingUnusedAttachments = true, + + /* VK_EXT_depth_bias_control */ + .depthBiasControl = true, + .floatRepresentation = true, + .leastRepresentableValueForceUnormRepresentation = false, + .depthBiasExact = true, }; /* The new DOOM and Wolfenstein games require depthBounds without diff --git a/src/intel/vulkan/gfx8_cmd_buffer.c b/src/intel/vulkan/gfx8_cmd_buffer.c index 823191ef0b3..0cffb411da8 100644 --- a/src/intel/vulkan/gfx8_cmd_buffer.c +++ b/src/intel/vulkan/gfx8_cmd_buffer.c @@ -462,7 +462,8 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) if ((cmd_buffer->state.gfx.dirty & ANV_CMD_DIRTY_PIPELINE) || BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_LINE_WIDTH) || - BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_PROVOKING_VERTEX)) { + BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_PROVOKING_VERTEX) || + BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_RS_DEPTH_BIAS_FACTORS)) { uint32_t sf_dw[GENX(3DSTATE_SF_length)]; struct GENX(3DSTATE_SF) sf = { GENX(3DSTATE_SF_header), @@ -470,7 +471,30 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) ANV_SETUP_PROVOKING_VERTEX(sf, dyn->rs.provoking_vertex); - sf.LineWidth = dyn->rs.line.width, + sf.LineWidth = dyn->rs.line.width; + + /** + * From the Vulkan Spec: + * + * "VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT specifies that the depth + * bias representation is a factor of constant r equal to 1." + * + * From the SKL PRMs, Volume 7: 3D-Media-GPGPU, Depth Offset: + * + * "When UNORM Depth Buffer is at Output Merger (or no Depth Buffer): + * + * Bias = GlobalDepthOffsetConstant * r + GlobalDepthOffsetScale * MaxDepthSlope + * + * Where r is the minimum representable value > 0 in the depth + * buffer format, converted to float32 (note: If state bit Legacy + * Global Depth Bias Enable is set, the r term will be forced to + * 1.0)" + * + * When VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT is set, enable + * LegacyGlobalDepthBiasEnable. + */ + sf.LegacyGlobalDepthBiasEnable = + dyn->rs.depth_bias.representation == VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT; GENX(3DSTATE_SF_pack)(NULL, sf_dw, &sf); anv_batch_emit_merge(&cmd_buffer->batch, sf_dw, pipeline->gfx8.sf);