summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-05-29 12:38:49 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2008-05-29 12:38:49 +0100
commitbb2e13b9e82b68ec3b9fc56a4c35e7ead8fd138f (patch)
tree65f387b426dcd113f602d9a51ef6fc8d1652200f /src/gallium/auxiliary/draw
parent82605d7bcd533d7c96cc619c45970efd7229dc3b (diff)
draw: make sure constant buffer data is aligned before passing to aos.c
Diffstat (limited to 'src/gallium/auxiliary/draw')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h3
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h9
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c19
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos.c4
5 files changed, 33 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index bcec85c2ef..2f263cf06a 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -217,10 +217,11 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw,
void
draw_set_mapped_constant_buffer(struct draw_context *draw,
- const void *buffer)
+ const void *buffer,
+ unsigned size )
{
draw->pt.user.constants = buffer;
- draw_vs_set_constants( draw, (const float (*)[4])buffer );
+ draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
}
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index 8dd03cb79e..b8f2bfa332 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -133,7 +133,8 @@ void draw_set_mapped_vertex_buffer(struct draw_context *draw,
unsigned attr, const void *buffer);
void draw_set_mapped_constant_buffer(struct draw_context *draw,
- const void *buffer);
+ const void *buffer,
+ unsigned size );
void draw_set_edgeflags( struct draw_context *draw,
const unsigned *edgeflag );
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 40f1d978f2..88a7224b62 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -190,6 +190,12 @@ struct draw_context
struct aos_machine *aos_machine;
+ const float (*aligned_constants)[4];
+
+ const float (*aligned_constant_storage)[4];
+ unsigned const_storage_size;
+
+
struct translate *fetch;
struct translate_cache *fetch_cache;
struct translate *emit;
@@ -225,7 +231,8 @@ void draw_vs_set_viewport( struct draw_context *,
const struct pipe_viewport_state * );
void draw_vs_set_constants( struct draw_context *,
- const float (*constants)[4] );
+ const float (*constants)[4],
+ unsigned size );
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index a8b6d0c90d..ce35112fc1 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -43,8 +43,22 @@
void draw_vs_set_constants( struct draw_context *draw,
- const float (*constants)[4] )
+ const float (*constants)[4],
+ unsigned size )
{
+ if (((unsigned)constants) & 0xf) {
+ if (size > draw->vs.const_storage_size) {
+ if (draw->vs.aligned_constant_storage)
+ align_free(draw->vs.aligned_constant_storage);
+ draw->vs.aligned_constant_storage = align_malloc( size, 16 );
+ }
+ memcpy( draw->vs.aligned_constant_storage,
+ constants,
+ size );
+ constants = draw->vs.aligned_constant_storage;
+ }
+
+ draw->vs.aligned_constants = constants;
draw_vs_aos_machine_constants( draw->vs.aos_machine, constants );
}
@@ -159,6 +173,9 @@ draw_vs_destroy( struct draw_context *draw )
if (draw->vs.aos_machine)
draw_vs_aos_machine_destroy(draw->vs.aos_machine);
+ if (draw->vs.aligned_constant_storage)
+ align_free(draw->vs.aligned_constant_storage);
+
tgsi_exec_machine_free_data(&draw->vs.machine);
}
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c
index b5e4e1e7b1..55cabb6df9 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.c
@@ -1957,7 +1957,7 @@ static void PIPE_CDECL vaos_run_elts( struct draw_vs_varient *varient,
struct aos_machine *machine = vaos->draw->vs.aos_machine;
machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
- machine->constants = (const float (*)[4])vaos->draw->pt.user.constants;
+ machine->constants = vaos->draw->vs.aligned_constants;
machine->immediates = vaos->base.vs->immediates;
machine->attrib = vaos->attrib;
@@ -1976,7 +1976,7 @@ static void PIPE_CDECL vaos_run_linear( struct draw_vs_varient *varient,
struct aos_machine *machine = vaos->draw->vs.aos_machine;
machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
- machine->constants = (const float (*)[4])vaos->draw->pt.user.constants;
+ machine->constants = vaos->draw->vs.aligned_constants;
machine->immediates = vaos->base.vs->immediates;
machine->attrib = vaos->attrib;