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:
Jason Ekstrand
2021-11-19 13:44:35 -06:00
committed by Marge Bot
parent 5644011f06
commit 949b42c4dc
10 changed files with 31 additions and 13 deletions

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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();

View File

@@ -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,