c->parameters = rzalloc(s, nir_variable);
c->parameters->type =
glsl_array_type(glsl_vec4_type(), prog->Parameters->NumParameters, 0);
- c->parameters->name = "parameters";
+ c->parameters->name = strdup(prog->Parameters->Parameters[0].Name);
c->parameters->data.read_only = true;
c->parameters->data.mode = nir_var_uniform;
exec_list_push_tail(&s->uniforms, &c->parameters->node);
#include "main/mtypes.h"
#include "program/prog_parameter.h"
#include "program/prog_print.h"
+#include "program/prog_to_nir.h"
#include "program/programopt.h"
#include "compiler/nir/nir.h"
}
}
+/**
+ * Translate ARB (asm) program to NIR
+ */
+static nir_shader *
+st_translate_prog_to_nir(struct st_context *st, struct gl_program *prog,
+ gl_shader_stage stage)
+{
+ enum pipe_shader_type p_stage = stage; /* valid for VS/FS */
+ const bool is_scalar =
+ st->pipe->screen->get_shader_param(st->pipe->screen, p_stage,
+ PIPE_SHADER_CAP_SCALAR_ISA);
+
+ const struct gl_shader_compiler_options *options =
+ &st->ctx->Const.ShaderCompilerOptions[stage];
+
+ /* Translate to NIR */
+ nir_shader *nir = prog_to_nir(prog, options->NirOptions);
+ NIR_PASS_V(nir, nir_lower_regs_to_ssa); /* turn registers into SSA */
+ nir_validate_shader(nir, "after st/ptn lower_regs_to_ssa");
+
+ NIR_PASS_V(nir, st_nir_lower_wpos_ytransform, prog, st->pipe->screen);
+ NIR_PASS_V(nir, nir_lower_system_values);
+
+ /* Optimise NIR */
+ NIR_PASS_V(nir, nir_opt_constant_folding);
+ st_nir_opts(nir, is_scalar);
+ nir_validate_shader(nir, "after st/ptn NIR opts");
+
+ return nir;
+}
+
/**
* Translate a vertex program.
*/
st_store_ir_in_disk_cache(st, &stvp->Base, false);
}
+ bool use_nir = PIPE_SHADER_IR_NIR ==
+ st->pipe->screen->get_shader_param(st->pipe->screen, PIPE_SHADER_VERTEX,
+ PIPE_SHADER_CAP_PREFERRED_IR);
+
+ if (use_nir) {
+ nir_shader *nir =
+ st_translate_prog_to_nir(st, &stvp->Base, MESA_SHADER_VERTEX);
+
+ stvp->tgsi.type = PIPE_SHADER_IR_NIR;
+ stvp->tgsi.ir.nir = nir;
+ return true;
+ }
+
return stvp->tgsi.tokens != NULL;
}
}
}
+
+ bool use_nir = PIPE_SHADER_IR_NIR ==
+ st->pipe->screen->get_shader_param(st->pipe->screen,
+ PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_CAP_PREFERRED_IR);
+
+ if (use_nir && !stfp->ati_fs) {
+ nir_shader *nir =
+ st_translate_prog_to_nir(st, &stfp->Base, MESA_SHADER_FRAGMENT);
+
+ stfp->tgsi.type = PIPE_SHADER_IR_NIR;
+ stfp->tgsi.ir.nir = nir;
+ return true;
+ }
+
/*
* Convert Mesa program inputs to TGSI input register semantics.
*/