<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 17, 2017 at 10:05 AM, Jose Maria Casanova Crespo <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">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 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 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 *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 < glsl_count_attribute_slots(<wbr>var->type, false); i++) {<br>
- int idx = var->data.location + i;<br>
- shader->info.double_inputs_<wbr>read |= BITFIELD64_BIT(idx);<br>
+ var->data.mode == nir_var_shader_in) {<br>
+ if (glsl_type_is_dual_slot(glsl_<wbr>without_array(var->type))) {<br>
+ for (uint i = 0; i < glsl_count_attribute_slots(<wbr>var->type, false); i++) {<br>
+ int idx = var->data.location + i;<br>
+ shader->info.double_inputs_<wbr>read |= BITFIELD64_BIT(idx);<br>
+ }<br>
+ } else if (glsl_get_bit_size(glsl_<wbr>without_array(var->type)) == 16) {<br>
+ for (uint i = 0; i < glsl_count_attribute_slots(<wbr>var->type, false); i++) {<br>
+ int idx = var->data.location + i;<br>
+ shader->info.half_inputs_read |= BITFIELD64_BIT(idx);<br>
+ }<br>
}<br>
}<br>
}<br>
@@ -312,6 +318,7 @@ nir_shader_gather_info(nir_<wbr>shader *shader, 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></blockquote><div><br></div><div>Given that we're flagging this for 16-bit integers, I don't think "half" is really appropriate. How about just 16bit_inputs_read?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/* Which outputs are actually written */<br>
uint64_t outputs_written;<br>
/* Which outputs are actually read */<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.6<br>
<br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>