Path: blob/21.2-virgl/src/gallium/drivers/lima/lima_texture.h
4565 views
/*1* Copyright (c) 2018-2019 Lima Project2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sub license,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the11* next paragraph) shall be included in all copies or substantial portions12* of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*22*/2324#ifndef H_LIMA_TEXTURE25#define H_LIMA_TEXTURE2627#define lima_min_tex_desc_size 642829#define LIMA_TEXTURE_TYPE_2D 230#define LIMA_TEXTURE_TYPE_CUBE 53132typedef struct __attribute__((__packed__)) {33/* Word 0 */34uint32_t format : 6;35uint32_t flag1: 1;36uint32_t swap_r_b: 1;37uint32_t unknown_0_1: 8;38uint32_t stride: 15;39uint32_t unknown_0_2: 1;4041/* Word 1-3 */42uint32_t unknown_1_1: 7;43uint32_t unnorm_coords: 1;44uint32_t unknown_1_2: 1;45uint32_t texture_type: 3;46uint32_t min_lod: 8; /* Fixed point, 4.4, unsigned */47uint32_t max_lod: 8; /* Fixed point, 4.4, unsigned */48uint32_t lod_bias: 9; /* Fixed point, signed, 1.4.4 */49uint32_t unknown_2_1: 3;50uint32_t has_stride: 1;51uint32_t min_mipfilter_2: 2; /* 0x3 for linear, 0x0 for nearest */52uint32_t min_img_filter_nearest: 1;53uint32_t mag_img_filter_nearest: 1;54uint32_t wrap_s_clamp_to_edge: 1;55uint32_t wrap_s_clamp: 1;56uint32_t wrap_s_mirror_repeat: 1;57uint32_t wrap_t_clamp_to_edge: 1;58uint32_t wrap_t_clamp: 1;59uint32_t wrap_t_mirror_repeat: 1;60uint32_t unknown_2_2: 3;61uint32_t width: 13;62uint32_t height: 13;63uint32_t unknown_3_1: 1;64uint32_t unknown_3_2: 15;6566/* Word 4 */67uint32_t unknown_4;6869/* Word 5 */70uint32_t unknown_5;7172/* Word 6-15 */73/* layout is in va[0] bit 13-14 */74/* VAs start in va[0] at bit 30, each VA is 26 bits (only MSBs are stored), stored75* linearly in memory */76union {77uint32_t va[0];78struct __attribute__((__packed__)) {79uint32_t unknown_6_1: 13;80uint32_t layout: 2;81uint32_t unknown_6_2: 9;82uint32_t unknown_6_3: 6;83#define VA_BIT_OFFSET 3084#define VA_BIT_SIZE 2685uint32_t va_0: VA_BIT_SIZE;86uint32_t va_0_1: 8;87uint32_t va_1_x[0];88} va_s;89};90} lima_tex_desc;9192void lima_texture_desc_set_res(struct lima_context *ctx, lima_tex_desc *desc,93struct pipe_resource *prsc,94unsigned first_level, unsigned last_level,95unsigned first_layer);96void lima_update_textures(struct lima_context *ctx);979899static inline int16_t lima_float_to_fixed8(float f)100{101return (int)(f * 16.0);102}103104static inline float lima_fixed8_to_float(int16_t i)105{106float sign = 1.0;107108if (i > 0xff) {109i = 0x200 - i;110sign = -1;111}112113return sign * (float)(i / 16.0);114}115116#endif117118119