From f41ae4d5926f36f433a1cfc85fb90298fa70775c Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Thu, 17 Dec 2020 22:01:06 -0800 Subject: [PATCH] spirv2nir: Add --opengl (-g) argument for OpenGL SPIR-V MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Tapani Pälli Part-of: --- 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 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;