Merge vk-gl-cts/vulkan-cts-1.1.3 into vk-gl-cts/vulkan-cts-1.1.4
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / amber / vktAmberGraphicsFuzzTests.cpp
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2018 Intel Corporation
6  * Copyright (c) 2018 Google LLC
7  * Copyright (c) 2019 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
23  * \brief GraphicsFuzz tests
24  *//*--------------------------------------------------------------------*/
25
26 #include <amber/amber.h>
27
28 #include "vktAmberGraphicsFuzzTests.hpp"
29 #include "vktAmberTestCase.hpp"
30 #include "vktTestGroupUtil.hpp"
31
32 namespace vkt
33 {
34 namespace cts_amber
35 {
36 namespace
37 {
38
39 void createAmberTests (tcu::TestCaseGroup* group)
40 {
41         tcu::TestContext&       testCtx = group->getTestContext();
42
43         static const struct
44         {
45                 const char *filename;
46                 const char *name;
47                 const char *description;
48         }
49         tests[] =
50         {
51                 {       "continue-and-merge.amber",                             "continue-and-merge",                   "A fragment shader with two nested loops"                                                                               },
52                 {       "control-flow-switch.amber",                    "control-flow-switch",                  "A fragment shader with somewhat complex control flow and a switch"                             },
53                 {       "dead-struct-init.amber",                               "dead-struct-init",                             "A fragment shader that uses struct initializers"                                                               },
54                 {       "fragcoord-control-flow.amber",                 "fragcoord-control-flow",               "A fragment shader that uses FragCoord and somewhat complex control flow"               },
55                 {       "fragcoord-control-flow-2.amber",               "fragcoord-control-flow-2",             "A fragment shader that uses FragCoord and somewhat complex control flow"               },
56                 {       "mat-array-deep-control-flow.amber",    "mat-array-deep-control-flow",  "A fragment shader that uses an array of matrices and has deep control flow"    },
57                 {       "mat-array-distance.amber",                             "mat-array-distance",                   "A fragment shader that uses an array of matrices and distance"                                 },
58                 {       "pow-vec4.amber",                                               "pow-vec4",                                             "A fragment shader that uses pow"                                                                                               },
59                 {       "swizzle-struct-init-min.amber",                "swizzle-struct-init-min",              "A fragment shader that uses vector swizzles, struct initializers, and min"             },
60                 {       "while-inside-switch.amber",                    "while-inside-switch",                  "A fragment shader that uses a while loop inside a switch"                                              },
61         };
62
63         for (size_t i = 0; i < sizeof tests / sizeof tests[0]; i++)
64         {
65                 // .amber files are saved in <path>/external/vulkancts/data/vulkan/amber/<categoryname>/
66                 AmberTestCase *testCase = new AmberTestCase(testCtx, tests[i].name, tests[i].description);
67
68                 // Make sure the input can be parsed before we use it.
69                 if (testCase->parse("graphicsfuzz", tests[i].filename))
70                 {
71                         group->addChild(testCase);
72                 }
73                 else
74                 {
75                         delete testCase;
76
77                         TCU_THROW(InternalError, "Failed to parse amber file");
78                 }
79         }
80 }
81
82 } // anonymous
83
84 tcu::TestCaseGroup* createGraphicsFuzzTests (tcu::TestContext& testCtx)
85 {
86         return createTestGroup(testCtx, "graphicsfuzz", "Amber GraphicsFuzz Tests", createAmberTests);
87 }
88
89 } // cts_amber
90 } // vkt