i965/miptree: Replace is_lossless_compressed with mt->aux_usage checks
[mesa.git] / src / mesa / drivers / dri / i965 / brw_tes.c
index 2dae1e57f416f16877e2fe05b70041017db44529..20ce1f4c15bc13f4803f0abee841ec0315804927 100644 (file)
@@ -28,9 +28,8 @@
  */
 
 #include "brw_context.h"
-#include "brw_nir.h"
+#include "compiler/brw_nir.h"
 #include "brw_program.h"
-#include "brw_shader.h"
 #include "brw_state.h"
 #include "program/prog_parameter.h"
 
@@ -38,27 +37,15 @@ static void
 brw_tes_debug_recompile(struct brw_context *brw, struct gl_program *prog,
                        const struct brw_tes_prog_key *key)
 {
-   struct brw_cache_item *c = NULL;
-   const struct brw_tes_prog_key *old_key = NULL;
-   bool found = false;
-
    perf_debug("Recompiling tessellation evaluation shader for program %d\n",
               prog->Id);
 
-   for (unsigned int i = 0; i < brw->cache.size; i++) {
-      for (c = brw->cache.items[i]; c; c = c->next) {
-         if (c->cache_id == BRW_CACHE_TES_PROG) {
-            old_key = c->key;
-
-            if (old_key->program_string_id == key->program_string_id)
-               break;
-         }
-      }
-      if (c)
-         break;
-   }
+   bool found = false;
+   const struct brw_tes_prog_key *old_key =
+      brw_find_previous_compile(&brw->cache, BRW_CACHE_TES_PROG,
+                                key->program_string_id);
 
-   if (!c) {
+   if (!old_key) {
       perf_debug("  Didn't find previous compile in the shader cache for "
                  "debug\n");
       return;
@@ -93,45 +80,6 @@ brw_codegen_tes_prog(struct brw_context *brw,
    brw_assign_common_binding_table_offsets(devinfo, &tep->program,
                                            &prog_data.base.base, 0);
 
-   switch (tep->program.info.tes.spacing) {
-   case GL_EQUAL:
-      prog_data.partitioning = BRW_TESS_PARTITIONING_INTEGER;
-      break;
-   case GL_FRACTIONAL_ODD:
-      prog_data.partitioning = BRW_TESS_PARTITIONING_ODD_FRACTIONAL;
-      break;
-   case GL_FRACTIONAL_EVEN:
-      prog_data.partitioning = BRW_TESS_PARTITIONING_EVEN_FRACTIONAL;
-      break;
-   default:
-      unreachable("invalid domain shader spacing");
-   }
-
-   switch (tep->program.info.tes.primitive_mode) {
-   case GL_QUADS:
-      prog_data.domain = BRW_TESS_DOMAIN_QUAD;
-      break;
-   case GL_TRIANGLES:
-      prog_data.domain = BRW_TESS_DOMAIN_TRI;
-      break;
-   case GL_ISOLINES:
-      prog_data.domain = BRW_TESS_DOMAIN_ISOLINE;
-      break;
-   default:
-      unreachable("invalid domain shader primitive mode");
-   }
-
-   if (tep->program.info.tes.point_mode) {
-      prog_data.output_topology = BRW_TESS_OUTPUT_TOPOLOGY_POINT;
-   } else if (tep->program.info.tes.primitive_mode == GL_ISOLINES) {
-      prog_data.output_topology = BRW_TESS_OUTPUT_TOPOLOGY_LINE;
-   } else {
-      /* Hardware winding order is backwards from OpenGL */
-      prog_data.output_topology =
-         tep->program.info.tes.ccw ? BRW_TESS_OUTPUT_TOPOLOGY_TRI_CW
-                                   : BRW_TESS_OUTPUT_TOPOLOGY_TRI_CCW;
-   }
-
    /* Allocate the references to the uniforms that will end up in the
     * prog_data associated with the compiled program, and which will be freed
     * by the state cache.
@@ -154,24 +102,30 @@ brw_codegen_tes_prog(struct brw_context *brw,
 
    brw_nir_setup_glsl_uniforms(nir, &tep->program, &prog_data.base.base,
                                compiler->scalar_stage[MESA_SHADER_TESS_EVAL]);
+   brw_nir_analyze_ubo_ranges(compiler, tep->program.nir,
+                              prog_data.base.base.ubo_ranges);
 
    int st_index = -1;
    if (unlikely(INTEL_DEBUG & DEBUG_SHADER_TIME))
       st_index = brw_get_shader_time_index(brw, &tep->program, ST_TES, true);
 
    if (unlikely(brw->perf_debug)) {
-      start_busy = brw->batch.last_bo && drm_intel_bo_busy(brw->batch.last_bo);
+      start_busy = brw->batch.last_bo && brw_bo_busy(brw->batch.last_bo);
       start_time = get_time();
    }
 
+   struct brw_vue_map input_vue_map;
+   brw_compute_tess_vue_map(&input_vue_map, key->inputs_read,
+                            key->patch_inputs_read);
+
    void *mem_ctx = ralloc_context(NULL);
    unsigned program_size;
    char *error_str;
    const unsigned *program =
-      brw_compile_tes(compiler, brw, mem_ctx, key, &prog_data, nir,
-                      &tep->program, st_index, &program_size, &error_str);
+      brw_compile_tes(compiler, brw, mem_ctx, key, &input_vue_map, &prog_data,
+                      nir, &tep->program, st_index, &program_size, &error_str);
    if (program == NULL) {
-      tep->program.sh.data->LinkStatus = false;
+      tep->program.sh.data->LinkStatus = linking_failure;
       ralloc_strcat(&tep->program.sh.data->InfoLog, error_str);
 
       _mesa_problem(NULL, "Failed to compile tessellation evaluation shader: "
@@ -185,7 +139,7 @@ brw_codegen_tes_prog(struct brw_context *brw,
       if (tep->compiled_once) {
          brw_tes_debug_recompile(brw, &tep->program, key);
       }
-      if (start_busy && !drm_intel_bo_busy(brw->batch.last_bo)) {
+      if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
          perf_debug("TES compile took %.03f ms and stalled the GPU\n",
                     (get_time() - start_time) * 1000);
       }
@@ -282,15 +236,15 @@ brw_tes_precompile(struct gl_context *ctx,
    memset(&key, 0, sizeof(key));
 
    key.program_string_id = btep->id;
-   key.inputs_read = prog->nir->info->inputs_read;
-   key.patch_inputs_read = prog->nir->info->patch_inputs_read;
+   key.inputs_read = prog->nir->info.inputs_read;
+   key.patch_inputs_read = prog->nir->info.patch_inputs_read;
 
    if (shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) {
       struct gl_program *tcp =
          shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program;
-      key.inputs_read |= tcp->nir->info->outputs_written &
+      key.inputs_read |= tcp->nir->info.outputs_written &
          ~(VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER);
-      key.patch_inputs_read |= tcp->nir->info->patch_outputs_written;
+      key.patch_inputs_read |= tcp->nir->info.patch_outputs_written;
    }
 
    brw_setup_tex_for_precompile(brw, &key.tex, prog);