return true;
}
-static bool
-vc4_render_blit(struct pipe_context *ctx, struct pipe_blit_info *info)
+void
+vc4_blitter_save(struct vc4_context *vc4)
{
- struct vc4_context *vc4 = vc4_context(ctx);
-
- if (!util_blitter_is_blit_supported(vc4->blitter, info)) {
- fprintf(stderr, "blit unsupported %s -> %s\n",
- util_format_short_name(info->src.resource->format),
- util_format_short_name(info->dst.resource->format));
- return false;
- }
-
util_blitter_save_vertex_buffer_slot(vc4->blitter, vc4->vertexbuf.vb);
util_blitter_save_vertex_elements(vc4->blitter, vc4->vtx);
util_blitter_save_vertex_shader(vc4->blitter, vc4->prog.bind_vs);
(void **)vc4->fragtex.samplers);
util_blitter_save_fragment_sampler_views(vc4->blitter,
vc4->fragtex.num_textures, vc4->fragtex.textures);
+}
+
+static bool
+vc4_render_blit(struct pipe_context *ctx, struct pipe_blit_info *info)
+{
+ struct vc4_context *vc4 = vc4_context(ctx);
+
+ if (!util_blitter_is_blit_supported(vc4->blitter, info)) {
+ fprintf(stderr, "blit unsupported %s -> %s\n",
+ util_format_short_name(info->src.resource->format),
+ util_format_short_name(info->dst.resource->format));
+ return false;
+ }
+ vc4_blitter_save(vc4);
util_blitter_blit(vc4->blitter, info);
return true;
const uint8_t *vc4_get_format_swizzle(enum pipe_format f);
void vc4_init_query_functions(struct vc4_context *vc4);
void vc4_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info);
+void vc4_blitter_save(struct vc4_context *vc4);
#endif /* VC4_CONTEXT_H */
* IN THE SOFTWARE.
*/
+#include "util/u_blitter.h"
#include "util/u_prim.h"
#include "util/u_format.h"
#include "util/u_pack_color.h"
vc4_flush(pctx);
}
+ /* Clearing ZS will clear both Z and stencil, so if we're trying to
+ * clear just one then we need to draw a quad to do it instead.
+ */
+ if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) != 0 &&
+ (buffers & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL &&
+ util_format_is_depth_and_stencil(vc4->framebuffer.zsbuf->format)) {
+ vc4_blitter_save(vc4);
+ util_blitter_clear(vc4->blitter,
+ vc4->framebuffer.width,
+ vc4->framebuffer.height,
+ 1,
+ buffers & PIPE_CLEAR_DEPTHSTENCIL,
+ NULL, depth, stencil);
+ buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
+ if (!buffers)
+ return;
+ }
+
if (buffers & PIPE_CLEAR_COLOR0) {
vc4->clear_color[0] = vc4->clear_color[1] =
pack_rgba(vc4->framebuffer.cbufs[0]->format,
color->f);
}
- if (buffers & PIPE_CLEAR_DEPTH) {
+ if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
/* Though the depth buffer is stored with Z in the high 24,
* for this field we just need to store it in the low 24.
*/
vc4->clear_depth = util_pack_z(PIPE_FORMAT_Z24X8_UNORM, depth);
- }
-
- if (buffers & PIPE_CLEAR_STENCIL)
vc4->clear_stencil = stencil;
+ }
vc4->draw_min_x = 0;
vc4->draw_min_y = 0;