Home | History | Annotate | Download | only in sparse_resources
      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 
     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 	static const deUint32 sizeCountPerImageType = 4u;
     39 
     40 	struct ImageParameters
     41 	{
     42 		ImageType	imageType;
     43 		tcu::UVec3	imageSizes[sizeCountPerImageType];
     44 	};
     45 
     46 	static const ImageParameters imageParametersArray[] =
     47 	{
     48 		{ IMAGE_TYPE_2D,		{ tcu::UVec3(512u, 256u, 1u),	tcu::UVec3(128u, 128u, 1u), tcu::UVec3(503u, 137u, 1u), tcu::UVec3(11u, 37u, 1u) } },
     49 		{ IMAGE_TYPE_2D_ARRAY,	{ tcu::UVec3(512u, 256u, 6u),	tcu::UVec3(128u, 128u, 8u),	tcu::UVec3(503u, 137u, 3u),	tcu::UVec3(11u, 37u, 3u) } },
     50 		{ IMAGE_TYPE_CUBE,		{ tcu::UVec3(256u, 256u, 1u),	tcu::UVec3(128u, 128u, 1u),	tcu::UVec3(137u, 137u, 1u),	tcu::UVec3(11u, 11u, 1u) } },
     51 		{ IMAGE_TYPE_CUBE_ARRAY,{ tcu::UVec3(256u, 256u, 6u),	tcu::UVec3(128u, 128u, 8u),	tcu::UVec3(137u, 137u, 3u),	tcu::UVec3(11u, 11u, 3u) } },
     52 		{ IMAGE_TYPE_3D,		{ tcu::UVec3(256u, 256u, 16u),	tcu::UVec3(128u, 128u, 8u),	tcu::UVec3(503u, 137u, 3u),	tcu::UVec3(11u, 37u, 3u) } }
     53 	};
     54 
     55 	static const tcu::TextureFormat formats[] =
     56 	{
     57 		tcu::TextureFormat(tcu::TextureFormat::R,	 tcu::TextureFormat::SIGNED_INT32),
     58 		tcu::TextureFormat(tcu::TextureFormat::R,	 tcu::TextureFormat::SIGNED_INT16),
     59 		tcu::TextureFormat(tcu::TextureFormat::R,	 tcu::TextureFormat::SIGNED_INT8),
     60 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNSIGNED_INT32),
     61 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNSIGNED_INT16),
     62 		tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNSIGNED_INT8)
     63 	};
     64 
     65 	static const std::string functions[SPARSE_SPIRV_FUNCTION_TYPE_LAST] =
     66 	{
     67 		"_sparse_fetch",
     68 		"_sparse_read",
     69 		"_sparse_sample_explicit_lod",
     70 		"_sparse_sample_implicit_lod",
     71 		"_sparse_gather",
     72 	};
     73 
     74 	for (deUint32 functionNdx = 0; functionNdx < SPARSE_SPIRV_FUNCTION_TYPE_LAST; ++functionNdx)
     75 	{
     76 		const SpirVFunction function = static_cast<SpirVFunction>(functionNdx);
     77 
     78 		for (deInt32 imageTypeNdx = 0; imageTypeNdx < DE_LENGTH_OF_ARRAY(imageParametersArray); ++imageTypeNdx)
     79 		{
     80 			const ImageType					imageType = imageParametersArray[imageTypeNdx].imageType;
     81 			de::MovePtr<tcu::TestCaseGroup> imageTypeGroup(new tcu::TestCaseGroup(testCtx, (getImageTypeName(imageType) + functions[functionNdx]).c_str(), ""));
     82 
     83 			for (deInt32 formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); ++formatNdx)
     84 			{
     85 				const tcu::TextureFormat&		format = formats[formatNdx];
     86 				de::MovePtr<tcu::TestCaseGroup> formatGroup(new tcu::TestCaseGroup(testCtx, getShaderImageFormatQualifier(format).c_str(), ""));
     87 
     88 				for (deInt32 imageSizeNdx = 0; imageSizeNdx < DE_LENGTH_OF_ARRAY(imageParametersArray[imageTypeNdx].imageSizes); ++imageSizeNdx)
     89 				{
     90 					const tcu::UVec3 imageSize = imageParametersArray[imageTypeNdx].imageSizes[imageSizeNdx];
     91 
     92 					std::ostringstream stream;
     93 					stream << imageSize.x() << "_" << imageSize.y() << "_" << imageSize.z();
     94 
     95 					switch (function)
     96 					{
     97 					case SPARSE_FETCH:
     98 						if ((imageType == IMAGE_TYPE_CUBE) || (imageType == IMAGE_TYPE_CUBE_ARRAY)) continue;
     99 						break;
    100 					case SPARSE_SAMPLE_EXPLICIT_LOD:
    101 					case SPARSE_SAMPLE_IMPLICIT_LOD:
    102 					case SPARSE_GATHER:
    103 						if ((imageType == IMAGE_TYPE_CUBE) || (imageType == IMAGE_TYPE_CUBE_ARRAY) || (imageType == IMAGE_TYPE_3D)) continue;
    104 						break;
    105 					default:
    106 						break;
    107 					}
    108 
    109 					switch (function)
    110 					{
    111 					case SPARSE_FETCH:
    112 						formatGroup->addChild(new SparseCaseOpImageSparseFetch(testCtx, stream.str(), function, imageType, imageSize, format));
    113 						break;
    114 					case SPARSE_READ:
    115 						formatGroup->addChild(new SparseCaseOpImageSparseRead(testCtx, stream.str(), function, imageType, imageSize, format));
    116 						break;
    117 					case SPARSE_SAMPLE_EXPLICIT_LOD:
    118 						formatGroup->addChild(new SparseCaseOpImageSparseSampleExplicitLod(testCtx, stream.str(), function, imageType, imageSize, format));
    119 						break;
    120 					case SPARSE_SAMPLE_IMPLICIT_LOD:
    121 						formatGroup->addChild(new SparseCaseOpImageSparseSampleImplicitLod(testCtx, stream.str(), function, imageType, imageSize, format));
    122 						break;
    123 					case SPARSE_GATHER:
    124 						formatGroup->addChild(new SparseCaseOpImageSparseGather(testCtx, stream.str(), function, imageType, imageSize, format));
    125 						break;
    126 					default:
    127 						DE_ASSERT(0);
    128 						break;
    129 					}
    130 				}
    131 				imageTypeGroup->addChild(formatGroup.release());
    132 			}
    133 			testGroup->addChild(imageTypeGroup.release());
    134 		}
    135 	}
    136 
    137 	return testGroup.release();
    138 }
    139 
    140 } // sparse
    141 } // vkt
    142