void lp_setup_reset( struct lp_setup_context *setup )
{
+ unsigned i;
+
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
/* Reset derived state */
- setup->constants.stored_size = 0;
- setup->constants.stored_data = NULL;
+ for (i = 0; i < Elements(setup->constants); ++i) {
+ setup->constants[i].stored_size = 0;
+ setup->constants[i].stored_data = NULL;
+ }
setup->fs.stored = NULL;
setup->dirty = ~0;
static boolean
lp_setup_try_clear( struct lp_setup_context *setup,
- const float *color,
+ const union pipe_color_union *color,
double depth,
unsigned stencil,
unsigned flags )
if (flags & PIPE_CLEAR_COLOR) {
for (i = 0; i < 4; i++)
- color_arg.clear_color[i] = color[i];
+ color_arg.clear_color.i[i] = color->i[i];
}
if (flags & PIPE_CLEAR_DEPTHSTENCIL) {
}
if (flags & PIPE_CLEAR_COLOR) {
- memcpy(setup->clear.color.clear_color,
+ memcpy(&setup->clear.color.clear_color,
&color_arg,
sizeof setup->clear.color.clear_color);
}
void
lp_setup_clear( struct lp_setup_context *setup,
- const float *color,
+ const union pipe_color_union *color,
double depth,
unsigned stencil,
unsigned flags )
void
lp_setup_set_fs_constants(struct lp_setup_context *setup,
- struct pipe_resource *buffer)
+ unsigned num,
+ struct pipe_constant_buffer *buffers)
{
- LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, (void *) buffer);
+ unsigned i;
- pipe_resource_reference(&setup->constants.current, buffer);
+ LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, (void *) buffers);
+ assert(num <= Elements(setup->constants));
+
+ for (i = 0; i < num; ++i) {
+ util_copy_constant_buffer(&setup->constants[i].current, &buffers[i]);
+ }
+ for (; i < Elements(setup->constants); i++) {
+ util_copy_constant_buffer(&setup->constants[i].current, NULL);
+ }
setup->dirty |= LP_SETUP_NEW_CONSTANTS;
}
lp_setup_set_rasterizer_discard( struct lp_setup_context *setup,
boolean rasterizer_discard )
{
- setup->rasterizer_discard = rasterizer_discard;
- set_scene_state( setup, SETUP_FLUSHED, __FUNCTION__ );
+ if (setup->rasterizer_discard != rasterizer_discard) {
+ setup->rasterizer_discard = rasterizer_discard;
+ set_scene_state( setup, SETUP_FLUSHED, __FUNCTION__ );
+ }
}
void
LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
- assert(num <= PIPE_MAX_SAMPLERS);
+ assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) {
struct pipe_sampler_view *view = i < num ? views[i] : NULL;
if (view) {
const struct pipe_sampler_state *sampler = i < num ? samplers[i] : NULL;
if (sampler) {
- struct lp_jit_texture *jit_tex;
- jit_tex = &setup->fs.current.jit_context.textures[i];
+ struct lp_jit_sampler *jit_sam;
+ jit_sam = &setup->fs.current.jit_context.samplers[i];
- jit_tex->min_lod = sampler->min_lod;
- jit_tex->max_lod = sampler->max_lod;
- jit_tex->lod_bias = sampler->lod_bias;
- COPY_4V(jit_tex->border_color, sampler->border_color.f);
+ jit_sam->min_lod = sampler->min_lod;
+ jit_sam->max_lod = sampler->max_lod;
+ jit_sam->lod_bias = sampler->lod_bias;
+ COPY_4V(jit_sam->border_color, sampler->border_color.f);
}
}
{
boolean new_scene = (setup->fs.stored == NULL);
struct lp_scene *scene = setup->scene;
+ unsigned i;
assert(scene);
setup->dirty |= LP_SETUP_NEW_FS;
}
- if(setup->dirty & LP_SETUP_NEW_CONSTANTS) {
- struct pipe_resource *buffer = setup->constants.current;
+ if (setup->dirty & LP_SETUP_NEW_CONSTANTS) {
+ for (i = 0; i < Elements(setup->constants); ++i) {
+ struct pipe_resource *buffer = setup->constants[i].current.buffer;
+ const unsigned current_size = setup->constants[i].current.buffer_size;
+ const ubyte *current_data = NULL;
- if(buffer) {
- unsigned current_size = buffer->width0;
- const void *current_data = llvmpipe_resource_data(buffer);
+ if (buffer) {
+ /* resource buffer */
+ current_data = (ubyte *) llvmpipe_resource_data(buffer);
+ }
+ else if (setup->constants[i].current.user_buffer) {
+ /* user-space buffer */
+ current_data = (ubyte *) setup->constants[i].current.user_buffer;
+ }
- /* TODO: copy only the actually used constants? */
+ if (current_data) {
+ current_data += setup->constants[i].current.buffer_offset;
- if(setup->constants.stored_size != current_size ||
- !setup->constants.stored_data ||
- memcmp(setup->constants.stored_data,
- current_data,
- current_size) != 0) {
- void *stored;
+ /* TODO: copy only the actually used constants? */
- stored = lp_scene_alloc(scene, current_size);
- if (!stored) {
- assert(!new_scene);
- return FALSE;
- }
+ if (setup->constants[i].stored_size != current_size ||
+ !setup->constants[i].stored_data ||
+ memcmp(setup->constants[i].stored_data,
+ current_data,
+ current_size) != 0) {
+ void *stored;
- memcpy(stored,
- current_data,
- current_size);
- setup->constants.stored_size = current_size;
- setup->constants.stored_data = stored;
+ stored = lp_scene_alloc(scene, current_size);
+ if (!stored) {
+ assert(!new_scene);
+ return FALSE;
+ }
+
+ memcpy(stored,
+ current_data,
+ current_size);
+ setup->constants[i].stored_size = current_size;
+ setup->constants[i].stored_data = stored;
+ }
+ }
+ else {
+ setup->constants[i].stored_size = 0;
+ setup->constants[i].stored_data = NULL;
}
- }
- else {
- setup->constants.stored_size = 0;
- setup->constants.stored_data = NULL;
- }
- setup->fs.current.jit_context.constants = setup->constants.stored_data;
- setup->dirty |= LP_SETUP_NEW_FS;
+ setup->fs.current.jit_context.constants[i] = setup->constants[i].stored_data;
+ setup->dirty |= LP_SETUP_NEW_FS;
+ }
}
sizeof setup->fs.current) != 0)
{
struct lp_rast_state *stored;
- uint i;
/* The fs state that's been stored in the scene is different from
* the new, current state. So allocate a new lp_rast_state object
pipe_resource_reference(&setup->fs.current_tex[i], NULL);
}
- pipe_resource_reference(&setup->constants.current, NULL);
+ for (i = 0; i < Elements(setup->constants); i++) {
+ pipe_resource_reference(&setup->constants[i].current.buffer, NULL);
+ }
/* free the scenes in the 'empty' queue */
for (i = 0; i < Elements(setup->scenes); i++) {