diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r300/r300_blit.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 20 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 54 |
4 files changed, 59 insertions, 27 deletions
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index eb9b0beeb5a..c48684fe51f 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -108,9 +108,9 @@ static void r300_hw_copy(struct pipe_context* pipe, 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, diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 1eba8a8ed12..2edf65797a2 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -300,9 +300,9 @@ struct r300_context { int sampler_count; /* Scissor state. */ struct r300_atom scissor_state; - /* Texture states. */ - struct r300_texture* textures[8]; - int texture_count; + /* Sampler view states. */ + struct pipe_sampler_view* fragment_sampler_views[8]; + int fragment_sampler_view_count; /* Vertex shader. */ struct r300_vertex_shader* vs; /* Viewport state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 88fe166359b..4310ff1411d 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -159,7 +159,7 @@ static const float * get_shader_constant( /* 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; @@ -967,11 +967,11 @@ void r300_emit_texture_count(struct r300_context* r300) 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; } } @@ -1043,10 +1043,10 @@ validate: } } /* ...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); @@ -1145,13 +1145,13 @@ void r300_emit_dirty_state(struct r300_context* r300) (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); } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 34bf81c1930..e5ec2701c81 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -932,9 +932,9 @@ static void r300_delete_sampler_state(struct pipe_context* pipe, void* state) 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; @@ -946,13 +946,17 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, } 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; @@ -961,14 +965,40 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, } 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, @@ -1234,7 +1264,9 @@ void r300_init_state_functions(struct r300_context* r300) 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; |