}; /* end of anonymous namespace */
-static const nir_shader_compiler_options default_options = {
-};
-
nir_shader *
-glsl_to_nir(exec_list *ir, _mesa_glsl_parse_state *state,
- bool native_integers)
+glsl_to_nir(exec_list *ir, bool native_integers,
+ const nir_shader_compiler_options *options)
{
- const nir_shader_compiler_options *options;
-
- if (state) {
- struct gl_context *ctx = state->ctx;
- struct gl_shader_compiler_options *gl_options =
- &ctx->Const.ShaderCompilerOptions[state->stage];
-
- if (!gl_options->NirOptions) {
- nir_shader_compiler_options *new_options =
- rzalloc(ctx, nir_shader_compiler_options);
- options = gl_options->NirOptions = new_options;
-
- if (gl_options->EmitNoPow)
- new_options->lower_fpow = true;
- } else {
- options = gl_options->NirOptions;
- }
- } else {
- options = &default_options;
- }
-
nir_shader *shader = nir_shader_create(NULL, options);
nir_visitor v1(shader, native_integers);
extern "C" {
#endif
-nir_shader *glsl_to_nir(exec_list * ir, _mesa_glsl_parse_state *state,
- bool native_integers);
+nir_shader *glsl_to_nir(exec_list *ir, bool native_integers,
+ const nir_shader_compiler_options *options);
#ifdef __cplusplus
}
#include "tnl/t_pipeline.h"
#include "util/ralloc.h"
+#include "glsl/nir/nir.h"
+
/***************************************
* Mesa's Driver Functions
***************************************/
ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 128;
}
+ static const nir_shader_compiler_options nir_options = {};
+
/* We want the GLSL compiler to emit code that uses condition codes */
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
ctx->Const.ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX;
(i == MESA_SHADER_FRAGMENT);
ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectUniform = false;
ctx->Const.ShaderCompilerOptions[i].LowerClipDistance = true;
+ ctx->Const.ShaderCompilerOptions[i].NirOptions = &nir_options;
}
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
void
fs_visitor::emit_nir_code()
{
+ const nir_shader_compiler_options *options =
+ ctx->Const.ShaderCompilerOptions[stage].NirOptions;
+
/* first, lower the GLSL IR shader to NIR */
lower_output_reads(shader->base.ir);
- nir_shader *nir = glsl_to_nir(shader->base.ir, NULL, true);
+ nir_shader *nir = glsl_to_nir(shader->base.ir, true, options);
nir_validate_shader(nir);
nir_lower_global_vars_to_local(nir);
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
- struct nir_shader_compiler_options *NirOptions;
+ const struct nir_shader_compiler_options *NirOptions;
};