Skip to content

Commit

Permalink
i965/nir: Pass a is_scalar boolean to brw_create_nir()
Browse files Browse the repository at this point in the history
The upcoming introduction of NIR->vec4 pass will require that some NIR lowering
passes are enabled/disabled depending on the type of shader (scalar vs. vector).

With this patch we pass a 'is_scalar' variable to the process of constructing the
NIR, to let an external context decide how the shader should be handled.
  • Loading branch information
elima committed Jul 31, 2015
1 parent 1013ace commit 2d72ae5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/mesa/drivers/dri/i965/brw_nir.c
Expand Up @@ -61,7 +61,8 @@ 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)
gl_shader_stage stage,
bool is_scalar)
{
struct gl_context *ctx = &brw->ctx;
const nir_shader_compiler_options *options =
Expand Down
3 changes: 2 additions & 1 deletion src/mesa/drivers/dri/i965/brw_nir.h
Expand Up @@ -77,7 +77,8 @@ void brw_nir_analyze_boolean_resolves(nir_shader *nir);
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);
gl_shader_stage stage,
bool is_scalar);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions src/mesa/drivers/dri/i965/brw_program.c
Expand Up @@ -143,7 +143,7 @@ brwProgramStringNotify(struct gl_context *ctx,
brw_add_texrect_params(prog);

if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT].NirOptions) {
prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_FRAGMENT);
prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_FRAGMENT, true);
}

brw_fs_precompile(ctx, NULL, prog);
Expand All @@ -169,7 +169,7 @@ brwProgramStringNotify(struct gl_context *ctx,
brw_add_texrect_params(prog);

if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].NirOptions) {
prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_VERTEX);
prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_VERTEX, false);
}

brw_vs_precompile(ctx, NULL, prog);
Expand Down
6 changes: 4 additions & 2 deletions src/mesa/drivers/dri/i965/brw_shader.cpp
Expand Up @@ -398,8 +398,10 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)

brw_add_texrect_params(prog);

if (options->NirOptions)
prog->nir = brw_create_nir(brw, shProg, prog, (gl_shader_stage) stage);
if (options->NirOptions) {
prog->nir = brw_create_nir(brw, shProg, prog, (gl_shader_stage) stage,
is_scalar_shader_stage(brw, stage));
}

_mesa_reference_program(ctx, &prog, NULL);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mesa/drivers/dri/i965/brw_vec4.cpp
Expand Up @@ -1919,7 +1919,7 @@ brw_vs_emit(struct brw_context *brw,
*/
assert(vp->Base.Id == 0 && prog == NULL);
vp->Base.nir =
brw_create_nir(brw, NULL, &vp->Base, MESA_SHADER_VERTEX);
brw_create_nir(brw, NULL, &vp->Base, MESA_SHADER_VERTEX, false);
}

prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8;
Expand Down

0 comments on commit 2d72ae5

Please sign in to comment.