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 		layout			(LayoutStd140),
     62 		format			(vk::VK_FORMAT_UNDEFINED),
     63 		numElements		(0),
     64 		isImage			(false),
     65 		binding			(0u),
     66 		stages			((vk::VkShaderStageFlagBits)0u)
     67 	{}
     68 
     69 	enum InputDataInitializeType
     70 	{
     71 		InitializeNone = 0,
     72 		InitializeNonZero,
     73 		InitializeZero,
     74 	} initializeType;
     75 
     76 	enum InputDataLayoutType
     77 	{
     78 		LayoutStd140 = 0,
     79 		LayoutStd430,
     80 		LayoutPacked
     81 	} layout;
     82 
     83 	vk::VkFormat				format;
     84 	vk::VkDeviceSize			numElements;
     85 	bool						isImage;
     86 	deUint32					binding;
     87 	vk::VkShaderStageFlagBits	stages;
     88 };
     89 
     90 std::string getSharedMemoryBallotHelper();
     91 
     92 deUint32 getSubgroupSize(Context& context);
     93 
     94 vk::VkDeviceSize maxSupportedSubgroupSize();
     95 
     96 std::string getShaderStageName(vk::VkShaderStageFlags stage);
     97 
     98 std::string getSubgroupFeatureName(vk::VkSubgroupFeatureFlagBits bit);
     99 
    100 void addNoSubgroupShader (vk::SourceCollections& programCollection);
    101 
    102 std::string getVertShaderForStage(vk::VkShaderStageFlags stage);//TODO
    103 
    104 bool isSubgroupSupported(Context& context);
    105 
    106 bool areSubgroupOperationsSupportedForStage(
    107 	Context& context, vk::VkShaderStageFlags stage);
    108 
    109 bool areSubgroupOperationsRequiredForStage(vk::VkShaderStageFlags stage);
    110 
    111 bool isSubgroupFeatureSupportedForDevice(Context& context, vk::VkSubgroupFeatureFlagBits bit);
    112 
    113 bool isFragmentSSBOSupportedForDevice(Context& context);
    114 
    115 bool isVertexSSBOSupportedForDevice(Context& context);
    116 
    117 bool isDoubleSupportedForDevice(Context& context);
    118 
    119 bool isDoubleFormat(vk::VkFormat format);
    120 
    121 std::string getFormatNameForGLSL(vk::VkFormat format);
    122 
    123 void addGeometryShadersFromTemplate (const std::string& glslTemplate, const vk::ShaderBuildOptions& options, vk::GlslSourceCollection& collection);
    124 void addGeometryShadersFromTemplate (const std::string& spirvTemplate, const vk::SpirVAsmBuildOptions& options, vk::SpirVAsmCollection& collection);
    125 
    126 void setVertexShaderFrameBuffer (vk::SourceCollections& programCollection);
    127 
    128 void setFragmentShaderFrameBuffer (vk::SourceCollections& programCollection);
    129 
    130 void setFragmentShaderFrameBuffer (vk::SourceCollections& programCollection);
    131 
    132 void setTesCtrlShaderFrameBuffer (vk::SourceCollections& programCollection);
    133 
    134 void setTesEvalShaderFrameBuffer (vk::SourceCollections& programCollection);
    135 
    136 bool check(std::vector<const void*> datas,
    137 	deUint32 width, deUint32 ref);
    138 
    139 bool checkCompute(std::vector<const void*> datas,
    140 	const deUint32 numWorkgroups[3], const deUint32 localSize[3],
    141 	deUint32 ref);
    142 
    143 tcu::TestStatus makeTessellationEvaluationFrameBufferTest(Context& context, vk::VkFormat format,
    144 	SSBOData* extraData, deUint32 extraDataCount,
    145 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize),
    146 	const vk::VkShaderStageFlags shaderStage = vk::VK_SHADER_STAGE_ALL_GRAPHICS);
    147 
    148 tcu::TestStatus makeGeometryFrameBufferTest(Context& context, vk::VkFormat format, SSBOData* extraData,
    149 	deUint32 extraDataCount,
    150 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
    151 
    152 tcu::TestStatus allStages(Context& context, vk::VkFormat format,
    153 	SSBOData* extraData, deUint32 extraDataCount,
    154 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize),
    155 	const vk::VkShaderStageFlags shaderStage);
    156 
    157 tcu::TestStatus makeVertexFrameBufferTest(Context& context, vk::VkFormat format,
    158 	SSBOData* extraData, deUint32 extraDataCount,
    159 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width, deUint32 subgroupSize));
    160 
    161 tcu::TestStatus makeFragmentFrameBufferTest(Context& context, vk::VkFormat format,
    162 	SSBOData* extraData, deUint32 extraDataCount,
    163 	bool (*checkResult)(std::vector<const void*> datas, deUint32 width,
    164 									 deUint32 height, deUint32 subgroupSize));
    165 
    166 tcu::TestStatus makeComputeTest(
    167 	Context& context, vk::VkFormat format, SSBOData* inputs,
    168 	deUint32 inputsCount,
    169 	bool (*checkResult)(std::vector<const void*> datas,
    170 		const deUint32 numWorkgroups[3], const deUint32 localSize[3],
    171 		deUint32 subgroupSize));
    172 } // subgroups
    173 } // vkt
    174 
    175 #endif // _VKTSUBGROUPSTESTSUTILS_HPP
    176