summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_wm_glsl.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-03-19 12:34:53 -0700
committerEric Anholt <eric@anholt.net>2010-03-22 15:04:46 -0700
commit4fc57322258a750c0a9cabc77372b5ccde1fa877 (patch)
tree4847b7cc15466645b5b71c8f4e7fe3ffbf45da51 /src/mesa/drivers/dri/i965/brw_wm_glsl.c
parent864f2bd61d2bad31b49a680a168fc6d7c04d1de1 (diff)
i965: Allow FS constants to be used as immediates instead of push/pull.
The hope is to later take advantage of the reduced constant usage to free up regs. This only covers the GLSL path at the moment, because the brw_wm_emit path doesn't get the information as to whether a float value is a constant or a uniform.
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_wm_glsl.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_glsl.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
index d9d6ddae8c4..d78fb4ed09f 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
@@ -570,12 +570,25 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,
const GLuint nr = 1;
const GLuint component = GET_SWZ(src->Swizzle, channel);
- /* Extended swizzle terms */
- if (component == SWIZZLE_ZERO) {
- return brw_imm_f(0.0F);
- }
- else if (component == SWIZZLE_ONE) {
- return brw_imm_f(1.0F);
+ /* Only one immediate value can be used per native opcode, and it
+ * has be in the src1 slot, so not all Mesa instructions will get
+ * to take advantage of immediate constants.
+ */
+ if (brw_wm_arg_can_be_immediate(inst->Opcode, srcRegIndex)) {
+ const struct gl_program_parameter_list *params;
+
+ params = c->fp->program.Base.Parameters;
+
+ /* Extended swizzle terms */
+ if (component == SWIZZLE_ZERO) {
+ return brw_imm_f(0.0F);
+ } else if (component == SWIZZLE_ONE) {
+ return brw_imm_f(1.0F);
+ }
+
+ if (src->File == PROGRAM_CONSTANT) {
+ return brw_imm_f(params->ParameterValues[src->Index][component]);
+ }
}
if (c->fp->use_const_buffer &&