X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fnir%2Fnir_gather_info.c;h=b6e6b0afd1f2da62c23445645302d6db8fef8778;hb=fd73ed1bd7e4d5a6af05d29908d6c4e2cca868b5;hp=30f0bc721d4292f267f8a08a6ace3d182ebdd87c;hpb=44ec31cd75f679b32afb03c3c9c46762e57ce506;p=mesa.git diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index 30f0bc721d4..b6e6b0afd1f 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -108,13 +108,11 @@ get_io_offset(nir_deref_instr *deref, bool is_vertex_input) for (nir_deref_instr *d = deref; d; d = nir_deref_instr_parent(d)) { if (d->deref_type == nir_deref_type_array) { - nir_const_value *const_index = nir_src_as_const_value(d->arr.index); - - if (!const_index) + if (!nir_src_is_const(d->arr.index)) return -1; offset += glsl_count_attribute_slots(d->type, is_vertex_input) * - const_index->u32[0]; + nir_src_as_uint(d->arr.index); } /* TODO: we can get the offset for structs here see nir_lower_io() */ } @@ -200,6 +198,8 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, void *dead_ctx) { switch (instr->intrinsic) { + case nir_intrinsic_demote: + case nir_intrinsic_demote_if: case nir_intrinsic_discard: case nir_intrinsic_discard_if: assert(shader->info.stage == MESA_SHADER_FRAGMENT); @@ -212,10 +212,9 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, case nir_intrinsic_load_deref: case nir_intrinsic_store_deref:{ nir_deref_instr *deref = nir_src_as_deref(instr->src[0]); - nir_variable *var = nir_deref_instr_get_variable(deref); - - if (var->data.mode == nir_var_shader_in || - var->data.mode == nir_var_shader_out) { + if (deref->mode == nir_var_shader_in || + deref->mode == nir_var_shader_out) { + nir_variable *var = nir_deref_instr_get_variable(deref); bool is_output_read = false; if (var->data.mode == nir_var_shader_out && instr->intrinsic == nir_intrinsic_load_deref) @@ -240,6 +239,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, case nir_intrinsic_load_draw_id: case nir_intrinsic_load_frag_coord: + case nir_intrinsic_load_point_coord: case nir_intrinsic_load_front_face: case nir_intrinsic_load_vertex_id: case nir_intrinsic_load_vertex_id_zero_base: @@ -265,6 +265,14 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, (1ull << nir_system_value_from_intrinsic(instr->intrinsic)); break; + case nir_intrinsic_quad_broadcast: + case nir_intrinsic_quad_swap_horizontal: + case nir_intrinsic_quad_swap_vertical: + case nir_intrinsic_quad_swap_diagonal: + if (shader->info.stage == MESA_SHADER_FRAGMENT) + shader->info.fs.needs_helper_invocations = true; + break; + case nir_intrinsic_end_primitive: case nir_intrinsic_end_primitive_with_counter: assert(shader->info.stage == MESA_SHADER_GEOMETRY); @@ -285,17 +293,14 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader, static void gather_tex_info(nir_tex_instr *instr, nir_shader *shader) { + if (shader->info.stage == MESA_SHADER_FRAGMENT && + nir_tex_instr_has_implicit_derivative(instr)) + shader->info.fs.needs_helper_invocations = true; + switch (instr->op) { case nir_texop_tg4: shader->info.uses_texture_gather = true; break; - case nir_texop_txf: - case nir_texop_txf_ms: - case nir_texop_txf_ms_mcs: - shader->info.textures_used_by_txf |= - ((1 << MAX2(instr->texture_array_size, 1)) - 1) << - instr->texture_index; - break; default: break; } @@ -308,10 +313,23 @@ gather_alu_info(nir_alu_instr *instr, nir_shader *shader) case nir_op_fddx: case nir_op_fddy: shader->info.uses_fddx_fddy = true; + /* Fall through */ + case nir_op_fddx_fine: + case nir_op_fddy_fine: + case nir_op_fddx_coarse: + case nir_op_fddy_coarse: + if (shader->info.stage == MESA_SHADER_FRAGMENT) + shader->info.fs.needs_helper_invocations = true; break; default: break; } + + shader->info.uses_64bit |= instr->dest.dest.ssa.bit_size == 64; + unsigned num_srcs = nir_op_infos[instr->op].num_inputs; + for (unsigned i = 0; i < num_srcs; i++) { + shader->info.uses_64bit |= nir_src_bit_size(instr->src[i].src) == 64; + } } static void @@ -337,48 +355,6 @@ gather_info_block(nir_block *block, nir_shader *shader, void *dead_ctx) } } -static unsigned -glsl_type_get_sampler_count(const struct glsl_type *type) -{ - if (glsl_type_is_array(type)) { - return (glsl_get_aoa_size(type) * - glsl_type_get_sampler_count(glsl_without_array(type))); - } - - if (glsl_type_is_struct(type)) { - unsigned count = 0; - for (int i = 0; i < glsl_get_length(type); i++) - count += glsl_type_get_sampler_count(glsl_get_struct_field(type, i)); - return count; - } - - if (glsl_type_is_sampler(type)) - return 1; - - return 0; -} - -static unsigned -glsl_type_get_image_count(const struct glsl_type *type) -{ - if (glsl_type_is_array(type)) { - return (glsl_get_aoa_size(type) * - glsl_type_get_image_count(glsl_without_array(type))); - } - - if (glsl_type_is_struct(type)) { - unsigned count = 0; - for (int i = 0; i < glsl_get_length(type); i++) - count += glsl_type_get_image_count(glsl_get_struct_field(type, i)); - return count; - } - - if (glsl_type_is_image(type)) - return 1; - - return 0; -} - void nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) {