<p dir="ltr"><br>
On Jul 6, 2016 6:59 PM, "Timothy Arceri" <<a href="mailto:timothy.arceri@collabora.com">timothy.arceri@collabora.com</a>> wrote:<br>
><br>
> ---<br>
> src/mesa/drivers/dri/i965/brw_fs.cpp | 20 ++++++++++++--------<br>
> src/mesa/drivers/dri/i965/brw_fs.h | 5 +++--<br>
> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 29 ++++++++++++++++++++---------<br>
> 3 files changed, 35 insertions(+), 19 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> index 2f473cc..9e7223e 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> @@ -1109,7 +1109,8 @@ fs_visitor::emit_general_interpolation(fs_reg *attr, const char *name,<br>
> const glsl_type *type,<br>
> glsl_interp_qualifier interpolation_mode,<br>
> int *location, bool mod_centroid,<br>
> - bool mod_sample)<br>
> + bool mod_sample,<br>
> + unsigned num_packed_components)<br>
> {<br>
> assert(stage == MESA_SHADER_FRAGMENT);<br>
> brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;<br>
> @@ -1131,22 +1132,26 @@ fs_visitor::emit_general_interpolation(fs_reg *attr, const char *name,<br>
><br>
> for (unsigned i = 0; i < length; i++) {<br>
> emit_general_interpolation(attr, name, elem_type, interpolation_mode,<br>
> - location, mod_centroid, mod_sample);<br>
> + location, mod_centroid, mod_sample,<br>
> + num_packed_components);<br>
> }<br>
> } else if (type->is_record()) {<br>
> for (unsigned i = 0; i < type->length; i++) {<br>
> const glsl_type *field_type = type->fields.structure[i].type;<br>
> emit_general_interpolation(attr, name, field_type, interpolation_mode,<br>
> - location, mod_centroid, mod_sample);<br>
> + location, mod_centroid, mod_sample,<br>
> + num_packed_components);<br>
> }<br>
> } else {<br>
> assert(type->is_scalar() || type->is_vector());<br>
> + unsigned num_components = num_packed_components ?<br>
> + num_packed_components : type->vector_elements;<br>
><br>
> if (prog_data->urb_setup[*location] == -1) {<br>
> /* If there's no incoming setup data for this slot, don't<br>
> * emit interpolation for it.<br>
> */<br>
> - *attr = offset(*attr, bld, type->vector_elements);<br>
> + *attr = offset(*attr, bld, num_components);</p>
<p dir="ltr">This appears to be the only interesting use of num_components. Pardon my while I ask a really stupid question: why can't we just make it always 4 and call it a day?</p>
<p dir="ltr">> (*location)++;<br>
> return;<br>
> }<br>
> @@ -1158,7 +1163,6 @@ fs_visitor::emit_general_interpolation(fs_reg *attr, const char *name,<br>
> * handed us defined values in only the constant offset<br>
> * field of the setup reg.<br>
> */<br>
> - unsigned vector_elements = type->vector_elements;<br>
><br>
> /* Data starts at suboffet 3 in 32-bit units (12 bytes), so it is not<br>
> * 64-bit aligned and the current implementation fails to read the<br>
> @@ -1166,10 +1170,10 @@ fs_visitor::emit_general_interpolation(fs_reg *attr, const char *name,<br>
> * read it as vector of floats with twice the number of components.<br>
> */<br>
> if (attr->type == BRW_REGISTER_TYPE_DF) {<br>
> - vector_elements *= 2;<br>
> + num_components *= 2;<br>
> attr->type = BRW_REGISTER_TYPE_F;<br>
> }<br>
> - for (unsigned int i = 0; i < vector_elements; i++) {<br>
> + for (unsigned int i = 0; i < num_components; i++) {<br>
> struct brw_reg interp = interp_reg(*location, i);<br>
> interp = suboffset(interp, 3);<br>
> interp.type = attr->type;<br>
> @@ -1178,7 +1182,7 @@ fs_visitor::emit_general_interpolation(fs_reg *attr, const char *name,<br>
> }<br>
> } else {<br>
> /* Smooth/noperspective interpolation case. */<br>
> - for (unsigned int i = 0; i < type->vector_elements; i++) {<br>
> + for (unsigned int i = 0; i < num_components; i++) {<br>
> struct brw_reg interp = interp_reg(*location, i);<br>
> if (devinfo->needs_unlit_centroid_workaround && mod_centroid) {<br>
> /* Get the pixel/sample mask into f0 so that we know<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h<br>
> index 1f88f8f..0c72802 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_fs.h<br>
> +++ b/src/mesa/drivers/dri/i965/brw_fs.h<br>
> @@ -181,7 +181,7 @@ public:<br>
> const glsl_type *type,<br>
> glsl_interp_qualifier interpolation_mode,<br>
> int *location, bool mod_centroid,<br>
> - bool mod_sample);<br>
> + bool mod_sample, unsigned num_components);<br>
> fs_reg *emit_vs_system_value(int location);<br>
> void emit_interpolation_setup_gen4();<br>
> void emit_interpolation_setup_gen6();<br>
> @@ -200,7 +200,8 @@ public:<br>
> void emit_nir_code();<br>
> void nir_setup_inputs();<br>
> void nir_setup_single_output_varying(fs_reg *reg, const glsl_type *type,<br>
> - unsigned *location);<br>
> + unsigned *location,<br>
> + unsigned num_components);<br>
> void nir_setup_outputs();<br>
> void nir_setup_uniforms();<br>
> void nir_emit_system_values();<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> index 04ed42e..a08297e 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> @@ -78,7 +78,8 @@ fs_visitor::nir_setup_inputs()<br>
> emit_general_interpolation(&input, var->name, var->type,<br>
> (glsl_interp_qualifier) var->data.interpolation,<br>
> &location, var->data.centroid,<br>
> - var->data.sample);<br>
> + var->data.sample,<br>
> + var->data.num_packed_components);<br>
> }<br>
> }<br>
> }<br>
> @@ -86,23 +87,27 @@ fs_visitor::nir_setup_inputs()<br>
> void<br>
> fs_visitor::nir_setup_single_output_varying(fs_reg *reg,<br>
> const glsl_type *type,<br>
> - unsigned *location)<br>
> + unsigned *location,<br>
> + unsigned num_packed_components)<br>
> {<br>
> if (type->is_array() || type->is_matrix()) {<br>
> const struct glsl_type *elem_type = glsl_get_array_element(type);<br>
> const unsigned length = glsl_get_length(type);<br>
><br>
> for (unsigned i = 0; i < length; i++) {<br>
> - nir_setup_single_output_varying(reg, elem_type, location);<br>
> + nir_setup_single_output_varying(reg, elem_type, location,<br>
> + num_packed_components);<br>
> }<br>
> } else if (type->is_record()) {<br>
> for (unsigned i = 0; i < type->length; i++) {<br>
> const struct glsl_type *field_type = type->fields.structure[i].type;<br>
> - nir_setup_single_output_varying(reg, field_type, location);<br>
> + nir_setup_single_output_varying(reg, field_type, location,<br>
> + num_packed_components);<br>
> }<br>
> } else {<br>
> assert(type->is_scalar() || type->is_vector());<br>
> - unsigned num_elements = type->vector_elements;<br>
> + unsigned num_elements = num_packed_components ? num_packed_components :<br>
> + type->vector_elements;<br>
> if (type->is_double())<br>
> num_elements *= 2;<br>
> for (unsigned count = 0; count < num_elements; count += 4) {<br>
> @@ -132,7 +137,8 @@ fs_visitor::nir_setup_outputs()<br>
> case MESA_SHADER_TESS_EVAL:<br>
> case MESA_SHADER_GEOMETRY: {<br>
> unsigned location = var->data.location;<br>
> - nir_setup_single_output_varying(®, var->type, &location);<br>
> + nir_setup_single_output_varying(®, var->type, &location,<br>
> + var->data.num_packed_components);<br>
> break;<br>
> }<br>
> case MESA_SHADER_FRAGMENT:<br>
> @@ -158,7 +164,9 @@ fs_visitor::nir_setup_outputs()<br>
> } else if (var->data.location == FRAG_RESULT_SAMPLE_MASK) {<br>
> this->sample_mask = reg;<br>
> } else {<br>
> - int vector_elements = var->type->without_array()->vector_elements;<br>
> + int vector_elements = var->data.num_packed_components ?<br>
> + var->data.num_packed_components :<br>
> + var->type->without_array()->vector_elements;<br>
><br>
> /* gl_FragData or a user-defined FS output */<br>
> assert(var->data.location >= FRAG_RESULT_DATA0 &&<br>
> @@ -3835,6 +3843,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr<br>
><br>
> case nir_intrinsic_load_input: {<br>
> fs_reg src;<br>
> + unsigned first_component = nir_intrinsic_component(instr);<br>
> unsigned num_components = instr->num_components;<br>
> enum brw_reg_type type = dest.type;<br>
><br>
> @@ -3859,7 +3868,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr<br>
> src = offset(src, bld, const_offset->u32[0]);<br>
><br>
> for (unsigned j = 0; j < num_components; j++) {<br>
> - bld.MOV(offset(dest, bld, j), offset(src, bld, j));<br>
> + bld.MOV(offset(dest, bld, j), offset(src, bld, j + first_component));<br>
> }<br>
><br>
> if (type == BRW_REGISTER_TYPE_DF) {<br>
> @@ -3985,6 +3994,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr<br>
> new_dest = offset(new_dest, bld, const_offset->u32[0]);<br>
><br>
> unsigned num_components = instr->num_components;<br>
> + unsigned first_component = nir_intrinsic_component(instr);<br>
> unsigned bit_size = instr->src[0].is_ssa ?<br>
> instr->src[0].ssa->bit_size : instr->src[0].reg.reg->bit_size;<br>
> if (bit_size == 64) {<br>
> @@ -3998,7 +4008,8 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr<br>
> }<br>
><br>
> for (unsigned j = 0; j < num_components; j++) {<br>
> - bld.MOV(offset(new_dest, bld, j), offset(src, bld, j));<br>
> + bld.MOV(offset(new_dest, bld, j + first_component),<br>
> + offset(src, bld, j));<br>
> }<br>
> break;<br>
> }<br>
> --<br>
> 2.7.4<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>