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"
32 #include "deStringUtil.hpp"
45 std::string getOsName (int os)
49 case DE_OS_VANILLA: return "DE_OS_VANILLA";
50 case DE_OS_WIN32: return "DE_OS_WIN32";
51 case DE_OS_UNIX: return "DE_OS_UNIX";
52 case DE_OS_WINCE: return "DE_OS_WINCE";
53 case DE_OS_OSX: return "DE_OS_OSX";
54 case DE_OS_ANDROID: return "DE_OS_ANDROID";
55 case DE_OS_SYMBIAN: return "DE_OS_SYMBIAN";
56 case DE_OS_IOS: return "DE_OS_IOS";
58 return de::toString(os);
62 std::string getCompilerName (int compiler)
66 case DE_COMPILER_VANILLA: return "DE_COMPILER_VANILLA";
67 case DE_COMPILER_MSC: return "DE_COMPILER_MSC";
68 case DE_COMPILER_GCC: return "DE_COMPILER_GCC";
69 case DE_COMPILER_CLANG: return "DE_COMPILER_CLANG";
71 return de::toString(compiler);
75 std::string getCpuName (int cpu)
79 case DE_CPU_VANILLA: return "DE_CPU_VANILLA";
80 case DE_CPU_ARM: return "DE_CPU_ARM";
81 case DE_CPU_X86: return "DE_CPU_X86";
82 case DE_CPU_X86_64: return "DE_CPU_X86_64";
83 case DE_CPU_ARM_64: return "DE_CPU_ARM_64";
84 case DE_CPU_MIPS: return "DE_CPU_MIPS";
85 case DE_CPU_MIPS_64: return "DE_CPU_MIPS_64";
87 return de::toString(cpu);
91 std::string getEndiannessName (int endianness)
95 case DE_BIG_ENDIAN: return "DE_BIG_ENDIAN";
96 case DE_LITTLE_ENDIAN: return "DE_LITTLE_ENDIAN";
98 return de::toString(endianness);
102 tcu::TestStatus logBuildInfo (Context& context)
104 #if defined(DE_DEBUG)
105 const bool isDebug = true;
107 const bool isDebug = false;
110 context.getTestContext().getLog()
112 << "DE_OS: " << getOsName(DE_OS) << "\n"
113 << "DE_CPU: " << getCpuName(DE_CPU) << "\n"
114 << "DE_PTR_SIZE: " << DE_PTR_SIZE << "\n"
115 << "DE_ENDIANNESS: " << getEndiannessName(DE_ENDIANNESS) << "\n"
116 << "DE_COMPILER: " << getCompilerName(DE_COMPILER) << "\n"
117 << "DE_DEBUG: " << (isDebug ? "true" : "false") << "\n"
118 << TestLog::EndMessage;
120 return tcu::TestStatus::pass("Not validated");
123 tcu::TestStatus logDeviceInfo (Context& context)
125 TestLog& log = context.getTestContext().getLog();
126 const vk::VkPhysicalDeviceProperties& properties = context.getDeviceProperties();
128 log << TestLog::Message
129 << "Using --deqp-vk-device-id="
130 << context.getTestContext().getCommandLine().getVKDeviceId()
131 << TestLog::EndMessage;
133 log << TestLog::Message
134 << "apiVersion: " << vk::unpackVersion(properties.apiVersion) << "\n"
135 << "driverVersion: " << tcu::toHex(properties.driverVersion) << "\n"
136 << "deviceName: " << (const char*)properties.deviceName << "\n"
137 << "vendorID: " << tcu::toHex(properties.vendorID) << "\n"
138 << "deviceID: " << tcu::toHex(properties.deviceID) << "\n"
139 << TestLog::EndMessage;
141 return tcu::TestStatus::pass("Not validated");
144 tcu::TestStatus logPlatformInfo (Context& context)
146 std::ostringstream details;
148 context.getTestContext().getPlatform().getVulkanPlatform().describePlatform(details);
150 context.getTestContext().getLog()
153 << TestLog::EndMessage;
155 return tcu::TestStatus::pass("Not validated");
158 template<typename SizeType>
164 PrettySize (SizeType value_, int precision_)
166 , precision (precision_)
176 const SizeUnit* getBestSizeUnit (deUint64 value)
178 static const SizeUnit s_units[] =
180 // \note Must be ordered from largest to smallest
181 { "TiB", 1ull<<40ull },
182 { "MiB", 1ull<<20ull },
183 { "GiB", 1ull<<30ull },
184 { "KiB", 1ull<<10ull },
186 static const SizeUnit s_defaultUnit = { "B", 1u };
188 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_units); ++ndx)
190 if (value >= s_units[ndx].value)
191 return &s_units[ndx];
194 return &s_defaultUnit;
197 template<typename SizeType>
198 std::ostream& operator<< (std::ostream& str, const PrettySize<SizeType>& size)
200 const SizeUnit* unit = getBestSizeUnit(deUint64(size.value));
201 std::ostringstream tmp;
203 tmp << std::fixed << std::setprecision(size.precision)
204 << (double(size.value) / double(unit->value))
205 << " " << unit->name;
207 return str << tmp.str();
210 template<typename SizeType>
211 PrettySize<SizeType> prettySize (SizeType value, int precision = 2)
213 return PrettySize<SizeType>(value, precision);
216 tcu::TestStatus logPlatformMemoryLimits (Context& context)
218 TestLog& log = context.getTestContext().getLog();
219 vk::PlatformMemoryLimits limits;
221 context.getTestContext().getPlatform().getVulkanPlatform().getMemoryLimits(limits);
223 log << TestLog::Message << "totalSystemMemory = " << prettySize(limits.totalSystemMemory) << " (" << limits.totalSystemMemory << ")\n"
224 << "totalDeviceLocalMemory = " << prettySize(limits.totalDeviceLocalMemory) << " (" << limits.totalDeviceLocalMemory << ")\n"
225 << "deviceMemoryAllocationGranularity = " << limits.deviceMemoryAllocationGranularity << "\n"
226 << "devicePageSize = " << limits.devicePageSize << "\n"
227 << "devicePageTableEntrySize = " << limits.devicePageTableEntrySize << "\n"
228 << "devicePageTableHierarchyLevels = " << limits.devicePageTableHierarchyLevels << "\n"
229 << TestLog::EndMessage;
231 TCU_CHECK(limits.totalSystemMemory > 0);
232 TCU_CHECK(limits.deviceMemoryAllocationGranularity > 0);
233 TCU_CHECK(deIsPowerOfTwo64(limits.devicePageSize));
235 return tcu::TestStatus::pass("Pass");
240 void createInfoTests (tcu::TestCaseGroup* testGroup)
242 addFunctionCase(testGroup, "build", "Build Info", logBuildInfo);
243 addFunctionCase(testGroup, "device", "Device Info", logDeviceInfo);
244 addFunctionCase(testGroup, "platform", "Platform Info", logPlatformInfo);
245 addFunctionCase(testGroup, "memory_limits", "Platform Memory Limits", logPlatformMemoryLimits);