glsl2: glsl_type has its own talloc context, don't pass one in
This commit is contained in:
@@ -312,8 +312,7 @@ process_array_constructor(exec_list *instructions,
|
|||||||
|
|
||||||
if (constructor_type->length == 0) {
|
if (constructor_type->length == 0) {
|
||||||
constructor_type =
|
constructor_type =
|
||||||
glsl_type::get_array_instance(state,
|
glsl_type::get_array_instance(constructor_type->element_type(),
|
||||||
constructor_type->element_type(),
|
|
||||||
parameter_count);
|
parameter_count);
|
||||||
assert(constructor_type != NULL);
|
assert(constructor_type != NULL);
|
||||||
assert(constructor_type->length == parameter_count);
|
assert(constructor_type->length == parameter_count);
|
||||||
|
@@ -511,8 +511,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
|
|||||||
var->max_array_access);
|
var->max_array_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
var->type = glsl_type::get_array_instance(state,
|
var->type = glsl_type::get_array_instance(lhs->type->element_type(),
|
||||||
lhs->type->element_type(),
|
|
||||||
rhs->type->array_size());
|
rhs->type->array_size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1407,7 +1406,7 @@ process_array_type(const glsl_type *base, ast_node *array_size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return glsl_type::get_array_instance(state, base, length);
|
return glsl_type::get_array_instance(base, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -289,7 +289,7 @@ glsl_type::generate_constructor(glsl_symbol_table *symtab) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) :
|
glsl_type::glsl_type(const glsl_type *array, unsigned length) :
|
||||||
base_type(GLSL_TYPE_ARRAY),
|
base_type(GLSL_TYPE_ARRAY),
|
||||||
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
|
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
|
||||||
sampler_type(0),
|
sampler_type(0),
|
||||||
@@ -308,7 +308,7 @@ glsl_type::glsl_type(void *ctx, const glsl_type *array, unsigned length) :
|
|||||||
* NUL.
|
* NUL.
|
||||||
*/
|
*/
|
||||||
const unsigned name_length = strlen(array->name) + 10 + 3;
|
const unsigned name_length = strlen(array->name) + 10 + 3;
|
||||||
char *const n = (char *) talloc_size(ctx, name_length);
|
char *const n = (char *) talloc_size(this->ctx, name_length);
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
snprintf(n, name_length, "%s[]", array->name);
|
snprintf(n, name_length, "%s[]", array->name);
|
||||||
@@ -411,10 +411,9 @@ glsl_type::array_key_hash(const void *a)
|
|||||||
|
|
||||||
|
|
||||||
const glsl_type *
|
const glsl_type *
|
||||||
glsl_type::get_array_instance(void *ctx, const glsl_type *base,
|
glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
|
||||||
unsigned array_size)
|
|
||||||
{
|
{
|
||||||
const glsl_type key(ctx, base, array_size);
|
const glsl_type key(base, array_size);
|
||||||
|
|
||||||
if (array_types == NULL) {
|
if (array_types == NULL) {
|
||||||
array_types = hash_table_ctor(64, array_key_hash, array_key_compare);
|
array_types = hash_table_ctor(64, array_key_hash, array_key_compare);
|
||||||
@@ -422,7 +421,7 @@ glsl_type::get_array_instance(void *ctx, const glsl_type *base,
|
|||||||
|
|
||||||
const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key);
|
const glsl_type *t = (glsl_type *) hash_table_find(array_types, & key);
|
||||||
if (t == NULL) {
|
if (t == NULL) {
|
||||||
t = new glsl_type(ctx, base, array_size);
|
t = new glsl_type(base, array_size);
|
||||||
|
|
||||||
hash_table_insert(array_types, (void *) t, t);
|
hash_table_insert(array_types, (void *) t, t);
|
||||||
}
|
}
|
||||||
|
@@ -197,8 +197,7 @@ struct glsl_type {
|
|||||||
/**
|
/**
|
||||||
* Get the instance of an array type
|
* Get the instance of an array type
|
||||||
*/
|
*/
|
||||||
static const glsl_type *get_array_instance(void *ctx,
|
static const glsl_type *get_array_instance(const glsl_type *base,
|
||||||
const glsl_type *base,
|
|
||||||
unsigned elements);
|
unsigned elements);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -412,7 +411,7 @@ private:
|
|||||||
const char *name);
|
const char *name);
|
||||||
|
|
||||||
/** Constructor for array types */
|
/** Constructor for array types */
|
||||||
glsl_type(void *ctx, const glsl_type *array, unsigned length);
|
glsl_type(const glsl_type *array, unsigned length);
|
||||||
|
|
||||||
/** Hash table containing the known array types. */
|
/** Hash table containing the known array types. */
|
||||||
static struct hash_table *array_types;
|
static struct hash_table *array_types;
|
||||||
|
@@ -138,7 +138,7 @@ read_type(_mesa_glsl_parse_state *st, s_expression *expr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return glsl_type::get_array_instance(st, base_type, size->value());
|
return glsl_type::get_array_instance(base_type, size->value());
|
||||||
} else if (strcmp(type_sym->value(), "struct") == 0) {
|
} else if (strcmp(type_sym->value(), "struct") == 0) {
|
||||||
assert(false); // FINISHME
|
assert(false); // FINISHME
|
||||||
} else {
|
} else {
|
||||||
|
@@ -138,7 +138,7 @@ generate_110_uniforms(exec_list *instructions,
|
|||||||
state->Const.MaxFragmentUniformComponents);
|
state->Const.MaxFragmentUniformComponents);
|
||||||
|
|
||||||
const glsl_type *const mat4_array_type =
|
const glsl_type *const mat4_array_type =
|
||||||
glsl_type::get_array_instance(state->symbols, glsl_type::mat4_type,
|
glsl_type::get_array_instance(glsl_type::mat4_type,
|
||||||
state->Const.MaxTextureCoords);
|
state->Const.MaxTextureCoords);
|
||||||
|
|
||||||
add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type,
|
add_variable("gl_TextureMatrix", ir_var_uniform, -1, mat4_array_type,
|
||||||
@@ -157,8 +157,7 @@ generate_110_uniforms(exec_list *instructions,
|
|||||||
* FINISHME: at least 8, so hard-code 8 for now.
|
* FINISHME: at least 8, so hard-code 8 for now.
|
||||||
*/
|
*/
|
||||||
const glsl_type *const light_source_array_type =
|
const glsl_type *const light_source_array_type =
|
||||||
glsl_type::get_array_instance(state->symbols,
|
glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), 8);
|
||||||
state->symbols->get_type("gl_LightSourceParameters"), 8);
|
|
||||||
|
|
||||||
add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type,
|
add_variable("gl_LightSource", ir_var_uniform, -1, light_source_array_type,
|
||||||
instructions, state->symbols);
|
instructions, state->symbols);
|
||||||
@@ -196,7 +195,7 @@ generate_110_vs_variables(exec_list *instructions,
|
|||||||
* implementation in preserving varying resources."
|
* implementation in preserving varying resources."
|
||||||
*/
|
*/
|
||||||
const glsl_type *const vec4_array_type =
|
const glsl_type *const vec4_array_type =
|
||||||
glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0);
|
glsl_type::get_array_instance(glsl_type::vec4_type, 0);
|
||||||
|
|
||||||
add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type,
|
add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type,
|
||||||
instructions, state->symbols);
|
instructions, state->symbols);
|
||||||
@@ -221,7 +220,6 @@ static void
|
|||||||
generate_130_vs_variables(exec_list *instructions,
|
generate_130_vs_variables(exec_list *instructions,
|
||||||
struct _mesa_glsl_parse_state *state)
|
struct _mesa_glsl_parse_state *state)
|
||||||
{
|
{
|
||||||
void *ctx = state->symbols;
|
|
||||||
generate_120_vs_variables(instructions, state);
|
generate_120_vs_variables(instructions, state);
|
||||||
|
|
||||||
for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) {
|
for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) {
|
||||||
@@ -233,7 +231,7 @@ generate_130_vs_variables(exec_list *instructions,
|
|||||||
* FINISHME: the value of GL_MAX_CLIP_DISTANCES.
|
* FINISHME: the value of GL_MAX_CLIP_DISTANCES.
|
||||||
*/
|
*/
|
||||||
const glsl_type *const clip_distance_array_type =
|
const glsl_type *const clip_distance_array_type =
|
||||||
glsl_type::get_array_instance(ctx, glsl_type::float_type, 8);
|
glsl_type::get_array_instance(glsl_type::float_type, 8);
|
||||||
|
|
||||||
/* FINISHME: gl_ClipDistance needs a real location assigned. */
|
/* FINISHME: gl_ClipDistance needs a real location assigned. */
|
||||||
add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type,
|
add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type,
|
||||||
@@ -286,7 +284,7 @@ generate_110_fs_variables(exec_list *instructions,
|
|||||||
* implementation in preserving varying resources."
|
* implementation in preserving varying resources."
|
||||||
*/
|
*/
|
||||||
const glsl_type *const vec4_array_type =
|
const glsl_type *const vec4_array_type =
|
||||||
glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type, 0);
|
glsl_type::get_array_instance(glsl_type::vec4_type, 0);
|
||||||
|
|
||||||
add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type,
|
add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type,
|
||||||
instructions, state->symbols);
|
instructions, state->symbols);
|
||||||
@@ -318,7 +316,7 @@ generate_ARB_draw_buffers_variables(exec_list *instructions,
|
|||||||
*/
|
*/
|
||||||
if (target == fragment_shader) {
|
if (target == fragment_shader) {
|
||||||
const glsl_type *const vec4_array_type =
|
const glsl_type *const vec4_array_type =
|
||||||
glsl_type::get_array_instance(state->symbols, glsl_type::vec4_type,
|
glsl_type::get_array_instance(glsl_type::vec4_type,
|
||||||
state->Const.MaxDrawBuffers);
|
state->Const.MaxDrawBuffers);
|
||||||
|
|
||||||
ir_variable *const fd =
|
ir_variable *const fd =
|
||||||
@@ -349,14 +347,13 @@ static void
|
|||||||
generate_130_fs_variables(exec_list *instructions,
|
generate_130_fs_variables(exec_list *instructions,
|
||||||
struct _mesa_glsl_parse_state *state)
|
struct _mesa_glsl_parse_state *state)
|
||||||
{
|
{
|
||||||
void *ctx = state->symbols;
|
|
||||||
generate_120_fs_variables(instructions, state);
|
generate_120_fs_variables(instructions, state);
|
||||||
|
|
||||||
/* FINISHME: The size of this array is implementation dependent based on
|
/* FINISHME: The size of this array is implementation dependent based on
|
||||||
* FINISHME: the value of GL_MAX_CLIP_DISTANCES.
|
* FINISHME: the value of GL_MAX_CLIP_DISTANCES.
|
||||||
*/
|
*/
|
||||||
const glsl_type *const clip_distance_array_type =
|
const glsl_type *const clip_distance_array_type =
|
||||||
glsl_type::get_array_instance(ctx, glsl_type::float_type, 8);
|
glsl_type::get_array_instance(glsl_type::float_type, 8);
|
||||||
|
|
||||||
/* FINISHME: gl_ClipDistance needs a real location assigned. */
|
/* FINISHME: gl_ClipDistance needs a real location assigned. */
|
||||||
add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type,
|
add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type,
|
||||||
|
Reference in New Issue
Block a user