From f62bbe44c973fad90544db22dc82c1a2a0d1df81 Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Thu, 23 Dec 2021 10:43:40 +0800 Subject: [PATCH] glsl: add vec5 glsl types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Used by nir_variable holds sparse texture output which is up to vec5 size. Reviewed-by: Marek Olšák Singed-off-by: Qiang Yu Part-of: --- src/compiler/builtin_type_macros.h | 1 + src/compiler/glsl_types.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/compiler/builtin_type_macros.h b/src/compiler/builtin_type_macros.h index aa929d4f500..e0260674837 100644 --- a/src/compiler/builtin_type_macros.h +++ b/src/compiler/builtin_type_macros.h @@ -36,6 +36,7 @@ DECL_TYPE(void, GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0) DECL_TYPE(vtype ## 2, etype ##_VEC2 ##__VA_ARGS__, btype, 2, 1) \ DECL_TYPE(vtype ## 3, etype ##_VEC3 ##__VA_ARGS__, btype, 3, 1) \ DECL_TYPE(vtype ## 4, etype ##_VEC4 ##__VA_ARGS__, btype, 4, 1) \ + DECL_TYPE(vtype ## 5, 0, btype, 5, 1) \ DECL_TYPE(vtype ## 8, 0, btype, 8, 1) \ DECL_TYPE(vtype ## 16, 0, btype, 16, 1) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 8c827a5f28f..e0de4fef2ef 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -630,11 +630,11 @@ glsl_type::vec(unsigned components, const glsl_type *const ts[]) unsigned n = components; if (components == 8) - n = 5; - else if (components == 16) n = 6; + else if (components == 16) + n = 7; - if (n == 0 || n > 6) + if (n == 0 || n > 7) return error_type; return ts[n - 1]; @@ -647,6 +647,7 @@ glsl_type:: vname (unsigned components) \ static const glsl_type *const ts[] = { \ sname ## _type, vname ## 2_type, \ vname ## 3_type, vname ## 4_type, \ + vname ## 5_type, \ vname ## 8_type, vname ## 16_type, \ }; \ return glsl_type::vec(components, ts); \ @@ -3123,12 +3124,12 @@ encode_type_to_blob(struct blob *blob, const glsl_type *type) case GLSL_TYPE_BOOL: encoded.basic.interface_row_major = type->interface_row_major; assert(type->matrix_columns < 8); - if (type->vector_elements <= 4) + if (type->vector_elements <= 5) encoded.basic.vector_elements = type->vector_elements; else if (type->vector_elements == 8) - encoded.basic.vector_elements = 5; - else if (type->vector_elements == 16) encoded.basic.vector_elements = 6; + else if (type->vector_elements == 16) + encoded.basic.vector_elements = 7; encoded.basic.matrix_columns = type->matrix_columns; encoded.basic.explicit_stride = MIN2(type->explicit_stride, 0xffff); encoded.basic.explicit_alignment = @@ -3241,9 +3242,9 @@ decode_type_from_blob(struct blob_reader *blob) else if (explicit_alignment > 0) explicit_alignment = 1 << (explicit_alignment - 1); uint32_t vector_elements = encoded.basic.vector_elements; - if (vector_elements == 5) + if (vector_elements == 6) vector_elements = 8; - else if (vector_elements == 6) + else if (vector_elements == 7) vector_elements = 16; return glsl_type::get_instance(base_type, vector_elements, encoded.basic.matrix_columns,