#include "glsl_types.h"
#include "glsl_parser_extras.h"
#include "main/macros.h"
-#include "program/hash_table.h"
+#include "util/hash_table.h"
static void print_type(FILE *f, const glsl_type *t);
}
fprintf(f, "(\n");
- foreach_list(n, instructions) {
- ir_instruction *ir = (ir_instruction *) n;
+ foreach_in_list(ir_instruction, ir, instructions) {
ir->fprint(f);
if (ir->ir_type != ir_type_function)
fprintf(f, "\n");
}
- fprintf(f, "\n)");
+ fprintf(f, ")\n");
}
void
{
indentation = 0;
printable_names =
- hash_table_ctor(32, hash_table_pointer_hash, hash_table_pointer_compare);
+ _mesa_hash_table_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
symbols = _mesa_symbol_table_ctor();
mem_ctx = ralloc_context(NULL);
}
ir_print_visitor::~ir_print_visitor()
{
- hash_table_dtor(printable_names);
+ _mesa_hash_table_destroy(printable_names, NULL);
_mesa_symbol_table_dtor(symbols);
ralloc_free(mem_ctx);
}
}
/* Do we already have a name for this variable? */
- const char *name = (const char *) hash_table_find(this->printable_names, var);
- if (name != NULL)
- return name;
+ struct hash_entry * entry =
+ _mesa_hash_table_search(this->printable_names, var);
+
+ if (entry != NULL) {
+ return (const char *) entry->data;
+ }
/* If there's no conflict, just use the original name */
+ const char* name = NULL;
if (_mesa_symbol_table_find_symbol(this->symbols, -1, var->name) == NULL) {
name = var->name;
} else {
static unsigned i = 1;
name = ralloc_asprintf(this->mem_ctx, "%s@%u", var->name, ++i);
}
- hash_table_insert(this->printable_names, (void *) name, var);
+ _mesa_hash_table_insert(this->printable_names, var, (void *) name);
_mesa_symbol_table_add_symbol(this->symbols, -1, name, var);
return name;
}
{
fprintf(f, "(declare ");
+ char loc[256] = {0};
+ if (ir->data.location != -1)
+ snprintf(loc, sizeof(loc), "location=%i ", ir->data.location);
+
const char *const cent = (ir->data.centroid) ? "centroid " : "";
const char *const samp = (ir->data.sample) ? "sample " : "";
+ const char *const patc = (ir->data.patch) ? "patch " : "";
const char *const inv = (ir->data.invariant) ? "invariant " : "";
- const char *const mode[] = { "", "uniform ", "shader_in ", "shader_out ",
+ const char *const mode[] = { "", "uniform ", "shader_storage ",
+ "shader_shared ", "shader_in ", "shader_out ",
"in ", "out ", "inout ",
"const_in ", "sys ", "temporary " };
STATIC_ASSERT(ARRAY_SIZE(mode) == ir_var_mode_count);
+ const char *const stream [] = {"", "stream1 ", "stream2 ", "stream3 "};
const char *const interp[] = { "", "smooth", "flat", "noperspective" };
STATIC_ASSERT(ARRAY_SIZE(interp) == INTERP_QUALIFIER_COUNT);
- fprintf(f, "(%s%s%s%s%s) ",
- cent, samp, inv, mode[ir->data.mode], interp[ir->data.interpolation]);
+ fprintf(f, "(%s%s%s%s%s%s%s%s) ",
+ loc, cent, samp, patc, inv, mode[ir->data.mode],
+ stream[ir->data.stream],
+ interp[ir->data.interpolation]);
print_type(f, ir->type);
fprintf(f, " %s)", unique_name(ir));
fprintf(f, "(parameters\n");
indentation++;
- foreach_list(n, &ir->parameters) {
- ir_variable *const inst = (ir_variable *) n;
-
+ foreach_in_list(ir_variable, inst, &ir->parameters) {
indent();
inst->accept(this);
fprintf(f, "\n");
fprintf(f, "(\n");
indentation++;
- foreach_list(n, &ir->body) {
- ir_instruction *const inst = (ir_instruction *) n;
-
+ foreach_in_list(ir_instruction, inst, &ir->body) {
indent();
inst->accept(this);
fprintf(f, "\n");
void ir_print_visitor::visit(ir_function *ir)
{
- fprintf(f, "(function %s\n", ir->name);
+ fprintf(f, "(%s function %s\n", ir->is_subroutine ? "subroutine" : "", ir->name);
indentation++;
- foreach_list(n, &ir->signatures) {
- ir_function_signature *const sig = (ir_function_signature *) n;
+ foreach_in_list(ir_function_signature, sig, &ir->signatures) {
indent();
sig->accept(this);
fprintf(f, "\n");
{
fprintf(f, "(%s ", ir->opcode_string());
+ if (ir->op == ir_samples_identical) {
+ ir->sampler->accept(this);
+ fprintf(f, " ");
+ ir->coordinate->accept(this);
+ fprintf(f, ")");
+ return;
+ }
+
print_type(f, ir->type);
fprintf(f, " ");
ir->sampler->accept(this);
fprintf(f, " ");
- if (ir->op != ir_txs && ir->op != ir_query_levels) {
+ if (ir->op != ir_txs && ir->op != ir_query_levels &&
+ ir->op != ir_texture_samples) {
ir->coordinate->accept(this);
fprintf(f, " ");
if (ir->op != ir_txf && ir->op != ir_txf_ms &&
ir->op != ir_txs && ir->op != ir_tg4 &&
- ir->op != ir_query_levels) {
+ ir->op != ir_query_levels && ir->op != ir_texture_samples) {
if (ir->projector)
ir->projector->accept(this);
else
case ir_tex:
case ir_lod:
case ir_query_levels:
+ case ir_texture_samples:
break;
case ir_txb:
ir->lod_info.bias->accept(this);
case ir_tg4:
ir->lod_info.component->accept(this);
break;
+ case ir_samples_identical:
+ unreachable(!"ir_samples_identical was already handled");
};
fprintf(f, ")");
}
fprintf(f, "%f", ir->value.f[i]);
break;
case GLSL_TYPE_BOOL: fprintf(f, "%d", ir->value.b[i]); break;
+ case GLSL_TYPE_DOUBLE:
+ if (ir->value.d[i] == 0.0)
+ /* 0.0 == -0.0, so print with %f to get the proper sign. */
+ fprintf(f, "%.1f", ir->value.d[i]);
+ else if (fabs(ir->value.d[i]) < 0.000001)
+ fprintf(f, "%a", ir->value.d[i]);
+ else if (fabs(ir->value.d[i]) > 1000000.0)
+ fprintf(f, "%e", ir->value.d[i]);
+ else
+ fprintf(f, "%f", ir->value.d[i]);
+ break;
default: assert(0);
}
}
if (ir->return_deref)
ir->return_deref->accept(this);
fprintf(f, " (");
- foreach_list(n, &ir->actual_parameters) {
- ir_rvalue *const param = (ir_rvalue *) n;
-
+ foreach_in_list(ir_rvalue, param, &ir->actual_parameters) {
param->accept(this);
}
fprintf(f, "))\n");
fprintf(f, "(\n");
indentation++;
- foreach_list(n, &ir->then_instructions) {
- ir_instruction *const inst = (ir_instruction *) n;
-
+ foreach_in_list(ir_instruction, inst, &ir->then_instructions) {
indent();
inst->accept(this);
fprintf(f, "\n");
fprintf(f, "(\n");
indentation++;
- foreach_list(n, &ir->else_instructions) {
- ir_instruction *const inst = (ir_instruction *) n;
-
+ foreach_in_list(ir_instruction, inst, &ir->else_instructions) {
indent();
inst->accept(this);
fprintf(f, "\n");
fprintf(f, "(loop (\n");
indentation++;
- foreach_list(n, &ir->body_instructions) {
- ir_instruction *const inst = (ir_instruction *) n;
-
+ foreach_in_list(ir_instruction, inst, &ir->body_instructions) {
indent();
inst->accept(this);
fprintf(f, "\n");
}
void
-ir_print_visitor::visit(ir_emit_vertex *)
+ir_print_visitor::visit(ir_emit_vertex *ir)
{
- fprintf(f, "(emit-vertex)");
+ fprintf(f, "(emit-vertex ");
+ ir->stream->accept(this);
+ fprintf(f, ")\n");
+}
+
+void
+ir_print_visitor::visit(ir_end_primitive *ir)
+{
+ fprintf(f, "(end-primitive ");
+ ir->stream->accept(this);
+ fprintf(f, ")\n");
}
void
-ir_print_visitor::visit(ir_end_primitive *)
+ir_print_visitor::visit(ir_barrier *)
{
- fprintf(f, "(end-primitive)");
+ fprintf(f, "(barrier)\n");
}