Set the type of ir_texture properly; infer it from the sampler type.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
+3
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user