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