1 /*
2 * Copyright © 2022 Intel Corporation
3 *
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, sublicense,
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:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 #include "texcompress_astc_luts_wrap.h"
24 #include "texcompress_astc_luts.h"
25
26 extern "C" void
_mesa_init_astc_decoder_luts(astc_decoder_lut_holder * holder)27 _mesa_init_astc_decoder_luts(astc_decoder_lut_holder *holder)
28 {
29 auto &luts = Granite::get_astc_luts();
30
31 holder->color_endpoint.data = luts.color_endpoint.lut;
32 holder->color_endpoint.size_B = sizeof(luts.color_endpoint.lut);
33 holder->color_endpoint.format = PIPE_FORMAT_R16G16B16A16_UINT;
34
35 holder->color_endpoint_unquant.data = luts.color_endpoint.unquant_lut;
36 holder->color_endpoint_unquant.size_B = luts.color_endpoint.unquant_offset;
37 holder->color_endpoint_unquant.format = PIPE_FORMAT_R8_UINT;
38
39 holder->weights.data = luts.weights.lut;
40 holder->weights.size_B = sizeof(luts.weights.lut);
41 holder->weights.format = PIPE_FORMAT_R8G8B8A8_UINT;
42
43 holder->weights_unquant.data = luts.weights.unquant_lut;
44 holder->weights_unquant.size_B = luts.weights.unquant_offset;
45 holder->weights_unquant.format = PIPE_FORMAT_R8_UINT;
46
47 holder->trits_quints.data = luts.integer.trits_quints;
48 holder->trits_quints.size_B = sizeof(luts.integer.trits_quints);
49 holder->trits_quints.format = PIPE_FORMAT_R16_UINT;
50 }
51
52 extern "C" void *
_mesa_get_astc_decoder_partition_table(uint32_t block_width,uint32_t block_height,unsigned * lut_width,unsigned * lut_height)53 _mesa_get_astc_decoder_partition_table(uint32_t block_width,
54 uint32_t block_height,
55 unsigned *lut_width,
56 unsigned *lut_height)
57 {
58 auto &luts = Granite::get_astc_luts();
59 auto &table = luts.get_partition_table(block_width, block_height);
60
61 *lut_width = table.lut_width;
62 *lut_height = table.lut_height;
63 return table.lut_buffer.data();
64 }
65