1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2014 Broadcom 3bf215546Sopenharmony_ci * Copyright (C) 2019 Collabora, Ltd. 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22bf215546Sopenharmony_ci * SOFTWARE. 23bf215546Sopenharmony_ci * 24bf215546Sopenharmony_ci * Authors (Collabora): 25bf215546Sopenharmony_ci * Tomeu Vizoso <tomeu.vizoso@collabora.com> 26bf215546Sopenharmony_ci * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> 27bf215546Sopenharmony_ci * 28bf215546Sopenharmony_ci */ 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "pan_context.h" 31bf215546Sopenharmony_ci#include "pan_util.h" 32bf215546Sopenharmony_ci#include "util/format/u_format.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_civoid 35bf215546Sopenharmony_cipanfrost_blitter_save(struct panfrost_context *ctx, bool render_cond) 36bf215546Sopenharmony_ci{ 37bf215546Sopenharmony_ci struct blitter_context *blitter = ctx->blitter; 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci util_blitter_save_vertex_buffer_slot(blitter, ctx->vertex_buffers); 40bf215546Sopenharmony_ci util_blitter_save_vertex_elements(blitter, ctx->vertex); 41bf215546Sopenharmony_ci util_blitter_save_vertex_shader(blitter, ctx->shader[PIPE_SHADER_VERTEX]); 42bf215546Sopenharmony_ci util_blitter_save_rasterizer(blitter, ctx->rasterizer); 43bf215546Sopenharmony_ci util_blitter_save_viewport(blitter, &ctx->pipe_viewport); 44bf215546Sopenharmony_ci util_blitter_save_scissor(blitter, &ctx->scissor); 45bf215546Sopenharmony_ci util_blitter_save_fragment_shader(blitter, ctx->shader[PIPE_SHADER_FRAGMENT]); 46bf215546Sopenharmony_ci util_blitter_save_blend(blitter, ctx->blend); 47bf215546Sopenharmony_ci util_blitter_save_depth_stencil_alpha(blitter, ctx->depth_stencil); 48bf215546Sopenharmony_ci util_blitter_save_stencil_ref(blitter, &ctx->stencil_ref); 49bf215546Sopenharmony_ci util_blitter_save_so_targets(blitter, 0, NULL); 50bf215546Sopenharmony_ci util_blitter_save_sample_mask(blitter, ctx->sample_mask, ctx->min_samples); 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci util_blitter_save_framebuffer(blitter, &ctx->pipe_framebuffer); 53bf215546Sopenharmony_ci util_blitter_save_fragment_sampler_states(blitter, 54bf215546Sopenharmony_ci ctx->sampler_count[PIPE_SHADER_FRAGMENT], 55bf215546Sopenharmony_ci (void **)(&ctx->samplers[PIPE_SHADER_FRAGMENT])); 56bf215546Sopenharmony_ci util_blitter_save_fragment_sampler_views(blitter, 57bf215546Sopenharmony_ci ctx->sampler_view_count[PIPE_SHADER_FRAGMENT], 58bf215546Sopenharmony_ci (struct pipe_sampler_view **)&ctx->sampler_views[PIPE_SHADER_FRAGMENT]); 59bf215546Sopenharmony_ci util_blitter_save_fragment_constant_buffer_slot(blitter, 60bf215546Sopenharmony_ci ctx->constant_buffer[PIPE_SHADER_FRAGMENT].cb); 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci if (!render_cond) { 63bf215546Sopenharmony_ci util_blitter_save_render_condition(blitter, 64bf215546Sopenharmony_ci (struct pipe_query *) ctx->cond_query, 65bf215546Sopenharmony_ci ctx->cond_cond, ctx->cond_mode); 66bf215546Sopenharmony_ci } 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci} 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_civoid 71bf215546Sopenharmony_cipanfrost_blit(struct pipe_context *pipe, 72bf215546Sopenharmony_ci const struct pipe_blit_info *info) 73bf215546Sopenharmony_ci{ 74bf215546Sopenharmony_ci struct panfrost_context *ctx = pan_context(pipe); 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci if (info->render_condition_enable && 77bf215546Sopenharmony_ci !panfrost_render_condition_check(ctx)) 78bf215546Sopenharmony_ci return; 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci if (!util_blitter_is_blit_supported(ctx->blitter, info)) 81bf215546Sopenharmony_ci unreachable("Unsupported blit\n"); 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci panfrost_blitter_save(ctx, info->render_condition_enable); 84bf215546Sopenharmony_ci util_blitter_blit(ctx->blitter, info); 85bf215546Sopenharmony_ci} 86