diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 8e90285742c..4cc9975630f 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -6868,7 +6868,7 @@ radv_bind_fragment_shader(struct radv_cmd_buffer *cmd_buffer, const struct radv_ cmd_buffer->state.dirty_dynamic |= RADV_CMD_DIRTY_DYNAMIC_RASTERIZATION_SAMPLES; } - if (!previous_ps || previous_ps->info.ps.db_shader_control != ps->info.ps.db_shader_control || + if (!previous_ps || previous_ps->info.regs.ps.db_shader_control != ps->info.regs.ps.db_shader_control || previous_ps->info.ps.pops_is_per_sample != ps->info.ps.pops_is_per_sample) cmd_buffer->state.dirty |= RADV_CMD_DIRTY_DB_SHADER_CONTROL; @@ -9360,7 +9360,7 @@ radv_emit_db_shader_control(struct radv_cmd_buffer *cmd_buffer) uint32_t db_shader_control; if (ps) { - db_shader_control = ps->info.ps.db_shader_control; + db_shader_control = ps->info.regs.ps.db_shader_control; } else { db_shader_control = S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_ANY_Z) | S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z) | diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index f2d1ad8bf9f..9db1de7c195 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -1600,6 +1600,30 @@ radv_precompute_registers_hw_fs(struct radv_device *device, struct radv_shader_b const struct radv_physical_device *pdev = radv_device_physical(device); struct radv_shader_info *info = &binary->info; + unsigned conservative_z_export = V_02880C_EXPORT_ANY_Z; + if (info->ps.depth_layout == FRAG_DEPTH_LAYOUT_GREATER) + conservative_z_export = V_02880C_EXPORT_GREATER_THAN_Z; + else if (info->ps.depth_layout == FRAG_DEPTH_LAYOUT_LESS) + conservative_z_export = V_02880C_EXPORT_LESS_THAN_Z; + + const unsigned z_order = + info->ps.early_fragment_test || !info->ps.writes_memory ? V_02880C_EARLY_Z_THEN_LATE_Z : V_02880C_LATE_Z; + + /* It shouldn't be needed to export gl_SampleMask when MSAA is disabled, but this appears to break Project Cars + * (DXVK). See https://bugs.freedesktop.org/show_bug.cgi?id=109401 + */ + const bool mask_export_enable = info->ps.writes_sample_mask; + const bool disable_rbplus = pdev->info.has_rbplus && !pdev->info.rbplus_allowed; + + info->regs.ps.db_shader_control = + S_02880C_Z_EXPORT_ENABLE(info->ps.writes_z) | S_02880C_STENCIL_TEST_VAL_EXPORT_ENABLE(info->ps.writes_stencil) | + S_02880C_KILL_ENABLE(info->ps.can_discard) | S_02880C_MASK_EXPORT_ENABLE(mask_export_enable) | + S_02880C_CONSERVATIVE_Z_EXPORT(conservative_z_export) | S_02880C_Z_ORDER(z_order) | + S_02880C_DEPTH_BEFORE_SHADER(info->ps.early_fragment_test) | + S_02880C_PRE_SHADER_DEPTH_COVERAGE_ENABLE(info->ps.post_depth_coverage) | + S_02880C_EXEC_ON_HIER_FAIL(info->ps.writes_memory) | S_02880C_EXEC_ON_NOOP(info->ps.writes_memory) | + S_02880C_DUAL_QUAD_DISABLE(disable_rbplus) | S_02880C_PRIMITIVE_ORDERED_PIXEL_SHADER(info->ps.pops); + const bool param_gen = pdev->info.gfx_level >= GFX11 && !info->ps.num_interp && binary->config.lds_size; info->regs.ps.spi_ps_in_control = S_0286D8_NUM_INTERP(info->ps.num_interp) | diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index 6641a285282..6a09da933c8 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -941,33 +941,6 @@ gather_shader_info_fs(const struct radv_device *device, const nir_shader *nir, (pdev->info.gfx_level == GFX10_3 && (nir->info.fs.sample_interlock_ordered || nir->info.fs.sample_interlock_unordered || nir->info.fs.pixel_interlock_ordered || nir->info.fs.pixel_interlock_unordered)); - - /* DB_SHADER_CONTROL based on other fragment shader info fields. */ - - unsigned conservative_z_export = V_02880C_EXPORT_ANY_Z; - if (info->ps.depth_layout == FRAG_DEPTH_LAYOUT_GREATER) - conservative_z_export = V_02880C_EXPORT_GREATER_THAN_Z; - else if (info->ps.depth_layout == FRAG_DEPTH_LAYOUT_LESS) - conservative_z_export = V_02880C_EXPORT_LESS_THAN_Z; - - unsigned z_order = - info->ps.early_fragment_test || !info->ps.writes_memory ? V_02880C_EARLY_Z_THEN_LATE_Z : V_02880C_LATE_Z; - - /* It shouldn't be needed to export gl_SampleMask when MSAA is disabled, but this appears to break Project Cars - * (DXVK). See https://bugs.freedesktop.org/show_bug.cgi?id=109401 - */ - const bool mask_export_enable = info->ps.writes_sample_mask; - - const bool disable_rbplus = pdev->info.has_rbplus && !pdev->info.rbplus_allowed; - - info->ps.db_shader_control = - S_02880C_Z_EXPORT_ENABLE(info->ps.writes_z) | S_02880C_STENCIL_TEST_VAL_EXPORT_ENABLE(info->ps.writes_stencil) | - S_02880C_KILL_ENABLE(info->ps.can_discard) | S_02880C_MASK_EXPORT_ENABLE(mask_export_enable) | - S_02880C_CONSERVATIVE_Z_EXPORT(conservative_z_export) | S_02880C_Z_ORDER(z_order) | - S_02880C_DEPTH_BEFORE_SHADER(info->ps.early_fragment_test) | - S_02880C_PRE_SHADER_DEPTH_COVERAGE_ENABLE(info->ps.post_depth_coverage) | - S_02880C_EXEC_ON_HIER_FAIL(info->ps.writes_memory) | S_02880C_EXEC_ON_NOOP(info->ps.writes_memory) | - S_02880C_DUAL_QUAD_DISABLE(disable_rbplus) | S_02880C_PRIMITIVE_ORDERED_PIXEL_SHADER(info->ps.pops); } static void diff --git a/src/amd/vulkan/radv_shader_info.h b/src/amd/vulkan/radv_shader_info.h index 5341d89bf98..a9a2fe20210 100644 --- a/src/amd/vulkan/radv_shader_info.h +++ b/src/amd/vulkan/radv_shader_info.h @@ -209,7 +209,6 @@ struct radv_shader_info { bool load_provoking_vtx; bool load_rasterization_prim; bool force_sample_iter_shading_rate; - uint32_t db_shader_control; /* DB_SHADER_CONTROL without intrinsic rate overrides */ } ps; struct { bool uses_grid_size; @@ -281,6 +280,7 @@ struct radv_shader_info { } ms; struct { + uint32_t db_shader_control; uint32_t pa_sc_shader_control; uint32_t spi_ps_in_control; uint32_t spi_shader_z_format;