Module: Mesa Branch: master Commit: 5875cfcc2ff8d6321f08b6d3f4f90c8b8ae3bbb5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5875cfcc2ff8d6321f08b6d3f4f90c8b8ae3bbb5
Author: Eric Anholt <[email protected]> Date: Mon Aug 24 13:50:45 2020 -0700 mesa/ati_fs: Clean up writemask handling. Just put it into the op in core Mesa and explain what it's doing. Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8118> --- src/mesa/drivers/dri/r200/r200_fragshader.c | 6 ++++-- src/mesa/main/atifragshader.c | 18 +++++++++++++++++- src/mesa/state_tracker/st_atifs_to_tgsi.c | 11 +---------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_fragshader.c b/src/mesa/drivers/dri/r200/r200_fragshader.c index ca772f1c872..eca4c814b5f 100644 --- a/src/mesa/drivers/dri/r200/r200_fragshader.c +++ b/src/mesa/drivers/dri/r200/r200_fragshader.c @@ -109,8 +109,9 @@ static void r200SetFragShaderArg( GLuint *afs_cmd, GLuint opnum, GLuint optype, SET_INST_2(opnum, optype) |= reg2; } -static GLuint dstmask_table[8] = +static GLuint dstmask_table[9] = { + /* first slot never used, GL_NONE translated to RGB by mesa and you can't get a 0 dstmask. */ R200_TXC_OUTPUT_MASK_RGB, R200_TXC_OUTPUT_MASK_R, R200_TXC_OUTPUT_MASK_G, @@ -118,7 +119,8 @@ static GLuint dstmask_table[8] = R200_TXC_OUTPUT_MASK_B, R200_TXC_OUTPUT_MASK_RB, R200_TXC_OUTPUT_MASK_GB, - R200_TXC_OUTPUT_MASK_RGB + R200_TXC_OUTPUT_MASK_RGB, + R200_TXC_OUTPUT_MASK_RGB, /* alpha ops */ }; static void r200UpdateFSArith( struct gl_context *ctx ) diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c index aff4c6e2383..dba67f08d8e 100644 --- a/src/mesa/main/atifragshader.c +++ b/src/mesa/main/atifragshader.c @@ -30,6 +30,7 @@ #include "main/mtypes.h" #include "main/atifragshader.h" #include "program/program.h" +#include "program/prog_instruction.h" #include "util/u_memory.h" #define MESA_DEBUG_ATI_FS 0 @@ -711,7 +712,22 @@ _mesa_FragmentOpXATI(GLint optype, GLuint arg_count, GLenum op, GLuint dst, curI->DstReg[optype].Index = dst; curI->DstReg[optype].dstMod = dstMod; - curI->DstReg[optype].dstMask = dstMask; + /* From the ATI_fs spec: + * + * "The <dstMask> parameter specifies which of the color components in + * <dst> will be written (ColorFragmentOp[1..3]ATI only). This can + * either be NONE, in which case there is no mask and everything is + * written, or the bitwise-or of RED_BIT_ATI, GREEN_BIT_ATI, and + * BLUE_BIT_ATI." + * + * For AlphaFragmentOp, it always writes alpha. + */ + if (optype == ATI_FRAGMENT_SHADER_ALPHA_OP) + curI->DstReg[optype].dstMask = WRITEMASK_W; + else if (dstMask == GL_NONE) + curI->DstReg[optype].dstMask = WRITEMASK_XYZ; + else + curI->DstReg[optype].dstMask = dstMask; #if MESA_DEBUG_ATI_FS debug_op(optype, arg_count, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod); diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c b/src/mesa/state_tracker/st_atifs_to_tgsi.c index 70306eaa216..0de2d53321c 100644 --- a/src/mesa/state_tracker/st_atifs_to_tgsi.c +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c @@ -377,16 +377,7 @@ compile_instruction(struct st_translate *t, /* prepare dst */ dst[0] = get_temp(t, dstreg); - if (optype) { - dst[0] = ureg_writemask(dst[0], TGSI_WRITEMASK_W); - } else { - GLuint dstMask = inst->DstReg[optype].dstMask; - if (dstMask == GL_NONE) { - dst[0] = ureg_writemask(dst[0], TGSI_WRITEMASK_XYZ); - } else { - dst[0] = ureg_writemask(dst[0], dstMask); /* the enum values match */ - } - } + dst[0] = ureg_writemask(dst[0], inst->DstReg[optype].dstMask); /* emit the main instruction */ emit_arith_inst(t, desc, dst, args, arg); _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
