2 * Copyright (c) 2018-2019 Lima Project
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 #ifndef H_LIMA_TEXTURE
26 #define H_LIMA_TEXTURE
28 #define lima_min_tex_desc_size 64
30 #define LIMA_TEXTURE_TYPE_2D 2
31 #define LIMA_TEXTURE_TYPE_CUBE 5
33 typedef struct __attribute__((__packed__
)) {
38 uint32_t unknown_0_1
: 8;
40 uint32_t unknown_0_2
: 1;
43 uint32_t unknown_1_1
: 7;
44 uint32_t unnorm_coords
: 1;
45 uint32_t unknown_1_2
: 1;
46 uint32_t texture_type
: 3;
47 uint32_t min_lod
: 8; /* Fixed point, 4.4, unsigned */
48 uint32_t max_lod
: 8; /* Fixed point, 4.4, unsigned */
49 uint32_t lod_bias
: 9; /* Fixed point, signed, 1.4.4 */
50 uint32_t unknown_2_1
: 3;
51 uint32_t has_stride
: 1;
52 uint32_t min_mipfilter_2
: 2; /* 0x3 for linear, 0x0 for nearest */
53 uint32_t min_img_filter_nearest
: 1;
54 uint32_t mag_img_filter_nearest
: 1;
55 uint32_t wrap_s_clamp_to_edge
: 1;
56 uint32_t wrap_s_clamp
: 1;
57 uint32_t wrap_s_mirror_repeat
: 1;
58 uint32_t wrap_t_clamp_to_edge
: 1;
59 uint32_t wrap_t_clamp
: 1;
60 uint32_t wrap_t_mirror_repeat
: 1;
61 uint32_t unknown_2_2
: 3;
64 uint32_t unknown_3_1
: 1;
65 uint32_t unknown_3_2
: 15;
74 /* layout is in va[0] bit 13-14 */
75 /* VAs start in va[0] at bit 30, each VA is 26 bits (only MSBs are stored), stored
76 * linearly in memory */
79 struct __attribute__((__packed__
)) {
80 uint32_t unknown_6_1
: 13;
82 uint32_t unknown_6_2
: 9;
83 uint32_t unknown_6_3
: 6;
84 #define VA_BIT_OFFSET 30
85 #define VA_BIT_SIZE 26
86 uint32_t va_0
: VA_BIT_SIZE
;
93 void lima_texture_desc_set_res(struct lima_context
*ctx
, lima_tex_desc
*desc
,
94 struct pipe_resource
*prsc
,
95 unsigned first_level
, unsigned last_level
);
96 void lima_update_textures(struct lima_context
*ctx
);
99 static inline int16_t lima_float_to_fixed8(float f
)
101 return (int)(f
* 16.0);
104 static inline float lima_fixed8_to_float(int16_t i
)
113 return sign
* (float)(i
/ 16.0);