From f22ff6a3401290fd9fa8a05dcd36e35746c67a96 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 24 Jan 2023 11:16:25 -0800 Subject: [PATCH] the createSwapChain flag shouldn't be a reference --- .../backend/include/backend/platforms/OpenGLPlatform.h | 4 ++-- .../backend/include/backend/platforms/PlatformCocoaGL.h | 4 ++-- .../include/backend/platforms/PlatformCocoaTouchGL.h | 4 ++-- filament/backend/include/backend/platforms/PlatformEGL.h | 4 ++-- filament/backend/include/backend/platforms/PlatformGLX.h | 4 ++-- filament/backend/include/backend/platforms/PlatformWGL.h | 4 ++-- .../backend/include/backend/platforms/PlatformWebGL.h | 4 ++-- filament/backend/src/opengl/platforms/PlatformCocoaGL.mm | 6 ++---- .../backend/src/opengl/platforms/PlatformCocoaTouchGL.mm | 6 ++---- filament/backend/src/opengl/platforms/PlatformEGL.cpp | 4 ++-- filament/backend/src/opengl/platforms/PlatformGLX.cpp | 8 ++------ filament/backend/src/opengl/platforms/PlatformWGL.cpp | 4 ++-- filament/backend/src/opengl/platforms/PlatformWebGL.cpp | 4 ++-- 13 files changed, 26 insertions(+), 34 deletions(-) diff --git a/filament/backend/include/backend/platforms/OpenGLPlatform.h b/filament/backend/include/backend/platforms/OpenGLPlatform.h index 74d7033740..d9c8476280 100644 --- a/filament/backend/include/backend/platforms/OpenGLPlatform.h +++ b/filament/backend/include/backend/platforms/OpenGLPlatform.h @@ -66,7 +66,7 @@ public: * @return The driver's SwapChain object. * */ - virtual SwapChain* createSwapChain(void* nativeWindow, uint64_t& flags) noexcept = 0; + virtual SwapChain* createSwapChain(void* nativeWindow, uint64_t flags) noexcept = 0; /** * Called by the driver create a headless SwapChain. @@ -79,7 +79,7 @@ public: * TODO: we need a more generic way of passing construction parameters * A void* might be enough. */ - virtual SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept = 0; + virtual SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept = 0; /** * Called by the driver to destroys the SwapChain diff --git a/filament/backend/include/backend/platforms/PlatformCocoaGL.h b/filament/backend/include/backend/platforms/PlatformCocoaGL.h index ac5befb31b..f32d0a25bb 100644 --- a/filament/backend/include/backend/platforms/PlatformCocoaGL.h +++ b/filament/backend/include/backend/platforms/PlatformCocoaGL.h @@ -52,8 +52,8 @@ protected: void terminate() noexcept override; - SwapChain* createSwapChain(void* nativewindow, uint64_t& flags) noexcept override; - SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept override; + SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override; + SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override; void destroySwapChain(SwapChain* swapChain) noexcept override; void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; void commit(SwapChain* swapChain) noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h b/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h index a28e3f34c1..5eb3b63b06 100644 --- a/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h +++ b/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h @@ -47,8 +47,8 @@ public: uint32_t createDefaultRenderTarget() noexcept override; - SwapChain* createSwapChain(void* nativewindow, uint64_t& flags) noexcept override; - SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept override; + SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override; + SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override; void destroySwapChain(SwapChain* swapChain) noexcept override; void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; void commit(SwapChain* swapChain) noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformEGL.h b/filament/backend/include/backend/platforms/PlatformEGL.h index 1830e8c1b9..a4505c42ab 100644 --- a/filament/backend/include/backend/platforms/PlatformEGL.h +++ b/filament/backend/include/backend/platforms/PlatformEGL.h @@ -58,8 +58,8 @@ protected: void terminate() noexcept override; - SwapChain* createSwapChain(void* nativewindow, uint64_t& flags) noexcept override; - SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept override; + SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override; + SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override; void destroySwapChain(SwapChain* swapChain) noexcept override; void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; void commit(SwapChain* swapChain) noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformGLX.h b/filament/backend/include/backend/platforms/PlatformGLX.h index e9323e957b..b2be5e4062 100644 --- a/filament/backend/include/backend/platforms/PlatformGLX.h +++ b/filament/backend/include/backend/platforms/PlatformGLX.h @@ -48,8 +48,8 @@ protected: void terminate() noexcept override; - SwapChain* createSwapChain(void* nativewindow, uint64_t& flags) noexcept override; - SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept override; + SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override; + SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override; void destroySwapChain(SwapChain* swapChain) noexcept override; void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; void commit(SwapChain* swapChain) noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformWGL.h b/filament/backend/include/backend/platforms/PlatformWGL.h index e7b40d10c6..d18a20b2cd 100644 --- a/filament/backend/include/backend/platforms/PlatformWGL.h +++ b/filament/backend/include/backend/platforms/PlatformWGL.h @@ -46,8 +46,8 @@ protected: void terminate() noexcept override; - SwapChain* createSwapChain(void* nativewindow, uint64_t& flags) noexcept override; - SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept override; + SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override; + SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override; void destroySwapChain(SwapChain* swapChain) noexcept override; void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; void commit(SwapChain* swapChain) noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformWebGL.h b/filament/backend/include/backend/platforms/PlatformWebGL.h index 01d7860a44..92bff0c4e8 100644 --- a/filament/backend/include/backend/platforms/PlatformWebGL.h +++ b/filament/backend/include/backend/platforms/PlatformWebGL.h @@ -43,8 +43,8 @@ protected: void terminate() noexcept override; - SwapChain* createSwapChain(void* nativewindow, uint64_t& flags) noexcept override; - SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept override; + SwapChain* createSwapChain(void* nativewindow, uint64_t flags) noexcept override; + SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override; void destroySwapChain(SwapChain* swapChain) noexcept override; void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; void commit(SwapChain* swapChain) noexcept override; diff --git a/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm b/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm index e57f273284..55d5cb7925 100644 --- a/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm +++ b/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm @@ -171,9 +171,7 @@ void PlatformCocoaGL::terminate() noexcept { bluegl::unbind(); } -Platform::SwapChain* PlatformCocoaGL::createSwapChain(void* nativewindow, uint64_t& flags) noexcept { - // Transparent SwapChain is not supported - flags &= ~SWAP_CHAIN_CONFIG_TRANSPARENT; +Platform::SwapChain* PlatformCocoaGL::createSwapChain(void* nativewindow, uint64_t flags) noexcept { NSView* nsView = (__bridge NSView*)nativewindow; CocoaGLSwapChain* swapChain = new CocoaGLSwapChain( nsView ); @@ -188,7 +186,7 @@ Platform::SwapChain* PlatformCocoaGL::createSwapChain(void* nativewindow, uint64 return swapChain; } -Platform::SwapChain* PlatformCocoaGL::createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept { +Platform::SwapChain* PlatformCocoaGL::createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept { NSView* nsView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, width, height)]; // adding the pointer to the array retains the NSView diff --git a/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm b/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm index cdec87d83f..fe66cd81b6 100644 --- a/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm +++ b/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm @@ -99,13 +99,11 @@ void PlatformCocoaTouchGL::terminate() noexcept { delete pImpl->mExternalImageSharedGl; } -Platform::SwapChain* PlatformCocoaTouchGL::createSwapChain(void* nativewindow, uint64_t& flags) noexcept { - // Transparent swap chain is not supported - flags &= ~SWAP_CHAIN_CONFIG_TRANSPARENT; +Platform::SwapChain* PlatformCocoaTouchGL::createSwapChain(void* nativewindow, uint64_t flags) noexcept { return (SwapChain*) nativewindow; } -Platform::SwapChain* PlatformCocoaTouchGL::createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept { +Platform::SwapChain* PlatformCocoaTouchGL::createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept { CAEAGLLayer* glLayer = [CAEAGLLayer layer]; glLayer.frame = CGRectMake(0, 0, width, height); diff --git a/filament/backend/src/opengl/platforms/PlatformEGL.cpp b/filament/backend/src/opengl/platforms/PlatformEGL.cpp index 215b6d1914..1fc5ffeb52 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGL.cpp @@ -264,7 +264,7 @@ void PlatformEGL::terminate() noexcept { } Platform::SwapChain* PlatformEGL::createSwapChain( - void* nativeWindow, uint64_t& flags) noexcept { + void* nativeWindow, uint64_t flags) noexcept { EGLSurface sur = eglCreateWindowSurface(mEGLDisplay, (flags & SWAP_CHAIN_CONFIG_TRANSPARENT) ? mEGLTransparentConfig : mEGLConfig, @@ -282,7 +282,7 @@ Platform::SwapChain* PlatformEGL::createSwapChain( } Platform::SwapChain* PlatformEGL::createSwapChain( - uint32_t width, uint32_t height, uint64_t& flags) noexcept { + uint32_t width, uint32_t height, uint64_t flags) noexcept { EGLint attribs[] = { EGL_WIDTH, EGLint(width), diff --git a/filament/backend/src/opengl/platforms/PlatformGLX.cpp b/filament/backend/src/opengl/platforms/PlatformGLX.cpp index 46f7d61008..7a11f9f3f2 100644 --- a/filament/backend/src/opengl/platforms/PlatformGLX.cpp +++ b/filament/backend/src/opengl/platforms/PlatformGLX.cpp @@ -239,16 +239,12 @@ void PlatformGLX::terminate() noexcept { bluegl::unbind(); } -Platform::SwapChain* PlatformGLX::createSwapChain(void* nativeWindow, uint64_t& flags) noexcept { - // Transparent swap chain is not supported - flags &= ~SWAP_CHAIN_CONFIG_TRANSPARENT; +Platform::SwapChain* PlatformGLX::createSwapChain(void* nativeWindow, uint64_t flags) noexcept { return (SwapChain*)nativeWindow; } Platform::SwapChain* PlatformGLX::createSwapChain( - uint32_t width, uint32_t height, uint64_t& flags) noexcept { - // Transparent swap chain is not supported - flags &= ~SWAP_CHAIN_CONFIG_TRANSPARENT; + uint32_t width, uint32_t height, uint64_t flags) noexcept { int pbufferAttribs[] = { GLX_PBUFFER_WIDTH, int(width), GLX_PBUFFER_HEIGHT, int(height), diff --git a/filament/backend/src/opengl/platforms/PlatformWGL.cpp b/filament/backend/src/opengl/platforms/PlatformWGL.cpp index 4341265b6c..8f8cf6e1ee 100644 --- a/filament/backend/src/opengl/platforms/PlatformWGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformWGL.cpp @@ -175,7 +175,7 @@ void PlatformWGL::terminate() noexcept { bluegl::unbind(); } -Platform::SwapChain* PlatformWGL::createSwapChain(void* nativeWindow, uint64_t& flags) noexcept { +Platform::SwapChain* PlatformWGL::createSwapChain(void* nativeWindow, uint64_t flags) noexcept { auto* swapChain = new WGLSwapChain(); swapChain->isHeadless = false; @@ -194,7 +194,7 @@ Platform::SwapChain* PlatformWGL::createSwapChain(void* nativeWindow, uint64_t& return (Platform::SwapChain*) swapChain; } -Platform::SwapChain* PlatformWGL::createSwapChain(uint32_t width, uint32_t height, uint64_t& flags) noexcept { +Platform::SwapChain* PlatformWGL::createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept { auto* swapChain = new WGLSwapChain(); swapChain->isHeadless = true; diff --git a/filament/backend/src/opengl/platforms/PlatformWebGL.cpp b/filament/backend/src/opengl/platforms/PlatformWebGL.cpp index a87711bbc8..e4017da945 100644 --- a/filament/backend/src/opengl/platforms/PlatformWebGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformWebGL.cpp @@ -33,12 +33,12 @@ void PlatformWebGL::terminate() noexcept { } Platform::SwapChain* PlatformWebGL::createSwapChain( - void* nativeWindow, uint64_t& flags) noexcept { + void* nativeWindow, uint64_t flags) noexcept { return (SwapChain*)nativeWindow; } Platform::SwapChain* PlatformWebGL::createSwapChain( - uint32_t width, uint32_t height, uint64_t& flags) noexcept { + uint32_t width, uint32_t height, uint64_t flags) noexcept { // TODO: implement headless SwapChain return nullptr; }