From de80660c2bd43db112b6c82d970660ed9806cd33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 13 Sep 2012 19:38:25 +0200 Subject: [PATCH] gallium: remove resource_resolve MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The functionality is provided by the new blit function. Tested-by: Michel Dänzer Reviewed-by: Brian Paul --- src/gallium/docs/d3d11ddi.txt | 2 +- src/gallium/docs/source/context.rst | 14 -- src/gallium/drivers/galahad/glhd_context.c | 1 - src/gallium/drivers/nv30/nv30_miptree.c | 2 + src/gallium/drivers/nv30/nv30_resource.c | 1 - src/gallium/drivers/nv50/nv50_surface.c | 3 +- src/gallium/drivers/nvc0/nvc0_surface.c | 3 +- src/gallium/drivers/r300/r300_render.c | 4 +- src/gallium/drivers/r600/r600_blit.c | 152 ------------------ src/gallium/include/pipe/p_context.h | 9 +- src/gallium/include/pipe/p_state.h | 26 --- .../d3d1x/gd3d11/d3d11_context.h | 2 + 12 files changed, 12 insertions(+), 207 deletions(-) diff --git a/src/gallium/docs/d3d11ddi.txt b/src/gallium/docs/d3d11ddi.txt index 7cbcdc7e731..14a589fffe2 100644 --- a/src/gallium/docs/d3d11ddi.txt +++ b/src/gallium/docs/d3d11ddi.txt @@ -384,7 +384,7 @@ ResourceIsStagingBusy -> ResourceReadAfterWriteHazard - Gallium lacks this -ResourceResolveSubresource -> resource_resolve +ResourceResolveSubresource -> blit ResourceMap ResourceUnmap diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 29b38e50e4e..28096f804b1 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -444,20 +444,6 @@ the optimal method for blitting (like using a special 2D engine), and usually offers, for example, accelerated stencil-only copies even where PIPE_CAP_SHADER_STENCIL_EXPORT is not available. -``resource_resolve`` resolves a multisampled resource into a non-multisampled -one. Their formats must match. This function must be present if a driver -supports multisampling. -The region that is to be resolved is described by ``pipe_resolve_info``, which -provides a source and a destination rectangle. -The source rectangle may be vertically flipped, but otherwise the dimensions -of the rectangles must match, unless PIPE_CAP_SCALED_RESOLVE is supported, -in which case scaling and horizontal flipping are allowed as well. -The result of resolving depth/stencil values may be any function of the values at -the sample points, but returning the value of the centermost sample is preferred. - -The interfaces to these calls are likely to change to make it easier -for a driver to batch multiple blits with the same source and -destination. Transfers ^^^^^^^^^ diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c index e20986fca6e..354f20a3ad7 100644 --- a/src/gallium/drivers/galahad/glhd_context.c +++ b/src/gallium/drivers/galahad/glhd_context.c @@ -1080,7 +1080,6 @@ galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) //GLHD_PIPE_INIT(set_stream_output_targets); GLHD_PIPE_INIT(resource_copy_region); GLHD_PIPE_INIT(blit); - //GLHD_PIPE_INIT(resource_resolve); GLHD_PIPE_INIT(clear); GLHD_PIPE_INIT(clear_render_target); GLHD_PIPE_INIT(clear_depth_stencil); diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index 79034ac7dae..5a9a63ba0d9 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -148,6 +148,7 @@ void nv30_resource_resolve(struct pipe_context *pipe, const struct pipe_resolve_info *info) { +#if 0 struct nv30_context *nv30 = nv30_context(pipe); struct nv30_rect src, dst; @@ -157,6 +158,7 @@ nv30_resource_resolve(struct pipe_context *pipe, info->dst.x1 - info->dst.x0, info->dst.y1 - info->dst.y0, &dst); nv30_transfer_rect(nv30, BILINEAR, &src, &dst); +#endif } void diff --git a/src/gallium/drivers/nv30/nv30_resource.c b/src/gallium/drivers/nv30/nv30_resource.c index 80dc61efcb0..4d2a2284a75 100644 --- a/src/gallium/drivers/nv30/nv30_resource.c +++ b/src/gallium/drivers/nv30/nv30_resource.c @@ -75,6 +75,5 @@ nv30_resource_init(struct pipe_context *pipe) pipe->create_surface = nv30_miptree_surface_new; pipe->surface_destroy = nv30_miptree_surface_del; pipe->resource_copy_region = nv30_resource_copy_region; - pipe->resource_resolve = nv30_resource_resolve; pipe->blit = nv30_blit; } diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 69bc77233f5..68809ec181b 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -859,6 +859,7 @@ nv50_blitctx_post_blit(struct nv50_context *nv50, struct nv50_blitctx *blit) NV50_NEW_VERTPROG | NV50_NEW_GMTYPROG | NV50_NEW_FRAGPROG); } +#if 0 static void nv50_resource_resolve(struct pipe_context *pipe, const struct pipe_resolve_info *info) @@ -955,6 +956,7 @@ nv50_resource_resolve(struct pipe_context *pipe, nv50_blitctx_post_blit(nv50, blit); } +#endif boolean nv50_blitctx_create(struct nv50_screen *screen) @@ -983,7 +985,6 @@ nv50_init_surface_functions(struct nv50_context *nv50) struct pipe_context *pipe = &nv50->base.pipe; pipe->resource_copy_region = nv50_resource_copy_region; - pipe->resource_resolve = nv50_resource_resolve; pipe->clear_render_target = nv50_clear_render_target; pipe->clear_depth_stencil = nv50_clear_depth_stencil; } diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c index d52de0b6186..d95124dec10 100644 --- a/src/gallium/drivers/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nvc0/nvc0_surface.c @@ -945,6 +945,7 @@ nvc0_blitctx_post_blit(struct nvc0_context *nvc0, struct nvc0_blitctx *blit) NVC0_NEW_TFB_TARGETS); } +#if 0 static void nvc0_resource_resolve(struct pipe_context *pipe, const struct pipe_resolve_info *info) @@ -1047,6 +1048,7 @@ nvc0_resource_resolve(struct pipe_context *pipe, nvc0_blitctx_post_blit(nvc0, blit); } +#endif boolean nvc0_blitctx_create(struct nvc0_screen *screen) @@ -1076,7 +1078,6 @@ nvc0_init_surface_functions(struct nvc0_context *nvc0) struct pipe_context *pipe = &nvc0->base.pipe; pipe->resource_copy_region = nvc0_resource_copy_region; - pipe->resource_resolve = nvc0_resource_resolve; pipe->clear_render_target = nvc0_clear_render_target; pipe->clear_depth_stencil = nvc0_clear_depth_stencil; } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index e388260894c..198ab73d257 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -1254,6 +1254,7 @@ done: r300->sprite_coord_enable = last_sprite_coord_enable; } +#if 0 static void r300_resource_resolve(struct pipe_context *pipe, const struct pipe_resolve_info *info) { @@ -1303,6 +1304,7 @@ static void r300_resource_resolve(struct pipe_context *pipe, pipe_surface_reference(&srcsurf, NULL); pipe_surface_reference(&dstsurf, NULL); } +#endif void r300_init_render_functions(struct r300_context *r300) { @@ -1313,8 +1315,6 @@ void r300_init_render_functions(struct r300_context *r300) r300->context.draw_vbo = r300_swtcl_draw_vbo; } - r300->context.resource_resolve = r300_resource_resolve; - /* Plug in the two-sided stencil reference value fallback if needed. */ if (!r300->screen->caps.is_r500) r300_plug_in_stencil_ref_fallback(r300); diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c index 9ebb043168a..090121cccf5 100644 --- a/src/gallium/drivers/r600/r600_blit.c +++ b/src/gallium/drivers/r600/r600_blit.c @@ -351,67 +351,6 @@ static bool r600_decompress_subresource(struct pipe_context *ctx, return true; } -static void r600_copy_first_sample(struct pipe_context *ctx, - const struct pipe_resolve_info *info) -{ - struct r600_context *rctx = (struct r600_context *)ctx; - struct pipe_surface *dst_view, dst_templ; - struct pipe_sampler_view src_templ, *src_view; - struct pipe_box box; - - /* The driver doesn't decompress resources automatically while - * u_blitter is rendering. */ - if (!r600_decompress_subresource(ctx, info->src.res, 0, - info->src.layer, info->src.layer)) { - return; /* error */ - } - - /* this is correct for upside-down blits too */ - u_box_2d(info->src.x0, - info->src.y0, - info->src.x1 - info->src.x0, - info->src.y1 - info->src.y0, &box); - - /* Initialize the surface. */ - util_blitter_default_dst_texture(&dst_templ, info->dst.res, - info->dst.level, info->dst.layer, &box); - dst_view = ctx->create_surface(ctx, info->dst.res, &dst_templ); - - /* Initialize the sampler view. */ - util_blitter_default_src_texture(&src_templ, info->src.res, 0); - src_view = ctx->create_sampler_view(ctx, info->src.res, &src_templ); - - /* Copy the first sample into dst. */ - r600_blitter_begin(ctx, R600_COPY_TEXTURE); - util_blitter_blit_generic(rctx->blitter, dst_view, info->dst.x0, - info->dst.y0, abs(box.width), abs(box.height), - src_view, &box, - info->src.res->width0, info->src.res->height0, - info->mask, PIPE_TEX_FILTER_NEAREST, NULL, FALSE); - r600_blitter_end(ctx); - - pipe_surface_reference(&dst_view, NULL); - pipe_sampler_view_reference(&src_view, NULL); -} - -static boolean is_simple_resolve(const struct pipe_resolve_info *info) -{ - unsigned dst_width = u_minify(info->dst.res->width0, info->dst.level); - unsigned dst_height = u_minify(info->dst.res->height0, info->dst.level); - - return info->dst.res->format == info->src.res->format && - dst_width == info->src.res->width0 && - dst_height == info->src.res->height0 && - info->dst.x0 == 0 && - info->dst.y0 == 0 && - info->dst.x1 == dst_width && - info->dst.y1 == dst_height && - info->src.x0 == 0 && - info->src.y0 == 0 && - info->src.x1 == dst_width && - info->src.y1 == dst_height; -} - static boolean is_simple_msaa_resolve(const struct pipe_blit_info *info) { unsigned dst_width = u_minify(info->dst.resource->width0, info->dst.level); @@ -434,96 +373,6 @@ static boolean is_simple_msaa_resolve(const struct pipe_blit_info *info) info->src.box.height == dst_height; } -static void r600_color_resolve(struct pipe_context *ctx, - const struct pipe_resolve_info *info) -{ - struct r600_context *rctx = (struct r600_context *)ctx; - struct pipe_screen *screen = ctx->screen; - struct pipe_resource *tmp, templ; - struct pipe_box box; - unsigned sample_mask = - rctx->chip_class == CAYMAN ? ~0 : ((1ull << MAX2(1, info->src.res->nr_samples)) - 1); - - assert((info->mask & PIPE_MASK_RGBA) == PIPE_MASK_RGBA); - - if (is_simple_resolve(info)) { - r600_blitter_begin(ctx, R600_COLOR_RESOLVE); - util_blitter_custom_resolve_color(rctx->blitter, - info->dst.res, info->dst.level, info->dst.layer, - info->src.res, info->src.layer, - sample_mask, rctx->custom_blend_resolve); - r600_blitter_end(ctx); - return; - } - - /* resolve into a temporary texture, then blit */ - templ.target = PIPE_TEXTURE_2D; - templ.format = info->src.res->format; - templ.width0 = info->src.res->width0; - templ.height0 = info->src.res->height0; - templ.depth0 = 1; - templ.array_size = 1; - templ.last_level = 0; - templ.nr_samples = 0; - templ.usage = PIPE_USAGE_STATIC; - templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; - templ.flags = 0; - - tmp = screen->resource_create(screen, &templ); - - /* XXX use scissor, so that only the needed part of the resource is resolved */ - r600_blitter_begin(ctx, R600_COLOR_RESOLVE); - util_blitter_custom_resolve_color(rctx->blitter, - tmp, 0, 0, - info->src.res, info->src.layer, - sample_mask, rctx->custom_blend_resolve); - r600_blitter_end(ctx); - - /* this is correct for upside-down blits too */ - u_box_2d(info->src.x0, - info->src.y0, - info->src.x1 - info->src.x0, - info->src.y1 - info->src.y0, &box); - - r600_blitter_begin(ctx, R600_COPY_TEXTURE); - util_blitter_copy_texture(rctx->blitter, info->dst.res, info->dst.level, - info->dst.x0, info->dst.y0, info->dst.layer, - tmp, 0, &box, PIPE_MASK_RGBAZS, FALSE); - r600_blitter_end(ctx); - - pipe_resource_reference(&tmp, NULL); -} - -static void r600_resource_resolve(struct pipe_context *ctx, - const struct pipe_resolve_info *info) -{ - /* make sure we're doing a resolve operation */ - assert(info->src.res->nr_samples > 1); - assert(info->dst.res->nr_samples <= 1); - - /* limitations of multisample resources */ - assert(info->src.res->last_level == 0); - assert(info->src.res->target == PIPE_TEXTURE_2D || - info->src.res->target == PIPE_TEXTURE_2D_ARRAY); - - /* check if the resolve box is valid */ - assert(info->dst.x0 < info->dst.x1); - assert(info->dst.y0 < info->dst.y1); - - /* scaled resolve isn't allowed */ - assert(abs(info->dst.x0 - info->dst.x1) == - abs(info->src.x0 - info->src.x1)); - assert(abs(info->dst.y0 - info->dst.y1) == - abs(info->src.y0 - info->src.y1)); - - if ((info->mask & PIPE_MASK_ZS) || - util_format_is_pure_integer(info->src.res->format)) { - r600_copy_first_sample(ctx, info); - } else { - r600_color_resolve(ctx, info); - } -} - static void r600_clear(struct pipe_context *ctx, unsigned buffers, const union pipe_color_union *color, double depth, unsigned stencil) @@ -892,6 +741,5 @@ void r600_init_blit_functions(struct r600_context *rctx) rctx->context.clear_render_target = r600_clear_render_target; rctx->context.clear_depth_stencil = r600_clear_depth_stencil; rctx->context.resource_copy_region = r600_resource_copy_region; - rctx->context.resource_resolve = r600_resource_resolve; rctx->context.blit = r600_blit; } diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 3c33bc6cb84..09760ddbe0f 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -281,7 +281,7 @@ struct pipe_context { /** * Resource functions for blit-like functionality * - * If a driver supports multisampling, resource_resolve must be available. + * If a driver supports multisampling, blit must implement color resolve. */ /*@{*/ @@ -304,13 +304,6 @@ struct pipe_context { void (*blit)(struct pipe_context *pipe, const struct pipe_blit_info *info); - /** - * Resolve a multisampled resource into a non-multisampled one. - * Source and destination must be of the same format. - */ - void (*resource_resolve)(struct pipe_context *pipe, - const struct pipe_resolve_info *info); - /*@}*/ /** diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 1f748cdda4f..e88242dd769 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -585,32 +585,6 @@ struct pipe_blit_info struct pipe_scissor_state scissor; }; -/** - * Information to describe a resource_resolve call. - */ -struct pipe_resolve_info -{ - struct { - 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 */ - int y1; /**< determines scale if PIPE_CAP_SCALED_RESOLVE is supported */ - } dst; - - struct { - struct pipe_resource *res; - unsigned layer; - int x0; - int y0; - int x1; /**< may be < x0 only if PIPE_CAP_SCALED_RESOLVE is supported */ - int y1; /**< may be < y1 even if PIPE_CAP_SCALED_RESOLVE not supported */ - } src; - - unsigned mask; /**< PIPE_MASK_RGBA, Z, S or ZS */ -}; /** * Structure used as a header for serialized LLVM programs. diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h index a7b761c707f..07612bd5f9a 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h @@ -1755,6 +1755,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl unsigned src_subresource, DXGI_FORMAT format) { +#if 0 SYNCHRONIZED; GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource; @@ -1778,6 +1779,7 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl info.mask = PIPE_MASK_RGBA | PIPE_MASK_ZS; pipe->resource_resolve(pipe, &info); +#endif } #if API >= 11 -- 2.30.2