summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-06-28 19:16:18 -0700
committerKenneth Graunke <[email protected]>2014-06-30 14:05:28 -0700
commitf36bebcd5c9d3f23d611c59a97ab49e93c8850ee (patch)
treeccbb754abf4c2470832258ee23829b0f94420930 /src
parentbdcbcc73dd67892247e133309c65eb4677757eb0 (diff)
i965/disasm: Cut piles of duplicate swizzle printing.
Making a helper function saves us from cut and pasting this four times. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_disasm.c115
1 files changed, 26 insertions, 89 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c b/src/mesa/drivers/dri/i965/brw_disasm.c
index de438cd239f..54435bef3b8 100644
--- a/src/mesa/drivers/dri/i965/brw_disasm.c
+++ b/src/mesa/drivers/dri/i965/brw_disasm.c
@@ -817,6 +817,28 @@ src_ia1(FILE *file,
}
static int
+src_swizzle(FILE *file, unsigned swiz)
+{
+ unsigned x = BRW_GET_SWZ(swiz, BRW_CHANNEL_X);
+ unsigned y = BRW_GET_SWZ(swiz, BRW_CHANNEL_Y);
+ unsigned z = BRW_GET_SWZ(swiz, BRW_CHANNEL_Z);
+ unsigned w = BRW_GET_SWZ(swiz, BRW_CHANNEL_W);
+ int err = 0;
+
+ if (x == y && x == z && x == w) {
+ string(file, ".");
+ err |= control(file, "channel select", chan_sel, x, NULL);
+ } else if (swiz != BRW_SWIZZLE_XYZW) {
+ string(file, ".");
+ err |= control(file, "channel select", chan_sel, x, NULL);
+ err |= control(file, "channel select", chan_sel, y, NULL);
+ err |= control(file, "channel select", chan_sel, z, NULL);
+ err |= control(file, "channel select", chan_sel, w, NULL);
+ }
+ return err;
+}
+
+static int
src_da16(FILE *file,
const struct brw_context *brw,
unsigned opcode,
@@ -848,26 +870,7 @@ src_da16(FILE *file,
string(file, "<");
err |= control(file, "vert stride", vert_stride, _vert_stride, NULL);
string(file, ",4,1>");
- /*
- * Three kinds of swizzle display:
- * identity - nothing printed
- * 1->all - print the single channel
- * 1->1 - print the mapping
- */
- if (swz_x == BRW_CHANNEL_X &&
- swz_y == BRW_CHANNEL_Y &&
- swz_z == BRW_CHANNEL_Z && swz_w == BRW_CHANNEL_W) {
- ;
- } else if (swz_x == swz_y && swz_x == swz_z && swz_x == swz_w) {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- } else {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- err |= control(file, "channel select", chan_sel, swz_y, NULL);
- err |= control(file, "channel select", chan_sel, swz_z, NULL);
- err |= control(file, "channel select", chan_sel, swz_w, NULL);
- }
+ err |= src_swizzle(file, BRW_SWIZZLE4(swz_x, swz_y, swz_z, swz_w));
err |= control(file, "src da16 reg type", reg_encoding, _reg_type, NULL);
return err;
}
@@ -876,11 +879,6 @@ static int
src0_3src(FILE *file, struct brw_context *brw, brw_inst *inst)
{
int err = 0;
- unsigned swz = brw_inst_3src_src0_swizzle(brw, inst);
- unsigned swz_x = BRW_GET_SWZ(swz, BRW_CHANNEL_X);
- unsigned swz_y = BRW_GET_SWZ(swz, BRW_CHANNEL_Y);
- unsigned swz_z = BRW_GET_SWZ(swz, BRW_CHANNEL_Z);
- unsigned swz_w = BRW_GET_SWZ(swz, BRW_CHANNEL_W);
unsigned src0_subreg_nr = brw_inst_3src_src0_subreg_nr(brw, inst);
err |= control(file, "negate", m_negate,
@@ -899,24 +897,7 @@ src0_3src(FILE *file, struct brw_context *brw, brw_inst *inst)
string(file, "<4,4,1>");
err |= control(file, "src da16 reg type", three_source_reg_encoding,
brw_inst_3src_src_type(brw, inst), NULL);
- /*
- * Three kinds of swizzle display:
- * identity - nothing printed
- * 1->all - print the single channel
- * 1->1 - print the mapping
- */
- if (swz == BRW_SWIZZLE_XYZW) {
- ;
- } else if (swz_x == swz_y && swz_x == swz_z && swz_x == swz_w) {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- } else {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- err |= control(file, "channel select", chan_sel, swz_y, NULL);
- err |= control(file, "channel select", chan_sel, swz_z, NULL);
- err |= control(file, "channel select", chan_sel, swz_w, NULL);
- }
+ err |= src_swizzle(file, brw_inst_3src_src0_swizzle(brw, inst));
return err;
}
@@ -924,11 +905,6 @@ static int
src1_3src(FILE *file, struct brw_context *brw, brw_inst *inst)
{
int err = 0;
- unsigned swz = brw_inst_3src_src1_swizzle(brw, inst);
- unsigned swz_x = BRW_GET_SWZ(swz, BRW_CHANNEL_X);
- unsigned swz_y = BRW_GET_SWZ(swz, BRW_CHANNEL_Y);
- unsigned swz_z = BRW_GET_SWZ(swz, BRW_CHANNEL_Z);
- unsigned swz_w = BRW_GET_SWZ(swz, BRW_CHANNEL_W);
unsigned src1_subreg_nr = brw_inst_3src_src1_subreg_nr(brw, inst);
err |= control(file, "negate", m_negate,
@@ -947,24 +923,7 @@ src1_3src(FILE *file, struct brw_context *brw, brw_inst *inst)
string(file, "<4,4,1>");
err |= control(file, "src da16 reg type", three_source_reg_encoding,
brw_inst_3src_src_type(brw, inst), NULL);
- /*
- * Three kinds of swizzle display:
- * identity - nothing printed
- * 1->all - print the single channel
- * 1->1 - print the mapping
- */
- if (swz == BRW_SWIZZLE_XYZW) {
- ;
- } else if (swz_x == swz_y && swz_x == swz_z && swz_x == swz_w) {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- } else {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- err |= control(file, "channel select", chan_sel, swz_y, NULL);
- err |= control(file, "channel select", chan_sel, swz_z, NULL);
- err |= control(file, "channel select", chan_sel, swz_w, NULL);
- }
+ err |= src_swizzle(file, brw_inst_3src_src1_swizzle(brw, inst));
return err;
}
@@ -973,11 +932,6 @@ static int
src2_3src(FILE *file, struct brw_context *brw, brw_inst *inst)
{
int err = 0;
- unsigned swz = brw_inst_3src_src2_swizzle(brw, inst);
- unsigned swz_x = BRW_GET_SWZ(swz, BRW_CHANNEL_X);
- unsigned swz_y = BRW_GET_SWZ(swz, BRW_CHANNEL_Y);
- unsigned swz_z = BRW_GET_SWZ(swz, BRW_CHANNEL_Z);
- unsigned swz_w = BRW_GET_SWZ(swz, BRW_CHANNEL_W);
unsigned src2_subreg_nr = brw_inst_3src_src2_subreg_nr(brw, inst);
err |= control(file, "negate", m_negate,
@@ -996,24 +950,7 @@ src2_3src(FILE *file, struct brw_context *brw, brw_inst *inst)
string(file, "<4,4,1>");
err |= control(file, "src da16 reg type", three_source_reg_encoding,
brw_inst_3src_src_type(brw, inst), NULL);
- /*
- * Three kinds of swizzle display:
- * identity - nothing printed
- * 1->all - print the single channel
- * 1->1 - print the mapping
- */
- if (swz == BRW_SWIZZLE_XYZW) {
- ;
- } else if (swz_x == swz_y && swz_x == swz_z && swz_x == swz_w) {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- } else {
- string(file, ".");
- err |= control(file, "channel select", chan_sel, swz_x, NULL);
- err |= control(file, "channel select", chan_sel, swz_y, NULL);
- err |= control(file, "channel select", chan_sel, swz_z, NULL);
- err |= control(file, "channel select", chan_sel, swz_w, NULL);
- }
+ err |= src_swizzle(file, brw_inst_3src_src2_swizzle(brw, inst));
return err;
}