void *blend)
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
+
+ if (i915->blend == blend)
+ return;
i915->blend = (struct i915_blend_state*)blend;
const struct pipe_blend_color *blend_color )
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
+
+ if (!blend_color)
+ return;
i915->blend_color = *blend_color;
const struct pipe_stencil_ref *stencil_ref )
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
i915->stencil_ref = *stencil_ref;
unsigned minFilt, magFilt;
unsigned mipFilt;
- cso->templ = sampler;
+ cso->templ = *sampler;
mipFilt = translate_mip_filter(sampler->min_mip_filter);
minFilt = translate_img_filter( sampler->min_img_filter );
magFilt = translate_img_filter( sampler->mag_img_filter );
-
+
if (sampler->max_anisotropy > 1)
minFilt = magFilt = FILTER_ANISOTROPIC;
/* Shadow:
*/
- if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE)
+ if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE)
{
cso->state[0] |= (SS2_SHADOW_ENABLE |
i915_translate_shadow_compare_func(sampler->compare_func));
}
{
- ubyte r = float_to_ubyte(sampler->border_color[0]);
- ubyte g = float_to_ubyte(sampler->border_color[1]);
- ubyte b = float_to_ubyte(sampler->border_color[2]);
- ubyte a = float_to_ubyte(sampler->border_color[3]);
+ ubyte r = float_to_ubyte(sampler->border_color.f[0]);
+ ubyte g = float_to_ubyte(sampler->border_color.f[1]);
+ ubyte b = float_to_ubyte(sampler->border_color.f[2]);
+ ubyte a = float_to_ubyte(sampler->border_color.f[3]);
cso->state[2] = I915PACKCOLOR8888(r, g, b, a);
}
return cso;
i915->saved_bind_sampler_states(pipe, num, sampler);
}
-static void i915_bind_sampler_states(struct pipe_context *pipe,
+static void
+i915_bind_vertex_sampler_states(struct pipe_context *pipe,
+ unsigned num_samplers,
+ void **samplers)
+{
+ struct i915_context *i915 = i915_context(pipe);
+ unsigned i;
+
+ assert(num_samplers <= PIPE_MAX_VERTEX_SAMPLERS);
+
+ /* Check for no-op */
+ if (num_samplers == i915->num_vertex_samplers &&
+ !memcmp(i915->vertex_samplers, samplers, num_samplers * sizeof(void *)))
+ return;
+
+ for (i = 0; i < num_samplers; ++i)
+ i915->vertex_samplers[i] = samplers[i];
+ for (i = num_samplers; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
+ i915->vertex_samplers[i] = NULL;
+
+ i915->num_vertex_samplers = num_samplers;
+
+ draw_set_samplers(i915->draw,
+ i915->vertex_samplers,
+ i915->num_vertex_samplers);
+}
+
+
+
+static void i915_bind_fragment_sampler_states(struct pipe_context *pipe,
unsigned num, void **sampler)
{
struct i915_context *i915 = i915_context(pipe);
!memcmp(i915->sampler, sampler, num * sizeof(void *)))
return;
- draw_flush(i915->draw);
-
for (i = 0; i < num; ++i)
i915->sampler[i] = sampler[i];
for (i = num; i < PIPE_MAX_SAMPLERS; ++i)
}
+/**
+ * Called before drawing VBO to map vertex samplers and hand them to draw
+ */
+void
+i915_prepare_vertex_sampling(struct i915_context *i915)
+{
+ struct i915_winsys *iws = i915->iws;
+ unsigned i,j;
+ uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS];
+ uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
+ const void* data[PIPE_MAX_TEXTURE_LEVELS];
+ unsigned num = i915->num_vertex_sampler_views;
+ struct pipe_sampler_view **views = i915->vertex_sampler_views;
+
+ assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+ if (!num)
+ return;
+
+ for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+ struct pipe_sampler_view *view = i < num ? views[i] : NULL;
+
+ if (view) {
+ struct pipe_resource *tex = view->texture;
+ struct i915_texture *i915_tex = i915_texture(tex);
+ ubyte *addr;
+
+ /* We're referencing the texture's internal data, so save a
+ * reference to it.
+ */
+ pipe_resource_reference(&i915->mapped_vs_tex[i], tex);
+
+ i915->mapped_vs_tex_buffer[i] = i915_tex->buffer;
+ addr = iws->buffer_map(iws,
+ i915_tex->buffer,
+ FALSE /* read only */);
+
+ /* Setup array of mipmap level pointers */
+ /* FIXME: handle 3D textures? */
+ for (j = view->u.tex.first_level; j <= tex->last_level; j++) {
+ unsigned offset = i915_texture_offset(i915_tex, j , 0 /* FIXME depth */);
+ data[j] = addr + offset;
+ row_stride[j] = i915_tex->stride;
+ img_stride[j] = 0; /* FIXME */;
+ }
+
+ draw_set_mapped_texture(i915->draw,
+ i,
+ tex->width0, tex->height0, tex->depth0,
+ view->u.tex.first_level, tex->last_level,
+ row_stride, img_stride, data);
+ } else
+ i915->mapped_vs_tex[i] = NULL;
+ }
+}
+
+void
+i915_cleanup_vertex_sampling(struct i915_context *i915)
+{
+ struct i915_winsys *iws = i915->iws;
+ unsigned i;
+ for (i = 0; i < Elements(i915->mapped_vs_tex); i++) {
+ if (i915->mapped_vs_tex_buffer[i]) {
+ iws->buffer_unmap(iws, i915->mapped_vs_tex_buffer[i]);
+ pipe_resource_reference(&i915->mapped_vs_tex[i], NULL);
+ }
+ }
+}
+
+
+
/** XXX move someday? Or consolidate all these simple state setters
* into one file.
*/
void *depth_stencil)
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
+
+ if (i915->depth_stencil == depth_stencil)
+ return;
i915->depth_stencil = (const struct i915_depth_stencil_state *)depth_stencil;
const struct pipe_scissor_state *scissor )
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
memcpy( &i915->scissor, scissor, sizeof(*scissor) );
i915->dirty |= I915_NEW_SCISSOR;
static void i915_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
+ const struct pipe_poly_stipple *stipple )
{
}
i915_fixup_bind_fs_state(struct pipe_context *pipe, void *shader)
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
+
+ if (i915->saved_fs == shader)
+ return;
i915->saved_fs = shader;
i915_bind_fs_state(struct pipe_context *pipe, void *shader)
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
+
+ if (i915->fs == shader)
+ return;
i915->fs = (struct i915_fragment_shader*) shader;
{
struct i915_fragment_shader *ifs = (struct i915_fragment_shader *) shader;
+ if (ifs->decl) {
+ FREE(ifs->decl);
+ ifs->decl = NULL;
+ }
+
if (ifs->program) {
FREE(ifs->program);
ifs->program = NULL;
ifs->state.tokens = NULL;
}
ifs->program_len = 0;
+ ifs->decl_len = 0;
FREE(ifs);
}
{
struct i915_context *i915 = i915_context(pipe);
+ if (i915->saved_vs == shader)
+ return;
+
i915->saved_vs = shader;
/* just pass-through to draw module */
diff = i915->current.num_user_constants[shader] != 0;
}
- /*
- * flush before updateing the state.
- */
- if (diff && shader == PIPE_SHADER_FRAGMENT)
- draw_flush(i915->draw);
-
pipe_resource_reference(&i915->constants[shader], buf);
i915->current.num_user_constants[shader] = new_num;
!memcmp(i915->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
return;
- /* Fixes wrong texture in texobj with VBUF */
- draw_flush(i915->draw);
-
for (i = 0; i < num; i++)
pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
views[i]);
i915->dirty |= I915_NEW_SAMPLER_VIEW;
}
+static void
+i915_set_vertex_sampler_views(struct pipe_context *pipe,
+ unsigned num,
+ struct pipe_sampler_view **views)
+{
+ struct i915_context *i915 = i915_context(pipe);
+ uint i;
+
+ assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+
+ /* Check for no-op */
+ if (num == i915->num_vertex_sampler_views &&
+ !memcmp(i915->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
+ return;
+ }
+
+ for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+ struct pipe_sampler_view *view = i < num ? views[i] : NULL;
+
+ pipe_sampler_view_reference(&i915->vertex_sampler_views[i], view);
+ }
+
+ i915->num_vertex_sampler_views = num;
+
+ draw_set_sampler_views(i915->draw,
+ i915->vertex_sampler_views,
+ i915->num_vertex_sampler_views);
+}
+
static struct pipe_sampler_view *
i915_create_sampler_view(struct pipe_context *pipe,
struct i915_context *i915 = i915_context(pipe);
int i;
- draw_flush(i915->draw);
-
i915->framebuffer.width = fb->width;
i915->framebuffer.height = fb->height;
i915->framebuffer.nr_cbufs = fb->nr_cbufs;
const struct pipe_clip_state *clip )
{
struct i915_context *i915 = i915_context(pipe);
- draw_flush(i915->draw);
i915->saved_clip = *clip;
{
struct i915_context *i915 = i915_context(pipe);
+ if (i915->rasterizer == raster)
+ return;
+
i915->rasterizer = (struct i915_rasterizer_state *)raster;
/* pass-through to draw module */
struct i915_context *i915 = i915_context(pipe);
struct i915_velems_state *i915_velems = (struct i915_velems_state *) velems;
+ if (i915->saved_velems == velems)
+ return;
+
i915->saved_velems = velems;
/* pass-through to draw module */
i915->base.delete_blend_state = i915_delete_blend_state;
i915->base.create_sampler_state = i915_create_sampler_state;
- i915->base.bind_fragment_sampler_states = i915_bind_sampler_states;
+ i915->base.bind_fragment_sampler_states = i915_bind_fragment_sampler_states;
+ i915->base.bind_vertex_sampler_states = i915_bind_vertex_sampler_states;
i915->base.delete_sampler_state = i915_delete_sampler_state;
i915->base.create_depth_stencil_alpha_state = i915_create_depth_stencil_state;
i915->base.set_polygon_stipple = i915_set_polygon_stipple;
i915->base.set_scissor_state = i915_set_scissor_state;
i915->base.set_fragment_sampler_views = i915_set_fragment_sampler_views;
+ i915->base.set_vertex_sampler_views = i915_set_vertex_sampler_views;
i915->base.create_sampler_view = i915_create_sampler_view;
i915->base.sampler_view_destroy = i915_sampler_view_destroy;
i915->base.set_viewport_state = i915_set_viewport_state;