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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8118>
This commit is contained in:
Eric Anholt 2020-08-24 13:50:45 -07:00 committed by Marge Bot
parent 06a081c631
commit 5875cfcc2f
3 changed files with 22 additions and 13 deletions

View File

@ -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 )

View File

@ -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);

View File

@ -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);