summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-10-19 11:53:22 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-10-19 11:53:22 +0100
commitf2be08ae0e20b3da8ff684ffeb94412cc6a5a5a1 (patch)
tree275ad7551dc28362b430eacfac3a4c8ff82a4c09
parent269342d916fff3bf0fa0a5c1f26aec30b62ed352 (diff)
llvmpipe: Allocate the blend color from the data store, and ensure it's aligned.
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c34
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_context.h28
2 files changed, 50 insertions, 12 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 08dac459db..da5a68cd40 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -105,6 +105,7 @@ static void reset_context( struct setup_context *setup )
pipe_buffer_reference(&setup->constants.current, NULL);
setup->constants.stored_size = 0;
setup->constants.stored_data = NULL;
+ setup->dirty = ~0;
/* Free all but last binner command lists:
*/
@@ -453,20 +454,14 @@ void
lp_setup_set_blend_color( struct setup_context *setup,
const struct pipe_blend_color *blend_color )
{
- unsigned i, j;
-
SETUP_DEBUG("%s\n", __FUNCTION__);
- if(!setup->fs.current.jit_context.blend_color)
- setup->fs.current.jit_context.blend_color = align_malloc(4 * 16, 16);
+ assert(blend_color);
- for (i = 0; i < 4; ++i) {
- uint8_t c = float_to_ubyte(blend_color->color[i]);
- for (j = 0; j < 16; ++j)
- setup->fs.current.jit_context.blend_color[i*4 + j] = c;
+ if(memcmp(&setup->blend_color.current, blend_color, sizeof *blend_color) != 0) {
+ memcpy(&setup->blend_color.current, blend_color, sizeof *blend_color);
+ setup->dirty |= LP_SETUP_NEW_BLEND_COLOR;
}
-
- setup->dirty |= LP_SETUP_NEW_FS;
}
void
@@ -522,6 +517,25 @@ lp_setup_update_shader_state( struct setup_context *setup )
assert(setup->fs.current.jit_function);
+ if(setup->dirty & LP_SETUP_NEW_BLEND_COLOR) {
+ uint8_t *stored;
+ unsigned i, j;
+
+ stored = get_data_aligned(&setup->data, 4 * 16, 16);
+
+ for (i = 0; i < 4; ++i) {
+ uint8_t c = float_to_ubyte(setup->blend_color.current.color[i]);
+ for (j = 0; j < 16; ++j)
+ stored[i*4 + j] = c;
+ }
+
+ setup->blend_color.stored = stored;
+
+ setup->fs.current.jit_context.blend_color = setup->blend_color.stored;
+ setup->dirty |= LP_SETUP_NEW_FS;
+ }
+
+
if(setup->dirty & LP_SETUP_NEW_CONSTANTS) {
struct pipe_buffer *buffer = setup->constants.current;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
index 82ec71f100..bcd3b9b7aa 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
@@ -43,8 +43,9 @@
#define DATA_BLOCK_SIZE (16 * 1024 - sizeof(unsigned) - sizeof(void *))
-#define LP_SETUP_NEW_FS 0x01
-#define LP_SETUP_NEW_CONSTANTS 0x02
+#define LP_SETUP_NEW_FS 0x01
+#define LP_SETUP_NEW_CONSTANTS 0x02
+#define LP_SETUP_NEW_BLEND_COLOR 0x04
/* switch to a non-pointer value for this:
@@ -124,6 +125,11 @@ struct setup_context {
const void *stored_data;
} constants;
+ struct {
+ struct pipe_blend_color current;
+ uint8_t *stored;
+ } blend_color;
+
unsigned dirty;
void (*point)( struct setup_context *,
@@ -163,6 +169,24 @@ static INLINE void *get_data( struct data_block_list *list,
}
}
+static INLINE void *get_data_aligned( struct data_block_list *list,
+ unsigned size,
+ unsigned alignment )
+{
+
+ if (list->tail->used + size + alignment - 1 > DATA_BLOCK_SIZE) {
+ lp_setup_new_data_block( list );
+ }
+
+ {
+ struct data_block *tail = list->tail;
+ ubyte *data = tail->data + tail->used;
+ unsigned offset = (((uintptr_t)data + alignment - 1) & ~(alignment - 1)) - (uintptr_t)data;
+ tail->used += offset + size;
+ return data + offset;
+ }
+}
+
/* Add a command to a given bin.
*/
static INLINE void bin_command( struct cmd_block_list *list,