Home | History | Annotate | Download | only in subgroups
      1 #ifndef _VKTSUBGROUPSTESTSUTILS_HPP
      2 #define _VKTSUBGROUPSTESTSUTILS_HPP
      3 /*------------------------------------------------------------------------
      4  * Vulkan Conformance Tests
      5  * ------------------------
      6  *
      7  * Copyright (c) 2017 The Khronos Group Inc.
      8  * Copyright (c) 2017 Codeplay Software Ltd.
      9  *
     10  * Licensed under the Apache License, Version 2.0 (the "License");
     11  * you may not use this file except in compliance with the License.
     12  * You may obtain a copy of the License at
     13  *
     14  *      http://www.apache.org/licenses/LICENSE-2.0
     15  *
     16  * Unless required by applicable law or agreed to in writing, software
     17  * distributed under the License is distributed on an "AS IS" BASIS,
     18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     19  * See the License for the specific language governing permissions and
     20  * limitations under the License.
     21  *
     22  */ /*!
     23  * \file
     24  * \brief Subgroups tests utility classes
     25  */ /*--------------------------------------------------------------------*/
     26 
     27 #include "vkBuilderUtil.hpp"
     28 #include "vkDefs.hpp"
     29 #include "vkDeviceUtil.hpp"
     30 #include "vkMemUtil.hpp"
     31 #include "vkPlatform.hpp"
     32 #include "vkPrograms.hpp"
     33 #include "vkQueryUtil.hpp"
     34 #include "vkRef.hpp"
     35 #include "vkRefUtil.hpp"
     36 #include "vkStrUtil.hpp"
     37 #include "vkTypeUtil.hpp"
     38 #include "vktTestCase.hpp"
     39 #include "vktTestCaseUtil.hpp"
     40 
     41 #include "tcuFormatUtil.hpp"
     42 #include "tcuTestLog.hpp"
     43 #include "tcuVectorUtil.hpp"
     44 
     45 #include "gluShaderUtil.hpp"
     46 
     47 #include "deSharedPtr.hpp"
     48 #include "deUniquePtr.hpp"
     49 
     50 #include <string>
     51 
     52 namespace vkt
     53 {
     54 namespace subgroups
     55 {
     56 // A struct to represent input data to a shader
     57 struct SSBOData
     58 {
     59 	SSBOData() :
     60 		initializeType(InitializeNone),
     61 		format(vk::VK_FORMAT_UNDEFINED),
     62 		numElements(0),
     63 		isImage(false) {}
     64 
     65 	enum InputDataInitializeType
     66 	{
     67 		InitializeNone = 0,
     68 		InitializeNonZero,
     69 		InitializeZero,
     70 	} initializeType;
     71 
     72 	vk::VkFormat format;
     73 	vk::VkDeviceSize numElements;
     74 	bool isImage;
     75 };
     76 
     77 std::string getSharedMemoryBallotHelper();
     78 
     79 deUint32 getSubgroupSize(Context& context);
     80 
     81 vk::VkDeviceSize maxSupportedSubgroupSize();
     82 
     83 std::string getShaderStageName(vk::VkShaderStageFlags stage);
     84 
     85 std::string getSubgroupFeatureName(vk::VkSubgroupFeatureFlagBits bit);
     86 
     87 std::string getVertShaderForStage(vk::VkShaderStageFlags stage);
     88 
     89 bool isSubgroupSupported(Context& context);
     90 
     91 bool areSubgroupOperationsSupportedForStage(
     92 	Context& context, vk::VkShaderStageFlags stage);
     93 
     94 bool areSubgroupOperationsRequiredForStage(vk::VkShaderStageFlags stage);
     95 
     96 bool isSubgroupFeatureSupportedForDevice(Context& context, vk::VkSubgroupFeatureFlagBits bit);
     97 
     98 bool isFragmentSSBOSupportedForDevice(Context& context);
     99 
    100 bool isVertexSSBOSupportedForDevice(Context& context);
    101 
    102 bool isDoubleSupportedForDevice(Context& context);
    103 
    104 bool isDoubleFormat(vk::VkFormat format);
    105 
    106 std::string getFormatNameForGLSL(vk::VkFormat format);
    107 
    108 tcu::TestStatus makeTessellationEvaluationTest(Context& context, vk::VkFormat format,
    109 	SSBOData* extraData, deUint32 extraDataCount,
    110 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
    111 
    112 tcu::TestStatus makeTessellationControlTest(Context& context, vk::VkFormat format,
    113 	SSBOData* extraData, deUint32 extraDataCount,
    114 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
    115 
    116 tcu::TestStatus makeGeometryTest(Context& context, vk::VkFormat format,
    117 	SSBOData* extraData, deUint32 extraDataCount,
    118 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
    119 
    120 tcu::TestStatus makeVertexFrameBufferTest(Context& context, vk::VkFormat format,
    121 	SSBOData* extraData, deUint32 extraDataCount,
    122 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
    123 
    124 tcu::TestStatus makeVertexTest(Context& context, vk::VkFormat format,
    125 	SSBOData* extraData, deUint32 extraDataCount,
    126 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
    127 
    128 tcu::TestStatus makeFragmentFrameBufferTest(Context& context, vk::VkFormat format,
    129 	SSBOData* extraData, deUint32 extraDataCount,
    130 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width,
    131 									 deUint32 height, deUint32 subgroupSize));
    132 
    133 tcu::TestStatus makeFragmentTest(Context& context, vk::VkFormat format,
    134 	SSBOData* extraData, deUint32 extraDataCount,
    135 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width,
    136 									 deUint32 height, deUint32 subgroupSize));
    137 
    138 tcu::TestStatus makeComputeTest(
    139 	Context& context, vk::VkFormat format, SSBOData* inputs,
    140 	deUint32 inputsCount,
    141 	bool (*checkResult)(std::vector<const void*> datas,
    142 		const deUint32 numWorkgroups[3], const deUint32 localSize[3],
    143 		deUint32 subgroupSize));
    144 } // subgroups
    145 } // vkt
    146 
    147 #endif // _VKTSUBGROUPSTESTSUTILS_HPP
    148