From: Brian Paul Date: Tue, 15 Apr 2014 16:13:04 +0000 (-0700) Subject: svga: use new inst_token_predicated() helper function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e131576eede26ebfd5e6d18f09642bdccb6be0f;p=mesa.git svga: use new inst_token_predicated() helper function Reviewed-by: Charmaine Lee --- diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h b/src/gallium/drivers/svga/svga_tgsi_emit.h index 53f93de28d3..0141d71568e 100644 --- a/src/gallium/drivers/svga/svga_tgsi_emit.h +++ b/src/gallium/drivers/svga/svga_tgsi_emit.h @@ -188,6 +188,23 @@ inst_token(unsigned opcode) } +/** + * Generate a SVGA3dShaderInstToken for the given SVGA3D shader opcode + * with the predication flag set. + */ +static INLINE SVGA3dShaderInstToken +inst_token_predicated(unsigned opcode) +{ + SVGA3dShaderInstToken inst; + + inst.value = 0; + inst.op = opcode; + inst.predicated = 1; + + return inst; +} + + /** * Create an instance of a SVGA3dShaderDestToken. * Note that this function is used to create tokens for output registers, diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c index 73303e35222..3ed724020b5 100644 --- a/src/gallium/drivers/svga/svga_tgsi_insn.c +++ b/src/gallium/drivers/svga/svga_tgsi_insn.c @@ -1530,7 +1530,7 @@ emit_conditional(struct svga_shader_emitter *emit, struct src_register fail) { SVGA3dShaderDestToken pred_reg = dst_register( SVGA3DREG_PREDICATE, 0 ); - SVGA3dShaderInstToken setp_token, mov_token; + SVGA3dShaderInstToken setp_token; setp_token = inst_token( SVGA3DOP_SETP ); switch (compare_func) { @@ -1577,11 +1577,8 @@ emit_conditional(struct svga_shader_emitter *emit, src0, src1 )) return FALSE; - mov_token = inst_token( SVGA3DOP_MOV ); - /* MOV dst, fail */ - if (!submit_op1( emit, mov_token, dst, - fail )) + if (!submit_op1(emit, inst_token(SVGA3DOP_MOV), dst, fail)) return FALSE; /* MOV dst, pass (predicated) @@ -1589,9 +1586,9 @@ emit_conditional(struct svga_shader_emitter *emit, * Note that the predicate reg (and possible modifiers) is passed * as the first source argument. */ - mov_token.predicated = 1; - if (!submit_op2( emit, mov_token, dst, - src( pred_reg ), pass )) + if (!submit_op2(emit, + inst_token_predicated(SVGA3DOP_MOV), dst, + src(pred_reg), pass)) return FALSE; return TRUE; @@ -2560,12 +2557,10 @@ emit_lit(struct svga_shader_emitter *emit, */ { SVGA3dShaderDestToken pred_reg = dst_register( SVGA3DREG_PREDICATE, 0 ); - SVGA3dShaderInstToken setp_token, mov_token; + SVGA3dShaderInstToken setp_token; struct src_register predsrc; setp_token = inst_token( SVGA3DOP_SETP ); - mov_token = inst_token( SVGA3DOP_MOV ); - setp_token.control = SVGA3DOPCOMP_GT; /* D3D vs GL semantics: @@ -2592,8 +2587,8 @@ emit_lit(struct svga_shader_emitter *emit, * as the first source argument. */ if (dst.mask & TGSI_WRITEMASK_YZ) { - mov_token.predicated = 1; - if (!submit_op2( emit, mov_token, + if (!submit_op2( emit, + inst_token_predicated(SVGA3DOP_MOV), writemask(dst, TGSI_WRITEMASK_YZ), src( pred_reg ), src( tmp ) )) return FALSE;