git.s-ol.nu forks/DiligentCore / a8143c8
Updated Mac and iOS native window structs assiduous 3 years ago
10 changed file(s) with 39 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
4141 const SwapChainDesc& SCDesc,
4242 class RenderDeviceMtlImpl* pRenderDeviceMtl,
4343 class DeviceContextMtlImpl* pDeviceContextMtl,
44 void* pView);
44 const NativeWindow& Window);
4545 ~SwapChainMtlImpl();
4646
4747 virtual void QueryInterface(const Diligent::INTERFACE_ID& IID, IObject** ppInterface) override final;
5252 virtual void CreateSwapChainMtl(IRenderDevice* pDevice,
5353 IDeviceContext* pImmediateContext,
5454 const SwapChainDesc& SCDesc,
55 void* pView,
55 const NativeWindow& Window,
5656 ISwapChain** ppSwapChain) = 0;
5757
5858 virtual void AttachToMtlDevice(void* pMtlNativeDevice,
5353 IRenderDevice** ppDevice,
5454 IDeviceContext** ppContexts)override final;
5555
56 void CreateSwapChainMtl( IRenderDevice* pDevice,
57 IDeviceContext* pImmediateContext,
58 const SwapChainDesc& SCDesc,
59 void* pView,
60 ISwapChain** ppSwapChain )override final;
56 void CreateSwapChainMtl( IRenderDevice* pDevice,
57 IDeviceContext* pImmediateContext,
58 const SwapChainDesc& SCDesc,
59 const NativeWindow& Window,
60 ISwapChain** ppSwapChain )override final;
6161
6262 void AttachToMtlDevice(void* pMtlNativeDevice,
6363 const EngineMtlCreateInfo& EngineCI,
178178 ///
179179 /// \param [out] ppSwapChain - Address of the memory location where pointer to the new
180180 /// swap chain will be written
181 void EngineFactoryMtlImpl::CreateSwapChainMtl(IRenderDevice* pDevice,
182 IDeviceContext* pImmediateContext,
183 const SwapChainDesc& SCDesc,
184 void* pView,
185 ISwapChain** ppSwapChain )
181 void EngineFactoryMtlImpl::CreateSwapChainMtl(IRenderDevice* pDevice,
182 IDeviceContext* pImmediateContext,
183 const SwapChainDesc& SCDesc,
184 const NativeWindow& Window,
185 ISwapChain** ppSwapChain )
186186 {
187187 VERIFY( ppSwapChain, "Null pointer provided" );
188188 if( !ppSwapChain )
197197 auto &RawMemAllocator = GetRawAllocator();
198198
199199 auto *pSwapChainMtl = NEW_RC_OBJ(RawMemAllocator, "SwapChainMtlImpl instance", SwapChainMtlImpl)
200 (SCDesc, pDeviceMtl, pDeviceContextMtl, pView);
200 (SCDesc, pDeviceMtl, pDeviceContextMtl, Window);
201201 pSwapChainMtl->QueryInterface( IID_SwapChain, reinterpret_cast<IObject**>(ppSwapChain) );
202202 }
203203 catch( const std::runtime_error & )
3131 const SwapChainDesc& SCDesc,
3232 RenderDeviceMtlImpl* pRenderDeviceMtl,
3333 DeviceContextMtlImpl* pDeviceContextMtl,
34 void* pNativeWndHandle) :
34 const NativeWindow& Window) :
3535 TSwapChainBase(pRefCounters, pRenderDeviceMtl, pDeviceContextMtl, SCDesc)
3636 {
3737 LOG_ERROR_AND_THROW("Swap chain is not implemented in Metal backend");
4545 //Or better yet, use the GL3 way to get the version number
4646 glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion );
4747 glGetIntegerv( GL_MINOR_VERSION, &MinorVersion );
48 LOG_INFO_MESSAGE(Info.Window.pNSView != nullptr ? "Initialized OpenGLES " : "Attached to OpenGLES ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')');
48 LOG_INFO_MESSAGE(Info.Window.pCALayer != nullptr ? "Initialized OpenGLES " : "Attached to OpenGLES ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')');
4949
5050 // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap.
5151 // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but
7373 //Or better yet, use the GL3 way to get the version number
7474 glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion );
7575 glGetIntegerv( GL_MINOR_VERSION, &MinorVersion );
76 LOG_INFO_MESSAGE(InitAttribs.Window.pNSWindow != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')');
76 LOG_INFO_MESSAGE(InitAttribs.Window.pNSView != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')');
7777
7878 // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap.
7979 // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but
4242 m_DepthRenderBuffer(false),
4343 m_DefaultFBO(false)
4444 {
45 m_CALayer = InitAttribs.Window.pNSView;
45 m_CALayer = InitAttribs.Window.pCALayer;
4646 InitRenderBuffers(true, m_SwapChainDesc.Width, m_SwapChainDesc.Height);
4747 CreateDummyBuffers(m_pRenderDevice.RawPtr<RenderDeviceGLImpl>());
4848 }
6868 VkIOSSurfaceCreateInfoMVK surfaceCreateInfo = {};
6969
7070 surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK;
71 surfaceCreateInfo.pView = Window.pNSView;
71 surfaceCreateInfo.pView = Window.pCALayer;
7272
7373 auto err = vkCreateIOSSurfaceMVK(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, nullptr, &m_VkSurface);
7474 #elif defined(VK_USE_PLATFORM_MACOS_MVK)
7575 VkMacOSSurfaceCreateInfoMVK surfaceCreateInfo = {};
7676
7777 surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
78 surfaceCreateInfo.pView = Window.pNSWindow;
78 surfaceCreateInfo.pView = Window.pNSView;
7979
8080 auto err = vkCreateMacOSSurfaceMVK(m_VulkanInstance->GetVkInstance(), &surfaceCreateInfo, NULL, &m_VkSurface);
8181 #elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
3232
3333 struct IOSNativeWindow
3434 {
35 void* pNSView DEFAULT_INITIALIZER(nullptr);
35 void* pCALayer DEFAULT_INITIALIZER(nullptr);
36
37 #if DILIGENT_CPP_INTERFACE
38 IOSNativeWindow() noexcept
39 {}
40
41 explicit IOSNativeWindow(void* _pCALayer) noexcept :
42 pCALayer{_pCALayer}
43 {}
44 #endif
3645 };
3746
3847 DILIGENT_END_NAMESPACE // namespace Diligent
3232
3333 struct MacOSNativeWindow
3434 {
35 void* pNSWindow DEFAULT_INITIALIZER(nullptr);
35 void* pNSView DEFAULT_INITIALIZER(nullptr);
36
37 #if DILIGENT_CPP_INTERFACE
38 MacOSNativeWindow() noexcept
39 {}
40
41 explicit MacOSNativeWindow(void* _pNSView) noexcept :
42 pNSView(_pNSView)
43 {}
44 #endif
3645 };
3746
3847 DILIGENT_END_NAMESPACE // namespace Diligent