blob: 7b718a65f369097ed625ddd28a7e93105bf76b5d [file] [log] [blame]
/*
* MVKSurface.h
*
* Copyright (c) 2014-2019 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "mvk_vulkan.h"
#include "MVKBaseObject.h"
#include <mutex>
// Expose MoltenVK Apple surface extension functionality
#ifdef VK_USE_PLATFORM_IOS_MVK
# define vkCreate_PLATFORM_SurfaceMVK vkCreateIOSSurfaceMVK
# define Vk_PLATFORM_SurfaceCreateInfoMVK VkIOSSurfaceCreateInfoMVK
# define PLATFORM_VIEW_CLASS UIView
# import <UIKit/UIView.h>
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
# define vkCreate_PLATFORM_SurfaceMVK vkCreateMacOSSurfaceMVK
# define Vk_PLATFORM_SurfaceCreateInfoMVK VkMacOSSurfaceCreateInfoMVK
# define PLATFORM_VIEW_CLASS NSView
# import <AppKit/NSView.h>
#endif
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
class MVKInstance;
@class MVKBlockObserver;
#pragma mark MVKSurface
/** Represents a Vulkan WSI surface. */
class MVKSurface : public MVKConfigurableObject {
public:
/** Returns the CAMetalLayer underlying this surface. */
inline CAMetalLayer* getCAMetalLayer() {
std::lock_guard<std::mutex> lock(_lock);
return _mtlCAMetalLayer;
}
#pragma mark Construction
MVKSurface(MVKInstance* mvkInstance,
const Vk_PLATFORM_SurfaceCreateInfoMVK* pCreateInfo,
const VkAllocationCallbacks* pAllocator);
~MVKSurface() override;
protected:
CAMetalLayer* _mtlCAMetalLayer;
std::mutex _lock;
MVKBlockObserver* _layerObserver;
};