Mesa (master): mesa/glspirv: compute double inputs and remap attributes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 13 14:30:37 UTC 2018


Module: Mesa
Branch: master
Commit: 32e1d4c34b3d153ce20726a39eac5f93d8ef26dc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=32e1d4c34b3d153ce20726a39eac5f93d8ef26dc

Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date:   Wed Mar 21 09:05:51 2018 +0100

mesa/glspirv: compute double inputs and remap attributes

input locations used by input attributes are not handled in the same
way in OpenGL vs Vulkan. There is a detailed explanation of such
differences on the following commit:

c2acf97fcc9b32eaa9778771282758e5652a8ad4

So with this commit, the same adjustment that is done after
glsl_to_nir, is being done after spirv_to_nir, when it is used on
OpenGL (ARB_gl_spirv).

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/mesa/main/glspirv.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index 87075a547c..7af73efd58 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -182,6 +182,20 @@ _mesa_spirv_link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       prog->last_vert_prog = prog->_LinkedShaders[last_vert_stage - 1]->Program;
 }
 
+static void
+nir_compute_double_inputs(nir_shader *shader,
+                          const nir_shader_compiler_options *options)
+{
+   nir_foreach_variable(var, &shader->inputs) {
+      if (glsl_type_is_dual_slot(glsl_without_array(var->type))) {
+         for (uint i = 0; i < glsl_count_attribute_slots(var->type, true); i++) {
+            uint64_t bitfield = BITFIELD64_BIT(var->data.location + i);
+            shader->info.vs.double_inputs |= bitfield;
+         }
+      }
+   }
+}
+
 nir_shader *
 _mesa_spirv_to_nir(struct gl_context *ctx,
                    const struct gl_shader_program *prog,
@@ -246,6 +260,11 @@ _mesa_spirv_to_nir(struct gl_context *ctx,
    NIR_PASS_V(nir, nir_split_var_copies);
    NIR_PASS_V(nir, nir_split_per_member_structs);
 
+   if (nir->info.stage == MESA_SHADER_VERTEX) {
+      nir_compute_double_inputs(nir, options);
+      nir_remap_attributes(nir, options);
+   }
+
    return nir;
 }
 




More information about the mesa-commit mailing list