From c06e32596735074536b0e613cbddb1c5fd7b367a Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Thu, 11 Aug 2011 20:58:21 -0700 Subject: glsl: Implement a lowering pass for gl_ClipDistance. In i965 GEN6+ (and I suspect most other hardware), gl_ClipDistance needs to be laid out as a pair of vec4's (the first containing clip distances 0-3, and the second containing clip distances 4-7). However, it is declared in GLSL as an array of 8 floats. This lowering pass acts at the GLSL level, modifying the declaration of gl_ClipDistance so that it is an array of vec4's rather than an array of floats, and renaming it to gl_ClipDistanceMESA. In addition, it modifies all accesses to the array so that they access the appropiate component of one of the vec4's. Since some hardware may not internally represent gl_ClipDistance as a pair of vec4's, this lowering pass is optional. To enable it, set the LowerClipDistance flag in gl_shader_compiler_options to true. Reviewed-by: Kenneth Graunke --- src/glsl/linker.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/glsl/linker.cpp') diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 195f58f29c6..ceb49fd5b20 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1743,6 +1743,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) if (!prog->LinkStatus) goto done; + if (ctx->ShaderCompilerOptions[i].LowerClipDistance) + lower_clip_distance(prog->_LinkedShaders[i]->ir); + while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, 32)) ; } -- cgit v1.2.3