Skip to content

Commit 10e32c8

Browse files
committed
[Vk] added VulkanWindowNull, that could be used as fake initial window or for headless operations
1 parent 1871a53 commit 10e32c8

15 files changed

Lines changed: 156 additions & 64 deletions

RenderSystems/Vulkan/include/OgreVulkanPrerequisites.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ namespace Ogre
107107
class VulkanTextureGpuManager;
108108
class VulkanVaoManager;
109109
class VulkanWindow;
110+
class VulkanWindowSwapChainBased;
110111
class VulkanDiscardBuffer;
111112
class VulkanDiscardBufferManager;
112113

RenderSystems/Vulkan/include/OgreVulkanQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace Ogre
113113
RefCountedFenceMap mRefCountedFences;
114114

115115
public:
116-
FastArray<VulkanWindow *> mWindowsPendingSwap;
116+
FastArray<VulkanWindowSwapChainBased *> mWindowsPendingSwap;
117117

118118
protected:
119119
FastArray<VkCommandBuffer> mPendingCmds;

RenderSystems/Vulkan/include/OgreVulkanTextureGpuManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace Ogre
9797
VulkanDevice *device, bool bCanRestrictImageViewUsage );
9898
~VulkanTextureGpuManager() override;
9999

100-
TextureGpu *createTextureGpuWindow( VulkanWindow *window );
100+
TextureGpu *createTextureGpuWindow( VulkanWindowSwapChainBased *window );
101101
TextureGpu *createWindowDepthBuffer();
102102

103103
VkImage getBlankTextureVulkanName( TextureTypes::TextureTypes textureType ) const;

