From 6286d9810b7ebae588060370cd7a63c327478a2f Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Tue, 31 Jul 2012 15:56:09 +0200 Subject: [PATCH] Revert "gallium: specify resource_resolve destination via a pipe_surface" This reverts commit 5d5af7d359e0060fa00b90a8f04900b96f9058b0. It turns out the issue this was supposed to fix merely counter-acted a bug in the hardware driver that I wasn't aware of. The resource_resolve is not supposed to do sRGB conversion, period. (This would violate the requirement that source and destination must be of the same format). --- src/gallium/drivers/nv30/nv30_miptree.c | 5 +--- src/gallium/drivers/nv50/nv50_surface.c | 32 +++++++++++++++---------- src/gallium/drivers/nvc0/nvc0_surface.c | 32 +++++++++++++++---------- src/gallium/drivers/r300/r300_render.c | 7 +++++- src/gallium/include/pipe/p_state.h | 6 +++-- src/mesa/state_tracker/st_cb_blit.c | 15 +++++++----- 6 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index cd6a81428d9..7e677291f6a 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -153,10 +153,7 @@ nv30_resource_resolve(struct pipe_context *pipe, define_rect(info->src.res, 0, 0, info->src.x0, info->src.y0, info->src.x1 - info->src.x0, info->src.y1 - info->src.y0, &src); - define_rect(info->dst.surface->texture, - info->dst.surface->u.tex.level, - info->dst.surface->u.tex.first_layer, - info->dst.x0, info->dst.y0, + define_rect(info->dst.res, info->dst.level, 0, info->dst.x0, info->dst.y0, info->dst.x1 - info->dst.x0, info->dst.y1 - info->dst.y0, &dst); nv30_transfer_rect(nv30, BILINEAR, &src, &dst); diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index ed5223b2085..0872f8d0dc4 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -436,7 +436,6 @@ struct nv50_blitctx unsigned num_samplers[3]; struct pipe_sampler_view *texture[2]; struct nv50_tsc_entry *sampler[2]; - enum pipe_format format; unsigned dirty; } saved; struct nv50_program vp; @@ -662,19 +661,26 @@ nv50_blitctx_get_color_mask_and_fp(struct nv50_blitctx *blit, } static void -nv50_blit_set_dst(struct nv50_context *nv50, struct pipe_surface *surf, - struct nv50_blitctx *blit) +nv50_blit_set_dst(struct nv50_context *nv50, + struct pipe_resource *res, unsigned level, unsigned layer) { - blit->saved.format = surf->format; + struct pipe_context *pipe = &nv50->base.pipe; + struct pipe_surface templ; - if (util_format_is_depth_or_stencil(surf->format)) - surf->format = nv50_blit_zeta_to_colour_format(surf->format); + if (util_format_is_depth_or_stencil(res->format)) + templ.format = nv50_blit_zeta_to_colour_format(res->format); + else + templ.format = res->format; + + templ.usage = PIPE_USAGE_STREAM; + templ.u.tex.level = level; + templ.u.tex.first_layer = templ.u.tex.last_layer = layer; - nv50->framebuffer.cbufs[0] = surf; + nv50->framebuffer.cbufs[0] = nv50_miptree_surface_new(pipe, res, &templ); nv50->framebuffer.nr_cbufs = 1; nv50->framebuffer.zsbuf = NULL; - nv50->framebuffer.width = surf->width; - nv50->framebuffer.height = surf->height; + nv50->framebuffer.width = nv50->framebuffer.cbufs[0]->width; + nv50->framebuffer.height = nv50->framebuffer.cbufs[0]->height; } static INLINE void @@ -816,7 +822,7 @@ nv50_blitctx_post_blit(struct nv50_context *nv50, struct nv50_blitctx *blit) { int s; - nv50->framebuffer.cbufs[0]->format = blit->saved.format; + pipe_surface_reference(&nv50->framebuffer.cbufs[0], NULL); nv50->framebuffer.width = blit->saved.fb.width; nv50->framebuffer.height = blit->saved.fb.height; @@ -856,7 +862,7 @@ nv50_resource_resolve(struct pipe_context *pipe, struct nv50_blitctx *blit = screen->blitctx; struct nouveau_pushbuf *push = nv50->base.pushbuf; struct pipe_resource *src = info->src.res; - struct pipe_resource *dst = info->dst.surface->texture; + struct pipe_resource *dst = info->dst.res; float x0, x1, y0, y1, z; float x_range, y_range; @@ -866,8 +872,8 @@ nv50_resource_resolve(struct pipe_context *pipe, nv50_blitctx_pre_blit(blit, nv50); - nv50_blit_set_dst(nv50, info->dst.surface, blit); - nv50_blit_set_src(nv50, src, 0, info->src.layer); + nv50_blit_set_dst(nv50, dst, info->dst.level, info->dst.layer); + nv50_blit_set_src(nv50, src, 0, info->src.layer); nv50_blitctx_prepare_state(blit); diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c index 6773f96baa6..607b02e0277 100644 --- a/src/gallium/drivers/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nvc0/nvc0_surface.c @@ -457,7 +457,6 @@ struct nvc0_blitctx unsigned num_samplers[5]; struct pipe_sampler_view *texture[2]; struct nv50_tsc_entry *sampler[2]; - enum pipe_format format; unsigned dirty; } saved; struct nvc0_program vp; @@ -728,19 +727,26 @@ nvc0_blitctx_get_color_mask_and_fp(struct nvc0_blitctx *blit, } static void -nvc0_blit_set_dst(struct nvc0_context *nvc0, struct pipe_surface *surf, - struct nvc0_blitctx *blit) +nvc0_blit_set_dst(struct nvc0_context *nvc0, + struct pipe_resource *res, unsigned level, unsigned layer) { - blit->saved.format = surf->format; + struct pipe_context *pipe = &nvc0->base.pipe; + struct pipe_surface templ; + + if (util_format_is_depth_or_stencil(res->format)) + templ.format = nvc0_blit_zeta_to_colour_format(res->format); + else + templ.format = res->format; - if (util_format_is_depth_or_stencil(surf->format)) - surf->format = nvc0_blit_zeta_to_colour_format(surf->format); + templ.usage = PIPE_USAGE_STREAM; + templ.u.tex.level = level; + templ.u.tex.first_layer = templ.u.tex.last_layer = layer; - nvc0->framebuffer.cbufs[0] = surf; + nvc0->framebuffer.cbufs[0] = nvc0_miptree_surface_new(pipe, res, &templ); nvc0->framebuffer.nr_cbufs = 1; nvc0->framebuffer.zsbuf = NULL; - nvc0->framebuffer.width = surf->width; - nvc0->framebuffer.height = surf->height; + nvc0->framebuffer.width = nvc0->framebuffer.cbufs[0]->width; + nvc0->framebuffer.height = nvc0->framebuffer.cbufs[0]->height; } static INLINE void @@ -893,7 +899,7 @@ nvc0_blitctx_post_blit(struct nvc0_context *nvc0, struct nvc0_blitctx *blit) { int s; - nvc0->framebuffer.cbufs[0]->format = blit->saved.format; + pipe_surface_reference(&nvc0->framebuffer.cbufs[0], NULL); nvc0->framebuffer.width = blit->saved.fb.width; nvc0->framebuffer.height = blit->saved.fb.height; @@ -942,7 +948,7 @@ nvc0_resource_resolve(struct pipe_context *pipe, struct nvc0_blitctx *blit = screen->blitctx; struct nouveau_pushbuf *push = screen->base.pushbuf; struct pipe_resource *src = info->src.res; - struct pipe_resource *dst = info->dst.surface->texture; + struct pipe_resource *dst = info->dst.res; float x0, x1, y0, y1; float x_range, y_range; @@ -958,8 +964,8 @@ nvc0_resource_resolve(struct pipe_context *pipe, nvc0_blitctx_pre_blit(blit, nvc0); - nvc0_blit_set_dst(nvc0, info->dst.surface, blit); - nvc0_blit_set_src(nvc0, src, 0, info->src.layer, blit->filter); + nvc0_blit_set_dst(nvc0, dst, info->dst.level, info->dst.layer); + nvc0_blit_set_src(nvc0, src, 0, info->src.layer, blit->filter); nvc0_blitctx_prepare_state(blit); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 74e137d0220..ceda1269707 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -1272,7 +1272,11 @@ static void r300_resource_resolve(struct pipe_context *pipe, srcsurf = pipe->create_surface(pipe, info->src.res, &surf_tmpl); /* XXX Offset both surfaces by x0,y1. */ - dstsurf = info->dst.surface; + surf_tmpl.format = info->dst.res->format; + surf_tmpl.u.tex.level = info->dst.level; + surf_tmpl.u.tex.first_layer = + surf_tmpl.u.tex.last_layer = info->dst.layer; + dstsurf = pipe->create_surface(pipe, info->dst.res, &surf_tmpl); DBG(r300, DBG_DRAW, "r300: Resolving resource...\n"); @@ -1298,6 +1302,7 @@ static void r300_resource_resolve(struct pipe_context *pipe, r300_mark_atom_dirty(r300, &r300->aa_state); pipe_surface_reference(&srcsurf, NULL); + pipe_surface_reference(&dstsurf, NULL); } void r300_init_render_functions(struct r300_context *r300) diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index dbe726dbf9a..c828c806aef 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -572,7 +572,9 @@ struct pipe_draw_info struct pipe_resolve_info { struct { - struct pipe_surface *surface; + struct pipe_resource *res; + unsigned level; + unsigned layer; int x0; /**< always left */ int y0; /**< always top */ int x1; /**< determines scale if PIPE_CAP_SCALED_RESOLVE is supported */ @@ -585,7 +587,7 @@ struct pipe_resolve_info int x0; int y0; int x1; /**< may be < x0 only if PIPE_CAP_SCALED_RESOLVE is supported */ - int y1; /**< may be < y0 even if PIPE_CAP_SCALED_RESOLVE not supported */ + int y1; /**< may be < y1 even if PIPE_CAP_SCALED_RESOLVE not supported */ } src; unsigned mask; /**< PIPE_MASK_RGBA, Z, S or ZS */ diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index b189cb40688..1486779fd9f 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -80,8 +80,9 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx, info->src.res = srcRb->texture; info->src.layer = srcRb->surface->u.tex.first_layer; - - info->dst.surface = dstRb->surface; + info->dst.res = dstRb->texture; + info->dst.level = dstRb->surface->u.tex.level; + info->dst.layer = dstRb->surface->u.tex.first_layer; st->pipe->resource_resolve(st->pipe, info); } @@ -113,8 +114,9 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx, info->src.res = srcRb->texture; info->src.layer = srcRb->surface->u.tex.first_layer; - - info->dst.surface = dstRb->surface; + info->dst.res = dstRb->texture; + info->dst.level = dstRb->surface->u.tex.level; + info->dst.layer = dstRb->surface->u.tex.first_layer; st->pipe->resource_resolve(st->pipe, info); } @@ -128,8 +130,9 @@ st_BlitFramebuffer_resolve(struct gl_context *ctx, info->src.res = srcRb->texture; info->src.layer = srcRb->surface->u.tex.first_layer; - - info->dst.surface = dstRb->surface; + info->dst.res = dstRb->texture; + info->dst.level = dstRb->surface->u.tex.level; + info->dst.layer = dstRb->surface->u.tex.first_layer; st->pipe->resource_resolve(st->pipe, info); } -- 2.30.2