diff options
author | Jason Ekstrand <[email protected]> | 2017-09-14 19:52:38 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2017-10-20 12:49:17 -0700 |
commit | 59fb59ad54d368683d5cc3b149f021452bddc05f (patch) | |
tree | 734e742be190df8ae7a19a975c59ba7eeeded6eb /src/compiler/nir | |
parent | 341529dbee5c2b17fdcb7990484a383459bed305 (diff) |
nir: Get rid of nir_shader::stage
It's redundant with nir_shader::info::stage.
Acked-by: Timothy Arceri <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/compiler/nir')
22 files changed, 51 insertions, 48 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 5bc07b7e506..fe484516947 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -44,8 +44,12 @@ nir_shader_create(void *mem_ctx, shader->options = options; - if (si) + if (si) { + assert(si->stage == stage); shader->info = *si; + } else { + shader->info.stage = stage; + } exec_list_make_empty(&shader->functions); exec_list_make_empty(&shader->registers); @@ -58,8 +62,6 @@ nir_shader_create(void *mem_ctx, shader->num_uniforms = 0; shader->num_shared = 0; - shader->stage = stage; - return shader; } @@ -143,7 +145,7 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var) break; case nir_var_shared: - assert(shader->stage == MESA_SHADER_COMPUTE); + assert(shader->info.stage == MESA_SHADER_COMPUTE); exec_list_push_tail(&shader->shared, &var->node); break; @@ -162,8 +164,10 @@ nir_variable_create(nir_shader *shader, nir_variable_mode mode, var->type = type; var->data.mode = mode; - if ((mode == nir_var_shader_in && shader->stage != MESA_SHADER_VERTEX) || - (mode == nir_var_shader_out && shader->stage != MESA_SHADER_FRAGMENT)) + if ((mode == nir_var_shader_in && + shader->info.stage != MESA_SHADER_VERTEX) || + (mode == nir_var_shader_out && + shader->info.stage != MESA_SHADER_FRAGMENT)) var->data.interpolation = INTERP_MODE_SMOOTH; if (mode == nir_var_shader_in || mode == nir_var_uniform) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 70c23c2db99..dd833cf1831 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1904,9 +1904,6 @@ typedef struct nir_shader { * access plus one */ unsigned num_inputs, num_uniforms, num_outputs, num_shared; - - /** The shader stage, such as MESA_SHADER_VERTEX. */ - gl_shader_stage stage; } nir_shader; static inline nir_function_impl * diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index c13163f25c6..bcfdaa75942 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -737,7 +737,7 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s) clone_state state; init_clone_state(&state, NULL, true, false); - nir_shader *ns = nir_shader_create(mem_ctx, s->stage, s->options, NULL); + nir_shader *ns = nir_shader_create(mem_ctx, s->info.stage, s->options, NULL); state.ns = ns; clone_var_list(&state, &ns->uniforms, &s->uniforms); diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index f46cee7aa5e..7ae3ecc4425 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -53,7 +53,7 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len) else shader->info.inputs_read |= bitfield; - if (shader->stage == MESA_SHADER_FRAGMENT) { + if (shader->info.stage == MESA_SHADER_FRAGMENT) { shader->info.fs.uses_sample_qualifier |= var->data.sample; } } else { @@ -79,7 +79,7 @@ mark_whole_variable(nir_shader *shader, nir_variable *var) { const struct glsl_type *type = var->type; - if (nir_is_per_vertex_io(var, shader->stage)) { + if (nir_is_per_vertex_io(var, shader->info.stage)) { assert(glsl_type_is_array(type)); type = glsl_get_array_element(type); } @@ -129,7 +129,7 @@ try_mask_partial_io(nir_shader *shader, nir_deref_var *deref) nir_variable *var = deref->var; const struct glsl_type *type = var->type; - if (nir_is_per_vertex_io(var, shader->stage)) { + if (nir_is_per_vertex_io(var, shader->info.stage)) { assert(glsl_type_is_array(type)); type = glsl_get_array_element(type); } @@ -196,7 +196,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader) switch (instr->intrinsic) { case nir_intrinsic_discard: case nir_intrinsic_discard_if: - assert(shader->stage == MESA_SHADER_FRAGMENT); + assert(shader->info.stage == MESA_SHADER_FRAGMENT); shader->info.fs.uses_discard = true; break; @@ -214,7 +214,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader) /* We need to track which input_reads bits correspond to a * dvec3/dvec4 input attribute */ - if (shader->stage == MESA_SHADER_VERTEX && + if (shader->info.stage == MESA_SHADER_VERTEX && var->data.mode == nir_var_shader_in && glsl_type_is_dual_slot(glsl_without_array(var->type))) { for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); i++) { @@ -252,7 +252,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader) case nir_intrinsic_end_primitive: case nir_intrinsic_end_primitive_with_counter: - assert(shader->stage == MESA_SHADER_GEOMETRY); + assert(shader->info.stage == MESA_SHADER_GEOMETRY); shader->info.gs.uses_end_primitive = 1; break; @@ -327,7 +327,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) shader->info.patch_inputs_read = 0; shader->info.patch_outputs_written = 0; shader->info.system_values_read = 0; - if (shader->stage == MESA_SHADER_FRAGMENT) { + if (shader->info.stage == MESA_SHADER_FRAGMENT) { shader->info.fs.uses_sample_qualifier = false; } nir_foreach_block(block, entrypoint) { diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c index 5591f9be820..54ba1c85e58 100644 --- a/src/compiler/nir/nir_linking_helpers.c +++ b/src/compiler/nir/nir_linking_helpers.c @@ -75,7 +75,7 @@ tcs_add_output_reads(nir_shader *shader, uint64_t *read) nir_variable *var = intrin_instr->variables[0]->var; read[var->data.location_frac] |= get_variable_io_mask(intrin_instr->variables[0]->var, - shader->stage); + shader->info.stage); } } } @@ -102,7 +102,7 @@ remove_unused_io_vars(nir_shader *shader, struct exec_list *var_list, uint64_t other_stage = used_by_other_stage[var->data.location_frac]; - if (!(other_stage & get_variable_io_mask(var, shader->stage))) { + if (!(other_stage & get_variable_io_mask(var, shader->info.stage))) { /* This one is invalid, make it a global variable instead */ var->data.location = 0; var->data.mode = nir_var_global; @@ -120,26 +120,26 @@ remove_unused_io_vars(nir_shader *shader, struct exec_list *var_list, bool nir_remove_unused_varyings(nir_shader *producer, nir_shader *consumer) { - assert(producer->stage != MESA_SHADER_FRAGMENT); - assert(consumer->stage != MESA_SHADER_VERTEX); + assert(producer->info.stage != MESA_SHADER_FRAGMENT); + assert(consumer->info.stage != MESA_SHADER_VERTEX); uint64_t read[4] = { 0 }, written[4] = { 0 }; nir_foreach_variable(var, &producer->outputs) { written[var->data.location_frac] |= - get_variable_io_mask(var, producer->stage); + get_variable_io_mask(var, producer->info.stage); } nir_foreach_variable(var, &consumer->inputs) { read[var->data.location_frac] |= - get_variable_io_mask(var, consumer->stage); + get_variable_io_mask(var, consumer->info.stage); } /* Each TCS invocation can read data written by other TCS invocations, * so even if the outputs are not used by the TES we must also make * sure they are not read by the TCS before demoting them to globals. */ - if (producer->stage == MESA_SHADER_TESS_CTRL) + if (producer->info.stage == MESA_SHADER_TESS_CTRL) tcs_add_output_reads(producer, read); bool progress = false; diff --git a/src/compiler/nir/nir_lower_alpha_test.c b/src/compiler/nir/nir_lower_alpha_test.c index bd433b8ec66..6bf9ff142df 100644 --- a/src/compiler/nir/nir_lower_alpha_test.c +++ b/src/compiler/nir/nir_lower_alpha_test.c @@ -39,7 +39,7 @@ void nir_lower_alpha_test(nir_shader *shader, enum compare_func func, bool alpha_to_one) { - assert(shader->stage == MESA_SHADER_FRAGMENT); + assert(shader->info.stage == MESA_SHADER_FRAGMENT); nir_foreach_function(function, shader) { nir_function_impl *impl = function->impl; diff --git a/src/compiler/nir/nir_lower_atomics.c b/src/compiler/nir/nir_lower_atomics.c index 2252e1679be..bdab4b87377 100644 --- a/src/compiler/nir/nir_lower_atomics.c +++ b/src/compiler/nir/nir_lower_atomics.c @@ -100,7 +100,7 @@ lower_instr(nir_intrinsic_instr *instr, nir_intrinsic_instr *new_instr = nir_intrinsic_instr_create(mem_ctx, op); nir_intrinsic_set_base(new_instr, - shader_program->data->UniformStorage[uniform_loc].opaque[shader->stage].index); + shader_program->data->UniformStorage[uniform_loc].opaque[shader->info.stage].index); nir_load_const_instr *offset_const = nir_load_const_instr_create(mem_ctx, 1, 32); diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c index 9d04ae79dd8..a4d9498576c 100644 --- a/src/compiler/nir/nir_lower_bitmap.c +++ b/src/compiler/nir/nir_lower_bitmap.c @@ -133,7 +133,7 @@ void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options) { - assert(shader->stage == MESA_SHADER_FRAGMENT); + assert(shader->info.stage == MESA_SHADER_FRAGMENT); lower_bitmap_impl(nir_shader_get_entrypoint(shader), options); } diff --git a/src/compiler/nir/nir_lower_clamp_color_outputs.c b/src/compiler/nir/nir_lower_clamp_color_outputs.c index cc497351eee..55becbf769e 100644 --- a/src/compiler/nir/nir_lower_clamp_color_outputs.c +++ b/src/compiler/nir/nir_lower_clamp_color_outputs.c @@ -33,7 +33,7 @@ typedef struct { static bool is_color_output(lower_state *state, nir_variable *out) { - switch (state->shader->stage) { + switch (state->shader->info.stage) { case MESA_SHADER_VERTEX: case MESA_SHADER_GEOMETRY: switch (out->data.location) { diff --git a/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c b/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c index ea23a604ed1..95eda82139b 100644 --- a/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c +++ b/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c @@ -48,7 +48,7 @@ get_unwrapped_array_length(nir_shader *nir, nir_variable *var) * array length. */ const struct glsl_type *type = var->type; - if (nir_is_per_vertex_io(var, nir->stage)) + if (nir_is_per_vertex_io(var, nir->info.stage)) type = glsl_get_array_element(type); assert(glsl_type_is_array(type)); @@ -158,7 +158,7 @@ combine_clip_cull(nir_shader *nir, cull->data.location = VARYING_SLOT_CLIP_DIST0; } else { /* Turn the ClipDistance array into a combined one */ - update_type(clip, nir->stage, clip_array_size + cull_array_size); + update_type(clip, nir->info.stage, clip_array_size + cull_array_size); /* Rewrite CullDistance to reference the combined array */ nir_foreach_function(function, nir) { @@ -194,10 +194,10 @@ nir_lower_clip_cull_distance_arrays(nir_shader *nir) { bool progress = false; - if (nir->stage <= MESA_SHADER_GEOMETRY) + if (nir->info.stage <= MESA_SHADER_GEOMETRY) progress |= combine_clip_cull(nir, &nir->outputs, true); - if (nir->stage > MESA_SHADER_VERTEX) + if (nir->info.stage > MESA_SHADER_VERTEX) progress |= combine_clip_cull(nir, &nir->inputs, false); return progress; diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c index c01ae9e2536..acec9443431 100644 --- a/src/compiler/nir/nir_lower_drawpixels.c +++ b/src/compiler/nir/nir_lower_drawpixels.c @@ -252,7 +252,7 @@ nir_lower_drawpixels(nir_shader *shader, .shader = shader, }; - assert(shader->stage == MESA_SHADER_FRAGMENT); + assert(shader->info.stage == MESA_SHADER_FRAGMENT); nir_foreach_function(function, shader) { if (function->impl) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index bb1cdec9632..3879f0297d3 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -167,7 +167,7 @@ lower_load(nir_intrinsic_instr *intrin, struct lower_io_state *state, nir_intrinsic_op op; switch (mode) { case nir_var_shader_in: - if (nir->stage == MESA_SHADER_FRAGMENT && + if (nir->info.stage == MESA_SHADER_FRAGMENT && nir->options->use_interpolated_input_intrinsics && var->data.interpolation != INTERP_MODE_FLAT) { assert(vertex_index == NULL); @@ -412,7 +412,7 @@ nir_lower_io_block(nir_block *block, b->cursor = nir_before_instr(instr); - const bool per_vertex = nir_is_per_vertex_io(var, b->shader->stage); + const bool per_vertex = nir_is_per_vertex_io(var, b->shader->info.stage); nir_ssa_def *offset; nir_ssa_def *vertex_index = NULL; diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c index d2df14ed1e0..301ba658921 100644 --- a/src/compiler/nir/nir_lower_io_to_temporaries.c +++ b/src/compiler/nir/nir_lower_io_to_temporaries.c @@ -76,7 +76,7 @@ emit_copies(nir_cursor cursor, nir_shader *shader, struct exec_list *new_vars, static void emit_output_copies_impl(struct lower_io_state *state, nir_function_impl *impl) { - if (state->shader->stage == MESA_SHADER_GEOMETRY) { + if (state->shader->info.stage == MESA_SHADER_GEOMETRY) { /* For geometry shaders, we have to emit the output copies right * before each EmitVertex call. */ @@ -152,7 +152,7 @@ nir_lower_io_to_temporaries(nir_shader *shader, nir_function_impl *entrypoint, { struct lower_io_state state; - if (shader->stage == MESA_SHADER_TESS_CTRL) + if (shader->info.stage == MESA_SHADER_TESS_CTRL) return; state.shader = shader; diff --git a/src/compiler/nir/nir_lower_io_types.c b/src/compiler/nir/nir_lower_io_types.c index fb84b185be3..d31082e543e 100644 --- a/src/compiler/nir/nir_lower_io_types.c +++ b/src/compiler/nir/nir_lower_io_types.c @@ -131,7 +131,7 @@ lower_io_types_block(struct lower_io_types_state *state, nir_block *block) (var->data.mode != nir_var_shader_out)) continue; - bool vs_in = (state->shader->stage == MESA_SHADER_VERTEX) && + bool vs_in = (state->shader->info.stage == MESA_SHADER_VERTEX) && (var->data.mode == nir_var_shader_in); if (glsl_count_attribute_slots(var->type, vs_in) == 1) continue; diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c index f75fb1afe88..9aa4a9e967f 100644 --- a/src/compiler/nir/nir_lower_samplers.c +++ b/src/compiler/nir/nir_lower_samplers.c @@ -157,7 +157,8 @@ nir_lower_samplers(nir_shader *shader, nir_foreach_function(function, shader) { if (function->impl) - progress |= lower_impl(function->impl, shader_program, shader->stage); + progress |= lower_impl(function->impl, shader_program, + shader->info.stage); } return progress; diff --git a/src/compiler/nir/nir_lower_samplers_as_deref.c b/src/compiler/nir/nir_lower_samplers_as_deref.c index d2717840c94..bdbd8672f40 100644 --- a/src/compiler/nir/nir_lower_samplers_as_deref.c +++ b/src/compiler/nir/nir_lower_samplers_as_deref.c @@ -116,7 +116,7 @@ lower_deref(nir_deref_var *deref, nir_builder *b) { nir_variable *var = deref->var; - gl_shader_stage stage = state->shader->stage; + gl_shader_stage stage = state->shader->info.stage; unsigned location = var->data.location; unsigned binding; const struct glsl_type *orig_type = deref->deref.type; diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index c6f001b62ca..a50cb52d549 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -820,7 +820,8 @@ nir_lower_tex_block(nir_block *block, nir_builder *b, if ((nir_tex_instr_src_index(tex, nir_tex_src_lod) == -1) && (tex->op == nir_texop_txf || tex->op == nir_texop_txs || tex->op == nir_texop_txl || tex->op == nir_texop_query_levels || - (tex->op == nir_texop_tex && b->shader->stage != MESA_SHADER_FRAGMENT))) { + (tex->op == nir_texop_tex && + b->shader->info.stage != MESA_SHADER_FRAGMENT))) { b->cursor = nir_before_instr(&tex->instr); nir_tex_instr_add_src(tex, nir_tex_src_lod, nir_src_for_ssa(nir_imm_int(b, 0))); progress = true; diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c index 90da1013ec8..b6742ab2462 100644 --- a/src/compiler/nir/nir_lower_two_sided_color.c +++ b/src/compiler/nir/nir_lower_two_sided_color.c @@ -193,7 +193,7 @@ nir_lower_two_sided_color(nir_shader *shader) .shader = shader, }; - if (shader->stage != MESA_SHADER_FRAGMENT) + if (shader->info.stage != MESA_SHADER_FRAGMENT) return; if (setup_inputs(&state) != 0) diff --git a/src/compiler/nir/nir_lower_wpos_center.c b/src/compiler/nir/nir_lower_wpos_center.c index 478818d8d66..dca810d735e 100644 --- a/src/compiler/nir/nir_lower_wpos_center.c +++ b/src/compiler/nir/nir_lower_wpos_center.c @@ -105,7 +105,7 @@ nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading) bool progress = false; nir_builder b; - assert(shader->stage == MESA_SHADER_FRAGMENT); + assert(shader->info.stage == MESA_SHADER_FRAGMENT); nir_foreach_function(function, shader) { if (function->impl) { diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c b/src/compiler/nir/nir_lower_wpos_ytransform.c index 771c6ffe4a5..e2a3039241c 100644 --- a/src/compiler/nir/nir_lower_wpos_ytransform.c +++ b/src/compiler/nir/nir_lower_wpos_ytransform.c @@ -348,7 +348,7 @@ nir_lower_wpos_ytransform(nir_shader *shader, .shader = shader, }; - assert(shader->stage == MESA_SHADER_FRAGMENT); + assert(shader->info.stage == MESA_SHADER_FRAGMENT); nir_foreach_function(function, shader) { if (function->impl) diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index f4811fe8bc1..0c21e5ba1b5 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -416,7 +416,7 @@ print_var_decl(nir_variable *var, print_state *state) const char *loc = NULL; char buf[4]; - switch (state->shader->stage) { + switch (state->shader->info.stage) { case MESA_SHADER_VERTEX: if (var->data.mode == nir_var_shader_in) loc = gl_vert_attrib_name(var->data.location); @@ -1157,7 +1157,7 @@ nir_print_shader_annotated(nir_shader *shader, FILE *fp, state.annotations = annotations; - fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->stage)); + fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->info.stage)); if (shader->info.name) fprintf(fp, "name: %s\n", shader->info.name); @@ -1165,7 +1165,7 @@ nir_print_shader_annotated(nir_shader *shader, FILE *fp, if (shader->info.label) fprintf(fp, "label: %s\n", shader->info.label); - switch (shader->stage) { + switch (shader->info.stage) { case MESA_SHADER_COMPUTE: fprintf(fp, "local-size: %u, %u, %u%s\n", shader->info.cs.local_size[0], diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index cdbe6a6dced..2322c8f786d 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -973,7 +973,7 @@ validate_var_decl(nir_variable *var, bool is_global, validate_state *state) assert(glsl_type_is_array(var->type)); const struct glsl_type *type = glsl_get_array_element(var->type); - if (nir_is_per_vertex_io(var, state->shader->stage)) { + if (nir_is_per_vertex_io(var, state->shader->info.stage)) { assert(glsl_type_is_array(type)); assert(glsl_type_is_scalar(glsl_get_array_element(type))); } else { |