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