pan_cs.h revision 7ec681f3
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 * Authors: 24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> 25 * Boris Brezillon <boris.brezillon@collabora.com> 26 */ 27 28#ifndef __PAN_CS_H 29#define __PAN_CS_H 30 31#include "genxml/gen_macros.h" 32 33#include "pan_texture.h" 34 35struct pan_compute_dim { 36 uint32_t x, y, z; 37}; 38 39struct pan_fb_color_attachment { 40 const struct pan_image_view *view; 41 bool *crc_valid; 42 bool clear; 43 bool preload; 44 bool discard; 45 uint32_t clear_value[4]; 46}; 47 48struct pan_fb_zs_attachment { 49 struct { 50 const struct pan_image_view *zs, *s; 51 } view; 52 53 struct { 54 bool z, s; 55 } clear; 56 57 struct { 58 bool z, s; 59 } discard; 60 61 struct { 62 bool z, s; 63 } preload; 64 65 struct { 66 float depth; 67 uint8_t stencil; 68 } clear_value; 69}; 70 71struct pan_tiler_context { 72 union { 73 mali_ptr bifrost; 74 struct { 75 bool disable; 76 struct panfrost_bo *polygon_list; 77 } midgard; 78 }; 79}; 80 81struct pan_tls_info { 82 struct { 83 mali_ptr ptr; 84 unsigned size; 85 } tls; 86 87 struct { 88 struct pan_compute_dim dim; 89 mali_ptr ptr; 90 unsigned size; 91 } wls; 92}; 93 94struct pan_fb_bifrost_info { 95 struct { 96 struct panfrost_ptr dcds; 97 unsigned modes[3]; 98 } pre_post; 99}; 100 101struct pan_fb_info { 102 unsigned width, height; 103 struct { 104 /* Max values are inclusive */ 105 unsigned minx, miny, maxx, maxy; 106 } extent; 107 unsigned nr_samples; 108 unsigned rt_count; 109 struct pan_fb_color_attachment rts[8]; 110 struct pan_fb_zs_attachment zs; 111 112 struct { 113 unsigned stride; 114 mali_ptr base; 115 } tile_map; 116 117 union { 118 struct pan_fb_bifrost_info bifrost; 119 }; 120}; 121 122static inline unsigned 123pan_wls_instances(const struct pan_compute_dim *dim) 124{ 125 return util_next_power_of_two(dim->x) * 126 util_next_power_of_two(dim->y) * 127 util_next_power_of_two(dim->z); 128} 129 130static inline unsigned 131pan_wls_adjust_size(unsigned wls_size) 132{ 133 return util_next_power_of_two(MAX2(wls_size, 128)); 134} 135 136static inline unsigned 137pan_wls_mem_size(const struct panfrost_device *dev, 138 const struct pan_compute_dim *dim, 139 unsigned wls_size) 140{ 141 unsigned instances = pan_wls_instances(dim); 142 143 return pan_wls_adjust_size(wls_size) * instances * dev->core_count; 144} 145 146#ifdef PAN_ARCH 147void 148GENX(pan_emit_tls)(const struct pan_tls_info *info, 149 void *out); 150 151int 152GENX(pan_select_crc_rt)(const struct pan_fb_info *fb); 153 154static inline bool 155pan_fbd_has_zs_crc_ext(const struct pan_fb_info *fb) 156{ 157 return PAN_ARCH >= 5 && 158 (fb->zs.view.zs || fb->zs.view.s || 159 GENX(pan_select_crc_rt)(fb) >= 0); 160} 161 162unsigned 163GENX(pan_emit_fbd)(const struct panfrost_device *dev, 164 const struct pan_fb_info *fb, 165 const struct pan_tls_info *tls, 166 const struct pan_tiler_context *tiler_ctx, 167 void *out); 168 169#if PAN_ARCH >= 6 170void 171GENX(pan_emit_tiler_heap)(const struct panfrost_device *dev, 172 void *out); 173 174void 175GENX(pan_emit_tiler_ctx)(const struct panfrost_device *dev, 176 unsigned fb_width, unsigned fb_height, 177 unsigned nr_samples, 178 mali_ptr heap, 179 void *out); 180#endif 181 182void 183GENX(pan_emit_fragment_job)(const struct pan_fb_info *fb, 184 mali_ptr fbd, 185 void *out); 186#endif /* ifdef PAN_ARCH */ 187 188#endif 189