From 0f86915c5322b096b7154b6c84e21288074b775d Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Thu, 9 Aug 2012 17:21:10 +0200 Subject: r600g: implement MSAA color resolve --- src/gallium/auxiliary/util/u_blitter.c | 61 ++++++++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_blitter.h | 8 +++++ 2 files changed, 69 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 1e373223eaf..a5510d553e9 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -1491,3 +1491,64 @@ void util_blitter_copy_buffer(struct blitter_context *blitter, blitter_unset_running_flag(ctx); pipe_so_target_reference(&so_target, NULL); } + +/* probably radeon specific */ +void util_blitter_resolve_color_custom(struct blitter_context *blitter, + struct pipe_resource *dst, + unsigned dst_level, + unsigned dst_layer, + struct pipe_resource *src, + unsigned src_layer, + void *custom_blend) +{ + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; + struct pipe_context *pipe = ctx->base.pipe; + struct pipe_framebuffer_state fb_state; + struct pipe_surface *srcsurf, *dstsurf, surf_tmpl; + + blitter_set_running_flag(ctx); + blitter_check_saved_vertex_states(ctx); + blitter_check_saved_fragment_states(ctx); + + /* bind states */ + pipe->bind_blend_state(pipe, custom_blend); + pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); + pipe->bind_vertex_elements_state(pipe, ctx->velem_state); + pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); + + memset(&surf_tmpl, 0, sizeof(surf_tmpl)); + surf_tmpl.format = dst->format; + surf_tmpl.u.tex.level = dst_level; + surf_tmpl.u.tex.first_layer = dst_layer; + surf_tmpl.u.tex.last_layer = dst_layer; + surf_tmpl.usage = PIPE_BIND_RENDER_TARGET; + + dstsurf = pipe->create_surface(pipe, dst, &surf_tmpl); + + surf_tmpl.u.tex.level = 0; + surf_tmpl.u.tex.first_layer = src_layer; + surf_tmpl.u.tex.last_layer = src_layer; + + srcsurf = pipe->create_surface(pipe, src, &surf_tmpl); + + /* set a framebuffer state */ + fb_state.width = src->width0; + fb_state.height = src->height0; + fb_state.nr_cbufs = 2; + fb_state.cbufs[0] = srcsurf; + fb_state.cbufs[1] = dstsurf; + fb_state.zsbuf = NULL; + pipe->set_framebuffer_state(pipe, &fb_state); + + blitter_set_common_draw_rect_state(ctx); + blitter_set_dst_dimensions(ctx, src->width0, src->height0); + blitter->draw_rectangle(blitter, 0, 0, src->width0, src->height0, + 0, 0, NULL); + blitter_restore_fb_state(ctx); + blitter_restore_vertex_states(ctx); + blitter_restore_fragment_states(ctx); + blitter_unset_running_flag(ctx); + + pipe_surface_reference(&srcsurf, NULL); + pipe_surface_reference(&dstsurf, NULL); +} diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 1881e6ae6ce..1207a9ae306 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -300,6 +300,14 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter, unsigned sample_mask, void *dsa_stage, float depth); +void util_blitter_resolve_color_custom(struct blitter_context *blitter, + struct pipe_resource *dst, + unsigned dst_level, + unsigned dst_layer, + struct pipe_resource *src, + unsigned src_layer, + void *custom_blend); + /* The functions below should be used to save currently bound constant state * objects inside a driver. The objects are automatically restored at the end * of the util_blitter_{clear, copy_region, fill_region} functions and then -- cgit v1.2.3