• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTSHADERRENDER_HPP
2 #define _VKTSHADERRENDER_HPP
3 /*------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2015 The Khronos Group Inc.
8  * Copyright (c) 2015 Samsung Electronics Co., 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 Vulkan ShaderRenderCase
25  *//*--------------------------------------------------------------------*/
26 
27 #include "tcuTexture.hpp"
28 #include "tcuSurface.hpp"
29 #include "tcuMaybe.hpp"
30 
31 #include "deMemory.h"
32 #include "deSharedPtr.hpp"
33 #include "deUniquePtr.hpp"
34 
35 #include "vkDefs.hpp"
36 #include "vkRefUtil.hpp"
37 #include "vkPrograms.hpp"
38 #include "vkRef.hpp"
39 #include "vkMemUtil.hpp"
40 #include "vkBuilderUtil.hpp"
41 #include "vkTypeUtil.hpp"
42 #include "vkPlatform.hpp"
43 
44 #include "vktTestCaseUtil.hpp"
45 
46 namespace vkt
47 {
48 namespace sr
49 {
50 
51 class LineStream
52 {
53 public:
LineStream(int indent=0)54 						LineStream		(int indent = 0)	{ m_indent = indent; }
~LineStream(void)55 						~LineStream		(void)				{}
56 
str(void) const57 	const char*			str				(void) const		{ m_string = m_stream.str(); return m_string.c_str(); }
operator <<(const char * line)58 	LineStream&			operator<<		(const char* line)	{ for (int i = 0; i < m_indent; i++) { m_stream << "\t"; } m_stream << line << "\n"; return *this; }
59 
60 private:
61 	int					m_indent;
62 	std::ostringstream	m_stream;
63 	mutable std::string	m_string;
64 };
65 
66 class QuadGrid;
67 class ShaderRenderCaseInstance;
68 
69 class TextureBinding
70 {
71 public:
72 	enum Type
73 	{
74 		TYPE_NONE = 0,
75 		TYPE_1D,
76 		TYPE_2D,
77 		TYPE_3D,
78 		TYPE_CUBE_MAP,
79 		TYPE_1D_ARRAY,
80 		TYPE_2D_ARRAY,
81 		TYPE_CUBE_ARRAY,
82 
83 		TYPE_LAST
84 	};
85 
86 	enum Init
87 	{
88 		INIT_UPLOAD_DATA,
89 		INIT_CLEAR,
90 
91 		INIT_LAST
92 	};
93 
94 	struct MinMaxLod
95 	{
96 		float minLod;
97 		float maxLod;
98 
MinMaxLodvkt::sr::TextureBinding::MinMaxLod99 		MinMaxLod (float min, float max) : minLod(min), maxLod(max) {}
100 	};
101 
102 	struct Parameters
103 	{
104 		deUint32					baseMipLevel;
105 		vk::VkComponentMapping		componentMapping;
106 		vk::VkSampleCountFlagBits	samples;
107 		Init						initialization;
108 		tcu::Maybe<MinMaxLod>		minMaxLod;
109 
Parametersvkt::sr::TextureBinding::Parameters110 		Parameters (deUint32						baseMipLevel_		= 0,
111 					vk::VkComponentMapping			componentMapping_	= vk::makeComponentMappingRGBA(),
112 					vk::VkSampleCountFlagBits		samples_			= vk::VK_SAMPLE_COUNT_1_BIT,
113 					Init							initialization_		= INIT_UPLOAD_DATA,
114 					const tcu::Maybe<MinMaxLod>&	minMaxLod_			= tcu::Nothing)
115 			: baseMipLevel		(baseMipLevel_)
116 			, componentMapping	(componentMapping_)
117 			, samples			(samples_)
118 			, initialization	(initialization_)
119 			, minMaxLod			(minMaxLod_)
120 		{
121 		}
122 	};
123 
124 										TextureBinding		(const tcu::Archive&	archive,
125 															const char*				filename,
126 															const Type				type,
127 															const tcu::Sampler&		sampler);
128 
129 										TextureBinding		(const tcu::Texture1D* tex1D, const tcu::Sampler& sampler);
130 										TextureBinding		(const tcu::Texture2D* tex2D, const tcu::Sampler& sampler);
131 										TextureBinding		(const tcu::Texture3D* tex3D, const tcu::Sampler& sampler);
132 										TextureBinding		(const tcu::TextureCube* texCube, const tcu::Sampler& sampler);
133 										TextureBinding		(const tcu::Texture1DArray* tex1DArray, const tcu::Sampler& sampler);
134 										TextureBinding		(const tcu::Texture2DArray* tex2DArray, const tcu::Sampler& sampler);
135 										TextureBinding		(const tcu::TextureCubeArray* texCubeArray, const tcu::Sampler& sampler);
136 
137 										~TextureBinding		(void);
138 
getType(void) const139 	Type								getType				(void) const { return m_type;		}
getSampler(void) const140 	const tcu::Sampler&					getSampler			(void) const { return m_sampler;	}
141 
get1D(void) const142 	const tcu::Texture1D&				get1D				(void) const { DE_ASSERT(getType() == TYPE_1D && m_binding.tex1D != NULL);					return *m_binding.tex1D;		}
get2D(void) const143 	const tcu::Texture2D&				get2D				(void) const { DE_ASSERT(getType() == TYPE_2D && m_binding.tex2D != NULL);					return *m_binding.tex2D;		}
get3D(void) const144 	const tcu::Texture3D&				get3D				(void) const { DE_ASSERT(getType() == TYPE_3D && m_binding.tex3D != NULL);					return *m_binding.tex3D;		}
getCube(void) const145 	const tcu::TextureCube&				getCube				(void) const { DE_ASSERT(getType() == TYPE_CUBE_MAP && m_binding.texCube != NULL);			return *m_binding.texCube;		}
get1DArray(void) const146 	const tcu::Texture1DArray&			get1DArray			(void) const { DE_ASSERT(getType() == TYPE_1D_ARRAY && m_binding.tex1DArray != NULL);		return *m_binding.tex1DArray;	}
get2DArray(void) const147 	const tcu::Texture2DArray&			get2DArray			(void) const { DE_ASSERT(getType() == TYPE_2D_ARRAY && m_binding.tex2DArray != NULL);		return *m_binding.tex2DArray;	}
getCubeArray(void) const148 	const tcu::TextureCubeArray&		getCubeArray		(void) const { DE_ASSERT(getType() == TYPE_CUBE_ARRAY && m_binding.texCubeArray != NULL);	return *m_binding.texCubeArray;	}
149 
setParameters(const Parameters & params)150 	void								setParameters		(const Parameters& params) { m_params = params; }
getParameters(void) const151 	const Parameters&					getParameters		(void) const { return m_params; }
152 
153 private:
154 										TextureBinding		(const TextureBinding&);	// not allowed!
155 	TextureBinding&						operator=			(const TextureBinding&);	// not allowed!
156 
157 	static de::MovePtr<tcu::Texture2D>	loadTexture2D		(const tcu::Archive& archive, const char* filename);
158 
159 	Type								m_type;
160 	tcu::Sampler						m_sampler;
161 	Parameters							m_params;
162 
163 	union
164 	{
165 		const tcu::Texture1D*			tex1D;
166 		const tcu::Texture2D*			tex2D;
167 		const tcu::Texture3D*			tex3D;
168 		const tcu::TextureCube*			texCube;
169 		const tcu::Texture1DArray*		tex1DArray;
170 		const tcu::Texture2DArray*		tex2DArray;
171 		const tcu::TextureCubeArray*	texCubeArray;
172 	} m_binding;
173 };
174 
175 typedef de::SharedPtr<TextureBinding> TextureBindingSp;
176 
177 // ShaderEvalContext.
178 
179 class ShaderEvalContext
180 {
181 public:
182 	// Limits.
183 	enum
184 	{
185 		MAX_USER_ATTRIBS	= 4,
186 		MAX_TEXTURES		= 4
187 	};
188 
189 	struct ShaderSampler
190 	{
191 		tcu::Sampler					sampler;
192 		const tcu::Texture1D*			tex1D;
193 		const tcu::Texture2D*			tex2D;
194 		const tcu::Texture3D*			tex3D;
195 		const tcu::TextureCube*			texCube;
196 		const tcu::Texture1DArray*		tex1DArray;
197 		const tcu::Texture2DArray*		tex2DArray;
198 		const tcu::TextureCubeArray*	texCubeArray;
199 
ShaderSamplervkt::sr::ShaderEvalContext::ShaderSampler200 		inline ShaderSampler (void)
201 			: tex1D			(DE_NULL)
202 			, tex2D			(DE_NULL)
203 			, tex3D			(DE_NULL)
204 			, texCube		(DE_NULL)
205 			, tex1DArray	(DE_NULL)
206 			, tex2DArray	(DE_NULL)
207 			, texCubeArray	(DE_NULL)
208 		{
209 		}
210 	};
211 
212 							ShaderEvalContext		(const QuadGrid& quadGrid);
213 							~ShaderEvalContext		(void);
214 
215 	void					reset					(float sx, float sy);
216 
217 	// Inputs.
218 	tcu::Vec4				coords;
219 	tcu::Vec4				unitCoords;
220 	tcu::Vec4				constCoords;
221 
222 	tcu::Vec4				in[MAX_USER_ATTRIBS];
223 	ShaderSampler			textures[MAX_TEXTURES];
224 
225 	// Output.
226 	tcu::Vec4				color;
227 	bool					isDiscarded;
228 
229 	// Functions.
discard(void)230 	inline void				discard					(void)  { isDiscarded = true; }
231 	tcu::Vec4				texture2D				(int unitNdx, const tcu::Vec2& coords);
232 
233 private:
234 	const QuadGrid&			m_quadGrid;
235 };
236 
237 typedef void (*ShaderEvalFunc) (ShaderEvalContext& c);
238 
evalCoordsPassthroughX(ShaderEvalContext & c)239 inline void evalCoordsPassthroughX		(ShaderEvalContext& c) { c.color.x() = c.coords.x(); }
evalCoordsPassthroughXY(ShaderEvalContext & c)240 inline void evalCoordsPassthroughXY		(ShaderEvalContext& c) { c.color.xy() = c.coords.swizzle(0,1); }
evalCoordsPassthroughXYZ(ShaderEvalContext & c)241 inline void evalCoordsPassthroughXYZ	(ShaderEvalContext& c) { c.color.xyz() = c.coords.swizzle(0,1,2); }
evalCoordsPassthrough(ShaderEvalContext & c)242 inline void evalCoordsPassthrough		(ShaderEvalContext& c) { c.color = c.coords; }
evalCoordsSwizzleWZYX(ShaderEvalContext & c)243 inline void evalCoordsSwizzleWZYX		(ShaderEvalContext& c) { c.color = c.coords.swizzle(3,2,1,0); }
244 
245 // ShaderEvaluator
246 // Either inherit a class with overridden evaluate() or just pass in an evalFunc.
247 
248 class ShaderEvaluator
249 {
250 public:
251 							ShaderEvaluator			(void);
252 							ShaderEvaluator			(const ShaderEvalFunc evalFunc);
253 	virtual					~ShaderEvaluator		(void);
254 
255 	virtual void			evaluate				(ShaderEvalContext& ctx) const;
256 
257 private:
258 							ShaderEvaluator			(const ShaderEvaluator&);   // not allowed!
259 	ShaderEvaluator&		operator=				(const ShaderEvaluator&);   // not allowed!
260 
261 	const ShaderEvalFunc	m_evalFunc;
262 };
263 
264 // UniformSetup
265 
266 typedef void (*UniformSetupFunc) (ShaderRenderCaseInstance& instance, const tcu::Vec4& constCoords);
267 
268 class UniformSetup
269 {
270 public:
271 							UniformSetup			(void);
272 							UniformSetup			(const UniformSetupFunc setup);
273 	virtual					~UniformSetup			(void);
274 	virtual void			setup					(ShaderRenderCaseInstance& instance, const tcu::Vec4& constCoords) const;
275 
276 private:
277 							UniformSetup			(const UniformSetup&);	// not allowed!
278 	UniformSetup&			operator=				(const UniformSetup&);	// not allowed!
279 
280 	const UniformSetupFunc	m_setupFunc;
281 };
282 
283 typedef void (*AttributeSetupFunc) (ShaderRenderCaseInstance& instance, deUint32 numVertices);
284 
285 class ShaderRenderCase : public vkt::TestCase
286 {
287 public:
288 													ShaderRenderCase	(tcu::TestContext&			testCtx,
289 																		 const std::string&			name,
290 																		 const bool					isVertexCase,
291 																		 const ShaderEvalFunc		evalFunc,
292 																		 const UniformSetup*		uniformSetup,
293 																		 const AttributeSetupFunc	attribFunc);
294 
295 													ShaderRenderCase	(tcu::TestContext&			testCtx,
296 																		 const std::string&			name,
297 																		 const bool					isVertexCase,
298 																		 const ShaderEvaluator*		evaluator,
299 																		 const UniformSetup*		uniformSetup,
300 																		 const AttributeSetupFunc	attribFunc);
301 
302 	virtual											~ShaderRenderCase	(void);
303 	virtual	void									initPrograms		(vk::SourceCollections& programCollection) const;
304 	virtual	TestInstance*							createInstance		(Context& context) const;
305 
306 protected:
307 	std::string										m_vertShaderSource;
308 	std::string										m_fragShaderSource;
309 
310 	const bool										m_isVertexCase;
311 	const de::UniquePtr<const ShaderEvaluator>		m_evaluator;
312 	const de::UniquePtr<const UniformSetup>			m_uniformSetup;
313 	const AttributeSetupFunc						m_attribFunc;
314 };
315 
316 enum BaseUniformType
317 {
318 // Bool
319 	UB_FALSE,
320 	UB_TRUE,
321 
322 // BVec4
323 	UB4_FALSE,
324 	UB4_TRUE,
325 
326 // Integers
327 	UI_ZERO,
328 	UI_ONE,
329 	UI_TWO,
330 	UI_THREE,
331 	UI_FOUR,
332 	UI_FIVE,
333 	UI_SIX,
334 	UI_SEVEN,
335 	UI_EIGHT,
336 	UI_ONEHUNDREDONE,
337 
338 // IVec2
339 	UI2_MINUS_ONE,
340 	UI2_ZERO,
341 	UI2_ONE,
342 	UI2_TWO,
343 	UI2_THREE,
344 	UI2_FOUR,
345 	UI2_FIVE,
346 
347 // IVec3
348 	UI3_MINUS_ONE,
349 	UI3_ZERO,
350 	UI3_ONE,
351 	UI3_TWO,
352 	UI3_THREE,
353 	UI3_FOUR,
354 	UI3_FIVE,
355 
356 // IVec4
357 	UI4_MINUS_ONE,
358 	UI4_ZERO,
359 	UI4_ONE,
360 	UI4_TWO,
361 	UI4_THREE,
362 	UI4_FOUR,
363 	UI4_FIVE,
364 
365 // Float
366 	UF_ZERO,
367 	UF_ONE,
368 	UF_TWO,
369 	UF_THREE,
370 	UF_FOUR,
371 	UF_FIVE,
372 	UF_SIX,
373 	UF_SEVEN,
374 	UF_EIGHT,
375 
376 	UF_HALF,
377 	UF_THIRD,
378 	UF_FOURTH,
379 	UF_FIFTH,
380 	UF_SIXTH,
381 	UF_SEVENTH,
382 	UF_EIGHTH,
383 
384 // Vec2
385 	UV2_MINUS_ONE,
386 	UV2_ZERO,
387 	UV2_ONE,
388 	UV2_TWO,
389 	UV2_THREE,
390 
391 	UV2_HALF,
392 
393 // Vec3
394 	UV3_MINUS_ONE,
395 	UV3_ZERO,
396 	UV3_ONE,
397 	UV3_TWO,
398 	UV3_THREE,
399 
400 	UV3_HALF,
401 
402 // Vec4
403 	UV4_MINUS_ONE,
404 	UV4_ZERO,
405 	UV4_ONE,
406 	UV4_TWO,
407 	UV4_THREE,
408 
409 	UV4_HALF,
410 
411 	UV4_BLACK,
412 	UV4_GRAY,
413 	UV4_WHITE,
414 
415 // Last
416 	U_LAST
417 };
418 
419 enum BaseAttributeType
420 {
421 // User attributes
422 	A_IN0,
423 	A_IN1,
424 	A_IN2,
425 	A_IN3,
426 
427 // Matrices
428 	MAT2,
429 	MAT2x3,
430 	MAT2x4,
431 	MAT3x2,
432 	MAT3,
433 	MAT3x4,
434 	MAT4x2,
435 	MAT4x3,
436 	MAT4
437 };
438 
439 // ShaderRenderCaseInstance.
440 
441 class ShaderRenderCaseInstance : public vkt::TestInstance
442 {
443 public:
444 	enum ImageBackingMode
445 	{
446 		IMAGE_BACKING_MODE_REGULAR = 0,
447 		IMAGE_BACKING_MODE_SPARSE,
448 	};
449 
450 	// Default wertex and fragment grid sizes are used by a large collection of tests
451 	// to generate input sets. Some tests might change their behavior if the
452 	// default grid size values are altered, so care should be taken to confirm that
453 	// any changes to default values do not produce regressions.
454 	// If a particular tests needs to use a different grid size value, rather than
455 	// modifying the default grid size values for all tests, it is recommended that
456 	// the test specifies the required grid size using the gridSize parameter in the
457 	// ShaderRenderCaseInstance constuctor instead.
458 	enum
459 	{
460 		GRID_SIZE_DEFAULTS			= 0,
461 		GRID_SIZE_DEFAULT_VERTEX	= 90,
462 		GRID_SIZE_DEFAULT_FRAGMENT	= 4,
463 	};
464 
465 														ShaderRenderCaseInstance	(Context&					context);
466 														ShaderRenderCaseInstance	(Context&					context,
467 																					const bool					isVertexCase,
468 																					const ShaderEvaluator&		evaluator,
469 																					const UniformSetup&			uniformSetup,
470 																					const AttributeSetupFunc	attribFunc,
471 																					const ImageBackingMode		imageBackingMode = IMAGE_BACKING_MODE_REGULAR,
472 																					const deUint32				gridSize = static_cast<deUint32>(GRID_SIZE_DEFAULTS),
473 																					const bool					fuzzyCompare = true);
474 
475 	virtual												~ShaderRenderCaseInstance	(void);
476 	virtual tcu::TestStatus								iterate						(void);
477 
478 	void												addAttribute				(deUint32			bindingLocation,
479 																					vk::VkFormat		format,
480 																					deUint32			sizePerElement,
481 																					deUint32			count,
482 																					const void*			data);
483 	void												useAttribute				(deUint32			bindingLocation,
484 																					BaseAttributeType	type);
485 
486 	template<typename T>
487 	void												addUniform					(deUint32				bindingLocation,
488 																					vk::VkDescriptorType	descriptorType,
489 																					const T&				data);
490 	void												addUniform					(deUint32				bindingLocation,
491 																					vk::VkDescriptorType	descriptorType,
492 																					size_t					dataSize,
493 																					const void*				data);
494 	void												useUniform					(deUint32				bindingLocation,
495 																					BaseUniformType			type);
496 	void												useSampler					(deUint32				bindingLocation,
497 																					deUint32				textureId);
498 
getDefaultConstCoords(void)499 	static const tcu::Vec4								getDefaultConstCoords		(void) { return tcu::Vec4(0.125f, 0.25f, 0.5f, 1.0f); }
500 	void												setPushConstantRanges		(const deUint32 rangeCount, const vk::VkPushConstantRange* const pcRanges);
501 	virtual void										updatePushConstants			(vk::VkCommandBuffer commandBuffer, vk::VkPipelineLayout pipelineLayout);
502 
503 protected:
504 														ShaderRenderCaseInstance	(Context&					context,
505 																					 const bool					isVertexCase,
506 																					 const ShaderEvaluator*		evaluator,
507 																					 const UniformSetup*		uniformSetup,
508 																					 const AttributeSetupFunc	attribFunc,
509 																					 const ImageBackingMode		imageBackingMode = IMAGE_BACKING_MODE_REGULAR,
510 																					 const deUint32				gridSize = static_cast<deUint32>(GRID_SIZE_DEFAULTS));
511 
512 	virtual void										setup						(void);
513 	virtual void										setupUniforms				(const tcu::Vec4& constCoords);
514 	virtual void										setupDefaultInputs			(void);
515 
516 	void												render						(deUint32					numVertices,
517 																					 deUint32					numTriangles,
518 																					 const deUint16*			indices,
519 																					 const tcu::Vec4&			constCoords		= getDefaultConstCoords());
520 
521 	void												render						(deUint32					numVertices,
522 																					 deUint32					numIndices,
523 																					 const deUint16*			indices,
524 																					 vk::VkPrimitiveTopology	topology,
525 																					 const tcu::Vec4&			constCoords		= getDefaultConstCoords());
526 
getResultImage(void) const527 	const tcu::TextureLevel&							getResultImage				(void) const { return m_resultImage; }
528 
529 	const tcu::UVec2									getViewportSize				(void) const;
530 
531 	void												setSampleCount				(vk::VkSampleCountFlagBits sampleCount);
532 
533 	bool												isMultiSampling				(void) const;
534 
535 	ImageBackingMode									m_imageBackingMode;
536 
537 	deUint32											m_quadGridSize;
538 
539 protected:
540 	vk::Allocator&										m_memAlloc;
541 	const tcu::Vec4										m_clearColor;
542 	const bool											m_isVertexCase;
543 
544 	std::vector<tcu::Mat4>								m_userAttribTransforms;
545 	std::vector<TextureBindingSp>						m_textures;
546 
547 	std::string											m_vertexShaderName;
548 	std::string											m_fragmentShaderName;
549 	tcu::UVec2											m_renderSize;
550 	vk::VkFormat										m_colorFormat;
551 
552 	de::SharedPtr<vk::Unique<vk::VkCommandPool>	>		m_externalCommandPool;
553 private:
554 	typedef std::vector<tcu::ConstPixelBufferAccess>	TextureLayerData;
555 	typedef std::vector<TextureLayerData>				TextureData;
556 
557 	void												uploadImage					(const tcu::TextureFormat&		texFormat,
558 																					 const TextureData&				textureData,
559 																					 const tcu::Sampler&			refSampler,
560 																					 deUint32						mipLevels,
561 																					 deUint32						arrayLayers,
562 																					 vk::VkImage					destImage);
563 
564 	void												clearImage					(const tcu::Sampler&			refSampler,
565 																					 deUint32						mipLevels,
566 																					 deUint32						arrayLayers,
567 																					 vk::VkImage					destImage);
568 
569 	void												checkSparseSupport			(const vk::VkImageCreateInfo&	imageInfo) const;
570 #ifndef CTS_USES_VULKANSC
571 	void												uploadSparseImage			(const tcu::TextureFormat&		texFormat,
572 																					 const TextureData&				textureData,
573 																					 const tcu::Sampler&			refSampler,
574 																					 const deUint32					mipLevels,
575 																					 const deUint32					arrayLayers,
576 																					 const vk::VkImage				sparseImage,
577 																					 const vk::VkImageCreateInfo&	imageCreateInfo,
578 																					 const tcu::UVec3				texSize);
579 #endif // CTS_USES_VULKANSC
580 	void												createSamplerUniform		(deUint32						bindingLocation,
581 																					 TextureBinding::Type			textureType,
582 																					 TextureBinding::Init			textureInit,
583 																					 const tcu::TextureFormat&		texFormat,
584 																					 const tcu::UVec3				texSize,
585 																					 const TextureData&				textureData,
586 																					 const tcu::Sampler&			refSampler,
587 																					 deUint32						mipLevels,
588 																					 deUint32						arrayLayers,
589 																					 TextureBinding::Parameters		textureParams);
590 
591 	void												setupUniformData			(deUint32 bindingLocation, size_t size, const void* dataPtr);
592 
593 	void												computeVertexReference		(tcu::Surface& result, const QuadGrid& quadGrid);
594 	void												computeFragmentReference	(tcu::Surface& result, const QuadGrid& quadGrid);
595 	bool												compareImages				(const tcu::Surface&	resImage,
596 																					 const tcu::Surface&	refImage,
597 																					 float					errorThreshold);
598 
599 private:
600 	const ShaderEvaluator*								m_evaluator;
601 	const UniformSetup*									m_uniformSetup;
602 	const AttributeSetupFunc							m_attribFunc;
603 	de::MovePtr<QuadGrid>								m_quadGrid;
604 	tcu::TextureLevel									m_resultImage;
605 
606 	struct EnabledBaseAttribute
607 	{
608 		deUint32			location;
609 		BaseAttributeType	type;
610 	};
611 	std::vector<EnabledBaseAttribute>					m_enabledBaseAttributes;
612 
613 	de::MovePtr<vk::DescriptorSetLayoutBuilder>			m_descriptorSetLayoutBuilder;
614 	de::MovePtr<vk::DescriptorPoolBuilder>				m_descriptorPoolBuilder;
615 	de::MovePtr<vk::DescriptorSetUpdateBuilder>			m_descriptorSetUpdateBuilder;
616 
617 	typedef de::SharedPtr<vk::Unique<vk::VkBuffer> >		VkBufferSp;
618 	typedef de::SharedPtr<vk::Unique<vk::VkImage> >			VkImageSp;
619 	typedef de::SharedPtr<vk::Unique<vk::VkImageView> >		VkImageViewSp;
620 	typedef de::SharedPtr<vk::Unique<vk::VkSampler> >		VkSamplerSp;
621 	typedef de::SharedPtr<vk::Allocation>					AllocationSp;
622 
623 	class UniformInfo
624 	{
625 	public:
UniformInfo(void)626 									UniformInfo		(void) {}
~UniformInfo(void)627 		virtual						~UniformInfo	(void) {}
628 
629 		vk::VkDescriptorType		type;
630 		deUint32					location;
631 	};
632 
633 	class BufferUniform : public UniformInfo
634 	{
635 	public:
BufferUniform(void)636 									BufferUniform	(void) {}
~BufferUniform(void)637 		virtual						~BufferUniform	(void) {}
638 
639 		VkBufferSp					buffer;
640 		AllocationSp				alloc;
641 		vk::VkDescriptorBufferInfo	descriptor;
642 	};
643 
644 	class SamplerUniform : public UniformInfo
645 	{
646 	public:
SamplerUniform(void)647 									SamplerUniform	(void) {}
~SamplerUniform(void)648 		virtual						~SamplerUniform	(void) {}
649 
650 		VkImageSp					image;
651 		VkImageViewSp				imageView;
652 		VkSamplerSp					sampler;
653 		AllocationSp				alloc;
654 		vk::VkDescriptorImageInfo	descriptor;
655 	};
656 
657 	typedef de::SharedPtr<de::UniquePtr<UniformInfo> >	UniformInfoSp;
658 	std::vector<UniformInfoSp>							m_uniformInfos;
659 
660 	std::vector< de::SharedPtr<vk::Allocation> >		m_allocations;
661 
662 	std::vector<vk::VkVertexInputBindingDescription>	m_vertexBindingDescription;
663 	std::vector<vk::VkVertexInputAttributeDescription>	m_vertexAttributeDescription;
664 
665 	std::vector<VkBufferSp>								m_vertexBuffers;
666 	std::vector<AllocationSp>							m_vertexBufferAllocs;
667 
668 	vk::VkSampleCountFlagBits							m_sampleCount;
669 	std::vector<vk::VkPushConstantRange>				m_pushConstantRanges;
670 
671 	bool												m_fuzzyCompare;
672 protected:
673 	vk::VkDevice										getDevice						(void) const;
674 	deUint32											getUniversalQueueFamilyIndex	(void) const;
675 	deUint32											getSparseQueueFamilyIndex		(void) const;
676 	const vk::DeviceInterface&							getDeviceInterface				(void) const;
677 	vk::VkQueue											getUniversalQueue				(void) const;
678 	vk::VkQueue											getSparseQueue					(void) const;
679 	vk::VkPhysicalDevice								getPhysicalDevice				(void) const;
680 	const vk::InstanceInterface&						getInstanceInterface			(void) const;
681 	vk::Allocator&										getAllocator					(void) const;
682 };
683 
684 template<typename T>
addUniform(deUint32 bindingLocation,vk::VkDescriptorType descriptorType,const T & data)685 void ShaderRenderCaseInstance::addUniform (deUint32 bindingLocation, vk::VkDescriptorType descriptorType, const T& data)
686 {
687 	addUniform(bindingLocation, descriptorType, sizeof(T), &data);
688 }
689 
690 vk::VkImageViewType		textureTypeToImageViewType	(TextureBinding::Type type);
691 vk::VkImageType			viewTypeToImageType			(vk::VkImageViewType type);
692 vk::VkImageUsageFlags	textureUsageFlags			(void);
693 vk::VkImageCreateFlags	textureCreateFlags			(vk::VkImageViewType viewType, ShaderRenderCaseInstance::ImageBackingMode backingMode);
694 
695 } // sr
696 } // vkt
697 
698 #endif // _VKTSHADERRENDER_HPP
699