1 #ifndef _VKSPIRVPROGRAM_HPP
2 #define _VKSPIRVPROGRAM_HPP
3 /*-------------------------------------------------------------------------
4 * Vulkan CTS Framework
5 * --------------------
6 *
7 * Copyright (c) 2015 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 SPIR-V program and binary info.
24 *//*--------------------------------------------------------------------*/
25
26 #include "vkDefs.hpp"
27 #include "deStringUtil.hpp"
28 #include "vkValidatorOptions.hpp"
29
30 #include <string>
31
32 namespace tcu
33 {
34 class TestLog;
35 } // tcu
36
37 namespace vk
38 {
39
40 struct SpirVAsmBuildOptions
41 {
42 deUint32 vulkanVersion;
43 SpirvVersion targetVersion;
44 bool supports_VK_KHR_spirv_1_4;
45 bool supports_VK_KHR_maintenance4;
46
SpirVAsmBuildOptionsvk::SpirVAsmBuildOptions47 SpirVAsmBuildOptions (deUint32 vulkanVersion_, SpirvVersion targetVersion_, bool allowSpirv14 = false, bool allowMaintenance4 = false)
48 : vulkanVersion (vulkanVersion_)
49 , targetVersion (targetVersion_)
50 , supports_VK_KHR_spirv_1_4 (allowSpirv14)
51 , supports_VK_KHR_maintenance4 (allowMaintenance4)
52 {}
53
SpirVAsmBuildOptionsvk::SpirVAsmBuildOptions54 SpirVAsmBuildOptions (void)
55 : vulkanVersion (VK_MAKE_VERSION(1, 0, 0))
56 , targetVersion (SPIRV_VERSION_1_0)
57 , supports_VK_KHR_spirv_1_4 (false)
58 , supports_VK_KHR_maintenance4 (false)
59 {}
60
getSpirvValidatorOptionsvk::SpirVAsmBuildOptions61 SpirvValidatorOptions getSpirvValidatorOptions() const
62 {
63 SpirvValidatorOptions result(vulkanVersion);
64 result.supports_VK_KHR_spirv_1_4 = supports_VK_KHR_spirv_1_4;
65 if (supports_VK_KHR_maintenance4)
66 result.flags = result.flags | SpirvValidatorOptions::FLAG_SPIRV_VALIDATOR_ALLOW_LOCALSIZEID;
67 return result;
68 }
69 };
70
71 struct SpirVAsmSource
72 {
SpirVAsmSourcevk::SpirVAsmSource73 SpirVAsmSource (void)
74 {
75 }
76
SpirVAsmSourcevk::SpirVAsmSource77 SpirVAsmSource (const std::string& source_)
78 : source(source_)
79 {
80 }
81
operator <<vk::SpirVAsmSource82 SpirVAsmSource& operator<< (const SpirVAsmBuildOptions& buildOptions_)
83 {
84 buildOptions = buildOptions_;
85 return *this;
86 }
87
88 SpirVAsmBuildOptions buildOptions;
89 std::string source;
90 };
91
92 struct SpirVProgramInfo
93 {
SpirVProgramInfovk::SpirVProgramInfo94 SpirVProgramInfo (void)
95 : compileTimeUs (0)
96 , compileOk (false)
97 {
98 }
99
100 std::string source;
101 std::string infoLog;
102 deUint64 compileTimeUs;
103 bool compileOk;
104 };
105
106 tcu::TestLog& operator<< (tcu::TestLog& log, const SpirVProgramInfo& shaderInfo);
107 tcu::TestLog& operator<< (tcu::TestLog& log, const SpirVAsmSource& program);
108
109 // Helper for constructing SpirVAsmSource
110 template<typename T>
operator <<(SpirVAsmSource & src,const T & val)111 SpirVAsmSource& operator<< (SpirVAsmSource& src, const T& val)
112 {
113 src.source += de::toString(val);
114 return src;
115 }
116
117 }
118
119 #endif // _VKSPIRVPROGRAM_HPP
120