Track and print user defined structure types
This commit is contained in:
@@ -2375,6 +2375,16 @@ ast_struct_specifier::hir(exec_list *instructions,
|
|||||||
} else {
|
} else {
|
||||||
t->generate_constructor(state->symbols);
|
t->generate_constructor(state->symbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const glsl_type **s = (const glsl_type **)
|
||||||
|
realloc(state->user_structures,
|
||||||
|
sizeof(state->user_structures[0]) *
|
||||||
|
(state->num_user_structures + 1));
|
||||||
|
if (s != NULL) {
|
||||||
|
s[state->num_user_structures] = t;
|
||||||
|
state->user_structures = s;
|
||||||
|
state->num_user_structures++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Structure type definitions do not have r-values.
|
/* Structure type definitions do not have r-values.
|
||||||
|
@@ -61,6 +61,10 @@ struct _mesa_glsl_parse_state {
|
|||||||
/** Loop or switch statement containing the current instructions. */
|
/** Loop or switch statement containing the current instructions. */
|
||||||
class ir_instruction *loop_or_switch_nesting;
|
class ir_instruction *loop_or_switch_nesting;
|
||||||
|
|
||||||
|
/** List of structures defined in user code. */
|
||||||
|
const glsl_type **user_structures;
|
||||||
|
unsigned num_user_structures;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name Enable bits for GLSL extensions
|
* \name Enable bits for GLSL extensions
|
||||||
*/
|
*/
|
||||||
|
@@ -23,12 +23,29 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "ir_print_visitor.h"
|
#include "ir_print_visitor.h"
|
||||||
#include "glsl_types.h"
|
#include "glsl_types.h"
|
||||||
|
#include "glsl_parser_extras.h"
|
||||||
|
|
||||||
|
static void print_type(const glsl_type *t);
|
||||||
|
|
||||||
void
|
void
|
||||||
_mesa_print_ir(exec_list *instructions,
|
_mesa_print_ir(exec_list *instructions,
|
||||||
struct _mesa_glsl_parse_state *state)
|
struct _mesa_glsl_parse_state *state)
|
||||||
{
|
{
|
||||||
(void) state;
|
for (unsigned i = 0; i < state->num_user_structures; i++) {
|
||||||
|
const glsl_type *const s = state->user_structures[i];
|
||||||
|
|
||||||
|
printf("(structure (%s) (%s@%08x) (%u) (\n",
|
||||||
|
s->name, s->name, (unsigned) s, s->length
|
||||||
|
);
|
||||||
|
|
||||||
|
for (unsigned j = 0; j < s->length; j++) {
|
||||||
|
printf("\t((");
|
||||||
|
print_type(s->fields.structure[j].type);
|
||||||
|
printf(")(%s))\n", s->fields.structure[j].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(")\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("(\n");
|
printf("(\n");
|
||||||
foreach_iter(exec_list_iterator, iter, *instructions) {
|
foreach_iter(exec_list_iterator, iter, *instructions) {
|
||||||
@@ -47,6 +64,9 @@ print_type(const glsl_type *t)
|
|||||||
printf("(array ");
|
printf("(array ");
|
||||||
print_type(t->fields.array);
|
print_type(t->fields.array);
|
||||||
printf(" %u)", t->length);
|
printf(" %u)", t->length);
|
||||||
|
} else if ((t->base_type == GLSL_TYPE_STRUCT)
|
||||||
|
&& (strncmp("gl_", t->name, 3) != 0)) {
|
||||||
|
printf("%s@%08x", t->name, (unsigned) t);
|
||||||
} else {
|
} else {
|
||||||
printf("%s", t->name);
|
printf("%s", t->name);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user