glsl: remove explicit __STDC_FORMAT_MACROS define
[mesa.git] / src / compiler / glsl / ir_print_visitor.cpp
index fc01be935bf5ef2aa92b154f9edad39d70ac0e4e..1c84c1be16e1a350a86195ddc2f47d178dcb7759 100644 (file)
@@ -21,6 +21,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <inttypes.h> /* for PRIx64 macro */
 #include "ir_print_visitor.h"
 #include "compiler/glsl_types.h"
 #include "glsl_parser_extras.h"
@@ -130,14 +131,14 @@ ir_print_visitor::unique_name(ir_variable *var)
 
    /* 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) {
+   if (_mesa_symbol_table_find_symbol(this->symbols, var->name) == NULL) {
       name = var->name;
    } else {
       static unsigned i = 1;
       name = ralloc_asprintf(this->mem_ctx, "%s@%u", var->name, ++i);
    }
    _mesa_hash_table_insert(this->printable_names, var, (void *) name);
-   _mesa_symbol_table_add_symbol(this->symbols, -1, name, var);
+   _mesa_symbol_table_add_symbol(this->symbols, name, var);
    return name;
 }
 
@@ -165,10 +166,29 @@ void ir_print_visitor::visit(ir_variable *ir)
 {
    fprintf(f, "(declare ");
 
-   char loc[256] = {0};
+   char binding[32] = {0};
+   if (ir->data.binding)
+      snprintf(binding, sizeof(binding), "binding=%i ", ir->data.binding);
+
+   char loc[32] = {0};
    if (ir->data.location != -1)
       snprintf(loc, sizeof(loc), "location=%i ", ir->data.location);
 
+   char component[32] = {0};
+   if (ir->data.explicit_component)
+      snprintf(component, sizeof(component), "component=%i ", ir->data.location_frac);
+
+   char stream[32] = {0};
+   if (ir->data.stream & (1u << 31)) {
+      if (ir->data.stream & ~(1u << 31)) {
+         snprintf(stream, sizeof(stream), "stream(%u,%u,%u,%u) ",
+                  ir->data.stream & 3, (ir->data.stream >> 2) & 3,
+                  (ir->data.stream >> 4) & 3, (ir->data.stream >> 6) & 3);
+      }
+   } else if (ir->data.stream) {
+      snprintf(stream, sizeof(stream), "stream%u ", ir->data.stream);
+   }
+
    const char *const cent = (ir->data.centroid) ? "centroid " : "";
    const char *const samp = (ir->data.sample) ? "sample " : "";
    const char *const patc = (ir->data.patch) ? "patch " : "";
@@ -179,13 +199,12 @@ void ir_print_visitor::visit(ir_variable *ir)
                                 "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_MODE_COUNT);
 
-   fprintf(f, "(%s%s%s%s%s%s%s%s%s) ",
-           loc, cent, samp, patc, inv, prec, mode[ir->data.mode],
-           stream[ir->data.stream],
+   fprintf(f, "(%s%s%s%s%s%s%s%s%s%s%s) ",
+           binding, loc, component, cent, samp, patc, inv, prec, mode[ir->data.mode],
+           stream,
            interp[ir->data.interpolation]);
 
    print_type(f, ir->type);
@@ -306,9 +325,9 @@ void ir_print_visitor::visit(ir_texture *ir)
       else
         fprintf(f, "1");
 
-      if (ir->shadow_comparitor) {
+      if (ir->shadow_comparator) {
         fprintf(f, " ");
-        ir->shadow_comparitor->accept(this);
+        ir->shadow_comparator->accept(this);
       } else {
         fprintf(f, " ()");
       }
@@ -458,6 +477,8 @@ void ir_print_visitor::visit(ir_constant *ir)
             else
                fprintf(f, "%f", ir->value.f[i]);
             break;
+        case GLSL_TYPE_UINT64:fprintf(f, "%" PRIu64, ir->value.u64[i]); break;
+        case GLSL_TYPE_INT64: fprintf(f, "%" PRIi64, ir->value.i64[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)
@@ -470,7 +491,8 @@ void ir_print_visitor::visit(ir_constant *ir)
             else
                fprintf(f, "%f", ir->value.d[i]);
             break;
-        default: assert(0);
+        default:
+            unreachable("Invalid constant type");
         }
       }
    }