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
SpirVAsmBuildOptionsvk::SpirVAsmBuildOptions46 SpirVAsmBuildOptions (deUint32 vulkanVersion_, SpirvVersion targetVersion_, bool allowSpirv14 = false)
47 : vulkanVersion (vulkanVersion_)
48 , targetVersion (targetVersion_)
49 , supports_VK_KHR_spirv_1_4 (allowSpirv14)
50 {}
51
SpirVAsmBuildOptionsvk::SpirVAsmBuildOptions52 SpirVAsmBuildOptions (void)
53 : vulkanVersion (VK_MAKE_VERSION(1, 0, 0))
54 , targetVersion (SPIRV_VERSION_1_0)
55 , supports_VK_KHR_spirv_1_4 (false)
56 {}
57
getSpirvValidatorOptionsvk::SpirVAsmBuildOptions58 SpirvValidatorOptions getSpirvValidatorOptions() const
59 {
60 SpirvValidatorOptions result(vulkanVersion);
61 result.supports_VK_KHR_spirv_1_4 = supports_VK_KHR_spirv_1_4;
62 return result;
63 }
64 };
65
66 struct SpirVAsmSource
67 {
SpirVAsmSourcevk::SpirVAsmSource68 SpirVAsmSource (void)
69 {
70 }
71
SpirVAsmSourcevk::SpirVAsmSource72 SpirVAsmSource (const std::string& source_)
73 : source(source_)
74 {
75 }
76
operator <<vk::SpirVAsmSource77 SpirVAsmSource& operator<< (const SpirVAsmBuildOptions& buildOptions_)
78 {
79 buildOptions = buildOptions_;
80 return *this;
81 };
82
83 SpirVAsmBuildOptions buildOptions;
84 std::string source;
85 };
86
87 struct SpirVProgramInfo
88 {
SpirVProgramInfovk::SpirVProgramInfo89 SpirVProgramInfo (void)
90 : compileTimeUs (0)
91 , compileOk (false)
92 {
93 }
94
95 std::string source;
96 std::string infoLog;
97 deUint64 compileTimeUs;
98 bool compileOk;
99 };
100
101 tcu::TestLog& operator<< (tcu::TestLog& log, const SpirVProgramInfo& shaderInfo);
102 tcu::TestLog& operator<< (tcu::TestLog& log, const SpirVAsmSource& program);
103
104 // Helper for constructing SpirVAsmSource
105 template<typename T>
operator <<(SpirVAsmSource & src,const T & val)106 SpirVAsmSource& operator<< (SpirVAsmSource& src, const T& val)
107 {
108 src.source += de::toString(val);
109 return src;
110 }
111
112 }
113
114 #endif // _VKSPIRVPROGRAM_HPP
115