aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util/u_blitter.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util/u_blitter.c')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c353
1 files changed, 247 insertions, 106 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index 58a52b3f2..89dae9556 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -68,6 +68,7 @@ struct blitter_context_priv
/* Fragment shaders. */
/* The shader at index i outputs color to color buffers 0,1,...,i-1. */
void *fs_col[PIPE_MAX_COLOR_BUFS+1];
+ void *fs_col_int[PIPE_MAX_COLOR_BUFS+1];
/* FS which outputs a color from a texture,
where the index is PIPE_TEXTURE_* to be sampled. */
@@ -88,6 +89,8 @@ struct blitter_context_priv
void *dsa_keep_depth_write_stencil;
void *velem_state;
+ void *velem_uint_state;
+ void *velem_sint_state;
/* Sampler state for clamping to a miplevel. */
void *sampler_state[PIPE_MAX_TEXTURE_LEVELS * 2];
@@ -104,6 +107,9 @@ struct blitter_context_priv
/* Destination surface dimensions. */
unsigned dst_width;
unsigned dst_height;
+
+ boolean has_geometry_shader;
+ boolean vertex_has_integers;
};
static void blitter_draw_rectangle(struct blitter_context *blitter,
@@ -137,12 +143,20 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
ctx->base.saved_rs_state = INVALID_PTR;
ctx->base.saved_fs = INVALID_PTR;
ctx->base.saved_vs = INVALID_PTR;
+ ctx->base.saved_gs = INVALID_PTR;
ctx->base.saved_velem_state = INVALID_PTR;
ctx->base.saved_fb_state.nr_cbufs = ~0;
ctx->base.saved_num_sampler_views = ~0;
ctx->base.saved_num_sampler_states = ~0;
ctx->base.saved_num_vertex_buffers = ~0;
+ ctx->has_geometry_shader =
+ pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_GEOMETRY,
+ PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0;
+ ctx->vertex_has_integers =
+ pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_VERTEX,
+ PIPE_SHADER_CAP_INTEGERS);
+
/* blend state objects */
memset(&blend, 0, sizeof(blend));
ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend);
@@ -201,6 +215,30 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
}
ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
+ if (ctx->vertex_has_integers) {
+ memset(&velem[0], 0, sizeof(velem[0]) * 2);
+ for (i = 0; i < 2; i++) {
+ velem[i].src_offset = i * 4 * sizeof(float);
+ if (i == 0) {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ } else {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_SINT;
+ }
+ }
+ ctx->velem_sint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
+
+ memset(&velem[0], 0, sizeof(velem[0]) * 2);
+ for (i = 0; i < 2; i++) {
+ velem[i].src_offset = i * 4 * sizeof(float);
+ if (i == 0) {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ } else {
+ velem[i].src_format = PIPE_FORMAT_R32G32B32A32_UINT;
+ }
+ }
+ ctx->velem_uint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
+ }
+
/* fragment shaders are created on-demand */
/* vertex shader */
@@ -243,6 +281,10 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe->delete_rasterizer_state(pipe, ctx->rs_state);
pipe->delete_vs_state(pipe, ctx->vs);
pipe->delete_vertex_elements_state(pipe, ctx->velem_state);
+ if (ctx->vertex_has_integers) {
+ pipe->delete_vertex_elements_state(pipe, ctx->velem_sint_state);
+ pipe->delete_vertex_elements_state(pipe, ctx->velem_uint_state);
+ }
for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) {
if (ctx->fs_texfetch_col[i])
@@ -251,9 +293,12 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]);
}
- for (i = 0; i <= PIPE_MAX_COLOR_BUFS; i++)
+ for (i = 0; i <= PIPE_MAX_COLOR_BUFS; i++) {
if (ctx->fs_col[i])
pipe->delete_fs_state(pipe, ctx->fs_col[i]);
+ if (ctx->fs_col_int[i])
+ pipe->delete_fs_state(pipe, ctx->fs_col_int[i]);
+ }
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS * 2; i++)
if (ctx->sampler_state[i])
@@ -263,100 +308,140 @@ void util_blitter_destroy(struct blitter_context *blitter)
FREE(ctx);
}
-static void blitter_check_saved_CSOs(struct blitter_context_priv *ctx)
+static void blitter_set_running_flag(struct blitter_context_priv *ctx)
{
if (ctx->base.running) {
- _debug_printf("u_blitter: Caught recursion on save. "
- "This is a driver bug.\n");
+ _debug_printf("u_blitter:%i: Caught recursion. This is a driver bug.\n",
+ __LINE__);
}
ctx->base.running = TRUE;
+}
- /* make sure these CSOs have been saved */
- assert(ctx->base.saved_blend_state != INVALID_PTR &&
- ctx->base.saved_dsa_state != INVALID_PTR &&
- ctx->base.saved_rs_state != INVALID_PTR &&
- ctx->base.saved_fs != INVALID_PTR &&
+static void blitter_unset_running_flag(struct blitter_context_priv *ctx)
+{
+ if (!ctx->base.running) {
+ _debug_printf("u_blitter:%i: Caught recursion. This is a driver bug.\n",
+ __LINE__);
+ }
+ ctx->base.running = FALSE;
+}
+
+static void blitter_check_saved_vertex_states(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_num_vertex_buffers != ~0 &&
+ ctx->base.saved_velem_state != INVALID_PTR &&
ctx->base.saved_vs != INVALID_PTR &&
- ctx->base.saved_velem_state != INVALID_PTR);
+ (!ctx->has_geometry_shader || ctx->base.saved_gs != INVALID_PTR) &&
+ ctx->base.saved_rs_state != INVALID_PTR);
}
-static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
+static void blitter_restore_vertex_states(struct blitter_context_priv *ctx)
{
struct pipe_context *pipe = ctx->base.pipe;
unsigned i;
- /* restore the state objects which are always required to be saved */
- pipe->bind_rasterizer_state(pipe, ctx->base.saved_rs_state);
- pipe->bind_vs_state(pipe, ctx->base.saved_vs);
+ /* Vertex buffers. */
+ pipe->set_vertex_buffers(pipe,
+ ctx->base.saved_num_vertex_buffers,
+ ctx->base.saved_vertex_buffers);
+
+ for (i = 0; i < ctx->base.saved_num_vertex_buffers; i++) {
+ if (ctx->base.saved_vertex_buffers[i].buffer) {
+ pipe_resource_reference(&ctx->base.saved_vertex_buffers[i].buffer,
+ NULL);
+ }
+ }
+ ctx->base.saved_num_vertex_buffers = ~0;
+
+ /* Vertex elements. */
pipe->bind_vertex_elements_state(pipe, ctx->base.saved_velem_state);
+ ctx->base.saved_velem_state = INVALID_PTR;
- ctx->base.saved_rs_state = INVALID_PTR;
+ /* Vertex shader. */
+ pipe->bind_vs_state(pipe, ctx->base.saved_vs);
ctx->base.saved_vs = INVALID_PTR;
- ctx->base.saved_velem_state = INVALID_PTR;
- /* restore the state objects which are required to be saved for clear/copy
- */
- if (ctx->base.saved_blend_state != INVALID_PTR) {
- pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
- ctx->base.saved_blend_state = INVALID_PTR;
- }
- if (ctx->base.saved_dsa_state != INVALID_PTR) {
- pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
- ctx->base.saved_dsa_state = INVALID_PTR;
- }
- if (ctx->base.saved_fs != INVALID_PTR) {
- pipe->bind_fs_state(pipe, ctx->base.saved_fs);
- ctx->base.saved_fs = INVALID_PTR;
+ /* Geometry shader. */
+ if (ctx->has_geometry_shader) {
+ pipe->bind_gs_state(pipe, ctx->base.saved_gs);
+ ctx->base.saved_gs = INVALID_PTR;
}
+ /* Rasterizer. */
+ pipe->bind_rasterizer_state(pipe, ctx->base.saved_rs_state);
+ ctx->base.saved_rs_state = INVALID_PTR;
+}
+
+static void blitter_check_saved_fragment_states(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_fs != INVALID_PTR &&
+ ctx->base.saved_dsa_state != INVALID_PTR &&
+ ctx->base.saved_blend_state != INVALID_PTR);
+}
+
+static void blitter_restore_fragment_states(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->base.pipe;
+
+ /* Fragment shader. */
+ pipe->bind_fs_state(pipe, ctx->base.saved_fs);
+ ctx->base.saved_fs = INVALID_PTR;
+
+ /* Depth, stencil, alpha. */
+ pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
+ ctx->base.saved_dsa_state = INVALID_PTR;
+
+ /* Blend state. */
+ pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
+ ctx->base.saved_blend_state = INVALID_PTR;
+
+ /* Miscellaneous states. */
+ /* XXX check whether these are saved and whether they need to be restored
+ * (depending on the operation) */
pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
pipe->set_viewport_state(pipe, &ctx->base.saved_viewport);
pipe->set_clip_state(pipe, &ctx->base.saved_clip);
+}
- if (ctx->base.saved_fb_state.nr_cbufs != ~0) {
- pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state);
- util_unreference_framebuffer_state(&ctx->base.saved_fb_state);
- ctx->base.saved_fb_state.nr_cbufs = ~0;
- }
+static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_fb_state.nr_cbufs != ~0);
+}
- if (ctx->base.saved_num_sampler_states != ~0) {
- pipe->bind_fragment_sampler_states(pipe,
- ctx->base.saved_num_sampler_states,
- ctx->base.saved_sampler_states);
- ctx->base.saved_num_sampler_states = ~0;
- }
+static void blitter_restore_fb_state(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->base.pipe;
- if (ctx->base.saved_num_sampler_views != ~0) {
- pipe->set_fragment_sampler_views(pipe,
- ctx->base.saved_num_sampler_views,
- ctx->base.saved_sampler_views);
+ pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state);
+ util_unreference_framebuffer_state(&ctx->base.saved_fb_state);
+}
- for (i = 0; i < ctx->base.saved_num_sampler_views; i++)
- pipe_sampler_view_reference(&ctx->base.saved_sampler_views[i],
- NULL);
+static void blitter_check_saved_textures(struct blitter_context_priv *ctx)
+{
+ assert(ctx->base.saved_num_sampler_states != ~0 &&
+ ctx->base.saved_num_sampler_views != ~0);
+}
- ctx->base.saved_num_sampler_views = ~0;
- }
+static void blitter_restore_textures(struct blitter_context_priv *ctx)
+{
+ struct pipe_context *pipe = ctx->base.pipe;
+ unsigned i;
- if (ctx->base.saved_num_vertex_buffers != ~0) {
- pipe->set_vertex_buffers(pipe,
- ctx->base.saved_num_vertex_buffers,
- ctx->base.saved_vertex_buffers);
+ /* Fragment sampler states. */
+ pipe->bind_fragment_sampler_states(pipe,
+ ctx->base.saved_num_sampler_states,
+ ctx->base.saved_sampler_states);
+ ctx->base.saved_num_sampler_states = ~0;
- for (i = 0; i < ctx->base.saved_num_vertex_buffers; i++) {
- if (ctx->base.saved_vertex_buffers[i].buffer) {
- pipe_resource_reference(&ctx->base.saved_vertex_buffers[i].buffer,
- NULL);
- }
- }
- ctx->base.saved_num_vertex_buffers = ~0;
- }
+ /* Fragment sampler views. */
+ pipe->set_fragment_sampler_views(pipe,
+ ctx->base.saved_num_sampler_views,
+ ctx->base.saved_sampler_views);
- if (!ctx->base.running) {
- _debug_printf("u_blitter: Caught recursion on restore. "
- "This is a driver bug.\n");
- }
- ctx->base.running = FALSE;
+ for (i = 0; i < ctx->base.saved_num_sampler_views; i++)
+ pipe_sampler_view_reference(&ctx->base.saved_sampler_views[i], NULL);
+
+ ctx->base.saved_num_sampler_views = ~0;
}
static void blitter_set_rectangle(struct blitter_context_priv *ctx,
@@ -404,10 +489,11 @@ static void blitter_set_clear_color(struct blitter_context_priv *ctx,
if (color) {
for (i = 0; i < 4; i++) {
- ctx->vertices[i][1][0] = color->f[0];
- ctx->vertices[i][1][1] = color->f[1];
- ctx->vertices[i][1][2] = color->f[2];
- ctx->vertices[i][1][3] = color->f[3];
+ uint32_t *uiverts = (uint32_t *)ctx->vertices[i][1];
+ uiverts[0] = color->ui[0];
+ uiverts[1] = color->ui[1];
+ uiverts[2] = color->ui[2];
+ uiverts[3] = color->ui[3];
}
} else {
for (i = 0; i < 4; i++) {
@@ -562,19 +648,28 @@ void **blitter_get_sampler_state(struct blitter_context_priv *ctx,
}
static INLINE
-void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs)
+void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs,
+ boolean int_format)
{
struct pipe_context *pipe = ctx->base.pipe;
assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
- if (!ctx->fs_col[num_cbufs])
- ctx->fs_col[num_cbufs] =
- util_make_fragment_cloneinput_shader(pipe, num_cbufs,
- TGSI_SEMANTIC_GENERIC,
- TGSI_INTERPOLATE_LINEAR);
-
- return ctx->fs_col[num_cbufs];
+ if (int_format) {
+ if (!ctx->fs_col_int[num_cbufs])
+ ctx->fs_col_int[num_cbufs] =
+ util_make_fragment_cloneinput_shader(pipe, num_cbufs,
+ TGSI_SEMANTIC_GENERIC,
+ TGSI_INTERPOLATE_CONSTANT);
+ return ctx->fs_col_int[num_cbufs];
+ } else {
+ if (!ctx->fs_col[num_cbufs])
+ ctx->fs_col[num_cbufs] =
+ util_make_fragment_cloneinput_shader(pipe, num_cbufs,
+ TGSI_SEMANTIC_GENERIC,
+ TGSI_INTERPOLATE_LINEAR);
+ return ctx->fs_col[num_cbufs];
+ }
}
/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
@@ -674,6 +769,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
+ enum pipe_format cbuf_format,
const union pipe_color_union *color,
double depth, unsigned stencil,
void *custom_blend, void *custom_dsa)
@@ -681,12 +777,14 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_stencil_ref sr = { { 0 } };
-
+ boolean int_format = util_format_is_pure_integer(cbuf_format);
assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
- blitter_check_saved_CSOs(ctx);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
- /* bind CSOs */
+ /* bind states */
if (custom_blend) {
pipe->bind_blend_state(pipe, custom_blend);
} else if (clear_buffers & PIPE_CLEAR_COLOR) {
@@ -711,25 +809,37 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
pipe->set_stencil_ref(pipe, &sr);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs));
+ if (util_format_is_pure_sint(cbuf_format)) {
+ pipe->bind_vertex_elements_state(pipe, ctx->velem_sint_state);
+ } else if (util_format_is_pure_uint(cbuf_format)) {
+ pipe->bind_vertex_elements_state(pipe, ctx->velem_uint_state);
+ } else {
+ pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
+ }
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs, int_format));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
blitter_set_dst_dimensions(ctx, width, height);
blitter->draw_rectangle(blitter, 0, 0, width, height, depth,
UTIL_BLITTER_ATTRIB_COLOR, color);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_unset_running_flag(ctx);
}
void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
+ enum pipe_format cbuf_format,
const union pipe_color_union *color,
double depth, unsigned stencil)
{
util_blitter_clear_custom(blitter, width, height, num_cbufs,
- clear_buffers, color, depth, stencil,
+ clear_buffers, cbuf_format, color, depth, stencil,
NULL, NULL);
}
@@ -739,7 +849,7 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter,
{
static const union pipe_color_union color;
util_blitter_clear_custom(blitter, width, height, 0,
- 0, &color, depth, 0, NULL, custom_dsa);
+ 0, PIPE_FORMAT_NONE, &color, depth, 0, NULL, custom_dsa);
}
static
@@ -817,10 +927,11 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
dstsurf = pipe->create_surface(pipe, dst, &surf_templ);
/* Check whether the states are properly saved. */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
- assert(blitter->saved_num_sampler_views != ~0);
- assert(blitter->saved_num_sampler_states != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_textures(ctx);
+ blitter_check_saved_fb_state(ctx);
/* Initialize framebuffer state. */
fb_state.width = dstsurf->width;
@@ -855,6 +966,8 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
/* Set rasterizer state, shaders, and textures. */
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_fragment_sampler_states(pipe, 1,
blitter_get_sampler_state(ctx, srclevel, normalized));
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
@@ -918,7 +1031,11 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
break;
}
- blitter_restore_CSOs(ctx);
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_textures(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
pipe_surface_reference(&dstsurf, NULL);
pipe_sampler_view_reference(&view, NULL);
@@ -940,15 +1057,19 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
return;
/* check the saved state */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_fb_state(ctx);
- /* bind CSOs */
+ /* bind states */
pipe->bind_blend_state(pipe, ctx->blend_write_color);
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1));
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
@@ -962,7 +1083,11 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
UTIL_BLITTER_ATTRIB_COLOR, color);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
}
/* Clear a region of a depth stencil surface. */
@@ -984,10 +1109,12 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
return;
/* check the saved state */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_fb_state(ctx);
- /* bind CSOs */
+ /* bind states */
pipe->bind_blend_state(pipe, ctx->blend_keep_color);
if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) == PIPE_CLEAR_DEPTHSTENCIL) {
sr.ref_value[0] = stencil & 0xff;
@@ -1007,8 +1134,10 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0));
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
@@ -1022,7 +1151,11 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, depth,
UTIL_BLITTER_ATTRIB_NONE, NULL);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
}
/* draw a rectangle across a region using a custom dsa stage - for r600g */
@@ -1040,16 +1173,20 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
return;
/* check the saved state */
- blitter_check_saved_CSOs(ctx);
- assert(blitter->saved_fb_state.nr_cbufs != ~0);
+ blitter_set_running_flag(ctx);
+ blitter_check_saved_vertex_states(ctx);
+ blitter_check_saved_fragment_states(ctx);
+ blitter_check_saved_fb_state(ctx);
- /* bind CSOs */
+ /* bind states */
pipe->bind_blend_state(pipe, ctx->blend_write_color);
pipe->bind_depth_stencil_alpha_state(pipe, dsa_stage);
pipe->bind_rasterizer_state(pipe, ctx->rs_state);
- pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0));
+ pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 0, FALSE));
pipe->bind_vs_state(pipe, ctx->vs);
+ if (ctx->has_geometry_shader)
+ pipe->bind_gs_state(pipe, NULL);
pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
@@ -1069,5 +1206,9 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height);
blitter->draw_rectangle(blitter, 0, 0, zsurf->width, zsurf->height, depth,
UTIL_BLITTER_ATTRIB_NONE, NULL);
- blitter_restore_CSOs(ctx);
+
+ blitter_restore_vertex_states(ctx);
+ blitter_restore_fragment_states(ctx);
+ blitter_restore_fb_state(ctx);
+ blitter_unset_running_flag(ctx);
}