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:
*/
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
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;
#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:
const void *stored_data;
} constants;
+ struct {
+ struct pipe_blend_color current;
+ uint8_t *stored;
+ } blend_color;
+
unsigned dirty;
void (*point)( struct setup_context *,
}
}
+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,