Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 1 | // Copyright 2018 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef SWIFTSHADER_XLIBSURFACEKHR_HPP |
| 16 | #define SWIFTSHADER_XLIBSURFACEKHR_HPP |
| 17 | |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 18 | #include "VkSurfaceKHR.hpp" |
Ben Clayton | 45c697a | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 19 | #include "libX11.hpp" |
| 20 | #include "Vulkan/VkObject.hpp" |
Nicolas Capens | 2490b1a | 2020-07-13 14:33:01 -0400 | [diff] [blame] | 21 | |
| 22 | #include <vulkan/vulkan_xlib.h> |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 23 | |
Ben Clayton | a9af883 | 2019-08-14 13:09:43 +0100 | [diff] [blame] | 24 | #include <unordered_map> |
Hernan Liatis | f945a5e | 2019-03-06 15:31:04 -0800 | [diff] [blame] | 25 | |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 26 | namespace vk { |
| 27 | |
Ben Clayton | 45c697a | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 28 | class XlibSurfaceKHR : public SurfaceKHR, public ObjectBase<XlibSurfaceKHR, VkSurfaceKHR> |
| 29 | { |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 30 | public: |
| 31 | XlibSurfaceKHR(const VkXlibSurfaceCreateInfoKHR *pCreateInfo, void *mem); |
| 32 | |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 33 | void destroySurface(const VkAllocationCallbacks *pAllocator) override; |
| 34 | |
| 35 | static size_t ComputeRequiredAllocationSize(const VkXlibSurfaceCreateInfoKHR *pCreateInfo); |
| 36 | |
Antonio Maiorano | 5128643 | 2021-02-19 09:56:47 -0500 | [diff] [blame] | 37 | VkResult getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) const override; |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 38 | |
Ben Clayton | 45c697a | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 39 | virtual void attachImage(PresentImage *image) override; |
| 40 | virtual void detachImage(PresentImage *image) override; |
| 41 | VkResult present(PresentImage *image) override; |
Hernan Liatis | 6b12a50 | 2019-03-01 15:06:13 -0800 | [diff] [blame] | 42 | |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 43 | private: |
Nicolas Capens | d354537 | 2019-08-09 13:59:18 -0400 | [diff] [blame] | 44 | Display *const pDisplay; |
| 45 | const Window window; |
Hernan Liatis | 6b12a50 | 2019-03-01 15:06:13 -0800 | [diff] [blame] | 46 | GC gc; |
Hernan Liatis | f945a5e | 2019-03-06 15:31:04 -0800 | [diff] [blame] | 47 | Visual *visual = nullptr; |
Ben Clayton | 45c697a | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 48 | std::unordered_map<PresentImage *, XImage *> imageMap; |
Hernan Liatis | c6eb41b | 2019-02-22 11:12:59 -0800 | [diff] [blame] | 49 | }; |
| 50 | |
Ben Clayton | 45c697a | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 51 | } // namespace vk |
Sean Risser | 08762e3 | 2021-05-05 14:28:24 -0400 | [diff] [blame^] | 52 | #endif // SWIFTSHADER_XLIBSURFACEKHR_HPP |