blob: fbba62a576590e1c2422a84568daca40c9d37fb5 [file] [log] [blame]
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08001// 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 Liatisc6eb41b2019-02-22 11:12:59 -080018#include "VkSurfaceKHR.hpp"
Ben Clayton45c697a2019-12-17 20:38:03 +000019#include "libX11.hpp"
20#include "Vulkan/VkObject.hpp"
Nicolas Capens2490b1a2020-07-13 14:33:01 -040021
22#include <vulkan/vulkan_xlib.h>
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080023
Ben Claytona9af8832019-08-14 13:09:43 +010024#include <unordered_map>
Hernan Liatisf945a5e2019-03-06 15:31:04 -080025
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080026namespace vk {
27
Ben Clayton45c697a2019-12-17 20:38:03 +000028class XlibSurfaceKHR : public SurfaceKHR, public ObjectBase<XlibSurfaceKHR, VkSurfaceKHR>
29{
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080030public:
31 XlibSurfaceKHR(const VkXlibSurfaceCreateInfoKHR *pCreateInfo, void *mem);
32
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080033 void destroySurface(const VkAllocationCallbacks *pAllocator) override;
34
35 static size_t ComputeRequiredAllocationSize(const VkXlibSurfaceCreateInfoKHR *pCreateInfo);
36
Antonio Maiorano51286432021-02-19 09:56:47 -050037 VkResult getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) const override;
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080038
Ben Clayton45c697a2019-12-17 20:38:03 +000039 virtual void attachImage(PresentImage *image) override;
40 virtual void detachImage(PresentImage *image) override;
41 VkResult present(PresentImage *image) override;
Hernan Liatis6b12a502019-03-01 15:06:13 -080042
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080043private:
Nicolas Capensd3545372019-08-09 13:59:18 -040044 Display *const pDisplay;
45 const Window window;
Hernan Liatis6b12a502019-03-01 15:06:13 -080046 GC gc;
Hernan Liatisf945a5e2019-03-06 15:31:04 -080047 Visual *visual = nullptr;
Ben Clayton45c697a2019-12-17 20:38:03 +000048 std::unordered_map<PresentImage *, XImage *> imageMap;
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080049};
50
Ben Clayton45c697a2019-12-17 20:38:03 +000051} // namespace vk
Sean Risser08762e32021-05-05 14:28:24 -040052#endif // SWIFTSHADER_XLIBSURFACEKHR_HPP