• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Build and Device Tests
22  *//*--------------------------------------------------------------------*/
23 
24 #include "vktInfoTests.hpp"
25 #include "vktTestCaseUtil.hpp"
26 #include "vkPlatform.hpp"
27 #include "vkApiVersion.hpp"
28 #include "tcuTestLog.hpp"
29 #include "tcuFormatUtil.hpp"
30 #include "tcuCommandLine.hpp"
31 #include "tcuPlatform.hpp"
32 #include "deDefs.h"
33 #include "deStringUtil.hpp"
34 #include "vktApiFeatureInfo.hpp"
35 
36 #include <iomanip>
37 
38 namespace vkt
39 {
40 
41 namespace
42 {
43 
44 using tcu::TestLog;
45 using std::string;
46 
getOsName(int os)47 std::string getOsName (int os)
48 {
49 	switch (os)
50 	{
51 		case DE_OS_VANILLA:		return "DE_OS_VANILLA";
52 		case DE_OS_WIN32:		return "DE_OS_WIN32";
53 		case DE_OS_UNIX:		return "DE_OS_UNIX";
54 		case DE_OS_WINCE:		return "DE_OS_WINCE";
55 		case DE_OS_OSX:			return "DE_OS_OSX";
56 		case DE_OS_ANDROID:		return "DE_OS_ANDROID";
57 		case DE_OS_SYMBIAN:		return "DE_OS_SYMBIAN";
58 		case DE_OS_IOS:			return "DE_OS_IOS";
59 		default:
60 			return de::toString(os);
61 	}
62 }
63 
getCompilerName(int compiler)64 std::string getCompilerName (int compiler)
65 {
66 	switch (compiler)
67 	{
68 		case DE_COMPILER_VANILLA:	return "DE_COMPILER_VANILLA";
69 		case DE_COMPILER_MSC:		return "DE_COMPILER_MSC";
70 		case DE_COMPILER_GCC:		return "DE_COMPILER_GCC";
71 		case DE_COMPILER_CLANG:		return "DE_COMPILER_CLANG";
72 		default:
73 			return de::toString(compiler);
74 	}
75 }
76 
getCpuName(int cpu)77 std::string getCpuName (int cpu)
78 {
79 	switch (cpu)
80 	{
81 		case DE_CPU_VANILLA:	return "DE_CPU_VANILLA";
82 		case DE_CPU_ARM:		return "DE_CPU_ARM";
83 		case DE_CPU_X86:		return "DE_CPU_X86";
84 		case DE_CPU_X86_64:		return "DE_CPU_X86_64";
85 		case DE_CPU_ARM_64:		return "DE_CPU_ARM_64";
86 		case DE_CPU_MIPS:		return "DE_CPU_MIPS";
87 		case DE_CPU_MIPS_64:	return "DE_CPU_MIPS_64";
88 		case DE_CPU_RISCV_32:	return "DE_CPU_RISCV_32";
89 		case DE_CPU_RISCV_64:	return "DE_CPU_RISCV_64";
90 		default:
91 			return de::toString(cpu);
92 	}
93 }
94 
getEndiannessName(int endianness)95 std::string getEndiannessName (int endianness)
96 {
97 	switch (endianness)
98 	{
99 		case DE_BIG_ENDIAN:		return "DE_BIG_ENDIAN";
100 		case DE_LITTLE_ENDIAN:	return "DE_LITTLE_ENDIAN";
101 		default:
102 			return de::toString(endianness);
103 	}
104 }
105 
logBuildInfo(Context & context)106 tcu::TestStatus logBuildInfo (Context& context)
107 {
108 #if defined(DE_DEBUG)
109 	const bool	isDebug	= true;
110 #else
111 	const bool	isDebug	= false;
112 #endif
113 
114 	context.getTestContext().getLog()
115 		<< TestLog::Message
116 		<< "DE_OS: " << getOsName(DE_OS) << "\n"
117 		<< "DE_CPU: " << getCpuName(DE_CPU) << "\n"
118 		<< "DE_PTR_SIZE: " << DE_PTR_SIZE << "\n"
119 		<< "DE_ENDIANNESS: " << getEndiannessName(DE_ENDIANNESS) << "\n"
120 		<< "DE_COMPILER: " << getCompilerName(DE_COMPILER) << "\n"
121 		<< "DE_DEBUG: " << (isDebug ? "true" : "false") << "\n"
122 		<< TestLog::EndMessage;
123 
124 	return tcu::TestStatus::pass("Not validated");
125 }
126 
logDeviceInfo(Context & context)127 tcu::TestStatus logDeviceInfo (Context& context)
128 {
129 	TestLog&								log			= context.getTestContext().getLog();
130 	const vk::VkPhysicalDeviceProperties&	properties	= context.getDeviceProperties();
131 
132 	log << TestLog::Message
133 		<< "Using --deqp-vk-device-id="
134 		<< context.getTestContext().getCommandLine().getVKDeviceId()
135 		<< TestLog::EndMessage;
136 
137 	log << TestLog::Message
138 		<< "apiVersion: " << vk::unpackVersion(properties.apiVersion) << "\n"
139 		<< "driverVersion: " << tcu::toHex(properties.driverVersion) << "\n"
140 		<< "deviceName: " << (const char*)properties.deviceName << "\n"
141 		<< "vendorID: " << tcu::toHex(properties.vendorID) << "\n"
142 		<< "deviceID: " << tcu::toHex(properties.deviceID) << "\n"
143 		<< TestLog::EndMessage;
144 
145 	return tcu::TestStatus::pass("Not validated");
146 }
147 
logPlatformInfo(Context & context)148 tcu::TestStatus logPlatformInfo (Context& context)
149 {
150 	std::ostringstream details;
151 
152 	context.getTestContext().getPlatform().getVulkanPlatform().describePlatform(details);
153 
154 	context.getTestContext().getLog()
155 		<< TestLog::Message
156 		<< details.str()
157 		<< TestLog::EndMessage;
158 
159 	return tcu::TestStatus::pass("Not validated");
160 }
161 
162 template<typename SizeType>
163 struct PrettySize
164 {
165 	SizeType	value;
166 	int			precision;
167 
PrettySizevkt::__anon0c9eff580111::PrettySize168 	PrettySize (SizeType value_, int precision_)
169 		: value		(value_)
170 		, precision	(precision_)
171 	{}
172 };
173 
174 struct SizeUnit
175 {
176 	const char*		name;
177 	deUint64		value;
178 };
179 
getBestSizeUnit(deUint64 value)180 const SizeUnit* getBestSizeUnit (deUint64 value)
181 {
182 	static const SizeUnit s_units[]		=
183 	{
184 		// \note Must be ordered from largest to smallest
185 		{ "TiB",	1ull<<40ull		},
186 		{ "GiB",	1ull<<30ull		},
187 		{ "MiB",	1ull<<20ull		},
188 		{ "KiB",	1ull<<10ull		},
189 	};
190 	static const SizeUnit s_defaultUnit	= { "B", 1u };
191 
192 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_units); ++ndx)
193 	{
194 		DE_ASSERT(ndx == (DE_LENGTH_OF_ARRAY(s_units) - 1) ||
195 		          s_units[ndx].value > s_units[ndx + 1].value);
196 		if (value >= s_units[ndx].value)
197 			return &s_units[ndx];
198 	}
199 
200 	return &s_defaultUnit;
201 }
202 
203 template<typename SizeType>
operator <<(std::ostream & str,const PrettySize<SizeType> & size)204 std::ostream& operator<< (std::ostream& str, const PrettySize<SizeType>& size)
205 {
206 	const SizeUnit*		unit = getBestSizeUnit(deUint64(size.value));
207 	std::ostringstream	tmp;
208 
209 	tmp << std::fixed << std::setprecision(size.precision)
210 		<< (double(size.value) / double(unit->value))
211 		<< " " << unit->name;
212 
213 	return str << tmp.str();
214 }
215 
216 template<typename SizeType>
prettySize(SizeType value,int precision=2)217 PrettySize<SizeType> prettySize (SizeType value, int precision = 2)
218 {
219 	return PrettySize<SizeType>(value, precision);
220 }
221 
logPlatformMemoryLimits(Context & context)222 tcu::TestStatus logPlatformMemoryLimits (Context& context)
223 {
224 	TestLog&					log			= context.getTestContext().getLog();
225 	tcu::PlatformMemoryLimits	limits;
226 
227 	context.getTestContext().getPlatform().getMemoryLimits(limits);
228 
229 	log << TestLog::Message << "totalSystemMemory = " << prettySize(limits.totalSystemMemory) << " (" << limits.totalSystemMemory << ")\n"
230 							<< "totalDeviceLocalMemory = " << prettySize(limits.totalDeviceLocalMemory) << " (" << limits.totalDeviceLocalMemory << ")\n"
231 							<< "deviceMemoryAllocationGranularity = " << limits.deviceMemoryAllocationGranularity << "\n"
232 							<< "devicePageSize = " << limits.devicePageSize << "\n"
233 							<< "devicePageTableEntrySize = " << limits.devicePageTableEntrySize << "\n"
234 							<< "devicePageTableHierarchyLevels = " << limits.devicePageTableHierarchyLevels << "\n"
235 		<< TestLog::EndMessage;
236 
237 	TCU_CHECK(limits.totalSystemMemory > 0);
238 	TCU_CHECK(limits.deviceMemoryAllocationGranularity > 0);
239 	TCU_CHECK(deIsPowerOfTwo64(limits.devicePageSize));
240 
241 	return tcu::TestStatus::pass("Pass");
242 }
243 
244 } // anonymous
245 
createInfoTests(tcu::TestCaseGroup * testGroup)246 void createInfoTests (tcu::TestCaseGroup* testGroup)
247 {
248 	addFunctionCase(testGroup, "build",			"Build Info",				logBuildInfo);
249 	addFunctionCase(testGroup, "device",		"Device Info",				logDeviceInfo);
250 	addFunctionCase(testGroup, "platform",		"Platform Info",			logPlatformInfo);
251 	addFunctionCase(testGroup, "memory_limits",	"Platform Memory Limits",	logPlatformMemoryLimits);
252 
253 	api::createFeatureInfoInstanceTests		(testGroup);
254 	api::createFeatureInfoDeviceTests		(testGroup);
255 	api::createFeatureInfoDeviceGroupTests	(testGroup);
256 }
257 
258 } // vkt
259