}
void
-st_nir_opts(nir_shader *nir)
+st_nir_opts(nir_shader *nir, bool scalar)
{
bool progress;
do {
progress = false;
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
- NIR_PASS_V(nir, nir_lower_alu_to_scalar);
- NIR_PASS_V(nir, nir_lower_phis_to_scalar);
+
+ if (scalar) {
+ NIR_PASS_V(nir, nir_lower_alu_to_scalar);
+ NIR_PASS_V(nir, nir_lower_phis_to_scalar);
+ }
NIR_PASS_V(nir, nir_lower_alu);
NIR_PASS_V(nir, nir_lower_pack);
{
const nir_shader_compiler_options *options =
st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
+ enum pipe_shader_type type = pipe_shader_type_from_mesa(stage);
+ struct pipe_screen *screen = st->pipe->screen;
+ bool is_scalar = screen->get_shader_param(screen, type, PIPE_SHADER_CAP_SCALAR_ISA);
assert(options);
if (prog->nir)
NIR_PASS_V(nir, nir_split_var_copies);
NIR_PASS_V(nir, nir_lower_var_copies);
- st_nir_opts(nir);
+ st_nir_opts(nir, is_scalar);
return nir;
}
}
static void
-st_nir_link_shaders(nir_shader **producer, nir_shader **consumer)
+st_nir_link_shaders(nir_shader **producer, nir_shader **consumer, bool scalar)
{
nir_lower_io_arrays_to_elements(*producer, *consumer);
NIR_PASS_V(*producer, nir_lower_indirect_derefs, indirect_mask);
NIR_PASS_V(*consumer, nir_lower_indirect_derefs, indirect_mask);
- st_nir_opts(*producer);
- st_nir_opts(*consumer);
+ st_nir_opts(*producer, scalar);
+ st_nir_opts(*consumer, scalar);
}
}
struct gl_shader_program *shader_program)
{
struct st_context *st = st_context(ctx);
+ struct pipe_screen *screen = st->pipe->screen;
+ bool is_scalar[MESA_SHADER_STAGES];
+
+ /* Determine scalar property of each shader stage */
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *shader = shader_program->_LinkedShaders[i];
+ enum pipe_shader_type type;
+
+ if (shader == NULL)
+ continue;
+
+ type = pipe_shader_type_from_mesa(shader->Stage);
+ is_scalar[i] = screen->get_shader_param(screen, type, PIPE_SHADER_CAP_SCALAR_ISA);
+ }
/* Determine first and last stage. */
unsigned first = MESA_SHADER_STAGES;
nir_shader *nir = shader->Program->nir;
NIR_PASS_V(nir, nir_lower_io_to_scalar_early, mask);
- st_nir_opts(nir);
+ st_nir_opts(nir, is_scalar[i]);
}
/* Linking the stages in the opposite order (from fragment to vertex)
continue;
st_nir_link_shaders(&shader->Program->nir,
- &shader_program->_LinkedShaders[next]->Program->nir);
+ &shader_program->_LinkedShaders[next]->Program->nir,
+ is_scalar[i]);
next = i;
}