From: Keith Whitwell Date: Sat, 12 Sep 2009 21:18:00 +0000 (-0700) Subject: ureg: add generic emitters for tex and branch instructions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c23894295b593b9a8561e9775199e1c78ea4435d;p=mesa.git ureg: add generic emitters for tex and branch instructions Couldn't previously emit these except by calling the opcode-specific helper. --- diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 9222af91fe1..352cb5a1e32 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -564,6 +564,19 @@ ureg_emit_dst( struct ureg_program *ureg, } +static void validate( unsigned opcode, + unsigned nr_dst, + unsigned nr_src ) +{ +#ifdef DEBUG + const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode ); + assert(info); + if(info) { + assert(nr_dst == info->num_dst); + assert(nr_src == info->num_src); + } +#endif +} unsigned ureg_emit_insn(struct ureg_program *ureg, @@ -574,6 +587,8 @@ ureg_emit_insn(struct ureg_program *ureg, { union tgsi_any_token *out; + validate( opcode, num_dst, num_src ); + out = get_tokens( ureg, DOMAIN_INSN, 1 ); out[0].value = 0; out[0].insn.Type = TGSI_TOKEN_TYPE_INSTRUCTION; @@ -676,17 +691,6 @@ ureg_insn(struct ureg_program *ureg, unsigned insn, i; boolean saturate; -#ifdef DEBUG - { - const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode ); - assert(info); - if(info) { - assert(nr_dst == info->num_dst); - assert(nr_src == info->num_src); - } - } -#endif - saturate = nr_dst ? dst[0].Saturate : FALSE; insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src ); @@ -700,6 +704,53 @@ ureg_insn(struct ureg_program *ureg, ureg_fixup_insn_size( ureg, insn ); } +void +ureg_tex_insn(struct ureg_program *ureg, + unsigned opcode, + const struct ureg_dst *dst, + unsigned nr_dst, + unsigned target, + const struct ureg_src *src, + unsigned nr_src ) +{ + unsigned insn, i; + boolean saturate; + + saturate = nr_dst ? dst[0].Saturate : FALSE; + + insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src ); + + ureg_emit_texture( ureg, insn, target ); \ + + for (i = 0; i < nr_dst; i++) + ureg_emit_dst( ureg, dst[i] ); + + for (i = 0; i < nr_src; i++) + ureg_emit_src( ureg, src[i] ); + + ureg_fixup_insn_size( ureg, insn ); +} + + +void +ureg_label_insn(struct ureg_program *ureg, + unsigned opcode, + const struct ureg_src *src, + unsigned nr_src, + unsigned *label_token ) +{ + unsigned insn, i; + + insn = ureg_emit_insn( ureg, opcode, FALSE, 0, nr_src ); + + ureg_emit_label( ureg, insn, label_token ); \ + + for (i = 0; i < nr_src; i++) + ureg_emit_src( ureg, src[i] ); + + ureg_fixup_insn_size( ureg, insn ); +} + static void emit_decl( struct ureg_program *ureg, diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 627a5b0c523..48aeaaf459d 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -233,6 +233,24 @@ ureg_insn(struct ureg_program *ureg, unsigned nr_src ); +void +ureg_tex_insn(struct ureg_program *ureg, + unsigned opcode, + const struct ureg_dst *dst, + unsigned nr_dst, + unsigned target, + const struct ureg_src *src, + unsigned nr_src ); + + +void +ureg_label_insn(struct ureg_program *ureg, + unsigned opcode, + const struct ureg_src *src, + unsigned nr_src, + unsigned *label); + + /*********************************************************************** * Internal instruction helpers, don't call these directly: */