RenderSystems/Vulkan/include/OgreVulkanTextureGpuWindow.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Ogre
3737
{
3838
class _OgreVulkanExport VulkanTextureGpuWindow final : public VulkanTextureGpuRenderTarget
3939
{
40-
VulkanWindow *mWindow;
40+
VulkanWindowSwapChainBased *mWindow;
4141

4242
uint32 mCurrentSwapchainIdx;
4343

@@ -48,7 +48,7 @@ namespace Ogre
4848
VulkanTextureGpuWindow( GpuPageOutStrategy::GpuPageOutStrategy pageOutStrategy,
4949
VaoManager *vaoManager, IdString name, uint32 textureFlags,
5050
TextureTypes::TextureTypes initialType,
51-
TextureGpuManager *textureManager, VulkanWindow *window );
51+
TextureGpuManager *textureManager, VulkanWindowSwapChainBased *window );
5252
~VulkanTextureGpuWindow() override;
5353

5454
void setTextureType( TextureTypes::TextureTypes textureType ) override;

RenderSystems/Vulkan/include/OgreVulkanWindow.h

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,49 @@ namespace Ogre
3636
{
3737
class VulkanWindow : public Window
3838
{
39+
protected:
40+
VulkanDevice *mDevice;
41+
42+
public:
43+
VulkanWindow( const String &title, uint32 width, uint32 height, bool fullscreenMode );
44+
45+
void _setDevice( VulkanDevice *device );
46+
void _initialize( TextureGpuManager *textureGpuManager ) override;
47+
virtual void _initialize( TextureGpuManager *textureGpuManager,
48+
const NameValuePairList *miscParams ) = 0;
49+
};
50+
51+
class VulkanWindowNull : public VulkanWindow
52+
{
53+
public:
54+
VulkanWindowNull( const String &title, uint32 width, uint32 height, bool fullscreenMode );
55+
56+
void destroy() override;
57+
void reposition( int32 leftPt, int32 topPt ) override;
58+
bool isClosed() const override;
59+
void _setVisible( bool visible ) override;
60+
bool isVisible() const override;
61+
void setHidden( bool hidden ) override;
62+
bool isHidden() const override;
63+
void _initialize( TextureGpuManager *textureGpuManager,
64+
const NameValuePairList *miscParams ) override;
65+
void swapBuffers() override;
66+
};
67+
68+
class VulkanWindowSwapChainBased : public VulkanWindow
69+
{
3970
public:
4071
enum Backend
4172
{
4273
BackendX11 = 1u << 0u
4374
};
4475
enum SwapchainStatus
4576
{
46-
/// We already called VulkanWindow::acquireNextSwapchain.
77+
/// We already called VulkanWindowSwapChainBased::acquireNextSwapchain.
4778
///
4879
/// Can only go into this state if we're coming from SwapchainReleased
4980
SwapchainAcquired,
50-
/// We already called VulkanWindow::getImageAcquiredSemaphore.
81+
/// We already called VulkanWindowSwapChainBased::getImageAcquiredSemaphore.
5182
/// Further calls to getImageAcquiredSemaphore will return null.
5283
/// Ogre is rendering or intends to into this swapchain.
5384
///
@@ -66,8 +97,6 @@ namespace Ogre
6697
bool mHwGamma;
6798
bool mClosed;
6899

69-
VulkanDevice *mDevice;
70-
71100
VkSurfaceKHR mSurfaceKHR;
72101
VkSwapchainKHR mSwapchain;
73102
FastArray<VkImage> mSwapchainImages;
@@ -89,16 +118,11 @@ namespace Ogre
89118
void acquireNextSwapchain();
90119

91120
public:
92-
VulkanWindow( const String &title, uint32 width, uint32 height, bool fullscreenMode );
93-
~VulkanWindow() override;
121+
VulkanWindowSwapChainBased( const String &title, uint32 width, uint32 height, bool fullscreenMode );
122+
~VulkanWindowSwapChainBased() override;
94123

95124
void destroy() override;
96125

97-
void _setDevice( VulkanDevice *device );
98-
void _initialize( TextureGpuManager *textureGpuManager ) override;
99-
virtual void _initialize( TextureGpuManager *textureGpuManager,
100-
const NameValuePairList *miscParams ) = 0;
101-
102126
/// Returns null if getImageAcquiredSemaphore has already been called during this frame
103127
VkSemaphore getImageAcquiredSemaphore();
104128

RenderSystems/Vulkan/include/Windowing/Android/OgreVulkanAndroidWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct ANativeWindow;
4141

4242
namespace Ogre
4343
{
44-
class _OgreVulkanExport VulkanAndroidWindow final : public VulkanWindow
44+
class _OgreVulkanExport VulkanAndroidWindow final : public VulkanWindowSwapChainBased
4545
{
4646
ANativeWindow *mNativeWindow;
4747

RenderSystems/Vulkan/include/Windowing/X11/OgreVulkanXcbWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef uint32_t xcb_atom_t;
4444

4545
namespace Ogre
4646
{
47-
class _OgreVulkanExport VulkanXcbWindow : public VulkanWindow
47+
class _OgreVulkanExport VulkanXcbWindow : public VulkanWindowSwapChainBased
4848
{
4949
xcb_connection_t *mConnection;
5050
xcb_screen_t *mScreen;

RenderSystems/Vulkan/include/Windowing/win32/OgreVulkanWin32Window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Copyright (c) 2000-present Torus Knot Software Ltd
3434

3535
namespace Ogre
3636
{
37-
class VulkanWin32Window final : public VulkanWindow
37+
class VulkanWin32Window final : public VulkanWindowSwapChainBased
3838
{
3939
private:
4040
HWND mHwnd; // Win32 Window handle

RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,13 +954,30 @@ namespace Ogre
954954
bool fullScreen,
955955
const NameValuePairList *miscParams )
956956
{
957+
String windowType;
958+
if( miscParams )
959+
{
960+
// Get variable-length params
961+
NameValuePairList::const_iterator opt = miscParams->find( "windowType" );
962+
if( opt != miscParams->end() )
963+
windowType = opt->second;
964+
}
965+
966+
VulkanWindow *win = nullptr;
967+
if( windowType == "Null" )
968+
{
969+
win = OGRE_NEW VulkanWindowNull( name, width, height, fullScreen );
970+
}
971+
else
972+
{
957973
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
958-
VulkanWindow *win = OGRE_NEW VulkanWin32Window( name, width, height, fullScreen );
974+
win = OGRE_NEW VulkanWin32Window( name, width, height, fullScreen );
959975
#elif OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
960-
VulkanWindow *win = OGRE_NEW VulkanAndroidWindow( name, width, height, fullScreen );
976+
win = OGRE_NEW VulkanAndroidWindow( name, width, height, fullScreen );
961977
#else
962-
VulkanWindow *win = OGRE_NEW VulkanXcbWindow( name, width, height, fullScreen );
978+
win = OGRE_NEW VulkanXcbWindow( name, width, height, fullScreen );
963979
#endif
980+
}
964981
mWindows.insert( win );
965982

966983
if( !mInitialized )

RenderSystems/Vulkan/src/OgreVulkanTextureGpuManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ namespace Ogre
314314
}
315315
}
316316
//-----------------------------------------------------------------------------------
317-
TextureGpu *VulkanTextureGpuManager::createTextureGpuWindow( VulkanWindow *window )
317+
TextureGpu *VulkanTextureGpuManager::createTextureGpuWindow( VulkanWindowSwapChainBased *window )
318318
{
319319
return OGRE_NEW VulkanTextureGpuWindow( GpuPageOutStrategy::Discard, mVaoManager,
320320
"RenderWindow", //

0 commit comments

Comments
 (0)