-/**
- * Optimal hardware path for blitting pixels.
- * Scaling, format conversion, up- and downsampling (resolve) are allowed.
- */
-static void
-fd_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
-{
- struct fd_context *ctx = fd_context(pctx);
- struct pipe_blit_info info = *blit_info;
- bool discard = false;
-
- if (info.src.resource->nr_samples > 1 &&
- info.dst.resource->nr_samples <= 1 &&
- !util_format_is_depth_or_stencil(info.src.resource->format) &&
- !util_format_is_pure_integer(info.src.resource->format)) {
- DBG("color resolve unimplemented");
- return;
- }
-
- if (info.render_condition_enable && !fd_render_condition_check(pctx))
- return;
-
- if (!info.scissor_enable && !info.alpha_blend) {
- discard = util_texrange_covers_whole_level(info.dst.resource,
- info.dst.level, info.dst.box.x, info.dst.box.y,
- info.dst.box.z, info.dst.box.width,
- info.dst.box.height, info.dst.box.depth);
- }
-
- if (util_try_blit_via_copy_region(pctx, &info)) {
- return; /* done */
- }
-
- if (info.mask & PIPE_MASK_S) {
- DBG("cannot blit stencil, skipping");
- info.mask &= ~PIPE_MASK_S;
- }
-
- if (!util_blitter_is_blit_supported(ctx->blitter, &info)) {
- DBG("blit unsupported %s -> %s",
- util_format_short_name(info.src.resource->format),
- util_format_short_name(info.dst.resource->format));
- return;
- }
-
- fd_blitter_pipe_begin(ctx, info.render_condition_enable, discard, FD_STAGE_BLIT);
- util_blitter_blit(ctx->blitter, &info);
- fd_blitter_pipe_end(ctx);
-}
-
-void
-fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond, bool discard,
- enum fd_render_stage stage)
-{
- util_blitter_save_fragment_constant_buffer_slot(ctx->blitter,
- ctx->constbuf[PIPE_SHADER_FRAGMENT].cb);
- util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vtx.vertexbuf.vb);
- util_blitter_save_vertex_elements(ctx->blitter, ctx->vtx.vtx);
- util_blitter_save_vertex_shader(ctx->blitter, ctx->prog.vp);
- util_blitter_save_so_targets(ctx->blitter, ctx->streamout.num_targets,
- ctx->streamout.targets);
- util_blitter_save_rasterizer(ctx->blitter, ctx->rasterizer);
- util_blitter_save_viewport(ctx->blitter, &ctx->viewport);
- util_blitter_save_scissor(ctx->blitter, &ctx->scissor);
- util_blitter_save_fragment_shader(ctx->blitter, ctx->prog.fp);
- util_blitter_save_blend(ctx->blitter, ctx->blend);
- util_blitter_save_depth_stencil_alpha(ctx->blitter, ctx->zsa);
- util_blitter_save_stencil_ref(ctx->blitter, &ctx->stencil_ref);
- util_blitter_save_sample_mask(ctx->blitter, ctx->sample_mask);
- util_blitter_save_framebuffer(ctx->blitter,
- ctx->batch ? &ctx->batch->framebuffer : NULL);
- util_blitter_save_fragment_sampler_states(ctx->blitter,
- ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers,
- (void **)ctx->tex[PIPE_SHADER_FRAGMENT].samplers);
- util_blitter_save_fragment_sampler_views(ctx->blitter,
- ctx->tex[PIPE_SHADER_FRAGMENT].num_textures,
- ctx->tex[PIPE_SHADER_FRAGMENT].textures);
- if (!render_cond)
- util_blitter_save_render_condition(ctx->blitter,
- ctx->cond_query, ctx->cond_cond, ctx->cond_mode);
-
- if (ctx->batch)
- fd_batch_set_stage(ctx->batch, stage);
-
- ctx->in_blit = discard;
-}
-
-void
-fd_blitter_pipe_end(struct fd_context *ctx)
-{
- if (ctx->batch)
- fd_batch_set_stage(ctx->batch, FD_STAGE_NULL);
- ctx->in_blit = false;
-}
-
-static void
-fd_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
-{
- struct fd_resource *rsc = fd_resource(prsc);
-
- if (rsc->write_batch)
- fd_batch_flush(rsc->write_batch, true, false);
-
- assert(!rsc->write_batch);
-}
-