Mesa (master): tnl: Delay results allocation until we actually need them.
Eric Anholt
anholt at kemper.freedesktop.org
Sun Oct 2 06:31:46 UTC 2011
Module: Mesa
Branch: master
Commit: f7f678331d5e95d2266fe6b3ea1cfa47d6421065
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7f678331d5e95d2266fe6b3ea1cfa47d6421065
Author: Eric Anholt <eric at anholt.net>
Date: Thu Sep 22 11:28:19 2011 -0700
tnl: Delay results allocation until we actually need them.
Decreases i965 peak memory allocation for a trivial shader program
from 23,483,048B to 21,932,128B, since we never actually use tnl for
rendering.
---
src/mesa/tnl/t_vb_program.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 3e0c80d..cc5e856 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -336,6 +336,11 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
for (i = 0; i < VERT_RESULT_MAX; i++) {
if (program->Base.OutputsWritten & BITFIELD64_BIT(i)) {
outputs[numOutputs++] = i;
+
+ if (!store->results[i].data) {
+ _mesa_vector4f_alloc( &store->results[i], 0, VB->Size, 32 );
+ store->results[i].size = 4;
+ }
}
}
@@ -504,19 +509,12 @@ init_vp(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
struct vertex_buffer *VB = &(tnl->vb);
struct vp_stage_data *store;
const GLuint size = VB->Size;
- GLuint i;
stage->privatePtr = CALLOC(sizeof(*store));
store = VP_STAGE_DATA(stage);
if (!store)
return GL_FALSE;
- /* Allocate arrays of vertex output values */
- for (i = 0; i < VERT_RESULT_MAX; i++) {
- _mesa_vector4f_alloc( &store->results[i], 0, size, 32 );
- store->results[i].size = 4;
- }
-
/* a few other misc allocations */
_mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
store->clipmask = (GLubyte *) _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
More information about the mesa-commit
mailing list