summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorZack Rusin <zack@kde.org>2011-03-01 22:50:42 -0500
committerZack Rusin <zack@kde.org>2011-03-02 17:45:22 -0500
commitff2a0faba068ac8bc891f4a6427ad3e241c5f09f (patch)
tree005cf3cfd201a2f84ac6231890ad0063f4ac2364 /src/gallium
parentd569cc4d4469ff921d544b0a931a229e5c6e2846 (diff)
tgsi: defer allocation of huge inputs/outputs until we have a gs
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c45
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h6
2 files changed, 45 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index cbb090b280..6576c74fbd 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -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->Inputs);
+ align_free(mach->Outputs);
- align_free(mach);
+ align_free(mach);
+ }
}
static void
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index 4a423b5bb4..33f33aa82c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -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 *