• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 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_METALSURFACE_HPP
16 #define SWIFTSHADER_METALSURFACE_HPP
17 
18 #include "VkSurfaceKHR.hpp"
19 #include "Vulkan/VkObject.hpp"
20 
21 #ifdef VK_USE_PLATFORM_MACOS_MVK
22 #	include <vulkan/vulkan_macos.h>
23 #endif
24 #ifdef VK_USE_PLATFORM_METAL_EXT
25 #	include <vulkan/vulkan_metal.h>
26 #endif
27 
28 namespace vk {
29 
30 class MetalLayer;
31 
32 class MetalSurface : public SurfaceKHR
33 {
34 public:
35 	MetalSurface(const void *pCreateInfo, void *mem);
36 
37 	void destroySurface(const VkAllocationCallbacks *pAllocator) override;
38 
39 	static size_t ComputeRequiredAllocationSize(const void *pCreateInfo);
40 
41 	VkResult getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) const override;
42 
attachImage(PresentImage * image)43 	virtual void attachImage(PresentImage *image) override {}
detachImage(PresentImage * image)44 	virtual void detachImage(PresentImage *image) override {}
45 	VkResult present(PresentImage *image) override;
46 
47 protected:
48 	MetalLayer *metalLayer = nullptr;
49 };
50 
51 #ifdef VK_USE_PLATFORM_METAL_EXT
52 class MetalSurfaceEXT : public MetalSurface, public ObjectBase<MetalSurfaceEXT, VkSurfaceKHR>
53 {
54 public:
55 	MetalSurfaceEXT(const VkMetalSurfaceCreateInfoEXT *pCreateInfo, void *mem);
56 };
57 #endif
58 
59 #ifdef VK_USE_PLATFORM_MACOS_MVK
60 class MacOSSurfaceMVK : public MetalSurface, public ObjectBase<MacOSSurfaceMVK, VkSurfaceKHR>
61 {
62 public:
63 	MacOSSurfaceMVK(const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, void *mem);
64 };
65 #endif
66 
67 }  // namespace vk
68 #endif  //SWIFTSHADER_METALSURFACE_HPP
69