mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 06:40:11 +01:00
Convert everything from the talloc API to the ralloc API.
This commit is contained in:
parent
dc55254f5b
commit
d3073f58c1
67 changed files with 590 additions and 604 deletions
|
|
@ -49,23 +49,23 @@ struct YYLTYPE;
|
|||
*/
|
||||
class ast_node {
|
||||
public:
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *node;
|
||||
|
||||
node = talloc_zero_size(ctx, size);
|
||||
node = rzalloc_size(ctx, size);
|
||||
assert(node != NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just
|
||||
* talloc_free in that case. */
|
||||
* ralloc_free in that case. */
|
||||
static void operator delete(void *table)
|
||||
{
|
||||
talloc_free(table);
|
||||
ralloc_free(table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters,
|
|||
* formal or actual parameter list. Only the type is used.
|
||||
*
|
||||
* \return
|
||||
* A talloced string representing the prototype of the function.
|
||||
* A ralloced string representing the prototype of the function.
|
||||
*/
|
||||
char *
|
||||
prototype_string(const glsl_type *return_type, const char *name,
|
||||
|
|
@ -75,19 +75,19 @@ prototype_string(const glsl_type *return_type, const char *name,
|
|||
char *str = NULL;
|
||||
|
||||
if (return_type != NULL)
|
||||
str = talloc_asprintf(str, "%s ", return_type->name);
|
||||
ralloc_asprintf(&str, "%s ", return_type->name);
|
||||
|
||||
str = talloc_asprintf_append(str, "%s(", name);
|
||||
ralloc_asprintf_append(&str, "%s(", name);
|
||||
|
||||
const char *comma = "";
|
||||
foreach_list(node, parameters) {
|
||||
const ir_instruction *const param = (ir_instruction *) node;
|
||||
|
||||
str = talloc_asprintf_append(str, "%s%s", comma, param->type->name);
|
||||
ralloc_asprintf_append(&str, "%s%s", comma, param->type->name);
|
||||
comma = ", ";
|
||||
}
|
||||
|
||||
str = talloc_strdup_append(str, ")");
|
||||
ralloc_strcat(&str, ")");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ match_function_by_name(exec_list *instructions, const char *name,
|
|||
ir_dereference_variable *deref;
|
||||
|
||||
var = new(ctx) ir_variable(sig->return_type,
|
||||
talloc_asprintf(ctx, "%s_retval",
|
||||
ralloc_asprintf(ctx, "%s_retval",
|
||||
sig->function_name()),
|
||||
ir_var_temporary);
|
||||
instructions->push_tail(var);
|
||||
|
|
@ -210,7 +210,7 @@ match_function_by_name(exec_list *instructions, const char *name,
|
|||
|
||||
_mesa_glsl_error(loc, state, "no matching function for call to `%s'",
|
||||
str);
|
||||
talloc_free(str);
|
||||
ralloc_free(str);
|
||||
|
||||
const char *prefix = "candidates are: ";
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ match_function_by_name(exec_list *instructions, const char *name,
|
|||
|
||||
str = prototype_string(sig->return_type, f->name, &sig->parameters);
|
||||
_mesa_glsl_error(loc, state, "%s%s\n", prefix, str);
|
||||
talloc_free(str);
|
||||
ralloc_free(str);
|
||||
|
||||
prefix = " ";
|
||||
}
|
||||
|
|
@ -247,7 +247,7 @@ match_function_by_name(exec_list *instructions, const char *name,
|
|||
static ir_rvalue *
|
||||
convert_component(ir_rvalue *src, const glsl_type *desired_type)
|
||||
{
|
||||
void *ctx = talloc_parent(src);
|
||||
void *ctx = ralloc_parent(src);
|
||||
const unsigned a = desired_type->base_type;
|
||||
const unsigned b = src->type->base_type;
|
||||
ir_expression *result = NULL;
|
||||
|
|
@ -310,7 +310,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
|
|||
static ir_rvalue *
|
||||
dereference_component(ir_rvalue *src, unsigned component)
|
||||
{
|
||||
void *ctx = talloc_parent(src);
|
||||
void *ctx = ralloc_parent(src);
|
||||
assert(component < src->type->components());
|
||||
|
||||
/* If the source is a constant, just create a new constant instead of a
|
||||
|
|
|
|||
|
|
@ -719,7 +719,7 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
|
|||
static ir_rvalue *
|
||||
get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue)
|
||||
{
|
||||
void *ctx = talloc_parent(lvalue);
|
||||
void *ctx = ralloc_parent(lvalue);
|
||||
ir_variable *var;
|
||||
|
||||
var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp",
|
||||
|
|
@ -3392,7 +3392,7 @@ ast_struct_specifier::hir(exec_list *instructions,
|
|||
* the types to HIR. This ensures that structure definitions embedded in
|
||||
* other structure definitions are processed.
|
||||
*/
|
||||
glsl_struct_field *const fields = talloc_array(state, glsl_struct_field,
|
||||
glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field,
|
||||
decl_count);
|
||||
|
||||
unsigned i = 0;
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ read_builtins(GLenum target, const char *protos, const char **functions, unsigne
|
|||
if (st->error) {
|
||||
printf("error reading builtin: %.35s ...\\n", functions[i]);
|
||||
printf("Info log:\\n%s\\n", st->info_log);
|
||||
talloc_free(sh);
|
||||
ralloc_free(sh);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ void *builtin_mem_ctx = NULL;
|
|||
void
|
||||
_mesa_glsl_release_functions(void)
|
||||
{
|
||||
talloc_free(builtin_mem_ctx);
|
||||
ralloc_free(builtin_mem_ctx);
|
||||
builtin_mem_ctx = NULL;
|
||||
memset(builtin_profiles, 0, sizeof(builtin_profiles));
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ _mesa_read_profile(struct _mesa_glsl_parse_state *state,
|
|||
|
||||
if (sh == NULL) {
|
||||
sh = read_builtins(GL_VERTEX_SHADER, prototypes, functions, count);
|
||||
talloc_steal(builtin_mem_ctx, sh);
|
||||
ralloc_steal(builtin_mem_ctx, sh);
|
||||
builtin_profiles[profile_index] = sh;
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ void
|
|||
_mesa_glsl_initialize_functions(struct _mesa_glsl_parse_state *state)
|
||||
{
|
||||
if (builtin_mem_ctx == NULL) {
|
||||
builtin_mem_ctx = talloc_init("GLSL built-in functions");
|
||||
builtin_mem_ctx = ralloc_context(NULL); // "GLSL built-in functions"
|
||||
memset(&builtin_profiles, 0, sizeof(builtin_profiles));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -795,6 +795,10 @@ int glcpp_get_lineno (yyscan_t yyscanner );
|
|||
|
||||
void glcpp_set_lineno (int line_number ,yyscan_t yyscanner );
|
||||
|
||||
int glcpp_get_column (yyscan_t yyscanner );
|
||||
|
||||
void glcpp_set_column (int column_no ,yyscan_t yyscanner );
|
||||
|
||||
YYSTYPE * glcpp_get_lval (yyscan_t yyscanner );
|
||||
|
||||
void glcpp_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
|
||||
|
|
@ -954,7 +958,7 @@ YY_DECL
|
|||
|
||||
|
||||
/* Single-line comments */
|
||||
#line 958 "glcpp/glcpp-lex.c"
|
||||
#line 962 "glcpp/glcpp-lex.c"
|
||||
|
||||
yylval = yylval_param;
|
||||
|
||||
|
|
@ -1121,7 +1125,7 @@ case 8:
|
|||
YY_RULE_SETUP
|
||||
#line 94 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_VERSION;
|
||||
}
|
||||
|
|
@ -1132,7 +1136,7 @@ case 9:
|
|||
YY_RULE_SETUP
|
||||
#line 102 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yylineno++;
|
||||
yycolumn = 0;
|
||||
return OTHER;
|
||||
|
|
@ -1312,7 +1316,7 @@ case 24:
|
|||
YY_RULE_SETUP
|
||||
#line 221 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
|
|
@ -1320,7 +1324,7 @@ case 25:
|
|||
YY_RULE_SETUP
|
||||
#line 226 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
|
|
@ -1328,7 +1332,7 @@ case 26:
|
|||
YY_RULE_SETUP
|
||||
#line 231 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
YY_BREAK
|
||||
|
|
@ -1406,7 +1410,7 @@ case 37:
|
|||
YY_RULE_SETUP
|
||||
#line 276 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
YY_BREAK
|
||||
|
|
@ -1421,7 +1425,7 @@ case 39:
|
|||
YY_RULE_SETUP
|
||||
#line 285 "glcpp/glcpp-lex.l"
|
||||
{
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return OTHER;
|
||||
}
|
||||
YY_BREAK
|
||||
|
|
@ -1471,7 +1475,7 @@ YY_RULE_SETUP
|
|||
#line 319 "glcpp/glcpp-lex.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1475 "glcpp/glcpp-lex.c"
|
||||
#line 1479 "glcpp/glcpp-lex.c"
|
||||
case YY_STATE_EOF(DONE):
|
||||
case YY_STATE_EOF(COMMENT):
|
||||
case YY_STATE_EOF(UNREACHABLE):
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
|||
}
|
||||
|
||||
{HASH}version {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yyextra->space_tokens = 0;
|
||||
return HASH_VERSION;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
|||
/* glcpp doesn't handle #extension, #version, or #pragma directives.
|
||||
* Simply pass them through to the main compiler's lexer/parser. */
|
||||
{HASH}(extension|pragma)[^\n]+ {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
yylineno++;
|
||||
yycolumn = 0;
|
||||
return OTHER;
|
||||
|
|
@ -219,17 +219,17 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
|||
}
|
||||
|
||||
{DECIMAL_INTEGER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
{OCTAL_INTEGER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
{HEXADECIMAL_INTEGER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return INTEGER_STRING;
|
||||
}
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
|||
}
|
||||
|
||||
{IDENTIFIER} {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
|
|
@ -283,7 +283,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
|||
}
|
||||
|
||||
{OTHER}+ {
|
||||
yylval->str = talloc_strdup (yyextra, yytext);
|
||||
yylval->str = ralloc_strdup (yyextra, yytext);
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -32,10 +32,6 @@
|
|||
#include "main/core.h" /* for struct gl_extensions */
|
||||
#include "main/mtypes.h" /* for gl_api enum */
|
||||
|
||||
#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
|
||||
#define glcpp_printf(stream, fmt, args, ...) \
|
||||
stream = talloc_asprintf_append(stream, fmt, args)
|
||||
|
||||
static void
|
||||
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
|
||||
|
||||
|
|
@ -79,7 +75,7 @@ _argument_list_length (argument_list_t *list);
|
|||
static token_list_t *
|
||||
_argument_list_member_at (argument_list_t *list, int index);
|
||||
|
||||
/* Note: This function talloc_steal()s the str pointer. */
|
||||
/* Note: This function ralloc_steal()s the str pointer. */
|
||||
static token_t *
|
||||
_token_create_str (void *ctx, int type, char *str);
|
||||
|
||||
|
|
@ -89,7 +85,7 @@ _token_create_ival (void *ctx, int type, int ival);
|
|||
static token_list_t *
|
||||
_token_list_create (void *ctx);
|
||||
|
||||
/* Note: This function calls talloc_steal on token. */
|
||||
/* Note: This function calls ralloc_steal on token. */
|
||||
static void
|
||||
_token_list_append (token_list_t *list, token_t *token);
|
||||
|
||||
|
|
@ -189,12 +185,12 @@ input:
|
|||
|
||||
line:
|
||||
control_line {
|
||||
glcpp_print(parser->output, "\n");
|
||||
ralloc_strcat (&parser->output, "\n");
|
||||
}
|
||||
| text_line {
|
||||
_glcpp_parser_print_expanded_token_list (parser, $1);
|
||||
glcpp_print(parser->output, "\n");
|
||||
talloc_free ($1);
|
||||
ralloc_strcat (&parser->output, "\n");
|
||||
ralloc_free ($1);
|
||||
}
|
||||
| expanded_line
|
||||
| HASH non_directive
|
||||
|
|
@ -223,9 +219,9 @@ control_line:
|
|||
macro_t *macro = hash_table_find (parser->defines, $2);
|
||||
if (macro) {
|
||||
hash_table_remove (parser->defines, $2);
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
}
|
||||
talloc_free ($2);
|
||||
ralloc_free ($2);
|
||||
}
|
||||
| HASH_IF conditional_tokens NEWLINE {
|
||||
/* Be careful to only evaluate the 'if' expression if
|
||||
|
|
@ -258,12 +254,12 @@ control_line:
|
|||
}
|
||||
| HASH_IFDEF IDENTIFIER junk NEWLINE {
|
||||
macro_t *macro = hash_table_find (parser->defines, $2);
|
||||
talloc_free ($2);
|
||||
ralloc_free ($2);
|
||||
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
|
||||
}
|
||||
| HASH_IFNDEF IDENTIFIER junk NEWLINE {
|
||||
macro_t *macro = hash_table_find (parser->defines, $2);
|
||||
talloc_free ($2);
|
||||
ralloc_free ($2);
|
||||
_glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL);
|
||||
}
|
||||
| HASH_ELIF conditional_tokens NEWLINE {
|
||||
|
|
@ -310,7 +306,7 @@ control_line:
|
|||
macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
|
||||
if (macro) {
|
||||
hash_table_remove (parser->defines, "__VERSION__");
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
}
|
||||
add_builtin_define (parser, "__VERSION__", $2);
|
||||
|
||||
|
|
@ -325,7 +321,7 @@ control_line:
|
|||
if ($2 >= 130 || $2 == 100)
|
||||
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
|
||||
|
||||
glcpp_printf(parser->output, "#version %" PRIiMAX, $2);
|
||||
ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, $2);
|
||||
}
|
||||
| HASH NEWLINE
|
||||
;
|
||||
|
|
@ -426,12 +422,12 @@ identifier_list:
|
|||
IDENTIFIER {
|
||||
$$ = _string_list_create (parser);
|
||||
_string_list_append_item ($$, $1);
|
||||
talloc_steal ($$, $1);
|
||||
ralloc_steal ($$, $1);
|
||||
}
|
||||
| identifier_list ',' IDENTIFIER {
|
||||
$$ = $1;
|
||||
_string_list_append_item ($$, $3);
|
||||
talloc_steal ($$, $3);
|
||||
ralloc_steal ($$, $3);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -559,7 +555,7 @@ _string_list_create (void *ctx)
|
|||
{
|
||||
string_list_t *list;
|
||||
|
||||
list = talloc (ctx, string_list_t);
|
||||
list = ralloc (ctx, string_list_t);
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
|
||||
|
|
@ -571,8 +567,8 @@ _string_list_append_item (string_list_t *list, const char *str)
|
|||
{
|
||||
string_node_t *node;
|
||||
|
||||
node = talloc (list, string_node_t);
|
||||
node->str = talloc_strdup (node, str);
|
||||
node = ralloc (list, string_node_t);
|
||||
node->str = ralloc_strdup (node, str);
|
||||
|
||||
node->next = NULL;
|
||||
|
||||
|
|
@ -650,7 +646,7 @@ _argument_list_create (void *ctx)
|
|||
{
|
||||
argument_list_t *list;
|
||||
|
||||
list = talloc (ctx, argument_list_t);
|
||||
list = ralloc (ctx, argument_list_t);
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
|
||||
|
|
@ -662,7 +658,7 @@ _argument_list_append (argument_list_t *list, token_list_t *argument)
|
|||
{
|
||||
argument_node_t *node;
|
||||
|
||||
node = talloc (list, argument_node_t);
|
||||
node = ralloc (list, argument_node_t);
|
||||
node->argument = argument;
|
||||
|
||||
node->next = NULL;
|
||||
|
|
@ -713,15 +709,17 @@ _argument_list_member_at (argument_list_t *list, int index)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Note: This function talloc_steal()s the str pointer. */
|
||||
/* Note: This function ralloc_steal()s the str pointer. */
|
||||
token_t *
|
||||
_token_create_str (void *ctx, int type, char *str)
|
||||
{
|
||||
token_t *token;
|
||||
|
||||
token = talloc (ctx, token_t);
|
||||
token = ralloc (ctx, token_t);
|
||||
token->type = type;
|
||||
token->value.str = talloc_steal (token, str);
|
||||
token->value.str = str;
|
||||
|
||||
ralloc_steal (token, str);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
|
@ -731,7 +729,7 @@ _token_create_ival (void *ctx, int type, int ival)
|
|||
{
|
||||
token_t *token;
|
||||
|
||||
token = talloc (ctx, token_t);
|
||||
token = ralloc (ctx, token_t);
|
||||
token->type = type;
|
||||
token->value.ival = ival;
|
||||
|
||||
|
|
@ -743,7 +741,7 @@ _token_list_create (void *ctx)
|
|||
{
|
||||
token_list_t *list;
|
||||
|
||||
list = talloc (ctx, token_list_t);
|
||||
list = ralloc (ctx, token_list_t);
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
list->non_space_tail = NULL;
|
||||
|
|
@ -756,11 +754,12 @@ _token_list_append (token_list_t *list, token_t *token)
|
|||
{
|
||||
token_node_t *node;
|
||||
|
||||
node = talloc (list, token_node_t);
|
||||
node->token = talloc_steal (list, token);
|
||||
|
||||
node = ralloc (list, token_node_t);
|
||||
node->token = token;
|
||||
node->next = NULL;
|
||||
|
||||
ralloc_steal (list, token);
|
||||
|
||||
if (list->head == NULL) {
|
||||
list->head = node;
|
||||
} else {
|
||||
|
|
@ -799,7 +798,7 @@ _token_list_copy (void *ctx, token_list_t *other)
|
|||
|
||||
copy = _token_list_create (ctx);
|
||||
for (node = other->head; node; node = node->next) {
|
||||
token_t *new_token = talloc (copy, token_t);
|
||||
token_t *new_token = ralloc (copy, token_t);
|
||||
*new_token = *node->token;
|
||||
_token_list_append (copy, new_token);
|
||||
}
|
||||
|
|
@ -819,7 +818,7 @@ _token_list_trim_trailing_space (token_list_t *list)
|
|||
|
||||
while (tail) {
|
||||
next = tail->next;
|
||||
talloc_free (tail);
|
||||
ralloc_free (tail);
|
||||
tail = next;
|
||||
}
|
||||
}
|
||||
|
|
@ -905,51 +904,51 @@ static void
|
|||
_token_print (char **out, token_t *token)
|
||||
{
|
||||
if (token->type < 256) {
|
||||
glcpp_printf (*out, "%c", token->type);
|
||||
ralloc_asprintf_append (out, "%c", token->type);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (token->type) {
|
||||
case INTEGER:
|
||||
glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
|
||||
ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival);
|
||||
break;
|
||||
case IDENTIFIER:
|
||||
case INTEGER_STRING:
|
||||
case OTHER:
|
||||
glcpp_print (*out, token->value.str);
|
||||
ralloc_strcat (out, token->value.str);
|
||||
break;
|
||||
case SPACE:
|
||||
glcpp_print (*out, " ");
|
||||
ralloc_strcat (out, " ");
|
||||
break;
|
||||
case LEFT_SHIFT:
|
||||
glcpp_print (*out, "<<");
|
||||
ralloc_strcat (out, "<<");
|
||||
break;
|
||||
case RIGHT_SHIFT:
|
||||
glcpp_print (*out, ">>");
|
||||
ralloc_strcat (out, ">>");
|
||||
break;
|
||||
case LESS_OR_EQUAL:
|
||||
glcpp_print (*out, "<=");
|
||||
ralloc_strcat (out, "<=");
|
||||
break;
|
||||
case GREATER_OR_EQUAL:
|
||||
glcpp_print (*out, ">=");
|
||||
ralloc_strcat (out, ">=");
|
||||
break;
|
||||
case EQUAL:
|
||||
glcpp_print (*out, "==");
|
||||
ralloc_strcat (out, "==");
|
||||
break;
|
||||
case NOT_EQUAL:
|
||||
glcpp_print (*out, "!=");
|
||||
ralloc_strcat (out, "!=");
|
||||
break;
|
||||
case AND:
|
||||
glcpp_print (*out, "&&");
|
||||
ralloc_strcat (out, "&&");
|
||||
break;
|
||||
case OR:
|
||||
glcpp_print (*out, "||");
|
||||
ralloc_strcat (out, "||");
|
||||
break;
|
||||
case PASTE:
|
||||
glcpp_print (*out, "##");
|
||||
ralloc_strcat (out, "##");
|
||||
break;
|
||||
case COMMA_FINAL:
|
||||
glcpp_print (*out, ",");
|
||||
ralloc_strcat (out, ",");
|
||||
break;
|
||||
case PLACEHOLDER:
|
||||
/* Nothing to print. */
|
||||
|
|
@ -960,7 +959,7 @@ _token_print (char **out, token_t *token)
|
|||
}
|
||||
}
|
||||
|
||||
/* Return a new token (talloc()ed off of 'token') formed by pasting
|
||||
/* Return a new token (ralloc()ed off of 'token') formed by pasting
|
||||
* 'token' and 'other'. Note that this function may return 'token' or
|
||||
* 'other' directly rather than allocating anything new.
|
||||
*
|
||||
|
|
@ -1031,7 +1030,7 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
|
|||
{
|
||||
char *str;
|
||||
|
||||
str = talloc_asprintf (token, "%s%s", token->value.str,
|
||||
str = ralloc_asprintf (token, "%s%s", token->value.str,
|
||||
other->value.str);
|
||||
combined = _token_create_str (token, token->type, str);
|
||||
combined->location = token->location;
|
||||
|
|
@ -1039,11 +1038,11 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
|
|||
}
|
||||
|
||||
glcpp_error (&token->location, parser, "");
|
||||
glcpp_print (parser->info_log, "Pasting \"");
|
||||
ralloc_strcat (&parser->info_log, "Pasting \"");
|
||||
_token_print (&parser->info_log, token);
|
||||
glcpp_print (parser->info_log, "\" and \"");
|
||||
ralloc_strcat (&parser->info_log, "\" and \"");
|
||||
_token_print (&parser->info_log, other);
|
||||
glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
|
||||
ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
|
@ -1085,7 +1084,7 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
|
|||
glcpp_parser_t *parser;
|
||||
int language_version;
|
||||
|
||||
parser = talloc (NULL, glcpp_parser_t);
|
||||
parser = ralloc (NULL, glcpp_parser_t);
|
||||
|
||||
glcpp_lex_init_extra (parser, &parser->scanner);
|
||||
parser->defines = hash_table_ctor (32, hash_table_string_hash,
|
||||
|
|
@ -1102,8 +1101,8 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
|
|||
parser->lex_from_list = NULL;
|
||||
parser->lex_from_node = NULL;
|
||||
|
||||
parser->output = talloc_strdup(parser, "");
|
||||
parser->info_log = talloc_strdup(parser, "");
|
||||
parser->output = ralloc_strdup(parser, "");
|
||||
parser->info_log = ralloc_strdup(parser, "");
|
||||
parser->error = 0;
|
||||
|
||||
/* Add pre-defined macros. */
|
||||
|
|
@ -1145,7 +1144,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser)
|
|||
{
|
||||
glcpp_lex_destroy (parser->scanner);
|
||||
hash_table_dtor (parser->defines);
|
||||
talloc_free (parser);
|
||||
ralloc_free (parser);
|
||||
}
|
||||
|
||||
typedef enum function_status
|
||||
|
|
@ -1316,7 +1315,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
|
|||
|
||||
/* Replace a macro defined as empty with a SPACE token. */
|
||||
if (macro->replacements == NULL) {
|
||||
talloc_free (arguments);
|
||||
ralloc_free (arguments);
|
||||
return _token_list_create_with_one_space (parser);
|
||||
}
|
||||
|
||||
|
|
@ -1472,7 +1471,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
|
|||
token_list_t *expansion;
|
||||
token_t *final;
|
||||
|
||||
str = talloc_strdup (parser, token->value.str);
|
||||
str = ralloc_strdup (parser, token->value.str);
|
||||
final = _token_create_str (parser, OTHER, str);
|
||||
expansion = _token_list_create (parser);
|
||||
_token_list_append (expansion, final);
|
||||
|
|
@ -1508,8 +1507,8 @@ _active_list_push (active_list_t *list,
|
|||
{
|
||||
active_list_t *node;
|
||||
|
||||
node = talloc (list, active_list_t);
|
||||
node->identifier = talloc_strdup (node, identifier);
|
||||
node = ralloc (list, active_list_t);
|
||||
node->identifier = ralloc_strdup (node, identifier);
|
||||
node->marker = marker;
|
||||
node->next = list;
|
||||
|
||||
|
|
@ -1525,7 +1524,7 @@ _active_list_pop (active_list_t *list)
|
|||
return NULL;
|
||||
|
||||
node = list->next;
|
||||
talloc_free (list);
|
||||
ralloc_free (list);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
|
@ -1674,17 +1673,18 @@ _define_object_macro (glcpp_parser_t *parser,
|
|||
if (loc != NULL)
|
||||
_check_for_reserved_macro_name(parser, loc, identifier);
|
||||
|
||||
macro = talloc (parser, macro_t);
|
||||
macro = ralloc (parser, macro_t);
|
||||
|
||||
macro->is_function = 0;
|
||||
macro->parameters = NULL;
|
||||
macro->identifier = talloc_strdup (macro, identifier);
|
||||
macro->replacements = talloc_steal (macro, replacements);
|
||||
macro->identifier = ralloc_strdup (macro, identifier);
|
||||
macro->replacements = replacements;
|
||||
ralloc_steal (macro, replacements);
|
||||
|
||||
previous = hash_table_find (parser->defines, identifier);
|
||||
if (previous) {
|
||||
if (_macro_equal (macro, previous)) {
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
return;
|
||||
}
|
||||
glcpp_error (loc, parser, "Redefinition of macro %s\n",
|
||||
|
|
@ -1705,17 +1705,18 @@ _define_function_macro (glcpp_parser_t *parser,
|
|||
|
||||
_check_for_reserved_macro_name(parser, loc, identifier);
|
||||
|
||||
macro = talloc (parser, macro_t);
|
||||
macro = ralloc (parser, macro_t);
|
||||
ralloc_steal (macro, parameters);
|
||||
ralloc_steal (macro, replacements);
|
||||
|
||||
macro->is_function = 1;
|
||||
macro->parameters = talloc_steal (macro, parameters);
|
||||
macro->identifier = talloc_strdup (macro, identifier);
|
||||
macro->replacements = talloc_steal (macro, replacements);
|
||||
|
||||
macro->parameters = parameters;
|
||||
macro->identifier = ralloc_strdup (macro, identifier);
|
||||
macro->replacements = replacements;
|
||||
previous = hash_table_find (parser->defines, identifier);
|
||||
if (previous) {
|
||||
if (_macro_equal (macro, previous)) {
|
||||
talloc_free (macro);
|
||||
ralloc_free (macro);
|
||||
return;
|
||||
}
|
||||
glcpp_error (loc, parser, "Redefinition of macro %s\n",
|
||||
|
|
@ -1791,7 +1792,7 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
|
|||
node = parser->lex_from_node;
|
||||
|
||||
if (node == NULL) {
|
||||
talloc_free (parser->lex_from_list);
|
||||
ralloc_free (parser->lex_from_list);
|
||||
parser->lex_from_list = NULL;
|
||||
return NEWLINE;
|
||||
}
|
||||
|
|
@ -1820,13 +1821,13 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
|
|||
_token_list_append (parser->lex_from_list, node->token);
|
||||
}
|
||||
|
||||
talloc_free (list);
|
||||
ralloc_free (list);
|
||||
|
||||
parser->lex_from_node = parser->lex_from_list->head;
|
||||
|
||||
/* It's possible the list consisted of nothing but whitespace. */
|
||||
if (parser->lex_from_node == NULL) {
|
||||
talloc_free (parser->lex_from_list);
|
||||
ralloc_free (parser->lex_from_list);
|
||||
parser->lex_from_list = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -1841,7 +1842,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
|
|||
if (parser->skip_stack)
|
||||
current = parser->skip_stack->type;
|
||||
|
||||
node = talloc (parser, skip_node_t);
|
||||
node = ralloc (parser, skip_node_t);
|
||||
node->loc = *loc;
|
||||
|
||||
if (current == SKIP_NO_SKIP) {
|
||||
|
|
@ -1886,5 +1887,5 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
|
|||
|
||||
node = parser->skip_stack;
|
||||
parser->skip_stack = node->next;
|
||||
talloc_free (node);
|
||||
ralloc_free (node);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ load_text_fd (void *ctx, int fd)
|
|||
while (1) {
|
||||
if (total_read + CHUNK + 1 > text_size) {
|
||||
text_size = text_size ? text_size * 2 : CHUNK + 1;
|
||||
text = talloc_realloc_size (ctx, text, text_size);
|
||||
text = reralloc_size (ctx, text, text_size);
|
||||
if (text == NULL) {
|
||||
fprintf (stderr, "Out of memory\n");
|
||||
return NULL;
|
||||
|
|
@ -64,7 +64,7 @@ load_text_fd (void *ctx, int fd)
|
|||
if (bytes < 0) {
|
||||
fprintf (stderr, "Error while reading: %s\n",
|
||||
strerror (errno));
|
||||
talloc_free (text);
|
||||
ralloc_free (text);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -107,8 +107,8 @@ int
|
|||
main (int argc, char *argv[])
|
||||
{
|
||||
char *filename = NULL;
|
||||
void *ctx = talloc(NULL, void*);
|
||||
char *info_log = talloc_strdup(ctx, "");
|
||||
void *ctx = ralloc(NULL, void*);
|
||||
char *info_log = ralloc_strdup(ctx, "");
|
||||
const char *shader;
|
||||
int ret;
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ main (int argc, char *argv[])
|
|||
printf("%s", shader);
|
||||
fprintf(stderr, "%s", info_log);
|
||||
|
||||
talloc_free(ctx);
|
||||
ralloc_free(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <talloc.h>
|
||||
#include "../ralloc.h"
|
||||
|
||||
#include "program/hash_table.h"
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ void
|
|||
glcpp_parser_destroy (glcpp_parser_t *parser);
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
||||
preprocess(void *ralloc_ctx, const char **shader, char **info_log,
|
||||
const struct gl_extensions *extensions, int api);
|
||||
|
||||
/* Functions for writing to the info log */
|
||||
|
|
|
|||
|
|
@ -33,16 +33,15 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
|
|||
va_list ap;
|
||||
|
||||
parser->error = 1;
|
||||
parser->info_log = talloc_asprintf_append(parser->info_log,
|
||||
"%u:%u(%u): "
|
||||
ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
|
||||
"preprocessor error: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_start(ap, fmt);
|
||||
parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
|
||||
ralloc_vasprintf_append(&parser->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
parser->info_log = talloc_strdup_append(parser->info_log, "\n");
|
||||
ralloc_strcat(&parser->info_log, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -50,16 +49,15 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
parser->info_log = talloc_asprintf_append(parser->info_log,
|
||||
"%u:%u(%u): "
|
||||
ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
|
||||
"preprocessor warning: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_start(ap, fmt);
|
||||
parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
|
||||
ralloc_vasprintf_append(&parser->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
parser->info_log = talloc_strdup_append(parser->info_log, "\n");
|
||||
ralloc_strcat(&parser->info_log, "\n");
|
||||
}
|
||||
|
||||
/* Searches backwards for '^ *#' from a given starting point. */
|
||||
|
|
@ -92,7 +90,7 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
|
|||
{
|
||||
int in_continued_line = 0;
|
||||
int extra_newlines = 0;
|
||||
char *clean = talloc_strdup(ctx, "");
|
||||
char *clean = ralloc_strdup(ctx, "");
|
||||
const char *search_start = shader;
|
||||
const char *newline;
|
||||
while ((newline = strchr(search_start, '\n')) != NULL) {
|
||||
|
|
@ -122,27 +120,27 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
|
|||
}
|
||||
if (in_continued_line) {
|
||||
/* Copy everything before the \ */
|
||||
clean = talloc_strndup_append(clean, shader, backslash - shader);
|
||||
ralloc_strncat(&clean, shader, backslash - shader);
|
||||
shader = newline + 1;
|
||||
extra_newlines++;
|
||||
}
|
||||
} else if (in_continued_line) {
|
||||
/* Copy everything up to and including the \n */
|
||||
clean = talloc_strndup_append(clean, shader, newline - shader + 1);
|
||||
ralloc_strncat(&clean, shader, newline - shader + 1);
|
||||
shader = newline + 1;
|
||||
/* Output extra newlines to make line numbers match */
|
||||
for (; extra_newlines > 0; extra_newlines--)
|
||||
clean = talloc_strdup_append(clean, "\n");
|
||||
ralloc_strcat(&clean, "\n");
|
||||
in_continued_line = 0;
|
||||
}
|
||||
search_start = newline + 1;
|
||||
}
|
||||
clean = talloc_strdup_append(clean, shader);
|
||||
ralloc_strcat(&clean, shader);
|
||||
return clean;
|
||||
}
|
||||
|
||||
int
|
||||
preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
||||
preprocess(void *ralloc_ctx, const char **shader, char **info_log,
|
||||
const struct gl_extensions *extensions, int api)
|
||||
{
|
||||
int errors;
|
||||
|
|
@ -156,9 +154,9 @@ preprocess(void *talloc_ctx, const char **shader, char **info_log,
|
|||
if (parser->skip_stack)
|
||||
glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
|
||||
|
||||
*info_log = talloc_strdup_append(*info_log, parser->info_log);
|
||||
ralloc_strcat(info_log, parser->info_log);
|
||||
|
||||
talloc_steal(talloc_ctx, parser->output);
|
||||
ralloc_steal(ralloc_ctx, parser->output);
|
||||
*shader = parser->output;
|
||||
|
||||
errors = parser->error;
|
||||
|
|
|
|||
|
|
@ -2537,7 +2537,7 @@ YY_RULE_SETUP
|
|||
{
|
||||
struct _mesa_glsl_parse_state *state = yyextra;
|
||||
void *ctx = state;
|
||||
yylval->identifier = talloc_strdup(ctx, yytext);
|
||||
yylval->identifier = ralloc_strdup(ctx, yytext);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
YY_BREAK
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ row_major KEYWORD(130, 999, ROW_MAJOR);
|
|||
[_a-zA-Z][_a-zA-Z0-9]* {
|
||||
struct _mesa_glsl_parse_state *state = yyextra;
|
||||
void *ctx = state;
|
||||
yylval->identifier = talloc_strdup(ctx, yytext);
|
||||
yylval->identifier = ralloc_strdup(ctx, yytext);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2844,7 +2844,7 @@ yyreduce:
|
|||
/* FINISHME: Check against implementation support versions. */
|
||||
state->language_version = (yyvsp[(2) - (3)].n);
|
||||
state->version_string =
|
||||
talloc_asprintf(state, "GLSL%s %d.%02d",
|
||||
ralloc_asprintf(state, "GLSL%s %d.%02d",
|
||||
state->es_shader ? " ES" : "",
|
||||
state->language_version / 100,
|
||||
state->language_version % 100);
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ version_statement:
|
|||
/* FINISHME: Check against implementation support versions. */
|
||||
state->language_version = $2;
|
||||
state->version_string =
|
||||
talloc_asprintf(state, "GLSL%s %d.%02d",
|
||||
ralloc_asprintf(state, "GLSL%s %d.%02d",
|
||||
state->es_shader ? " ES" : "",
|
||||
state->language_version / 100,
|
||||
state->language_version % 100);
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@
|
|||
#include <assert.h>
|
||||
|
||||
extern "C" {
|
||||
#include <talloc.h>
|
||||
#include "main/core.h" /* for struct gl_context */
|
||||
}
|
||||
|
||||
#include "ralloc.h"
|
||||
#include "ast.h"
|
||||
#include "glsl_parser_extras.h"
|
||||
#include "glsl_parser.h"
|
||||
|
|
@ -48,7 +48,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
|
|||
this->scanner = NULL;
|
||||
this->translation_unit.make_empty();
|
||||
this->symbols = new(mem_ctx) glsl_symbol_table;
|
||||
this->info_log = talloc_strdup(mem_ctx, "");
|
||||
this->info_log = ralloc_strdup(mem_ctx, "");
|
||||
this->error = false;
|
||||
this->loop_or_switch_nesting = NULL;
|
||||
|
||||
|
|
@ -104,15 +104,14 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
|||
state->error = true;
|
||||
|
||||
assert(state->info_log != NULL);
|
||||
state->info_log = talloc_asprintf_append(state->info_log,
|
||||
"%u:%u(%u): error: ",
|
||||
ralloc_asprintf_append(&state->info_log, "%u:%u(%u): error: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_start(ap, fmt);
|
||||
state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
|
||||
ralloc_vasprintf_append(&state->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
state->info_log = talloc_strdup_append(state->info_log, "\n");
|
||||
ralloc_strcat(&state->info_log, "\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -123,15 +122,14 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
|||
va_list ap;
|
||||
|
||||
assert(state->info_log != NULL);
|
||||
state->info_log = talloc_asprintf_append(state->info_log,
|
||||
"%u:%u(%u): warning: ",
|
||||
ralloc_asprintf_append(&state->info_log, "%u:%u(%u): warning: ",
|
||||
locp->source,
|
||||
locp->first_line,
|
||||
locp->first_column);
|
||||
va_start(ap, fmt);
|
||||
state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
|
||||
ralloc_vasprintf_append(&state->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
state->info_log = talloc_strdup_append(state->info_log, "\n");
|
||||
ralloc_strcat(&state->info_log, "\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -712,7 +710,7 @@ ast_struct_specifier::ast_struct_specifier(char *identifier,
|
|||
{
|
||||
if (identifier == NULL) {
|
||||
static unsigned anon_count = 1;
|
||||
identifier = talloc_asprintf(this, "#anon_struct_%04x", anon_count);
|
||||
identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count);
|
||||
anon_count++;
|
||||
}
|
||||
name = identifier;
|
||||
|
|
|
|||
|
|
@ -46,21 +46,21 @@ struct _mesa_glsl_parse_state {
|
|||
_mesa_glsl_parse_state(struct gl_context *ctx, GLenum target,
|
||||
void *mem_ctx);
|
||||
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *mem = talloc_zero_size(ctx, size);
|
||||
void *mem = rzalloc_size(ctx, size);
|
||||
assert(mem != NULL);
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just
|
||||
* talloc_free in that case. */
|
||||
* ralloc_free in that case. */
|
||||
static void operator delete(void *mem)
|
||||
{
|
||||
talloc_free(mem);
|
||||
ralloc_free(mem);
|
||||
}
|
||||
|
||||
void *scanner;
|
||||
|
|
|
|||
|
|
@ -26,19 +26,19 @@
|
|||
|
||||
class symbol_table_entry {
|
||||
public:
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *entry = talloc_size(ctx, size);
|
||||
void *entry = ralloc_size(ctx, size);
|
||||
assert(entry != NULL);
|
||||
return entry;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just talloc_free. */
|
||||
/* If the user *does* call delete, that's OK, we will just ralloc_free. */
|
||||
static void operator delete(void *entry)
|
||||
{
|
||||
talloc_free(entry);
|
||||
ralloc_free(entry);
|
||||
}
|
||||
|
||||
symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {}
|
||||
|
|
@ -54,13 +54,13 @@ glsl_symbol_table::glsl_symbol_table()
|
|||
{
|
||||
this->language_version = 120;
|
||||
this->table = _mesa_symbol_table_ctor();
|
||||
this->mem_ctx = talloc_init("symbol table entries");
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
}
|
||||
|
||||
glsl_symbol_table::~glsl_symbol_table()
|
||||
{
|
||||
_mesa_symbol_table_dtor(table);
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
void glsl_symbol_table::push_scope()
|
||||
|
|
|
|||
|
|
@ -44,36 +44,34 @@ class symbol_table_entry;
|
|||
*/
|
||||
struct glsl_symbol_table {
|
||||
private:
|
||||
static int
|
||||
static void
|
||||
_glsl_symbol_table_destructor (glsl_symbol_table *table)
|
||||
{
|
||||
table->~glsl_symbol_table();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *table;
|
||||
|
||||
table = talloc_size(ctx, size);
|
||||
table = ralloc_size(ctx, size);
|
||||
assert(table != NULL);
|
||||
|
||||
talloc_set_destructor(table, (int (*)(void*)) _glsl_symbol_table_destructor);
|
||||
ralloc_set_destructor(table, (void (*)(void*)) _glsl_symbol_table_destructor);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just
|
||||
* talloc_free in that case. Here, C++ will have already called the
|
||||
* destructor so tell talloc not to do that again. */
|
||||
* ralloc_free in that case. Here, C++ will have already called the
|
||||
* destructor so tell ralloc not to do that again. */
|
||||
static void operator delete(void *table)
|
||||
{
|
||||
talloc_set_destructor(table, NULL);
|
||||
talloc_free(table);
|
||||
ralloc_set_destructor(table, NULL);
|
||||
ralloc_free(table);
|
||||
}
|
||||
|
||||
glsl_symbol_table();
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ hash_table *glsl_type::record_types = NULL;
|
|||
void *glsl_type::mem_ctx = NULL;
|
||||
|
||||
void
|
||||
glsl_type::init_talloc_type_ctx(void)
|
||||
glsl_type::init_ralloc_type_ctx(void)
|
||||
{
|
||||
if (glsl_type::mem_ctx == NULL) {
|
||||
glsl_type::mem_ctx = talloc_autofree_context();
|
||||
glsl_type::mem_ctx = ralloc_autofree_context();
|
||||
assert(glsl_type::mem_ctx != NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -55,8 +55,8 @@ glsl_type::glsl_type(GLenum gl_type,
|
|||
vector_elements(vector_elements), matrix_columns(matrix_columns),
|
||||
length(0)
|
||||
{
|
||||
init_talloc_type_ctx();
|
||||
this->name = talloc_strdup(this->mem_ctx, name);
|
||||
init_ralloc_type_ctx();
|
||||
this->name = ralloc_strdup(this->mem_ctx, name);
|
||||
/* Neither dimension is zero or both dimensions are zero.
|
||||
*/
|
||||
assert((vector_elements == 0) == (matrix_columns == 0));
|
||||
|
|
@ -73,8 +73,8 @@ glsl_type::glsl_type(GLenum gl_type,
|
|||
vector_elements(0), matrix_columns(0),
|
||||
length(0)
|
||||
{
|
||||
init_talloc_type_ctx();
|
||||
this->name = talloc_strdup(this->mem_ctx, name);
|
||||
init_ralloc_type_ctx();
|
||||
this->name = ralloc_strdup(this->mem_ctx, name);
|
||||
memset(& fields, 0, sizeof(fields));
|
||||
}
|
||||
|
||||
|
|
@ -88,13 +88,13 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
init_talloc_type_ctx();
|
||||
this->name = talloc_strdup(this->mem_ctx, name);
|
||||
this->fields.structure = talloc_array(this->mem_ctx,
|
||||
init_ralloc_type_ctx();
|
||||
this->name = ralloc_strdup(this->mem_ctx, name);
|
||||
this->fields.structure = ralloc_array(this->mem_ctx,
|
||||
glsl_struct_field, length);
|
||||
for (i = 0; i < length; i++) {
|
||||
this->fields.structure[i].type = fields[i].type;
|
||||
this->fields.structure[i].name = talloc_strdup(this->fields.structure,
|
||||
this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
|
||||
fields[i].name);
|
||||
}
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
|
|||
* NUL.
|
||||
*/
|
||||
const unsigned name_length = strlen(array->name) + 10 + 3;
|
||||
char *const n = (char *) talloc_size(this->mem_ctx, name_length);
|
||||
char *const n = (char *) ralloc_size(this->mem_ctx, name_length);
|
||||
|
||||
if (length == 0)
|
||||
snprintf(n, name_length, "%s[]", array->name);
|
||||
|
|
@ -354,7 +354,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
|
|||
if (t == NULL) {
|
||||
t = new glsl_type(base, array_size);
|
||||
|
||||
hash_table_insert(array_types, (void *) t, talloc_strdup(mem_ctx, key));
|
||||
hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key));
|
||||
}
|
||||
|
||||
assert(t->base_type == GLSL_TYPE_ARRAY);
|
||||
|
|
|
|||
|
|
@ -31,9 +31,10 @@
|
|||
|
||||
extern "C" {
|
||||
#include "GL/gl.h"
|
||||
#include <talloc.h>
|
||||
}
|
||||
|
||||
#include "ralloc.h"
|
||||
|
||||
struct _mesa_glsl_parse_state;
|
||||
struct glsl_symbol_table;
|
||||
|
||||
|
|
@ -77,28 +78,28 @@ struct glsl_type {
|
|||
* and \c GLSL_TYPE_UINT are valid.
|
||||
*/
|
||||
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'mem_ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size)
|
||||
{
|
||||
if (glsl_type::mem_ctx == NULL) {
|
||||
glsl_type::mem_ctx = talloc_init("glsl_type");
|
||||
glsl_type::mem_ctx = ralloc_context(NULL);
|
||||
assert(glsl_type::mem_ctx != NULL);
|
||||
}
|
||||
|
||||
void *type;
|
||||
|
||||
type = talloc_size(glsl_type::mem_ctx, size);
|
||||
type = ralloc_size(glsl_type::mem_ctx, size);
|
||||
assert(type != NULL);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just
|
||||
* talloc_free in that case. */
|
||||
* ralloc_free in that case. */
|
||||
static void operator delete(void *type)
|
||||
{
|
||||
talloc_free(type);
|
||||
ralloc_free(type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -386,13 +387,13 @@ struct glsl_type {
|
|||
|
||||
private:
|
||||
/**
|
||||
* talloc context for all glsl_type allocations
|
||||
* ralloc context for all glsl_type allocations
|
||||
*
|
||||
* Set on the first call to \c glsl_type::new.
|
||||
*/
|
||||
static void *mem_ctx;
|
||||
|
||||
void init_talloc_type_ctx(void);
|
||||
void init_ralloc_type_ctx(void);
|
||||
|
||||
/** Constructor for vector and matrix types */
|
||||
glsl_type(GLenum gl_type,
|
||||
|
|
|
|||
|
|
@ -578,7 +578,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
|||
|| type->is_record() || type->is_array());
|
||||
|
||||
if (type->is_array()) {
|
||||
this->array_elements = talloc_array(this, ir_constant *, type->length);
|
||||
this->array_elements = ralloc_array(this, ir_constant *, type->length);
|
||||
unsigned i = 0;
|
||||
foreach_list(node, value_list) {
|
||||
ir_constant *value = (ir_constant *) node;
|
||||
|
|
@ -1036,7 +1036,7 @@ ir_dereference_array::ir_dereference_array(ir_rvalue *value,
|
|||
ir_dereference_array::ir_dereference_array(ir_variable *var,
|
||||
ir_rvalue *array_index)
|
||||
{
|
||||
void *ctx = talloc_parent(var);
|
||||
void *ctx = ralloc_parent(var);
|
||||
|
||||
this->ir_type = ir_type_dereference_array;
|
||||
this->array_index = array_index;
|
||||
|
|
@ -1069,7 +1069,7 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value,
|
|||
{
|
||||
this->ir_type = ir_type_dereference_record;
|
||||
this->record = value;
|
||||
this->field = talloc_strdup(this, field);
|
||||
this->field = ralloc_strdup(this, field);
|
||||
this->type = (this->record != NULL)
|
||||
? this->record->type->field_type(field) : glsl_type::error_type;
|
||||
}
|
||||
|
|
@ -1078,11 +1078,11 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value,
|
|||
ir_dereference_record::ir_dereference_record(ir_variable *var,
|
||||
const char *field)
|
||||
{
|
||||
void *ctx = talloc_parent(var);
|
||||
void *ctx = ralloc_parent(var);
|
||||
|
||||
this->ir_type = ir_type_dereference_record;
|
||||
this->record = new(ctx) ir_dereference_variable(var);
|
||||
this->field = talloc_strdup(this, field);
|
||||
this->field = ralloc_strdup(this, field);
|
||||
this->type = (this->record != NULL)
|
||||
? this->record->type->field_type(field) : glsl_type::error_type;
|
||||
}
|
||||
|
|
@ -1245,7 +1245,7 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
|
|||
ir_swizzle *
|
||||
ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
|
||||
{
|
||||
void *ctx = talloc_parent(val);
|
||||
void *ctx = ralloc_parent(val);
|
||||
|
||||
/* For each possible swizzle character, this table encodes the value in
|
||||
* \c idx_map that represents the 0th element of the vector. For invalid
|
||||
|
|
@ -1334,7 +1334,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
|
|||
{
|
||||
this->ir_type = ir_type_variable;
|
||||
this->type = type;
|
||||
this->name = talloc_strdup(this, name);
|
||||
this->name = ralloc_strdup(this, name);
|
||||
this->explicit_location = false;
|
||||
this->location = -1;
|
||||
this->warn_extension = NULL;
|
||||
|
|
@ -1426,7 +1426,7 @@ ir_function_signature::replace_parameters(exec_list *new_params)
|
|||
ir_function::ir_function(const char *name)
|
||||
{
|
||||
this->ir_type = ir_type_function;
|
||||
this->name = talloc_strdup(this, name);
|
||||
this->name = ralloc_strdup(this, name);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1492,7 +1492,7 @@ steal_memory(ir_instruction *ir, void *new_ctx)
|
|||
}
|
||||
}
|
||||
|
||||
talloc_steal(new_ctx, ir);
|
||||
ralloc_steal(new_ctx, ir);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,7 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C" {
|
||||
#include <talloc.h>
|
||||
}
|
||||
|
||||
#include "ralloc.h"
|
||||
#include "glsl_types.h"
|
||||
#include "list.h"
|
||||
#include "ir_visitor.h"
|
||||
|
|
@ -986,7 +983,7 @@ public:
|
|||
/**
|
||||
* Get a generic ir_call object when an error occurs
|
||||
*
|
||||
* Any allocation will be performed with 'ctx' as talloc owner.
|
||||
* Any allocation will be performed with 'ctx' as ralloc owner.
|
||||
*/
|
||||
static ir_call *get_error_instruction(void *ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
|
|||
ir_constant *c = new(mem_ctx) ir_constant;
|
||||
|
||||
c->type = this->type;
|
||||
c->array_elements = talloc_array(c, ir_constant *, this->type->length);
|
||||
c->array_elements = ralloc_array(c, ir_constant *, this->type->length);
|
||||
for (unsigned i = 0; i < this->type->length; i++) {
|
||||
c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ ir_expression::constant_expression_value()
|
|||
components = op[1]->type->components();
|
||||
}
|
||||
|
||||
void *ctx = talloc_parent(this);
|
||||
void *ctx = ralloc_parent(this);
|
||||
|
||||
/* Handle array operations here, rather than below. */
|
||||
if (op[0]->type->is_array()) {
|
||||
|
|
@ -845,7 +845,7 @@ ir_swizzle::constant_expression_value()
|
|||
}
|
||||
}
|
||||
|
||||
void *ctx = talloc_parent(this);
|
||||
void *ctx = ralloc_parent(this);
|
||||
return new(ctx) ir_constant(this->type, &data);
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -868,7 +868,7 @@ ir_dereference_variable::constant_expression_value()
|
|||
if (!var->constant_value)
|
||||
return NULL;
|
||||
|
||||
return var->constant_value->clone(talloc_parent(var), NULL);
|
||||
return var->constant_value->clone(ralloc_parent(var), NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -879,7 +879,7 @@ ir_dereference_array::constant_expression_value()
|
|||
ir_constant *idx = this->array_index->constant_expression_value();
|
||||
|
||||
if ((array != NULL) && (idx != NULL)) {
|
||||
void *ctx = talloc_parent(this);
|
||||
void *ctx = ralloc_parent(this);
|
||||
if (array->type->is_matrix()) {
|
||||
/* Array access of a matrix results in a vector.
|
||||
*/
|
||||
|
|
@ -984,7 +984,7 @@ ir_call::constant_expression_value()
|
|||
* - Fill "data" with appopriate constant data
|
||||
* - Return an ir_constant directly.
|
||||
*/
|
||||
void *mem_ctx = talloc_parent(this);
|
||||
void *mem_ctx = ralloc_parent(this);
|
||||
ir_expression *expr = NULL;
|
||||
|
||||
ir_constant_data data;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ ir_expression_flattening_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||
if (!ir || !this->predicate(ir))
|
||||
return;
|
||||
|
||||
void *ctx = talloc_parent(ir);
|
||||
void *ctx = ralloc_parent(ir);
|
||||
|
||||
var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary);
|
||||
base_ir->insert_before(var);
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ private:
|
|||
* \param dest Destination instruction stream where new \c ir_function and
|
||||
* \c ir_function_signature nodes will be stored
|
||||
* \param symbols Symbol table where new functions will be stored
|
||||
* \param mem_ctx talloc memory context used for new allocations
|
||||
* \param mem_ctx ralloc memory context used for new allocations
|
||||
*/
|
||||
void
|
||||
import_prototypes(const exec_list *source, exec_list *dest,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
|
|||
}
|
||||
|
||||
read_instructions(instructions, expr, NULL);
|
||||
talloc_free(expr);
|
||||
ralloc_free(expr);
|
||||
|
||||
if (debug)
|
||||
validate_ir_tree(instructions);
|
||||
|
|
@ -106,21 +106,19 @@ ir_reader::ir_read_error(s_expression *expr, const char *fmt, ...)
|
|||
state->error = true;
|
||||
|
||||
if (state->current_function != NULL)
|
||||
state->info_log = talloc_asprintf_append(state->info_log,
|
||||
"In function %s:\n",
|
||||
state->current_function->function_name());
|
||||
state->info_log = talloc_strdup_append(state->info_log, "error: ");
|
||||
ralloc_asprintf_append(&state->info_log, "In function %s:\n",
|
||||
state->current_function->function_name());
|
||||
ralloc_strcat(&state->info_log, "error: ");
|
||||
|
||||
va_start(ap, fmt);
|
||||
state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
|
||||
ralloc_vasprintf_append(&state->info_log, fmt, ap);
|
||||
va_end(ap);
|
||||
state->info_log = talloc_strdup_append(state->info_log, "\n");
|
||||
ralloc_strcat(&state->info_log, "\n");
|
||||
|
||||
if (expr != NULL) {
|
||||
state->info_log = talloc_strdup_append(state->info_log,
|
||||
"...in this context:\n ");
|
||||
ralloc_strcat(&state->info_log, "...in this context:\n ");
|
||||
expr->print();
|
||||
state->info_log = talloc_strdup_append(state->info_log, "\n\n");
|
||||
ralloc_strcat(&state->info_log, "\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ ir_validate::visit_enter(ir_function *ir)
|
|||
ir_visitor_status
|
||||
ir_validate::visit_leave(ir_function *ir)
|
||||
{
|
||||
assert(talloc_parent(ir->name) == ir);
|
||||
assert(ralloc_parent(ir->name) == ir);
|
||||
|
||||
this->current_function = NULL;
|
||||
return visit_continue;
|
||||
|
|
@ -450,7 +450,7 @@ ir_validate::visit(ir_variable *ir)
|
|||
* declared before it is dereferenced.
|
||||
*/
|
||||
if (ir->name)
|
||||
assert(talloc_parent(ir->name) == ir);
|
||||
assert(ralloc_parent(ir->name) == ir);
|
||||
|
||||
hash_table_insert(ht, ir, ir);
|
||||
return visit_continue;
|
||||
|
|
|
|||
|
|
@ -54,13 +54,13 @@ class ir_variable_refcount_visitor : public ir_hierarchical_visitor {
|
|||
public:
|
||||
ir_variable_refcount_visitor(void)
|
||||
{
|
||||
this->mem_ctx = talloc_new(NULL);
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->variable_list.make_empty();
|
||||
}
|
||||
|
||||
~ir_variable_refcount_visitor(void)
|
||||
{
|
||||
talloc_free(this->mem_ctx);
|
||||
ralloc_free(this->mem_ctx);
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit(ir_variable *);
|
||||
|
|
|
|||
|
|
@ -172,9 +172,9 @@ linker_error_printf(gl_shader_program *prog, const char *fmt, ...)
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
prog->InfoLog = talloc_strdup_append(prog->InfoLog, "error: ");
|
||||
ralloc_strcat(&prog->InfoLog, "error: ");
|
||||
va_start(ap, fmt);
|
||||
prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, ap);
|
||||
ralloc_vasprintf_append(&prog->InfoLog, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +432,7 @@ cross_validate_globals(struct gl_shader_program *prog,
|
|||
* FINISHME: will fail.
|
||||
*/
|
||||
existing->constant_value =
|
||||
var->constant_value->clone(talloc_parent(existing), NULL);
|
||||
var->constant_value->clone(ralloc_parent(existing), NULL);
|
||||
}
|
||||
|
||||
if (existing->invariant != var->invariant) {
|
||||
|
|
@ -1015,7 +1015,7 @@ add_uniform(void *mem_ctx, exec_list *uniforms, struct hash_table *ht,
|
|||
if (type->is_record()) {
|
||||
for (unsigned int i = 0; i < type->length; i++) {
|
||||
const glsl_type *field_type = type->fields.structure[i].type;
|
||||
char *field_name = talloc_asprintf(mem_ctx, "%s.%s", name,
|
||||
char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name,
|
||||
type->fields.structure[i].name);
|
||||
|
||||
add_uniform(mem_ctx, uniforms, ht, field_name, field_type,
|
||||
|
|
@ -1031,7 +1031,7 @@ add_uniform(void *mem_ctx, exec_list *uniforms, struct hash_table *ht,
|
|||
/* Array of structures. */
|
||||
if (array_elem_type->is_record()) {
|
||||
for (unsigned int i = 0; i < type->length; i++) {
|
||||
char *elem_name = talloc_asprintf(mem_ctx, "%s[%d]", name, i);
|
||||
char *elem_name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
|
||||
add_uniform(mem_ctx, uniforms, ht, elem_name, array_elem_type,
|
||||
shader_type, next_shader_pos, total_uniforms);
|
||||
}
|
||||
|
|
@ -1093,7 +1093,7 @@ assign_uniform_locations(struct gl_shader_program *prog)
|
|||
unsigned total_uniforms = 0;
|
||||
hash_table *ht = hash_table_ctor(32, hash_table_string_hash,
|
||||
hash_table_string_compare);
|
||||
void *mem_ctx = talloc_new(NULL);
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
|
||||
if (prog->_LinkedShaders[i] == NULL)
|
||||
|
|
@ -1122,7 +1122,7 @@ assign_uniform_locations(struct gl_shader_program *prog)
|
|||
}
|
||||
}
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
|
||||
gl_uniform_list *ul = (gl_uniform_list *)
|
||||
calloc(1, sizeof(gl_uniform_list));
|
||||
|
|
@ -1490,16 +1490,16 @@ assign_varying_locations(struct gl_shader_program *prog,
|
|||
void
|
||||
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
{
|
||||
void *mem_ctx = talloc_init("temporary linker context");
|
||||
void *mem_ctx = ralloc_context(NULL); // temporary linker context
|
||||
|
||||
prog->LinkStatus = false;
|
||||
prog->Validated = false;
|
||||
prog->_Used = false;
|
||||
|
||||
if (prog->InfoLog != NULL)
|
||||
talloc_free(prog->InfoLog);
|
||||
ralloc_free(prog->InfoLog);
|
||||
|
||||
prog->InfoLog = talloc_strdup(NULL, "");
|
||||
prog->InfoLog = ralloc_strdup(NULL, "");
|
||||
|
||||
/* Separate the shaders into groups based on their type.
|
||||
*/
|
||||
|
|
@ -1694,5 +1694,5 @@ done:
|
|||
reparent_ir(prog->_LinkedShaders[i]->ir, prog->_LinkedShaders[i]->ir);
|
||||
}
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,37 +66,33 @@
|
|||
|
||||
#ifndef __cplusplus
|
||||
#include <stddef.h>
|
||||
#include <talloc.h>
|
||||
#else
|
||||
extern "C" {
|
||||
#include <talloc.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "ralloc.h"
|
||||
|
||||
struct exec_node {
|
||||
struct exec_node *next;
|
||||
struct exec_node *prev;
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *node;
|
||||
|
||||
node = talloc_size(ctx, size);
|
||||
node = ralloc_size(ctx, size);
|
||||
assert(node != NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just
|
||||
* talloc_free in that case. */
|
||||
* ralloc_free in that case. */
|
||||
static void operator delete(void *node)
|
||||
{
|
||||
talloc_free(node);
|
||||
ralloc_free(node);
|
||||
}
|
||||
|
||||
exec_node() : next(NULL), prev(NULL)
|
||||
|
|
@ -289,23 +285,23 @@ struct exec_list {
|
|||
struct exec_node *tail_pred;
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *node;
|
||||
|
||||
node = talloc_size(ctx, size);
|
||||
node = ralloc_size(ctx, size);
|
||||
assert(node != NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/* If the user *does* call delete, that's OK, we will just
|
||||
* talloc_free in that case. */
|
||||
* ralloc_free in that case. */
|
||||
static void operator delete(void *node)
|
||||
{
|
||||
talloc_free(node);
|
||||
ralloc_free(node);
|
||||
}
|
||||
|
||||
exec_list()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ loop_state::loop_state()
|
|||
{
|
||||
this->ht = hash_table_ctor(0, hash_table_pointer_hash,
|
||||
hash_table_pointer_compare);
|
||||
this->mem_ctx = talloc_init("loop state");
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->loop_found = false;
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ loop_state::loop_state()
|
|||
loop_state::~loop_state()
|
||||
{
|
||||
hash_table_dtor(this->ht);
|
||||
talloc_free(this->mem_ctx);
|
||||
ralloc_free(this->mem_ctx);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -78,8 +78,8 @@ loop_variable_state::get(const ir_variable *ir)
|
|||
loop_variable *
|
||||
loop_variable_state::insert(ir_variable *var)
|
||||
{
|
||||
void *mem_ctx = talloc_parent(this);
|
||||
loop_variable *lv = talloc_zero(mem_ctx, loop_variable);
|
||||
void *mem_ctx = ralloc_parent(this);
|
||||
loop_variable *lv = rzalloc(mem_ctx, loop_variable);
|
||||
|
||||
lv->var = var;
|
||||
|
||||
|
|
@ -93,8 +93,8 @@ loop_variable_state::insert(ir_variable *var)
|
|||
loop_terminator *
|
||||
loop_variable_state::insert(ir_if *if_stmt)
|
||||
{
|
||||
void *mem_ctx = talloc_parent(this);
|
||||
loop_terminator *t = talloc_zero(mem_ctx, loop_terminator);
|
||||
void *mem_ctx = ralloc_parent(this);
|
||||
loop_terminator *t = rzalloc(mem_ctx, loop_terminator);
|
||||
|
||||
t->ir = if_stmt;
|
||||
this->terminators.push_tail(t);
|
||||
|
|
@ -450,7 +450,7 @@ get_basic_induction_increment(ir_assignment *ir, hash_table *var_hash)
|
|||
}
|
||||
|
||||
if ((inc != NULL) && (rhs->operation == ir_binop_sub)) {
|
||||
void *mem_ctx = talloc_parent(ir);
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
inc = new(mem_ctx) ir_expression(ir_unop_neg,
|
||||
inc->type,
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
|
|||
if (from == NULL || to == NULL || increment == NULL)
|
||||
return -1;
|
||||
|
||||
void *mem_ctx = talloc_init("%s", __func__);
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
ir_expression *const sub =
|
||||
new(mem_ctx) ir_expression(ir_binop_sub, from->type, to, from);
|
||||
|
|
@ -147,7 +147,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
|
|||
}
|
||||
}
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
return (valid_loop) ? iter_value : -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
|
|||
*/
|
||||
break_ir->remove();
|
||||
|
||||
void *const mem_ctx = talloc_parent(ir);
|
||||
void *const mem_ctx = ralloc_parent(ir);
|
||||
ir_instruction *ir_to_replace = ir;
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
|
|
@ -182,7 +182,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
|
|||
}
|
||||
}
|
||||
|
||||
void *const mem_ctx = talloc_parent(ir);
|
||||
void *const mem_ctx = ralloc_parent(ir);
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
exec_list copy_list;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ lower_discard_visitor::visit_leave(ir_if *ir)
|
|||
if (then_discard == NULL && else_discard == NULL)
|
||||
return visit_continue;
|
||||
|
||||
void *mem_ctx = talloc_parent(ir);
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
ir_variable *temp = new(mem_ctx) ir_variable(glsl_type::bool_type,
|
||||
"discard_cond_temp",
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir)
|
|||
if (found_control_flow)
|
||||
return visit_continue;
|
||||
|
||||
void *mem_ctx = talloc_parent(ir);
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
/* Store the condition to a variable so the assignment conditions are
|
||||
* simpler.
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
|
|||
|
||||
assert(orig_expr->get_num_operands() <= 2);
|
||||
|
||||
mem_ctx = talloc_parent(orig_assign);
|
||||
mem_ctx = ralloc_parent(orig_assign);
|
||||
|
||||
ir_dereference_variable *lhs_deref =
|
||||
orig_assign->lhs->as_dereference_variable();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public:
|
|||
* that implements noise. No hardware has a noise instruction.
|
||||
*/
|
||||
if (expr->operation == ir_unop_noise) {
|
||||
*rvalue = ir_constant::zero(talloc_parent(expr), expr->type);
|
||||
*rvalue = ir_constant::zero(ralloc_parent(expr), expr->type);
|
||||
this->progress = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ lower_texture_projection_visitor::visit_leave(ir_texture *ir)
|
|||
if (!ir->projector)
|
||||
return visit_continue;
|
||||
|
||||
void *mem_ctx = talloc_parent(ir);
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
ir_variable *var = new(mem_ctx) ir_variable(ir->projector->type,
|
||||
"projector", ir_var_auto);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ struct assignment_generator
|
|||
/* Just clone the rest of the deref chain when trying to get at the
|
||||
* underlying variable.
|
||||
*/
|
||||
void *mem_ctx = talloc_parent(base_ir);
|
||||
void *mem_ctx = ralloc_parent(base_ir);
|
||||
ir_dereference *element =
|
||||
new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, NULL),
|
||||
new(mem_ctx) ir_constant(i));
|
||||
|
|
@ -91,7 +91,7 @@ struct switch_generator
|
|||
linear_sequence_max_length(linear_sequence_max_length),
|
||||
condition_components(condition_components)
|
||||
{
|
||||
this->mem_ctx = talloc_parent(index);
|
||||
this->mem_ctx = ralloc_parent(index);
|
||||
}
|
||||
|
||||
void linear_sequence(unsigned begin, unsigned end, exec_list *list)
|
||||
|
|
@ -275,7 +275,7 @@ public:
|
|||
? orig_deref->array->type->length
|
||||
: orig_deref->array->type->matrix_columns;
|
||||
|
||||
void *const mem_ctx = talloc_parent(base_ir);
|
||||
void *const mem_ctx = ralloc_parent(base_ir);
|
||||
|
||||
/* Temporary storage for either the result of the dereference of
|
||||
* the array, or the RHS that's being assigned into the
|
||||
|
|
@ -342,7 +342,7 @@ public:
|
|||
if (needs_lowering(orig_deref)) {
|
||||
ir_variable* var = convert_dereference_array(orig_deref, 0);
|
||||
assert(var);
|
||||
*pir = new(talloc_parent(base_ir)) ir_dereference_variable(var);
|
||||
*pir = new(ralloc_parent(base_ir)) ir_dereference_variable(var);
|
||||
this->progress = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue
|
|||
orig_deref->array->type->is_array())
|
||||
return ir;
|
||||
|
||||
void *mem_ctx = talloc_parent(ir);
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir)
|
|||
orig_deref->array->type->is_array())
|
||||
return visit_continue;
|
||||
|
||||
void *mem_ctx = talloc_parent(ir);
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir)
|
|||
if (!ir_constant)
|
||||
return ir;
|
||||
|
||||
void *ctx = talloc_parent(ir);
|
||||
void *ctx = ralloc_parent(ir);
|
||||
this->progress = true;
|
||||
return new(ctx) ir_swizzle(deref->array,
|
||||
ir_constant->value.i[0], 0, 0, 0, 1);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||
if (this->dont_lower_swz && is_extended_swizzle(expr))
|
||||
return;
|
||||
|
||||
/* FINISHME: Is this the right thing to use for the talloc context?
|
||||
/* FINISHME: Is this the right thing to use for the ralloc context?
|
||||
*/
|
||||
void *const mem_ctx = expr;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
|
|||
(void) ctx;
|
||||
|
||||
assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
|
||||
shader = talloc_zero(NULL, struct gl_shader);
|
||||
shader = rzalloc(NULL, struct gl_shader);
|
||||
if (shader) {
|
||||
shader->Type = type;
|
||||
shader->Name = name;
|
||||
|
|
@ -101,7 +101,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
|
|||
ctx->Driver.NewShader = _mesa_new_shader;
|
||||
}
|
||||
|
||||
/* Returned string will have 'ctx' as its talloc owner. */
|
||||
/* Returned string will have 'ctx' as its ralloc owner. */
|
||||
static char *
|
||||
load_text_file(void *ctx, const char *file_name)
|
||||
{
|
||||
|
|
@ -118,7 +118,7 @@ load_text_file(void *ctx, const char *file_name)
|
|||
size = ftell(fp);
|
||||
fseek(fp, 0L, SEEK_SET);
|
||||
|
||||
text = (char *) talloc_size(ctx, size + 1);
|
||||
text = (char *) ralloc_size(ctx, size + 1);
|
||||
if (text != NULL) {
|
||||
do {
|
||||
size_t bytes = fread(text + total_read,
|
||||
|
|
@ -236,14 +236,14 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
|
|||
shader->num_builtins_to_link = state->num_builtins_to_link;
|
||||
|
||||
if (shader->InfoLog)
|
||||
talloc_free(shader->InfoLog);
|
||||
ralloc_free(shader->InfoLog);
|
||||
|
||||
shader->InfoLog = state->info_log;
|
||||
|
||||
/* Retain any live IR, but trash the rest. */
|
||||
reparent_ir(shader->ir, shader);
|
||||
|
||||
talloc_free(state);
|
||||
ralloc_free(state);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -268,16 +268,16 @@ main(int argc, char **argv)
|
|||
|
||||
struct gl_shader_program *whole_program;
|
||||
|
||||
whole_program = talloc_zero (NULL, struct gl_shader_program);
|
||||
whole_program = rzalloc (NULL, struct gl_shader_program);
|
||||
assert(whole_program != NULL);
|
||||
|
||||
for (/* empty */; argc > optind; optind++) {
|
||||
whole_program->Shaders = (struct gl_shader **)
|
||||
talloc_realloc(whole_program, whole_program->Shaders,
|
||||
struct gl_shader *, whole_program->NumShaders + 1);
|
||||
whole_program->Shaders =
|
||||
reralloc(whole_program, whole_program->Shaders,
|
||||
struct gl_shader *, whole_program->NumShaders + 1);
|
||||
assert(whole_program->Shaders != NULL);
|
||||
|
||||
struct gl_shader *shader = talloc_zero(whole_program, gl_shader);
|
||||
struct gl_shader *shader = rzalloc(whole_program, gl_shader);
|
||||
|
||||
whole_program->Shaders[whole_program->NumShaders] = shader;
|
||||
whole_program->NumShaders++;
|
||||
|
|
@ -320,9 +320,9 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++)
|
||||
talloc_free(whole_program->_LinkedShaders[i]);
|
||||
ralloc_free(whole_program->_LinkedShaders[i]);
|
||||
|
||||
talloc_free(whole_program);
|
||||
ralloc_free(whole_program);
|
||||
_mesa_glsl_release_types();
|
||||
_mesa_glsl_release_functions();
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
|
|||
}
|
||||
|
||||
if (this->mem_ctx == NULL)
|
||||
this->mem_ctx = talloc_parent(ir);
|
||||
this->mem_ctx = ralloc_parent(ir);
|
||||
|
||||
switch (ir->operation) {
|
||||
case ir_unop_logic_not: {
|
||||
|
|
|
|||
|
|
@ -78,13 +78,13 @@ public:
|
|||
ir_constant_propagation_visitor()
|
||||
{
|
||||
progress = false;
|
||||
mem_ctx = talloc_new(0);
|
||||
mem_ctx = ralloc_context(0);
|
||||
this->acp = new(mem_ctx) exec_list;
|
||||
this->kills = new(mem_ctx) exec_list;
|
||||
}
|
||||
~ir_constant_propagation_visitor()
|
||||
{
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit_enter(class ir_loop *);
|
||||
|
|
@ -195,7 +195,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||
}
|
||||
}
|
||||
|
||||
*rvalue = new(talloc_parent(deref)) ir_constant(type, &data);
|
||||
*rvalue = new(ralloc_parent(deref)) ir_constant(type, &data);
|
||||
this->progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,13 +71,13 @@ public:
|
|||
ir_copy_propagation_visitor()
|
||||
{
|
||||
progress = false;
|
||||
mem_ctx = talloc_new(0);
|
||||
mem_ctx = ralloc_context(0);
|
||||
this->acp = new(mem_ctx) exec_list;
|
||||
this->kills = new(mem_ctx) exec_list;
|
||||
}
|
||||
~ir_copy_propagation_visitor()
|
||||
{
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit(class ir_dereference_variable *);
|
||||
|
|
@ -325,7 +325,7 @@ ir_copy_propagation_visitor::add_copy(ir_assignment *ir)
|
|||
* calling us. Just flag it to not execute, and someone else
|
||||
* will clean up the mess.
|
||||
*/
|
||||
ir->condition = new(talloc_parent(ir)) ir_constant(false);
|
||||
ir->condition = new(ralloc_parent(ir)) ir_constant(false);
|
||||
this->progress = true;
|
||||
} else {
|
||||
entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var);
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ dead_code_local_basic_block(ir_instruction *first,
|
|||
bool *out_progress = (bool *)data;
|
||||
bool progress = false;
|
||||
|
||||
void *ctx = talloc_new(NULL);
|
||||
void *ctx = ralloc_context(NULL);
|
||||
/* Safe looping, since process_assignment */
|
||||
for (ir = first, ir_next = (ir_instruction *)first->next;;
|
||||
ir = ir_next, ir_next = (ir_instruction *)ir->next) {
|
||||
|
|
@ -212,7 +212,7 @@ dead_code_local_basic_block(ir_instruction *first,
|
|||
break;
|
||||
}
|
||||
*out_progress = progress;
|
||||
talloc_free(ctx);
|
||||
ralloc_free(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@
|
|||
public:
|
||||
ir_dead_functions_visitor()
|
||||
{
|
||||
this->mem_ctx = talloc_new(NULL);
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
}
|
||||
|
||||
~ir_dead_functions_visitor()
|
||||
{
|
||||
talloc_free(this->mem_ctx);
|
||||
ralloc_free(this->mem_ctx);
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit_enter(ir_function_signature *);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ do_function_inlining(exec_list *instructions)
|
|||
static void
|
||||
replace_return_with_assignment(ir_instruction *ir, void *data)
|
||||
{
|
||||
void *ctx = talloc_parent(ir);
|
||||
void *ctx = ralloc_parent(ir);
|
||||
ir_variable *retval = (ir_variable *)data;
|
||||
ir_return *ret = ir->as_return();
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ replace_return_with_assignment(ir_instruction *ir, void *data)
|
|||
ir_rvalue *
|
||||
ir_call::generate_inline(ir_instruction *next_ir)
|
||||
{
|
||||
void *ctx = talloc_parent(this);
|
||||
void *ctx = ralloc_parent(this);
|
||||
ir_variable **parameters;
|
||||
int num_parameters;
|
||||
int i;
|
||||
|
|
@ -357,7 +357,7 @@ ir_sampler_replacement_visitor::replace_deref(ir_dereference **deref)
|
|||
{
|
||||
ir_dereference_variable *deref_var = (*deref)->as_dereference_variable();
|
||||
if (deref_var && deref_var->var == this->sampler) {
|
||||
*deref = this->deref->clone(talloc_parent(*deref), NULL);
|
||||
*deref = this->deref->clone(ralloc_parent(*deref), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
ir_variable **components;
|
||||
|
||||
/** talloc_parent(this->var) -- the shader's talloc context. */
|
||||
/** ralloc_parent(this->var) -- the shader's ralloc context. */
|
||||
void *mem_ctx;
|
||||
};
|
||||
|
||||
|
|
@ -74,13 +74,13 @@ class ir_structure_reference_visitor : public ir_hierarchical_visitor {
|
|||
public:
|
||||
ir_structure_reference_visitor(void)
|
||||
{
|
||||
this->mem_ctx = talloc_new(NULL);
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->variable_list.make_empty();
|
||||
}
|
||||
|
||||
~ir_structure_reference_visitor(void)
|
||||
{
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit(ir_variable *);
|
||||
|
|
@ -322,7 +322,7 @@ do_structure_splitting(exec_list *instructions)
|
|||
if (refs.variable_list.is_empty())
|
||||
return false;
|
||||
|
||||
void *mem_ctx = talloc_new(NULL);
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
/* Replace the decls of the structures to be split with their split
|
||||
* components.
|
||||
|
|
@ -331,14 +331,14 @@ do_structure_splitting(exec_list *instructions)
|
|||
variable_entry2 *entry = (variable_entry2 *)iter.get();
|
||||
const struct glsl_type *type = entry->var->type;
|
||||
|
||||
entry->mem_ctx = talloc_parent(entry->var);
|
||||
entry->mem_ctx = ralloc_parent(entry->var);
|
||||
|
||||
entry->components = talloc_array(mem_ctx,
|
||||
entry->components = ralloc_array(mem_ctx,
|
||||
ir_variable *,
|
||||
type->length);
|
||||
|
||||
for (unsigned int i = 0; i < entry->var->type->length; i++) {
|
||||
const char *name = talloc_asprintf(mem_ctx, "%s_%s",
|
||||
const char *name = ralloc_asprintf(mem_ctx, "%s_%s",
|
||||
entry->var->name,
|
||||
type->fields.structure[i].name);
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ do_structure_splitting(exec_list *instructions)
|
|||
ir_structure_splitting_visitor split(&refs.variable_list);
|
||||
visit_list_elements(&split, instructions);
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
s_symbol::s_symbol(const char *tmp, size_t n)
|
||||
{
|
||||
this->str = talloc_strndup (this, tmp, n);
|
||||
this->str = ralloc_strndup (this, tmp, n);
|
||||
assert(this->str != NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public:
|
|||
* Read an S-Expression from the given string.
|
||||
* Advances the supplied pointer to just after the expression read.
|
||||
*
|
||||
* Any allocation will be performed with 'ctx' as the talloc owner.
|
||||
* Any allocation will be performed with 'ctx' as the ralloc owner.
|
||||
*/
|
||||
static s_expression *read_expression(void *ctx, const char *&src);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ brw_cubemap_normalize_visitor::visit_leave(ir_texture *ir)
|
|||
if (ir->sampler->type->sampler_dimensionality != GLSL_SAMPLER_DIM_CUBE)
|
||||
return visit_continue;
|
||||
|
||||
void *mem_ctx = talloc_parent(ir);
|
||||
void *mem_ctx = ralloc_parent(ir);
|
||||
|
||||
ir_variable *var = new(mem_ctx) ir_variable(ir->coordinate->type,
|
||||
"coordinate", ir_var_auto);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type)
|
|||
{
|
||||
struct brw_shader *shader;
|
||||
|
||||
shader = talloc_zero(NULL, struct brw_shader);
|
||||
shader = rzalloc(NULL, struct brw_shader);
|
||||
if (shader) {
|
||||
shader->base.Type = type;
|
||||
shader->base.Name = name;
|
||||
|
|
@ -69,7 +69,7 @@ struct gl_shader_program *
|
|||
brw_new_shader_program(struct gl_context *ctx, GLuint name)
|
||||
{
|
||||
struct brw_shader_program *prog;
|
||||
prog = talloc_zero(NULL, struct brw_shader_program);
|
||||
prog = rzalloc(NULL, struct brw_shader_program);
|
||||
if (prog) {
|
||||
prog->base.Name = name;
|
||||
_mesa_init_shader_program(ctx, &prog->base);
|
||||
|
|
@ -95,11 +95,11 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
struct brw_shader *shader =
|
||||
(struct brw_shader *)prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
|
||||
if (shader != NULL) {
|
||||
void *mem_ctx = talloc_new(NULL);
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
bool progress;
|
||||
|
||||
if (shader->ir)
|
||||
talloc_free(shader->ir);
|
||||
ralloc_free(shader->ir);
|
||||
shader->ir = new(shader) exec_list;
|
||||
clone_ir_list(mem_ctx, shader->ir, shader->base.ir);
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
validate_ir_tree(shader->ir);
|
||||
|
||||
reparent_ir(shader->ir, shader->ir);
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
if (!_mesa_ir_link_shader(ctx, prog))
|
||||
|
|
@ -236,8 +236,8 @@ fs_visitor::virtual_grf_alloc(int size)
|
|||
virtual_grf_array_size = 16;
|
||||
else
|
||||
virtual_grf_array_size *= 2;
|
||||
virtual_grf_sizes = talloc_realloc(mem_ctx, virtual_grf_sizes,
|
||||
int, virtual_grf_array_size);
|
||||
virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int,
|
||||
virtual_grf_array_size);
|
||||
|
||||
/* This slot is always unused. */
|
||||
virtual_grf_sizes[0] = 0;
|
||||
|
|
@ -2065,7 +2065,7 @@ fs_visitor::emit_fb_writes()
|
|||
}
|
||||
|
||||
for (int target = 0; target < c->key.nr_color_regions; target++) {
|
||||
this->current_annotation = talloc_asprintf(this->mem_ctx,
|
||||
this->current_annotation = ralloc_asprintf(this->mem_ctx,
|
||||
"FB write target %d",
|
||||
target);
|
||||
if (this->frag_color || this->frag_data) {
|
||||
|
|
@ -2755,8 +2755,8 @@ void
|
|||
fs_visitor::calculate_live_intervals()
|
||||
{
|
||||
int num_vars = this->virtual_grf_next;
|
||||
int *def = talloc_array(mem_ctx, int, num_vars);
|
||||
int *use = talloc_array(mem_ctx, int, num_vars);
|
||||
int *def = ralloc_array(mem_ctx, int, num_vars);
|
||||
int *use = ralloc_array(mem_ctx, int, num_vars);
|
||||
int loop_depth = 0;
|
||||
int loop_start = 0;
|
||||
int bb_header_ip = 0;
|
||||
|
|
@ -2839,8 +2839,8 @@ fs_visitor::calculate_live_intervals()
|
|||
}
|
||||
}
|
||||
|
||||
talloc_free(this->virtual_grf_def);
|
||||
talloc_free(this->virtual_grf_use);
|
||||
ralloc_free(this->virtual_grf_def);
|
||||
ralloc_free(this->virtual_grf_use);
|
||||
this->virtual_grf_def = def;
|
||||
this->virtual_grf_use = use;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ extern "C" {
|
|||
#include "brw_context.h"
|
||||
#include "brw_eu.h"
|
||||
#include "brw_wm.h"
|
||||
#include "talloc.h"
|
||||
}
|
||||
#include "../glsl/glsl_types.h"
|
||||
#include "../glsl/ir.h"
|
||||
|
|
@ -83,13 +82,13 @@ enum fs_opcodes {
|
|||
|
||||
class fs_reg {
|
||||
public:
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *node;
|
||||
|
||||
node = talloc_size(ctx, size);
|
||||
node = ralloc_size(ctx, size);
|
||||
assert(node != NULL);
|
||||
|
||||
return node;
|
||||
|
|
@ -193,13 +192,13 @@ static const fs_reg reg_null_d(ARF, BRW_ARF_NULL, BRW_REGISTER_TYPE_D);
|
|||
|
||||
class fs_inst : public exec_node {
|
||||
public:
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *node;
|
||||
|
||||
node = talloc_zero_size(ctx, size);
|
||||
node = rzalloc_size(ctx, size);
|
||||
assert(node != NULL);
|
||||
|
||||
return node;
|
||||
|
|
@ -361,7 +360,7 @@ public:
|
|||
this->fp = brw->fragment_program;
|
||||
this->intel = &brw->intel;
|
||||
this->ctx = &intel->ctx;
|
||||
this->mem_ctx = talloc_new(NULL);
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->shader = shader;
|
||||
this->fail = false;
|
||||
this->variable_ht = hash_table_ctor(0,
|
||||
|
|
@ -405,7 +404,7 @@ public:
|
|||
|
||||
~fs_visitor()
|
||||
{
|
||||
talloc_free(this->mem_ctx);
|
||||
ralloc_free(this->mem_ctx);
|
||||
hash_table_dtor(this->variable_ht);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
|
|||
return visit_continue;
|
||||
|
||||
if (!this->mem_ctx)
|
||||
this->mem_ctx = talloc_parent(ir);
|
||||
this->mem_ctx = ralloc_parent(ir);
|
||||
|
||||
for (i = 0; i < expr->get_num_operands(); i++) {
|
||||
if (expr->operands[i]->type->is_vector()) {
|
||||
|
|
|
|||
|
|
@ -233,8 +233,8 @@ fs_visitor::assign_regs()
|
|||
}
|
||||
|
||||
|
||||
talloc_free(g);
|
||||
talloc_free(regs);
|
||||
ralloc_free(g);
|
||||
ralloc_free(regs);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -272,8 +272,8 @@ fs_visitor::assign_regs()
|
|||
|
||||
this->grf_used = last_grf + 1;
|
||||
|
||||
talloc_free(g);
|
||||
talloc_free(regs);
|
||||
ralloc_free(g);
|
||||
ralloc_free(regs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public:
|
|||
instruction_scheduler(fs_visitor *v, void *mem_ctx, int virtual_grf_count)
|
||||
{
|
||||
this->v = v;
|
||||
this->mem_ctx = talloc_new(mem_ctx);
|
||||
this->mem_ctx = ralloc_context(mem_ctx);
|
||||
this->virtual_grf_count = virtual_grf_count;
|
||||
this->instructions.make_empty();
|
||||
this->instructions_to_schedule = 0;
|
||||
|
|
@ -136,7 +136,7 @@ public:
|
|||
|
||||
~instruction_scheduler()
|
||||
{
|
||||
talloc_free(this->mem_ctx);
|
||||
ralloc_free(this->mem_ctx);
|
||||
}
|
||||
void add_barrier_deps(schedule_node *n);
|
||||
void add_dep(schedule_node *before, schedule_node *after, int latency);
|
||||
|
|
@ -195,11 +195,11 @@ instruction_scheduler::add_dep(schedule_node *before, schedule_node *after,
|
|||
else
|
||||
before->child_array_size *= 2;
|
||||
|
||||
before->children = talloc_realloc(mem_ctx, before->children,
|
||||
schedule_node *,
|
||||
before->child_array_size);
|
||||
before->child_latency = talloc_realloc(mem_ctx, before->child_latency,
|
||||
int, before->child_array_size);
|
||||
before->children = reralloc(mem_ctx, before->children,
|
||||
schedule_node *,
|
||||
before->child_array_size);
|
||||
before->child_latency = reralloc(mem_ctx, before->child_latency,
|
||||
int, before->child_array_size);
|
||||
}
|
||||
|
||||
before->children[before->child_count] = after;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
ir_variable *components[4];
|
||||
|
||||
/** talloc_parent(this->var) -- the shader's talloc context. */
|
||||
/** ralloc_parent(this->var) -- the shader's ralloc context. */
|
||||
void *mem_ctx;
|
||||
};
|
||||
|
||||
|
|
@ -77,13 +77,13 @@ class ir_vector_reference_visitor : public ir_hierarchical_visitor {
|
|||
public:
|
||||
ir_vector_reference_visitor(void)
|
||||
{
|
||||
this->mem_ctx = talloc_new(NULL);
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->variable_list.make_empty();
|
||||
}
|
||||
|
||||
~ir_vector_reference_visitor(void)
|
||||
{
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit(ir_variable *);
|
||||
|
|
@ -358,7 +358,7 @@ brw_do_vector_splitting(exec_list *instructions)
|
|||
if (refs.variable_list.is_empty())
|
||||
return false;
|
||||
|
||||
void *mem_ctx = talloc_new(NULL);
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
/* Replace the decls of the vectors to be split with their split
|
||||
* components.
|
||||
|
|
@ -368,10 +368,10 @@ brw_do_vector_splitting(exec_list *instructions)
|
|||
const struct glsl_type *type;
|
||||
type = glsl_type::get_instance(entry->var->type->base_type, 1, 1);
|
||||
|
||||
entry->mem_ctx = talloc_parent(entry->var);
|
||||
entry->mem_ctx = ralloc_parent(entry->var);
|
||||
|
||||
for (unsigned int i = 0; i < entry->var->type->vector_elements; i++) {
|
||||
const char *name = talloc_asprintf(mem_ctx, "%s_%c",
|
||||
const char *name = ralloc_asprintf(mem_ctx, "%s_%c",
|
||||
entry->var->name,
|
||||
"xyzw"[i]);
|
||||
|
||||
|
|
@ -386,7 +386,7 @@ brw_do_vector_splitting(exec_list *instructions)
|
|||
ir_vector_splitting_visitor split(&refs.variable_list);
|
||||
visit_list_elements(&split, instructions);
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "program/program.h"
|
||||
#include "program/programopt.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "talloc.h"
|
||||
#include "../glsl/ralloc.h"
|
||||
|
||||
#include "brw_context.h"
|
||||
#include "brw_wm.h"
|
||||
|
|
@ -115,7 +115,7 @@ shader_error(struct gl_context *ctx, struct gl_program *prog, const char *msg)
|
|||
shader = _mesa_lookup_shader_program(ctx, prog->Id);
|
||||
|
||||
if (shader) {
|
||||
shader->InfoLog = talloc_strdup_append(shader->InfoLog, msg);
|
||||
ralloc_strcat(&shader->InfoLog, msg);
|
||||
shader->LinkStatus = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#include "program/program.h"
|
||||
#include "program/prog_parameter.h"
|
||||
#include "program/prog_uniform.h"
|
||||
#include "talloc.h"
|
||||
#include "ralloc.h"
|
||||
#include <stdbool.h>
|
||||
#include "../glsl/glsl_parser_extras.h"
|
||||
|
||||
|
|
@ -1137,9 +1137,9 @@ validate_program(struct gl_context *ctx, GLuint program)
|
|||
if (!shProg->Validated) {
|
||||
/* update info log */
|
||||
if (shProg->InfoLog) {
|
||||
talloc_free(shProg->InfoLog);
|
||||
ralloc_free(shProg->InfoLog);
|
||||
}
|
||||
shProg->InfoLog = talloc_strdup(shProg, errMsg);
|
||||
shProg->InfoLog = ralloc_strdup(shProg, errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1855,7 +1855,7 @@ _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string)
|
|||
#endif
|
||||
}
|
||||
|
||||
shProg->InfoLog = talloc_strdup_append(shProg->InfoLog, sh->InfoLog);
|
||||
ralloc_strcat(&shProg->InfoLog, sh->InfoLog);
|
||||
}
|
||||
|
||||
delete_shader(ctx, shader);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#include "program/program.h"
|
||||
#include "program/prog_parameter.h"
|
||||
#include "program/prog_uniform.h"
|
||||
#include "talloc.h"
|
||||
#include "ralloc.h"
|
||||
|
||||
/**********************************************************************/
|
||||
/*** Shader object functions ***/
|
||||
|
|
@ -105,7 +105,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
|
|||
struct gl_shader *shader;
|
||||
assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER ||
|
||||
type == GL_GEOMETRY_SHADER_ARB);
|
||||
shader = talloc_zero(NULL, struct gl_shader);
|
||||
shader = rzalloc(NULL, struct gl_shader);
|
||||
if (shader) {
|
||||
shader->Type = type;
|
||||
shader->Name = name;
|
||||
|
|
@ -125,7 +125,7 @@ _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
|
|||
if (sh->Source)
|
||||
free((void *) sh->Source);
|
||||
_mesa_reference_program(ctx, &sh->Program, NULL);
|
||||
talloc_free(sh);
|
||||
ralloc_free(sh);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ static struct gl_shader_program *
|
|||
_mesa_new_shader_program(struct gl_context *ctx, GLuint name)
|
||||
{
|
||||
struct gl_shader_program *shProg;
|
||||
shProg = talloc_zero(NULL, struct gl_shader_program);
|
||||
shProg = rzalloc(NULL, struct gl_shader_program);
|
||||
if (shProg) {
|
||||
shProg->Name = name;
|
||||
_mesa_init_shader_program(ctx, shProg);
|
||||
|
|
@ -316,7 +316,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
if (shProg->InfoLog) {
|
||||
talloc_free(shProg->InfoLog);
|
||||
ralloc_free(shProg->InfoLog);
|
||||
shProg->InfoLog = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ _mesa_delete_shader_program(struct gl_context *ctx, struct gl_shader_program *sh
|
|||
{
|
||||
_mesa_free_shader_program_data(ctx, shProg);
|
||||
|
||||
talloc_free(shProg);
|
||||
ralloc_free(shProg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -105,13 +105,13 @@ extern ir_to_mesa_src_reg ir_to_mesa_undef;
|
|||
|
||||
class ir_to_mesa_instruction : public exec_node {
|
||||
public:
|
||||
/* Callers of this talloc-based new need not call delete. It's
|
||||
* easier to just talloc_free 'ctx' (or any of its ancestors). */
|
||||
/* Callers of this ralloc-based new need not call delete. It's
|
||||
* easier to just ralloc_free 'ctx' (or any of its ancestors). */
|
||||
static void* operator new(size_t size, void *ctx)
|
||||
{
|
||||
void *node;
|
||||
|
||||
node = talloc_zero_size(ctx, size);
|
||||
node = rzalloc_size(ctx, size);
|
||||
assert(node != NULL);
|
||||
|
||||
return node;
|
||||
|
|
@ -318,7 +318,7 @@ fail_link(struct gl_shader_program *prog, const char *fmt, ...)
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, args);
|
||||
ralloc_vasprintf_append(&prog->InfoLog, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
prog->LinkStatus = GL_FALSE;
|
||||
|
|
@ -1570,7 +1570,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir)
|
|||
this->result, src_reg_for_float(element_size));
|
||||
}
|
||||
|
||||
src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg);
|
||||
src_reg.reladdr = ralloc(mem_ctx, ir_to_mesa_src_reg);
|
||||
memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg));
|
||||
}
|
||||
|
||||
|
|
@ -1927,7 +1927,7 @@ ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig)
|
|||
return entry;
|
||||
}
|
||||
|
||||
entry = talloc(mem_ctx, function_entry);
|
||||
entry = ralloc(mem_ctx, function_entry);
|
||||
entry->sig = sig;
|
||||
entry->sig_id = this->next_signature_id++;
|
||||
entry->bgn_inst = NULL;
|
||||
|
|
@ -2264,12 +2264,12 @@ ir_to_mesa_visitor::ir_to_mesa_visitor()
|
|||
next_temp = 1;
|
||||
next_signature_id = 1;
|
||||
current_function = NULL;
|
||||
mem_ctx = talloc_new(NULL);
|
||||
mem_ctx = ralloc_context(NULL);
|
||||
}
|
||||
|
||||
ir_to_mesa_visitor::~ir_to_mesa_visitor()
|
||||
{
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
static struct prog_src_register
|
||||
|
|
@ -2318,8 +2318,8 @@ set_branchtargets(ir_to_mesa_visitor *v,
|
|||
}
|
||||
}
|
||||
|
||||
if_stack = talloc_zero_array(v->mem_ctx, int, if_count);
|
||||
loop_stack = talloc_zero_array(v->mem_ctx, int, loop_count);
|
||||
if_stack = rzalloc_array(v->mem_ctx, int, if_count);
|
||||
loop_stack = rzalloc_array(v->mem_ctx, int, loop_count);
|
||||
|
||||
for (i = 0; i < num_instructions; i++) {
|
||||
switch (mesa_instructions[i].Opcode) {
|
||||
|
|
@ -2462,7 +2462,7 @@ add_uniforms_to_parameters_list(struct gl_shader_program *shader_program,
|
|||
unsigned int next_sampler = 0, num_uniforms = 0;
|
||||
struct uniform_sort *sorted_uniforms;
|
||||
|
||||
sorted_uniforms = talloc_array(NULL, struct uniform_sort,
|
||||
sorted_uniforms = ralloc_array(NULL, struct uniform_sort,
|
||||
shader_program->Uniforms->NumUniforms);
|
||||
|
||||
for (i = 0; i < shader_program->Uniforms->NumUniforms; i++) {
|
||||
|
|
@ -2541,7 +2541,7 @@ add_uniforms_to_parameters_list(struct gl_shader_program *shader_program,
|
|||
}
|
||||
}
|
||||
|
||||
talloc_free(sorted_uniforms);
|
||||
ralloc_free(sorted_uniforms);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2557,7 +2557,7 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
|
|||
|
||||
for (unsigned int i = 0; i < type->length; i++) {
|
||||
const glsl_type *field_type = type->fields.structure[i].type;
|
||||
const char *field_name = talloc_asprintf(mem_ctx, "%s.%s", name,
|
||||
const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name,
|
||||
type->fields.structure[i].name);
|
||||
set_uniform_initializer(ctx, mem_ctx, shader_program, field_name,
|
||||
field_type, field_constant);
|
||||
|
|
@ -2588,7 +2588,7 @@ set_uniform_initializer(struct gl_context *ctx, void *mem_ctx,
|
|||
void *values;
|
||||
|
||||
if (element_type->base_type == GLSL_TYPE_BOOL) {
|
||||
int *conv = talloc_array(mem_ctx, int, element_type->components());
|
||||
int *conv = ralloc_array(mem_ctx, int, element_type->components());
|
||||
for (unsigned int j = 0; j < element_type->components(); j++) {
|
||||
conv[j] = element->value.b[j];
|
||||
}
|
||||
|
|
@ -2634,14 +2634,14 @@ set_uniform_initializers(struct gl_context *ctx,
|
|||
continue;
|
||||
|
||||
if (!mem_ctx)
|
||||
mem_ctx = talloc_new(NULL);
|
||||
mem_ctx = ralloc_context(NULL);
|
||||
|
||||
set_uniform_initializer(ctx, mem_ctx, shader_program, var->name,
|
||||
var->type, var->constant_value);
|
||||
}
|
||||
}
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -2667,7 +2667,7 @@ set_uniform_initializers(struct gl_context *ctx,
|
|||
void
|
||||
ir_to_mesa_visitor::copy_propagate(void)
|
||||
{
|
||||
ir_to_mesa_instruction **acp = talloc_zero_array(mem_ctx,
|
||||
ir_to_mesa_instruction **acp = rzalloc_array(mem_ctx,
|
||||
ir_to_mesa_instruction *,
|
||||
this->next_temp * 4);
|
||||
|
||||
|
|
@ -2771,7 +2771,7 @@ ir_to_mesa_visitor::copy_propagate(void)
|
|||
}
|
||||
}
|
||||
|
||||
talloc_free(acp);
|
||||
ralloc_free(acp);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2870,7 +2870,7 @@ get_mesa_program(struct gl_context *ctx,
|
|||
mesa_instructions =
|
||||
(struct prog_instruction *)calloc(num_instructions,
|
||||
sizeof(*mesa_instructions));
|
||||
mesa_instruction_annotation = talloc_array(v.mem_ctx, ir_instruction *,
|
||||
mesa_instruction_annotation = ralloc_array(v.mem_ctx, ir_instruction *,
|
||||
num_instructions);
|
||||
|
||||
v.copy_propagate();
|
||||
|
|
@ -3127,7 +3127,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
|
|||
_mesa_glsl_lexer_dtor(state);
|
||||
}
|
||||
|
||||
talloc_free(shader->ir);
|
||||
ralloc_free(shader->ir);
|
||||
shader->ir = new(shader) exec_list;
|
||||
if (!state->error && !state->translation_unit.is_empty())
|
||||
_mesa_ast_to_hir(shader->ir, state);
|
||||
|
|
@ -3174,7 +3174,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
|
|||
/* Retain any live IR, but trash the rest. */
|
||||
reparent_ir(shader->ir, shader->ir);
|
||||
|
||||
talloc_free(state);
|
||||
ralloc_free(state);
|
||||
|
||||
if (shader->CompileStatus) {
|
||||
if (!ctx->Driver.CompileShader(ctx, shader))
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
* Graph-coloring register allocator.
|
||||
*/
|
||||
|
||||
#include <talloc.h>
|
||||
#include <ralloc.h>
|
||||
|
||||
#include "main/imports.h"
|
||||
#include "main/macros.h"
|
||||
|
|
@ -96,15 +96,15 @@ ra_alloc_reg_set(unsigned int count)
|
|||
unsigned int i;
|
||||
struct ra_regs *regs;
|
||||
|
||||
regs = talloc_zero(NULL, struct ra_regs);
|
||||
regs = rzalloc(NULL, struct ra_regs);
|
||||
regs->count = count;
|
||||
regs->regs = talloc_zero_array(regs, struct ra_reg, count);
|
||||
regs->regs = rzalloc_array(regs, struct ra_reg, count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
regs->regs[i].conflicts = talloc_zero_array(regs->regs, GLboolean, count);
|
||||
regs->regs[i].conflicts = rzalloc_array(regs->regs, GLboolean, count);
|
||||
regs->regs[i].conflicts[i] = GL_TRUE;
|
||||
|
||||
regs->regs[i].conflict_list = talloc_array(regs->regs, unsigned int, 4);
|
||||
regs->regs[i].conflict_list = ralloc_array(regs->regs, unsigned int, 4);
|
||||
regs->regs[i].conflict_list_size = 4;
|
||||
regs->regs[i].conflict_list[0] = i;
|
||||
regs->regs[i].num_conflicts = 1;
|
||||
|
|
@ -120,10 +120,8 @@ ra_add_conflict_list(struct ra_regs *regs, unsigned int r1, unsigned int r2)
|
|||
|
||||
if (reg1->conflict_list_size == reg1->num_conflicts) {
|
||||
reg1->conflict_list_size *= 2;
|
||||
reg1->conflict_list = talloc_realloc(regs->regs,
|
||||
reg1->conflict_list,
|
||||
unsigned int,
|
||||
reg1->conflict_list_size);
|
||||
reg1->conflict_list = reralloc(regs->regs, reg1->conflict_list,
|
||||
unsigned int, reg1->conflict_list_size);
|
||||
}
|
||||
reg1->conflict_list[reg1->num_conflicts++] = r2;
|
||||
reg1->conflicts[r2] = GL_TRUE;
|
||||
|
|
@ -143,14 +141,13 @@ ra_alloc_reg_class(struct ra_regs *regs)
|
|||
{
|
||||
struct ra_class *class;
|
||||
|
||||
regs->classes = talloc_realloc(regs->regs, regs->classes,
|
||||
struct ra_class *,
|
||||
regs->class_count + 1);
|
||||
regs->classes = reralloc(regs->regs, regs->classes, struct ra_class *,
|
||||
regs->class_count + 1);
|
||||
|
||||
class = talloc_zero(regs, struct ra_class);
|
||||
class = rzalloc(regs, struct ra_class);
|
||||
regs->classes[regs->class_count] = class;
|
||||
|
||||
class->regs = talloc_zero_array(class, GLboolean, regs->count);
|
||||
class->regs = rzalloc_array(class, GLboolean, regs->count);
|
||||
|
||||
return regs->class_count++;
|
||||
}
|
||||
|
|
@ -174,7 +171,7 @@ ra_set_finalize(struct ra_regs *regs)
|
|||
unsigned int b, c;
|
||||
|
||||
for (b = 0; b < regs->class_count; b++) {
|
||||
regs->classes[b]->q = talloc_array(regs, unsigned int, regs->class_count);
|
||||
regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count);
|
||||
}
|
||||
|
||||
/* Compute, for each class B and C, how many regs of B an
|
||||
|
|
@ -218,16 +215,16 @@ ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count)
|
|||
struct ra_graph *g;
|
||||
unsigned int i;
|
||||
|
||||
g = talloc_zero(regs, struct ra_graph);
|
||||
g = rzalloc(regs, struct ra_graph);
|
||||
g->regs = regs;
|
||||
g->nodes = talloc_zero_array(g, struct ra_node, count);
|
||||
g->nodes = rzalloc_array(g, struct ra_node, count);
|
||||
g->count = count;
|
||||
|
||||
g->stack = talloc_zero_array(g, unsigned int, count);
|
||||
g->stack = rzalloc_array(g, unsigned int, count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
g->nodes[i].adjacency = talloc_zero_array(g, GLboolean, count);
|
||||
g->nodes[i].adjacency_list = talloc_array(g, unsigned int, count);
|
||||
g->nodes[i].adjacency = rzalloc_array(g, GLboolean, count);
|
||||
g->nodes[i].adjacency_list = ralloc_array(g, unsigned int, count);
|
||||
g->nodes[i].adjacency_count = 0;
|
||||
ra_add_node_adjacency(g, i, i);
|
||||
g->nodes[i].reg = ~0;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ static void fail_link(struct gl_shader_program *prog, const char *fmt, ...)
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, args);
|
||||
ralloc_vasprintf_append(&prog->InfoLog, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
prog->LinkStatus = GL_FALSE;
|
||||
|
|
@ -52,7 +52,7 @@ public:
|
|||
get_sampler_name(ir_dereference *last,
|
||||
struct gl_shader_program *shader_program)
|
||||
{
|
||||
this->mem_ctx = talloc_new(NULL);
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->shader_program = shader_program;
|
||||
this->name = NULL;
|
||||
this->offset = 0;
|
||||
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
~get_sampler_name()
|
||||
{
|
||||
talloc_free(this->mem_ctx);
|
||||
ralloc_free(this->mem_ctx);
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit(ir_dereference_variable *ir)
|
||||
|
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
virtual ir_visitor_status visit_leave(ir_dereference_record *ir)
|
||||
{
|
||||
this->name = talloc_asprintf(mem_ctx, "%s.%s", name, ir->field);
|
||||
this->name = ralloc_asprintf(mem_ctx, "%s.%s", name, ir->field);
|
||||
return visit_continue;
|
||||
}
|
||||
|
||||
|
|
@ -91,16 +91,14 @@ public:
|
|||
* all that would work would be an unrolled loop counter that ends
|
||||
* up being constant above.
|
||||
*/
|
||||
shader_program->InfoLog =
|
||||
talloc_asprintf_append(shader_program->InfoLog,
|
||||
"warning: Variable sampler array index "
|
||||
"unsupported.\nThis feature of the language "
|
||||
"was removed in GLSL 1.20 and is unlikely "
|
||||
"to be supported for 1.10 in Mesa.\n");
|
||||
ralloc_strcat(&shader_program->InfoLog,
|
||||
"warning: Variable sampler array index unsupported.\n"
|
||||
"This feature of the language was removed in GLSL 1.20 "
|
||||
"and is unlikely to be supported for 1.10 in Mesa.\n");
|
||||
i = 0;
|
||||
}
|
||||
if (ir != last) {
|
||||
this->name = talloc_asprintf(mem_ctx, "%s[%d]", name, i);
|
||||
this->name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
|
||||
} else {
|
||||
offset = i;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue