Merge vk-gl-cts/vulkan-cts-1.1.0 into vk-gl-cts/vulkan-cts-1.1.1
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / spirv_assembly / vktSpvAsmGraphicsShaderTestUtil.hpp
1 #ifndef _VKTSPVASMGRAPHICSSHADERTESTUTIL_HPP
2 #define _VKTSPVASMGRAPHICSSHADERTESTUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2017 Google 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
23  * \brief Graphics pipeline and helper functions for SPIR-V assembly tests
24  *//*--------------------------------------------------------------------*/
25
26 #include "tcuCommandLine.hpp"
27 #include "tcuRGBA.hpp"
28
29 #include "vkPrograms.hpp"
30 #include "vktSpvAsmComputeShaderTestUtil.hpp"
31 #include "vktSpvAsmUtils.hpp"
32 #include "vktTestCaseUtil.hpp"
33
34 #include "deRandom.hpp"
35 #include "deSharedPtr.hpp"
36
37 #include <map>
38 #include <sstream>
39 #include <string>
40 #include <utility>
41
42 namespace vkt
43 {
44 namespace SpirVAssembly
45 {
46
47 typedef vk::Unique<VkBuffer>                                                                            BufferHandleUp;
48 typedef vk::Unique<VkImage>                                                                                     ImageHandleUp;
49 typedef vk::Unique<VkImageView>                                                                         ImageViewHandleUp;
50 typedef vk::Unique<VkSampler>                                                                           SamplerHandleUp;
51 typedef de::SharedPtr<BufferHandleUp>                                                           BufferHandleSp;
52 typedef de::SharedPtr<ImageHandleUp>                                                            ImageHandleSp;
53 typedef de::SharedPtr<ImageViewHandleUp>                                                        ImageViewHandleSp;
54 typedef de::SharedPtr<SamplerHandleUp>                                                          SamplerHandleSp;
55 typedef vk::Unique<vk::VkShaderModule>                                                          ModuleHandleUp;
56 typedef de::SharedPtr<ModuleHandleUp>                                                           ModuleHandleSp;
57 typedef std::pair<std::string, vk::VkShaderStageFlagBits>                       EntryToStage;
58 typedef std::map<std::string, std::vector<EntryToStage> >                       ModuleMap;
59 typedef std::map<vk::VkShaderStageFlagBits, std::vector<deInt32> >      StageToSpecConstantMap;
60 typedef std::pair<vk::VkDescriptorType, BufferSp>                                       Resource;
61
62 enum NumberType
63 {
64         NUMBERTYPE_INT32,
65         NUMBERTYPE_UINT32,
66         NUMBERTYPE_FLOAT32,
67         NUMBERTYPE_END32,               // Marks the end of 32-bit scalar types
68         NUMBERTYPE_INT16,
69         NUMBERTYPE_UINT16,
70         NUMBERTYPE_FLOAT16,
71 };
72
73 typedef enum RoundingModeFlags_e
74 {
75         ROUNDINGMODE_RTE = 0x1, // Round to nearest even
76         ROUNDINGMODE_RTZ = 0x2, // Round to zero
77 } RoundingModeFlags;
78
79 typedef bool (*GraphicsVerifyIOFunc) (const std::vector<Resource>&              inputs,
80                                                                           const std::vector<AllocationSp>&      outputAllocations,
81                                                                           const std::vector<Resource>&          expectedOutputs,
82                                                                           tcu::TestLog&                                         log);
83
84 typedef bool (*GraphicsVerifyBinaryFunc) (const ProgramBinary&  binary);
85
86 // Resources used by graphics-pipeline-based tests.
87 struct GraphicsResources
88 {
89         // Resources used as inputs.
90         std::vector<Resource>           inputs;
91         // Resources used as outputs. The data supplied will be used as
92         // the expected outputs for the corresponding bindings by default.
93         // If other behaviors are needed, please provide a custom verifyIO.
94         std::vector<Resource>           outputs;
95         // If null, a default verification will be performed by comparing the
96         // memory pointed to by outputAllocations  and the contents of
97         // expectedOutputs. Otherwise the function pointed to by verifyIO will
98         // be called. If true is returned, then the test case is assumed to
99         // have passed, if false is returned, then the test case is assumed
100         // to have failed.
101         GraphicsVerifyIOFunc            verifyIO;
102         GraphicsVerifyBinaryFunc        verifyBinary;
103         SpirvVersion                            spirvVersion;
104
105                                                         GraphicsResources()
106                                                                 : verifyIO              (DE_NULL)
107                                                                 , verifyBinary  (DE_NULL)
108                                                                 , spirvVersion  (SPIRV_VERSION_1_0)
109                                                         {}
110 };
111
112 // Interface data type.
113 struct IFDataType
114 {
115                                                 IFDataType                      (deUint32 numE, NumberType elementT)
116                                                         : numElements   (numE)
117                                                         , elementType   (elementT)
118                                                 {
119                                                         DE_ASSERT(numE > 0 && numE < 5);
120                                                         DE_ASSERT(elementT != NUMBERTYPE_END32);
121                                                 }
122
123                                                 IFDataType                      (const IFDataType& that)
124                                                         : numElements   (that.numElements)
125                                                         , elementType   (that.elementType)
126                                                 {}
127
128         deUint32                        getElementNumBytes      (void) const;
129         deUint32                        getNumBytes                     (void) const { return numElements * getElementNumBytes(); }
130
131         vk::VkFormat            getVkFormat                     (void) const;
132
133         tcu::TextureFormat      getTextureFormat        (void) const;
134
135         std::string                     str                                     (void) const;
136
137         bool                            elementIs32bit          (void) const { return elementType < NUMBERTYPE_END32; }
138         bool                            isVector                        (void) const { return numElements > 1; }
139
140         deUint32                        numElements;
141         NumberType                      elementType;
142 };
143
144 typedef std::pair<IFDataType, BufferSp>                 Interface;
145
146 // Interface variables used by graphics-pipeline-based tests.
147 class GraphicsInterfaces
148 {
149 public:
150                                                 GraphicsInterfaces      ()
151                                                         : rndMode       (static_cast<RoundingModeFlags>(0))
152                                                 {}
153
154                                                 GraphicsInterfaces      (const GraphicsInterfaces& that)
155                                                         : inputs        (that.inputs)
156                                                         , outputs       (that.outputs)
157                                                         , rndMode       (that.rndMode)
158                                                 {}
159
160         void                            setInputOutput          (const Interface& input, const Interface&  output)
161                                                 {
162                                                         inputs.clear();
163                                                         outputs.clear();
164                                                         inputs.push_back(input);
165                                                         outputs.push_back(output);
166                                                 }
167
168         const IFDataType&       getInputType            (void) const
169                                                 {
170                                                         DE_ASSERT(inputs.size() == 1);
171                                                         return inputs.front().first;
172                                                 }
173
174         const IFDataType&       getOutputType           (void) const
175                                                 {
176                                                         DE_ASSERT(outputs.size() == 1);
177                                                         return outputs.front().first;
178                                                 }
179
180         const BufferSp&         getInputBuffer          (void) const
181                                                 {
182                                                         DE_ASSERT(inputs.size() == 1);
183                                                         return inputs.front().second;
184                                                 }
185
186         const BufferSp&         getOutputBuffer         (void) const
187                                                 {
188                                                         DE_ASSERT(outputs.size() == 1);
189                                                         return outputs.front().second;
190                                                 }
191
192         bool                            empty                           (void) const
193                                                 {
194                                                         return inputs.size() == 0;
195                                                 }
196
197         void                            setRoundingMode         (RoundingModeFlags flag)
198                                                 {
199                                                         rndMode = flag;
200                                                 }
201         RoundingModeFlags       getRoundingMode         (void) const
202                                                 {
203                                                         return rndMode;
204                                                 }
205 private:
206         // vector<Interface> acts as a null-able Interface here. Canonically we should use
207         // std::unique_ptr, but sadly we cannot leverage C++11 in dEQP. dEQP has its own
208         // de::UniquePtr, but still cumbersome to use in InstanceContext and do copies
209         // at various places.
210         // Public methods should make sure that there are less than two elements in both
211         // members and both members have the same number of elements.
212         std::vector<Interface>  inputs;
213         std::vector<Interface>  outputs;
214         RoundingModeFlags               rndMode;
215
216 };
217
218 struct PushConstants
219 {
220 public:
221                                                         PushConstants (void)
222                                                         {}
223
224                                                         PushConstants (const PushConstants& that)
225                                                                 : pcs   (that.pcs)
226                                                         {}
227
228         void                                    setPushConstant (const BufferSp& pc)
229                                                         {
230                                                                 pcs.clear();
231                                                                 pcs.push_back(pc);
232                                                         }
233
234         bool                                    empty (void) const
235                                                         {
236                                                                 return pcs.empty();
237                                                         }
238
239         const BufferSp&                 getBuffer(void) const
240                                                         {
241                                                                 DE_ASSERT(pcs.size() == 1);
242                                                                 return pcs[0];
243                                                         }
244
245 private:
246         // Right now we only support one field in the push constant block.
247         std::vector<BufferSp>   pcs;
248 };
249
250 // Returns the corresponding buffer usage flag bit for the given descriptor type.
251 VkBufferUsageFlagBits getMatchingBufferUsageFlagBit(VkDescriptorType dType);
252
253 // Context for a specific test instantiation. For example, an instantiation
254 // may test colors yellow/magenta/cyan/mauve in a tesselation shader
255 // with an entry point named 'main_to_the_main'
256 struct InstanceContext
257 {
258         // Map of modules to what entry_points we care to use from those modules.
259         ModuleMap                                                               moduleMap;
260         tcu::RGBA                                                               inputColors[4];
261         tcu::RGBA                                                               outputColors[4];
262         // Concrete SPIR-V code to test via boilerplate specialization.
263         std::map<std::string, std::string>              testCodeFragments;
264         StageToSpecConstantMap                                  specConstants;
265         bool                                                                    hasTessellation;
266         vk::VkShaderStageFlagBits                               requiredStages;
267         std::vector<std::string>                                requiredDeviceExtensions;
268         std::vector<std::string>                                requiredDeviceFeatures;
269         VulkanFeatures                                                  requestedFeatures;
270         PushConstants                                                   pushConstants;
271         // Specifies the (one or more) stages that use a customized shader code.
272         VkShaderStageFlags                                              customizedStages;
273         // Possible resources used by the graphics pipeline.
274         // If it is not empty, a single descriptor set (number 0) will be allocated
275         // to point to all resources specified. Binding numbers are allocated in
276         // accord with the resources' order in the vector; outputs are allocated
277         // after inputs.
278         GraphicsResources                                               resources;
279         // Possible interface variables use by the graphics pipeline.
280         // If it is not empty, input/output variables will be set up for shader stages
281         // in the test. Both the input and output variable will take location #2 in the
282         // pipeline for all stages, except that the output variable in the fragment
283         // stage will take location #1.
284         GraphicsInterfaces                                              interfaces;
285         qpTestResult                                                    failResult;
286         std::string                                                             failMessageTemplate;    //!< ${reason} in the template will be replaced with a detailed failure message
287
288         InstanceContext (const tcu::RGBA                                                        (&inputs)[4],
289                                          const tcu::RGBA                                                        (&outputs)[4],
290                                          const std::map<std::string, std::string>&      testCodeFragments_,
291                                          const StageToSpecConstantMap&                          specConstants_,
292                                          const PushConstants&                                           pushConsants_,
293                                          const GraphicsResources&                                       resources_,
294                                          const GraphicsInterfaces&                                      interfaces_,
295                                          const std::vector<std::string>&                        extensions_,
296                                          const std::vector<std::string>&                        features_,
297                                          VulkanFeatures                                                         vulkanFeatures_,
298                                          VkShaderStageFlags                                                     customizedStages_);
299
300         InstanceContext (const InstanceContext& other);
301
302         std::string getSpecializedFailMessage (const std::string& failureReason);
303 };
304
305 // A description of a shader to be used for a single stage of the graphics pipeline.
306 struct ShaderElement
307 {
308         // The module that contains this shader entrypoint.
309         std::string                                     moduleName;
310
311         // The name of the entrypoint.
312         std::string                                     entryName;
313
314         // Which shader stage this entry point represents.
315         vk::VkShaderStageFlagBits       stage;
316
317         ShaderElement (const std::string& moduleName_, const std::string& entryPoint_, vk::VkShaderStageFlagBits shaderStage_);
318 };
319
320 template <typename T>
321 const std::string numberToString (T number)
322 {
323         std::stringstream ss;
324         ss << number;
325         return ss.str();
326 }
327
328 // Performs a bitwise copy of source to the destination type Dest.
329 template <typename Dest, typename Src>
330 Dest bitwiseCast(Src source)
331 {
332   Dest dest;
333   DE_STATIC_ASSERT(sizeof(source) == sizeof(dest));
334   deMemcpy(&dest, &source, sizeof(dest));
335   return dest;
336 }
337
338 template<typename T>    T                       randomScalar    (de::Random& rnd, T minValue, T maxValue);
339 template<> inline               float           randomScalar    (de::Random& rnd, float minValue, float maxValue)               { return rnd.getFloat(minValue, maxValue);      }
340 template<> inline               deInt32         randomScalar    (de::Random& rnd, deInt32 minValue, deInt32 maxValue)   { return rnd.getInt(minValue, maxValue);        }
341
342
343 void getDefaultColors (tcu::RGBA (&colors)[4]);
344
345 void getHalfColorsFullAlpha (tcu::RGBA (&colors)[4]);
346
347 void getInvertedDefaultColors (tcu::RGBA (&colors)[4]);
348
349 // Creates fragments that specialize into a simple pass-through shader (of any kind).
350 std::map<std::string, std::string> passthruFragments(void);
351
352 void createCombinedModule(vk::SourceCollections& dst, InstanceContext);
353
354 // This has two shaders of each stage. The first
355 // is a passthrough, the second inverts the color.
356 void createMultipleEntries(vk::SourceCollections& dst, InstanceContext);
357
358 // Turns a statically sized array of ShaderElements into an instance-context
359 // by setting up the mapping of modules to their contained shaders and stages.
360 // The inputs and expected outputs are given by inputColors and outputColors
361 template<size_t N>
362 InstanceContext createInstanceContext (const ShaderElement                                                      (&elements)[N],
363                                                                            const tcu::RGBA                                                              (&inputColors)[4],
364                                                                            const tcu::RGBA                                                              (&outputColors)[4],
365                                                                            const std::map<std::string, std::string>&    testCodeFragments,
366                                                                            const StageToSpecConstantMap&                                specConstants,
367                                                                            const PushConstants&                                                 pushConstants,
368                                                                            const GraphicsResources&                                             resources,
369                                                                            const GraphicsInterfaces&                                    interfaces,
370                                                                            const std::vector<std::string>&                              extensions,
371                                                                            const std::vector<std::string>&                              features,
372                                                                            VulkanFeatures                                                               vulkanFeatures,
373                                                                            VkShaderStageFlags                                                   customizedStages,
374                                                                            const qpTestResult                                                   failResult                      = QP_TEST_RESULT_FAIL,
375                                                                            const std::string&                                                   failMessageTemplate     = std::string())
376 {
377         InstanceContext ctx (inputColors, outputColors, testCodeFragments, specConstants, pushConstants, resources, interfaces, extensions, features, vulkanFeatures, customizedStages);
378         for (size_t i = 0; i < N; ++i)
379         {
380                 ctx.moduleMap[elements[i].moduleName].push_back(std::make_pair(elements[i].entryName, elements[i].stage));
381                 ctx.requiredStages = static_cast<VkShaderStageFlagBits>(ctx.requiredStages | elements[i].stage);
382         }
383         ctx.failResult                          = failResult;
384         if (!failMessageTemplate.empty())
385                 ctx.failMessageTemplate = failMessageTemplate;
386         return ctx;
387 }
388
389 // The same as createInstanceContext above, without extensions, spec constants, and resources.
390 template<size_t N>
391 inline InstanceContext createInstanceContext (const ShaderElement                                               (&elements)[N],
392                                                                                           tcu::RGBA                                                                     (&inputColors)[4],
393                                                                                           const tcu::RGBA                                                       (&outputColors)[4],
394                                                                                           const std::map<std::string, std::string>&     testCodeFragments)
395 {
396         return createInstanceContext(elements, inputColors, outputColors, testCodeFragments,
397                                                                  StageToSpecConstantMap(), PushConstants(), GraphicsResources(),
398                                                                  GraphicsInterfaces(), std::vector<std::string>(), std::vector<std::string>(),
399                                                                  VulkanFeatures(), vk::VK_SHADER_STAGE_ALL);
400 }
401
402 // The same as createInstanceContext above, but with default colors.
403 template<size_t N>
404 InstanceContext createInstanceContext (const ShaderElement                                                      (&elements)[N],
405                                                                            const std::map<std::string, std::string>&    testCodeFragments)
406 {
407         tcu::RGBA defaultColors[4];
408         getDefaultColors(defaultColors);
409         return createInstanceContext(elements, defaultColors, defaultColors, testCodeFragments);
410 }
411
412
413 void addShaderCodeCustomVertex(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
414 void addShaderCodeCustomTessControl(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
415 void addShaderCodeCustomTessEval(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
416 void addShaderCodeCustomGeometry(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
417 void addShaderCodeCustomFragment(vk::SourceCollections& dst, InstanceContext& context, const SpirVAsmBuildOptions* spirVAsmBuildOptions);
418
419 void createTestsForAllStages (const std::string&                                                name,
420                                                           const tcu::RGBA                                                       (&inputColors)[4],
421                                                           const tcu::RGBA                                                       (&outputColors)[4],
422                                                           const std::map<std::string, std::string>&     testCodeFragments,
423                                                           const std::vector<deInt32>&                           specConstants,
424                                                           const PushConstants&                                          pushConstants,
425                                                           const GraphicsResources&                                      resources,
426                                                           const GraphicsInterfaces&                                     interfaces,
427                                                           const std::vector<std::string>&                       extensions,
428                                                           const std::vector<std::string>&                       features,
429                                                           VulkanFeatures                                                        vulkanFeatures,
430                                                           tcu::TestCaseGroup*                                           tests,
431                                                           const qpTestResult                                            failResult                      = QP_TEST_RESULT_FAIL,
432                                                           const std::string&                                            failMessageTemplate     = std::string());
433
434 inline void createTestsForAllStages (const std::string&                                                 name,
435                                                                          const tcu::RGBA                                                        (&inputColors)[4],
436                                                                          const tcu::RGBA                                                        (&outputColors)[4],
437                                                                          const std::map<std::string, std::string>&      testCodeFragments,
438                                                                          tcu::TestCaseGroup*                                            tests,
439                                                                          const qpTestResult                                                     failResult                      = QP_TEST_RESULT_FAIL,
440                                                                          const std::string&                                                     failMessageTemplate     = std::string())
441 {
442         std::vector<deInt32>            noSpecConstants;
443         PushConstants                           noPushConstants;
444         GraphicsResources                       noResources;
445         GraphicsInterfaces                      noInterfaces;
446         std::vector<std::string>        noExtensions;
447         std::vector<std::string>        noFeatures;
448
449         createTestsForAllStages(
450                         name, inputColors, outputColors, testCodeFragments, noSpecConstants, noPushConstants,
451                         noResources, noInterfaces, noExtensions, noFeatures, VulkanFeatures(),
452                         tests, failResult, failMessageTemplate);
453 }
454
455 inline void createTestsForAllStages (const std::string&                                                 name,
456                                                                          const tcu::RGBA                                                        (&inputColors)[4],
457                                                                          const tcu::RGBA                                                        (&outputColors)[4],
458                                                                          const std::map<std::string, std::string>&      testCodeFragments,
459                                                                          const std::vector<deInt32>&                            specConstants,
460                                                                          tcu::TestCaseGroup*                                            tests,
461                                                                          const qpTestResult                                                     failResult                      = QP_TEST_RESULT_FAIL,
462                                                                          const std::string&                                                     failMessageTemplate     = std::string())
463 {
464         PushConstants                                   noPushConstants;
465         GraphicsResources                               noResources;
466         GraphicsInterfaces                              noInterfaces;
467         std::vector<std::string>                noExtensions;
468         std::vector<std::string>                noFeatures;
469
470         createTestsForAllStages(
471                         name, inputColors, outputColors, testCodeFragments, specConstants, noPushConstants,
472                         noResources, noInterfaces, noExtensions, noFeatures, VulkanFeatures(),
473                         tests, failResult, failMessageTemplate);
474 }
475
476 inline void createTestsForAllStages (const std::string&                                                 name,
477                                                                          const tcu::RGBA                                                        (&inputColors)[4],
478                                                                          const tcu::RGBA                                                        (&outputColors)[4],
479                                                                          const std::map<std::string, std::string>&      testCodeFragments,
480                                                                          const GraphicsResources&                                       resources,
481                                                                          const std::vector<std::string>&                        extensions,
482                                                                          tcu::TestCaseGroup*                                            tests,
483                                                                          VulkanFeatures                                                         vulkanFeatures          = VulkanFeatures(),
484                                                                          const qpTestResult                                                     failResult                      = QP_TEST_RESULT_FAIL,
485                                                                          const std::string&                                                     failMessageTemplate     = std::string())
486 {
487         std::vector<deInt32>            noSpecConstants;
488         PushConstants                           noPushConstants;
489         GraphicsInterfaces                      noInterfaces;
490         std::vector<std::string>        noFeatures;
491
492         createTestsForAllStages(
493                         name, inputColors, outputColors, testCodeFragments, noSpecConstants, noPushConstants,
494                         resources, noInterfaces, extensions, noFeatures, vulkanFeatures,
495                         tests, failResult, failMessageTemplate);
496 }
497
498 inline void createTestsForAllStages (const std::string& name,
499                                                                          const tcu::RGBA                                                        (&inputColors)[4],
500                                                                          const tcu::RGBA                                                        (&outputColors)[4],
501                                                                          const std::map<std::string, std::string>&      testCodeFragments,
502                                                                          const GraphicsInterfaces                                       interfaces,
503                                                                          const std::vector<std::string>&                        extensions,
504                                                                          tcu::TestCaseGroup*                                            tests,
505                                                                          VulkanFeatures                                                         vulkanFeatures          = VulkanFeatures(),
506                                                                          const qpTestResult                                                     failResult                      = QP_TEST_RESULT_FAIL,
507                                                                          const std::string&                                                     failMessageTemplate     = std::string())
508 {
509         GraphicsResources                       noResources;
510         std::vector<deInt32>            noSpecConstants;
511         std::vector<std::string>        noFeatures;
512         PushConstants                           noPushConstants;
513
514         createTestsForAllStages(
515                         name, inputColors, outputColors, testCodeFragments, noSpecConstants, noPushConstants,
516                         noResources, interfaces, extensions, noFeatures, vulkanFeatures,
517                         tests, failResult, failMessageTemplate);
518 }
519
520 inline void createTestsForAllStages (const std::string& name,
521                                                                          const tcu::RGBA                                                        (&inputColors)[4],
522                                                                          const tcu::RGBA                                                        (&outputColors)[4],
523                                                                          const std::map<std::string, std::string>&      testCodeFragments,
524                                                                          const PushConstants&                                           pushConstants,
525                                                                          const GraphicsResources&                                       resources,
526                                                                          const std::vector<std::string>&                        extensions,
527                                                                          tcu::TestCaseGroup*                                            tests,
528                                                                          VulkanFeatures                                                         vulkanFeatures          = VulkanFeatures(),
529                                                                          const qpTestResult                                                     failResult                      = QP_TEST_RESULT_FAIL,
530                                                                          const std::string&                                                     failMessageTemplate     = std::string())
531 {
532         std::vector<deInt32>                    noSpecConstants;
533         GraphicsInterfaces                              noInterfaces;
534         std::vector<std::string>                noFeatures;
535
536         createTestsForAllStages(
537                         name, inputColors, outputColors, testCodeFragments, noSpecConstants, pushConstants,
538                         resources, noInterfaces, extensions, noFeatures, vulkanFeatures,
539                         tests, failResult, failMessageTemplate);
540 }
541
542 // Sets up and runs a Vulkan pipeline, then spot-checks the resulting image.
543 // Feeds the pipeline a set of colored triangles, which then must occur in the
544 // rendered image.  The surface is cleared before executing the pipeline, so
545 // whatever the shaders draw can be directly spot-checked.
546 tcu::TestStatus runAndVerifyDefaultPipeline (Context& context, InstanceContext instance);
547
548 // Adds a new test to group using custom fragments for the tessellation-control
549 // stage and passthrough fragments for all other stages.  Uses default colors
550 // for input and expected output.
551 void addTessCtrlTest(tcu::TestCaseGroup* group, const char* name, const std::map<std::string, std::string>& fragments);
552
553 // Given the original 32-bit float value, computes the corresponding 16-bit
554 // float value under the given rounding mode flags and compares with the
555 // returned 16-bit float value. Returns true if they are considered as equal.
556 //
557 // The following equivalence criteria are respected:
558 // * Positive and negative zeros are considered equivalent.
559 // * Denormalized floats are allowed to be flushed to zeros, including
560 //   * Inputted 32bit denormalized float
561 //   * Generated 16bit denormalized float
562 // * Different bit patterns of NaNs are allowed.
563 // * For the rest, require exactly the same bit pattern.
564 bool compare16BitFloat (float original, deUint16 returned, RoundingModeFlags flags, tcu::TestLog& log);
565
566 // Compare the returned 32-bit float against its expected value.
567 //
568 // The following equivalence criteria are respected:
569 // * Denormalized floats are allowed to be flushed to zeros, including
570 //   * The expected value itself is a denormalized float
571 //   * The expected value is a denormalized float if converted to 16bit
572 // * Different bit patterns of NaNs/Infs are allowed.
573 // * For the rest, use C++ float equivalence check.
574 bool compare32BitFloat (float expected, float returned, tcu::TestLog& log);
575
576 } // SpirVAssembly
577 } // vkt
578
579 #endif // _VKTSPVASMGRAPHICSSHADERTESTUTIL_HPP