nir/glsl: make nir_remap_attributes public
authorAlejandro Piñeiro <apinheiro@igalia.com>
Wed, 21 Mar 2018 08:39:32 +0000 (09:39 +0100)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Mon, 13 Aug 2018 14:28:27 +0000 (16:28 +0200)
As we plan to reuse it for ARB_gl_spirv implementation.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/nir/nir.c
src/compiler/nir/nir.h

index 1e4d9f9d3c83b0e8d3e5c0d07140434d6dd95a83..b1d1da891111752bcaaddc0e942ee27130bdab49 100644 (file)
@@ -128,23 +128,6 @@ private:
 
 } /* end of anonymous namespace */
 
-static void
-nir_remap_attributes(nir_shader *shader,
-                     const nir_shader_compiler_options *options)
-{
-   if (options->vs_inputs_dual_locations) {
-      nir_foreach_variable(var, &shader->inputs) {
-         var->data.location +=
-            _mesa_bitcount_64(shader->info.vs.double_inputs &
-                              BITFIELD64_MASK(var->data.location));
-      }
-   }
-
-   /* Once the remap is done, reset double_inputs_read, so later it will have
-    * which location/slots are doubles */
-   shader->info.vs.double_inputs = 0;
-}
-
 nir_shader *
 glsl_to_nir(const struct gl_shader_program *shader_prog,
             gl_shader_stage stage,
index 5e76654ca3d655a898f09f775f2b93fcb7fc5235..e12aa5d80f56ef6aa5c981211c3bd27f29736f65 100644 (file)
@@ -32,6 +32,9 @@
 #include <assert.h>
 #include <math.h>
 
+#include "main/imports.h" /* _mesa_bitcount_64 */
+#include "main/menums.h" /* BITFIELD64_MASK */
+
 nir_shader *
 nir_shader_create(void *mem_ctx,
                   gl_shader_stage stage,
@@ -1847,3 +1850,24 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       unreachable("intrinsic doesn't produce a system value");
    }
 }
+
+/* OpenGL utility method that remaps the location attributes if they are
+ * doubles. Not needed for vulkan due the differences on the input location
+ * count for doubles on vulkan vs OpenGL
+ */
+void
+nir_remap_attributes(nir_shader *shader,
+                     const nir_shader_compiler_options *options)
+{
+   if (options->vs_inputs_dual_locations) {
+      nir_foreach_variable(var, &shader->inputs) {
+         var->data.location +=
+            _mesa_bitcount_64(shader->info.vs.double_inputs &
+                              BITFIELD64_MASK(var->data.location));
+      }
+   }
+
+   /* Once the remap is done, reset double_inputs_read, so later it will have
+    * which location/slots are doubles */
+   shader->info.vs.double_inputs = 0;
+}
index 1ccbccc8bbb1c9dc6f8651437b659617c0025387..d0fa693884b5c07fb25b811952d27d28d5889f7f 100644 (file)
@@ -2999,6 +2999,9 @@ bool nir_opt_conditional_discard(nir_shader *shader);
 
 void nir_sweep(nir_shader *shader);
 
+void nir_remap_attributes(nir_shader *shader,
+                          const nir_shader_compiler_options *options);
+
 nir_intrinsic_op nir_intrinsic_from_system_value(gl_system_value val);
 gl_system_value nir_system_value_from_intrinsic(nir_intrinsic_op intrin);