This adds the builtins and the lexer support.
To avoid too many warnings, it adds basic support to the type in a few
other places in mesa, mostly in the trivial places.
It also adds a query to be used later for if a type is an integer 32 or 64.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
DECL_TYPE(dmat4x2, GL_DOUBLE_MAT4x2, GLSL_TYPE_DOUBLE, 2, 4)
DECL_TYPE(dmat4x3, GL_DOUBLE_MAT4x3, GLSL_TYPE_DOUBLE, 3, 4)
+DECL_TYPE(int64_t, GL_INT64_ARB, GLSL_TYPE_INT64, 1, 1)
+DECL_TYPE(i64vec2, GL_INT64_VEC2_ARB, GLSL_TYPE_INT64, 2, 1)
+DECL_TYPE(i64vec3, GL_INT64_VEC3_ARB, GLSL_TYPE_INT64, 3, 1)
+DECL_TYPE(i64vec4, GL_INT64_VEC4_ARB, GLSL_TYPE_INT64, 4, 1)
+
+DECL_TYPE(uint64_t, GL_UNSIGNED_INT64_ARB, GLSL_TYPE_UINT64, 1, 1)
+DECL_TYPE(u64vec2, GL_UNSIGNED_INT64_VEC2_ARB, GLSL_TYPE_UINT64, 2, 1)
+DECL_TYPE(u64vec3, GL_UNSIGNED_INT64_VEC3_ARB, GLSL_TYPE_UINT64, 3, 1)
+DECL_TYPE(u64vec4, GL_UNSIGNED_INT64_VEC4_ARB, GLSL_TYPE_UINT64, 4, 1)
+
DECL_TYPE(sampler, GL_SAMPLER_1D, GLSL_TYPE_SAMPLER, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_VOID)
DECL_TYPE(sampler1D, GL_SAMPLER_1D, GLSL_TYPE_SAMPLER, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT)
DECL_TYPE(sampler2D, GL_SAMPLER_2D, GLSL_TYPE_SAMPLER, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT)
case GLSL_TYPE_INT:
case GLSL_TYPE_BOOL:
case GLSL_TYPE_DOUBLE:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
return new(mem_ctx) ir_expression(operation, op0, op1);
case GLSL_TYPE_ARRAY: {
add_type(symbols, glsl_type::dmat4x2_type);
add_type(symbols, glsl_type::dmat4x3_type);
}
+
+ if (state->ARB_gpu_shader_int64_enable) {
+ add_type(symbols, glsl_type::int64_t_type);
+ add_type(symbols, glsl_type::i64vec2_type);
+ add_type(symbols, glsl_type::i64vec3_type);
+ add_type(symbols, glsl_type::i64vec4_type);
+
+ add_type(symbols, glsl_type::uint64_t_type);
+ add_type(symbols, glsl_type::u64vec2_type);
+ add_type(symbols, glsl_type::u64vec3_type);
+ add_type(symbols, glsl_type::u64vec4_type);
+ }
}
/** @} */
sample KEYWORD_WITH_ALT(400, 300, 400, 320, yyextra->ARB_gpu_shader5_enable || yyextra->OES_shader_multisample_interpolation_enable, SAMPLE);
subroutine KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_shader_subroutine_enable, SUBROUTINE);
+ /* Additional words for ARB_gpu_shader_int64 */
+int64_t KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, INT64);
+i64vec2 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, I64VEC2);
+i64vec3 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, I64VEC3);
+i64vec4 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, I64VEC4);
+
+uint64_t KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, UINT64);
+u64vec2 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, U64VEC2);
+u64vec3 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, U64VEC3);
+u64vec4 KEYWORD_WITH_ALT(0, 0, 0, 0, yyextra->ARB_gpu_shader_int64_enable, U64VEC4);
[_a-zA-Z][_a-zA-Z0-9]* {
struct _mesa_glsl_parse_state *state = yyextra;
%token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK DOUBLE_TOK
%token BREAK BUFFER CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 DVEC2 DVEC3 DVEC4
+%token INT64 UINT64 I64VEC2 I64VEC3 I64VEC4 U64VEC2 U64VEC3 U64VEC4
%token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING SAMPLE
%token NOPERSPECTIVE FLAT SMOOTH
%token MAT2X2 MAT2X3 MAT2X4
| UIMAGE2DMS { $$ = "uimage2DMS"; }
| UIMAGE2DMSARRAY { $$ = "uimage2DMSArray"; }
| ATOMIC_UINT { $$ = "atomic_uint"; }
+ | INT64 { $$ = "int64_t"; }
+ | I64VEC2 { $$ = "i64vec2"; }
+ | I64VEC3 { $$ = "i64vec3"; }
+ | I64VEC4 { $$ = "i64vec4"; }
+ | UINT64 { $$ = "uint64_t"; }
+ | U64VEC2 { $$ = "u64vec2"; }
+ | U64VEC3 { $$ = "u64vec3"; }
+ | U64VEC4 { $$ = "u64vec4"; }
;
precision_qualifier:
case GLSL_TYPE_FLOAT:
case GLSL_TYPE_DOUBLE:
case GLSL_TYPE_BOOL:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
return new(mem_ctx) ir_constant(this->type, &this->value);
case GLSL_TYPE_STRUCT: {
case GLSL_TYPE_BOOL:
storage[i].b = val->value.b[i] ? boolean_true : 0;
break;
+ case GLSL_TYPE_INT64:
+ case GLSL_TYPE_UINT64:
case GLSL_TYPE_ARRAY:
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_IMAGE:
return double_type;
case GLSL_TYPE_BOOL:
return bool_type;
+ case GLSL_TYPE_UINT64:
+ return uint64_t_type;
+ case GLSL_TYPE_INT64:
+ return int64_t_type;
default:
return error_type;
}
return double_type;
case GLSL_TYPE_BOOL:
return bool_type;
+ case GLSL_TYPE_UINT64:
+ return uint64_t_type;
+ case GLSL_TYPE_INT64:
+ return int64_t_type;
default:
/* Handle everything else */
return type;
}
+const glsl_type *
+glsl_type::i64vec(unsigned components)
+{
+ if (components == 0 || components > 4)
+ return error_type;
+
+ static const glsl_type *const ts[] = {
+ int64_t_type, i64vec2_type, i64vec3_type, i64vec4_type
+ };
+ return ts[components - 1];
+}
+
+
+const glsl_type *
+glsl_type::u64vec(unsigned components)
+{
+ if (components == 0 || components > 4)
+ return error_type;
+
+ static const glsl_type *const ts[] = {
+ uint64_t_type, u64vec2_type, u64vec3_type, u64vec4_type
+ };
+ return ts[components - 1];
+}
+
const glsl_type *
glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
{
return dvec(rows);
case GLSL_TYPE_BOOL:
return bvec(rows);
+ case GLSL_TYPE_UINT64:
+ return u64vec(rows);
+ case GLSL_TYPE_INT64:
+ return i64vec(rows);
default:
return error_type;
}
return this->components();
case GLSL_TYPE_DOUBLE:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
return 2 * this->components();
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_INT:
case GLSL_TYPE_FLOAT:
case GLSL_TYPE_DOUBLE:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
case GLSL_TYPE_BOOL:
case GLSL_TYPE_SAMPLER:
case GLSL_TYPE_IMAGE:
case GLSL_TYPE_FLOAT:
case GLSL_TYPE_DOUBLE:
case GLSL_TYPE_BOOL:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
return 1;
case GLSL_TYPE_STRUCT:
case GLSL_TYPE_BOOL:
return this->matrix_columns;
case GLSL_TYPE_DOUBLE:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
if (this->vector_elements > 2 && !is_vertex_input)
return this->matrix_columns * 2;
else
GLSL_TYPE_INT,
GLSL_TYPE_FLOAT,
GLSL_TYPE_DOUBLE,
+ GLSL_TYPE_UINT64,
+ GLSL_TYPE_INT64,
GLSL_TYPE_BOOL,
GLSL_TYPE_SAMPLER,
GLSL_TYPE_IMAGE,
static inline bool glsl_base_type_is_64bit(enum glsl_base_type type)
{
- return type == GLSL_TYPE_DOUBLE;
+ return type == GLSL_TYPE_DOUBLE ||
+ type == GLSL_TYPE_UINT64 ||
+ type == GLSL_TYPE_INT64;
}
enum glsl_sampler_dim {
static const glsl_type *ivec(unsigned components);
static const glsl_type *uvec(unsigned components);
static const glsl_type *bvec(unsigned components);
+ static const glsl_type *i64vec(unsigned components);
+ static const glsl_type *u64vec(unsigned components);
/**@}*/
/**
*/
bool is_numeric() const
{
- return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_DOUBLE);
+ return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_INT64);
}
/**
}
/**
- * Query whether or not type is an integral type, or for struct, interface
- * and array types, contains an integral type.
+ * Query whether or not a type is a 32-bit or 64-bit integer
+ */
+ bool is_integer_32_64() const
+ {
+ return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT) ||
+ (base_type == GLSL_TYPE_UINT64) || (base_type == GLSL_TYPE_INT64);
+ }
+
+ /**
+ * Query whether or not type is an integral type, or for struct and array
+ * types, contains an integral type.
*/
bool contains_integer() const;
return 1;
}
break;
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
+ if (type->vector_elements > 2)
+ return 2;
+ else
+ return 1;
case GLSL_TYPE_ARRAY:
assert(type->length > 0);
return type_size(type->fields.array) * type->length;
unsigned columns = 0;
int dmul = 4 * sizeof(float);
switch (storage->type->base_type) {
+ case GLSL_TYPE_UINT64:
+ if (storage->type->vector_elements > 2)
+ dmul *= 2;
+ /* fallthrough */
case GLSL_TYPE_UINT:
assert(ctx->Const.NativeIntegers);
format = uniform_native;
columns = 1;
break;
+ case GLSL_TYPE_INT64:
+ if (storage->type->vector_elements > 2)
+ dmul *= 2;
+ /* fallthrough */
case GLSL_TYPE_INT:
format =
(ctx->Const.NativeIntegers) ? uniform_native : uniform_int_float;
return 2;
}
break;
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
+ if (type->vector_elements <= 2 || is_vs_input)
+ return 1;
+ else
+ return 2;
case GLSL_TYPE_ARRAY:
assert(type->length > 0);
return st_glsl_attrib_type_size(type->fields.array, is_vs_input) * type->length;