diff options
author | Rob Clark <[email protected]> | 2018-03-12 15:00:31 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2018-03-25 10:42:54 -0400 |
commit | 2f181c8c183cc8b4d0450789bb20c2be48d32db3 (patch) | |
tree | 612dbe92456c69ce1d362abc2851c89201172dad | |
parent | f407edf3407396379e16b0be74b8d3b85d2ad7f0 (diff) |
glsl_types: vec8/vec16 support
Not used in GL but 8 and 16 component vectors exist in OpenCL.
Signed-off-by: Rob Clark <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r-- | src/compiler/builtin_type_macros.h | 4 | ||||
-rw-r--r-- | src/compiler/glsl_types.cpp | 8 | ||||
-rw-r--r-- | src/compiler/nir/nir_print.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_validate.c | 4 | ||||
-rw-r--r-- | src/compiler/nir_types.cpp | 10 | ||||
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 3 |
6 files changed, 23 insertions, 10 deletions
diff --git a/src/compiler/builtin_type_macros.h b/src/compiler/builtin_type_macros.h index dd8204a1981..55ad2b89554 100644 --- a/src/compiler/builtin_type_macros.h +++ b/src/compiler/builtin_type_macros.h @@ -35,7 +35,9 @@ DECL_TYPE(void, GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0) DECL_TYPE(stype, etype ##__VA_ARGS__, btype, 1, 1) \ 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 ## 4, etype ##_VEC4 ##__VA_ARGS__, btype, 4, 1) \ + DECL_TYPE(vtype ## 8, 0, btype, 8, 1) \ + DECL_TYPE(vtype ## 16, 0, btype, 16, 1) DECL_VEC_TYPE(bool, bvec, GLSL_TYPE_BOOL, GL_BOOL) DECL_VEC_TYPE(int, ivec, GLSL_TYPE_INT, GL_INT) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 8b18f2f3210..b8caddb4066 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -498,7 +498,12 @@ glsl_type::vec(unsigned components, const glsl_type *const ts[]) { unsigned n = components; - if (n == 0 || n > 4) + if (components == 8) + n = 5; + else if (components == 16) + n = 6; + + if (n == 0 || n > 6) return error_type; return ts[n - 1]; @@ -508,6 +513,7 @@ glsl_type::vec(unsigned components, const glsl_type *const ts[]) static const glsl_type *const ts[] = { \ sname ## _type, vname ## 2_type, \ vname ## 3_type, vname ## 4_type, \ + vname ## 8_type, vname ## 16_type, \ }; \ glsl_type::vec(components, ts); \ }) diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 7888dbd3384..21f13097651 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -85,7 +85,9 @@ print_register(nir_register *reg, print_state *state) fprintf(fp, "r%u", reg->index); } -static const char *sizes[] = { "error", "vec1", "vec2", "vec3", "vec4" }; +static const char *sizes[] = { "error", "vec1", "vec2", "vec3", "vec4", + "error", "error", "error", "vec8", + "error", "error", "error", "vec16"}; static void print_register_decl(nir_register *reg, print_state *state) diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index a49948fbb48..725ba43152c 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -294,7 +294,9 @@ validate_ssa_def(nir_ssa_def *def, validate_state *state) validate_assert(state, def->parent_instr == state->instr); - validate_assert(state, def->num_components <= 4); + validate_assert(state, (def->num_components <= 4) || + (def->num_components == 8) || + (def->num_components == 16)); list_validate(&def->uses); list_validate(&def->if_uses); diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index ee6b06aea63..78b66803f08 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -366,15 +366,17 @@ glsl_scalar_type(enum glsl_base_type base_type) const glsl_type * glsl_vector_type(enum glsl_base_type base_type, unsigned components) { - assert(components > 1 && components <= 4); - return glsl_type::get_instance(base_type, components, 1); + const glsl_type *t = glsl_type::get_instance(base_type, components, 1); + assert(t != glsl_type::error_type); + return t; } const glsl_type * glsl_matrix_type(enum glsl_base_type base_type, unsigned rows, unsigned columns) { - assert(rows > 1 && rows <= 4 && columns >= 1 && columns <= 4); - return glsl_type::get_instance(base_type, rows, columns); + const glsl_type *t = glsl_type::get_instance(base_type, rows, columns); + assert(t != glsl_type::error_type); + return t; } const glsl_type * diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index e91d1e3dfaa..7888e1b7463 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -934,7 +934,6 @@ vtn_type_layout_std430(struct vtn_builder *b, struct vtn_type *type, case vtn_base_type_vector: { uint32_t comp_size = glsl_get_bit_size(type->type) / 8; - assert(type->length > 0 && type->length <= 4); unsigned align_comps = type->length == 3 ? 4 : type->length; *size_out = comp_size * type->length, *align_out = comp_size * align_comps; @@ -1047,7 +1046,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode, vtn_fail_if(base->base_type != vtn_base_type_scalar, "Base type for OpTypeVector must be a scalar"); - vtn_fail_if(elems < 2 || elems > 4, + vtn_fail_if((elems < 2 || elems > 4) && (elems != 8) && (elems != 16), "Invalid component count for OpTypeVector"); val->type->base_type = vtn_base_type_vector; |