[Mesa-dev] [PATCH v4 29/44] compiler: Mark when input/ouput attribute at VS uses 16-bit
Jose Maria Casanova Crespo
jmcasanova at igalia.com
Thu Nov 30 02:57:09 UTC 2017
New shader attribute to mark when a location has 16-bit
value. This patch includes support on mesa glsl and nir.
v2: Remove use of is_half_slot as is a duplicate of is_16bit
(Topi Pohjolainen)
Renamed half_inputs_read to inputs_read_16bit (Jason Ekstrand)
---
src/compiler/glsl_types.h | 15 +++++++++++++++
src/compiler/nir/nir_gather_info.c | 17 ++++++++++++-----
src/compiler/shader_info.h | 2 ++
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index ee8aa71c75..4e1c4325f7 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -100,6 +100,13 @@ static inline bool glsl_base_type_is_integer(enum glsl_base_type type)
type == GLSL_TYPE_IMAGE;
}
+static inline bool glsl_base_type_is_16bit(enum glsl_base_type type)
+{
+ return type == GLSL_TYPE_FLOAT16 ||
+ type == GLSL_TYPE_UINT16 ||
+ type == GLSL_TYPE_INT16;
+}
+
enum glsl_sampler_dim {
GLSL_SAMPLER_DIM_1D = 0,
GLSL_SAMPLER_DIM_2D,
@@ -574,6 +581,14 @@ public:
return glsl_base_type_is_64bit(base_type);
}
+ /**
+ * Query whether or not a type is 16-bit
+ */
+ bool is_16bit() const
+ {
+ return glsl_base_type_is_16bit(base_type);
+ }
+
/**
* Query whether or not a type is a non-array boolean type
*/
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index 946939657e..e8724313bd 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -230,11 +230,17 @@ 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->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++) {
- int idx = var->data.location + i;
- shader->info.double_inputs_read |= BITFIELD64_BIT(idx);
+ var->data.mode == nir_var_shader_in) {
+ if (glsl_type_is_dual_slot(glsl_without_array(var->type))) {
+ for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); i++) {
+ int idx = var->data.location + i;
+ shader->info.double_inputs_read |= BITFIELD64_BIT(idx);
+ }
+ } else if (glsl_get_bit_size(glsl_without_array(var->type)) == 16) {
+ for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); i++) {
+ int idx = var->data.location + i;
+ shader->info.inputs_read_16bit |= BITFIELD64_BIT(idx);
+ }
}
}
}
@@ -357,6 +363,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
shader->info.outputs_read = 0;
shader->info.patch_outputs_read = 0;
shader->info.double_inputs_read = 0;
+ shader->info.inputs_read_16bit = 0;
shader->info.patch_inputs_read = 0;
shader->info.patch_outputs_written = 0;
shader->info.system_values_read = 0;
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index bcb3f0fffa..016751de8d 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -55,6 +55,8 @@ typedef struct shader_info {
uint64_t inputs_read;
/* Which inputs are actually read and are double */
uint64_t double_inputs_read;
+ /* Which inputs are actually read and are 16-bit type */
+ uint64_t inputs_read_16bit;
/* Which outputs are actually written */
uint64_t outputs_written;
/* Which outputs are actually read */
--
2.14.3
More information about the mesa-dev
mailing list