1*35238bceSAndroid Build Coastguard Worker #ifndef _TCUPLATFORM_HPP
2*35238bceSAndroid Build Coastguard Worker #define _TCUPLATFORM_HPP
3*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program Tester Core
5*35238bceSAndroid Build Coastguard Worker * ----------------------------------------
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
8*35238bceSAndroid Build Coastguard Worker *
9*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
10*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
11*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
14*35238bceSAndroid Build Coastguard Worker *
15*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
16*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
17*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
19*35238bceSAndroid Build Coastguard Worker * limitations under the License.
20*35238bceSAndroid Build Coastguard Worker *
21*35238bceSAndroid Build Coastguard Worker *//*!
22*35238bceSAndroid Build Coastguard Worker * \file
23*35238bceSAndroid Build Coastguard Worker * \brief Platform (OS) specific services.
24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
25*35238bceSAndroid Build Coastguard Worker
26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp"
27*35238bceSAndroid Build Coastguard Worker
28*35238bceSAndroid Build Coastguard Worker #include <cstdint>
29*35238bceSAndroid Build Coastguard Worker
30*35238bceSAndroid Build Coastguard Worker namespace glu
31*35238bceSAndroid Build Coastguard Worker {
32*35238bceSAndroid Build Coastguard Worker class Platform;
33*35238bceSAndroid Build Coastguard Worker }
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker namespace eglu
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker class Platform;
38*35238bceSAndroid Build Coastguard Worker }
39*35238bceSAndroid Build Coastguard Worker
40*35238bceSAndroid Build Coastguard Worker namespace vk
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker class Platform;
43*35238bceSAndroid Build Coastguard Worker }
44*35238bceSAndroid Build Coastguard Worker
45*35238bceSAndroid Build Coastguard Worker namespace tcu
46*35238bceSAndroid Build Coastguard Worker {
47*35238bceSAndroid Build Coastguard Worker
48*35238bceSAndroid Build Coastguard Worker class CommandLine;
49*35238bceSAndroid Build Coastguard Worker class FunctionLibrary;
50*35238bceSAndroid Build Coastguard Worker
51*35238bceSAndroid Build Coastguard Worker struct PlatformMemoryLimits
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker // System memory properties
54*35238bceSAndroid Build Coastguard Worker size_t totalSystemMemory; // #bytes of system memory (heap + HOST_LOCAL) tests must not exceed
55*35238bceSAndroid Build Coastguard Worker
56*35238bceSAndroid Build Coastguard Worker // Device memory properties
57*35238bceSAndroid Build Coastguard Worker std::uint64_t
58*35238bceSAndroid Build Coastguard Worker totalDeviceLocalMemory; // #bytes of total DEVICE_LOCAL memory tests must not exceed or 0 if DEVICE_LOCAL counts against system memory
59*35238bceSAndroid Build Coastguard Worker std::uint64_t deviceMemoryAllocationGranularity; // VkDeviceMemory allocation granularity (typically page size)
60*35238bceSAndroid Build Coastguard Worker
61*35238bceSAndroid Build Coastguard Worker // Device memory page table geometry
62*35238bceSAndroid Build Coastguard Worker std::uint64_t devicePageSize; // Page size on device (must be rounded up to the nearest POT)
63*35238bceSAndroid Build Coastguard Worker std::uint64_t devicePageTableEntrySize; // Number of bytes per page table size
64*35238bceSAndroid Build Coastguard Worker size_t devicePageTableHierarchyLevels; // Number of levels in device page table hierarchy
65*35238bceSAndroid Build Coastguard Worker
PlatformMemoryLimitstcu::PlatformMemoryLimits66*35238bceSAndroid Build Coastguard Worker PlatformMemoryLimits(void)
67*35238bceSAndroid Build Coastguard Worker : totalSystemMemory(0)
68*35238bceSAndroid Build Coastguard Worker , totalDeviceLocalMemory(0)
69*35238bceSAndroid Build Coastguard Worker , deviceMemoryAllocationGranularity(0)
70*35238bceSAndroid Build Coastguard Worker , devicePageSize(0)
71*35238bceSAndroid Build Coastguard Worker , devicePageTableEntrySize(0)
72*35238bceSAndroid Build Coastguard Worker , devicePageTableHierarchyLevels(0)
73*35238bceSAndroid Build Coastguard Worker {
74*35238bceSAndroid Build Coastguard Worker }
75*35238bceSAndroid Build Coastguard Worker };
76*35238bceSAndroid Build Coastguard Worker
77*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
78*35238bceSAndroid Build Coastguard Worker * \brief Base class for platform implementation.
79*35238bceSAndroid Build Coastguard Worker *
80*35238bceSAndroid Build Coastguard Worker * This class represents the minimum set of functionality for a platform
81*35238bceSAndroid Build Coastguard Worker * port.
82*35238bceSAndroid Build Coastguard Worker *
83*35238bceSAndroid Build Coastguard Worker * In addition to implementing Platform class, main entry point must be
84*35238bceSAndroid Build Coastguard Worker * created that takes care of parsing command line, creating log and
85*35238bceSAndroid Build Coastguard Worker * executing tcu::App. See tcuMain.cpp for reference on implementing
86*35238bceSAndroid Build Coastguard Worker * application stub.
87*35238bceSAndroid Build Coastguard Worker *
88*35238bceSAndroid Build Coastguard Worker * If the platform uses standard posix-style main() for application entry
89*35238bceSAndroid Build Coastguard Worker * point, tcuMain.cpp can be used as is. In that case you only have to
90*35238bceSAndroid Build Coastguard Worker * implement createPlatform().
91*35238bceSAndroid Build Coastguard Worker *
92*35238bceSAndroid Build Coastguard Worker * API-specific platform interfaces (glu::Platform, eglu::Platform and vk::Platform)
93*35238bceSAndroid Build Coastguard Worker * can be provided by implementing get<API>Platform() functions.
94*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
95*35238bceSAndroid Build Coastguard Worker class Platform
96*35238bceSAndroid Build Coastguard Worker {
97*35238bceSAndroid Build Coastguard Worker public:
98*35238bceSAndroid Build Coastguard Worker Platform(void);
99*35238bceSAndroid Build Coastguard Worker virtual ~Platform(void);
100*35238bceSAndroid Build Coastguard Worker
101*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
102*35238bceSAndroid Build Coastguard Worker * \brief Process platform-specific events.
103*35238bceSAndroid Build Coastguard Worker *
104*35238bceSAndroid Build Coastguard Worker * Test framework will call this function between test cases and test case
105*35238bceSAndroid Build Coastguard Worker * iterations. Any event handling that must be done periodically should be
106*35238bceSAndroid Build Coastguard Worker * done here.
107*35238bceSAndroid Build Coastguard Worker *
108*35238bceSAndroid Build Coastguard Worker * Test framework will decide whether to continue test execution based on
109*35238bceSAndroid Build Coastguard Worker * return code. For instance if the application receives close event from OS,
110*35238bceSAndroid Build Coastguard Worker * it should communicate that to framework by returning false.
111*35238bceSAndroid Build Coastguard Worker *
112*35238bceSAndroid Build Coastguard Worker * \note Do not do rendering buffer swaps here.
113*35238bceSAndroid Build Coastguard Worker * Do it in RenderContext::postIterate() instead.
114*35238bceSAndroid Build Coastguard Worker * \return true if test execution should continue, false otherwise.
115*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
116*35238bceSAndroid Build Coastguard Worker virtual bool processEvents(void);
117*35238bceSAndroid Build Coastguard Worker
118*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
119*35238bceSAndroid Build Coastguard Worker * \brief Get GL platform interface
120*35238bceSAndroid Build Coastguard Worker *
121*35238bceSAndroid Build Coastguard Worker * GL-specific platform interface is defined by glu::Platform. If your
122*35238bceSAndroid Build Coastguard Worker * platform port supports OpenGL (ES), you should implement this function.
123*35238bceSAndroid Build Coastguard Worker *
124*35238bceSAndroid Build Coastguard Worker * Default implementation throws tcu::NotSupportedError exception.
125*35238bceSAndroid Build Coastguard Worker *
126*35238bceSAndroid Build Coastguard Worker * \return Reference to GL platform interface.
127*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
128*35238bceSAndroid Build Coastguard Worker virtual const glu::Platform &getGLPlatform(void) const;
129*35238bceSAndroid Build Coastguard Worker
130*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
131*35238bceSAndroid Build Coastguard Worker * \brief Get EGL platform interface
132*35238bceSAndroid Build Coastguard Worker *
133*35238bceSAndroid Build Coastguard Worker * EGL-specific platform interface is defined by eglu::Platform. If your
134*35238bceSAndroid Build Coastguard Worker * platform port supports EGL, you should implement this function.
135*35238bceSAndroid Build Coastguard Worker *
136*35238bceSAndroid Build Coastguard Worker * Default implementation throws tcu::NotSupportedError exception.
137*35238bceSAndroid Build Coastguard Worker *
138*35238bceSAndroid Build Coastguard Worker * \return Reference to EGL platform interface.
139*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
140*35238bceSAndroid Build Coastguard Worker virtual const eglu::Platform &getEGLPlatform(void) const;
141*35238bceSAndroid Build Coastguard Worker
142*35238bceSAndroid Build Coastguard Worker virtual const vk::Platform &getVulkanPlatform(void) const;
143*35238bceSAndroid Build Coastguard Worker
144*35238bceSAndroid Build Coastguard Worker virtual void getMemoryLimits(PlatformMemoryLimits &limits) const;
145*35238bceSAndroid Build Coastguard Worker };
146*35238bceSAndroid Build Coastguard Worker
getMemoryLimits(const tcu::Platform & platform)147*35238bceSAndroid Build Coastguard Worker inline tcu::PlatformMemoryLimits getMemoryLimits(const tcu::Platform &platform)
148*35238bceSAndroid Build Coastguard Worker {
149*35238bceSAndroid Build Coastguard Worker tcu::PlatformMemoryLimits limits;
150*35238bceSAndroid Build Coastguard Worker platform.getMemoryLimits(limits);
151*35238bceSAndroid Build Coastguard Worker return limits;
152*35238bceSAndroid Build Coastguard Worker }
153*35238bceSAndroid Build Coastguard Worker
154*35238bceSAndroid Build Coastguard Worker } // namespace tcu
155*35238bceSAndroid Build Coastguard Worker
156*35238bceSAndroid Build Coastguard Worker #endif // _TCUPLATFORM_HPP
157