nir/i915g/r300/nv30: skip marking varyings as flat in some drivers
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 18 May 2022 02:00:30 +0000 (12:00 +1000)
committerMarge Bot <emma+marge@anholt.net>
Thu, 19 May 2022 01:05:32 +0000 (01:05 +0000)
Some older drivers don't support GLSL versions with the concept of flat
varyings and also don't support integers. Here we add a new setting to
make sure we don't use the optimisation that sets varyings to flat.
This setting helps us avoid marking varyings as flat and therefore
potentially having them changed to ints via varying packing.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6500
Fixes: 7647023f3bb5 ("glsl: enable the use of the nir based varying linker")

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16573>

src/compiler/nir/nir.h
src/compiler/nir/nir_linking_helpers.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/nouveau/nv30/nv30_screen.c
src/gallium/drivers/r300/r300_screen.c

index 968aa78..329d642 100644 (file)
@@ -3583,6 +3583,13 @@ typedef struct nir_shader_compiler_options {
     */
    bool force_indirect_unrolling_sampler;
 
+   /* Some older drivers don't support GLSL versions with the concept of flat
+    * varyings and also don't support integers. This setting helps us avoid
+    * marking varyings as flat and potentially having them changed to ints via
+    * varying packing.
+    */
+   bool no_integers;
+
    /**
     * Specifies which type of indirectly accessed variables should force
     * loop unrolling.
index 7c21b63..613b424 100644 (file)
@@ -1392,7 +1392,8 @@ nir_link_opt_varyings(nir_shader *producer, nir_shader *consumer)
             /* The varying is loaded from same uniform, so no need to do any
              * interpolation. Mark it as flat explicitly.
              */
-            if (in_var && in_var->data.interpolation <= INTERP_MODE_NOPERSPECTIVE) {
+            if (!consumer->options->no_integers &&
+                in_var && in_var->data.interpolation <= INTERP_MODE_NOPERSPECTIVE) {
                in_var->data.interpolation = INTERP_MODE_FLAT;
                out_var->data.interpolation = INTERP_MODE_FLAT;
             }
index d359209..d6f3acb 100644 (file)
@@ -123,6 +123,7 @@ static const nir_shader_compiler_options i915_compiler_options = {
    .force_indirect_unrolling = nir_var_all,
    .force_indirect_unrolling_sampler = true,
    .max_unroll_iterations = 32,
+   .no_integers = true,
 };
 
 static const struct nir_shader_compiler_options gallivm_nir_options = {
index ac50211..480a3f2 100644 (file)
@@ -498,6 +498,7 @@ static const nir_shader_compiler_options nv30_base_compiler_options = {
    .lower_vector_cmp = true,
    .force_indirect_unrolling_sampler = true,
    .max_unroll_iterations = 32,
+   .no_integers = true,
 
    .use_interpolated_input_intrinsics = true,
 };
index a6cd784..05c0ca2 100644 (file)
@@ -515,6 +515,7 @@ static const nir_shader_compiler_options r500_vs_compiler_options = {
    .max_unroll_iterations = 32,
 
    .use_interpolated_input_intrinsics = true,
+   .no_integers = true,
 };
 
 static const nir_shader_compiler_options r500_fs_compiler_options = {
@@ -543,6 +544,7 @@ static const nir_shader_compiler_options r500_fs_compiler_options = {
    .max_unroll_iterations = 32,
 
    .use_interpolated_input_intrinsics = true,
+   .no_integers = true,
 };
 
 static const nir_shader_compiler_options r300_vs_compiler_options = {
@@ -570,6 +572,7 @@ static const nir_shader_compiler_options r300_vs_compiler_options = {
    .max_unroll_iterations = 32,
 
    .use_interpolated_input_intrinsics = true,
+   .no_integers = true,
 };
 
 static const nir_shader_compiler_options r300_fs_compiler_options = {
@@ -597,6 +600,7 @@ static const nir_shader_compiler_options r300_fs_compiler_options = {
    .max_unroll_iterations = 64,
 
    .use_interpolated_input_intrinsics = true,
+   .no_integers = true,
 };
 
 static const void *