[Mesa-dev] [PATCH 1/1] spirv: handle FragCoord and SamplePosition builtins
Alejandro PiƱeiro
apinheiro at igalia.com
Fri Feb 8 14:33:13 UTC 2019
Those builtins need to fill origin_upper_left and pixel_center_integer
on the nir variable. Those depends on the execution mode, that moved
recently to be handled after creating the variables. This commit adds
a pass over the fragment shader inputs to set the proper value once we
have all the execution mode values.
Fixes: e68871f6a ("spirv: Handle constants and types before execution
modes")
---
src/compiler/spirv/spirv_to_nir.c | 14 ++++++++++++++
src/compiler/spirv/vtn_variables.c | 8 ++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 1cbc926c818..e15ff0ff806 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -4463,6 +4463,20 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
vtn_foreach_execution_mode(b, b->entry_point,
vtn_handle_execution_mode, NULL);
+ /* Update variables data that depends on the execution modes */
+ if (b->shader->info.stage == MESA_SHADER_FRAGMENT) {
+ nir_foreach_variable(var, &b->shader->inputs) {
+ switch (var->data.location) {
+ case VARYING_SLOT_POS: /* FragCoord */
+ var->data.pixel_center_integer = b->pixel_center_integer;
+ /* fallthrough */
+ var->data.origin_upper_left = b->origin_upper_left;
+ case SYSTEM_VALUE_SAMPLE_POS:
+ var->data.origin_upper_left = b->origin_upper_left;
+ }
+ }
+ }
+
if (b->workgroup_size_builtin) {
vtn_assert(b->workgroup_size_builtin->type->type ==
glsl_vector_type(GLSL_TYPE_UINT, 3));
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index f6b458b7e78..d4b64fd962d 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1448,12 +1448,8 @@ apply_var_decoration(struct vtn_builder *b,
case SpvBuiltInCullDistance:
var_data->compact = true;
break;
- case SpvBuiltInFragCoord:
- var_data->pixel_center_integer = b->pixel_center_integer;
- /* fallthrough */
- case SpvBuiltInSamplePosition:
- var_data->origin_upper_left = b->origin_upper_left;
- break;
+ /* FragCoord and SamplePosition depends on having the correct value for
+ * the execution mode. Will be handled later */
default:
break;
}
--
2.19.1
More information about the mesa-dev
mailing list