From 6db53ca490b22ba3f16b3ab0beef7a5fc071a074 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 23 Sep 2012 23:12:17 +0200 Subject: r600g: don't modify pipe_resource in resource_copy_region, fixing race condition pipe_resource can be shared between contexts, we shouldn't modify its description. Instead, let's use the resource "views" (sampler views and surfaces), where we can freely change almost any property of a resource. --- src/gallium/drivers/r600/r600_state.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/gallium/drivers/r600/r600_state.c') diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 3347e6d872f..1d6171debb5 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1007,9 +1007,11 @@ static void *r600_create_sampler_state(struct pipe_context *ctx, return ss; } -static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *ctx, - struct pipe_resource *texture, - const struct pipe_sampler_view *state) +struct pipe_sampler_view * +r600_create_sampler_view_custom(struct pipe_context *ctx, + struct pipe_resource *texture, + const struct pipe_sampler_view *state, + unsigned width_first_level, unsigned height_first_level) { struct r600_pipe_sampler_view *view = CALLOC_STRUCT(r600_pipe_sampler_view); struct r600_texture *tmp = (struct r600_texture*)texture; @@ -1055,8 +1057,8 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c offset_level = state->u.tex.first_level; last_level = state->u.tex.last_level - offset_level; - width = tmp->surface.level[offset_level].npix_x; - height = tmp->surface.level[offset_level].npix_y; + width = width_first_level; + height = height_first_level; depth = tmp->surface.level[offset_level].npix_z; pitch = tmp->surface.level[offset_level].nblk_x * util_format_get_blockwidth(state->format); tile_type = tmp->tile_type; @@ -1116,6 +1118,18 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c return &view->base; } +static struct pipe_sampler_view * +r600_create_sampler_view(struct pipe_context *ctx, + struct pipe_resource *tex, + const struct pipe_sampler_view *state) +{ + struct r600_texture *rtex = (struct r600_texture*)tex; + + return r600_create_sampler_view_custom(ctx, tex, state, + rtex->surface.level[state->u.tex.first_level].npix_x, + rtex->surface.level[state->u.tex.first_level].npix_y); +} + static void r600_emit_clip_state(struct r600_context *rctx, struct r600_atom *atom) { struct radeon_winsys_cs *cs = rctx->cs; -- cgit v1.2.3