1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2016 Google Inc.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Build and Device Tests
22 *//*--------------------------------------------------------------------*/
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"
33 #include "deStringUtil.hpp"
34 #include "vktApiFeatureInfo.hpp"
47 std::string getOsName (int os)
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";
60 return de::toString(os);
64 std::string getCompilerName (int compiler)
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";
73 return de::toString(compiler);
77 std::string getCpuName (int cpu)
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";
91 return de::toString(cpu);
95 std::string getEndiannessName (int endianness)
99 case DE_BIG_ENDIAN: return "DE_BIG_ENDIAN";
100 case DE_LITTLE_ENDIAN: return "DE_LITTLE_ENDIAN";
102 return de::toString(endianness);
106 tcu::TestStatus logBuildInfo (Context& context)
108 #if defined(DE_DEBUG)
109 const bool isDebug = true;
111 const bool isDebug = false;
114 context.getTestContext().getLog()
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;
124 return tcu::TestStatus::pass("Not validated");
127 tcu::TestStatus logDeviceInfo (Context& context)
129 TestLog& log = context.getTestContext().getLog();
130 const vk::VkPhysicalDeviceProperties& properties = context.getDeviceProperties();
132 log << TestLog::Message
133 << "Using --deqp-vk-device-id="
134 << context.getTestContext().getCommandLine().getVKDeviceId()
135 << TestLog::EndMessage;
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;
145 return tcu::TestStatus::pass("Not validated");
148 tcu::TestStatus logPlatformInfo (Context& context)
150 std::ostringstream details;
152 context.getTestContext().getPlatform().getVulkanPlatform().describePlatform(details);
154 context.getTestContext().getLog()
157 << TestLog::EndMessage;
159 return tcu::TestStatus::pass("Not validated");
162 template<typename SizeType>
168 PrettySize (SizeType value_, int precision_)
170 , precision (precision_)
180 const SizeUnit* getBestSizeUnit (deUint64 value)
182 static const SizeUnit s_units[] =
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 },
190 static const SizeUnit s_defaultUnit = { "B", 1u };
192 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_units); ++ndx)
194 DE_ASSERT(ndx == DE_LENGTH_OF_ARRAY(s_units) ||
195 s_units[ndx].value > s_units[ndx + 1].value);
196 if (value >= s_units[ndx].value)
197 return &s_units[ndx];
200 return &s_defaultUnit;
203 template<typename SizeType>
204 std::ostream& operator<< (std::ostream& str, const PrettySize<SizeType>& size)
206 const SizeUnit* unit = getBestSizeUnit(deUint64(size.value));
207 std::ostringstream tmp;
209 tmp << std::fixed << std::setprecision(size.precision)
210 << (double(size.value) / double(unit->value))
211 << " " << unit->name;
213 return str << tmp.str();
216 template<typename SizeType>
217 PrettySize<SizeType> prettySize (SizeType value, int precision = 2)
219 return PrettySize<SizeType>(value, precision);
222 tcu::TestStatus logPlatformMemoryLimits (Context& context)
224 TestLog& log = context.getTestContext().getLog();
225 tcu::PlatformMemoryLimits limits;
227 context.getTestContext().getPlatform().getMemoryLimits(limits);
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;
237 TCU_CHECK(limits.totalSystemMemory > 0);
238 TCU_CHECK(limits.deviceMemoryAllocationGranularity > 0);
239 TCU_CHECK(deIsPowerOfTwo64(limits.devicePageSize));
241 return tcu::TestStatus::pass("Pass");
246 void createInfoTests (tcu::TestCaseGroup* testGroup)
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);
253 api::createFeatureInfoInstanceTests (testGroup);
254 api::createFeatureInfoDeviceTests (testGroup);
255 api::createFeatureInfoDeviceGroupTests (testGroup);