| 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 |
|
| 33 |
#include "pvr_csb_enum_helpers.h" |
| 34 |
#include "pvr_macros.h" |
| 35 |
#include "pvr_types.h" |
| 36 |
|
| 37 |
enum pvr_pbe_gamma { |
| 38 |
PVR_PBE_GAMMA_NONE, |
| 39 |
/* For two-channel pack formats. */ |
| 40 |
PVR_PBE_GAMMA_RED, |
| 41 |
PVR_PBE_GAMMA_REDGREEN, |
| 42 |
/* For all other pack formats. */ |
| 43 |
PVR_PBE_GAMMA_ENABLED, |
| 44 |
}; |
| 45 |
|
| 46 |
/** |
| 47 |
* These are parameters specific to the surface being set up and hence can be |
| 48 |
* typically set up at surface creation time. |
| 49 |
*/ |
| 50 |
struct pvr_pbe_surf_params { |
| 51 |
/* Swizzle for a format can be retrieved using pvr_get_format_swizzle(). */ |
| 52 |
uint8_t swizzle[4]; |
| 53 |
/* is_normalized can be retrieved using pvr_vk_format_is_fully_normalized(). |
| 54 |
*/ |
| 55 |
bool is_normalized; |
| 56 |
/* pbe_packmode can be retrieved using pvr_get_pbe_packmode(). */ |
| 57 |
uint32_t pbe_packmode; |
| 58 |
/* source_format and gamma can be retrieved using |
| 59 |
* pvr_pbe_get_src_format_and_gamma(). |
| 60 |
*/ |
| 61 |
uint32_t source_format; |
| 62 |
enum pvr_pbe_gamma gamma; |
| 63 |
/* nr_components can be retrieved using vk_format_get_nr_components(). */ |
| 64 |
uint32_t nr_components; |
| 65 |
|
| 66 |
/* When an RT of MRT is packed using less USC outputs, this flag needs to be |
| 67 |
* setup to true. |
| 68 |
* |
| 69 |
* Currently, this flag is only considered when has_usc_f16_sop is enabled. |
| 70 |
* And it needs to be true when a render target by default should use F16 |
| 71 |
* USC channel but uses U8 channel instead for squeezing into on-chip MRT. |
| 72 |
* |
| 73 |
* It is better to make this member with FF_ACCUMFORMAT type or, at least, |
| 74 |
* describe USC channel size. But for now, only use this flag for |
| 75 |
* simplicity. |
| 76 |
*/ |
| 77 |
|
| 78 |
pvr_dev_addr_t addr; |
| 79 |
enum pvr_memlayout mem_layout; |
| 80 |
uint32_t stride; |
| 81 |
|
| 82 |
/* Depth size for renders */ |
| 83 |
uint32_t depth; |
| 84 |
|
| 85 |
/* Pre-rotation dimensions of surface */ |
| 86 |
uint32_t width; |
| 87 |
uint32_t height; |
| 88 |
|
| 89 |
bool z_only_render; |
| 90 |
bool down_scale; |
| 91 |
}; |
| 92 |
|
| 93 |
/** |
| 94 |
* These parameters are generally render-specific and need to be set up at the |
| 95 |
* time #pvr_pbe_pack_state() is called. |
| 96 |
*/ |
| 97 |
struct pvr_pbe_render_params { |
| 98 |
/* Clipping params are in terms of pixels and are inclusive. */ |
| 99 |
uint32_t min_x_clip; |
| 100 |
uint32_t max_x_clip; |
| 101 |
|
| 102 |
uint32_t min_y_clip; |
| 103 |
uint32_t max_y_clip; |
| 104 |
|
| 105 |
/* Start position of pixels to be read within 128bit USC output buffer. */ |
| 106 |
enum pvr_pbe_source_start_pos source_start; |
| 107 |
|
| 108 |
/* 9-bit slice number to be used when memlayout is 3D twiddle. */ |
| 109 |
uint32_t slice; |
| 110 |
|
| 111 |
/* Index */ |
| 112 |
uint32_t mrt_index; |
| 113 |
}; |
| 114 |
|
| 115 |
#ifdef PVR_PER_ARCH |
| 116 |
|
| 117 |
void PVR_PER_ARCH(pbe_pack_state)( |
| 118 |
const struct pvr_device_info *dev_info, |
| 119 |
const struct pvr_pbe_surf_params *surface_params, |
| 120 |
const struct pvr_pbe_render_params *render_params, |
| 121 |
uint32_t pbe_cs_words[static const ROGUE_NUM_PBESTATE_STATE_WORDS], |
| 122 |
uint64_t pbe_reg_words[static const ROGUE_NUM_PBESTATE_REG_WORDS]); |
| 123 |
|
| 124 |
# define pvr_arch_pbe_pack_state PVR_PER_ARCH(pbe_pack_state) |
| 125 |
|
| 126 |
/* Helper to calculate pvr_pbe_surf_params::gamma and |
| 127 |
* pvr_pbe_surf_params::source_format. |
| 128 |
*/ |
| 129 |
void PVR_PER_ARCH(pbe_get_src_format_and_gamma)( |
| 130 |
VkFormat vk_format, |
| 131 |
enum pvr_pbe_gamma default_gamma, |
| 132 |
bool with_packed_usc_channel, |
| 133 |
uint32_t *const src_format_out, |
| 134 |
enum pvr_pbe_gamma *const gamma_out); |
| 135 |
|
| 136 |
# define pvr_arch_pbe_get_src_format_and_gamma \ |
| 137 |
PVR_PER_ARCH(pbe_get_src_format_and_gamma) |
| 138 |
|
| 139 |
void PVR_PER_ARCH(setup_tiles_in_flight)( |
| 140 |
const struct pvr_device_info *dev_info, |
| 141 |
const struct pvr_device_runtime_info *dev_runtime_info, |
| 142 |
uint32_t msaa_mode, |
| 143 |
uint32_t pixel_width, |
| 144 |
bool paired_tiles, |
| 145 |
uint32_t max_tiles_in_flight, |
| 146 |
uint32_t *const isp_ctl_out, |
| 147 |
uint32_t *const pixel_ctl_out); |
| 148 |
|
| 149 |
# define pvr_arch_setup_tiles_in_flight PVR_PER_ARCH(setup_tiles_in_flight) |
| 150 |
|
| 151 |
#endif /* PVR_PER_ARCH */ |
| 152 |
|
| 153 |
#endif /* PVR_JOB_COMMON_H */ |