From 7c7ab5434aee1a40d1252ca10ac90a70dfd62174 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 15 Apr 2014 09:18:46 -0700 Subject: [PATCH] svga: use new inst_token_setp() helper function Reviewed-by: Charmaine Lee --- src/gallium/drivers/svga/svga_tgsi_emit.h | 17 +++++++++++++++++ src/gallium/drivers/svga/svga_tgsi_insn.c | 21 +++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h b/src/gallium/drivers/svga/svga_tgsi_emit.h index 0141d71568e..1a9731ffde8 100644 --- a/src/gallium/drivers/svga/svga_tgsi_emit.h +++ b/src/gallium/drivers/svga/svga_tgsi_emit.h @@ -205,6 +205,23 @@ inst_token_predicated(unsigned opcode) } +/** + * Generate a SVGA3dShaderInstToken for a SETP instruction (set predicate) + * using the given comparison operator (one of SVGA3DOPCOMP_xx). + */ +static INLINE SVGA3dShaderInstToken +inst_token_setp(unsigned operator) +{ + SVGA3dShaderInstToken inst; + + inst.value = 0; + inst.op = SVGA3DOP_SETP; + inst.control = operator; + + 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 3ed724020b5..d3570582404 100644 --- a/src/gallium/drivers/svga/svga_tgsi_insn.c +++ b/src/gallium/drivers/svga/svga_tgsi_insn.c @@ -1531,7 +1531,6 @@ emit_conditional(struct svga_shader_emitter *emit, { SVGA3dShaderDestToken pred_reg = dst_register( SVGA3DREG_PREDICATE, 0 ); SVGA3dShaderInstToken setp_token; - setp_token = inst_token( SVGA3DOP_SETP ); switch (compare_func) { case PIPE_FUNC_NEVER: @@ -1539,22 +1538,22 @@ emit_conditional(struct svga_shader_emitter *emit, dst, fail ); break; case PIPE_FUNC_LESS: - setp_token.control = SVGA3DOPCOMP_LT; + setp_token = inst_token_setp(SVGA3DOPCOMP_LT); break; case PIPE_FUNC_EQUAL: - setp_token.control = SVGA3DOPCOMP_EQ; + setp_token = inst_token_setp(SVGA3DOPCOMP_EQ); break; case PIPE_FUNC_LEQUAL: - setp_token.control = SVGA3DOPCOMP_LE; + setp_token = inst_token_setp(SVGA3DOPCOMP_LE); break; case PIPE_FUNC_GREATER: - setp_token.control = SVGA3DOPCOMP_GT; + setp_token = inst_token_setp(SVGA3DOPCOMP_GT); break; case PIPE_FUNC_NOTEQUAL: - setp_token.control = SVGA3DOPCOMPC_NE; + setp_token = inst_token_setp(SVGA3DOPCOMPC_NE); break; case PIPE_FUNC_GEQUAL: - setp_token.control = SVGA3DOPCOMP_GE; + setp_token = inst_token_setp(SVGA3DOPCOMP_GE); break; case PIPE_FUNC_ALWAYS: return submit_op1( emit, inst_token( SVGA3DOP_MOV ), @@ -2557,12 +2556,8 @@ emit_lit(struct svga_shader_emitter *emit, */ { SVGA3dShaderDestToken pred_reg = dst_register( SVGA3DREG_PREDICATE, 0 ); - SVGA3dShaderInstToken setp_token; struct src_register predsrc; - setp_token = inst_token( SVGA3DOP_SETP ); - setp_token.control = SVGA3DOPCOMP_GT; - /* D3D vs GL semantics: */ if (0) @@ -2571,7 +2566,9 @@ emit_lit(struct svga_shader_emitter *emit, predsrc = swizzle(src0, 0, 0, 0, 0); /* GL */ /* SETP src0.xxyy, GT, {0}.x */ - if (!submit_op2( emit, setp_token, pred_reg, + if (!submit_op2( emit, + inst_token_setp(SVGA3DOPCOMP_GT), + pred_reg, predsrc, get_zero_immediate(emit))) return FALSE; -- 2.30.2