summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_wm_glsl.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-04-01 12:25:34 -0600
committerBrian Paul <brianp@vmware.com>2009-04-03 09:07:04 -0600
commit34239862430aa38b0b1b6740c47d66f7260ae3e4 (patch)
treeadf692f6d06d973788b66c550d19369d583973d1 /src/mesa/drivers/dri/i965/brw_wm_glsl.c
parent597cd5b94e4818679af1134d053541f3d2cfb80e (diff)
i965: change args to get_src_reg() to prep for new constant buffer support
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_wm_glsl.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_glsl.c164
1 files changed, 85 insertions, 79 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
index 28ef84e4aac..41db3a805b7 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
@@ -254,7 +254,8 @@ static void prealloc_reg(struct brw_wm_compile *c)
* Convert Mesa dst register to brw register.
*/
static struct brw_reg get_dst_reg(struct brw_wm_compile *c,
- struct prog_instruction *inst, int component)
+ const struct prog_instruction *inst,
+ GLuint component)
{
const int nr = 1;
return get_reg(c, inst->DstReg.File, inst->DstReg.Index, component, nr,
@@ -266,10 +267,13 @@ static struct brw_reg get_dst_reg(struct brw_wm_compile *c,
* Convert Mesa src register to brw register.
*/
static struct brw_reg get_src_reg(struct brw_wm_compile *c,
- struct prog_src_register *src, int index)
+ const struct prog_instruction *inst,
+ GLuint srcRegIndex, GLuint channel)
{
- const int nr = 1;
- int component = GET_SWZ(src->Swizzle, index);
+ const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
+ const GLuint nr = 1;
+ const GLuint component = GET_SWZ(src->Swizzle, channel);
+
return get_reg(c, src->File, src->Index, component, nr,
src->NegateBase, src->Abs);
}
@@ -282,11 +286,13 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,
* For instructions with more than one operand, only the second can be a literal.
*/
static struct brw_reg get_src_reg_imm(struct brw_wm_compile *c,
- struct prog_src_register *src, int index)
+ const struct prog_instruction *inst,
+ GLuint srcRegIndex, GLuint channel)
{
+ const struct prog_src_register *src = &inst->SrcReg[srcRegIndex];
if (src->File == PROGRAM_CONSTANT) {
/* a literal */
- const int component = GET_SWZ(src->Swizzle, index);
+ const int component = GET_SWZ(src->Swizzle, channel);
const GLfloat *param =
c->fp->program.Base.Parameters->ParameterValues[src->Index];
GLfloat value = param[component];
@@ -297,7 +303,7 @@ static struct brw_reg get_src_reg_imm(struct brw_wm_compile *c,
return brw_imm_f(value);
}
else {
- return get_src_reg(c, src, index);
+ return get_src_reg(c, inst, srcRegIndex, channel);
}
}
@@ -376,7 +382,7 @@ static void emit_abs( struct brw_wm_compile *c,
if (inst->DstReg.WriteMask & (1<<i)) {
struct brw_reg src, dst;
dst = get_dst_reg(c, inst, i);
- src = get_src_reg(c, &inst->SrcReg[0], i);
+ src = get_src_reg(c, inst, 0, i);
brw_MOV(p, dst, brw_abs(src));
}
}
@@ -394,7 +400,7 @@ static void emit_trunc( struct brw_wm_compile *c,
if (mask & (1<<i)) {
struct brw_reg src, dst;
dst = get_dst_reg(c, inst, i);
- src = get_src_reg(c, &inst->SrcReg[0], i);
+ src = get_src_reg(c, inst, 0, i);
brw_RNDZ(p, dst, src);
}
}
@@ -412,7 +418,7 @@ static void emit_mov( struct brw_wm_compile *c,
if (mask & (1<<i)) {
struct brw_reg src, dst;
dst = get_dst_reg(c, inst, i);
- src = get_src_reg_imm(c, &inst->SrcReg[0], i);
+ src = get_src_reg_imm(c, inst, 0, i);
brw_MOV(p, dst, src);
}
}
@@ -459,8 +465,8 @@ static void emit_delta_xy(struct brw_wm_compile *c,
dst0 = get_dst_reg(c, inst, 0);
dst1 = get_dst_reg(c, inst, 1);
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
- src1 = get_src_reg(c, &inst->SrcReg[0], 1);
+ src0 = get_src_reg(c, inst, 0, 0);
+ src1 = get_src_reg(c, inst, 0, 1);
/* Calc delta X,Y by subtracting origin in r1 from the pixel
* centers.
*/
@@ -525,7 +531,7 @@ static void emit_fb_write(struct brw_wm_compile *c,
brw_push_insn_state(p);
for (channel = 0; channel < 4; channel++) {
- src0 = get_src_reg(c, &inst->SrcReg[0], channel);
+ src0 = get_src_reg(c, inst, 0, channel);
/* mov (8) m2.0<1>:ud r28.0<8;8,1>:ud { Align1 } */
/* mov (8) m6.0<1>:ud r29.0<8;8,1>:ud { Align1 SecHalf } */
brw_MOV(p, brw_message_reg(nr + channel), src0);
@@ -536,11 +542,11 @@ static void emit_fb_write(struct brw_wm_compile *c,
if (c->key.source_depth_to_render_target) {
if (c->key.computes_depth) {
- src0 = get_src_reg(c, &inst->SrcReg[2], 2);
+ src0 = get_src_reg(c, inst, 2, 2);
brw_MOV(p, brw_message_reg(nr), src0);
}
else {
- src0 = get_src_reg(c, &inst->SrcReg[1], 1);
+ src0 = get_src_reg(c, inst, 1, 1);
brw_MOV(p, brw_message_reg(nr), src0);
}
@@ -567,7 +573,7 @@ static void emit_fb_write(struct brw_wm_compile *c,
else
#endif
{
- struct brw_reg src = get_src_reg(c, &inst->SrcReg[1], 1);
+ struct brw_reg src = get_src_reg(c, inst, 1, 1);
brw_MOV(p, brw_message_reg(nr), src);
}
nr += 2;
@@ -588,9 +594,9 @@ static void emit_pixel_w( struct brw_wm_compile *c,
struct brw_reg interp3;
dst = get_dst_reg(c, inst, 3);
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
- delta0 = get_src_reg(c, &inst->SrcReg[1], 0);
- delta1 = get_src_reg(c, &inst->SrcReg[1], 1);
+ src0 = get_src_reg(c, inst, 0, 0);
+ delta0 = get_src_reg(c, inst, 1, 0);
+ delta1 = get_src_reg(c, inst, 1, 1);
interp3 = brw_vec1_grf(src0.nr+1, 4);
/* Calc 1/w - just linterp wpos[3] optimized by putting the
@@ -618,9 +624,9 @@ static void emit_linterp(struct brw_wm_compile *c,
struct brw_reg src0;
GLuint nr, i;
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
- delta0 = get_src_reg(c, &inst->SrcReg[1], 0);
- delta1 = get_src_reg(c, &inst->SrcReg[1], 1);
+ src0 = get_src_reg(c, inst, 0, 0);
+ delta0 = get_src_reg(c, inst, 1, 0);
+ delta1 = get_src_reg(c, inst, 1, 1);
nr = src0.nr;
interp[0] = brw_vec1_grf(nr, 0);
@@ -647,7 +653,7 @@ static void emit_cinterp(struct brw_wm_compile *c,
struct brw_reg dst, src0;
GLuint nr, i;
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
+ src0 = get_src_reg(c, inst, 0, 0);
nr = src0.nr;
interp[0] = brw_vec1_grf(nr, 0);
@@ -674,10 +680,10 @@ static void emit_pinterp(struct brw_wm_compile *c,
struct brw_reg src0, w;
GLuint nr, i;
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
- delta0 = get_src_reg(c, &inst->SrcReg[1], 0);
- delta1 = get_src_reg(c, &inst->SrcReg[1], 1);
- w = get_src_reg(c, &inst->SrcReg[2], 3);
+ src0 = get_src_reg(c, inst, 0, 0);
+ delta0 = get_src_reg(c, inst, 1, 0);
+ delta1 = get_src_reg(c, inst, 1, 1);
+ w = get_src_reg(c, inst, 2, 3);
nr = src0.nr;
interp[0] = brw_vec1_grf(nr, 0);
@@ -738,11 +744,11 @@ static void emit_xpd(struct brw_wm_compile *c,
if (mask & (1<<i)) {
struct brw_reg src0, src1, dst;
dst = get_dst_reg(c, inst, i);
- src0 = negate(get_src_reg(c, &inst->SrcReg[0], i2));
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i1);
+ src0 = negate(get_src_reg(c, inst, 0, i2));
+ src1 = get_src_reg_imm(c, inst, 1, i1);
brw_MUL(p, brw_null_reg(), src0, src1);
- src0 = get_src_reg(c, &inst->SrcReg[0], i1);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i2);
+ src0 = get_src_reg(c, inst, 0, i1);
+ src1 = get_src_reg_imm(c, inst, 1, i2);
brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
brw_MAC(p, dst, src0, src1);
brw_set_saturate(p, 0);
@@ -758,8 +764,8 @@ static void emit_dp3(struct brw_wm_compile *c,
int i;
struct brw_compile *p = &c->func;
for (i = 0; i < 3; i++) {
- src0[i] = get_src_reg(c, &inst->SrcReg[0], i);
- src1[i] = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0[i] = get_src_reg(c, inst, 0, i);
+ src1[i] = get_src_reg_imm(c, inst, 1, i);
}
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
@@ -777,8 +783,8 @@ static void emit_dp4(struct brw_wm_compile *c,
int i;
struct brw_compile *p = &c->func;
for (i = 0; i < 4; i++) {
- src0[i] = get_src_reg(c, &inst->SrcReg[0], i);
- src1[i] = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0[i] = get_src_reg(c, inst, 0, i);
+ src1[i] = get_src_reg_imm(c, inst, 1, i);
}
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
@@ -796,8 +802,8 @@ static void emit_dph(struct brw_wm_compile *c,
int i;
struct brw_compile *p = &c->func;
for (i = 0; i < 4; i++) {
- src0[i] = get_src_reg(c, &inst->SrcReg[0], i);
- src1[i] = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0[i] = get_src_reg(c, inst, 0, i);
+ src1[i] = get_src_reg_imm(c, inst, 1, i);
}
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
@@ -824,7 +830,7 @@ static void emit_math1(struct brw_wm_compile *c,
tmp = alloc_tmp(c);
/* Get first component of source register */
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
+ src0 = get_src_reg(c, inst, 0, 0);
/* tmp = func(src0) */
brw_MOV(p, brw_message_reg(2), src0);
@@ -897,8 +903,8 @@ static void emit_add(struct brw_wm_compile *c,
for (i = 0 ; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0 = get_src_reg(c, inst, 0, i);
+ src1 = get_src_reg_imm(c, inst, 1, i);
brw_ADD(p, dst, src0, src1);
}
}
@@ -913,7 +919,7 @@ static void emit_arl(struct brw_wm_compile *c,
brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
addr_reg = brw_uw8_reg(BRW_ARCHITECTURE_REGISTER_FILE,
BRW_ARF_ADDRESS, 0);
- src0 = get_src_reg(c, &inst->SrcReg[0], 0); /* channel 0 */
+ src0 = get_src_reg(c, inst, 0, 0); /* channel 0 */
brw_MOV(p, addr_reg, src0);
brw_set_saturate(p, 0);
}
@@ -929,8 +935,8 @@ static void emit_sub(struct brw_wm_compile *c,
for (i = 0 ; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0 = get_src_reg(c, inst, 0, i);
+ src1 = get_src_reg_imm(c, inst, 1, i);
brw_ADD(p, dst, src0, negate(src1));
}
}
@@ -948,8 +954,8 @@ static void emit_mul(struct brw_wm_compile *c,
for (i = 0 ; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0 = get_src_reg(c, inst, 0, i);
+ src1 = get_src_reg_imm(c, inst, 1, i);
brw_MUL(p, dst, src0, src1);
}
}
@@ -967,7 +973,7 @@ static void emit_frc(struct brw_wm_compile *c,
for (i = 0 ; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg_imm(c, &inst->SrcReg[0], i);
+ src0 = get_src_reg_imm(c, inst, 0, i);
brw_FRC(p, dst, src0);
}
}
@@ -986,7 +992,7 @@ static void emit_flr(struct brw_wm_compile *c,
for (i = 0 ; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg_imm(c, &inst->SrcReg[0], i);
+ src0 = get_src_reg_imm(c, inst, 0, i);
brw_RNDD(p, dst, src0);
}
}
@@ -1004,8 +1010,8 @@ static void emit_max(struct brw_wm_compile *c,
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0 = get_src_reg(c, inst, 0, i);
+ src1 = get_src_reg_imm(c, inst, 1, i);
brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
brw_MOV(p, dst, src0);
brw_set_saturate(p, 0);
@@ -1032,8 +1038,8 @@ static void emit_min(struct brw_wm_compile *c,
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg_imm(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
+ src0 = get_src_reg_imm(c, inst, 0, i);
+ src1 = get_src_reg(c, inst, 1, i);
brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
brw_MOV(p, dst, src0);
brw_set_saturate(p, 0);
@@ -1055,8 +1061,8 @@ static void emit_pow(struct brw_wm_compile *c,
struct brw_compile *p = &c->func;
struct brw_reg dst, src0, src1;
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
- src0 = get_src_reg_imm(c, &inst->SrcReg[0], 0);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], 0);
+ src0 = get_src_reg_imm(c, inst, 0, 0);
+ src1 = get_src_reg_imm(c, inst, 1, 0);
brw_MOV(p, brw_message_reg(2), src0);
brw_MOV(p, brw_message_reg(3), src1);
@@ -1082,9 +1088,9 @@ static void emit_lrp(struct brw_wm_compile *c,
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
+ src0 = get_src_reg(c, inst, 0, i);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src1 = get_src_reg_imm(c, inst, 1, i);
if (src1.nr == dst.nr) {
tmp1 = alloc_tmp(c);
@@ -1092,7 +1098,7 @@ static void emit_lrp(struct brw_wm_compile *c,
} else
tmp1 = src1;
- src2 = get_src_reg(c, &inst->SrcReg[2], i);
+ src2 = get_src_reg(c, inst, 2, i);
if (src2.nr == dst.nr) {
tmp2 = alloc_tmp(c);
brw_MOV(p, tmp2, src2);
@@ -1135,9 +1141,9 @@ static void emit_mad(struct brw_wm_compile *c,
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
- src2 = get_src_reg_imm(c, &inst->SrcReg[2], i);
+ src0 = get_src_reg(c, inst, 0, i);
+ src1 = get_src_reg_imm(c, inst, 1, i);
+ src2 = get_src_reg_imm(c, inst, 2, i);
brw_MUL(p, dst, src0, src1);
brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
@@ -1158,8 +1164,8 @@ static void emit_sop(struct brw_wm_compile *c,
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src0 = get_src_reg(c, inst, 0, i);
+ src1 = get_src_reg_imm(c, inst, 1, i);
brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), cond, src0, src1);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
@@ -1216,8 +1222,8 @@ static void emit_ddx(struct brw_wm_compile *c,
struct brw_reg dst;
struct brw_reg src0, w;
GLuint nr, i;
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
- w = get_src_reg(c, &inst->SrcReg[1], 3);
+ src0 = get_src_reg(c, inst, 0, 0);
+ w = get_src_reg(c, inst, 1, 3);
nr = src0.nr;
interp[0] = brw_vec1_grf(nr, 0);
interp[1] = brw_vec1_grf(nr, 4);
@@ -1244,9 +1250,9 @@ static void emit_ddy(struct brw_wm_compile *c,
struct brw_reg src0, w;
GLuint nr, i;
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
+ src0 = get_src_reg(c, inst, 0, 0);
nr = src0.nr;
- w = get_src_reg(c, &inst->SrcReg[1], 3);
+ w = get_src_reg(c, inst, 1, 3);
interp[0] = brw_vec1_grf(nr, 0);
interp[1] = brw_vec1_grf(nr, 4);
interp[2] = brw_vec1_grf(nr+1, 0);
@@ -1388,7 +1394,7 @@ static void emit_noise1( struct brw_wm_compile *c,
assert( mark == 0 );
- src = get_src_reg( c, inst->SrcReg, 0 );
+ src = get_src_reg( c, inst, 0, 0 );
param = alloc_tmp( c );
@@ -1558,8 +1564,8 @@ static void emit_noise2( struct brw_wm_compile *c,
assert( mark == 0 );
- src0 = get_src_reg( c, inst->SrcReg, 0 );
- src1 = get_src_reg( c, inst->SrcReg, 1 );
+ src0 = get_src_reg( c, inst, 0, 0 );
+ src1 = get_src_reg( c, inst, 0, 1 );
param0 = alloc_tmp( c );
param1 = alloc_tmp( c );
@@ -1861,9 +1867,9 @@ static void emit_noise3( struct brw_wm_compile *c,
assert( mark == 0 );
- src0 = get_src_reg( c, inst->SrcReg, 0 );
- src1 = get_src_reg( c, inst->SrcReg, 1 );
- src2 = get_src_reg( c, inst->SrcReg, 2 );
+ src0 = get_src_reg( c, inst, 0, 0 );
+ src1 = get_src_reg( c, inst, 0, 1 );
+ src2 = get_src_reg( c, inst, 0, 2 );
param0 = alloc_tmp( c );
param1 = alloc_tmp( c );
@@ -2284,10 +2290,10 @@ static void emit_noise4( struct brw_wm_compile *c,
assert( mark == 0 );
- src0 = get_src_reg( c, inst->SrcReg, 0 );
- src1 = get_src_reg( c, inst->SrcReg, 1 );
- src2 = get_src_reg( c, inst->SrcReg, 2 );
- src3 = get_src_reg( c, inst->SrcReg, 3 );
+ src0 = get_src_reg( c, inst, 0, 0 );
+ src1 = get_src_reg( c, inst, 0, 1 );
+ src2 = get_src_reg( c, inst, 0, 2 );
+ src3 = get_src_reg( c, inst, 0, 3 );
param0 = alloc_tmp( c );
param1 = alloc_tmp( c );
@@ -2325,8 +2331,8 @@ static void emit_wpos_xy(struct brw_wm_compile *c,
dst[0] = get_dst_reg(c, inst, 0);
dst[1] = get_dst_reg(c, inst, 1);
- src0[0] = get_src_reg(c, &inst->SrcReg[0], 0);
- src0[1] = get_src_reg(c, &inst->SrcReg[0], 1);
+ src0[0] = get_src_reg(c, inst, 0, 0);
+ src0[1] = get_src_reg(c, inst, 0, 1);
/* Calculate the pixel offset from window bottom left into destination
* X and Y channels.
@@ -2364,7 +2370,7 @@ static void emit_txb(struct brw_wm_compile *c,
for (i = 0; i < 4; i++)
dst[i] = get_dst_reg(c, inst, i);
for (i = 0; i < 4; i++)
- src[i] = get_src_reg(c, &inst->SrcReg[0], i);
+ src[i] = get_src_reg(c, inst, 0, i);
switch (inst->TexSrcTarget) {
case TEXTURE_1D_INDEX:
@@ -2416,7 +2422,7 @@ static void emit_tex(struct brw_wm_compile *c,
for (i = 0; i < 4; i++)
dst[i] = get_dst_reg(c, inst, i);
for (i = 0; i < 4; i++)
- src[i] = get_src_reg(c, &inst->SrcReg[0], i);
+ src[i] = get_src_reg(c, inst, 0, i);
switch (inst->TexSrcTarget) {
case TEXTURE_1D_INDEX: