radv: precompute DB_SHADER_CONTROL for fragment shaders later
To regroup all precomputed register values. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29022>
This commit is contained in:

committed by
Marge Bot

parent
c658ed5136
commit
c9162034bc
@@ -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) |
|
||||
|
@@ -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) |
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user