17ec681f3Smrg/*
27ec681f3Smrg * Copyright (C) 2014 Broadcom
37ec681f3Smrg * Copyright (C) 2019 Collabora, Ltd.
47ec681f3Smrg *
57ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
67ec681f3Smrg * copy of this software and associated documentation files (the "Software"),
77ec681f3Smrg * to deal in the Software without restriction, including without limitation
87ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
97ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the
107ec681f3Smrg * Software is furnished to do so, subject to the following conditions:
117ec681f3Smrg *
127ec681f3Smrg * The above copyright notice and this permission notice (including the next
137ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the
147ec681f3Smrg * Software.
157ec681f3Smrg *
167ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
197ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
207ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
217ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
227ec681f3Smrg * SOFTWARE.
237ec681f3Smrg *
247ec681f3Smrg * Authors (Collabora):
257ec681f3Smrg *   Tomeu Vizoso <tomeu.vizoso@collabora.com>
267ec681f3Smrg *   Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
277ec681f3Smrg *
287ec681f3Smrg */
297ec681f3Smrg
307ec681f3Smrg#include "pan_context.h"
317ec681f3Smrg#include "pan_util.h"
327ec681f3Smrg#include "util/format/u_format.h"
337ec681f3Smrg
347ec681f3Smrgstatic void
357ec681f3Smrgpanfrost_blitter_save(
367ec681f3Smrg        struct panfrost_context *ctx,
377ec681f3Smrg        struct blitter_context *blitter,
387ec681f3Smrg        bool render_cond)
397ec681f3Smrg{
407ec681f3Smrg
417ec681f3Smrg        util_blitter_save_vertex_buffer_slot(blitter, ctx->vertex_buffers);
427ec681f3Smrg        util_blitter_save_vertex_elements(blitter, ctx->vertex);
437ec681f3Smrg        util_blitter_save_vertex_shader(blitter, ctx->shader[PIPE_SHADER_VERTEX]);
447ec681f3Smrg        util_blitter_save_rasterizer(blitter, ctx->rasterizer);
457ec681f3Smrg        util_blitter_save_viewport(blitter, &ctx->pipe_viewport);
467ec681f3Smrg        util_blitter_save_scissor(blitter, &ctx->scissor);
477ec681f3Smrg        util_blitter_save_fragment_shader(blitter, ctx->shader[PIPE_SHADER_FRAGMENT]);
487ec681f3Smrg        util_blitter_save_blend(blitter, ctx->blend);
497ec681f3Smrg        util_blitter_save_depth_stencil_alpha(blitter, ctx->depth_stencil);
507ec681f3Smrg        util_blitter_save_stencil_ref(blitter, &ctx->stencil_ref);
517ec681f3Smrg        util_blitter_save_so_targets(blitter, 0, NULL);
527ec681f3Smrg        util_blitter_save_sample_mask(blitter, ctx->sample_mask);
537ec681f3Smrg
547ec681f3Smrg        util_blitter_save_framebuffer(blitter, &ctx->pipe_framebuffer);
557ec681f3Smrg        util_blitter_save_fragment_sampler_states(blitter,
567ec681f3Smrg                        ctx->sampler_count[PIPE_SHADER_FRAGMENT],
577ec681f3Smrg                        (void **)(&ctx->samplers[PIPE_SHADER_FRAGMENT]));
587ec681f3Smrg        util_blitter_save_fragment_sampler_views(blitter,
597ec681f3Smrg                        ctx->sampler_view_count[PIPE_SHADER_FRAGMENT],
607ec681f3Smrg                        (struct pipe_sampler_view **)&ctx->sampler_views[PIPE_SHADER_FRAGMENT]);
617ec681f3Smrg        util_blitter_save_fragment_constant_buffer_slot(blitter,
627ec681f3Smrg                        ctx->constant_buffer[PIPE_SHADER_FRAGMENT].cb);
637ec681f3Smrg
647ec681f3Smrg        if (!render_cond) {
657ec681f3Smrg                util_blitter_save_render_condition(blitter,
667ec681f3Smrg                                (struct pipe_query *) ctx->cond_query,
677ec681f3Smrg                                ctx->cond_cond, ctx->cond_mode);
687ec681f3Smrg        }
697ec681f3Smrg
707ec681f3Smrg}
717ec681f3Smrg
727ec681f3Smrgvoid
737ec681f3Smrgpanfrost_blit(struct pipe_context *pipe,
747ec681f3Smrg              const struct pipe_blit_info *info)
757ec681f3Smrg{
767ec681f3Smrg        struct panfrost_context *ctx = pan_context(pipe);
777ec681f3Smrg
787ec681f3Smrg        if (info->render_condition_enable &&
797ec681f3Smrg            !panfrost_render_condition_check(ctx))
807ec681f3Smrg                return;
817ec681f3Smrg
827ec681f3Smrg        if (!util_blitter_is_blit_supported(ctx->blitter, info))
837ec681f3Smrg                unreachable("Unsupported blit\n");
847ec681f3Smrg
857ec681f3Smrg        panfrost_blitter_save(ctx, ctx->blitter, info->render_condition_enable);
867ec681f3Smrg        util_blitter_blit(ctx->blitter, info);
877ec681f3Smrg}
88