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

Author: Caio Marcelo de Oliveira Filho <[email protected]>
Date:   Thu Dec 17 22:01:06 2020 -0800

spirv2nir: Add --opengl (-g) argument for OpenGL SPIR-V

Reviewed-by: Tapani Pälli <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8156>

---

 src/compiler/spirv/spirv2nir.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/compiler/spirv/spirv2nir.c b/src/compiler/spirv/spirv2nir.c
index c6dfab0d366..fed803e92a2 100644
--- a/src/compiler/spirv/spirv2nir.c
+++ b/src/compiler/spirv/spirv2nir.c
@@ -76,6 +76,8 @@ print_usage(char *exec_name, FILE *f)
 "                          vertex, tess-ctrl, tess-eval, geometry, fragment,\n"
 "                          compute, and kernel (OpenCL-style compute).\n"
 "  -e, --entry <name>      Specify the entry-point name.\n"
+"  -g, --opengl            Use OpenGL environment instead of Vulkan for\n"
+"                          graphics stages.\n"
    , exec_name);
 }
 
@@ -84,16 +86,18 @@ int main(int argc, char **argv)
    gl_shader_stage shader_stage = MESA_SHADER_FRAGMENT;
    char *entry_point = "main";
    int ch;
+   enum nir_spirv_execution_environment env = NIR_SPIRV_VULKAN;
 
    static struct option long_options[] =
      {
        {"help",         no_argument, 0, 'h'},
        {"stage",  required_argument, 0, 's'},
        {"entry",  required_argument, 0, 'e'},
+       {"opengl",       no_argument, 0, 'g'},
        {0, 0, 0, 0}
      };
 
-   while ((ch = getopt_long(argc, argv, "hs:e:", long_options, NULL)) != -1)
+   while ((ch = getopt_long(argc, argv, "hs:e:g", long_options, NULL)) != -1)
    {
       switch (ch)
       {
@@ -112,6 +116,9 @@ int main(int argc, char **argv)
       case 'e':
          entry_point = optarg;
          break;
+      case 'g':
+         env = NIR_SPIRV_OPENGL;
+         break;
       default:
          fprintf(stderr, "Unrecognized option \"%s\".\n", optarg);
          print_usage(argv[0], stderr);
@@ -149,7 +156,11 @@ int main(int argc, char **argv)
 
    glsl_type_singleton_init_or_ref();
 
-   struct spirv_to_nir_options spirv_opts = {0};
+   struct spirv_to_nir_options spirv_opts = {
+      .environment = env,
+      .use_deref_buffer_array_length = env == NIR_SPIRV_OPENGL,
+   };
+
    if (shader_stage == MESA_SHADER_KERNEL) {
       spirv_opts.environment = NIR_SPIRV_OPENCL;
       spirv_opts.caps.address = true;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to