nir: gather if a fragment shader uses sample shading

This introduces a new flag in shader_info to know if a fragment
shader uses sample shading, even if there is no inputs.

During NIR linking, constants varyings are optimized and the
per-sample interpolation info (ie. the sample qualifier) might
be removed if nir_shader_gather_info() is called again.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7876>
This commit is contained in:
Samuel Pitoiset
2020-12-02 16:18:13 +01:00
parent c0aa3c8323
commit 128b2de63b
2 changed files with 16 additions and 0 deletions

View File

@@ -859,4 +859,15 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
gather_info_block(block, shader, dead_ctx);
}
ralloc_free(dead_ctx);
if (shader->info.stage == MESA_SHADER_FRAGMENT &&
(shader->info.fs.uses_sample_qualifier ||
(shader->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_ID)) ||
shader->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_POS))) {
/* This shouldn't be cleared because if optimizations remove all
* sample-qualified inputs and that pass is run again, the sample
* shading must stay enabled.
*/
shader->info.fs.uses_sample_shading = true;
}
}

View File

@@ -286,6 +286,11 @@ typedef struct shader_info {
*/
bool uses_sample_qualifier:1;
/**
* Whether sample shading is used.
*/
bool uses_sample_shading:1;
/**
* Whether early fragment tests are enabled as defined by
* ARB_shader_image_load_store.