• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTPIPELINEMULTISAMPLEBASE_HPP
2 #define _VKTPIPELINEMULTISAMPLEBASE_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2016 The Khronos Group Inc.
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 vktPipelineMultisampleBase.hpp
23  * \brief Multisample Tests Base Classes
24  *//*--------------------------------------------------------------------*/
25 
26 #include "vktPipelineMultisampleTestsUtil.hpp"
27 #include "vkPipelineConstructionUtil.hpp"
28 #include "vktTestCase.hpp"
29 #include "tcuVector.hpp"
30 
31 namespace vkt
32 {
33 namespace pipeline
34 {
35 namespace multisample
36 {
37 
38 enum class ComponentSource
39 {
40 	NONE			= 0,
41 	CONSTANT		= 1,
42 	PUSH_CONSTANT	= 2,
43 };
44 
45 struct ComponentData
46 {
ComponentDatavkt::pipeline::multisample::ComponentData47 	ComponentData ()
48 		: source	{ComponentSource::NONE}
49 		, index		{0u}
50 		{}
51 
ComponentDatavkt::pipeline::multisample::ComponentData52 	ComponentData (ComponentSource source_, deUint32 index_)
53 		: source	{source_}
54 		, index		{index_}
55 		{}
56 
ComponentDatavkt::pipeline::multisample::ComponentData57 	ComponentData (const ComponentData& other)
58 		: source	{other.source}
59 		, index		{other.index}
60 		{}
61 
62 	ComponentSource	source;
63 	deUint32		index;
64 };
65 
66 struct ImageMSParams
67 {
68 	vk::PipelineConstructionType	pipelineConstructionType;
69 	vk::VkSampleCountFlagBits		numSamples;
70 	tcu::UVec3						imageSize;
71 	ComponentData					componentData;
72 };
73 
74 class MultisampleCaseBase : public TestCase
75 {
76 public:
MultisampleCaseBase(tcu::TestContext & testCtx,const std::string & name,const ImageMSParams & imageMSParams)77 	MultisampleCaseBase	(tcu::TestContext&		testCtx,
78 						 const std::string&		name,
79 						 const ImageMSParams&	imageMSParams)
80 		: TestCase(testCtx, name, "")
81 		, m_imageMSParams(imageMSParams)
82 	{}
checkSupport(Context & context) const83 	virtual void checkSupport (Context& context) const
84 	{
85 		checkGraphicsPipelineLibrarySupport(context);
86 	}
87 
88 protected:
89 
checkGraphicsPipelineLibrarySupport(Context & context) const90 	void checkGraphicsPipelineLibrarySupport(Context& context) const
91 	{
92 		checkPipelineLibraryRequirements(context.getInstanceInterface(), context.getPhysicalDevice(), m_imageMSParams.pipelineConstructionType);
93 	}
94 
95 protected:
96 	const ImageMSParams m_imageMSParams;
97 };
98 
99 typedef MultisampleCaseBase* (*MultisampleCaseFuncPtr)(tcu::TestContext& testCtx, const std::string& name, const ImageMSParams& imageMSParams);
100 
101 class MultisampleInstanceBase : public TestInstance
102 {
103 public:
MultisampleInstanceBase(Context & context,const ImageMSParams & imageMSParams)104 								MultisampleInstanceBase		(Context&							context,
105 															 const ImageMSParams&				imageMSParams)
106 		: TestInstance		(context)
107 		, m_imageMSParams	(imageMSParams)
108 		, m_imageType		(IMAGE_TYPE_2D)
109 		, m_imageFormat		(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8))
110 	{}
111 
112 	typedef std::vector<vk::VkVertexInputAttributeDescription> VertexAttribDescVec;
113 
114 	struct VertexDataDesc
115 	{
116 		vk::VkPrimitiveTopology	primitiveTopology;
117 		deUint32				verticesCount;
118 		deUint32				dataStride;
119 		vk::VkDeviceSize		dataSize;
120 		VertexAttribDescVec		vertexAttribDescVec;
121 	};
122 
123 protected:
124 
125 	void					validateImageSize			(const vk::InstanceInterface&	instance,
126 														 const vk::VkPhysicalDevice		physicalDevice,
127 														 const ImageType				imageType,
128 														 const tcu::UVec3&				imageSize) const;
129 
130 	void					validateImageFeatureFlags	(const vk::InstanceInterface&	instance,
131 														 const vk::VkPhysicalDevice		physicalDevice,
132 														 const vk::VkFormat				format,
133 														 const vk::VkFormatFeatureFlags	featureFlags) const;
134 
135 	void					validateImageInfo			(const vk::InstanceInterface&	instance,
136 														 const vk::VkPhysicalDevice		physicalDevice,
137 														 const vk::VkImageCreateInfo&	imageInfo) const;
138 
139 	virtual VertexDataDesc	getVertexDataDescripton		(void) const = 0;
140 
141 	virtual void			uploadVertexData			(const vk::Allocation&			vertexBufferAllocation,
142 														 const VertexDataDesc&			vertexDataDescripton) const = 0;
143 protected:
144 	const ImageMSParams			m_imageMSParams;
145 	const ImageType				m_imageType;
146 	const tcu::TextureFormat	m_imageFormat;
147 };
148 
149 } // multisample
150 
151 template <class CaseClass>
makeMSGroup(tcu::TestContext & testCtx,const std::string groupName,const vk::PipelineConstructionType pipelineConstructionType,const tcu::UVec3 imageSizes[],const deUint32 imageSizesElemCount,const vk::VkSampleCountFlagBits imageSamples[],const deUint32 imageSamplesElemCount,const multisample::ComponentData & componentData=multisample::ComponentData{})152 tcu::TestCaseGroup* makeMSGroup	(tcu::TestContext&							testCtx,
153 								 const std::string							groupName,
154 								 const vk::PipelineConstructionType			pipelineConstructionType,
155 								 const tcu::UVec3							imageSizes[],
156 								 const deUint32								imageSizesElemCount,
157 								 const vk::VkSampleCountFlagBits			imageSamples[],
158 								 const deUint32								imageSamplesElemCount,
159 								 const multisample::ComponentData&			componentData = multisample::ComponentData{})
160 {
161 	de::MovePtr<tcu::TestCaseGroup> caseGroup(new tcu::TestCaseGroup(testCtx, groupName.c_str(), ""));
162 
163 	for (deUint32 imageSizeNdx = 0u; imageSizeNdx < imageSizesElemCount; ++imageSizeNdx)
164 	{
165 		const tcu::UVec3	imageSize = imageSizes[imageSizeNdx];
166 		std::ostringstream	imageSizeStream;
167 
168 		imageSizeStream << imageSize.x() << "_" << imageSize.y() << "_" << imageSize.z();
169 
170 		de::MovePtr<tcu::TestCaseGroup> sizeGroup(new tcu::TestCaseGroup(testCtx, imageSizeStream.str().c_str(), ""));
171 
172 		for (deUint32 imageSamplesNdx = 0u; imageSamplesNdx < imageSamplesElemCount; ++imageSamplesNdx)
173 		{
174 			const vk::VkSampleCountFlagBits		samples			= imageSamples[imageSamplesNdx];
175 			const multisample::ImageMSParams	imageMSParams
176 			{
177 				pipelineConstructionType,
178 				samples,
179 				imageSize,
180 				componentData
181 			};
182 
183 			sizeGroup->addChild(CaseClass::createCase(testCtx, "samples_" + de::toString(samples), imageMSParams));
184 		}
185 
186 		caseGroup->addChild(sizeGroup.release());
187 	}
188 	return caseGroup.release();
189 }
190 
191 } // pipeline
192 } // vkt
193 
194 #endif // _VKTPIPELINEMULTISAMPLEBASE_HPP
195