<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Nov 2, 2017 at 11:17 AM, Chema Casanova <span dir="ltr"><<a href="mailto:jmcasanova@igalia.com" target="_blank">jmcasanova@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
El 01/11/17 a las 22:07, Jason Ekstrand escribió:<br>
<span class="">> On Tue, Oct 17, 2017 at 10:05 AM, Jose Maria Casanova Crespo<br>
</span><div><div class="h5">> <<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a> <mailto:<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a>><wbr>> wrote:<br>
><br>
> New shader attribute to mark when a location has 16-bit<br>
> value. This patch includes support on mesa glsl and nir.<br>
><br>
> v2: Remove use of is_half_slot as is a duplicate of is_16bit<br>
> (Topi Pohjolainen)<br>
> ---<br>
> src/compiler/glsl_types.h | 15 +++++++++++++++<br>
> src/compiler/nir/nir_gather_<wbr>info.c | 21 ++++++++++++++-------<br>
> src/compiler/shader_info.h | 2 ++<br>
> 3 files changed, 31 insertions(+), 7 deletions(-)<br>
><br>
> diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h<br>
> index 32399df351..e35e8d8f88 100644<br>
> --- a/src/compiler/glsl_types.h<br>
> +++ b/src/compiler/glsl_types.h<br>
> @@ -93,6 +93,13 @@ static inline bool<br>
> glsl_base_type_is_integer(enum glsl_base_type type)<br>
> type == GLSL_TYPE_IMAGE;<br>
> }<br>
><br>
> +static inline bool glsl_base_type_is_16bit(enum glsl_base_type type)<br>
> +{<br>
> + return type == GLSL_TYPE_FLOAT16 ||<br>
> + type == GLSL_TYPE_UINT16 ||<br>
> + type == GLSL_TYPE_INT16;<br>
> +}<br>
> +<br>
> enum glsl_sampler_dim {<br>
> GLSL_SAMPLER_DIM_1D = 0,<br>
> GLSL_SAMPLER_DIM_2D,<br>
> @@ -555,6 +562,14 @@ struct glsl_type {<br>
> }<br>
><br>
> /**<br>
> + * Query whether or not a type is 16-bit<br>
> + */<br>
> + bool is_16bit() const<br>
> + {<br>
> + return glsl_base_type_is_16bit(base_<wbr>type);<br>
> + }<br>
> +<br>
> + /**<br>
> * Query whether or not a type is a non-array boolean type<br>
> */<br>
> bool is_boolean() const<br>
> diff --git a/src/compiler/nir/nir_gather_<wbr>info.c<br>
> b/src/compiler/nir/nir_gather_<wbr>info.c<br>
> index ac87bec46c..cce64f9c84 100644<br>
> --- a/src/compiler/nir/nir_gather_<wbr>info.c<br>
> +++ b/src/compiler/nir/nir_gather_<wbr>info.c<br>
> @@ -212,14 +212,20 @@ gather_intrinsic_info(nir_<wbr>intrinsic_instr<br>
> *instr, nir_shader *shader)<br>
> if (!try_mask_partial_io(shader, instr->variables[0]))<br>
> mark_whole_variable(shader, var);<br>
><br>
> - /* We need to track which input_reads bits correspond to a<br>
> - * dvec3/dvec4 input attribute */<br>
> + /* We need to track which input_reads bits correspond to<br>
> + * dvec3/dvec4 or 16-bit input attributes */<br>
> if (shader->stage == MESA_SHADER_VERTEX &&<br>
> - var->data.mode == nir_var_shader_in &&<br>
> - glsl_type_is_dual_slot(glsl_<wbr>without_array(var->type))) {<br>
> - for (uint i = 0; i <<br>
> glsl_count_attribute_slots(<wbr>var->type, false); i++) {<br>
> - int idx = var->data.location + i;<br>
> - shader->info.double_inputs_<wbr>read |=<br>
> BITFIELD64_BIT(idx);<br>
> + var->data.mode == nir_var_shader_in) {<br>
> + if<br>
> (glsl_type_is_dual_slot(glsl_<wbr>without_array(var->type))) {<br>
> + for (uint i = 0; i <<br>
> glsl_count_attribute_slots(<wbr>var->type, false); i++) {<br>
> + int idx = var->data.location + i;<br>
> + shader->info.double_inputs_<wbr>read |=<br>
> BITFIELD64_BIT(idx);<br>
> + }<br>
> + } else if<br>
> (glsl_get_bit_size(glsl_<wbr>without_array(var->type)) == 16) {<br>
> + for (uint i = 0; i <<br>
> glsl_count_attribute_slots(<wbr>var->type, false); i++) {<br>
> + int idx = var->data.location + i;<br>
> + shader->info.half_inputs_read |=<br>
> BITFIELD64_BIT(idx);<br>
> + }<br>
> }<br>
> }<br>
> }<br>
> @@ -312,6 +318,7 @@ nir_shader_gather_info(nir_<wbr>shader *shader,<br>
> nir_function_impl *entrypoint)<br>
> shader->info.outputs_written = 0;<br>
> shader->info.outputs_read = 0;<br>
> shader->info.double_inputs_<wbr>read = 0;<br>
> + shader->info.half_inputs_read = 0;<br>
> shader->info.patch_inputs_read = 0;<br>
> shader->info.patch_outputs_<wbr>written = 0;<br>
> shader->info.system_values_<wbr>read = 0;<br>
> diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h<br>
> index 38413940d6..98111fa1e0 100644<br>
> --- a/src/compiler/shader_info.h<br>
> +++ b/src/compiler/shader_info.h<br>
> @@ -55,6 +55,8 @@ typedef struct shader_info {<br>
> uint64_t inputs_read;<br>
> /* Which inputs are actually read and are double */<br>
> uint64_t double_inputs_read;<br>
> + /* Which inputs are actually read and are half */<br>
> + uint64_t half_inputs_read;<br>
><br>
><br>
> Given that we're flagging this for 16-bit integers, I don't think<br>
> "half" is really appropriate. How about just 16bit_inputs_read?<br>
<br>
</div></div>I thought about that, but we can not do that. As the C restriction of<br>
variable names starting with alphabet or underscore. As the logic was<br>
the same as for double I didn't want to go for a inputs_read_16bits. I<br>
didn't come up with a better name. :(<span class=""></span><br></blockquote><div><br></div><div>Ugh. :-( You could always do _16bit_inputs_read. Or inputs_read_16bit. Really the double one will probably have to get renamed too since we have int64.<br></div></div></div></div>