-nir_shader *
-brw_create_nir(struct brw_context *brw,
- const struct gl_shader_program *shader_prog,
- const struct gl_program *prog,
- gl_shader_stage stage,
- bool is_scalar)
-{
- struct gl_context *ctx = &brw->ctx;
- const nir_shader_compiler_options *options =
- ctx->Const.ShaderCompilerOptions[stage].NirOptions;
- bool progress;
- nir_shader *nir;
-
- /* First, lower the GLSL IR or Mesa IR to NIR */
- if (shader_prog) {
- nir = glsl_to_nir(shader_prog, stage, options);
- } else {
- nir = prog_to_nir(prog, options);
- OPT_V(nir_convert_to_ssa); /* turn registers into SSA */
- }
- nir_validate_shader(nir);
-
- (void)progress;
-
- nir = brw_preprocess_nir(nir, is_scalar);
-
- OPT(nir_lower_system_values);
- OPT_V(brw_nir_lower_uniforms, is_scalar);
-
- if (shader_prog) {
- OPT_V(nir_lower_samplers, shader_prog);
- OPT_V(nir_lower_atomics, shader_prog);
- }
-
- return nir;
-}
-