glsl_types: vec8/vec16 support
Not used in GL but 8 and 16 component vectors exist in OpenCL. Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -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)
|
||||
|
@@ -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); \
|
||||
})
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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 *
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user