xref: /aosp_15_r20/external/deqp/framework/common/tcuAstcUtil.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _TCUASTCUTIL_HPP
2 #define _TCUASTCUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2016 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief ASTC Utilities.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "tcuCompressedTexture.hpp"
28 
29 #include <vector>
30 
31 namespace tcu
32 {
33 namespace astc
34 {
35 
36 enum BlockTestType
37 {
38     BLOCK_TEST_TYPE_VOID_EXTENT_LDR = 0,
39     BLOCK_TEST_TYPE_VOID_EXTENT_HDR,
40     BLOCK_TEST_TYPE_WEIGHT_GRID,
41     BLOCK_TEST_TYPE_WEIGHT_ISE,
42     BLOCK_TEST_TYPE_CEMS,
43     BLOCK_TEST_TYPE_PARTITION_SEED,
44     BLOCK_TEST_TYPE_ENDPOINT_VALUE_LDR,
45     BLOCK_TEST_TYPE_ENDPOINT_VALUE_HDR_NO_15,
46     BLOCK_TEST_TYPE_ENDPOINT_VALUE_HDR_15,
47     BLOCK_TEST_TYPE_ENDPOINT_ISE,
48     BLOCK_TEST_TYPE_CCS,
49     BLOCK_TEST_TYPE_RANDOM,
50 
51     BLOCK_TEST_TYPE_LAST
52 };
53 
54 enum
55 {
56     BLOCK_SIZE_BYTES = 128 / 8,
57 };
58 
59 const char *getBlockTestTypeName(BlockTestType testType);
60 const char *getBlockTestTypeDescription(BlockTestType testType);
61 bool isBlockTestTypeHDROnly(BlockTestType testType);
62 Vec4 getBlockTestTypeColorScale(BlockTestType testType);
63 Vec4 getBlockTestTypeColorBias(BlockTestType testType);
64 
65 void generateBlockCaseTestData(std::vector<uint8_t> &dst, CompressedTexFormat format, BlockTestType testType);
66 
67 void generateRandomBlocks(uint8_t *dst, size_t numBlocks, CompressedTexFormat format, uint32_t seed);
68 void generateRandomValidBlocks(uint8_t *dst, size_t numBlocks, CompressedTexFormat format,
69                                TexDecompressionParams::AstcMode mode, uint32_t seed);
70 
71 void generateDefaultVoidExtentBlocks(uint8_t *dst, size_t numBlocks);
72 void generateDefaultNormalBlocks(uint8_t *dst, size_t numBlocks, int blockWidth, int blockHeight);
73 
74 bool isValidBlock(const uint8_t *data, CompressedTexFormat format, TexDecompressionParams::AstcMode mode);
75 
76 void decompress(const PixelBufferAccess &dst, const uint8_t *data, CompressedTexFormat format,
77                 TexDecompressionParams::AstcMode mode);
78 
79 } // namespace astc
80 } // namespace tcu
81 
82 #endif // _TCUASTCUTIL_HPP
83