diff options
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ureg.c | 57 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ureg.h | 25 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_simple_shaders.c | 12 |
3 files changed, 72 insertions, 22 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 7922931361..c0a0627e0b 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -340,8 +340,9 @@ out: void ureg_release_temporary( struct ureg_program *ureg, struct ureg_dst tmp ) { - if (tmp.Index < UREG_MAX_TEMP) - ureg->temps_active[tmp.Index/32] &= ~(1 << (tmp.Index % 32)); + if(tmp.File == TGSI_FILE_TEMPORARY) + if (tmp.Index < UREG_MAX_TEMP) + ureg->temps_active[tmp.Index/32] &= ~(1 << (tmp.Index % 32)); } @@ -605,6 +606,29 @@ ureg_fixup_insn_size(struct ureg_program *ureg, } +void +ureg_insn(struct ureg_program *ureg, + unsigned opcode, + const struct ureg_dst *dst, + unsigned nr_dst, + 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 ); + + 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 ); +} @@ -765,9 +789,9 @@ emit_header( struct ureg_program *ureg ) } -void *ureg_create_shader( struct ureg_program *ureg ) +const struct tgsi_token *ureg_finalize( struct ureg_program *ureg ) { - struct pipe_shader_state state; + const struct tgsi_token *tokens; emit_header( ureg ); emit_decls( ureg ); @@ -781,31 +805,42 @@ void *ureg_create_shader( struct ureg_program *ureg ) return NULL; } - state.tokens = (const struct tgsi_token *)ureg->domain[DOMAIN_DECL].tokens; + tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token; if (0) { debug_printf("%s: emitted shader %d tokens:\n", __FUNCTION__, ureg->domain[DOMAIN_DECL].count); - tgsi_dump( state.tokens, 0 ); + tgsi_dump( tokens, 0 ); } + + return tokens; +} + + +void *ureg_create_shader( struct ureg_program *ureg, + struct pipe_context *pipe ) +{ + struct pipe_shader_state state; + + state.tokens = ureg_finalize(ureg); + if(!state.tokens) + return NULL; if (ureg->processor == TGSI_PROCESSOR_VERTEX) - return ureg->pipe->create_vs_state( ureg->pipe, &state ); + return pipe->create_vs_state( pipe, &state ); else - return ureg->pipe->create_fs_state( ureg->pipe, &state ); + return pipe->create_fs_state( pipe, &state ); } -struct ureg_program *ureg_create( struct pipe_context *pipe, - unsigned processor ) +struct ureg_program *ureg_create( unsigned processor ) { struct ureg_program *ureg = CALLOC_STRUCT( ureg_program ); if (ureg == NULL) return NULL; - ureg->pipe = pipe; ureg->processor = processor; return ureg; } diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 5a48bb7a35..8836a1ea0e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -69,11 +69,14 @@ struct ureg_dst struct pipe_context; struct ureg_program * -ureg_create( struct pipe_context *pipe, - unsigned processor ); +ureg_create( unsigned processor ); + +const struct tgsi_token * +ureg_finalize( struct ureg_program * ); void * -ureg_create_shader( struct ureg_program * ); +ureg_create_shader( struct ureg_program *, + struct pipe_context *pipe ); void ureg_destroy( struct ureg_program * ); @@ -82,9 +85,11 @@ ureg_destroy( struct ureg_program * ); /*********************************************************************** * Convenience routine: */ -static INLINE void *ureg_create_shader_and_destroy( struct ureg_program *p ) +static INLINE void * +ureg_create_shader_and_destroy( struct ureg_program *p, + struct pipe_context *pipe ) { - void *result = ureg_create_shader( p ); + void *result = ureg_create_shader( p, pipe ); ureg_destroy( p ); return result; } @@ -199,6 +204,16 @@ ureg_fixup_label(struct ureg_program *ureg, unsigned instruction_number ); +/* Generic instruction emitter. Use if you need to pass the opcode as + * a parameter, rather than using the emit_OP() varients below. + */ +void +ureg_insn(struct ureg_program *ureg, + unsigned opcode, + const struct ureg_dst *dst, + unsigned nr_dst, + const struct ureg_src *src, + unsigned nr_src ); /*********************************************************************** diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 1152d62e73..d54a1d8c74 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -59,7 +59,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, struct ureg_program *ureg; uint i; - ureg = ureg_create( pipe, TGSI_PROCESSOR_VERTEX ); + ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); if (ureg == NULL) return NULL; @@ -80,7 +80,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, ureg_END( ureg ); - return ureg_create_shader_and_destroy( ureg ); + return ureg_create_shader_and_destroy( ureg, pipe ); } @@ -99,7 +99,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe) struct ureg_src tex; struct ureg_dst out; - ureg = ureg_create( pipe, TGSI_PROCESSOR_FRAGMENT ); + ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); if (ureg == NULL) return NULL; @@ -116,7 +116,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe) ureg_TEX( ureg, out, TGSI_TEXTURE_2D, tex, sampler ); ureg_END( ureg ); - return ureg_create_shader_and_destroy( ureg ); + return ureg_create_shader_and_destroy( ureg, pipe ); } @@ -133,7 +133,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe) struct ureg_src src; struct ureg_dst dst; - ureg = ureg_create( pipe, TGSI_PROCESSOR_FRAGMENT ); + ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); if (ureg == NULL) return NULL; @@ -145,7 +145,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe) ureg_MOV( ureg, dst, src ); ureg_END( ureg ); - return ureg_create_shader_and_destroy( ureg ); + return ureg_create_shader_and_destroy( ureg, pipe ); } |