diff options
-rw-r--r-- | src/compiler/builtin_type_macros.h | 10 | ||||
-rw-r--r-- | src/compiler/glsl/ast_to_hir.cpp | 2 | ||||
-rw-r--r-- | src/compiler/glsl/builtin_types.cpp | 12 | ||||
-rw-r--r-- | src/compiler/glsl/glsl_lexer.ll | 10 | ||||
-rw-r--r-- | src/compiler/glsl/glsl_parser.yy | 9 | ||||
-rw-r--r-- | src/compiler/glsl/ir_clone.cpp | 2 | ||||
-rw-r--r-- | src/compiler/glsl/link_uniform_initializers.cpp | 2 | ||||
-rw-r--r-- | src/compiler/glsl_types.cpp | 45 | ||||
-rw-r--r-- | src/compiler/glsl_types.h | 23 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 14 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_types.cpp | 6 |
11 files changed, 131 insertions, 4 deletions
diff --git a/src/compiler/builtin_type_macros.h b/src/compiler/builtin_type_macros.h index 49a5a348d77..a275617b343 100644 --- a/src/compiler/builtin_type_macros.h +++ b/src/compiler/builtin_type_macros.h @@ -78,6 +78,16 @@ DECL_TYPE(dmat3x4, GL_DOUBLE_MAT3x4, GLSL_TYPE_DOUBLE, 4, 3) 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) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index ce620fab827..5cd094d7c55 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -1093,6 +1093,8 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue *op0, ir_rvalue *op1) 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: { diff --git a/src/compiler/glsl/builtin_types.cpp b/src/compiler/glsl/builtin_types.cpp index 000f8112920..a63d736ea16 100644 --- a/src/compiler/glsl/builtin_types.cpp +++ b/src/compiler/glsl/builtin_types.cpp @@ -409,5 +409,17 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) 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); + } } /** @} */ diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll index 0e722cbfba3..4c0980fc248 100644 --- a/src/compiler/glsl/glsl_lexer.ll +++ b/src/compiler/glsl/glsl_lexer.ll @@ -591,6 +591,16 @@ resource KEYWORD(420, 300, 0, 0, RESOURCE); 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; diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy index 519e35b6d53..734dc499cca 100644 --- a/src/compiler/glsl/glsl_parser.yy +++ b/src/compiler/glsl/glsl_parser.yy @@ -136,6 +136,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2, %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 @@ -2304,6 +2305,14 @@ basic_type_specifier_nonarray: | 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: diff --git a/src/compiler/glsl/ir_clone.cpp b/src/compiler/glsl/ir_clone.cpp index 062ea23a830..bfe2573c071 100644 --- a/src/compiler/glsl/ir_clone.cpp +++ b/src/compiler/glsl/ir_clone.cpp @@ -337,6 +337,8 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const 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: { diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp index 7439fd3789a..994c2f4ed21 100644 --- a/src/compiler/glsl/link_uniform_initializers.cpp +++ b/src/compiler/glsl/link_uniform_initializers.cpp @@ -70,6 +70,8 @@ copy_constant_to_storage(union gl_constant_value *storage, 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: diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 79f026785f8..a431edcdd3f 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -354,6 +354,10 @@ const glsl_type *glsl_type::get_base_type() const 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; } @@ -380,6 +384,10 @@ const glsl_type *glsl_type::get_scalar_type() const 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; @@ -520,6 +528,31 @@ glsl_type::bvec(unsigned components) 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) { if (base_type == GLSL_TYPE_VOID) @@ -542,6 +575,10 @@ 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; } @@ -1239,6 +1276,8 @@ glsl_type::component_slots() const return this->components(); case GLSL_TYPE_DOUBLE: + case GLSL_TYPE_UINT64: + case GLSL_TYPE_INT64: return 2 * this->components(); case GLSL_TYPE_STRUCT: @@ -1321,6 +1360,8 @@ glsl_type::uniform_locations() const 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: @@ -1350,6 +1391,8 @@ glsl_type::varying_count() const 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: @@ -1923,6 +1966,8 @@ glsl_type::count_attribute_slots(bool is_vertex_input) const 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 diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 508cf521364..23d600589f6 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -54,6 +54,8 @@ enum glsl_base_type { GLSL_TYPE_INT, GLSL_TYPE_FLOAT, GLSL_TYPE_DOUBLE, + GLSL_TYPE_UINT64, + GLSL_TYPE_INT64, GLSL_TYPE_BOOL, GLSL_TYPE_SAMPLER, GLSL_TYPE_IMAGE, @@ -69,7 +71,9 @@ enum glsl_base_type { 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 { @@ -225,6 +229,8 @@ struct glsl_type { 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); /**@}*/ /** @@ -462,7 +468,7 @@ struct glsl_type { */ 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); } /** @@ -474,8 +480,17 @@ struct glsl_type { } /** - * 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; diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index f7797e28fa3..85e6e92a2d5 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -532,6 +532,12 @@ type_size(const struct glsl_type *type) 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; @@ -2522,11 +2528,19 @@ _mesa_associate_uniform_storage(struct gl_context *ctx, 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; diff --git a/src/mesa/state_tracker/st_glsl_types.cpp b/src/mesa/state_tracker/st_glsl_types.cpp index 857e143287f..37c3164254a 100644 --- a/src/mesa/state_tracker/st_glsl_types.cpp +++ b/src/mesa/state_tracker/st_glsl_types.cpp @@ -67,6 +67,12 @@ st_glsl_attrib_type_size(const struct glsl_type *type, bool is_vs_input) 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; |