glsl: Specify framebuffer fetch coherency mode in lower_blend_equation_advanced().
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 14 Feb 2018 19:53:49 +0000 (11:53 -0800)
committerFrancisco Jerez <currojerez@riseup.net>
Sat, 24 Feb 2018 23:28:36 +0000 (15:28 -0800)
This requires passing an extra argument to the lowering pass because
the KHR_blend_equation_advanced specification doesn't seem to define
any mechanism for the implementation to determine at compile-time
whether coherent blending can ever be used (not even an "#extension
KHR_blend_equation_advanced_coherent" directive seems to be required
in the shader source AFAICT).

In the long run we'll probably want to do state-dependent recompiles
based on the value of ctx->Color.BlendCoherent, but right now there
would be no benefit from that because the only driver that supports
coherent framebuffer fetch is i965 on SKL+ hardware, which are unable
to support the non-coherent path for the moment because of texture
layout issues, so framebuffer fetch coherency is always enabled for
them.

Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
src/compiler/glsl/ir_optimization.h
src/compiler/glsl/lower_blend_equation_advanced.cpp
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 2b8c195151aeb9741e0c9c900a2f2b8f42e2550e..81049a479e86290432ac7ee112df245aeb8b4433 100644 (file)
@@ -166,7 +166,7 @@ bool lower_tess_level(gl_linked_shader *shader);
 
 bool lower_vertex_id(gl_linked_shader *shader);
 bool lower_cs_derived(gl_linked_shader *shader);
-bool lower_blend_equation_advanced(gl_linked_shader *shader);
+bool lower_blend_equation_advanced(gl_linked_shader *shader, bool coherent);
 
 bool lower_subroutine(exec_list *instructions, struct _mesa_glsl_parse_state *state);
 void propagate_invariance(exec_list *instructions);
index c6db58142cd76847752e485ca4aaca4d7b089443..b05a2e0f0bbd088ad3ea36dddc603d8522358fca 100644 (file)
@@ -462,7 +462,7 @@ get_main(gl_linked_shader *sh)
 }
 
 bool
-lower_blend_equation_advanced(struct gl_linked_shader *sh)
+lower_blend_equation_advanced(struct gl_linked_shader *sh, bool coherent)
 {
    if (sh->Program->sh.fs.BlendSupport == 0)
       return false;
@@ -480,6 +480,7 @@ lower_blend_equation_advanced(struct gl_linked_shader *sh)
    fb->data.location = FRAG_RESULT_DATA0;
    fb->data.read_only = 1;
    fb->data.fb_fetch_output = 1;
+   fb->data.memory_coherent = coherent;
    fb->data.how_declared = ir_var_hidden;
 
    ir_variable *mode = new(mem_ctx) ir_variable(glsl_type::uint_type,
index f0598f591ab1240fb0586b41367ba4a171ee2505..b08b56a935301b926e1ef7f8c8a5d9a3ddd1d9e5 100644 (file)
@@ -99,7 +99,8 @@ process_glsl_ir(struct brw_context *brw,
 
    ralloc_adopt(mem_ctx, shader->ir);
 
-   lower_blend_equation_advanced(shader);
+   lower_blend_equation_advanced(
+      shader, ctx->Extensions.KHR_blend_equation_advanced_coherent);
 
    /* lower_packing_builtins() inserts arithmetic instructions, so it
     * must precede lower_instructions().
index 7fef93949e8808f5914b297d003ce4e6fc2def90..ccf4dabcc9fd7e5c3678cdf4ac03fdba256b28ed 100644 (file)
@@ -7056,7 +7056,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       do_mat_op_to_vec(ir);
 
       if (stage == MESA_SHADER_FRAGMENT)
-         lower_blend_equation_advanced(shader);
+         lower_blend_equation_advanced(
+            shader, ctx->Extensions.KHR_blend_equation_advanced_coherent);
 
       lower_instructions(ir,
                          MOD_TO_FLOOR |