i965: Store uniform constant values in a gl_constant_value instead of float
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vec4.cpp
index 045e1c5d413e1b529bf68f2911359fe89f375892..5f8f39971b9c00fa3db93c7cde4b7b7a153f679d 100644 (file)
@@ -667,7 +667,7 @@ vec4_visitor::move_push_constants_to_pull_constants()
       pull_constant_loc[i / 4] = -1;
 
       if (i >= max_uniform_components) {
-        const float **values = &stage_prog_data->param[i];
+        const gl_constant_value **values = &stage_prog_data->param[i];
 
         /* Try to find an existing copy of this uniform in the pull
          * constants if it was part of an array access already.
@@ -1490,10 +1490,10 @@ vec4_visitor::setup_uniforms(int reg)
       this->uniform_vector_size[this->uniforms] = 1;
 
       stage_prog_data->param =
-         reralloc(NULL, stage_prog_data->param, const float *, 4);
+         reralloc(NULL, stage_prog_data->param, const gl_constant_value *, 4);
       for (unsigned int i = 0; i < 4; i++) {
         unsigned int slot = this->uniforms * 4 + i;
-        static float zero = 0.0;
+        static gl_constant_value zero = { .f = 0.0 };
         stage_prog_data->param[slot] = &zero;
       }
 
@@ -1668,15 +1668,45 @@ vec4_visitor::run()
    move_push_constants_to_pull_constants();
    split_virtual_grfs();
 
+   const char *stage_name = stage == MESA_SHADER_GEOMETRY ? "gs" : "vs";
+
+#define OPT(pass, args...) do {                                        \
+      pass_num++;                                                      \
+      bool this_progress = pass(args);                                 \
+                                                                       \
+      if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER) && this_progress) {  \
+         char filename[64];                                            \
+         snprintf(filename, 64, "%s-%04d-%02d-%02d-" #pass,            \
+                  stage_name, shader_prog->Name, iteration, pass_num); \
+                                                                       \
+         backend_visitor::dump_instructions(filename);                 \
+      }                                                                \
+                                                                       \
+      progress = progress || this_progress;                            \
+   } while (false)
+
+
+   if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER)) {
+      char filename[64];
+      snprintf(filename, 64, "%s-%04d-00-start",
+               stage_name, shader_prog->Name);
+
+      backend_visitor::dump_instructions(filename);
+   }
+
    bool progress;
+   int iteration = 0;
    do {
       progress = false;
-      progress = dead_code_eliminate() || progress;
-      progress = dead_control_flow_eliminate(this) || progress;
-      progress = opt_copy_propagation() || progress;
-      progress = opt_algebraic() || progress;
-      progress = opt_cse() || progress;
-      progress = opt_register_coalesce() || progress;
+      iteration++;
+      int pass_num = 0;
+
+      OPT(dead_code_eliminate);
+      OPT(dead_control_flow_eliminate, this);
+      OPT(opt_copy_propagation);
+      OPT(opt_algebraic);
+      OPT(opt_cse);
+      OPT(opt_register_coalesce);
    } while (progress);
 
 
@@ -1764,15 +1794,9 @@ brw_vs_emit(struct brw_context *brw,
    }
 
    const unsigned *assembly = NULL;
-   if (brw->gen >= 8) {
-      gen8_vec4_generator g(brw, prog, &c->vp->program.Base, &prog_data->base,
-                            mem_ctx, INTEL_DEBUG & DEBUG_VS);
-      assembly = g.generate_assembly(&v.instructions, final_assembly_size);
-   } else {
-      vec4_generator g(brw, prog, &c->vp->program.Base, &prog_data->base,
-                       mem_ctx, INTEL_DEBUG & DEBUG_VS);
-      assembly = g.generate_assembly(&v.instructions, final_assembly_size);
-   }
+   vec4_generator g(brw, prog, &c->vp->program.Base, &prog_data->base,
+                    mem_ctx, INTEL_DEBUG & DEBUG_VS);
+   assembly = g.generate_assembly(&v.instructions, final_assembly_size);
 
    if (unlikely(brw->perf_debug) && shader) {
       if (shader->compiled_once) {