summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300/r300_state.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-12-29 18:18:38 +0100
committerMarek Olšák <[email protected]>2012-01-01 11:47:05 +0100
commitce9d61fec64138ebf8d0bec2511e66593297b7d5 (patch)
tree3e60c2743b8df17392415e7d22b0e10446343624 /src/gallium/drivers/r300/r300_state.c
parentce31970af16558ebd60cfae33c000252bc3e1cbf (diff)
r300g: rework resource_copy_region, not changing pipe_resource
Changing pipe_resource was wrong, because it can be used by other contexts at the same time. This fixes the last possible race condition in r300g that I know of. This also fixes blitting NPOT compressed textures. Random pixels sometimes appeared at the right-hand edge of the texture. Finally, this removes r300_texture_desc::stride_in_pixels. It makes little sense with sampler views and surfaces being able to override width0, height0, and the format entirely.
Diffstat (limited to 'src/gallium/drivers/r300/r300_state.c')
-rw-r--r--src/gallium/drivers/r300/r300_state.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index d704057e466..3606e0bf505 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -756,7 +756,7 @@ static void r300_print_fb_surf_info(struct pipe_surface *surf, unsigned index,
"r300: %s[%i] Dim: %ix%i, Firstlayer: %i, "
"Lastlayer: %i, Level: %i, Format: %s\n"
- "r300: TEX: Macro: %s, Micro: %s, Pitch: %i, "
+ "r300: TEX: Macro: %s, Micro: %s, "
"Dim: %ix%ix%i, LastLevel: %i, Format: %s\n",
binding, index, surf->width, surf->height,
@@ -765,9 +765,8 @@ static void r300_print_fb_surf_info(struct pipe_surface *surf, unsigned index,
rtex->tex.macrotile[0] ? "YES" : " NO",
rtex->tex.microtile ? "YES" : " NO",
- rtex->tex.stride_in_pixels[0],
tex->width0, tex->height0, tex->depth0,
- tex->last_level, util_format_short_name(tex->format));
+ tex->last_level, util_format_short_name(surf->format));
}
void r300_mark_fb_state_dirty(struct r300_context *r300,
@@ -888,7 +887,7 @@ r300_set_framebuffer_state(struct pipe_context* pipe,
r300_mark_fb_state_dirty(r300, R300_CHANGED_FB_STATE);
if (state->zsbuf) {
- switch (util_format_get_blocksize(state->zsbuf->texture->format)) {
+ switch (util_format_get_blocksize(state->zsbuf->format)) {
case 2:
zbuffer_bpp = 16;
break;
@@ -1458,10 +1457,12 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
}
}
-static struct pipe_sampler_view *
-r300_create_sampler_view(struct pipe_context *pipe,
+struct pipe_sampler_view *
+r300_create_sampler_view_custom(struct pipe_context *pipe,
struct pipe_resource *texture,
- const struct pipe_sampler_view *templ)
+ const struct pipe_sampler_view *templ,
+ unsigned width0_override,
+ unsigned height0_override)
{
struct r300_sampler_view *view = CALLOC_STRUCT(r300_sampler_view);
struct r300_resource *tex = r300_resource(texture);
@@ -1477,6 +1478,8 @@ r300_create_sampler_view(struct pipe_context *pipe,
view->base.texture = NULL;
pipe_resource_reference(&view->base.texture, texture);
+ view->width0_override = width0_override;
+ view->height0_override = height0_override;
view->swizzle[0] = templ->swizzle_r;
view->swizzle[1] = templ->swizzle_g;
view->swizzle[2] = templ->swizzle_b;
@@ -1493,7 +1496,10 @@ r300_create_sampler_view(struct pipe_context *pipe,
}
assert(hwformat != ~0);
- view->format = tex->tx_format;
+ r300_texture_setup_format_state(r300_screen(pipe->screen), tex,
+ templ->format, 0,
+ width0_override, height0_override,
+ &view->format);
view->format.format1 |= hwformat;
if (is_r500) {
view->format.format2 |= r500_tx_format_msb_bit(templ->format);
@@ -1503,6 +1509,17 @@ r300_create_sampler_view(struct pipe_context *pipe,
return (struct pipe_sampler_view*)view;
}
+static struct pipe_sampler_view *
+r300_create_sampler_view(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ const struct pipe_sampler_view *templ)
+{
+ return r300_create_sampler_view_custom(pipe, texture, templ,
+ r300_resource(texture)->tex.width0,
+ r300_resource(texture)->tex.height0);
+}
+
+
static void
r300_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)