1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program Tester Core 3 * ---------------------------------------- 4 * 5 * Copyright (c) 2022 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 Fuchsia Platform definition. 22 *//*--------------------------------------------------------------------*/ 23 24 #include "tcuFunctionLibrary.hpp" 25 #include "tcuPlatform.hpp" 26 #include "vkPlatform.hpp" 27 28 class FuchsiaVkLibrary : public vk::Library 29 { 30 public: FuchsiaVkLibrary(const char * library_path)31 FuchsiaVkLibrary(const char *library_path) 32 : library_(library_path ? library_path : "libvulkan.so") 33 , driver_(library_) 34 { 35 } 36 getPlatformInterface() const37 const vk::PlatformInterface &getPlatformInterface() const 38 { 39 return driver_; 40 } getFunctionLibrary(void) const41 const tcu::FunctionLibrary &getFunctionLibrary(void) const 42 { 43 return library_; 44 } 45 46 private: 47 const tcu::DynamicFunctionLibrary library_; 48 const vk::PlatformDriver driver_; 49 }; 50 51 class FuchsiaVkPlatform : public vk::Platform 52 { 53 public: createLibrary(const char * library_path) const54 vk::Library *createLibrary(const char *library_path) const 55 { 56 return new FuchsiaVkLibrary(library_path); 57 } 58 describePlatform(std::ostream & dst) const59 void describePlatform(std::ostream &dst) const 60 { 61 dst << "OS: Fuchsia\n"; 62 const char *cpu = "Unknown"; 63 #if defined(__x86_64__) 64 cpu = "x86_64"; 65 #elif defined(__aarch64__) 66 cpu = "aarch64"; 67 #endif 68 dst << "CPU: " << cpu << "\n"; 69 } 70 getMemoryLimits(tcu::PlatformMemoryLimits & limits) const71 void getMemoryLimits(tcu::PlatformMemoryLimits &limits) const 72 { 73 // Copied from tcuX11VulkanPlatform.cpp 74 limits.totalSystemMemory = 256 * 1024 * 1024; 75 limits.totalDeviceLocalMemory = 0; // unified memory 76 limits.deviceMemoryAllocationGranularity = 64 * 1024; 77 limits.devicePageSize = 4096; 78 limits.devicePageTableEntrySize = 8; 79 limits.devicePageTableHierarchyLevels = 3; 80 } 81 }; 82 83 class FuchsiaPlatform : public tcu::Platform 84 { 85 public: ~FuchsiaPlatform()86 ~FuchsiaPlatform() 87 { 88 } 89 getVulkanPlatform() const90 const vk::Platform &getVulkanPlatform() const 91 { 92 return vk_platform_; 93 } 94 95 private: 96 FuchsiaVkPlatform vk_platform_; 97 }; 98 createPlatform()99tcu::Platform *createPlatform() 100 { 101 return new FuchsiaPlatform(); 102 } 103