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);
+}
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
return retval == usage;
}
-static void *evergreen_create_blend_state(struct pipe_context *ctx,
- const struct pipe_blend_state *state)
+static void *evergreen_create_blend_state_mode(struct pipe_context *ctx,
+ const struct pipe_blend_state *state, int mode)
{
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_pipe_blend *blend = CALLOC_STRUCT(r600_pipe_blend);
blend->cb_target_mask = target_mask;
if (target_mask)
- color_control |= S_028808_MODE(V_028808_CB_NORMAL);
+ color_control |= S_028808_MODE(mode);
else
color_control |= S_028808_MODE(V_028808_CB_DISABLE);
return rstate;
}
+static void *evergreen_create_blend_state(struct pipe_context *ctx,
+ const struct pipe_blend_state *state)
+{
+
+ return evergreen_create_blend_state_mode(ctx, state, V_028808_CB_NORMAL);
+}
+
static void *evergreen_create_dsa_state(struct pipe_context *ctx,
const struct pipe_depth_stencil_alpha_state *state)
{
ve->fetch_shader, RADEON_USAGE_READ);
}
+void *evergreen_create_resolve_blend(struct r600_context *rctx)
+{
+ struct pipe_blend_state blend;
+ struct r600_pipe_state *rstate;
+
+ memset(&blend, 0, sizeof(blend));
+ blend.rt[0].colormask = 0xf;
+ rstate = evergreen_create_blend_state_mode(&rctx->context, &blend, V_028808_CB_RESOLVE);
+ return rstate;
+}
+
void *evergreen_create_db_flush_dsa(struct r600_context *rctx)
{
struct pipe_depth_stencil_alpha_state dsa = {{0}};
R600_DISABLE_RENDER_COND,
R600_DECOMPRESS = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_DISABLE_RENDER_COND,
+
+ R600_COLOR_RESOLVE = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_DISABLE_RENDER_COND
};
static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op)
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 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;
+
+ assert((info->mask & PIPE_MASK_RGBA) == PIPE_MASK_RGBA);
+
+ if (is_simple_resolve(info)) {
+ r600_blitter_begin(ctx, R600_COLOR_RESOLVE);
+ util_blitter_resolve_color_custom(rctx->blitter,
+ info->dst.res, info->dst.level, info->dst.layer,
+ info->src.res, info->src.layer,
+ 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_resolve_color_custom(rctx->blitter,
+ tmp, 0, 0,
+ info->src.res, info->src.layer,
+ 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,
+ ~0, info->dst.x0, info->dst.y0, info->dst.layer,
+ tmp, 0, 0, &box);
+ r600_blitter_end(ctx);
+
+ pipe_resource_reference(&tmp, NULL);
+}
+
static void r600_resource_resolve(struct pipe_context *ctx,
const struct pipe_resolve_info *info)
{
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);
}
}
if (rctx->custom_dsa_flush) {
rctx->context.delete_depth_stencil_alpha_state(&rctx->context, rctx->custom_dsa_flush);
}
+ if (rctx->custom_blend_resolve) {
+ rctx->context.delete_blend_state(&rctx->context, rctx->custom_blend_resolve);
+ }
util_unreference_framebuffer_state(&rctx->framebuffer);
r600_context_fini(rctx);
if (evergreen_context_init(rctx))
goto fail;
rctx->custom_dsa_flush = evergreen_create_db_flush_dsa(rctx);
+ rctx->custom_blend_resolve = evergreen_create_resolve_blend(rctx);
rctx->has_vertex_cache = !(rctx->family == CHIP_CEDAR ||
rctx->family == CHIP_PALM ||
rctx->family == CHIP_SUMO ||
boolean has_vertex_cache;
unsigned r6xx_num_clause_temp_gprs;
void *custom_dsa_flush;
+ void *custom_blend_resolve;
+
struct r600_screen *screen;
struct radeon_winsys *ws;
struct r600_pipe_state *states[R600_PIPE_NSTATES];
void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader);
void evergreen_fetch_shader(struct pipe_context *ctx, struct r600_vertex_element *ve);
void *evergreen_create_db_flush_dsa(struct r600_context *rctx);
+void *evergreen_create_resolve_blend(struct r600_context *rctx);
void evergreen_polygon_offset_update(struct r600_context *rctx);
boolean evergreen_is_format_supported(struct pipe_screen *screen,
enum pipe_format format,