tgsi: defer allocation of huge inputs/outputs until we have a gs

This commit is contained in:
Zack Rusin
2011-03-01 22:50:42 -05:00
parent d569cc4d44
commit ff2a0faba0
2 changed files with 45 additions and 6 deletions
+41 -4
View File
@@ -672,6 +672,31 @@ tgsi_exec_machine_bind_shader(
mach->Processor = parse.FullHeader.Processor.Processor;
mach->ImmLimit = 0;
if (mach->Processor == TGSI_PROCESSOR_GEOMETRY &&
!mach->UsedGeometryShader) {
struct tgsi_exec_vector *inputs =
align_malloc(sizeof(struct tgsi_exec_vector) *
TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS,
16);
struct tgsi_exec_vector *outputs =
align_malloc(sizeof(struct tgsi_exec_vector) *
TGSI_MAX_TOTAL_VERTICES, 16);
if (!inputs)
return;
if (!outputs) {
align_free(inputs);
return;
}
align_free(mach->Inputs);
align_free(mach->Outputs);
mach->Inputs = inputs;
mach->Outputs = outputs;
mach->UsedGeometryShader = TRUE;
}
declarations = (struct tgsi_full_declaration *)
MALLOC( maxDeclarations * sizeof(struct tgsi_full_declaration) );
@@ -801,6 +826,11 @@ tgsi_exec_machine_create( void )
mach->MaxGeometryShaderOutputs = TGSI_MAX_TOTAL_VERTICES;
mach->Predicates = &mach->Temps[TGSI_EXEC_TEMP_P0];
mach->Inputs = align_malloc(sizeof(struct tgsi_exec_vector) * PIPE_MAX_ATTRIBS, 16);
mach->Outputs = align_malloc(sizeof(struct tgsi_exec_vector) * PIPE_MAX_ATTRIBS, 16);
if (!mach->Inputs || !mach->Outputs)
goto fail;
/* Setup constants needed by the SSE2 executor. */
for( i = 0; i < 4; i++ ) {
mach->Temps[TGSI_EXEC_TEMP_00000000_I].xyzw[TGSI_EXEC_TEMP_00000000_C].u[i] = 0x00000000;
@@ -824,7 +854,11 @@ tgsi_exec_machine_create( void )
return mach;
fail:
align_free(mach);
if (mach) {
align_free(mach->Inputs);
align_free(mach->Outputs);
align_free(mach);
}
return NULL;
}
@@ -836,10 +870,13 @@ tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach)
if (mach->Instructions)
FREE(mach->Instructions);
if (mach->Declarations)
FREE(mach->Declarations);
}
FREE(mach->Declarations);
align_free(mach);
align_free(mach->Inputs);
align_free(mach->Outputs);
align_free(mach);
}
}
static void
+4 -2
View File
@@ -228,8 +228,8 @@ struct tgsi_exec_machine
float ImmArray[TGSI_EXEC_NUM_IMMEDIATES][4];
struct tgsi_exec_vector Inputs[TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS];
struct tgsi_exec_vector Outputs[TGSI_MAX_TOTAL_VERTICES];
struct tgsi_exec_vector *Inputs;
struct tgsi_exec_vector *Outputs;
/* System values */
unsigned SysSemanticToIndex[TGSI_SEMANTIC_COUNT];
@@ -309,6 +309,8 @@ struct tgsi_exec_machine
uint NumDeclarations;
struct tgsi_declaration_resource Resources[PIPE_MAX_SHADER_RESOURCES];
boolean UsedGeometryShader;
};
struct tgsi_exec_machine *