From 6d8dbd3d1ec888300fb0e9ac3cf61808ba8ecc2b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 14:12:35 -0700 Subject: tgsi/ureg: VS inputs don't have any semantic tags, just an index Fix ureg_DECL_vs_input to reflect this and fix up all callers. --- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium/auxiliary/tgsi/tgsi_ureg.h') diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index acbca59040..3bc1b77503 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -116,8 +116,7 @@ ureg_DECL_fs_input( struct ureg_program *, struct ureg_src ureg_DECL_vs_input( struct ureg_program *, - unsigned semantic_name, - unsigned semantic_index ); + unsigned index ); struct ureg_dst ureg_DECL_output( struct ureg_program *, -- cgit v1.2.3 From ae4704eabc237e13c9b06df9c44f31c9baca6208 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 14:16:00 -0700 Subject: tgsi/ureg: give ureg_DECL_constant an explicit index parameter Avoid the need to emit all constant declarations in order. Makes referring to a specific constant in the constant buffer much easier. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 5 ++++- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 3 ++- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary/tgsi/tgsi_ureg.h') diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 55a4e5b2e9..9222af91fe 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -308,8 +308,11 @@ out: * value or manage any constant_buffer contents -- that's the * resposibility of the calling code. */ -struct ureg_src ureg_DECL_constant(struct ureg_program *ureg ) +struct ureg_src ureg_DECL_constant(struct ureg_program *ureg, + unsigned index ) { + + return ureg_src_register( TGSI_FILE_CONSTANT, ureg->nr_constants++ ); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 3bc1b77503..627a5b0c52 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -129,7 +129,8 @@ ureg_DECL_immediate( struct ureg_program *, unsigned nr ); struct ureg_src -ureg_DECL_constant( struct ureg_program * ); +ureg_DECL_constant( struct ureg_program *, + unsigned index ); struct ureg_dst ureg_DECL_temporary( struct ureg_program * ); diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 978dc209c0..b30cbff479 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -247,8 +247,8 @@ create_vs(struct pipe_context *pipe, if (ureg == NULL) return 0; - const0 = ureg_DECL_constant(ureg); - const1 = ureg_DECL_constant(ureg); + const0 = ureg_DECL_constant(ureg, 0); + const1 = ureg_DECL_constant(ureg, 1); /* it has to be either a fill or a composite op */ debug_assert(is_fill ^ is_composite); -- cgit v1.2.3 From c23894295b593b9a8561e9775199e1c78ea4435d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 14:18:00 -0700 Subject: ureg: add generic emitters for tex and branch instructions Couldn't previously emit these except by calling the opcode-specific helper. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 73 +++++++++++++++++++++++++++++----- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 18 +++++++++ 2 files changed, 80 insertions(+), 11 deletions(-) (limited to 'src/gallium/auxiliary/tgsi/tgsi_ureg.h') diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 9222af91fe..352cb5a1e3 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 627a5b0c52..48aeaaf459 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: */ -- cgit v1.2.3 From 11f41f54cf4ce1cdc19c4b5c45ed8d2083d96831 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 14:18:50 -0700 Subject: ureg: add a mechanism to get the built tokens rather than a full shader Previously ureg would always call the driver's create-shader function. This allows the caller the opportunity to hold onto the tokens if it needs to reuse them, eg. to create an internal draw shader. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 19 +++++++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_ureg.h | 11 +++++++++++ 2 files changed, 30 insertions(+) (limited to 'src/gallium/auxiliary/tgsi/tgsi_ureg.h') diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 352cb5a1e3..9e2e7f0d19 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -978,6 +978,25 @@ void *ureg_create_shader( struct ureg_program *ureg, } +const struct tgsi_token *ureg_get_tokens( struct ureg_program *ureg, + unsigned *nr_tokens ) +{ + const struct tgsi_token *tokens; + + ureg_finalize(ureg); + + tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token; + + if (nr_tokens) + *nr_tokens = ureg->domain[DOMAIN_DECL].size; + + ureg->domain[DOMAIN_DECL].tokens = 0; + ureg->domain[DOMAIN_DECL].size = 0; + ureg->domain[DOMAIN_DECL].order = 0; + ureg->domain[DOMAIN_DECL].count = 0; + + return tokens; +} struct ureg_program *ureg_create( unsigned processor ) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 48aeaaf459..f04f443b9e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -82,10 +82,21 @@ ureg_create( unsigned processor ); const struct tgsi_token * ureg_finalize( struct ureg_program * ); +/* Create and return a shader: + */ void * ureg_create_shader( struct ureg_program *, struct pipe_context *pipe ); + +/* Alternately, return the built token stream and hand ownership of + * that memory to the caller: + */ +const struct tgsi_token * +ureg_get_tokens( struct ureg_program *ureg, + unsigned *nr_tokens ); + + void ureg_destroy( struct ureg_program * ); -- cgit v1.2.3