glsl: drop cache_fallback
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 7 Nov 2017 22:54:22 +0000 (09:54 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 9 Nov 2017 01:07:48 +0000 (12:07 +1100)
This turned out to be a dead end, it is much easier and less error
prone to just cache the IR used by the drivers backend e.g. TGSI or
NIR.

Cc: "17.2 17.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/linker.cpp
src/compiler/glsl/shader_cache.cpp
src/mesa/main/mtypes.h
src/mesa/main/shaderobj.c

index 7d141549f55ad6f23fb8382b6104cf423909c930..3da015eb7fd245df7d482bb85f6a074ab4f487a8 100644 (file)
@@ -1400,13 +1400,6 @@ link_assign_uniform_storage(struct gl_context *ctx,
              sizeof(shader->Program->sh.SamplerTargets));
    }
 
-   /* If this is a fallback compile for a cache miss we already have the
-    * correct uniform mappings and we don't want to reinitialise uniforms so
-    * just return now.
-    */
-   if (prog->data->cache_fallback)
-      return;
-
 #ifndef NDEBUG
    for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
       assert(prog->data->UniformStorage[i].storage != NULL ||
@@ -1431,11 +1424,9 @@ void
 link_assign_uniform_locations(struct gl_shader_program *prog,
                               struct gl_context *ctx)
 {
-   if (!prog->data->cache_fallback) {
-      ralloc_free(prog->data->UniformStorage);
-      prog->data->UniformStorage = NULL;
-      prog->data->NumUniformStorage = 0;
-   }
+   ralloc_free(prog->data->UniformStorage);
+   prog->data->UniformStorage = NULL;
+   prog->data->NumUniformStorage = 0;
 
    if (prog->UniformHash != NULL) {
       prog->UniformHash->clear();
index 3b8734fc8b81694cf83c91c4d37ec20a75314a2e..cb2a6c7892a6401eadc6fb043e34327852afb352 100644 (file)
@@ -2264,8 +2264,7 @@ link_intrastage_shaders(void *mem_ctx,
       return NULL;
    }
 
-   if (!prog->data->cache_fallback)
-      _mesa_reference_shader_program_data(ctx, &gl_prog->sh.data, prog->data);
+   _mesa_reference_shader_program_data(ctx, &gl_prog->sh.data, prog->data);
 
    /* Don't use _mesa_reference_program() just take ownership */
    linked->Program = gl_prog;
@@ -2322,34 +2321,32 @@ link_intrastage_shaders(void *mem_ctx,
    v.run(linked->ir);
    v.fixup_unnamed_interface_types();
 
-   if (!prog->data->cache_fallback) {
-      /* Link up uniform blocks defined within this stage. */
-      link_uniform_blocks(mem_ctx, ctx, prog, linked, &ubo_blocks,
-                          &num_ubo_blocks, &ssbo_blocks, &num_ssbo_blocks);
+   /* Link up uniform blocks defined within this stage. */
+   link_uniform_blocks(mem_ctx, ctx, prog, linked, &ubo_blocks,
+                       &num_ubo_blocks, &ssbo_blocks, &num_ssbo_blocks);
 
-      if (!prog->data->LinkStatus) {
-         _mesa_delete_linked_shader(ctx, linked);
-         return NULL;
-      }
+   if (!prog->data->LinkStatus) {
+      _mesa_delete_linked_shader(ctx, linked);
+      return NULL;
+   }
 
-      /* Copy ubo blocks to linked shader list */
-      linked->Program->sh.UniformBlocks =
-         ralloc_array(linked, gl_uniform_block *, num_ubo_blocks);
-      ralloc_steal(linked, ubo_blocks);
-      for (unsigned i = 0; i < num_ubo_blocks; i++) {
-         linked->Program->sh.UniformBlocks[i] = &ubo_blocks[i];
-      }
-      linked->Program->info.num_ubos = num_ubo_blocks;
-
-      /* Copy ssbo blocks to linked shader list */
-      linked->Program->sh.ShaderStorageBlocks =
-         ralloc_array(linked, gl_uniform_block *, num_ssbo_blocks);
-      ralloc_steal(linked, ssbo_blocks);
-      for (unsigned i = 0; i < num_ssbo_blocks; i++) {
-         linked->Program->sh.ShaderStorageBlocks[i] = &ssbo_blocks[i];
-      }
-      linked->Program->info.num_ssbos = num_ssbo_blocks;
+   /* Copy ubo blocks to linked shader list */
+   linked->Program->sh.UniformBlocks =
+      ralloc_array(linked, gl_uniform_block *, num_ubo_blocks);
+   ralloc_steal(linked, ubo_blocks);
+   for (unsigned i = 0; i < num_ubo_blocks; i++) {
+      linked->Program->sh.UniformBlocks[i] = &ubo_blocks[i];
+   }
+   linked->Program->info.num_ubos = num_ubo_blocks;
+
+   /* Copy ssbo blocks to linked shader list */
+   linked->Program->sh.ShaderStorageBlocks =
+      ralloc_array(linked, gl_uniform_block *, num_ssbo_blocks);
+   ralloc_steal(linked, ssbo_blocks);
+   for (unsigned i = 0; i < num_ssbo_blocks; i++) {
+      linked->Program->sh.ShaderStorageBlocks[i] = &ssbo_blocks[i];
    }
+   linked->Program->info.num_ssbos = num_ssbo_blocks;
 
    /* At this point linked should contain all of the linked IR, so
     * validate it to make sure nothing went wrong.
@@ -4639,14 +4636,12 @@ link_and_validate_uniforms(struct gl_context *ctx,
    update_array_sizes(prog);
    link_assign_uniform_locations(prog, ctx);
 
-   if (!prog->data->cache_fallback) {
-      link_assign_atomic_counter_resources(ctx, prog);
-      link_calculate_subroutine_compat(prog);
-      check_resources(ctx, prog);
-      check_subroutine_resources(prog);
-      check_image_resources(ctx, prog);
-      link_check_atomic_counter_resources(ctx, prog);
-   }
+   link_assign_atomic_counter_resources(ctx, prog);
+   link_calculate_subroutine_compat(prog);
+   check_resources(ctx, prog);
+   check_subroutine_resources(prog);
+   check_image_resources(ctx, prog);
+   link_check_atomic_counter_resources(ctx, prog);
 }
 
 static bool
@@ -4960,10 +4955,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       last = i;
    }
 
-   if (!prog->data->cache_fallback) {
-      check_explicit_uniform_locations(ctx, prog);
-      link_assign_subroutine_types(prog);
-   }
+   check_explicit_uniform_locations(ctx, prog);
+   link_assign_subroutine_types(prog);
 
    if (!prog->data->LinkStatus)
       goto done;
@@ -5028,15 +5021,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    if (prog->SeparateShader)
       disable_varying_optimizations_for_sso(prog);
 
-   if (!prog->data->cache_fallback) {
-      /* Process UBOs */
-      if (!interstage_cross_validate_uniform_blocks(prog, false))
-         goto done;
+   /* Process UBOs */
+   if (!interstage_cross_validate_uniform_blocks(prog, false))
+      goto done;
 
-      /* Process SSBOs */
-      if (!interstage_cross_validate_uniform_blocks(prog, true))
-         goto done;
-   }
+   /* Process SSBOs */
+   if (!interstage_cross_validate_uniform_blocks(prog, true))
+      goto done;
 
    /* Do common optimization before assigning storage for attributes,
     * uniforms, and varyings.  Later optimization could possibly make
index 8fd2774bdfa14574d5b6e5c973e8da9ca058a0a3..89da19914fe8f8135a5aaf83af1a3806d721e06a 100644 (file)
@@ -1299,7 +1299,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
       return false;
 
    struct disk_cache *cache = ctx->Cache;
-   if (!cache || prog->data->cache_fallback || prog->data->skip_cache)
+   if (!cache || prog->data->skip_cache)
       return false;
 
    /* Include bindings when creating sha1. These bindings change the resulting
index 2acf64eb56df96691bbfecfcad3826eb42d33bec..a6931649aa0d74ce242de9ba169bf120b0985ff9 100644 (file)
@@ -2872,12 +2872,11 @@ struct gl_shader_program_data
    unsigned NumUniformDataSlots;
    union gl_constant_value *UniformDataSlots;
 
-   bool cache_fallback;
-
    /* TODO: This used by Gallium drivers to skip the cache on tgsi fallback.
     * All structures (gl_program, uniform storage, etc) will get recreated
-    * even though we have already loaded them from cache. Once the i965 cache
-    * lands we should switch to using the cache_fallback support.
+    * even though we have already loaded them from cache. We should instead
+    * switch to storing the GLSL metadata and TGSI IR in a single cache item
+    * like the i965 driver does with NIR.
     */
    bool skip_cache;
    GLboolean Validated;
index b9d1079a35abab68fbb776627dcbe057d46249c9..e2103bcde4974e953f7ea3da0b8700c1c44a1a83 100644 (file)
@@ -327,7 +327,7 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
 
    shProg->data->linked_stages = 0;
 
-   if (shProg->data->UniformStorage && !shProg->data->cache_fallback) {
+   if (shProg->data->UniformStorage) {
       for (unsigned i = 0; i < shProg->data->NumUniformStorage; ++i)
          _mesa_uniform_detach_all_driver_storage(&shProg->data->
                                                     UniformStorage[i]);
@@ -336,7 +336,7 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
       shProg->data->UniformStorage = NULL;
    }
 
-   if (shProg->UniformRemapTable && !shProg->data->cache_fallback) {
+   if (shProg->UniformRemapTable) {
       ralloc_free(shProg->UniformRemapTable);
       shProg->NumUniformRemapTable = 0;
       shProg->UniformRemapTable = NULL;
@@ -351,17 +351,15 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
    ralloc_free(shProg->data->InfoLog);
    shProg->data->InfoLog = ralloc_strdup(shProg->data, "");
 
-   if (!shProg->data->cache_fallback) {
-      ralloc_free(shProg->data->UniformBlocks);
-      shProg->data->UniformBlocks = NULL;
-      shProg->data->NumUniformBlocks = 0;
+   ralloc_free(shProg->data->UniformBlocks);
+   shProg->data->UniformBlocks = NULL;
+   shProg->data->NumUniformBlocks = 0;
 
-      ralloc_free(shProg->data->ShaderStorageBlocks);
-      shProg->data->ShaderStorageBlocks = NULL;
-      shProg->data->NumShaderStorageBlocks = 0;
-   }
+   ralloc_free(shProg->data->ShaderStorageBlocks);
+   shProg->data->ShaderStorageBlocks = NULL;
+   shProg->data->NumShaderStorageBlocks = 0;
 
-   if (shProg->data->AtomicBuffers && !shProg->data->cache_fallback) {
+   if (shProg->data->AtomicBuffers) {
       ralloc_free(shProg->data->AtomicBuffers);
       shProg->data->AtomicBuffers = NULL;
       shProg->data->NumAtomicBuffers = 0;
@@ -434,8 +432,7 @@ _mesa_delete_shader_program(struct gl_context *ctx,
                             struct gl_shader_program *shProg)
 {
    _mesa_free_shader_program_data(ctx, shProg);
-   if (!shProg->data->cache_fallback)
-      _mesa_reference_shader_program_data(ctx, &shProg->data, NULL);
+   _mesa_reference_shader_program_data(ctx, &shProg->data, NULL);
    ralloc_free(shProg);
 }