util_blitter_save_fragment_sampler_states(
r300->blitter, r300->sampler_count, (void**)r300->sampler_states);
- util_blitter_save_fragment_sampler_textures(
- r300->blitter, r300->texture_count,
- (struct pipe_texture**)r300->textures);
+ util_blitter_save_fragment_sampler_views(
+ r300->blitter, r300->fragment_sampler_view_count,
+ r300->fragment_sampler_views);
/* Do a copy */
util_blitter_copy(r300->blitter,
/* Factor for converting rectangle coords to
* normalized coords. Should only show up on non-r500. */
case RC_STATE_R300_TEXRECT_FACTOR:
- tex = &r300->textures[constant->u.State[1]]->tex;
+ tex = r300->fragment_sampler_views[constant->u.State[1]]->texture;
vec[0] = 1.0 / tex->width0;
vec[1] = 1.0 / tex->height0;
break;
int i;
CS_LOCALS(r300);
- /* Notice that texture_count and sampler_count are just sizes
+ /* Notice that fragment_sampler_view_count and sampler_count are just sizes
* of the respective arrays. We still have to check for the individual
* elements. */
- for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) {
- if (r300->textures[i]) {
+ for (i = 0; i < MIN2(r300->sampler_count, r300->fragment_sampler_view_count); i++) {
+ if (r300->fragment_sampler_views[i]) {
tx_enable |= 1 << i;
}
}
}
}
/* ...textures... */
- for (i = 0; i < r300->texture_count; i++) {
- tex = r300->textures[i];
- if (!tex)
+ for (i = 0; i < r300->fragment_sampler_view_count; i++) {
+ if (!r300->fragment_sampler_views[i])
continue;
+ tex = (struct r300_texture *)r300->fragment_sampler_views[i]->texture;
if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
r300->context.flush(&r300->context, 0, NULL);
(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) {
r300_emit_texture_count(r300);
- for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) {
+ for (i = 0; i < MIN2(r300->sampler_count, r300->fragment_sampler_view_count); i++) {
if (r300->dirty_state &
((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) {
- if (r300->textures[i]) {
+ if (r300->fragment_sampler_views[i]) {
r300_emit_texture(r300,
r300->sampler_states[i],
- r300->textures[i],
+ (struct r300_texture *)r300->fragment_sampler_views[i]->texture,
i);
dirty_tex |= r300->dirty_state & (R300_NEW_TEXTURE << i);
}
FREE(state);
}
-static void r300_set_sampler_textures(struct pipe_context* pipe,
- unsigned count,
- struct pipe_texture** texture)
+static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
+ unsigned count,
+ struct pipe_sampler_view** views)
{
struct r300_context* r300 = r300_context(pipe);
boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
}
for (i = 0; i < count; i++) {
- if (r300->textures[i] != (struct r300_texture*)texture[i]) {
- pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
- texture[i]);
+ if (r300->fragment_sampler_views[i] != views[i]) {
+ struct r300_texture *texture;
+
+ pipe_sampler_view_reference(&r300->fragment_sampler_views[i],
+ views[i]);
r300->dirty_state |= (R300_NEW_TEXTURE << i);
+ texture = (struct r300_texture *)views[i]->texture;
+
/* R300-specific - set the texrect factor in a fragment shader */
- if (!is_r500 && r300->textures[i]->is_npot) {
+ if (!is_r500 && texture->is_npot) {
/* XXX It would be nice to re-emit just 1 constant,
* XXX not all of them */
r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
}
for (i = count; i < 8; i++) {
- if (r300->textures[i]) {
- pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
+ if (r300->fragment_sampler_views[i]) {
+ pipe_sampler_view_reference(&r300->fragment_sampler_views[i],
NULL);
r300->dirty_state |= (R300_NEW_TEXTURE << i);
}
}
- r300->texture_count = count;
+ r300->fragment_sampler_view_count = count;
+}
+
+static struct pipe_sampler_view *
+r300_create_sampler_view(struct pipe_context *pipe,
+ struct pipe_texture *texture,
+ const struct pipe_sampler_view *templ)
+{
+ struct r300_context *r300 = r300_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
+r300_sampler_view_destroy(struct pipe_context *pipe,
+ struct pipe_sampler_view *view)
+{
+ pipe_texture_reference(&view->texture, NULL);
+ FREE(view);
}
static void r300_set_scissor_state(struct pipe_context* pipe,
r300->context.bind_vertex_sampler_states = r300_lacks_vertex_textures;
r300->context.delete_sampler_state = r300_delete_sampler_state;
- r300->context.set_fragment_sampler_textures = r300_set_sampler_textures;
+ r300->context.set_fragment_sampler_views = r300_set_fragment_sampler_views;
+ r300->context.create_sampler_view = r300_create_sampler_view;
+ r300->context.sampler_view_destroy = r300_sampler_view_destroy;
r300->context.set_scissor_state = r300_set_scissor_state;