glsl: Lower UBO and SSBO access in glsl linker
authorKristian Høgsberg Kristensen <krh@bitplanet.net>
Wed, 4 Nov 2015 22:55:32 +0000 (14:55 -0800)
committerKristian Høgsberg Kristensen <krh@bitplanet.net>
Tue, 10 Nov 2015 20:02:46 +0000 (12:02 -0800)
All GLSL IR consumers run this lowering pass so we can move it to the
linker. This moves the pass up quite a bit, but that's the point: it
needs to run before we throw away information about per-component vector
access.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Signed-off-by: Kristian Høgsberg Kristensen <krh@bitplanet.net>
src/glsl/linker.cpp
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 26c02986be4a7dacbf2f64b3069dddcad9c17687..a8baee07f10c0d780e4d1efc6c402185336f302b 100644 (file)
@@ -4445,6 +4445,14 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
 
    /* FINISHME: Assign fragment shader output locations. */
 
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+      if (prog->_LinkedShaders[i] == NULL)
+        continue;
+
+      if (ctx->Const.ShaderCompilerOptions[i].LowerBufferInterfaceBlocks)
+         lower_ubo_reference(prog->_LinkedShaders[i]);
+   }
+
 done:
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
       free(shader_list[i]);
index f1e386059356c28ec3cc21d9eba270e38138997a..2991173276140de318e3cf556d4ea5aea5ab6c52 100644 (file)
@@ -157,8 +157,6 @@ process_glsl_ir(gl_shader_stage stage,
                  _mesa_shader_stage_to_abbrev(shader->Stage));
    }
 
-   lower_ubo_reference(shader);
-
    bool progress;
    do {
       progress = false;
index 0312024ed1b8a694163da774dc72971b509740bf..a6b57c3c3f1532801459901388707ede4c9339a3 100644 (file)
@@ -148,6 +148,8 @@ brw_compiler_create(void *mem_ctx, const struct brw_device_info *devinfo)
          compiler->glsl_compiler_options[i].EmitNoIndirectSampler = true;
 
       compiler->glsl_compiler_options[i].NirOptions = nir_options;
+
+      compiler->glsl_compiler_options[i].LowerBufferInterfaceBlocks = true;
    }
 
    return compiler;
index 05c546e00a078c6438aaab0a244bff76a07d0848..777a1eecd12b6c07fe613ba4f3cf6c56c3235c52 100644 (file)
@@ -2875,6 +2875,8 @@ struct gl_shader_compiler_options
     */
    GLboolean OptimizeForAOS;
 
+   GLboolean LowerBufferInterfaceBlocks; /**< Lower UBO and SSBO access to intrinsics. */
+
    const struct nir_shader_compiler_options *NirOptions;
 };
 
index bd7cbccc20cf12f1e668ba214e3f68072e9e8db9..bbb9027f4d7139f4d9d23cfe6b640a4bc1dad398 100644 (file)
@@ -254,6 +254,7 @@ void st_init_limits(struct pipe_screen *screen,
                                       PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT);
 
       options->LowerClipDistance = true;
+      options->LowerBufferInterfaceBlocks = true;
    }
 
    c->LowerTessLevel = true;
index ca00930e26119fc3fcb662a563a19a5080fb9b74..9ee6f8f89be6944e1aa8018a355111a26d5abb6c 100644 (file)
@@ -5822,7 +5822,6 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                          (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) |
                          (options->EmitNoSat ? SAT_TO_CLAMP : 0));
 
-      lower_ubo_reference(prog->_LinkedShaders[i]);
       do_vec_index_to_cond_assign(ir);
       lower_vector_insert(ir, true);
       lower_quadop_vector(ir, false);