diff options
author | Eric Anholt <[email protected]> | 2020-01-06 11:37:38 -0800 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-01-14 23:55:00 +0000 |
commit | 74ee3f76deec064577b2ce33b6a7ec9828868d57 (patch) | |
tree | f28104909fa0b512881acdc4746de1b76f896387 /src/compiler | |
parent | b807f7a43a4df6a13ec365a4c2f152a81e64731b (diff) |
mesa/st: Move the vec4 type size function into core GLSL types.
The only bit that gallium varied on was handling of bindless. We can
retain previous behavior for count_attribute_slots() by passing in
"true" (though I suspect this is just giving a silly answer to a silly
question), and delete our recursive function from mesa/st.
Reviewed-by: Kristian H. Kristensen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3297>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl_types.cpp | 16 | ||||
-rw-r--r-- | src/compiler/glsl_types.h | 13 | ||||
-rw-r--r-- | src/compiler/nir_types.cpp | 7 | ||||
-rw-r--r-- | src/compiler/nir_types.h | 2 |
4 files changed, 32 insertions, 6 deletions
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index c958cc4b90d..a814166f9e5 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -2432,7 +2432,7 @@ glsl_type::get_explicit_type_for_size_align(glsl_type_size_align_func type_info, } unsigned -glsl_type::count_attribute_slots(bool is_gl_vertex_input) const +glsl_type::count_vec4_slots(bool is_gl_vertex_input, bool is_bindless) const { /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: * @@ -2469,8 +2469,6 @@ glsl_type::count_attribute_slots(bool is_gl_vertex_input) const case GLSL_TYPE_FLOAT: case GLSL_TYPE_FLOAT16: case GLSL_TYPE_BOOL: - case GLSL_TYPE_SAMPLER: - case GLSL_TYPE_IMAGE: return this->matrix_columns; case GLSL_TYPE_DOUBLE: case GLSL_TYPE_UINT64: @@ -2485,7 +2483,7 @@ glsl_type::count_attribute_slots(bool is_gl_vertex_input) const for (unsigned i = 0; i < this->length; i++) { const glsl_type *member_type = this->fields.structure[i].type; - size += member_type->count_attribute_slots(is_gl_vertex_input); + size += member_type->count_vec4_slots(is_gl_vertex_input, is_bindless); } return size; @@ -2493,9 +2491,17 @@ glsl_type::count_attribute_slots(bool is_gl_vertex_input) const case GLSL_TYPE_ARRAY: { const glsl_type *element = this->fields.array; - return this->length * element->count_attribute_slots(is_gl_vertex_input); + return this->length * element->count_vec4_slots(is_gl_vertex_input, + is_bindless); } + case GLSL_TYPE_SAMPLER: + case GLSL_TYPE_IMAGE: + if (!is_bindless) + return 0; + else + return 1; + case GLSL_TYPE_SUBROUTINE: return 1; diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 10596603887..c29d589a148 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -473,6 +473,15 @@ public: unsigned varying_count() const; /** + * Calculate the number of vec4 slots required to hold this type. + * + * This is the underlying recursive type_size function for + * count_attribute_slots() (vertex inputs and varyings) but also for + * gallium's !PIPE_CAP_PACKED_UNIFORMS case. + */ + unsigned count_vec4_slots(bool is_gl_vertex_input, bool bindless) const; + + /** * Calculate the number of attribute slots required to hold this type * * This implements the language rules of GLSL 1.50 for counting the number @@ -487,7 +496,9 @@ public: * Vulkan doesn’t make this distinction so the argument should always be * false. */ - unsigned count_attribute_slots(bool is_gl_vertex_input) const; + unsigned count_attribute_slots(bool is_gl_vertex_input) const { + return count_vec4_slots(is_gl_vertex_input, true); + } /** * Alignment in bytes of the start of this type in a std140 uniform diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index 817dae09e7b..ecceffeb351 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -153,6 +153,13 @@ glsl_get_aoa_size(const struct glsl_type *type) } unsigned +glsl_count_vec4_slots(const struct glsl_type *type, + bool is_gl_vertex_input, bool is_bindless) +{ + return type->count_vec4_slots(is_gl_vertex_input, is_bindless); +} + +unsigned glsl_count_attribute_slots(const struct glsl_type *type, bool is_gl_vertex_input) { diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h index e1fbc830b1c..ff4c7fae85a 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -80,6 +80,8 @@ unsigned glsl_get_length(const struct glsl_type *type); unsigned glsl_get_aoa_size(const struct glsl_type *type); +unsigned glsl_count_vec4_slots(const struct glsl_type *type, + bool is_gl_vertex_input, bool is_bindless); unsigned glsl_count_attribute_slots(const struct glsl_type *type, bool is_gl_vertex_input); unsigned glsl_get_component_slots(const struct glsl_type *type); |