• 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_TEX_STATE_H
25 #define PVR_TEX_STATE_H
26 
27 #include <stdint.h>
28 #include <vulkan/vulkan.h>
29 
30 #include "hwdef/rogue_hw_defs.h"
31 #include "pvr_private.h"
32 #include "pvr_types.h"
33 #include "util/macros.h"
34 
35 /**
36  * Texture requires 32bit index lookups instead of texture coordinate access.
37  */
38 #define PVR_TEXFLAGS_INDEX_LOOKUP BITFIELD_BIT(0U)
39 
40 /** Texture has border texels present. */
41 #define PVR_TEXFLAGS_BORDER BITFIELD_BIT(1U)
42 
43 /**
44  * Resource is actually a buffer, not a texture, and therefore LOD is ignored.
45  * Coordinates are integers.
46  */
47 #define PVR_TEXFLAGS_BUFFER BITFIELD_BIT(2U)
48 
49 /** Parameters for #pvr_pack_tex_state(). */
50 struct pvr_texture_state_info {
51    VkFormat format;
52    enum pvr_memlayout mem_layout;
53    uint32_t flags;
54    VkImageViewType type;
55    bool is_cube;
56    enum pvr_texture_state tex_state_type;
57    VkExtent3D extent;
58 
59    /**
60     * For array textures, this holds the array dimension, in elements. This can
61     * be zero if texture is not an array.
62     */
63    uint32_t array_size;
64 
65    /** Base mipmap level. This is the miplevel you want as the top level. */
66    uint32_t base_level;
67 
68    /**
69     * Number of mipmap levels that should be accessed by HW. This is not
70     * necessarily the number of levels that are in memory. (See
71     * mipmaps_present)
72     */
73    uint32_t mip_levels;
74 
75    /**
76     * True if the texture is mipmapped.
77     * Note: This is based on the number of mip levels the texture contains, not
78     * on the mip levels that are being used i.e. mip_levels.
79     */
80    bool mipmaps_present;
81 
82    /**
83     * Number of samples per texel for multisampling. This should be 1 for none
84     * multisampled textures.
85     */
86    uint32_t sample_count;
87 
88    /** Stride, in pixels. Only valid if mem_layout is stride or tiled. */
89    uint32_t stride;
90 
91    /**
92     * For buffers, where TPU_BUFFER_LOOKUP is present, this defines
93     * the offset for the buffer, in texels.
94     */
95    uint32_t offset;
96 
97    /**
98     * Precomputed (composed from createinfo->components and format swizzle)
99     * swizzles to pass in to the texture state.
100     */
101    uint8_t swizzle[4];
102 
103    /** Address of texture, which must be aligned to at least 32bits. */
104    pvr_dev_addr_t addr;
105 };
106 
107 VkResult
108 pvr_pack_tex_state(struct pvr_device *device,
109                    struct pvr_texture_state_info *info,
110                    uint64_t state[static const ROGUE_NUM_TEXSTATE_IMAGE_WORDS]);
111 
112 #endif /* PVR_TEX_STATE_H */
113