Mesa (master): mesa/glspirv: pick off the only entry point we need

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


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

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Tue Jul 31 15:37:59 2018 +0200

mesa/glspirv: pick off the only entry point we need

This is the same we do for vulkan drivers

This is needed to pass the following CTS test:
KHR-GL45.gl_spirv.spirv_modules_shader_binary_multiple_shader_objects_test

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

---

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

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index 7af73efd58..5a2d6a4bb2 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -252,8 +252,23 @@ _mesa_spirv_to_nir(struct gl_context *ctx,
                       prog->Name);
    nir_validate_shader(nir);
 
+   /* We have to lower away local constant initializers right before we
+    * inline functions.  That way they get properly initialized at the top
+    * of the function and not at the top of its caller.
+    */
+   NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_local);
+   NIR_PASS_V(nir, nir_lower_returns);
+   NIR_PASS_V(nir, nir_inline_functions);
    NIR_PASS_V(nir, nir_copy_prop);
 
+   /* Pick off the single entrypoint that we want */
+   foreach_list_typed_safe(nir_function, func, node, &nir->functions) {
+      if (func != entry_point)
+         exec_node_remove(&func->node);
+   }
+   assert(exec_list_length(&nir->functions) == 1);
+   entry_point->name = ralloc_strdup(entry_point, "main");
+
    /* Split member structs.  We do this before lower_io_to_temporaries so that
     * it doesn't lower system values to temporaries by accident.
     */




More information about the mesa-commit mailing list