summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/r600/evergreen_state.c24
-rw-r--r--src/gallium/drivers/r600/r600_blit.c80
-rw-r--r--src/gallium/drivers/r600/r600_pipe.c4
-rw-r--r--src/gallium/drivers/r600/r600_pipe.h3
4 files changed, 108 insertions, 3 deletions
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 56b578b89f2..f9c7b52d55d 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -669,8 +669,8 @@ boolean evergreen_is_format_supported(struct pipe_screen *screen,
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);
@@ -706,7 +706,7 @@ static void *evergreen_create_blend_state(struct pipe_context *ctx,
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);
@@ -756,6 +756,13 @@ static void *evergreen_create_blend_state(struct pipe_context *ctx,
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)
{
@@ -2989,6 +2996,17 @@ void evergreen_fetch_shader(struct pipe_context *ctx,
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}};
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 41c2ef52efa..547386dfc74 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -42,6 +42,8 @@ enum r600_blitter_op /* bitmask */
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)
@@ -288,6 +290,82 @@ static void r600_copy_first_sample(struct pipe_context *ctx,
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)
{
@@ -313,6 +391,8 @@ static void r600_resource_resolve(struct pipe_context *ctx,
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);
}
}
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index f3556dec7a8..3960cd0d48a 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -162,6 +162,9 @@ static void r600_destroy_context(struct pipe_context *context)
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);
@@ -254,6 +257,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
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 ||
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 4cadab809ad..aeff52849ce 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -326,6 +326,8 @@ struct r600_context {
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];
@@ -465,6 +467,7 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
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,