1 /* 2 * Copyright © 2022 Imagination Technologies Ltd. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * 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 THE 18 * 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 PVR_JOB_COMMON_H 25 #define PVR_JOB_COMMON_H 26 27 #include <stdbool.h> 28 #include <stdint.h> 29 #include <vulkan/vulkan.h> 30 31 #include "hwdef/rogue_hw_defs.h" 32 #include "pvr_private.h" 33 #include "pvr_types.h" 34 35 enum pvr_pbe_gamma { 36 PVR_PBE_GAMMA_NONE, 37 /* For two-channel pack formats. */ 38 PVR_PBE_GAMMA_RED, 39 PVR_PBE_GAMMA_REDGREEN, 40 /* For all other pack formats. */ 41 PVR_PBE_GAMMA_ENABLED, 42 }; 43 44 enum pvr_pbe_source_start_pos { 45 PVR_PBE_STARTPOS_BIT0, 46 PVR_PBE_STARTPOS_BIT32, 47 PVR_PBE_STARTPOS_BIT64, 48 PVR_PBE_STARTPOS_BIT96, 49 /* The below ones are available if has_eight_output_registers feature is 50 * enabled. 51 */ 52 PVR_PBE_STARTPOS_BIT128, 53 PVR_PBE_STARTPOS_BIT160, 54 PVR_PBE_STARTPOS_BIT192, 55 PVR_PBE_STARTPOS_BIT224, 56 }; 57 58 /** 59 * These are parameters specific to the surface being set up and hence can be 60 * typically set up at surface creation time. 61 */ 62 struct pvr_pbe_surf_params { 63 /* Swizzle for a format can be retrieved using pvr_get_format_swizzle(). */ 64 uint8_t swizzle[4]; 65 /* is_normalized can be retrieved using vk_format_is_normalized(). */ 66 bool is_normalized; 67 /* pbe_packmode can be retrieved using pvr_get_pbe_packmode(). */ 68 uint32_t pbe_packmode; 69 /* source_format and gamma can be retrieved using 70 * pvr_pbe_get_src_format_and_gamma(). 71 */ 72 uint32_t source_format; 73 enum pvr_pbe_gamma gamma; 74 /* nr_components can be retrieved using vk_format_get_nr_components(). */ 75 uint32_t nr_components; 76 77 /* When an RT of MRT is packed using less USC outputs, this flag needs to be 78 * setup to true. 79 * 80 * Currently, this flag is only considered when has_usc_f16_sop is enabled. 81 * And it needs to be true when a render target by default should use F16 82 * USC channel but uses U8 channel instead for squeezing into on-chip MRT. 83 * 84 * It is better to make this member with FF_ACCUMFORMAT type or, at least, 85 * describe USC channel size. But for now, only use this flag for 86 * simplicity. 87 */ 88 89 pvr_dev_addr_t addr; 90 enum pvr_memlayout mem_layout; 91 uint32_t stride; 92 93 /* Depth size for renders */ 94 uint32_t depth; 95 96 /* Pre-rotation dimensions of surface */ 97 uint32_t width; 98 uint32_t height; 99 100 bool z_only_render; 101 bool down_scale; 102 uint32_t msaa_mode; 103 }; 104 105 /** 106 * These parameters are generally render-specific and need to be set up at the 107 * time #pvr_pbe_pack_state() is called. 108 */ 109 struct pvr_pbe_render_params { 110 /* Clipping params are in terms of pixels and are inclusive. */ 111 uint32_t min_x_clip; 112 uint32_t max_x_clip; 113 114 uint32_t min_y_clip; 115 uint32_t max_y_clip; 116 117 /* Start position of pixels to be read within 128bit USC output buffer. */ 118 enum pvr_pbe_source_start_pos source_start; 119 120 /* 9-bit slice number to be used when memlayout is 3D twiddle. */ 121 uint32_t slice; 122 123 /* Index */ 124 uint32_t mrt_index; 125 }; 126 127 void pvr_pbe_pack_state( 128 const struct pvr_device_info *dev_info, 129 const struct pvr_pbe_surf_params *surface_params, 130 const struct pvr_pbe_render_params *render_params, 131 uint32_t pbe_cs_words[static const ROGUE_NUM_PBESTATE_STATE_WORDS], 132 uint64_t pbe_reg_words[static const ROGUE_NUM_PBESTATE_REG_WORDS]); 133 134 /* Helper to calculate pvr_pbe_surf_params::gamma and 135 * pvr_pbe_surf_params::source_format. 136 */ 137 void pvr_pbe_get_src_format_and_gamma(VkFormat vk_format, 138 enum pvr_pbe_gamma default_gamma, 139 bool with_packed_usc_channel, 140 uint32_t *const src_format_out, 141 enum pvr_pbe_gamma *const gamma_out); 142 143 void pvr_setup_tiles_in_flight( 144 const struct pvr_device_info *dev_info, 145 const struct pvr_device_runtime_info *dev_runtime_info, 146 uint32_t msaa_mode, 147 uint32_t pixel_width, 148 bool paired_tiles, 149 uint32_t max_tiles_in_flight, 150 uint32_t *const isp_ctl_out, 151 uint32_t *const pixel_ctl_out); 152 153 #endif /* PVR_JOB_COMMON_H */ 154