diff options
-rw-r--r-- | builtin_types.h | 2 | ||||
-rw-r--r-- | glsl_types.h | 2 | ||||
-rw-r--r-- | ir.cpp | 20 | ||||
-rw-r--r-- | ir.h | 3 | ||||
-rw-r--r-- | ir_reader.cpp | 5 |
5 files changed, 30 insertions, 2 deletions
diff --git a/builtin_types.h b/builtin_types.h index 148917e0dcf..41ce5d21896 100644 --- a/builtin_types.h +++ b/builtin_types.h @@ -65,6 +65,7 @@ static const struct glsl_type builtin_core_types[] = { const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; +const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7]; const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9]; const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10]; @@ -230,6 +231,7 @@ static const struct glsl_type builtin_130_types[] = { }; const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; +const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; /*@}*/ /** \name Sampler types added by GL_ARB_texture_rectangle diff --git a/glsl_types.h b/glsl_types.h index 96e4c74d5b5..22df13b07f0 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -108,7 +108,9 @@ struct glsl_type { /*@{*/ static const glsl_type *const error_type; static const glsl_type *const int_type; + static const glsl_type *const ivec4_type; static const glsl_type *const uint_type; + static const glsl_type *const uvec4_type; static const glsl_type *const float_type; static const glsl_type *const vec2_type; static const glsl_type *const vec3_type; @@ -324,6 +324,26 @@ ir_texture::get_opcode(const char *str) } +void +ir_texture::set_sampler(ir_dereference *sampler) +{ + assert(sampler != NULL); + this->sampler = sampler; + + switch (sampler->type->sampler_type) { + case GLSL_TYPE_FLOAT: + this->type = glsl_type::vec4_type; + break; + case GLSL_TYPE_INT: + this->type = glsl_type::ivec4_type; + break; + case GLSL_TYPE_UINT: + this->type = glsl_type::uvec4_type; + break; + } +} + + ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, unsigned w, unsigned count) : val(val) @@ -787,6 +787,9 @@ public: */ const char *opcode_string(); + /** Set the sampler and infer the type. */ + void set_sampler(ir_dereference *sampler); + /** * Do a reverse-lookup to translate a string into an ir_texture_opcode. */ diff --git a/ir_reader.cpp b/ir_reader.cpp index 4c97cc8ebad..0a2d18e2e01 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -934,11 +934,12 @@ read_texture(_mesa_glsl_parse_state *st, s_list *list) // Read sampler (must be a deref) s_expression *sampler_expr = (s_expression *) tag->next; - tex->sampler = read_dereference(st, sampler_expr); - if (tex->sampler == NULL) { + ir_dereference *sampler = read_dereference(st, sampler_expr); + if (sampler == NULL) { ir_read_error(st, NULL, "when reading sampler in (%s ...)", tag->value()); return NULL; } + tex->set_sampler(sampler); // Read coordinate (any rvalue) s_expression *coordinate_expr = (s_expression *) sampler_expr->next; |