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