• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2016 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*
20  * \file  vktSparseResourcesShaderIntrinsics.cpp
21  * \brief Sparse Resources Shader Intrinsics
22  *//*--------------------------------------------------------------------*/
23 
24 #include "vktSparseResourcesShaderIntrinsicsSampled.hpp"
25 #include "vktSparseResourcesShaderIntrinsicsStorage.hpp"
26 
27 using namespace vk;
28 
29 namespace vkt
30 {
31 namespace sparse
32 {
33 
createSparseResourcesShaderIntrinsicsTests(tcu::TestContext & testCtx)34 tcu::TestCaseGroup* createSparseResourcesShaderIntrinsicsTests (tcu::TestContext& testCtx)
35 {
36 	de::MovePtr<tcu::TestCaseGroup> testGroup(new tcu::TestCaseGroup(testCtx, "shader_intrinsics", "Sparse Resources Shader Intrinsics"));
37 
38 	const std::vector<TestImageParameters> imageParameters =
39 	{
40 		{ IMAGE_TYPE_2D,			{ tcu::UVec3(512u, 256u, 1u),	tcu::UVec3(128u, 128u, 1u), tcu::UVec3(503u, 137u, 1u), tcu::UVec3(11u, 37u, 1u) },	getTestFormats(IMAGE_TYPE_2D) },
41 		{ IMAGE_TYPE_2D_ARRAY,		{ tcu::UVec3(512u, 256u, 6u),	tcu::UVec3(128u, 128u, 8u),	tcu::UVec3(503u, 137u, 3u),	tcu::UVec3(11u, 37u, 3u) },	getTestFormats(IMAGE_TYPE_2D_ARRAY) },
42 		{ IMAGE_TYPE_CUBE,			{ tcu::UVec3(256u, 256u, 1u),	tcu::UVec3(128u, 128u, 1u),	tcu::UVec3(137u, 137u, 1u),	tcu::UVec3(11u, 11u, 1u) },	getTestFormats(IMAGE_TYPE_CUBE) },
43 		{ IMAGE_TYPE_CUBE_ARRAY,	{ tcu::UVec3(256u, 256u, 6u),	tcu::UVec3(128u, 128u, 8u),	tcu::UVec3(137u, 137u, 3u),	tcu::UVec3(11u, 11u, 3u) },	getTestFormats(IMAGE_TYPE_CUBE_ARRAY) },
44 		{ IMAGE_TYPE_3D,			{ tcu::UVec3(256u, 256u, 16u),	tcu::UVec3(128u, 128u, 8u),	tcu::UVec3(503u, 137u, 3u),	tcu::UVec3(11u, 37u, 3u) },	getTestFormats(IMAGE_TYPE_3D) }
45 	};
46 
47 	static const std::string functions[SPARSE_SPIRV_FUNCTION_TYPE_LAST] =
48 	{
49 		"_sparse_fetch",
50 		"_sparse_read",
51 		"_sparse_sample_explicit_lod",
52 		"_sparse_sample_implicit_lod",
53 		"_sparse_gather",
54 	};
55 
56 	for (deUint32 functionNdx = 0; functionNdx < SPARSE_SPIRV_FUNCTION_TYPE_LAST; ++functionNdx)
57 	{
58 		const SpirVFunction function = static_cast<SpirVFunction>(functionNdx);
59 
60 		for (size_t imageTypeNdx = 0; imageTypeNdx < imageParameters.size(); ++imageTypeNdx)
61 		{
62 			const ImageType					imageType		= imageParameters[imageTypeNdx].imageType;
63 			de::MovePtr<tcu::TestCaseGroup> imageTypeGroup	(new tcu::TestCaseGroup(testCtx, (getImageTypeName(imageType) + functions[functionNdx]).c_str(), ""));
64 
65 			for (size_t formatNdx = 0; formatNdx < imageParameters[imageTypeNdx].formats.size(); ++formatNdx)
66 			{
67 				VkFormat						format				= imageParameters[imageTypeNdx].formats[formatNdx].format;
68 				tcu::UVec3						imageSizeAlignment	= getImageSizeAlignment(format);
69 				de::MovePtr<tcu::TestCaseGroup> formatGroup			(new tcu::TestCaseGroup(testCtx, getImageFormatID(format).c_str(), ""));
70 
71 				for (size_t imageSizeNdx = 0; imageSizeNdx < imageParameters[imageTypeNdx].imageSizes.size(); ++imageSizeNdx)
72 				{
73 					const tcu::UVec3 imageSize = imageParameters[imageTypeNdx].imageSizes[imageSizeNdx];
74 
75 					// skip test for images with odd sizes for some YCbCr formats
76 					if ((imageSize.x() % imageSizeAlignment.x()) != 0)
77 						continue;
78 					if ((imageSize.y() % imageSizeAlignment.y()) != 0)
79 						continue;
80 
81 					std::ostringstream stream;
82 					stream << imageSize.x() << "_" << imageSize.y() << "_" << imageSize.z();
83 
84 					switch (function)
85 					{
86 						case SPARSE_FETCH:
87 							if ((imageType == IMAGE_TYPE_CUBE) || (imageType == IMAGE_TYPE_CUBE_ARRAY)) continue;
88 							break;
89 						case SPARSE_SAMPLE_EXPLICIT_LOD:
90 						case SPARSE_SAMPLE_IMPLICIT_LOD:
91 						case SPARSE_GATHER:
92 							if ((imageType == IMAGE_TYPE_CUBE) || (imageType == IMAGE_TYPE_CUBE_ARRAY) || (imageType == IMAGE_TYPE_3D)) continue;
93 							break;
94 						default:
95 							break;
96 					}
97 
98 					switch (function)
99 					{
100 						case SPARSE_FETCH:
101 							formatGroup->addChild(new SparseCaseOpImageSparseFetch(testCtx, stream.str(), function, imageType, imageSize, format));
102 							break;
103 						case SPARSE_READ:
104 							formatGroup->addChild(new SparseCaseOpImageSparseRead(testCtx, stream.str(), function, imageType, imageSize, format));
105 							break;
106 						case SPARSE_SAMPLE_EXPLICIT_LOD:
107 							formatGroup->addChild(new SparseCaseOpImageSparseSampleExplicitLod(testCtx, stream.str(), function, imageType, imageSize, format));
108 							break;
109 						case SPARSE_SAMPLE_IMPLICIT_LOD:
110 							formatGroup->addChild(new SparseCaseOpImageSparseSampleImplicitLod(testCtx, stream.str(), function, imageType, imageSize, format));
111 							break;
112 						case SPARSE_GATHER:
113 							formatGroup->addChild(new SparseCaseOpImageSparseGather(testCtx, stream.str(), function, imageType, imageSize, format));
114 							break;
115 						default:
116 							DE_FATAL("Unexpected function type");
117 							break;
118 					}
119 				}
120 				imageTypeGroup->addChild(formatGroup.release());
121 			}
122 			testGroup->addChild(imageTypeGroup.release());
123 		}
124 	}
125 
126 	return testGroup.release();
127 }
128 
129 } // sparse
130 } // vkt
131