summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir_optimization.h
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-06-27 11:32:16 -0700
committerKenneth Graunke <[email protected]>2016-08-25 19:22:10 -0700
commit8ab50f5dd14fb720316e65d9553e7cad5c50bf87 (patch)
tree483403faaff53b705dcff9a5861460675783a9f6 /src/compiler/glsl/ir_optimization.h
parente299661166a77c3cfc8a59c874bdb1e2179aa160 (diff)
glsl: Add a lowering pass to handle advanced blending modes.
Many GPUs cannot handle GL_KHR_blend_equation_advanced natively, and need to emulate it in the pixel shader. This lowering pass implements all the necessary math for advanced blending. It fetches the existing framebuffer value using the MESA_shader_framebuffer_fetch built-in variables, and the previous commit's state var uniform to select which equation to use. This is done at the GLSL IR level to make it easy for all drivers to implement the GL_KHR_blend_equation_advanced extension and share code. Drivers need to hook up MESA_shader_framebuffer_fetch functionality: 1. Hook up the fb_fetch_output variable 2. Implement BlendBarrier() Then to get KHR_blend_equation_advanced, they simply need to: 3. Disable hardware blending based on ctx->Color._AdvancedBlendEnabled 4. Call this lowering pass. Very little driver specific code should be required. v2: Handle multiple output variables per render target (which may exist due to ARB_enhanced_layouts), and array variables (even with one render target, we might have out vec4 color[1]), and non-vec4 variables (it's easier than finding spec text to justify not handling it). Thanks to Francisco Jerez for the feedback. v3: Lower main returns so that we have a single exit point where we can add our blending epilogue (caught by Francisco Jerez). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/compiler/glsl/ir_optimization.h')
-rw-r--r--src/compiler/glsl/ir_optimization.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index c29260a45ca..3bd6928a06c 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -151,6 +151,7 @@ void optimize_dead_builtin_variables(exec_list *instructions,
bool lower_tess_level(gl_linked_shader *shader);
bool lower_vertex_id(gl_linked_shader *shader);
+bool lower_blend_equation_advanced(gl_linked_shader *shader);
bool lower_subroutine(exec_list *instructions, struct _mesa_glsl_parse_state *state);
void propagate_invariance(exec_list *instructions);