glsl: switch to a full nir based linker

This commit does 3 things at once (3 squashed commits) as required
to make sure the commit doesn't break things.

1. convert to nir at compile time
2. enable full nir linking
3. switch standalone compiler to nir linker

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31137>
This commit is contained in:
Timothy Arceri
2024-06-05 15:42:07 +10:00
committed by Marge Bot
parent 5108a9a37d
commit cbfc225e2b
13 changed files with 272 additions and 133 deletions
+14 -9
View File
@@ -36,7 +36,7 @@
#include "standalone_scaffolding.h"
#include "standalone.h"
#include "util/set.h"
#include "linker.h"
#include "gl_nir_linker.h"
#include "glsl_parser_extras.h"
#include "builtin_functions.h"
#include "main/mtypes.h"
@@ -44,6 +44,9 @@
static const struct standalone_options *options;
static const struct nir_shader_compiler_options nir_vs_options = { 0 };
static const struct nir_shader_compiler_options nir_fs_options = { 0 };
static void
initialize_context(struct gl_context *ctx, gl_api api)
{
@@ -51,6 +54,10 @@ initialize_context(struct gl_context *ctx, gl_api api)
_mesa_glsl_builtin_functions_init_or_ref();
ctx->Version = 450;
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].NirOptions =
&nir_fs_options;
ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT].NirOptions =
&nir_vs_options;
/* The standalone compiler needs to claim support for almost
* everything in order to compile the built-in functions.
@@ -305,15 +312,11 @@ load_text_file(void *ctx, const char *file_name)
static void
compile_shader(struct gl_context *ctx, struct gl_shader *shader)
{
_mesa_glsl_compile_shader(ctx, shader, options->dump_ast,
/* Print out the resulting IR if requested */
FILE *print_file = options->dump_lir ? stdout : NULL;
_mesa_glsl_compile_shader(ctx, shader, print_file, options->dump_ast,
options->dump_hir, true);
/* Print out the resulting IR */
if (shader->CompileStatus == COMPILE_SUCCESS && options->dump_lir) {
_mesa_print_ir(stdout, shader->ir, NULL);
}
return;
}
extern "C" struct gl_shader_program *
@@ -423,7 +426,9 @@ standalone_compile_shader(const struct standalone_options *_options,
if (status == EXIT_SUCCESS && options->do_link) {
_mesa_clear_shader_program_data(ctx, whole_program);
whole_program->data->LinkStatus = LINKING_SUCCESS;
link_shaders(ctx, whole_program);
gl_nir_link_glsl(ctx, whole_program);
status = (whole_program->data->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;