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 | 10 +++++++--- src/compiler/shader_info.h | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index ab0b263764..0a9a3d61ec 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 743f968035..d661a9c89b 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -55,9 +55,12 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len, shader->info.inputs_read |= bitfield; /* double inputs read is only for vertex inputs */ - if (shader->info.stage == MESA_SHADER_VERTEX && - glsl_type_is_dual_slot(glsl_without_array(var->type))) - shader->info.vs.double_inputs_read |= bitfield; + if (shader->info.stage == MESA_SHADER_VERTEX) { + if (glsl_type_is_dual_slot(glsl_without_array(var->type))) + shader->info.vs.double_inputs_read |= bitfield; + else if (glsl_get_bit_size(glsl_without_array(var->type)) == 16) + shader->info.vs.inputs_read_16bit |= bitfield; + } if (shader->info.stage == MESA_SHADER_FRAGMENT) { shader->info.fs.uses_sample_qualifier |= var->data.sample; @@ -380,6 +383,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) if (shader->info.stage == MESA_SHADER_VERTEX) { shader->info.vs.double_inputs = 0; shader->info.vs.double_inputs_read = 0; + shader->info.vs.inputs_read_16bit = 0; } if (shader->info.stage == MESA_SHADER_FRAGMENT) { shader->info.fs.uses_sample_qualifier = false; diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index e7fd7dbe62..645f05cd1b 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -113,6 +113,9 @@ typedef struct shader_info { /* 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; } vs; struct { -- 2.14.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev