tgsi: fix regression in indexed const lookups
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_exec.c
index 5cb322a5fa296fe2fe60f595b8c288989d7d193a..fe571a86bcad95c2bf7fea9f5b5c3764c9243046 100644 (file)
@@ -365,15 +365,26 @@ 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->Tokens = NULL;
+   mach->Primitives = NULL;
+   mach->InterpCoefs = NULL;
+   mach->Instructions = NULL;
+   mach->Declarations = NULL;
+
    /* Setup constants. */
    for( i = 0; i < 4; i++ ) {
       mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].u[i] = 0x00000000;
@@ -393,22 +404,24 @@ tgsi_exec_machine_init(
    (void) print_chan;
    (void) print_temp;
 #endif
+
+   return mach;
+
+fail:
+   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) {
+   if (mach) {
       FREE(mach->Instructions);
-      mach->Instructions = NULL;
-      mach->NumInstructions = 0;
-   }
-   if (mach->Declarations) {
       FREE(mach->Declarations);
-      mach->Declarations = NULL;
-      mach->NumDeclarations = 0;
    }
+
+   align_free(mach);
 }