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