intel/compiler: Convert wm_prog_key::multisample_fbo to a tri-state
This allows us to communicate to the back-end that we don't actually know if the framebuffer is multisampled or not. No drivers set anything but ALWAYS/NEVER and we still have a few ALWAYS/NEVER assumptions but those should be asserted. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21094>
This commit is contained in:

committed by
Marge Bot

parent
5644011f06
commit
949b42c4dc
@@ -4843,11 +4843,12 @@ crocus_populate_fs_key(const struct crocus_context *ice,
|
||||
key->flat_shade = rast->cso.flatshade &&
|
||||
(info->inputs_read & (VARYING_BIT_COL0 | VARYING_BIT_COL1));
|
||||
|
||||
key->multisample_fbo = rast->cso.multisample && fb->samples > 1;
|
||||
const bool multisample_fbo = rast->cso.multisample && fb->samples > 1;
|
||||
key->multisample_fbo = multisample_fbo ? BRW_ALWAYS : BRW_NEVER;
|
||||
key->persample_interp =
|
||||
rast->cso.force_persample_interp ? BRW_ALWAYS : BRW_NEVER;
|
||||
|
||||
key->ignore_sample_mask_out = !key->multisample_fbo;
|
||||
key->ignore_sample_mask_out = !multisample_fbo;
|
||||
key->coherent_fb_fetch = false; // TODO: needed?
|
||||
|
||||
key->force_dual_color_blend =
|
||||
|
@@ -160,7 +160,7 @@ iris_to_brw_fs_key(const struct iris_screen *screen,
|
||||
.alpha_to_coverage = key->alpha_to_coverage,
|
||||
.clamp_fragment_color = key->clamp_fragment_color,
|
||||
.persample_interp = key->persample_interp ? BRW_ALWAYS : BRW_NEVER,
|
||||
.multisample_fbo = key->multisample_fbo,
|
||||
.multisample_fbo = key->multisample_fbo ? BRW_ALWAYS : BRW_NEVER,
|
||||
.force_dual_color_blend = key->force_dual_color_blend,
|
||||
.coherent_fb_fetch = key->coherent_fb_fetch,
|
||||
.color_outputs_valid = key->color_outputs_valid,
|
||||
|
@@ -1527,7 +1527,7 @@ brw_blorp_get_blit_kernel_fs(struct blorp_batch *batch,
|
||||
|
||||
struct brw_wm_prog_key wm_key;
|
||||
brw_blorp_init_wm_prog_key(&wm_key);
|
||||
wm_key.multisample_fbo = key->rt_samples > 1;
|
||||
wm_key.multisample_fbo = key->rt_samples > 1 ? BRW_ALWAYS : BRW_NEVER;
|
||||
|
||||
program = blorp_compile_fs(blorp, mem_ctx, nir, &wm_key, false,
|
||||
&prog_data);
|
||||
|
@@ -1371,7 +1371,7 @@ blorp_params_get_mcs_partial_resolve_kernel(struct blorp_batch *batch,
|
||||
|
||||
struct brw_wm_prog_key wm_key;
|
||||
brw_blorp_init_wm_prog_key(&wm_key);
|
||||
wm_key.multisample_fbo = true;
|
||||
wm_key.multisample_fbo = BRW_ALWAYS;
|
||||
|
||||
struct brw_wm_prog_data prog_data;
|
||||
const unsigned *program =
|
||||
|
@@ -500,14 +500,16 @@ struct brw_wm_prog_key {
|
||||
*/
|
||||
enum brw_sometimes persample_interp:2;
|
||||
|
||||
bool multisample_fbo:1;
|
||||
/* Whether or not we are running on a multisampled framebuffer */
|
||||
enum brw_sometimes multisample_fbo:2;
|
||||
|
||||
enum brw_sometimes line_aa:2;
|
||||
bool force_dual_color_blend:1;
|
||||
bool coherent_fb_fetch:1;
|
||||
bool ignore_sample_mask_out:1;
|
||||
bool coarse_pixel:1;
|
||||
|
||||
uint64_t padding:57;
|
||||
uint64_t padding:56;
|
||||
};
|
||||
|
||||
struct brw_cs_prog_key {
|
||||
|
@@ -1273,12 +1273,13 @@ fs_visitor::emit_sampleid_setup()
|
||||
{
|
||||
assert(stage == MESA_SHADER_FRAGMENT);
|
||||
ASSERTED brw_wm_prog_key *key = (brw_wm_prog_key*) this->key;
|
||||
struct brw_wm_prog_data *wm_prog_data = brw_wm_prog_data(this->prog_data);
|
||||
assert(devinfo->ver >= 6);
|
||||
|
||||
const fs_builder abld = bld.annotate("compute sample id");
|
||||
fs_reg sample_id = abld.vgrf(BRW_REGISTER_TYPE_UD);
|
||||
|
||||
assert(key->multisample_fbo);
|
||||
assert(key->multisample_fbo != BRW_NEVER);
|
||||
|
||||
if (devinfo->ver >= 8) {
|
||||
/* Sample ID comes in as 4-bit numbers in g1.0:
|
||||
@@ -1368,6 +1369,13 @@ fs_visitor::emit_sampleid_setup()
|
||||
abld.emit(FS_OPCODE_SET_SAMPLE_ID, sample_id, t1, t2);
|
||||
}
|
||||
|
||||
if (key->multisample_fbo == BRW_SOMETIMES) {
|
||||
check_dynamic_msaa_flag(abld, wm_prog_data,
|
||||
BRW_WM_MSAA_FLAG_MULTISAMPLE_FBO);
|
||||
set_predicate(BRW_PREDICATE_NORMAL,
|
||||
abld.SEL(sample_id, sample_id, brw_imm_ud(0)));
|
||||
}
|
||||
|
||||
return sample_id;
|
||||
}
|
||||
|
||||
@@ -7284,12 +7292,17 @@ brw_nir_populate_wm_prog_data(const nir_shader *shader,
|
||||
shader->info.fs.uses_sample_shading ||
|
||||
shader->info.outputs_read;
|
||||
|
||||
assert(key->multisample_fbo || key->persample_interp == BRW_NEVER);
|
||||
assert(key->multisample_fbo != BRW_NEVER ||
|
||||
key->persample_interp == BRW_NEVER);
|
||||
|
||||
prog_data->persample_dispatch = key->persample_interp;
|
||||
if (key->multisample_fbo && prog_data->sample_shading)
|
||||
if (prog_data->sample_shading)
|
||||
prog_data->persample_dispatch = BRW_ALWAYS;
|
||||
|
||||
/* We can only persample dispatch if we have a multisample FBO */
|
||||
prog_data->persample_dispatch = MIN2(prog_data->persample_dispatch,
|
||||
key->multisample_fbo);
|
||||
|
||||
if (devinfo->ver >= 6) {
|
||||
prog_data->uses_sample_mask =
|
||||
BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_MASK_IN);
|
||||
|
@@ -3189,6 +3189,8 @@ fs_visitor::emit_non_coherent_fb_read(const fs_builder &bld, const fs_reg &dst,
|
||||
* shouldn't be necessary to recompile based on whether the framebuffer is
|
||||
* CMS or UMS.
|
||||
*/
|
||||
assert(wm_key->multisample_fbo == BRW_ALWAYS ||
|
||||
wm_key->multisample_fbo == BRW_NEVER);
|
||||
if (wm_key->multisample_fbo &&
|
||||
nir_system_values[SYSTEM_VALUE_SAMPLE_ID].file == BAD_FILE)
|
||||
nir_system_values[SYSTEM_VALUE_SAMPLE_ID] = emit_sampleid_setup();
|
||||
|
@@ -553,7 +553,7 @@ brw_nir_lower_fs_inputs(nir_shader *nir,
|
||||
if (devinfo->ver >= 11)
|
||||
nir_lower_interpolation(nir, ~0);
|
||||
|
||||
if (!key->multisample_fbo) {
|
||||
if (key->multisample_fbo == BRW_NEVER) {
|
||||
nir_lower_single_sampled(nir);
|
||||
} else if (key->persample_interp == BRW_ALWAYS) {
|
||||
nir_shader_instructions_pass(nir, lower_barycentric_per_sample,
|
||||
|
@@ -560,7 +560,7 @@ populate_wm_prog_key(const struct anv_graphics_pipeline *pipeline,
|
||||
(ms->sample_shading_enable &&
|
||||
(ms->min_sample_shading * ms->rasterization_samples) > 1) ?
|
||||
BRW_ALWAYS : BRW_NEVER;
|
||||
key->multisample_fbo = true;
|
||||
key->multisample_fbo = BRW_ALWAYS;
|
||||
}
|
||||
|
||||
if (device->physical->instance->sample_mask_out_opengl_behaviour)
|
||||
|
@@ -377,7 +377,7 @@ populate_wm_prog_key(const struct anv_graphics_pipeline *pipeline,
|
||||
(ms->sample_shading_enable &&
|
||||
(ms->min_sample_shading * ms->rasterization_samples) > 1) ?
|
||||
BRW_ALWAYS : BRW_NEVER;
|
||||
key->multisample_fbo = true;
|
||||
key->multisample_fbo = BRW_ALWAYS;
|
||||
}
|
||||
|
||||
if (device->physical->instance->sample_mask_out_opengl_behaviour)
|
||||
|
Reference in New Issue
Block a user