nir/lower_system_values: simplify load_helper_invocation lowering
The two backends (ir3, dxil) using the lowering have info->fs.uses_sample_shading matching set when sample shading is used -- the VK drivers pass the rasterization state flag into the compiler, while freedreno and d3d12 have caps->force_persample_interp so the frontend creates a shader variant with info->fs.uses_sample_shading set. This means that we can drop the sample-id SHL/AND in the pixel-rate shading case, which in turn means that drivers don't need to have a load_sample_id() that doesn't trigger sample-rate shading (which Adreno doesn't have). Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36429>
This commit is contained in:
committed by
Marge Bot
parent
ceaa8de981
commit
04be5a8910
@@ -347,11 +347,14 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
|
||||
nir_def *
|
||||
nir_build_lowered_load_helper_invocation(nir_builder *b)
|
||||
{
|
||||
nir_def *tmp;
|
||||
tmp = nir_ishl(b, nir_imm_int(b, 1),
|
||||
nir_load_sample_id_no_per_sample(b));
|
||||
tmp = nir_iand(b, nir_load_sample_mask_in(b), tmp);
|
||||
return nir_inot(b, nir_i2b(b, tmp));
|
||||
nir_def *mask = nir_load_sample_mask_in(b);
|
||||
|
||||
if (b->shader->info.fs.uses_sample_shading) {
|
||||
nir_def *id = nir_load_sample_id(b);
|
||||
mask = nir_iand(b, mask, nir_ishl(b, nir_imm_int(b, 1), id));
|
||||
}
|
||||
|
||||
return nir_ieq_imm(b, mask, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -370,7 +370,14 @@ typedef struct nir_shader_compiler_options {
|
||||
/**
|
||||
* If enabled, gl_HelperInvocation will be lowered as:
|
||||
*
|
||||
* !((1 << sample_id) & sample_mask_in))
|
||||
* - non-sample-shading: sample_mask_in == 0.
|
||||
* - sample shading: !((1 << sample_id) & sample_mask_in))
|
||||
*
|
||||
* For this to be correct, it requires that fs.uses_sample_shading is set to
|
||||
* true when sample shading is enabled. This means that you need shader
|
||||
* variants to set the flag when Vulkan's
|
||||
* VkPipelineMultisampleStateCreateInfo->sampleShadingEnable or GL's
|
||||
* glMinSampleshading() are enabled.
|
||||
*
|
||||
* This depends on some possibly hw implementation details, which may
|
||||
* not be true for all hw. In particular that the FS is only executed
|
||||
|
||||
Reference in New Issue
Block a user