1 /* 2 * Copyright (C) 2021 Collabora, Ltd. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 * 23 */ 24 25 #ifndef __PAN_BLITTER_H 26 #define __PAN_BLITTER_H 27 28 #include "genxml/gen_macros.h" 29 30 #include "panfrost-job.h" 31 #include "pan_cs.h" 32 #include "pan_pool.h" 33 #include "pan_texture.h" 34 #include "pan_util.h" 35 #include "util/format/u_format.h" 36 37 struct pan_fb_info; 38 struct pan_scoreboard; 39 struct pan_pool; 40 struct panfrost_device; 41 42 struct pan_blit_info { 43 struct { 44 struct { 45 const struct pan_image *image; 46 enum pipe_format format; 47 } planes[2]; 48 unsigned level; 49 struct { 50 int32_t x, y, z; 51 unsigned layer; 52 } start, end; 53 } src, dst; 54 struct { 55 bool enable; 56 uint16_t minx, miny, maxx, maxy; 57 } scissor; 58 bool nearest; 59 }; 60 61 struct pan_blit_context { 62 mali_ptr rsd, vpd; 63 mali_ptr textures; 64 mali_ptr samplers; 65 mali_ptr position; 66 struct { 67 enum mali_texture_dimension dim; 68 struct { 69 float x, y; 70 } start, end; 71 union { 72 unsigned layer_offset; 73 float z_offset; 74 }; 75 } src; 76 struct { 77 int32_t layer_offset; 78 int32_t cur_layer; 79 int32_t last_layer; 80 } dst; 81 float z_scale; 82 }; 83 84 void 85 GENX(pan_blitter_init)(struct panfrost_device *dev, 86 struct pan_pool *bin_pool, 87 struct pan_pool *desc_pool); 88 89 void 90 GENX(pan_blitter_cleanup)(struct panfrost_device *dev); 91 92 unsigned 93 GENX(pan_preload_fb)(struct pan_pool *desc_pool, 94 struct pan_scoreboard *scoreboard, 95 struct pan_fb_info *fb, 96 mali_ptr tsd, mali_ptr tiler, 97 struct panfrost_ptr *jobs); 98 99 void 100 GENX(pan_blit_ctx_init)(struct panfrost_device *dev, 101 const struct pan_blit_info *info, 102 struct pan_pool *blit_pool, 103 struct pan_blit_context *ctx); 104 105 static inline bool 106 pan_blit_next_surface(struct pan_blit_context *ctx) 107 { 108 if (ctx->dst.last_layer < ctx->dst.layer_offset) { 109 if (ctx->dst.cur_layer <= ctx->dst.last_layer) 110 return false; 111 112 ctx->dst.cur_layer--; 113 } else { 114 if (ctx->dst.cur_layer >= ctx->dst.last_layer) 115 return false; 116 117 ctx->dst.cur_layer++; 118 } 119 120 return true; 121 } 122 123 struct panfrost_ptr 124 GENX(pan_blit)(struct pan_blit_context *ctx, 125 struct pan_pool *pool, 126 struct pan_scoreboard *scoreboard, 127 mali_ptr tsd, mali_ptr tiler); 128 129 #endif 130