diff --git a/filament/backend/include/backend/platforms/OpenGLPlatform.h b/filament/backend/include/backend/platforms/OpenGLPlatform.h index 121039ea31..0cc0c1c189 100644 --- a/filament/backend/include/backend/platforms/OpenGLPlatform.h +++ b/filament/backend/include/backend/platforms/OpenGLPlatform.h @@ -199,7 +199,7 @@ public: */ virtual bool makeCurrent(ContextType type, SwapChain* UTILS_NONNULL drawSwapChain, - SwapChain* UTILS_NONNULL readSwapChain) noexcept = 0; + SwapChain* UTILS_NONNULL readSwapChain) = 0; /** * Called by the driver to make the OpenGL context active on the calling thread and bind @@ -219,7 +219,7 @@ public: SwapChain* UTILS_NONNULL drawSwapChain, SwapChain* UTILS_NONNULL readSwapChain, utils::Invocable preContextChange, - utils::Invocable postContextChange) noexcept; + utils::Invocable postContextChange); /** * Called by the backend just before calling commit() diff --git a/filament/backend/include/backend/platforms/PlatformCocoaGL.h b/filament/backend/include/backend/platforms/PlatformCocoaGL.h index 0d86d1e6b8..ebc177433b 100644 --- a/filament/backend/include/backend/platforms/PlatformCocoaGL.h +++ b/filament/backend/include/backend/platforms/PlatformCocoaGL.h @@ -58,7 +58,7 @@ protected: 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; - bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; + bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) override; void commit(SwapChain* swapChain) noexcept override; ExternalTexture* createExternalImageTexture() noexcept override; void destroyExternalImageTexture(ExternalTexture* texture) noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h b/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h index 2c98fe6c85..cdb548181e 100644 --- a/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h +++ b/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h @@ -55,7 +55,7 @@ public: 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; - bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; + bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) override; void commit(SwapChain* swapChain) noexcept override; ExternalTexture* createExternalImageTexture() noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformEGL.h b/filament/backend/include/backend/platforms/PlatformEGL.h index 299e32dc8f..e48623595a 100644 --- a/filament/backend/include/backend/platforms/PlatformEGL.h +++ b/filament/backend/include/backend/platforms/PlatformEGL.h @@ -109,11 +109,11 @@ protected: bool makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept override; + SwapChain* readSwapChain) override; void makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain, utils::Invocable preContextChange, - utils::Invocable postContextChange) noexcept override; + utils::Invocable postContextChange) override; void commit(SwapChain* swapChain) noexcept override; @@ -148,12 +148,12 @@ protected: EGLContext getContextForType(ContextType type) const noexcept; // makes the draw and read surface current without changing the current context - EGLBoolean makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) noexcept { + EGLBoolean makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) { return egl.makeCurrent(drawSurface, readSurface); } // makes context current and set draw and read surfaces to EGL_NO_SURFACE - EGLBoolean makeCurrent(EGLContext context) noexcept { + EGLBoolean makeCurrent(EGLContext context) { return egl.makeCurrent(context, mEGLDummySurface, mEGLDummySurface); } @@ -211,9 +211,9 @@ private: public: explicit EGL(EGLDisplay& dpy) : mEGLDisplay(dpy) {} EGLBoolean makeCurrent(EGLContext context, - EGLSurface drawSurface, EGLSurface readSurface) noexcept; + EGLSurface drawSurface, EGLSurface readSurface); - EGLBoolean makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) noexcept { + EGLBoolean makeCurrent(EGLSurface drawSurface, EGLSurface readSurface) { return makeCurrent(mCurrentContext, drawSurface, readSurface); } } egl{ mEGLDisplay }; diff --git a/filament/backend/include/backend/platforms/PlatformEGLAndroid.h b/filament/backend/include/backend/platforms/PlatformEGLAndroid.h index fa3121e3c7..88431a286f 100644 --- a/filament/backend/include/backend/platforms/PlatformEGLAndroid.h +++ b/filament/backend/include/backend/platforms/PlatformEGLAndroid.h @@ -127,7 +127,7 @@ protected: protected: bool makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept override; + SwapChain* readSwapChain) override; private: struct InitializeJvmForPerformanceManagerIfNeeded { diff --git a/filament/backend/include/backend/platforms/PlatformGLX.h b/filament/backend/include/backend/platforms/PlatformGLX.h index 796e27a111..1cec1d64ce 100644 --- a/filament/backend/include/backend/platforms/PlatformGLX.h +++ b/filament/backend/include/backend/platforms/PlatformGLX.h @@ -51,7 +51,7 @@ protected: 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; - bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; + bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) override; void commit(SwapChain* swapChain) noexcept override; private: diff --git a/filament/backend/include/backend/platforms/PlatformOSMesa.h b/filament/backend/include/backend/platforms/PlatformOSMesa.h index 5f6658f94d..4ed4db7a21 100644 --- a/filament/backend/include/backend/platforms/PlatformOSMesa.h +++ b/filament/backend/include/backend/platforms/PlatformOSMesa.h @@ -56,7 +56,7 @@ protected: SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) noexcept override; void destroySwapChain(SwapChain* swapChain) noexcept override; bool makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept override; + SwapChain* readSwapChain) override; void commit(SwapChain* swapChain) noexcept override; private: diff --git a/filament/backend/include/backend/platforms/PlatformWGL.h b/filament/backend/include/backend/platforms/PlatformWGL.h index e0003156b8..3963e1476c 100644 --- a/filament/backend/include/backend/platforms/PlatformWGL.h +++ b/filament/backend/include/backend/platforms/PlatformWGL.h @@ -53,7 +53,7 @@ protected: 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; - bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; + bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) override; void commit(SwapChain* swapChain) noexcept override; protected: diff --git a/filament/backend/include/backend/platforms/PlatformWebGL.h b/filament/backend/include/backend/platforms/PlatformWebGL.h index 0d83fbb979..4ced86d9bb 100644 --- a/filament/backend/include/backend/platforms/PlatformWebGL.h +++ b/filament/backend/include/backend/platforms/PlatformWebGL.h @@ -46,7 +46,7 @@ protected: 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; - bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept override; + bool makeCurrent(ContextType type, SwapChain* drawSwapChain, SwapChain* readSwapChain) override; void commit(SwapChain* swapChain) noexcept override; }; diff --git a/filament/backend/include/private/backend/CircularBuffer.h b/filament/backend/include/private/backend/CircularBuffer.h index 7d2de52b00..063ea8b947 100644 --- a/filament/backend/include/private/backend/CircularBuffer.h +++ b/filament/backend/include/private/backend/CircularBuffer.h @@ -72,7 +72,7 @@ public: Range getBuffer() noexcept; private: - void* alloc(size_t size) noexcept; + void* alloc(size_t size); void dealloc() noexcept; // pointer to the beginning of the circular buffer (constant) diff --git a/filament/backend/include/private/backend/CommandBufferQueue.h b/filament/backend/include/private/backend/CommandBufferQueue.h index e8ff9aa896..f9a96ab9b0 100644 --- a/filament/backend/include/private/backend/CommandBufferQueue.h +++ b/filament/backend/include/private/backend/CommandBufferQueue.h @@ -76,7 +76,7 @@ public: // all commands buffers (Slices) written to this point are returned by waitForCommand(). This // call blocks until the CircularBuffer has at least mRequiredSize bytes available. - void flush() noexcept; + void flush(); // returns from waitForCommands() immediately. void requestExit(); diff --git a/filament/backend/include/private/backend/VirtualMachineEnv.h b/filament/backend/include/private/backend/VirtualMachineEnv.h index 00dfa439e5..c4352391c3 100644 --- a/filament/backend/include/private/backend/VirtualMachineEnv.h +++ b/filament/backend/include/private/backend/VirtualMachineEnv.h @@ -27,13 +27,13 @@ namespace filament { class VirtualMachineEnv { public: // must be called before VirtualMachineEnv::get() from a thread that is attached to the JavaVM - static jint JNI_OnLoad(JavaVM* vm) noexcept; + static jint JNI_OnLoad(JavaVM* vm); // must be called on backend thread static VirtualMachineEnv& get() noexcept; // can be called from any thread that already has a JniEnv - static JNIEnv* getThreadEnvironment() noexcept; + static JNIEnv* getThreadEnvironment(); // must be called from the backend thread JNIEnv* getEnvironment() noexcept { @@ -49,7 +49,7 @@ public: private: explicit VirtualMachineEnv(JavaVM* vm) noexcept; ~VirtualMachineEnv() noexcept; - JNIEnv* getEnvironmentSlow() noexcept; + JNIEnv* getEnvironmentSlow(); static utils::Mutex sLock; static JavaVM* sVirtualMachine; diff --git a/filament/backend/src/CircularBuffer.cpp b/filament/backend/src/CircularBuffer.cpp index b8796623e0..d059bca491 100644 --- a/filament/backend/src/CircularBuffer.cpp +++ b/filament/backend/src/CircularBuffer.cpp @@ -65,7 +65,7 @@ CircularBuffer::~CircularBuffer() noexcept { // to each others and a special case in circularize() UTILS_NOINLINE -void* CircularBuffer::alloc(size_t size) noexcept { +void* CircularBuffer::alloc(size_t size) { #if HAS_MMAP void* data = nullptr; void* vaddr = MAP_FAILED; diff --git a/filament/backend/src/CommandBufferQueue.cpp b/filament/backend/src/CommandBufferQueue.cpp index 216e1e3241..4b7617a747 100644 --- a/filament/backend/src/CommandBufferQueue.cpp +++ b/filament/backend/src/CommandBufferQueue.cpp @@ -53,18 +53,18 @@ CommandBufferQueue::~CommandBufferQueue() { } void CommandBufferQueue::requestExit() { - std::lock_guard const lock(mLock); + std::lock_guard const lock(mLock); mExitRequested = EXIT_REQUESTED; mCondition.notify_one(); } bool CommandBufferQueue::isPaused() const noexcept { - std::lock_guard const lock(mLock); + std::lock_guard const lock(mLock); return mPaused; } void CommandBufferQueue::setPaused(bool paused) { - std::lock_guard const lock(mLock); + std::lock_guard const lock(mLock); if (paused) { mPaused = true; } else { @@ -74,12 +74,12 @@ void CommandBufferQueue::setPaused(bool paused) { } bool CommandBufferQueue::isExitRequested() const { - std::lock_guard const lock(mLock); - return (bool)mExitRequested; + std::lock_guard const lock(mLock); + return bool(mExitRequested); } -void CommandBufferQueue::flush() noexcept { +void CommandBufferQueue::flush() { FILAMENT_TRACING_CALL(FILAMENT_TRACING_CATEGORY_FILAMENT); CircularBuffer& circularBuffer = mCircularBuffer; @@ -103,7 +103,7 @@ void CommandBufferQueue::flush() noexcept { static_cast(begin), static_cast(end)); - std::unique_lock lock(mLock); + std::unique_lock lock(mLock); // circular buffer is too small, we corrupted the stream FILAMENT_CHECK_POSTCONDITION(used <= mFreeSpace) << @@ -147,7 +147,7 @@ std::vector CommandBufferQueue::waitForCommands() con if (!UTILS_HAS_THREADING) { return std::move(mCommandBuffersToExecute); } - std::unique_lock lock(mLock); + std::unique_lock lock(mLock); while ((mCommandBuffersToExecute.empty() || mPaused) && !mExitRequested) { mCondition.wait(lock); } @@ -157,7 +157,7 @@ std::vector CommandBufferQueue::waitForCommands() con void CommandBufferQueue::releaseBuffer(CommandBufferQueue::Range const& buffer) { size_t const used = std::distance( static_cast(buffer.begin), static_cast(buffer.end)); - std::lock_guard const lock(mLock); + std::lock_guard const lock(mLock); mFreeSpace += used; mCondition.notify_one(); } diff --git a/filament/backend/src/VirtualMachineEnv.cpp b/filament/backend/src/VirtualMachineEnv.cpp index 7909afc130..9616db1559 100644 --- a/filament/backend/src/VirtualMachineEnv.cpp +++ b/filament/backend/src/VirtualMachineEnv.cpp @@ -50,7 +50,7 @@ JavaVM* VirtualMachineEnv::getVirtualMachine() { */ UTILS_PUBLIC UTILS_NOINLINE -jint VirtualMachineEnv::JNI_OnLoad(JavaVM* vm) noexcept { +jint VirtualMachineEnv::JNI_OnLoad(JavaVM* vm) { std::lock_guard const lock(sLock); if (sVirtualMachine) { // It doesn't make sense for JNI_OnLoad() to be called more than once @@ -77,7 +77,7 @@ VirtualMachineEnv& VirtualMachineEnv::get() noexcept { } UTILS_NOINLINE -JNIEnv* VirtualMachineEnv::getThreadEnvironment() noexcept { +JNIEnv* VirtualMachineEnv::getThreadEnvironment() { JavaVM* const vm = getVirtualMachine(); JNIEnv* env = nullptr; jint const result = vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6); @@ -101,7 +101,7 @@ VirtualMachineEnv::~VirtualMachineEnv() noexcept { } UTILS_NOINLINE -JNIEnv* VirtualMachineEnv::getEnvironmentSlow() noexcept { +JNIEnv* VirtualMachineEnv::getEnvironmentSlow() { FILAMENT_CHECK_PRECONDITION(mVirtualMachine) << "JNI_OnLoad() has not been called"; diff --git a/filament/backend/src/opengl/OpenGLPlatform.cpp b/filament/backend/src/opengl/OpenGLPlatform.cpp index 4506223aa9..d440533f70 100644 --- a/filament/backend/src/opengl/OpenGLPlatform.cpp +++ b/filament/backend/src/opengl/OpenGLPlatform.cpp @@ -64,7 +64,7 @@ utils::CString OpenGLPlatform::getRendererString(Driver const* driver) { } void OpenGLPlatform::makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain, - utils::Invocable, utils::Invocable) noexcept { + utils::Invocable, utils::Invocable) { makeCurrent(getCurrentContextType(), drawSwapChain, readSwapChain); } diff --git a/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm b/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm index 876de9b8d2..9e22ef5f96 100644 --- a/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm +++ b/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm @@ -255,7 +255,7 @@ void PlatformCocoaGL::destroySwapChain(Platform::SwapChain* swapChain) noexcept } bool PlatformCocoaGL::makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept { + SwapChain* readSwapChain) { ASSERT_PRECONDITION_NON_FATAL(drawSwapChain == readSwapChain, "ContextManagerCocoa does not support using distinct draw/read swap chains."); CocoaGLSwapChain* swapChain = (CocoaGLSwapChain*)drawSwapChain; diff --git a/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm b/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm index 681a6a81b9..aee19daadc 100644 --- a/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm +++ b/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm @@ -155,7 +155,7 @@ uint32_t PlatformCocoaTouchGL::getDefaultFramebufferObject() noexcept { } bool PlatformCocoaTouchGL::makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept { + SwapChain* readSwapChain) { ASSERT_PRECONDITION_NON_FATAL(drawSwapChain == readSwapChain, "PlatformCocoaTouchGL does not support using distinct draw/read swap chains."); CAEAGLLayer* const glLayer = (__bridge CAEAGLLayer*) drawSwapChain; diff --git a/filament/backend/src/opengl/platforms/PlatformEGL.cpp b/filament/backend/src/opengl/platforms/PlatformEGL.cpp index 3e141c4639..c5b4a5ec35 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGL.cpp @@ -577,18 +577,18 @@ OpenGLPlatform::ContextType PlatformEGL::getCurrentContextType() const noexcept } bool PlatformEGL::makeCurrent(ContextType type, - SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept { + SwapChain* drawSwapChain, SwapChain* readSwapChain) { SwapChainEGL const* const dsc = static_cast(drawSwapChain); SwapChainEGL const* const rsc = static_cast(readSwapChain); EGLContext context = getContextForType(type); EGLBoolean const success = egl.makeCurrent(context, dsc->sur, rsc->sur); - return success == EGL_TRUE ? true : false; + return success == EGL_TRUE; } void PlatformEGL::makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain, Invocable preContextChange, - Invocable postContextChange) noexcept { + Invocable postContextChange) { assert_invariant(drawSwapChain); assert_invariant(readSwapChain); @@ -796,7 +796,7 @@ void PlatformEGL::Config::erase(EGLint name) noexcept { // ------------------------------------------------------------------------------------------------ EGLBoolean PlatformEGL::EGL::makeCurrent(EGLContext context, EGLSurface drawSurface, - EGLSurface readSurface) noexcept { + EGLSurface readSurface) { if (UTILS_UNLIKELY(( mCurrentContext != context || drawSurface != mCurrentDrawSurface || readSurface != mCurrentReadSurface))) { diff --git a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp index 9e2a32eaf5..f36c4b5373 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp @@ -135,7 +135,7 @@ static constexpr const std::string_view kNativeWindowInvalidMsg = bool PlatformEGLAndroid::makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept { + SwapChain* readSwapChain) { // fast & safe path if (UTILS_LIKELY(!mAssertNativeWindowIsValid)) { diff --git a/filament/backend/src/opengl/platforms/PlatformGLX.cpp b/filament/backend/src/opengl/platforms/PlatformGLX.cpp index c3b1a76ff8..5dcf928f72 100644 --- a/filament/backend/src/opengl/platforms/PlatformGLX.cpp +++ b/filament/backend/src/opengl/platforms/PlatformGLX.cpp @@ -266,7 +266,7 @@ void PlatformGLX::destroySwapChain(Platform::SwapChain* swapChain) noexcept { } bool PlatformGLX::makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept { + SwapChain* readSwapChain) { g_glx.setCurrentContext(mGLXDisplay, (GLXDrawable)drawSwapChain, (GLXDrawable)readSwapChain, mGLXContext); return true; diff --git a/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp b/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp index 16d52de0d2..b6841a8d53 100644 --- a/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp +++ b/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp @@ -169,7 +169,7 @@ void PlatformOSMesa::destroySwapChain(Platform::SwapChain* swapChain) noexcept { } bool PlatformOSMesa::makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept { + SwapChain* readSwapChain) { OSMesaAPI* api = (OSMesaAPI*) mOsMesaApi; OSMesaSwapchain* impl = (OSMesaSwapchain*) drawSwapChain; diff --git a/filament/backend/src/opengl/platforms/PlatformWGL.cpp b/filament/backend/src/opengl/platforms/PlatformWGL.cpp index 094ecf3e2c..8ef99a00bc 100644 --- a/filament/backend/src/opengl/platforms/PlatformWGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformWGL.cpp @@ -262,7 +262,7 @@ void PlatformWGL::destroySwapChain(Platform::SwapChain* swapChain) noexcept { } bool PlatformWGL::makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept { + SwapChain* readSwapChain) { ASSERT_PRECONDITION_NON_FATAL(drawSwapChain == readSwapChain, "PlatformWGL does not support distinct draw/read swap chains."); diff --git a/filament/backend/src/opengl/platforms/PlatformWebGL.cpp b/filament/backend/src/opengl/platforms/PlatformWebGL.cpp index 4f522b2991..3e31ea074e 100644 --- a/filament/backend/src/opengl/platforms/PlatformWebGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformWebGL.cpp @@ -47,7 +47,7 @@ void PlatformWebGL::destroySwapChain(Platform::SwapChain* swapChain) noexcept { } bool PlatformWebGL::makeCurrent(ContextType type, SwapChain* drawSwapChain, - SwapChain* readSwapChain) noexcept { + SwapChain* readSwapChain) { return true; } diff --git a/filament/include/filament/Engine.h b/filament/include/filament/Engine.h index 30d2ca869d..f3c9b90b72 100644 --- a/filament/include/filament/Engine.h +++ b/filament/include/filament/Engine.h @@ -1017,7 +1017,7 @@ public: * * @see setPaused */ - bool isPaused() const noexcept; + bool isPaused() const noexcept(UTILS_HAS_THREADING); /** * Pause or resume rendering thread. diff --git a/filament/src/Engine.cpp b/filament/src/Engine.cpp index 1927e7a34f..89a587e783 100644 --- a/filament/src/Engine.cpp +++ b/filament/src/Engine.cpp @@ -387,7 +387,7 @@ JobSystem& Engine::getJobSystem() noexcept { return downcast(this)->getJobSystem(); } -bool Engine::isPaused() const noexcept { +bool Engine::isPaused() const noexcept(UTILS_HAS_THREADING) { FILAMENT_CHECK_PRECONDITION(UTILS_HAS_THREADING) << "Pause is meant for multi-threaded platforms."; return downcast(this)->isPaused(); diff --git a/filament/src/details/Fence.cpp b/filament/src/details/Fence.cpp index 8c7a2c81a4..86536020aa 100644 --- a/filament/src/details/Fence.cpp +++ b/filament/src/details/Fence.cpp @@ -20,9 +20,19 @@ #include +#include + +#include #include #include +#include +#include +#include +#include + +#include + namespace filament { using namespace backend; @@ -30,7 +40,7 @@ using namespace backend; utils::Mutex FFence::sLock; utils::Condition FFence::sCondition; -static const constexpr uint64_t PUMP_INTERVAL_MILLISECONDS = 1; +static constexpr uint64_t PUMP_INTERVAL_MILLISECONDS = 1; using ms = std::chrono::milliseconds; using ns = std::chrono::nanoseconds; @@ -60,7 +70,7 @@ FenceStatus FFence::waitAndDestroy(FFence* fence, Mode const mode) noexcept { } UTILS_NOINLINE -FenceStatus FFence::wait(Mode const mode, uint64_t const timeout) noexcept { +FenceStatus FFence::wait(Mode const mode, uint64_t const timeout) { FILAMENT_CHECK_PRECONDITION(UTILS_HAS_THREADING || timeout == 0) << "Non-zero timeout requires threads."; @@ -103,18 +113,15 @@ FenceStatus FFence::wait(Mode const mode, uint64_t const timeout) noexcept { UTILS_NOINLINE void FFence::FenceSignal::signal(State const s) noexcept { - std::lock_guard const lock(sLock); + std::lock_guard const lock(sLock); mState = s; sCondition.notify_all(); } UTILS_NOINLINE Fence::FenceStatus FFence::FenceSignal::wait(uint64_t const timeout) noexcept { - std::unique_lock lock(sLock); + std::unique_lock lock(sLock); while (mState == UNSIGNALED) { - if (mState == DESTROYED) { - return FenceStatus::ERROR; - } if (timeout == FENCE_WAIT_FOR_EVER) { sCondition.wait(lock); } else { @@ -124,6 +131,9 @@ Fence::FenceStatus FFence::FenceSignal::wait(uint64_t const timeout) noexcept { } } } + if (mState == DESTROYED) { + return FenceStatus::ERROR; + } return FenceStatus::CONDITION_SATISFIED; } diff --git a/filament/src/details/Fence.h b/filament/src/details/Fence.h index a8a3fc68a2..092798f0b0 100644 --- a/filament/src/details/Fence.h +++ b/filament/src/details/Fence.h @@ -37,7 +37,7 @@ public: void terminate(FEngine& engine) noexcept; - FenceStatus wait(Mode mode, uint64_t timeout) noexcept; + FenceStatus wait(Mode mode, uint64_t timeout); static FenceStatus waitAndDestroy(FFence* fence, Mode mode) noexcept; diff --git a/filament/src/details/Material.cpp b/filament/src/details/Material.cpp index 48858e99fb..4042fee664 100644 --- a/filament/src/details/Material.cpp +++ b/filament/src/details/Material.cpp @@ -94,7 +94,7 @@ static std::unique_ptr createParser(Backend const backend, } } - FILAMENT_CHECK_PRECONDITION( + FILAMENT_CHECK_POSTCONDITION( materialResult != MaterialParser::ParseResult::ERROR_MISSING_BACKEND) << "the material was not built for any of the " << to_string(backend) << " backend's supported shader languages (" << languageNames.c_str() << ")\n"; @@ -104,12 +104,12 @@ static std::unique_ptr createParser(Backend const backend, return materialParser; } - FILAMENT_CHECK_PRECONDITION(materialResult == MaterialParser::ParseResult::SUCCESS) + FILAMENT_CHECK_POSTCONDITION(materialResult == MaterialParser::ParseResult::SUCCESS) << "could not parse the material package"; uint32_t version = 0; materialParser->getMaterialVersion(&version); - FILAMENT_CHECK_PRECONDITION(version == MATERIAL_VERSION) + FILAMENT_CHECK_POSTCONDITION(version == MATERIAL_VERSION) << "Material version mismatch. Expected " << MATERIAL_VERSION << " but received " << version << "."; @@ -573,7 +573,7 @@ void FMaterial::getPostProcessProgramSlow(Variant const variant, Program FMaterial::getProgramWithVariants( Variant variant, Variant vertexVariant, - Variant fragmentVariant) const noexcept { + Variant fragmentVariant) const { FEngine const& engine = mEngine; const ShaderModel sm = engine.getShaderModel(); const bool isNoop = engine.getBackend() == Backend::NOOP; diff --git a/filament/src/details/Material.h b/filament/src/details/Material.h index 02f67b1bb9..ac6f0e76af 100644 --- a/filament/src/details/Material.h +++ b/filament/src/details/Material.h @@ -267,7 +267,7 @@ private: void getPostProcessProgramSlow(Variant variant, CompilerPriorityQueue priorityQueue) const noexcept; backend::Program getProgramWithVariants(Variant variant, - Variant vertexVariant, Variant fragmentVariant) const noexcept; + Variant vertexVariant, Variant fragmentVariant) const; void processBlendingMode(MaterialParser const* parser); diff --git a/filament/src/details/MorphTargetBuffer.cpp b/filament/src/details/MorphTargetBuffer.cpp index d2595263a4..dd478cdaf5 100644 --- a/filament/src/details/MorphTargetBuffer.cpp +++ b/filament/src/details/MorphTargetBuffer.cpp @@ -178,7 +178,7 @@ void FMorphTargetBuffer::setPositionsAt(FEngine& engine, size_t const targetInde void FMorphTargetBuffer::setPositionsAt(FEngine& engine, size_t const targetIndex, float4 const* positions, size_t const count, size_t const offset) { FILAMENT_CHECK_PRECONDITION(offset + count <= mVertexCount) - << "MorphTargetBuffer (size=" << (unsigned)mVertexCount + << "MorphTargetBuffer (size=" << mVertexCount << ") overflow (count=" << (unsigned)count << ", offset=" << (unsigned)offset << ")"; auto size = getSize(count); @@ -200,7 +200,7 @@ void FMorphTargetBuffer::setPositionsAt(FEngine& engine, size_t const targetInde void FMorphTargetBuffer::setTangentsAt(FEngine& engine, size_t const targetIndex, short4 const* tangents, size_t const count, size_t const offset) { FILAMENT_CHECK_PRECONDITION(offset + count <= mVertexCount) - << "MorphTargetBuffer (size=" << (unsigned)mVertexCount + << "MorphTargetBuffer (size=" << mVertexCount << ") overflow (count=" << (unsigned)count << ", offset=" << (unsigned)offset << ")"; const auto size = getSize(count); diff --git a/filament/src/details/Renderer.cpp b/filament/src/details/Renderer.cpp index 7c78cec9bb..04d86a4f72 100644 --- a/filament/src/details/Renderer.cpp +++ b/filament/src/details/Renderer.cpp @@ -447,11 +447,12 @@ void FRenderer::endFrame() { void FRenderer::readPixels(uint32_t const xoffset, uint32_t const yoffset, uint32_t const width, uint32_t const height, PixelBufferDescriptor&& buffer) { -#ifndef NDEBUG + const bool withinFrame = mSwapChain != nullptr; - FILAMENT_CHECK_PRECONDITION(withinFrame) << "readPixels() on a SwapChain must be called after" - " beginFrame() and before endFrame()."; -#endif + FILAMENT_CHECK_PRECONDITION(withinFrame) + << "readPixels() on a SwapChain must be called after " + "beginFrame() and before endFrame()."; + RendererUtils::readPixels(mEngine.getDriverApi(), mRenderTargetHandle, xoffset, yoffset, width, height, std::move(buffer)); } diff --git a/filament/src/details/Texture.cpp b/filament/src/details/Texture.cpp index b26517522a..6aff494a72 100644 --- a/filament/src/details/Texture.cpp +++ b/filament/src/details/Texture.cpp @@ -391,7 +391,7 @@ void FTexture::setImage(FEngine& engine, size_t const level, FILAMENT_CHECK_PRECONDITION(p.buffer) << "Data buffer is nullptr."; - uint32_t effectiveTextureDepthOrLayers; + uint32_t effectiveTextureDepthOrLayers = 0; switch (mTarget) { case SamplerType::SAMPLER_EXTERNAL: // can't happen by construction, fallthrough... @@ -454,6 +454,7 @@ void FTexture::setImage(FEngine& engine, size_t const level, case SamplerType::SAMPLER_EXTERNAL: return false; } + return false; }; // this should have been validated already diff --git a/libs/filamat/include/filamat/MaterialBuilder.h b/libs/filamat/include/filamat/MaterialBuilder.h index 69093c2d45..2255d90058 100644 --- a/libs/filamat/include/filamat/MaterialBuilder.h +++ b/libs/filamat/include/filamat/MaterialBuilder.h @@ -305,7 +305,7 @@ public: //! Add a parameter array to this material. MaterialBuilder& parameter(const char* name, size_t size, UniformType type, - ParameterPrecision precision = ParameterPrecision::DEFAULT) noexcept; + ParameterPrecision precision = ParameterPrecision::DEFAULT); //! Add a constant parameter to this material. template @@ -325,9 +325,9 @@ public: SamplerFormat format = SamplerFormat::FLOAT, ParameterPrecision precision = ParameterPrecision::DEFAULT, bool multisample = false, const char* transformName = "", - ShaderStageFlags stages = ShaderStageFlags::ALL_SHADER_STAGE_FLAGS) noexcept; + ShaderStageFlags stages = ShaderStageFlags::ALL_SHADER_STAGE_FLAGS); - MaterialBuilder& buffer(filament::BufferInterfaceBlock bib) noexcept; + MaterialBuilder& buffer(filament::BufferInterfaceBlock bib); //! Custom variables (all float4). MaterialBuilder& variable(Variable v, const char* name) noexcept; @@ -617,7 +617,7 @@ public: //! Add a new fragment shader output variable. Only valid for materials in the POST_PROCESS domain. MaterialBuilder& output(VariableQualifier qualifier, OutputTarget target, Precision precision, - OutputType type, const char* name, int location = -1) noexcept; + OutputType type, const char* name, int location = -1); MaterialBuilder& enableFramebufferFetch() noexcept; @@ -646,12 +646,12 @@ public: * Add a subpass parameter to this material. */ MaterialBuilder& subpass(SubpassType subpassType, - SamplerFormat format, ParameterPrecision precision, const char* name) noexcept; + SamplerFormat format, ParameterPrecision precision, const char* name); MaterialBuilder& subpass(SubpassType subpassType, - SamplerFormat format, const char* name) noexcept; + SamplerFormat format, const char* name); MaterialBuilder& subpass(SubpassType subpassType, - ParameterPrecision precision, const char* name) noexcept; - MaterialBuilder& subpass(SubpassType subpassType, const char* name) noexcept; + ParameterPrecision precision, const char* name); + MaterialBuilder& subpass(SubpassType subpassType, const char* name); struct Parameter { Parameter() noexcept: parameterType(INVALID) {} diff --git a/libs/filamat/src/MaterialBuilder.cpp b/libs/filamat/src/MaterialBuilder.cpp index c114a8fb24..de0344f1df 100644 --- a/libs/filamat/src/MaterialBuilder.cpp +++ b/libs/filamat/src/MaterialBuilder.cpp @@ -289,7 +289,7 @@ MaterialBuilder& MaterialBuilder::variable(Variable v, } MaterialBuilder& MaterialBuilder::parameter(const char* name, size_t size, UniformType type, - ParameterPrecision precision) noexcept { + ParameterPrecision precision) { FILAMENT_CHECK_POSTCONDITION(mParameterCount < MAX_PARAMETERS_COUNT) << "Too many parameters"; mParameters[mParameterCount++] = { name, type, size, precision }; return *this; @@ -303,7 +303,7 @@ MaterialBuilder& MaterialBuilder::parameter(const char* name, UniformType const MaterialBuilder& MaterialBuilder::parameter(const char* name, SamplerType samplerType, SamplerFormat format, ParameterPrecision precision, bool multisample, - const char* transformName, ShaderStageFlags stages) noexcept { + const char* transformName, ShaderStageFlags stages) { FILAMENT_CHECK_PRECONDITION(!multisample || (format != SamplerFormat::SHADOW && (samplerType == SamplerType::SAMPLER_2D || @@ -364,14 +364,14 @@ template MaterialBuilder& MaterialBuilder::constant( template MaterialBuilder& MaterialBuilder::constant( const char* name, ConstantType type, bool defaultValue); -MaterialBuilder& MaterialBuilder::buffer(BufferInterfaceBlock bib) noexcept { +MaterialBuilder& MaterialBuilder::buffer(BufferInterfaceBlock bib) { FILAMENT_CHECK_POSTCONDITION(mBuffers.size() < MAX_BUFFERS_COUNT) << "Too many buffers"; mBuffers.emplace_back(std::make_unique(std::move(bib))); return *this; } MaterialBuilder& MaterialBuilder::subpass(SubpassType subpassType, SamplerFormat format, - ParameterPrecision precision, const char* name) noexcept { + ParameterPrecision precision, const char* name) { FILAMENT_CHECK_PRECONDITION(format == SamplerFormat::FLOAT) << "Subpass parameters must have FLOAT format."; @@ -381,16 +381,16 @@ MaterialBuilder& MaterialBuilder::subpass(SubpassType subpassType, SamplerFormat } MaterialBuilder& MaterialBuilder::subpass(SubpassType const subpassType, SamplerFormat const format, - const char* name) noexcept { + const char* name) { return subpass(subpassType, format, ParameterPrecision::DEFAULT, name); } MaterialBuilder& MaterialBuilder::subpass(SubpassType const subpassType, ParameterPrecision const precision, - const char* name) noexcept { + const char* name) { return subpass(subpassType, SamplerFormat::FLOAT, precision, name); } -MaterialBuilder& MaterialBuilder::subpass(SubpassType const subpassType, const char* name) noexcept { +MaterialBuilder& MaterialBuilder::subpass(SubpassType const subpassType, const char* name) { return subpass(subpassType, SamplerFormat::FLOAT, ParameterPrecision::DEFAULT, name); } @@ -1191,7 +1191,7 @@ bool MaterialBuilder::generateShaders(JobSystem& jobSystem, const std::vector::value || std::is_same::value>::type; template> - void getAux(AuxAttribute attribute, T* out, size_t stride = 0) const noexcept; + void getAux(AuxAttribute attribute, T* out, size_t stride = 0) const; /** * Get number of output triangles. diff --git a/libs/geometry/src/TangentSpaceMesh.cpp b/libs/geometry/src/TangentSpaceMesh.cpp index 385189add2..f142318fa1 100644 --- a/libs/geometry/src/TangentSpaceMesh.cpp +++ b/libs/geometry/src/TangentSpaceMesh.cpp @@ -747,22 +747,22 @@ void TangentSpaceMesh::getQuats(quath* out, size_t stride) const noexcept { } template void TangentSpaceMesh::getAux(AuxAttribute attribute, float2* out, - size_t stride) const noexcept; + size_t stride) const; template void TangentSpaceMesh::getAux(AuxAttribute attribute, float3* out, - size_t stride) const noexcept; + size_t stride) const; template void TangentSpaceMesh::getAux(AuxAttribute attribute, float4* out, - size_t stride) const noexcept; + size_t stride) const; template void TangentSpaceMesh::getAux(AuxAttribute attribute, ushort3* out, - size_t stride) const noexcept; + size_t stride) const; template void TangentSpaceMesh::getAux(AuxAttribute attribute, ushort4* out, - size_t stride) const noexcept; + size_t stride) const; template -void TangentSpaceMesh::getAux(AuxAttribute attribute, T* out, size_t stride) const noexcept { +void TangentSpaceMesh::getAux(AuxAttribute attribute, T* out, size_t stride) const { AttributeImpl attrib = static_cast(attribute); auto inAux = mInput->data(attrib); FILAMENT_CHECK_PRECONDITION(inAux) << "Must provide input auxilliary attribute"; diff --git a/libs/gltfio/src/AssetLoader.cpp b/libs/gltfio/src/AssetLoader.cpp index f8714a6c6e..9f163654dc 100644 --- a/libs/gltfio/src/AssetLoader.cpp +++ b/libs/gltfio/src/AssetLoader.cpp @@ -263,7 +263,7 @@ struct FAssetLoader : public AssetLoader { mEngine(*config.engine), mDefaultNodeName(config.defaultNodeName) { if (config.ext) { - FILAMENT_CHECK_PRECONDITION(AssetConfigurationExtended::isSupported()) + FILAMENT_CHECK_POSTCONDITION(AssetConfigurationExtended::isSupported()) << "Extend asset loading is not supported on this platform"; mLoaderExtended = std::make_unique( *config.ext, config.engine, mMaterials); diff --git a/libs/iblprefilter/src/IBLPrefilterContext.cpp b/libs/iblprefilter/src/IBLPrefilterContext.cpp index 6cbea06423..b7c16afcb5 100644 --- a/libs/iblprefilter/src/IBLPrefilterContext.cpp +++ b/libs/iblprefilter/src/IBLPrefilterContext.cpp @@ -99,7 +99,7 @@ IBLPrefilterContext::IBLPrefilterContext(Engine& engine) mVertexBuffer = VertexBuffer::Builder() .vertexCount(3) .bufferCount(1) - .attribute(VertexAttribute::POSITION, 0, + .attribute(POSITION, 0, VertexBuffer::AttributeType::FLOAT4, 0) .build(engine); @@ -180,7 +180,7 @@ IBLPrefilterContext& IBLPrefilterContext::operator=(IBLPrefilterContext&& rhs) n IBLPrefilterContext::EquirectangularToCubemap::EquirectangularToCubemap( IBLPrefilterContext& context, - IBLPrefilterContext::EquirectangularToCubemap::Config const& config) + Config const& config) : mContext(context), mConfig(config) { Engine& engine = mContext.mEngine; mEquirectMaterial = Material::Builder().package( @@ -198,7 +198,7 @@ IBLPrefilterContext::EquirectangularToCubemap::~EquirectangularToCubemap() noexc } IBLPrefilterContext::EquirectangularToCubemap::EquirectangularToCubemap( - IBLPrefilterContext::EquirectangularToCubemap&& rhs) noexcept + EquirectangularToCubemap&& rhs) noexcept : mContext(rhs.mContext) { using std::swap; swap(mEquirectMaterial, rhs.mEquirectMaterial); @@ -206,7 +206,7 @@ IBLPrefilterContext::EquirectangularToCubemap::EquirectangularToCubemap( IBLPrefilterContext::EquirectangularToCubemap& IBLPrefilterContext::EquirectangularToCubemap::operator=( - IBLPrefilterContext::EquirectangularToCubemap&& rhs) noexcept { + EquirectangularToCubemap&& rhs) noexcept { using std::swap; if (this != &rhs) { swap(mEquirectMaterial, rhs.mEquirectMaterial); @@ -300,7 +300,7 @@ Texture* IBLPrefilterContext::EquirectangularToCubemap::operator()( // ------------------------------------------------------------------------------------------------ IBLPrefilterContext::IrradianceFilter::IrradianceFilter(IBLPrefilterContext& context, - IBLPrefilterContext::IrradianceFilter::Config config) + Config config) : mContext(context), mSampleCount(std::min(config.sampleCount, uint16_t(2048))) { @@ -362,13 +362,13 @@ IBLPrefilterContext::IrradianceFilter::~IrradianceFilter() noexcept { } IBLPrefilterContext::IrradianceFilter::IrradianceFilter( - IBLPrefilterContext::IrradianceFilter&& rhs) noexcept + IrradianceFilter&& rhs) noexcept : mContext(rhs.mContext) { this->operator=(std::move(rhs)); } IBLPrefilterContext::IrradianceFilter& IBLPrefilterContext::IrradianceFilter::operator=( - IBLPrefilterContext::IrradianceFilter&& rhs) noexcept { + IrradianceFilter&& rhs) noexcept { using std::swap; if (this != & rhs) { swap(mKernelMaterial, rhs.mKernelMaterial); @@ -378,9 +378,8 @@ IBLPrefilterContext::IrradianceFilter& IBLPrefilterContext::IrradianceFilter::op return *this; } -filament::Texture* IBLPrefilterContext::IrradianceFilter::operator()( - IBLPrefilterContext::IrradianceFilter::Options options, - filament::Texture const* environmentCubemap, filament::Texture* outIrradianceTexture) { +Texture* IBLPrefilterContext::IrradianceFilter::operator()(Options options, + Texture const* environmentCubemap, Texture* outIrradianceTexture) { FILAMENT_TRACING_CALL(FILAMENT_TRACING_CATEGORY_FILAMENT); using namespace backend; @@ -470,12 +469,12 @@ filament::Texture* IBLPrefilterContext::IrradianceFilter::operator()( } UTILS_NOINLINE -filament::Texture* IBLPrefilterContext::IrradianceFilter::operator()( - filament::Texture const* environmentCubemap, filament::Texture* outIrradianceTexture) { +Texture* IBLPrefilterContext::IrradianceFilter::operator()( + Texture const* environmentCubemap, Texture* outIrradianceTexture) { return operator()({}, environmentCubemap, outIrradianceTexture); } -filament::Texture* IBLPrefilterContext::IrradianceFilter::createIrradianceTexture() { +Texture* IBLPrefilterContext::IrradianceFilter::createIrradianceTexture() { Engine& engine = mContext.mEngine; Texture* const outCubemap = Texture::Builder() @@ -614,7 +613,7 @@ Texture* IBLPrefilterContext::SpecularFilter::operator()( } Texture* IBLPrefilterContext::SpecularFilter::operator()( - IBLPrefilterContext::SpecularFilter::Options options, + Options options, Texture const* environmentCubemap, Texture* outReflectionsTexture) { FILAMENT_TRACING_CALL(FILAMENT_TRACING_CATEGORY_FILAMENT); diff --git a/libs/utils/include/utils/JobSystem.h b/libs/utils/include/utils/JobSystem.h index 1e424e4c5b..463ee609df 100644 --- a/libs/utils/include/utils/JobSystem.h +++ b/libs/utils/include/utils/JobSystem.h @@ -413,7 +413,7 @@ private: static_assert(sizeof(ThreadState) % CACHELINE_SIZE == 0, "ThreadState doesn't align to a cache line"); - ThreadState& getState() noexcept; + ThreadState& getState(); static void incRef(Job const* job) noexcept; void decRef(Job const* job) noexcept; @@ -426,12 +426,12 @@ private: bool exitRequested() const noexcept; bool hasActiveJobs() const noexcept; - void loop(ThreadState* state) noexcept; + void loop(ThreadState* state); bool execute(ThreadState& state) noexcept; Job* steal(ThreadState& state) noexcept; void finish(Job* job) noexcept; - void put(WorkQueue& workQueue, Job* job) noexcept; + void put(WorkQueue& workQueue, Job const* job) noexcept; Job* pop(WorkQueue& workQueue) noexcept; Job* steal(WorkQueue& workQueue) noexcept; diff --git a/libs/utils/src/JobSystem.cpp b/libs/utils/src/JobSystem.cpp index 95554327a2..179796921c 100644 --- a/libs/utils/src/JobSystem.cpp +++ b/libs/utils/src/JobSystem.cpp @@ -244,7 +244,7 @@ void JobSystem::decRef(Job const* job) noexcept { // Similarly, we need to guarantee that no read/write are reordered before the last decref, // or some other thread could see a destroyed object before the ref-count is 0. This is done // with memory_order_acquire. - auto c = job->refCount.fetch_sub(1, std::memory_order_acq_rel); + auto const c = job->refCount.fetch_sub(1, std::memory_order_acq_rel); assert(c > 0); if (c == 1) { // This was the last reference, it's safe to destroy the job. @@ -254,7 +254,7 @@ void JobSystem::decRef(Job const* job) noexcept { void JobSystem::requestExit() noexcept { mExitRequested.store(true); - std::lock_guard const lock(mWaiterLock); + std::lock_guard const lock(mWaiterLock); mWaiterCondition.notify_all(); } @@ -322,9 +322,9 @@ void JobSystem::wakeOne() noexcept { mWaiterCondition.notify_one(); } -inline JobSystem::ThreadState& JobSystem::getState() noexcept { - std::lock_guard const lock(mThreadMapLock); - auto iter = mThreadMap.find(std::this_thread::get_id()); +inline JobSystem::ThreadState& JobSystem::getState() { + std::lock_guard const lock(mThreadMapLock); + auto const iter = mThreadMap.find(std::this_thread::get_id()); FILAMENT_CHECK_PRECONDITION(iter != mThreadMap.end()) << "This thread has not been adopted."; return *iter->second; } @@ -333,10 +333,11 @@ JobSystem::Job* JobSystem::allocateJob() noexcept { return mJobPool.make(); } -void JobSystem::put(WorkQueue& workQueue, Job* job) noexcept { +void JobSystem::put(WorkQueue& workQueue, Job const* job) noexcept { assert(job); + assert(job >= mJobStorageBase && job < mJobStorageBase + MAX_JOB_COUNT); + size_t const index = job - mJobStorageBase; - assert(index >= 0 && index < MAX_JOB_COUNT); // put the job into the queue workQueue.push(uint16_t(index + 1)); @@ -435,12 +436,12 @@ bool JobSystem::execute(ThreadState& state) noexcept { return job != nullptr; } -void JobSystem::loop(ThreadState* state) noexcept { +void JobSystem::loop(ThreadState* state) { setThreadName("JobSystem::loop"); setThreadPriority(Priority::DISPLAY); // record our work queue - std::unique_lock lock(mThreadMapLock); + std::unique_lock lock(mThreadMapLock); bool const inserted = mThreadMap.emplace(std::this_thread::get_id(), state).second; lock.unlock(); @@ -449,7 +450,7 @@ void JobSystem::loop(ThreadState* state) noexcept { // run our main loop... do { if (!execute(*state)) { - std::unique_lock lock(mWaiterLock); + std::unique_lock lock(mWaiterLock); while (!exitRequested() && !hasActiveJobs()) { wait(lock); } @@ -590,7 +591,7 @@ void JobSystem::waitAndRelease(Job*& job) noexcept { // this could take time however, so we will wait with a condition, and // continue to handle more jobs, as they get added. - std::unique_lock lock(mWaiterLock); + std::unique_lock lock(mWaiterLock); uint32_t const runningJobCount = wait(lock, job); // we could be waking up because either: // - the job we're waiting on has completed @@ -625,9 +626,9 @@ void JobSystem::runAndWait(Job*& job) noexcept { void JobSystem::adopt() { const auto tid = std::this_thread::get_id(); - std::unique_lock lock(mThreadMapLock); - auto iter = mThreadMap.find(tid); - ThreadState* const state = iter == mThreadMap.end() ? nullptr : iter->second; + std::unique_lock lock(mThreadMapLock); + auto const iter = mThreadMap.find(tid); + ThreadState const* const state = iter == mThreadMap.end() ? nullptr : iter->second; lock.unlock(); if (state) { @@ -658,9 +659,9 @@ void JobSystem::adopt() { void JobSystem::emancipate() { const auto tid = std::this_thread::get_id(); - std::unique_lock const lock(mThreadMapLock); - auto iter = mThreadMap.find(tid); - ThreadState* const state = iter == mThreadMap.end() ? nullptr : iter->second; + std::unique_lock const lock(mThreadMapLock); + auto const iter = mThreadMap.find(tid); + ThreadState const* const state = iter == mThreadMap.end() ? nullptr : iter->second; FILAMENT_CHECK_PRECONDITION(state) << "this thread is not an adopted thread"; FILAMENT_CHECK_PRECONDITION(state->js == this) << "this thread is not adopted by us"; mThreadMap.erase(iter);