summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_fs.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-08-13 02:20:40 -0700
committerEric Anholt <[email protected]>2010-08-26 14:55:43 -0700
commit3a8ad33dde2f059b82ebf09f5cffa66c86f2e734 (patch)
tree63bbf650370578bf8273b754746d20cbe128171f /src/mesa/drivers/dri/i965/brw_fs.cpp
parenta1bebf73dfdaf2cd23286aa74271b87166589901 (diff)
i965: Add a pass for the FS to reduce vector expressions down to scalar.
This is a step towards implementing a GLSL IR backend for the 965 fragment shader. Because it has downsides with the current codegen, it is hidden under the environment variable INTEL_NEW_FS. This results in an increase in instruction count at the moment (1444 -> 1752 for glsl-fs-raytrace, 345 -> 359 on my demo), because dot products are turned into a series of multiplies and adds instead of a custom expansion of MULs and MACs, and by not splitting the variable types up we don't get tree grafting and thus there are extra moves of temporary storage. However, register count drops for the non-GLSL path (64 -> 56 on my demo shader) because the register allocator sees all the sub-operations.
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_fs.cpp')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 9509d932367..d16e75a2ca9 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -36,6 +36,7 @@ extern "C" {
#include "brw_wm.h"
#include "talloc.h"
}
+#include "../glsl/ir_optimization.h"
struct gl_shader *
brw_new_shader(GLcontext *ctx, GLuint name, GLuint type)
@@ -75,6 +76,20 @@ brw_compile_shader(GLcontext *ctx, struct gl_shader *shader)
GLboolean
brw_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
{
+ static int using_new_fs = -1;
+
+ if (using_new_fs == -1)
+ using_new_fs = getenv("INTEL_NEW_FS") != NULL;
+
+ for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
+ struct gl_shader *shader = prog->_LinkedShaders[i];
+
+ if (using_new_fs && shader->Type == GL_FRAGMENT_SHADER) {
+ do_mat_op_to_vec(shader->ir);
+ brw_do_channel_expressions(shader->ir);
+ }
+ }
+
if (!_mesa_ir_link_shader(ctx, prog))
return GL_FALSE;