From d5c737924ebf78a3f2639e04c6d12eb631df9764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 4 May 2015 14:05:04 -0700 Subject: [PATCH] Added back buffer depth stencil pointer to platform data. --- include/bgfxplatform.c99.h | 9 ++-- include/bgfxplatform.h | 101 ++++++++++++++++++++----------------- src/renderer_d3d11.cpp | 13 +++-- 3 files changed, 69 insertions(+), 54 deletions(-) diff --git a/include/bgfxplatform.c99.h b/include/bgfxplatform.c99.h index ce60185d1..31c65bd6f 100644 --- a/include/bgfxplatform.c99.h +++ b/include/bgfxplatform.c99.h @@ -33,10 +33,11 @@ BGFX_C_API bgfx_render_frame_t bgfx_render_frame(); typedef struct bgfx_platform_data { - void* ndt; - void* nwh; - void* context; - void* backbuffer; + void* ndt; + void* nwh; + void* context; + void* backBuffer; + void* backBufferDS; } bgfx_platform_data_t; diff --git a/include/bgfxplatform.h b/include/bgfxplatform.h index 416c37388..8a2cf5a07 100644 --- a/include/bgfxplatform.h +++ b/include/bgfxplatform.h @@ -33,10 +33,11 @@ namespace bgfx struct PlatformData { - void* ndt; //< Native display type - void* nwh; //< Native window handle - void* context; //< GL context, or D3D device - void* backbuffer; //< GL backbuffer, or D3D render target view + void* ndt; //< Native display type + void* nwh; //< Native window handle + void* context; //< GL context, or D3D device + void* backBuffer; //< GL backbuffer, or D3D render target view + void* backBufferDS; //< Backbuffer depth/stencil. }; void setPlatformData(const PlatformData& _hooks); @@ -52,10 +53,11 @@ namespace bgfx inline void androidSetWindow(::ANativeWindow* _window) { PlatformData pd; - pd.ndt = NULL; - pd.nwh = _window; - pd.context = NULL; - pd.backbuffer = NULL; + pd.ndt = NULL; + pd.nwh = _window; + pd.context = NULL; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); } @@ -68,10 +70,11 @@ namespace bgfx inline void iosSetEaglLayer(void* _window) { PlatformData pd; - pd.ndt = NULL; - pd.nwh = _window; - pd.context = NULL; - pd.backbuffer = NULL; + pd.ndt = NULL; + pd.nwh = _window; + pd.context = NULL; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); } @@ -85,10 +88,11 @@ namespace bgfx inline void x11SetDisplayWindow(void* _display, uint32_t _window, void* _glx = NULL) { PlatformData pd; - pd.ndt = _display; - pd.nwh = (void*)(uintptr_t)_window; - pd.context = _glx; - pd.backbuffer = NULL; + pd.ndt = _display; + pd.nwh = (void*)(uintptr_t)_window; + pd.context = _glx; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); } @@ -114,10 +118,11 @@ namespace bgfx inline void osxSetNSWindow(void* _window, void* _nsgl = NULL) { PlatformData pd; - pd.ndt = NULL; - pd.nwh = _window; - pd.context = _nsgl; - pd.backbuffer = NULL; + pd.ndt = NULL; + pd.nwh = _window; + pd.context = _nsgl; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); } @@ -132,10 +137,11 @@ namespace bgfx inline void winSetHwnd(::HWND _window) { PlatformData pd; - pd.ndt = NULL; - pd.nwh = _window; - pd.context = NULL; - pd.backbuffer = NULL; + pd.ndt = NULL; + pd.nwh = _window; + pd.context = NULL; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); } @@ -150,10 +156,11 @@ namespace bgfx inline void winrtSetWindow(::IUnknown* _window) { PlatformData pd; - pd.ndt = NULL; - pd.nwh = _window; - pd.context = NULL; - pd.backbuffer = NULL; + pd.ndt = NULL; + pd.nwh = _window; + pd.context = NULL; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); } @@ -179,17 +186,18 @@ namespace bgfx PlatformData pd; # if BX_PLATFORM_LINUX || BX_PLATFORM_FREEBSD - pd.ndt = wmi.info.x11.display; - pd.nwh = (void*)(uintptr_t)wmi.info.x11.window; + pd.ndt = wmi.info.x11.display; + pd.nwh = (void*)(uintptr_t)wmi.info.x11.window; # elif BX_PLATFORM_OSX - pd.ndt = NULL; - pd.nwh = wmi.info.cocoa.window; + pd.ndt = NULL; + pd.nwh = wmi.info.cocoa.window; # elif BX_PLATFORM_WINDOWS - pd.ndt = NULL; - pd.nwh = wmi.info.win.window; + pd.ndt = NULL; + pd.nwh = wmi.info.win.window; # endif // BX_PLATFORM_ - pd.context = NULL; - pd.backbuffer = NULL; + pd.context = NULL; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); return true; @@ -219,19 +227,20 @@ namespace bgfx { PlatformData pd; # if BX_PLATFORM_LINUX || BX_PLATFORM_FREEBSD - pd.ndt = glfwGetX11Display(); - pd.nwh = (void*)(uintptr_t)glfwGetX11Window(_window); - pd.context = glfwGetGLXContext(_window); + pd.ndt = glfwGetX11Display(); + pd.nwh = (void*)(uintptr_t)glfwGetX11Window(_window); + pd.context = glfwGetGLXContext(_window); # elif BX_PLATFORM_OSX - pd.ndt = NULL; - pd.nwh = glfwGetCocoaWindow(_window); - pd.context = glfwGetNSGLContext(_window); + pd.ndt = NULL; + pd.nwh = glfwGetCocoaWindow(_window); + pd.context = glfwGetNSGLContext(_window); # elif BX_PLATFORM_WINDOWS - pd.ndt = NULL; - pd.nwh = glfwGetWin32Window(_window); - pd.context = NULL; + pd.ndt = NULL; + pd.nwh = glfwGetWin32Window(_window); + pd.context = NULL; # endif // BX_PLATFORM_WINDOWS - pd.backbuffer = NULL; + pd.backBuffer = NULL; + pd.backBufferDS = NULL; setPlatformData(pd); } diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index fc3407e78..b13b2a0ce 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -717,7 +717,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); ; g_caps.deviceId = (uint16_t)m_adapterDesc.DeviceId; - if (NULL == g_platformData.backbuffer) + if (NULL == g_platformData.backBuffer) { #if BX_PLATFORM_WINRT hr = adapter->GetParent(__uuidof(IDXGIFactory2), (void**)&m_factory); @@ -780,7 +780,8 @@ BX_PRAGMA_DIAGNOSTIC_POP(); m_scd.SampleDesc.Count = 1; m_scd.SampleDesc.Quality = 0; setBufferSize(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT); - m_backBufferColor = (ID3D11RenderTargetView*)g_platformData.backbuffer; + m_backBufferColor = (ID3D11RenderTargetView*)g_platformData.backBuffer; + m_backBufferDepthStencil = (ID3D11DepthStencilView*)g_platformData.backBufferDS; } m_numWindows = 1; @@ -1424,7 +1425,10 @@ BX_PRAGMA_DIAGNOSTIC_POP(); { ovrPreReset(); - DX_RELEASE(m_backBufferDepthStencil, 0); + if (NULL == g_platformData.backBufferDS) + { + DX_RELEASE(m_backBufferDepthStencil, 0); + } if (NULL != m_swapChain) { @@ -1620,7 +1624,8 @@ BX_PRAGMA_DIAGNOSTIC_POP(); if (NULL == m_swapChain) { // Updated backbuffer if it changed in PlatformData. - m_backBufferColor = (ID3D11RenderTargetView*)g_platformData.backbuffer; + m_backBufferColor = (ID3D11RenderTargetView*)g_platformData.backBuffer; + m_backBufferDepthStencil = (ID3D11DepthStencilView*)g_platformData.backBufferDS; } else {