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