diff options
author | Keith Whitwell <[email protected]> | 2009-07-15 23:44:53 +0100 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2009-07-16 09:53:07 +0100 |
commit | 6175653d0bceedba1f599d27111bab14f312f134 (patch) | |
tree | adf7ba396a1621549b4842d047709129dc87646a /src/gallium/auxiliary/tgsi | |
parent | 3a3b83e5112b725e22f05b32a273a2351b820944 (diff) |
gallium: proper constructor and destructor for tgsi_exec_machine
Centralize the creation, initialization and destruction of this struct.
Use align_malloc instead of home-brew alternatives.
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_exec.c | 45 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_exec.h | 22 |
2 files changed, 48 insertions, 19 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 5cb322a5fa2..d9ebd955c82 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -365,15 +365,38 @@ tgsi_exec_machine_bind_shader( } -void -tgsi_exec_machine_init( - struct tgsi_exec_machine *mach ) +struct tgsi_exec_machine * +tgsi_exec_machine_create( void ) { + struct tgsi_exec_machine *mach; uint i; - mach->Temps = (struct tgsi_exec_vector *) tgsi_align_128bit( mach->_Temps); + mach = align_malloc( sizeof *mach, 16 ); + if (!mach) + goto fail; + mach->Addrs = &mach->Temps[TGSI_EXEC_TEMP_ADDR]; + mach->Samplers = NULL; + mach->Consts = NULL; + mach->Inputs = NULL; + mach->Outputs = NULL; + mach->Tokens = NULL; + mach->Primitives = NULL; + mach->InterpCoefs = NULL; + mach->Instructions = NULL; + mach->Declarations = NULL; + + mach->Inputs = align_malloc(PIPE_MAX_ATTRIBS * + sizeof(struct tgsi_exec_vector), 16); + if (!mach->Inputs) + goto fail; + + mach->Outputs = align_malloc(PIPE_MAX_ATTRIBS * + sizeof(struct tgsi_exec_vector), 16); + if (!mach->Outputs) + goto fail; + /* Setup constants. */ for( i = 0; i < 4; i++ ) { mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].u[i] = 0x00000000; @@ -393,11 +416,22 @@ tgsi_exec_machine_init( (void) print_chan; (void) print_temp; #endif + + return mach; + +fail: + if (mach) { + align_free(mach->Inputs); + align_free(mach->Outputs); + align_free(mach); + } + + return NULL; } void -tgsi_exec_machine_free_data(struct tgsi_exec_machine *mach) +tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach) { if (mach->Instructions) { FREE(mach->Instructions); @@ -409,6 +443,7 @@ tgsi_exec_machine_free_data(struct tgsi_exec_machine *mach) mach->Declarations = NULL; mach->NumDeclarations = 0; } + align_free(mach); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index da22baad3ef..f1866b7658c 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -187,20 +187,16 @@ struct tgsi_exec_labels struct tgsi_exec_machine { /* Total = program temporaries + internal temporaries - * + 1 padding to align to 16 bytes */ - struct tgsi_exec_vector _Temps[TGSI_EXEC_NUM_TEMPS + - TGSI_EXEC_NUM_TEMP_EXTRAS + 1]; + struct tgsi_exec_vector Temps[TGSI_EXEC_NUM_TEMPS + + TGSI_EXEC_NUM_TEMP_EXTRAS]; + + float Imms[TGSI_EXEC_NUM_IMMEDIATES][4]; - /* - * This will point to _Temps after aligning to 16B boundary. - */ - struct tgsi_exec_vector *Temps; struct tgsi_exec_vector *Addrs; struct tgsi_sampler **Samplers; - float Imms[TGSI_EXEC_NUM_IMMEDIATES][4]; unsigned ImmLimit; const float (*Consts)[4]; struct tgsi_exec_vector *Inputs; @@ -251,9 +247,11 @@ struct tgsi_exec_machine struct tgsi_exec_labels Labels; }; +struct tgsi_exec_machine * +tgsi_exec_machine_create( void ); + void -tgsi_exec_machine_init( - struct tgsi_exec_machine *mach ); +tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach); void @@ -268,10 +266,6 @@ tgsi_exec_machine_run( struct tgsi_exec_machine *mach ); -void -tgsi_exec_machine_free_data(struct tgsi_exec_machine *mach); - - static INLINE void tgsi_set_kill_mask(struct tgsi_exec_machine *mach, unsigned mask) { |