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 std::string& description,
291 const bool isVertexCase,
292 const ShaderEvalFunc evalFunc,
293 const UniformSetup* uniformSetup,
294 const AttributeSetupFunc attribFunc);
295
296 ShaderRenderCase (tcu::TestContext& testCtx,
297 const std::string& name,
298 const std::string& description,
299 const bool isVertexCase,
300 const ShaderEvaluator* evaluator,
301 const UniformSetup* uniformSetup,
302 const AttributeSetupFunc attribFunc);
303
304 virtual ~ShaderRenderCase (void);
305 virtual void initPrograms (vk::SourceCollections& programCollection) const;
306 virtual TestInstance* createInstance (Context& context) const;
307
308 protected:
309 std::string m_vertShaderSource;
310 std::string m_fragShaderSource;
311
312 const bool m_isVertexCase;
313 const de::UniquePtr<const ShaderEvaluator> m_evaluator;
314 const de::UniquePtr<const UniformSetup> m_uniformSetup;
315 const AttributeSetupFunc m_attribFunc;
316 };
317
318 enum BaseUniformType
319 {
320 // Bool
321 UB_FALSE,
322 UB_TRUE,
323
324 // BVec4
325 UB4_FALSE,
326 UB4_TRUE,
327
328 // Integers
329 UI_ZERO,
330 UI_ONE,
331 UI_TWO,
332 UI_THREE,
333 UI_FOUR,
334 UI_FIVE,
335 UI_SIX,
336 UI_SEVEN,
337 UI_EIGHT,
338 UI_ONEHUNDREDONE,
339
340 // IVec2
341 UI2_MINUS_ONE,
342 UI2_ZERO,
343 UI2_ONE,
344 UI2_TWO,
345 UI2_THREE,
346 UI2_FOUR,
347 UI2_FIVE,
348
349 // IVec3
350 UI3_MINUS_ONE,
351 UI3_ZERO,
352 UI3_ONE,
353 UI3_TWO,
354 UI3_THREE,
355 UI3_FOUR,
356 UI3_FIVE,
357
358 // IVec4
359 UI4_MINUS_ONE,
360 UI4_ZERO,
361 UI4_ONE,
362 UI4_TWO,
363 UI4_THREE,
364 UI4_FOUR,
365 UI4_FIVE,
366
367 // Float
368 UF_ZERO,
369 UF_ONE,
370 UF_TWO,
371 UF_THREE,
372 UF_FOUR,
373 UF_FIVE,
374 UF_SIX,
375 UF_SEVEN,
376 UF_EIGHT,
377
378 UF_HALF,
379 UF_THIRD,
380 UF_FOURTH,
381 UF_FIFTH,
382 UF_SIXTH,
383 UF_SEVENTH,
384 UF_EIGHTH,
385
386 // Vec2
387 UV2_MINUS_ONE,
388 UV2_ZERO,
389 UV2_ONE,
390 UV2_TWO,
391 UV2_THREE,
392
393 UV2_HALF,
394
395 // Vec3
396 UV3_MINUS_ONE,
397 UV3_ZERO,
398 UV3_ONE,
399 UV3_TWO,
400 UV3_THREE,
401
402 UV3_HALF,
403
404 // Vec4
405 UV4_MINUS_ONE,
406 UV4_ZERO,
407 UV4_ONE,
408 UV4_TWO,
409 UV4_THREE,
410
411 UV4_HALF,
412
413 UV4_BLACK,
414 UV4_GRAY,
415 UV4_WHITE,
416
417 // Last
418 U_LAST
419 };
420
421 enum BaseAttributeType
422 {
423 // User attributes
424 A_IN0,
425 A_IN1,
426 A_IN2,
427 A_IN3,
428
429 // Matrices
430 MAT2,
431 MAT2x3,
432 MAT2x4,
433 MAT3x2,
434 MAT3,
435 MAT3x4,
436 MAT4x2,
437 MAT4x3,
438 MAT4
439 };
440
441 // ShaderRenderCaseInstance.
442
443 class ShaderRenderCaseInstance : public vkt::TestInstance
444 {
445 public:
446 enum ImageBackingMode
447 {
448 IMAGE_BACKING_MODE_REGULAR = 0,
449 IMAGE_BACKING_MODE_SPARSE,
450 };
451
452 // Default wertex and fragment grid sizes are used by a large collection of tests
453 // to generate input sets. Some tests might change their behavior if the
454 // default grid size values are altered, so care should be taken to confirm that
455 // any changes to default values do not produce regressions.
456 // If a particular tests needs to use a different grid size value, rather than
457 // modifying the default grid size values for all tests, it is recommended that
458 // the test specifies the required grid size using the gridSize parameter in the
459 // ShaderRenderCaseInstance constuctor instead.
460 enum
461 {
462 GRID_SIZE_DEFAULTS = 0,
463 GRID_SIZE_DEFAULT_VERTEX = 90,
464 GRID_SIZE_DEFAULT_FRAGMENT = 4,
465 };
466
467 ShaderRenderCaseInstance (Context& context);
468 ShaderRenderCaseInstance (Context& context,
469 const bool isVertexCase,
470 const ShaderEvaluator& evaluator,
471 const UniformSetup& uniformSetup,
472 const AttributeSetupFunc attribFunc,
473 const ImageBackingMode imageBackingMode = IMAGE_BACKING_MODE_REGULAR,
474 const deUint32 gridSize = static_cast<deUint32>(GRID_SIZE_DEFAULTS),
475 const bool fuzzyCompare = true);
476
477 virtual ~ShaderRenderCaseInstance (void);
478 virtual tcu::TestStatus iterate (void);
479
480 void addAttribute (deUint32 bindingLocation,
481 vk::VkFormat format,
482 deUint32 sizePerElement,
483 deUint32 count,
484 const void* data);
485 void useAttribute (deUint32 bindingLocation,
486 BaseAttributeType type);
487
488 template<typename T>
489 void addUniform (deUint32 bindingLocation,
490 vk::VkDescriptorType descriptorType,
491 const T& data);
492 void addUniform (deUint32 bindingLocation,
493 vk::VkDescriptorType descriptorType,
494 size_t dataSize,
495 const void* data);
496 void useUniform (deUint32 bindingLocation,
497 BaseUniformType type);
498 void useSampler (deUint32 bindingLocation,
499 deUint32 textureId);
500
getDefaultConstCoords(void)501 static const tcu::Vec4 getDefaultConstCoords (void) { return tcu::Vec4(0.125f, 0.25f, 0.5f, 1.0f); }
502 void setPushConstantRanges (const deUint32 rangeCount, const vk::VkPushConstantRange* const pcRanges);
503 virtual void updatePushConstants (vk::VkCommandBuffer commandBuffer, vk::VkPipelineLayout pipelineLayout);
504
505 protected:
506 ShaderRenderCaseInstance (Context& context,
507 const bool isVertexCase,
508 const ShaderEvaluator* evaluator,
509 const UniformSetup* uniformSetup,
510 const AttributeSetupFunc attribFunc,
511 const ImageBackingMode imageBackingMode = IMAGE_BACKING_MODE_REGULAR,
512 const deUint32 gridSize = static_cast<deUint32>(GRID_SIZE_DEFAULTS));
513
514 virtual void setup (void);
515 virtual void setupUniforms (const tcu::Vec4& constCoords);
516 virtual void setupDefaultInputs (void);
517
518 void render (deUint32 numVertices,
519 deUint32 numTriangles,
520 const deUint16* indices,
521 const tcu::Vec4& constCoords = getDefaultConstCoords());
522
523 void render (deUint32 numVertices,
524 deUint32 numIndices,
525 const deUint16* indices,
526 vk::VkPrimitiveTopology topology,
527 const tcu::Vec4& constCoords = getDefaultConstCoords());
528
getResultImage(void) const529 const tcu::TextureLevel& getResultImage (void) const { return m_resultImage; }
530
531 const tcu::UVec2 getViewportSize (void) const;
532
533 void setSampleCount (vk::VkSampleCountFlagBits sampleCount);
534
535 bool isMultiSampling (void) const;
536
537 ImageBackingMode m_imageBackingMode;
538
539 deUint32 m_quadGridSize;
540
541 protected:
542 vk::Allocator& m_memAlloc;
543 const tcu::Vec4 m_clearColor;
544 const bool m_isVertexCase;
545
546 std::vector<tcu::Mat4> m_userAttribTransforms;
547 std::vector<TextureBindingSp> m_textures;
548
549 std::string m_vertexShaderName;
550 std::string m_fragmentShaderName;
551 tcu::UVec2 m_renderSize;
552 vk::VkFormat m_colorFormat;
553
554 private:
555 typedef std::vector<tcu::ConstPixelBufferAccess> TextureLayerData;
556 typedef std::vector<TextureLayerData> TextureData;
557
558 void uploadImage (const tcu::TextureFormat& texFormat,
559 const TextureData& textureData,
560 const tcu::Sampler& refSampler,
561 deUint32 mipLevels,
562 deUint32 arrayLayers,
563 vk::VkImage destImage);
564
565 void clearImage (const tcu::Sampler& refSampler,
566 deUint32 mipLevels,
567 deUint32 arrayLayers,
568 vk::VkImage destImage);
569
570 void checkSparseSupport (const vk::VkImageCreateInfo& imageInfo) const;
571
572 void uploadSparseImage (const tcu::TextureFormat& texFormat,
573 const TextureData& textureData,
574 const tcu::Sampler& refSampler,
575 const deUint32 mipLevels,
576 const deUint32 arrayLayers,
577 const vk::VkImage sparseImage,
578 const vk::VkImageCreateInfo& imageCreateInfo,
579 const tcu::UVec3 texSize);
580
581 void createSamplerUniform (deUint32 bindingLocation,
582 TextureBinding::Type textureType,
583 TextureBinding::Init textureInit,
584 const tcu::TextureFormat& texFormat,
585 const tcu::UVec3 texSize,
586 const TextureData& textureData,
587 const tcu::Sampler& refSampler,
588 deUint32 mipLevels,
589 deUint32 arrayLayers,
590 TextureBinding::Parameters textureParams);
591
592 void setupUniformData (deUint32 bindingLocation, size_t size, const void* dataPtr);
593
594 void computeVertexReference (tcu::Surface& result, const QuadGrid& quadGrid);
595 void computeFragmentReference (tcu::Surface& result, const QuadGrid& quadGrid);
596 bool compareImages (const tcu::Surface& resImage,
597 const tcu::Surface& refImage,
598 float errorThreshold);
599
600 private:
601 const ShaderEvaluator* m_evaluator;
602 const UniformSetup* m_uniformSetup;
603 const AttributeSetupFunc m_attribFunc;
604 de::MovePtr<QuadGrid> m_quadGrid;
605 tcu::TextureLevel m_resultImage;
606
607 struct EnabledBaseAttribute
608 {
609 deUint32 location;
610 BaseAttributeType type;
611 };
612 std::vector<EnabledBaseAttribute> m_enabledBaseAttributes;
613
614 de::MovePtr<vk::DescriptorSetLayoutBuilder> m_descriptorSetLayoutBuilder;
615 de::MovePtr<vk::DescriptorPoolBuilder> m_descriptorPoolBuilder;
616 de::MovePtr<vk::DescriptorSetUpdateBuilder> m_descriptorSetUpdateBuilder;
617
618 typedef de::SharedPtr<vk::Unique<vk::VkBuffer> > VkBufferSp;
619 typedef de::SharedPtr<vk::Unique<vk::VkImage> > VkImageSp;
620 typedef de::SharedPtr<vk::Unique<vk::VkImageView> > VkImageViewSp;
621 typedef de::SharedPtr<vk::Unique<vk::VkSampler> > VkSamplerSp;
622 typedef de::SharedPtr<vk::Allocation> AllocationSp;
623
624 class UniformInfo
625 {
626 public:
UniformInfo(void)627 UniformInfo (void) {}
~UniformInfo(void)628 virtual ~UniformInfo (void) {}
629
630 vk::VkDescriptorType type;
631 deUint32 location;
632 };
633
634 class BufferUniform : public UniformInfo
635 {
636 public:
BufferUniform(void)637 BufferUniform (void) {}
~BufferUniform(void)638 virtual ~BufferUniform (void) {}
639
640 VkBufferSp buffer;
641 AllocationSp alloc;
642 vk::VkDescriptorBufferInfo descriptor;
643 };
644
645 class SamplerUniform : public UniformInfo
646 {
647 public:
SamplerUniform(void)648 SamplerUniform (void) {}
~SamplerUniform(void)649 virtual ~SamplerUniform (void) {}
650
651 VkImageSp image;
652 VkImageViewSp imageView;
653 VkSamplerSp sampler;
654 AllocationSp alloc;
655 vk::VkDescriptorImageInfo descriptor;
656 };
657
658 typedef de::SharedPtr<de::UniquePtr<UniformInfo> > UniformInfoSp;
659 std::vector<UniformInfoSp> m_uniformInfos;
660
661 std::vector< de::SharedPtr<vk::Allocation> > m_allocations;
662
663 std::vector<vk::VkVertexInputBindingDescription> m_vertexBindingDescription;
664 std::vector<vk::VkVertexInputAttributeDescription> m_vertexAttributeDescription;
665
666 std::vector<VkBufferSp> m_vertexBuffers;
667 std::vector<AllocationSp> m_vertexBufferAllocs;
668
669 vk::VkSampleCountFlagBits m_sampleCount;
670 std::vector<vk::VkPushConstantRange> m_pushConstantRanges;
671
672 bool m_fuzzyCompare;
673
674 vk::VkDevice getDevice (void) const;
675 deUint32 getUniversalQueueFamilyIndex (void) const;
676 deUint32 getSparseQueueFamilyIndex (void) const;
677 const vk::DeviceInterface& getDeviceInterface (void) const;
678 vk::VkQueue getUniversalQueue (void) const;
679 vk::VkQueue getSparseQueue (void) const;
680 vk::VkPhysicalDevice getPhysicalDevice (void) const;
681 const vk::InstanceInterface& getInstanceInterface (void) const;
682 vk::Allocator& getAllocator (void) const;
683 };
684
685 template<typename T>
addUniform(deUint32 bindingLocation,vk::VkDescriptorType descriptorType,const T & data)686 void ShaderRenderCaseInstance::addUniform (deUint32 bindingLocation, vk::VkDescriptorType descriptorType, const T& data)
687 {
688 addUniform(bindingLocation, descriptorType, sizeof(T), &data);
689 }
690
691 vk::VkImageViewType textureTypeToImageViewType (TextureBinding::Type type);
692 vk::VkImageType viewTypeToImageType (vk::VkImageViewType type);
693 vk::VkImageUsageFlags textureUsageFlags (void);
694 vk::VkImageCreateFlags textureCreateFlags (vk::VkImageViewType viewType, ShaderRenderCaseInstance::ImageBackingMode backingMode);
695
696 } // sr
697 } // vkt
698
699 #endif // _VKTSHADERRENDER_HPP
700