spirv2nir: Add --opengl (-g) argument for OpenGL SPIR-V
Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8156>
This commit is contained in:
parent
e550ca8888
commit
f41ae4d592
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue