nir_foreach_variable(var, var_list) {
if (var->data.location >= VARYING_SLOT_VAR0) {
var->data.location += 9;
+ } else if (var->data.location == VARYING_SLOT_PNTC) {
+ var->data.location = VARYING_SLOT_VAR8;
} else if ((var->data.location >= VARYING_SLOT_TEX0) &&
(var->data.location <= VARYING_SLOT_TEX7)) {
var->data.location += VARYING_SLOT_VAR0 - VARYING_SLOT_TEX0;
}
}
+static void
+st_shader_gather_info(nir_shader *nir, struct gl_program *prog)
+{
+ nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
+
+ /* Copy the info we just generated back into the gl_program */
+ const char *prog_name = prog->info.name;
+ const char *prog_label = prog->info.label;
+ prog->info = nir->info;
+ prog->info.name = prog_name;
+ prog->info.label = prog_label;
+}
+
/* input location assignment for VS inputs must be handled specially, so
* that it is aligned w/ st's vbo state.
* (This isn't the case with, for ex, FS inputs, which only need to agree
bool removed_inputs = false;
nir->num_inputs = util_bitcount64(nir->info.inputs_read);
- nir_foreach_variable_safe(var, &nir->inputs) {
+ nir_foreach_shader_in_variable_safe(var, nir) {
/* NIR already assigns dual-slot inputs to two locations so all we have
* to do is compact everything down.
*/
NIR_PASS(progress, nir, nir_remove_dead_variables,
(nir_variable_mode)(nir_var_function_temp |
nir_var_shader_temp |
- nir_var_mem_shared));
+ nir_var_mem_shared),
+ NULL);
NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
NIR_PASS(progress, nir, nir_opt_dead_write_vars);
if (!_mesa_is_gles(st->ctx) || !nir->info.separate_shader) {
nir_variable_mode mask =
(nir_variable_mode) (nir_var_shader_in | nir_var_shader_out);
- nir_remove_dead_variables(nir, mask);
+ nir_remove_dead_variables(nir, mask, NULL);
}
if (options->lower_all_io_to_temps ||
for (unsigned int i = 0; i < var->num_state_slots; i++) {
unsigned comps;
if (glsl_type_is_struct_or_ifc(type)) {
- /* Builtin struct require specical handling for now we just
- * make all members vec4. See st_nir_lower_builtin.
- */
- comps = 4;
+ comps = _mesa_program_state_value_size(slots[i].tokens);
} else {
comps = glsl_get_vector_elements(type);
}
st_set_prog_affected_state_flags(prog);
/* None of the builtins being lowered here can be produced by SPIR-V. See
- * _mesa_builtin_uniform_desc.
+ * _mesa_builtin_uniform_desc. Also drivers that support packed uniform
+ * storage don't need to lower builtins.
*/
- if (!shader_program->data->spirv)
+ if (!shader_program->data->spirv &&
+ !st->ctx->Const.PackedDriverUniformStorage)
NIR_PASS_V(nir, st_nir_lower_builtin);
NIR_PASS_V(nir, gl_nir_lower_atomics, shader_program, true);
nir_variable_mode mask = (nir_variable_mode)
(nir_var_shader_in | nir_var_shader_out | nir_var_function_temp );
- nir_remove_dead_variables(nir, mask);
+ nir_remove_dead_variables(nir, mask, NULL);
if (!st->has_hw_atomics)
NIR_PASS_V(nir, nir_lower_atomics_to_ssbo);
if (nir_link_opt_varyings(producer, consumer))
st_nir_opts(consumer);
- NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out);
- NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in);
+ NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out, NULL);
+ NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in, NULL);
if (nir_remove_unused_varyings(producer, consumer)) {
NIR_PASS_V(producer, nir_lower_global_vars_to_local);
* nir_compact_varyings() depends on all dead varyings being removed so
* we need to call nir_remove_dead_variables() again here.
*/
- NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out);
- NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in);
+ NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out,
+ NULL);
+ NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in,
+ NULL);
}
}
stp->shader_program = shader_program;
stp->state.type = PIPE_SHADER_IR_NIR;
- if (shader_program->data->spirv) {
- prog->Parameters = _mesa_new_parameter_list();
- /* Parameters will be filled during NIR linking. */
+ /* Parameters will be filled during NIR linking. */
+ prog->Parameters = _mesa_new_parameter_list();
+ if (shader_program->data->spirv) {
prog->nir = _mesa_spirv_to_nir(ctx, shader_program, shader->Stage, options);
} else {
validate_ir_tree(shader->ir);
- prog->Parameters = _mesa_new_parameter_list();
- _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
- prog->Parameters);
-
if (ctx->_Shader->Flags & GLSL_DUMP) {
_mesa_log("\n");
_mesa_log("GLSL IR for linked %s program %d:\n",
_mesa_log("\n\n");
}
- prog->ExternalSamplersUsed = gl_external_samplers(prog);
- _mesa_update_shader_textures_used(shader_program, prog);
-
prog->nir = glsl_to_nir(st->ctx, shader_program, shader->Stage, options);
st_nir_preprocess(st, prog, shader_program, shader->Stage);
}
if (!gl_nir_link_glsl(ctx, shader_program))
return GL_FALSE;
+ for (unsigned i = 0; i < num_shaders; i++) {
+ struct gl_program *prog = linked_shader[i]->Program;
+ prog->ExternalSamplersUsed = gl_external_samplers(prog);
+ _mesa_update_shader_textures_used(shader_program, prog);
+ }
+
nir_build_program_resource_list(ctx, shader_program, false);
}
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays);
- nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
- shader->Program->info = nir->info;
+ st_shader_gather_info(nir, shader->Program);
if (shader->Stage == MESA_SHADER_VERTEX) {
/* NIR expands dual-slot inputs out to two locations. We need to
* compact things back down GL-style single-slot inputs to avoid
if (prog) {
prog->info.textures_used = nir->info.textures_used;
prog->info.textures_used_by_txf = nir->info.textures_used_by_txf;
+ prog->info.images_used = nir->info.images_used;
}
}
st_nir_lower_uniforms(st, nir);
st_nir_lower_samplers(screen, nir, shader_program, prog);
+ if (!screen->get_param(screen, PIPE_CAP_NIR_IMAGES_AS_DEREF))
+ NIR_PASS_V(nir, gl_nir_lower_images, false);
if (finalize_by_driver && screen->finalize_nir)
screen->finalize_nir(screen, nir, false);