• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
SpirVAsmBuildOptionsvk::SpirVAsmBuildOptions45 	SpirVAsmBuildOptions (deUint32 vulkanVersion_, SpirvVersion targetVersion_)
46 		: vulkanVersion	(vulkanVersion_)
47 		, targetVersion	(targetVersion_)
48 	{}
49 
SpirVAsmBuildOptionsvk::SpirVAsmBuildOptions50 	SpirVAsmBuildOptions (void)
51 		: vulkanVersion	(VK_MAKE_VERSION(1, 0, 0))
52 		, targetVersion	(SPIRV_VERSION_1_0)
53 	{}
54 
getSpirvValidatorOptionsvk::SpirVAsmBuildOptions55 	SpirvValidatorOptions getSpirvValidatorOptions() const
56 	{
57 		return SpirvValidatorOptions(vulkanVersion);
58 	}
59 };
60 
61 struct SpirVAsmSource
62 {
SpirVAsmSourcevk::SpirVAsmSource63 	SpirVAsmSource (void)
64 	{
65 	}
66 
SpirVAsmSourcevk::SpirVAsmSource67 	SpirVAsmSource (const std::string& source_)
68 		: source(source_)
69 	{
70 	}
71 
operator <<vk::SpirVAsmSource72 	SpirVAsmSource& operator<< (const SpirVAsmBuildOptions& buildOptions_)
73 	{
74 		buildOptions = buildOptions_;
75 		return *this;
76 	};
77 
78 	SpirVAsmBuildOptions	buildOptions;
79 	std::string				source;
80 };
81 
82 struct SpirVProgramInfo
83 {
SpirVProgramInfovk::SpirVProgramInfo84 	SpirVProgramInfo (void)
85 		: compileTimeUs	(0)
86 		, compileOk		(false)
87 	{
88 	}
89 
90 	std::string		source;
91 	std::string		infoLog;
92 	deUint64		compileTimeUs;
93 	bool			compileOk;
94 };
95 
96 tcu::TestLog&	operator<<		(tcu::TestLog& log, const SpirVProgramInfo& shaderInfo);
97 tcu::TestLog&	operator<<		(tcu::TestLog& log, const SpirVAsmSource& program);
98 
99 // Helper for constructing SpirVAsmSource
100 template<typename T>
operator <<(SpirVAsmSource & src,const T & val)101 SpirVAsmSource& operator<< (SpirVAsmSource& src, const T& val)
102 {
103 	src.source += de::toString(val);
104 	return src;
105 }
106 
107 }
108 
109 #endif // _VKSPIRVPROGRAM_HPP
110