1 /* 2 * Copyright (C) 2023 Amazon.com, Inc. or its affiliates 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 #ifndef __PAN_MOD_CONV_CSO_H__ 25 #define __PAN_MOD_CONV_CSO_H__ 26 27 #include "util/hash_table.h" 28 29 #include "panfrost/util/pan_ir.h" 30 #include "pan_texture.h" 31 32 struct panfrost_context; 33 struct panfrost_resource; 34 struct panfrost_screen; 35 36 struct pan_mod_convert_shader_key { 37 unsigned bpp; 38 unsigned align; 39 bool tiled; 40 }; 41 42 struct pan_mod_convert_shader_data { 43 struct pan_mod_convert_shader_key key; 44 void *afbc_size_cso; 45 void *afbc_pack_cso; 46 void *mtk_detile_cso; 47 }; 48 49 struct pan_mod_convert_shaders { 50 struct hash_table *shaders; 51 pthread_mutex_t lock; 52 }; 53 54 struct pan_afbc_block_info { 55 uint32_t size; 56 uint32_t offset; 57 }; 58 59 struct panfrost_afbc_size_info { 60 uint64_t src; 61 uint64_t metadata; 62 } PACKED; 63 64 struct panfrost_afbc_pack_info { 65 uint64_t src; 66 uint64_t dst; 67 uint64_t metadata; 68 uint32_t header_size; 69 uint32_t src_stride; 70 uint32_t dst_stride; 71 uint32_t padding[3]; // FIXME 72 } PACKED; 73 74 struct panfrost_mtk_detile_info { 75 uint32_t tiles_per_stride; 76 uint32_t src_width; 77 uint32_t src_height; 78 uint32_t dst_stride; 79 } PACKED; 80 81 void panfrost_afbc_context_init(struct panfrost_context *ctx); 82 void panfrost_afbc_context_destroy(struct panfrost_context *ctx); 83 84 struct pan_mod_convert_shader_data * 85 panfrost_get_mod_convert_shaders(struct panfrost_context *ctx, 86 struct panfrost_resource *rsrc, unsigned align); 87 88 #endif 89