struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct i915_texture *texture[PIPE_MAX_SAMPLERS];
+ struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
unsigned dirty;
unsigned num_samplers;
- unsigned num_textures;
+ unsigned num_fragment_sampler_views;
unsigned num_vertex_elements;
unsigned num_vertex_buffers;
#define I915_NEW_ALPHA_TEST 0x100
#define I915_NEW_DEPTH_STENCIL 0x200
#define I915_NEW_SAMPLER 0x400
-#define I915_NEW_TEXTURE 0x800
+#define I915_NEW_SAMPLER_VIEW 0x800
#define I915_NEW_CONSTANTS 0x1000
#define I915_NEW_VBO 0x2000
#define I915_NEW_VS 0x4000
}
-static void i915_set_sampler_textures(struct pipe_context *pipe,
- unsigned num,
- struct pipe_texture **texture)
+static void i915_set_fragment_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_SAMPLERS);
/* Check for no-op */
- if (num == i915->num_textures &&
- !memcmp(i915->texture, texture, num * sizeof(struct pipe_texture *)))
+ if (num == i915->num_fragment_sampler_views &&
+ !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_texture_reference((struct pipe_texture **) &i915->texture[i],
- texture[i]);
+ pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
+ views[i]);
- for (i = num; i < i915->num_textures; i++)
- pipe_texture_reference((struct pipe_texture **) &i915->texture[i],
- NULL);
+ for (i = num; i < i915->num_fragment_sampler_views; i++)
+ pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
+ NULL);
- i915->num_textures = num;
+ i915->num_fragment_sampler_views = num;
- i915->dirty |= I915_NEW_TEXTURE;
+ i915->dirty |= I915_NEW_SAMPLER_VIEW;
}
+static struct pipe_sampler_view *
+i915_create_sampler_view(struct pipe_context *pipe,
+ struct pipe_texture *texture,
+ const struct pipe_sampler_view *templ)
+{
+ struct i915_context *i915 = i915_context(pipe);
+ struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+ *view = *templ;
+ view->reference.count = 1;
+ view->texture = NULL;
+ pipe_texture_reference(&view->texture, texture);
+ view->context = pipe;
+
+ return view;
+}
+
+
+static void
+i915_sampler_view_destroy(struct pipe_context *pipe,
+ struct pipe_sampler_view *view)
+{
+ pipe_texture_reference(&view->texture, NULL);
+ FREE(view);
+}
+
static void i915_set_framebuffer_state(struct pipe_context *pipe,
const struct pipe_framebuffer_state *fb)
i915->base.set_polygon_stipple = i915_set_polygon_stipple;
i915->base.set_scissor_state = i915_set_scissor_state;
- i915->base.set_fragment_sampler_textures = i915_set_sampler_textures;
+ i915->base.set_fragment_sampler_views = i915_set_fragment_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;
i915->base.set_vertex_buffers = i915_set_vertex_buffers;
i915->base.set_vertex_elements = i915_set_vertex_elements;
if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS | I915_NEW_VS))
calculate_vertex_layout( i915 );
- if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_TEXTURE))
+ if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_SAMPLER_VIEW))
i915_update_samplers(i915);
- if (i915->dirty & I915_NEW_TEXTURE)
+ if (i915->dirty & I915_NEW_SAMPLER_VIEW)
i915_update_textures(i915);
if (i915->dirty)
OUT_BATCH(enabled);
for (unit = 0; unit < I915_TEX_UNITS; unit++) {
if (enabled & (1 << unit)) {
- struct intel_buffer *buf = i915->texture[unit]->buffer;
+ struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+ struct intel_buffer *buf = texture->buffer;
uint offset = 0;
assert(buf);
i915->current.sampler_enable_nr = 0;
i915->current.sampler_enable_flags = 0x0;
- for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers;
+ for (unit = 0; unit < i915->num_fragment_sampler_views && unit < i915->num_samplers;
unit++) {
/* determine unit enable/disable by looking for a bound texture */
/* could also examine the fragment program? */
- if (i915->texture[unit]) {
+ if (i915->fragment_sampler_views[unit]) {
+ struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+
update_sampler( i915,
unit,
i915->sampler[unit], /* sampler state */
- i915->texture[unit], /* texture */
+ texture, /* texture */
i915->current.sampler[unit] /* the result */
);
i915_update_texture( i915,
unit,
- i915->texture[unit], /* texture */
+ texture, /* texture */
i915->sampler[unit], /* sampler state */
i915->current.texbuffer[unit] );
{
uint unit;
- for (unit = 0; unit < i915->num_textures && unit < i915->num_samplers;
+ for (unit = 0; unit < i915->num_fragment_sampler_views && unit < i915->num_samplers;
unit++) {
/* determine unit enable/disable by looking for a bound texture */
/* could also examine the fragment program? */
- if (i915->texture[unit]) {
+ if (i915->fragment_sampler_views[unit]) {
+ struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+
i915_update_texture( i915,
unit,
- i915->texture[unit], /* texture */
+ texture, /* texture */
i915->sampler[unit], /* sampler state */
i915->current.texbuffer[unit] );
}