• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 public:
FuchsiaVkLibrary(const char * library_path)30     FuchsiaVkLibrary(const char* library_path)
31         : library_(library_path ? library_path : "libvulkan.so"), driver_(library_) {}
32 
getPlatformInterface() const33     const vk::PlatformInterface& getPlatformInterface() const {
34         return driver_;
35     }
getFunctionLibrary(void) const36     const tcu::FunctionLibrary&             getFunctionLibrary              (void) const
37     {
38             return library_;
39     }
40 
41 private:
42     const tcu::DynamicFunctionLibrary library_;
43     const vk::PlatformDriver driver_;
44 };
45 
46 class FuchsiaVkPlatform : public vk::Platform {
47 public:
createLibrary(const char * library_path) const48     vk::Library* createLibrary(const char* library_path) const {
49         return new FuchsiaVkLibrary(library_path);
50     }
51 
describePlatform(std::ostream & dst) const52     void describePlatform (std::ostream& dst) const
53     {
54         dst << "OS: Fuchsia\n";
55         const char* cpu = "Unknown";
56 #if defined(__x86_64__)
57         cpu = "x86_64";
58 #elif defined(__aarch64__)
59         cpu = "aarch64";
60 #endif
61         dst << "CPU: " << cpu << "\n";
62     }
63 
getMemoryLimits(tcu::PlatformMemoryLimits & limits) const64     void getMemoryLimits(tcu::PlatformMemoryLimits& limits) const {
65         // Copied from tcuX11VulkanPlatform.cpp
66         limits.totalSystemMemory = 256 * 1024 * 1024;
67         limits.totalDeviceLocalMemory = 0; // unified memory
68         limits.deviceMemoryAllocationGranularity = 64 * 1024;
69         limits.devicePageSize = 4096;
70         limits.devicePageTableEntrySize = 8;
71         limits.devicePageTableHierarchyLevels = 3;
72     }
73 };
74 
75 class FuchsiaPlatform : public tcu::Platform {
76 public:
~FuchsiaPlatform()77     ~FuchsiaPlatform() {}
78 
getVulkanPlatform() const79     const vk::Platform& getVulkanPlatform() const { return vk_platform_; }
80 
81 private:
82     FuchsiaVkPlatform vk_platform_;
83 };
84 
createPlatform()85 tcu::Platform* createPlatform() {
86     return new FuchsiaPlatform();
87 }
88