diff --git a/filament/backend/include/backend/Platform.h b/filament/backend/include/backend/Platform.h index 71564710dc..8142d54d3a 100644 --- a/filament/backend/include/backend/Platform.h +++ b/filament/backend/include/backend/Platform.h @@ -236,7 +236,7 @@ public: * @return nullptr on failure, or a pointer to the newly created driver. */ virtual Driver* UTILS_NULLABLE createDriver(void* UTILS_NULLABLE sharedContext, - const DriverConfig& driverConfig) noexcept = 0; + const DriverConfig& driverConfig) = 0; /** * Processes the platform's event queue when called from its primary event-handling thread. diff --git a/filament/backend/include/backend/Program.h b/filament/backend/include/backend/Program.h index f419f7b8f3..0a04726187 100644 --- a/filament/backend/include/backend/Program.h +++ b/filament/backend/include/backend/Program.h @@ -118,7 +118,7 @@ public: Program& multiview(bool multiview) noexcept; // For ES2 support only... - Program& uniforms(uint32_t index, utils::CString name, UniformInfo uniforms) noexcept; + Program& uniforms(uint32_t index, utils::CString name, UniformInfo uniforms); Program& attributes(AttributesInfo attributes) noexcept; // diff --git a/filament/backend/include/backend/platforms/OpenGLPlatform.h b/filament/backend/include/backend/platforms/OpenGLPlatform.h index 013dcfd6bc..3d674f1624 100644 --- a/filament/backend/include/backend/platforms/OpenGLPlatform.h +++ b/filament/backend/include/backend/platforms/OpenGLPlatform.h @@ -112,7 +112,7 @@ public: * */ virtual SwapChain* UTILS_NULLABLE createSwapChain( - void* UTILS_NULLABLE nativeWindow, uint64_t flags) noexcept = 0; + void* UTILS_NULLABLE nativeWindow, uint64_t flags) = 0; /** * Called by the driver create a headless SwapChain. @@ -126,7 +126,7 @@ public: * A void* might be enough. */ virtual SwapChain* UTILS_NULLABLE createSwapChain( - uint32_t width, uint32_t height, uint64_t flags) noexcept = 0; + uint32_t width, uint32_t height, uint64_t flags) = 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 ebc177433b..c424ec4f96 100644 --- a/filament/backend/include/backend/platforms/PlatformCocoaGL.h +++ b/filament/backend/include/backend/platforms/PlatformCocoaGL.h @@ -40,7 +40,7 @@ protected: // Platform Interface Driver* createDriver(void* sharedContext, - const DriverConfig& driverConfig) noexcept override; + const DriverConfig& driverConfig) override; // Currently returns 0 int getOSVersion() const noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h b/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h index cdb548181e..94ca86d153 100644 --- a/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h +++ b/filament/backend/include/backend/platforms/PlatformCocoaTouchGL.h @@ -38,7 +38,7 @@ public: // Platform Interface Driver* createDriver(void* sharedGLContext, - const DriverConfig& driverConfig) noexcept override; + const DriverConfig& driverConfig) override; int getOSVersion() const noexcept final { return 0; } diff --git a/filament/backend/include/backend/platforms/PlatformEGL.h b/filament/backend/include/backend/platforms/PlatformEGL.h index f3dafda73f..9204162fe9 100644 --- a/filament/backend/include/backend/platforms/PlatformEGL.h +++ b/filament/backend/include/backend/platforms/PlatformEGL.h @@ -80,7 +80,7 @@ protected: * Initializes EGL, creates the OpenGL context and returns a concrete Driver implementation * that supports OpenGL/OpenGL ES. */ - Driver* createDriver(void* sharedContext, const DriverConfig& driverConfig) noexcept override; + Driver* createDriver(void* sharedContext, const DriverConfig& driverConfig) override; /** * This returns zero. This method can be overridden to return something more useful. @@ -101,8 +101,8 @@ protected: bool isSRGBSwapChainSupported() const noexcept override; bool isMSAASwapChainSupported(uint32_t samples) const 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) override; + SwapChain* createSwapChain(uint32_t width, uint32_t height, uint64_t flags) override; void destroySwapChain(SwapChain* swapChain) noexcept override; bool isSwapChainProtected(SwapChain* swapChain) noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformEGLAndroid.h b/filament/backend/include/backend/platforms/PlatformEGLAndroid.h index 6a9163508c..249defbc6f 100644 --- a/filament/backend/include/backend/platforms/PlatformEGLAndroid.h +++ b/filament/backend/include/backend/platforms/PlatformEGLAndroid.h @@ -80,7 +80,7 @@ protected: int getOSVersion() const noexcept override; Driver* createDriver(void* sharedContext, - const Platform::DriverConfig& driverConfig) noexcept override; + const Platform::DriverConfig& driverConfig) override; // -------------------------------------------------------------------------------------------- // OpenGLPlatform Interface diff --git a/filament/backend/include/backend/platforms/PlatformEGLHeadless.h b/filament/backend/include/backend/platforms/PlatformEGLHeadless.h index 40d285b908..300748e0aa 100644 --- a/filament/backend/include/backend/platforms/PlatformEGLHeadless.h +++ b/filament/backend/include/backend/platforms/PlatformEGLHeadless.h @@ -29,7 +29,7 @@ public: PlatformEGLHeadless() noexcept; Driver* createDriver(void* sharedContext, - const Platform::DriverConfig& driverConfig) noexcept override; + const Platform::DriverConfig& driverConfig) override; protected: bool isOpenGL() const noexcept override; diff --git a/filament/backend/include/backend/platforms/PlatformGLX.h b/filament/backend/include/backend/platforms/PlatformGLX.h index b26a12b067..08b3b0a0e9 100644 --- a/filament/backend/include/backend/platforms/PlatformGLX.h +++ b/filament/backend/include/backend/platforms/PlatformGLX.h @@ -39,7 +39,7 @@ protected: // Platform Interface Driver* createDriver(void* sharedGLContext, - const DriverConfig& driverConfig) noexcept override; + const DriverConfig& driverConfig) override; int getOSVersion() const noexcept final override { return 0; } diff --git a/filament/backend/include/backend/platforms/PlatformMetal.h b/filament/backend/include/backend/platforms/PlatformMetal.h index 48a5f85cd5..a2e3ac25f3 100644 --- a/filament/backend/include/backend/platforms/PlatformMetal.h +++ b/filament/backend/include/backend/platforms/PlatformMetal.h @@ -36,7 +36,7 @@ public: PlatformMetal(); ~PlatformMetal() noexcept override; - Driver* createDriver(void* sharedContext, const Platform::DriverConfig& driverConfig) noexcept override; + Driver* createDriver(void* sharedContext, const Platform::DriverConfig& driverConfig) override; int getOSVersion() const noexcept override { return 0; } /** diff --git a/filament/backend/include/backend/platforms/PlatformOSMesa.h b/filament/backend/include/backend/platforms/PlatformOSMesa.h index 4ed4db7a21..10e1fb18c3 100644 --- a/filament/backend/include/backend/platforms/PlatformOSMesa.h +++ b/filament/backend/include/backend/platforms/PlatformOSMesa.h @@ -43,7 +43,7 @@ protected: // -------------------------------------------------------------------------------------------- // Platform Interface - Driver* createDriver(void* sharedGLContext, const DriverConfig& driverConfig) noexcept override; + Driver* createDriver(void* sharedGLContext, const DriverConfig& driverConfig) override; int getOSVersion() const noexcept final override { return 0; } diff --git a/filament/backend/include/backend/platforms/PlatformWGL.h b/filament/backend/include/backend/platforms/PlatformWGL.h index 3963e1476c..3b7ad7e7aa 100644 --- a/filament/backend/include/backend/platforms/PlatformWGL.h +++ b/filament/backend/include/backend/platforms/PlatformWGL.h @@ -38,7 +38,7 @@ protected: // Platform Interface Driver* createDriver(void* sharedGLContext, - const Platform::DriverConfig& driverConfig) noexcept override; + const Platform::DriverConfig& driverConfig) override; int getOSVersion() const noexcept final override { return 0; } diff --git a/filament/backend/include/backend/platforms/PlatformWebGL.h b/filament/backend/include/backend/platforms/PlatformWebGL.h index 4ced86d9bb..2def853101 100644 --- a/filament/backend/include/backend/platforms/PlatformWebGL.h +++ b/filament/backend/include/backend/platforms/PlatformWebGL.h @@ -34,7 +34,7 @@ protected: // Platform Interface Driver* createDriver(void* sharedGLContext, - const Platform::DriverConfig& driverConfig) noexcept override; + const Platform::DriverConfig& driverConfig) override; int getOSVersion() const noexcept override; diff --git a/filament/backend/include/backend/platforms/VulkanPlatform.h b/filament/backend/include/backend/platforms/VulkanPlatform.h index 163fa07605..49cf6d1c64 100644 --- a/filament/backend/include/backend/platforms/VulkanPlatform.h +++ b/filament/backend/include/backend/platforms/VulkanPlatform.h @@ -119,7 +119,7 @@ public: ~VulkanPlatform() override; Driver* createDriver(void* sharedContext, - Platform::DriverConfig const& driverConfig) noexcept override; + Platform::DriverConfig const& driverConfig) override; int getOSVersion() const noexcept override { return 0; diff --git a/filament/backend/include/backend/platforms/WebGPUPlatform.h b/filament/backend/include/backend/platforms/WebGPUPlatform.h index 93535ea1f8..03ace96c96 100644 --- a/filament/backend/include/backend/platforms/WebGPUPlatform.h +++ b/filament/backend/include/backend/platforms/WebGPUPlatform.h @@ -72,7 +72,7 @@ public: protected: [[nodiscard]] Driver* createDriver(void* sharedContext, - const Platform::DriverConfig& driverConfig) noexcept override; + const Platform::DriverConfig& driverConfig) override; private: // returns adapter request option variations applicable for the particular diff --git a/filament/backend/include/private/backend/CommandStream.h b/filament/backend/include/private/backend/CommandStream.h index 5322f7ab67..608e8ddf31 100644 --- a/filament/backend/include/private/backend/CommandStream.h +++ b/filament/backend/include/private/backend/CommandStream.h @@ -61,7 +61,7 @@ class CommandBase { protected: using Execute = Dispatcher::Execute; - constexpr explicit CommandBase(Execute execute) noexcept : mExecute(execute) {} + constexpr explicit CommandBase(Execute const execute) noexcept : mExecute(execute) {} public: // alignment of all Commands in the CommandStream @@ -70,7 +70,7 @@ public: } // executes this command and returns the next one - inline CommandBase* execute(Driver& driver) { + CommandBase* execute(Driver& driver) { // returning the next command by output parameter allows the compiler to perform the // tail-call optimization in the function called by mExecute, however that comes at // a cost here (writing and reading the stack at each iteration), in the end it's @@ -80,7 +80,7 @@ public: return reinterpret_cast(reinterpret_cast(this) + next); } - inline ~CommandBase() noexcept = default; + ~CommandBase() noexcept = default; private: Execute mExecute; @@ -135,7 +135,7 @@ struct CommandType { public: template - static inline void execute(M&& method, D&& driver, CommandBase* base, intptr_t* next) { + static void execute(M&& method, D&& driver, CommandBase* base, intptr_t* next) { Command* self = static_cast(base); *next = align(sizeof(Command)); #if DEBUG_COMMAND_STREAM @@ -147,15 +147,15 @@ struct CommandType { } // A command can be moved - inline Command(Command&& rhs) noexcept = default; + Command(Command&& rhs) noexcept = default; template - inline explicit constexpr Command(Execute execute, A&& ... args) + explicit constexpr Command(Execute const execute, A&& ... args) noexcept : CommandBase(execute), mArgs(std::forward(args)...) { } // placement new declared as "throw" to avoid the compiler's null-check - inline void* operator new(std::size_t, void* ptr) { + void* operator new(std::size_t, void* ptr) noexcept { assert_invariant(ptr); return ptr; } @@ -171,8 +171,9 @@ class CustomCommand : public CommandBase { std::function mCommand; static void execute(Driver&, CommandBase* base, intptr_t* next); public: - inline CustomCommand(CustomCommand&& rhs) = default; - inline explicit CustomCommand(std::function cmd) + CustomCommand(CustomCommand&& rhs) = default; + + explicit CustomCommand(std::function cmd) : CommandBase(execute), mCommand(std::move(cmd)) { } }; @@ -184,7 +185,7 @@ class NoopCommand : public CommandBase { *next = static_cast(self)->mNext; } public: - inline constexpr explicit NoopCommand(void* next) noexcept + constexpr explicit NoopCommand(void* next) noexcept : CommandBase(execute), mNext(intptr_t((char *)next - (char *)this)) { } }; @@ -207,8 +208,8 @@ class CommandStream { template struct AutoExecute { T closure; - inline explicit AutoExecute(T&& closure) : closure(std::forward(closure)) {} - inline ~AutoExecute() { closure(); } + explicit AutoExecute(T&& closure) : closure(std::forward(closure)) {} + ~AutoExecute() { closure(); } }; public: @@ -221,7 +222,7 @@ public: public: #define DECL_DRIVER_API(methodName, paramsDecl, params) \ - inline void methodName(paramsDecl) { \ + inline void methodName(paramsDecl) noexcept { \ DEBUG_COMMAND_BEGIN(methodName, false, params); \ using Cmd = COMMAND_TYPE(methodName); \ void* const p = allocateCommand(CommandBase::align(sizeof(Cmd))); \ @@ -230,7 +231,7 @@ public: } #define DECL_DRIVER_API_SYNCHRONOUS(RetType, methodName, paramsDecl, params) \ - inline RetType methodName(paramsDecl) { \ + inline RetType methodName(paramsDecl) noexcept { \ DEBUG_COMMAND_BEGIN(methodName, true, params); \ AutoExecute callOnExit([=, this](){ \ DEBUG_COMMAND_END(methodName, true); \ @@ -239,7 +240,7 @@ public: } #define DECL_DRIVER_API_RETURN(RetType, methodName, paramsDecl, params) \ - inline RetType methodName(paramsDecl) { \ + inline RetType methodName(paramsDecl) noexcept { \ DEBUG_COMMAND_BEGIN(methodName, false, params); \ RetType result = mDriver.methodName##S(); \ using Cmd = COMMAND_TYPE(methodName##R); \ @@ -255,7 +256,7 @@ public: // This is for debugging only. Currently, CircularBuffer can only be written from a // single thread. In debug builds we assert this condition. // Call this first in the render loop. - inline void debugThreading() noexcept { + void debugThreading() noexcept { #ifndef NDEBUG mThreadId = utils::ThreadUtils::getThreadId(); #endif @@ -281,11 +282,11 @@ public: */ template::value>::type> - inline PodType* allocatePod( + PodType* allocatePod( size_t count = 1, size_t alignment = alignof(PodType)) noexcept; private: - inline void* allocateCommand(size_t size) { + void* allocateCommand(size_t const size) noexcept { assert_invariant(utils::ThreadUtils::isThisThread(mThreadId)); return mCurrentBuffer.allocate(size); } diff --git a/filament/backend/include/private/backend/HandleAllocator.h b/filament/backend/include/private/backend/HandleAllocator.h index af355068cd..f0fb62434e 100644 --- a/filament/backend/include/private/backend/HandleAllocator.h +++ b/filament/backend/include/private/backend/HandleAllocator.h @@ -70,12 +70,12 @@ private: template class HandleAllocator : public DebugTag { public: - HandleAllocator(const char* name, size_t size) noexcept; + HandleAllocator(const char* name, size_t size); HandleAllocator(const char* name, size_t size, - bool disableUseAfterFreeCheck, bool disableHeapHandleTags) noexcept; + bool disableUseAfterFreeCheck, bool disableHeapHandleTags); HandleAllocator(HandleAllocator const& rhs) = delete; HandleAllocator& operator=(HandleAllocator const& rhs) = delete; - ~HandleAllocator(); + ~HandleAllocator() noexcept; /* * Constructs a D object and returns a Handle @@ -106,7 +106,7 @@ public: * */ template - Handle allocate() noexcept { + Handle allocate() { Handle h{ allocateHandle() }; return h; } @@ -342,7 +342,7 @@ private: // allocation size this is always inlined, because all these do is to call // allocateHandleInPool()/deallocateHandleFromPool() with the right pool size. template - HandleBase::HandleId allocateHandle() noexcept { + HandleBase::HandleId allocateHandle() { constexpr size_t BUCKET_SIZE = getBucketSize(); return allocateHandleInPool(); } @@ -358,7 +358,7 @@ private: // the code generated is not trivial (even if it's not insane either). template UTILS_NOINLINE - HandleBase::HandleId allocateHandleInPool() noexcept { + HandleBase::HandleId allocateHandleInPool() { uint8_t age; void* p = mHandleArena.alloc(SIZE, alignof(std::max_align_t), 0, &age); if (UTILS_LIKELY(p)) { diff --git a/filament/backend/src/CallbackManager.cpp b/filament/backend/src/CallbackManager.cpp index 8d85a9f488..3854c11c17 100644 --- a/filament/backend/src/CallbackManager.cpp +++ b/filament/backend/src/CallbackManager.cpp @@ -20,7 +20,7 @@ namespace filament::backend { -CallbackManager::CallbackManager(DriverBase& driver) noexcept +CallbackManager::CallbackManager(DriverBase& driver) : mDriver(driver), mCallbacks(1) { } diff --git a/filament/backend/src/CallbackManager.h b/filament/backend/src/CallbackManager.h index f4aee24c39..49e6fe3c61 100644 --- a/filament/backend/src/CallbackManager.h +++ b/filament/backend/src/CallbackManager.h @@ -51,7 +51,7 @@ class CallbackManager { public: using Handle = Container::const_iterator; - explicit CallbackManager(DriverBase& driver) noexcept; + explicit CallbackManager(DriverBase& driver); ~CallbackManager() noexcept; @@ -78,7 +78,7 @@ private: return --mCallbacks.end(); } - Container::iterator allocateNewSlot() noexcept { + Container::iterator allocateNewSlot() { std::lock_guard const lock(mLock); auto curr = --mCallbacks.end(); mCallbacks.emplace_back(); diff --git a/filament/backend/src/CommandStream.cpp b/filament/backend/src/CommandStream.cpp index 02ededfa78..4266683f62 100644 --- a/filament/backend/src/CommandStream.cpp +++ b/filament/backend/src/CommandStream.cpp @@ -57,12 +57,15 @@ static void printParameterPack(io::ostream& out, const FIRST& first, const REMAI printParameterPack(out, rest...); } -static UTILS_NOINLINE UTILS_UNUSED std::string_view extractMethodName(std::string_view command) noexcept { - constexpr const char startPattern[] = "::Command<&filament::backend::Driver::"; +static UTILS_NOINLINE UTILS_UNUSED std::string_view extractMethodName(std::string_view command) noexcept { // NOLINT(*-exception-escape) + constexpr char startPattern[] = "::Command<&filament::backend::Driver::"; auto pos = command.rfind(startPattern); auto end = command.rfind('('); pos += sizeof(startPattern) - 1; - return command.substr(pos, end-pos); + if (pos > command.size()) { + return { command.data(), command.size() }; + } + return command.substr(pos, end-pos); // this can't throw by construction } // ------------------------------------------------------------------------------------------------ diff --git a/filament/backend/src/CompilerThreadPool.cpp b/filament/backend/src/CompilerThreadPool.cpp index c090eac66a..6590555cf8 100644 --- a/filament/backend/src/CompilerThreadPool.cpp +++ b/filament/backend/src/CompilerThreadPool.cpp @@ -18,7 +18,14 @@ #include +#include +#include + +#include +#include #include +#include +#include namespace filament::backend { @@ -36,7 +43,7 @@ CompilerThreadPool::~CompilerThreadPool() noexcept { } void CompilerThreadPool::init(uint32_t threadCount, - ThreadSetup&& threadSetup, ThreadCleanup&& threadCleanup) noexcept { + ThreadSetup&& threadSetup, ThreadCleanup&& threadCleanup) { auto setup = std::make_shared(std::move(threadSetup)); auto cleanup = std::make_shared(std::move(threadCleanup)); diff --git a/filament/backend/src/CompilerThreadPool.h b/filament/backend/src/CompilerThreadPool.h index 03c3fe6cfe..993f991f7b 100644 --- a/filament/backend/src/CompilerThreadPool.h +++ b/filament/backend/src/CompilerThreadPool.h @@ -47,8 +47,7 @@ public: using Job = utils::Invocable; using ThreadSetup = utils::Invocable; using ThreadCleanup = utils::Invocable; - void init(uint32_t threadCount, - ThreadSetup&& threadSetup, ThreadCleanup&& threadCleanup) noexcept; + void init(uint32_t threadCount, ThreadSetup&& threadSetup, ThreadCleanup&& threadCleanup); void terminate() noexcept; void queue(CompilerPriorityQueue priorityQueue, program_token_t const& token, Job&& job); Job dequeue(program_token_t const& token); diff --git a/filament/backend/src/Driver.cpp b/filament/backend/src/Driver.cpp index 22cf90a156..e2f2e0a415 100644 --- a/filament/backend/src/Driver.cpp +++ b/filament/backend/src/Driver.cpp @@ -131,7 +131,7 @@ void DriverBase::purge() noexcept { // ------------------------------------------------------------------------------------------------ -void DriverBase::scheduleDestroySlow(BufferDescriptor&& buffer) noexcept { +void DriverBase::scheduleDestroySlow(BufferDescriptor&& buffer) { auto const handler = buffer.getHandler(); scheduleCallback(handler, [buffer = std::move(buffer)]() { // user callback is called when BufferDescriptor gets destroyed @@ -140,7 +140,7 @@ void DriverBase::scheduleDestroySlow(BufferDescriptor&& buffer) noexcept { // This is called from an async driver method so it's in the GL thread, but purge is called // on the user thread. This is typically called 0 or 1 times per frame. -void DriverBase::scheduleRelease(AcquiredImage const& image) noexcept { +void DriverBase::scheduleRelease(AcquiredImage const& image) { scheduleCallback(image.handler, [callback = image.callback, image = image.image, userData = image.userData]() { callback(image, userData); }); diff --git a/filament/backend/src/DriverBase.h b/filament/backend/src/DriverBase.h index 4aef4844af..ff9502aba5 100644 --- a/filament/backend/src/DriverBase.h +++ b/filament/backend/src/DriverBase.h @@ -214,15 +214,15 @@ public: protected: class CallbackDataDetails; - void scheduleDestroy(BufferDescriptor&& buffer) noexcept { + void scheduleDestroy(BufferDescriptor&& buffer) { if (buffer.hasCallback()) { scheduleDestroySlow(std::move(buffer)); } } - void scheduleDestroySlow(BufferDescriptor&& buffer) noexcept; + void scheduleDestroySlow(BufferDescriptor&& buffer); - void scheduleRelease(AcquiredImage const& image) noexcept; + void scheduleRelease(AcquiredImage const& image); void debugCommandBegin(CommandStream* cmds, bool synchronous, const char* methodName) noexcept override; void debugCommandEnd(CommandStream* cmds, bool synchronous, const char* methodName) noexcept override; diff --git a/filament/backend/src/HandleAllocator.cpp b/filament/backend/src/HandleAllocator.cpp index a6b121c196..794064581a 100644 --- a/filament/backend/src/HandleAllocator.cpp +++ b/filament/backend/src/HandleAllocator.cpp @@ -81,19 +81,19 @@ HandleAllocator::Allocator::Allocator(AreaPolicy::HeapArea const& ar template HandleAllocator::HandleAllocator(const char* name, size_t size, bool disableUseAfterFreeCheck, - bool disableHeapHandleTags) noexcept + bool disableHeapHandleTags) : mHandleArena(name, size, disableUseAfterFreeCheck), mUseAfterFreeCheckDisabled(disableUseAfterFreeCheck), mHeapHandleTagsDisabled(disableHeapHandleTags) { } template -HandleAllocator::HandleAllocator(const char* name, size_t size) noexcept +HandleAllocator::HandleAllocator(const char* name, size_t size) : HandleAllocator(name, size, false, false) { } template -HandleAllocator::~HandleAllocator() { +HandleAllocator::~HandleAllocator() noexcept { auto& overflowMap = mOverflowMap; if (!overflowMap.empty()) { PANIC_LOG("Not all handles have been freed. Probably leaking memory."); diff --git a/filament/backend/src/Program.cpp b/filament/backend/src/Program.cpp index 1771e6b935..cd230feb4f 100644 --- a/filament/backend/src/Program.cpp +++ b/filament/backend/src/Program.cpp @@ -41,37 +41,37 @@ Program& Program::operator=(Program&& rhs) noexcept = default; Program::~Program() noexcept = default; -Program& Program::priorityQueue(CompilerPriorityQueue priorityQueue) noexcept { +Program& Program::priorityQueue(CompilerPriorityQueue const priorityQueue) noexcept { mPriorityQueue = priorityQueue; return *this; } Program& Program::diagnostics(CString const& name, - Invocable&& logger) { + Invocable&& logger) { mName = name; mLogger = std::move(logger); return *this; } -Program& Program::shader(ShaderStage shader, void const* data, size_t size) { +Program& Program::shader(ShaderStage shader, void const* data, size_t const size) { ShaderBlob blob(size); std::copy_n((const uint8_t *)data, size, blob.data()); mShadersSource[size_t(shader)] = std::move(blob); return *this; } -Program& Program::shaderLanguage(ShaderLanguage shaderLanguage) { +Program& Program::shaderLanguage(ShaderLanguage const shaderLanguage) { mShaderLanguage = shaderLanguage; return *this; } -Program& Program::descriptorBindings(backend::descriptor_set_t set, +Program& Program::descriptorBindings(descriptor_set_t const set, DescriptorBindingsInfo descriptorBindings) noexcept { mDescriptorBindings[set] = std::move(descriptorBindings); return *this; } -Program& Program::uniforms(uint32_t index, utils::CString name, UniformInfo uniforms) noexcept { +Program& Program::uniforms(uint32_t index, CString name, UniformInfo uniforms) { mBindingUniformsInfo.reserve(mBindingUniformsInfo.capacity() + 1); mBindingUniformsInfo.emplace_back(index, std::move(name), std::move(uniforms)); return *this; @@ -88,17 +88,17 @@ Program& Program::specializationConstants(SpecializationConstantsInfo specConsta } Program& Program::pushConstants(ShaderStage stage, - utils::FixedCapacityVector constants) noexcept { + FixedCapacityVector constants) noexcept { mPushConstants[static_cast(stage)] = std::move(constants); return *this; } -Program& Program::cacheId(uint64_t cacheId) noexcept { +Program& Program::cacheId(uint64_t const cacheId) noexcept { mCacheId = cacheId; return *this; } -Program& Program::multiview(bool multiview) noexcept { +Program& Program::multiview(bool const multiview) noexcept { mMultiview = multiview; return *this; } diff --git a/filament/backend/src/metal/PlatformMetal.mm b/filament/backend/src/metal/PlatformMetal.mm index d4733d75c5..222cbb71dd 100644 --- a/filament/backend/src/metal/PlatformMetal.mm +++ b/filament/backend/src/metal/PlatformMetal.mm @@ -52,7 +52,7 @@ PlatformMetal::~PlatformMetal() noexcept { delete pImpl; } -Driver* PlatformMetal::createDriver(void* /*sharedContext*/, const Platform::DriverConfig& driverConfig) noexcept { +Driver* PlatformMetal::createDriver(void* /*sharedContext*/, const Platform::DriverConfig& driverConfig) { pImpl->mDrawableFailureBehavior = driverConfig.metalDisablePanicOnDrawableFailure ? DrawableFailureBehavior::ABORT_FRAME : DrawableFailureBehavior::PANIC; diff --git a/filament/backend/src/noop/PlatformNoop.cpp b/filament/backend/src/noop/PlatformNoop.cpp index 5fb65c683e..e7724adcc8 100644 --- a/filament/backend/src/noop/PlatformNoop.cpp +++ b/filament/backend/src/noop/PlatformNoop.cpp @@ -20,7 +20,7 @@ namespace filament::backend { -Driver* PlatformNoop::createDriver(void* sharedGLContext, const Platform::DriverConfig& driverConfig) noexcept { +Driver* PlatformNoop::createDriver(void* sharedGLContext, const Platform::DriverConfig& driverConfig) { return NoopDriver::create(); } diff --git a/filament/backend/src/noop/PlatformNoop.h b/filament/backend/src/noop/PlatformNoop.h index 8c0902d27c..1039c614c3 100644 --- a/filament/backend/src/noop/PlatformNoop.h +++ b/filament/backend/src/noop/PlatformNoop.h @@ -31,7 +31,7 @@ public: protected: - Driver* createDriver(void* sharedContext, const Platform::DriverConfig& driverConfig) noexcept override; + Driver* createDriver(void* sharedContext, const Platform::DriverConfig& driverConfig) override; }; } // namespace filament diff --git a/filament/backend/src/opengl/GLDescriptorSet.cpp b/filament/backend/src/opengl/GLDescriptorSet.cpp index 891c7389e1..fc5f7b7e87 100644 --- a/filament/backend/src/opengl/GLDescriptorSet.cpp +++ b/filament/backend/src/opengl/GLDescriptorSet.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -49,7 +50,7 @@ namespace filament::backend { GLDescriptorSet::GLDescriptorSet(OpenGLContext& gl, DescriptorSetLayoutHandle dslh, - GLDescriptorSetLayout const* layout) noexcept + GLDescriptorSetLayout const* layout) : descriptors(layout->maxDescriptorBinding + 1), dslh(std::move(dslh)) { @@ -156,8 +157,9 @@ void GLDescriptorSet::update(OpenGLContext&, arg.bo = bo; arg.offset = uint32_t(offset); } else { - // API usage error. User asked to update the wrong type of descriptor. - PANIC_PRECONDITION("descriptor %d is not a buffer", +binding); + // User asked to update the wrong type of descriptor. This should never happen + // because we're checking that on the filament side + LOG(ERROR) << "descriptor " << +binding << " is not a buffer"; } }, descriptors[binding].desc); } @@ -214,8 +216,9 @@ void GLDescriptorSet::update(OpenGLContext& gl, HandleAllocatorGL& handleAllocat arg.params = params; } } else { - // API usage error. User asked to update the wrong type of descriptor. - PANIC_PRECONDITION("descriptor %d is not a texture", +binding); + // User asked to update the wrong type of descriptor. This should never happen + // because we're checking that on the filament side + LOG(ERROR) << "descriptor " << +binding << " is not a texture"; } }, descriptors[binding].desc); } diff --git a/filament/backend/src/opengl/GLDescriptorSet.h b/filament/backend/src/opengl/GLDescriptorSet.h index 89d8794c65..0770ae8ffc 100644 --- a/filament/backend/src/opengl/GLDescriptorSet.h +++ b/filament/backend/src/opengl/GLDescriptorSet.h @@ -52,7 +52,7 @@ struct GLDescriptorSet : public HwDescriptorSet { using HwDescriptorSet::HwDescriptorSet; GLDescriptorSet(OpenGLContext& gl, DescriptorSetLayoutHandle dslh, - GLDescriptorSetLayout const* layout) noexcept; + GLDescriptorSetLayout const* layout); // update a buffer descriptor in the set void update(OpenGLContext& gl, diff --git a/filament/backend/src/opengl/OpenGLContext.cpp b/filament/backend/src/opengl/OpenGLContext.cpp index d6bde265bf..6bc97bb6e7 100644 --- a/filament/backend/src/opengl/OpenGLContext.cpp +++ b/filament/backend/src/opengl/OpenGLContext.cpp @@ -277,7 +277,7 @@ void OpenGLContext::terminate() noexcept { } void OpenGLContext::destroyWithContext( - size_t index, std::function const& closure) noexcept { + size_t index, std::function const& closure) { if (index == 0) { // Note: we only need to delay the destruction of objects on the unprotected context // (index 0) because the protected context is always immediately destroyed and all its @@ -296,7 +296,7 @@ void OpenGLContext::unbindEverything() noexcept { // worry about. } -void OpenGLContext::synchronizeStateAndCache(size_t index) noexcept { +void OpenGLContext::synchronizeStateAndCache(size_t index) { // if we're just switching back to context 0, run all the pending destructors if (index == 0) { @@ -865,10 +865,12 @@ GLuint OpenGLContext::bindFramebuffer(GLenum target, GLuint buffer) noexcept { if (UTILS_UNLIKELY(buffer == 0)) { // we're binding the default frame buffer, resolve its actual name auto& defaultFboForThisContext = mDefaultFbo[contextIndex]; + if (UTILS_UNLIKELY(!defaultFboForThisContext.has_value())) { defaultFboForThisContext = GLuint(mPlatform.getDefaultFramebufferObject()); } - buffer = defaultFboForThisContext.value(); + // by construction, defaultFboForThisContext has a value. value_or() avoids a throwing call. + buffer = defaultFboForThisContext.value_or(0); } bindFramebufferResolved(target, buffer); return buffer; diff --git a/filament/backend/src/opengl/OpenGLContext.h b/filament/backend/src/opengl/OpenGLContext.h index abecf3a7bd..526bdbaeae 100644 --- a/filament/backend/src/opengl/OpenGLContext.h +++ b/filament/backend/src/opengl/OpenGLContext.h @@ -193,7 +193,7 @@ public: void deleteBuffer(GLuint buffer, GLenum target) noexcept; void deleteVertexArray(GLuint vao) noexcept; - void destroyWithContext(size_t index, std::function const& closure) noexcept; + void destroyWithContext(size_t index, std::function const& closure); // glGet*() values struct Gets { @@ -498,7 +498,7 @@ public: } procs{}; void unbindEverything() noexcept; - void synchronizeStateAndCache(size_t index) noexcept; + void synchronizeStateAndCache(size_t index); #ifndef FILAMENT_SILENCE_NOT_SUPPORTED_BY_ES2 GLuint getSamplerSlow(SamplerParams sp) const noexcept; diff --git a/filament/backend/src/opengl/OpenGLDriver.cpp b/filament/backend/src/opengl/OpenGLDriver.cpp index e000cfbf0c..71db3ebb1e 100644 --- a/filament/backend/src/opengl/OpenGLDriver.cpp +++ b/filament/backend/src/opengl/OpenGLDriver.cpp @@ -3213,7 +3213,7 @@ void OpenGLDriver::setExternalStream(Handle th, Handle sh) } UTILS_NOINLINE -void OpenGLDriver::attachStream(GLTexture* t, GLStream* hwStream) noexcept { +void OpenGLDriver::attachStream(GLTexture* t, GLStream* hwStream) { mTexturesWithStreamsAttached.push_back(t); switch (hwStream->streamType) { @@ -3799,16 +3799,16 @@ void OpenGLDriver::readBufferSubData(BufferObjectHandle boh, } -void OpenGLDriver::runEveryNowAndThen(std::function fn) noexcept { +void OpenGLDriver::runEveryNowAndThen(std::function fn) { mEveryNowAndThenOps.push_back(std::move(fn)); } -void OpenGLDriver::executeEveryNowAndThenOps() noexcept { +void OpenGLDriver::executeEveryNowAndThenOps() noexcept { // NOLINT(*-exception-escape) auto& v = mEveryNowAndThenOps; auto it = v.begin(); while (it != v.end()) { if ((*it)()) { - it = v.erase(it); + it = v.erase(it); // cannot throw by construction } else { ++it; } @@ -3816,17 +3816,17 @@ void OpenGLDriver::executeEveryNowAndThenOps() noexcept { } #ifndef FILAMENT_SILENCE_NOT_SUPPORTED_BY_ES2 -void OpenGLDriver::whenFrameComplete(const std::function& fn) noexcept { +void OpenGLDriver::whenFrameComplete(const std::function& fn) { mFrameCompleteOps.push_back(fn); } -void OpenGLDriver::whenGpuCommandsComplete(const std::function& fn) noexcept { +void OpenGLDriver::whenGpuCommandsComplete(const std::function& fn) { GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); mGpuCommandCompleteOps.emplace_back(sync, fn); CHECK_GL_ERROR() } -void OpenGLDriver::executeGpuCommandsCompleteOps() noexcept { +void OpenGLDriver::executeGpuCommandsCompleteOps() noexcept { // NOLINT(*-exception-escape) auto& v = mGpuCommandCompleteOps; auto it = v.begin(); while (it != v.end()) { @@ -3842,13 +3842,13 @@ void OpenGLDriver::executeGpuCommandsCompleteOps() noexcept { // ready it->second(); glDeleteSync(sync); - it = v.erase(it); + it = v.erase(it); // cannot throw by construction break; default: // This should never happen, but is very problematic if it does, as we might leak // some data depending on what the callback does. However, we clean up our own state. glDeleteSync(sync); - it = v.erase(it); + it = v.erase(it); // cannot throw by construction break; } } diff --git a/filament/backend/src/opengl/OpenGLDriver.h b/filament/backend/src/opengl/OpenGLDriver.h index 223ff262d7..f6899dd8e5 100644 --- a/filament/backend/src/opengl/OpenGLDriver.h +++ b/filament/backend/src/opengl/OpenGLDriver.h @@ -395,23 +395,23 @@ private: std::unordered_map mStreamUniformDescriptors; - void attachStream(GLTexture* t, GLStream* stream) noexcept; + void attachStream(GLTexture* t, GLStream* stream); void detachStream(GLTexture* t) noexcept; void replaceStream(GLTexture* t, GLStream* stream) noexcept; math::mat3f getStreamTransformMatrix(Handle sh); #ifndef FILAMENT_SILENCE_NOT_SUPPORTED_BY_ES2 // tasks executed on the main thread after the fence signaled - void whenGpuCommandsComplete(const std::function& fn) noexcept; + void whenGpuCommandsComplete(const std::function& fn); void executeGpuCommandsCompleteOps() noexcept; std::vector>> mGpuCommandCompleteOps; - void whenFrameComplete(const std::function& fn) noexcept; + void whenFrameComplete(const std::function& fn); std::vector> mFrameCompleteOps; #endif // tasks regularly executed on the main thread at until they return true - void runEveryNowAndThen(std::function fn) noexcept; + void runEveryNowAndThen(std::function fn); void executeEveryNowAndThenOps() noexcept; std::vector> mEveryNowAndThenOps; diff --git a/filament/backend/src/opengl/OpenGLProgram.cpp b/filament/backend/src/opengl/OpenGLProgram.cpp index c506eb8af9..1b80b7e484 100644 --- a/filament/backend/src/opengl/OpenGLProgram.cpp +++ b/filament/backend/src/opengl/OpenGLProgram.cpp @@ -121,7 +121,7 @@ void OpenGLProgram::initialize(OpenGLDriver& gld) { * checkProgramStatus() has been successfully called. */ void OpenGLProgram::initializeProgramState(OpenGLContext& context, GLuint program, - LazyInitializationData& lazyInitializationData) noexcept { + LazyInitializationData& lazyInitializationData) { FILAMENT_TRACING_CALL(FILAMENT_TRACING_CATEGORY_FILAMENT); // from the pipeline layout we compute a mapping from {set, binding} to {binding} diff --git a/filament/backend/src/opengl/OpenGLProgram.h b/filament/backend/src/opengl/OpenGLProgram.h index db3723e972..4d4a1ca17b 100644 --- a/filament/backend/src/opengl/OpenGLProgram.h +++ b/filament/backend/src/opengl/OpenGLProgram.h @@ -106,7 +106,7 @@ private: void initialize(OpenGLDriver& gld); void initializeProgramState(OpenGLContext& context, GLuint program, - LazyInitializationData& lazyInitializationData) noexcept; + LazyInitializationData& lazyInitializationData); BindingMap mBindingMap; // 8 bytes + out-of-line 256 bytes diff --git a/filament/backend/src/opengl/OpenGLTimerQuery.cpp b/filament/backend/src/opengl/OpenGLTimerQuery.cpp index 16ee07c3b2..2d8aedc947 100644 --- a/filament/backend/src/opengl/OpenGLTimerQuery.cpp +++ b/filament/backend/src/opengl/OpenGLTimerQuery.cpp @@ -51,7 +51,7 @@ class OpenGLDriver; bool TimerQueryFactory::mGpuTimeSupported = false; TimerQueryFactoryInterface* TimerQueryFactory::init( - OpenGLPlatform& platform, OpenGLContext& context) noexcept { + OpenGLPlatform& platform, OpenGLContext& context) { (void)context; TimerQueryFactoryInterface* impl = nullptr; diff --git a/filament/backend/src/opengl/OpenGLTimerQuery.h b/filament/backend/src/opengl/OpenGLTimerQuery.h index 85c005ea84..1187f0bbab 100644 --- a/filament/backend/src/opengl/OpenGLTimerQuery.h +++ b/filament/backend/src/opengl/OpenGLTimerQuery.h @@ -64,7 +64,7 @@ class TimerQueryFactory { static bool mGpuTimeSupported; public: static TimerQueryFactoryInterface* init( - OpenGLPlatform& platform, OpenGLContext& context) noexcept; + OpenGLPlatform& platform, OpenGLContext& context); static bool isGpuTimeSupported() noexcept { return mGpuTimeSupported; diff --git a/filament/backend/src/opengl/ShaderCompilerService.cpp b/filament/backend/src/opengl/ShaderCompilerService.cpp index aa0dc61953..88d66886ab 100644 --- a/filament/backend/src/opengl/ShaderCompilerService.cpp +++ b/filament/backend/src/opengl/ShaderCompilerService.cpp @@ -71,7 +71,7 @@ static CString to_string(int const i) { return utils::to_string(i); } static CString to_string(float const f) { return "float(" + utils::to_string(f) + ")"; } static void logCompilationError(ShaderStage shaderType, const char* name, GLuint shaderId, - Program::ShaderBlob const& sourceCode) noexcept; + Program::ShaderBlob const& sourceCode); static void logProgramLinkError(char const* name, GLuint program) noexcept; static void process_GOOGLE_cpp_style_line_directive(OpenGLContext const& context, char* source, @@ -79,7 +79,7 @@ static void process_GOOGLE_cpp_style_line_directive(OpenGLContext const& context static void process_OVR_multiview2(OpenGLContext const& context, int32_t eyeCount, char* source, size_t len) noexcept; static std::string_view process_ARB_shading_language_packing(OpenGLContext& context) noexcept; -static std::array splitShaderSource(std::string_view source) noexcept; +static std::array splitShaderSource(std::string_view source); // ------------------------------------------------------------------------------------------------ @@ -312,7 +312,7 @@ ShaderCompilerService::program_token_t ShaderCompilerService::createProgram( } void ShaderCompilerService::compileProgram( - program_token_t const& token, Program&& program) noexcept { + program_token_t const& token, Program&& program) { auto& gl = mDriver.getContext(); CompilerPriorityQueue const priorityQueue = program.getPriorityQueue(); switch (mMode) { @@ -586,7 +586,7 @@ void ShaderCompilerService::handleCanceledTokensForThreadPool() { // ------------------------------------------------------------------------------------------------ void ShaderCompilerService::runAtNextTick(CompilerPriorityQueue priority, - program_token_t const& token, Job job) noexcept { + program_token_t const& token, Job job) { // insert items in order of priority and at the end of the range auto& ops = mRunAtNextTickOps; auto const pos = std::lower_bound(ops.begin(), ops.end(), priority, @@ -614,7 +614,7 @@ bool ShaderCompilerService::cancelTickOp(program_token_t const& token) noexcept return false; } -void ShaderCompilerService::executeTickOps() noexcept { +void ShaderCompilerService::executeTickOps() { auto& ops = mRunAtNextTickOps; auto it = ops.begin(); while (it != ops.end()) { @@ -636,7 +636,7 @@ bool ShaderCompilerService::shouldCompileSynchronousProgramThisTick() const noex mNumTicksUntilNextSynchronousProgram == 0); } -void ShaderCompilerService::compilePendingSynchronousPrograms() noexcept { +void ShaderCompilerService::compilePendingSynchronousPrograms() { if (mDriver.getDriverConfig().disableAmortizedShaderCompile) { return; } @@ -655,7 +655,7 @@ void ShaderCompilerService::compilePendingSynchronousPrograms() noexcept { } void ShaderCompilerService::compilePendingSynchronousProgramNow( - program_token_t const& token) noexcept { + program_token_t const& token) { if (mDriver.getDriverConfig().disableAmortizedShaderCompile) { return; } @@ -692,7 +692,7 @@ void ShaderCompilerService::cancelPendingSynchronousProgram(program_token_t cons /* static */ void ShaderCompilerService::compileShaders(OpenGLContext& context, Program::ShaderSource shadersSource, FixedCapacityVector const& specializationConstants, - bool multiview, program_token_t const& token) noexcept { + bool multiview, program_token_t const& token) { FILAMENT_TRACING_CALL(FILAMENT_TRACING_CATEGORY_FILAMENT); auto const appendSpecConstantString = +[](CString& s, Program::SpecializationConstant const& sc) { @@ -817,7 +817,7 @@ void ShaderCompilerService::cancelPendingSynchronousProgram(program_token_t cons return true; } -/* static */ void ShaderCompilerService::checkCompileStatus(program_token_t const& token) noexcept { +/* static */ void ShaderCompilerService::checkCompileStatus(program_token_t const& token) { FILAMENT_TRACING_CALL(FILAMENT_TRACING_CATEGORY_FILAMENT); UTILS_NOUNROLL @@ -839,7 +839,7 @@ void ShaderCompilerService::cancelPendingSynchronousProgram(program_token_t cons } /* static */ void ShaderCompilerService::linkProgram(OpenGLContext const& context, - program_token_t const& token) noexcept { + program_token_t const& token) { FILAMENT_TRACING_CALL(FILAMENT_TRACING_CATEGORY_FILAMENT); // Shader compilation should be completed by now. Check the status and log errors on failure. @@ -933,7 +933,7 @@ void ShaderCompilerService::cancelPendingSynchronousProgram(program_token_t cons UTILS_NOINLINE /* static */ void logCompilationError(ShaderStage shaderType, const char* name, GLuint const shaderId, - UTILS_UNUSED_IN_RELEASE Program::ShaderBlob const& sourceCode) noexcept { + UTILS_UNUSED_IN_RELEASE Program::ShaderBlob const& sourceCode) { // Collects the current GL error for additional context. While often redundant, // errors like `GL_CONTEXT_LOST` can occur asynchronously after `glCompileShader`. @@ -1179,7 +1179,7 @@ mediump vec4 unpackSnorm4x8(highp uint v) { // - the version line // - extensions // - everything else -/* static */ std::array splitShaderSource(std::string_view source) noexcept { +/* static */ std::array splitShaderSource(std::string_view source) { auto const version_start = source.find("#version"); assert_invariant(version_start != std::string_view::npos); diff --git a/filament/backend/src/opengl/ShaderCompilerService.h b/filament/backend/src/opengl/ShaderCompilerService.h index 00ed62ca70..db11dce1ab 100644 --- a/filament/backend/src/opengl/ShaderCompilerService.h +++ b/filament/backend/src/opengl/ShaderCompilerService.h @@ -148,16 +148,16 @@ private: // Methods for SYNCHRONOUS and ASYNCHRONOUS modes. void runAtNextTick(CompilerPriorityQueue priority, program_token_t const& token, - Job job) noexcept; - void executeTickOps() noexcept; + Job job); + void executeTickOps(); bool cancelTickOp(program_token_t const& token) noexcept; bool shouldCompileSynchronousProgramThisTick() const noexcept; - void compilePendingSynchronousPrograms() noexcept; - void compilePendingSynchronousProgramNow(program_token_t const& token) noexcept; + void compilePendingSynchronousPrograms(); + void compilePendingSynchronousProgramNow(program_token_t const& token); void cancelPendingSynchronousProgram(program_token_t const& token) noexcept; - void compileProgram(program_token_t const& token, Program&& program) noexcept; + void compileProgram(program_token_t const& token, Program&& program); // Compile shaders with the given `shaderSource`. `gl.shaders` is always populated with valid // shader IDs after this method. But this doesn't necessarily mean the shaders are successfully @@ -165,20 +165,20 @@ private: static void compileShaders(OpenGLContext& context, Program::ShaderSource shadersSource, utils::FixedCapacityVector const& specializationConstants, - bool multiview, program_token_t const& token) noexcept; + bool multiview, program_token_t const& token); // Check if the shader compilation is completed. You may want to call this when the extension // `KHR_parallel_shader_compile` is enabled. static bool isCompileCompleted(program_token_t const& token) noexcept; // Check compilation status of the shaders and log errors on failure. - static void checkCompileStatus(program_token_t const& token) noexcept; + static void checkCompileStatus(program_token_t const& token); // Create a program by linking the compiled shaders. `gl.program` is always populated with a // valid program ID after this method. But this doesn't necessarily mean the program is // successfully linked. Errors can be checked by calling `checkLinkStatusAndCleanupShaders` // later. - static void linkProgram(OpenGLContext const& context, program_token_t const& token) noexcept; + static void linkProgram(OpenGLContext const& context, program_token_t const& token); // Check if the program link is completed. You may want to call this when the extension // `KHR_parallel_shader_compile` is enabled. diff --git a/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm b/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm index 9e22ef5f96..4e6f72f30b 100644 --- a/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm +++ b/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm @@ -148,7 +148,7 @@ PlatformCocoaGL::~PlatformCocoaGL() noexcept { delete pImpl; } -Driver* PlatformCocoaGL::createDriver(void* sharedContext, const Platform::DriverConfig& driverConfig) noexcept { +Driver* PlatformCocoaGL::createDriver(void* sharedContext, const Platform::DriverConfig& driverConfig) { // NSOpenGLPFAColorSize: when unspecified, a format that matches the screen is preferred NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = { NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, diff --git a/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm b/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm index aee19daadc..5fac25e5bc 100644 --- a/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm +++ b/filament/backend/src/opengl/platforms/PlatformCocoaTouchGL.mm @@ -64,7 +64,7 @@ PlatformCocoaTouchGL::~PlatformCocoaTouchGL() noexcept { delete pImpl; } -Driver* PlatformCocoaTouchGL::createDriver(void* sharedGLContext, const Platform::DriverConfig& driverConfig) noexcept { +Driver* PlatformCocoaTouchGL::createDriver(void* sharedGLContext, const Platform::DriverConfig& driverConfig) { EAGLSharegroup* sharegroup = (__bridge EAGLSharegroup*) sharedGLContext; EAGLContext *context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3 sharegroup:sharegroup]; diff --git a/filament/backend/src/opengl/platforms/PlatformEGL.cpp b/filament/backend/src/opengl/platforms/PlatformEGL.cpp index 0b676b6697..60b22f7d50 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGL.cpp @@ -119,7 +119,7 @@ bool PlatformEGL::isOpenGL() const noexcept { PlatformEGL::ExternalImageEGL::~ExternalImageEGL() = default; -Driver* PlatformEGL::createDriver(void* sharedContext, const DriverConfig& driverConfig) noexcept { +Driver* PlatformEGL::createDriver(void* sharedContext, const DriverConfig& driverConfig) { mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert_invariant(mEGLDisplay != EGL_NO_DISPLAY); @@ -500,7 +500,7 @@ bool PlatformEGL::isMSAASwapChainSupported(uint32_t samples) const noexcept { } Platform::SwapChain* PlatformEGL::createSwapChain( - void* nativeWindow, uint64_t flags) noexcept { + void* nativeWindow, uint64_t flags) { Config attribs; @@ -561,7 +561,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) { Config attribs = { { EGL_WIDTH, EGLint(width) }, diff --git a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp index 5b2b33aa94..fa338ab91f 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp @@ -198,7 +198,7 @@ void backend::PlatformEGLAndroid::preCommit() noexcept { } Driver* PlatformEGLAndroid::createDriver(void* sharedContext, - const Platform::DriverConfig& driverConfig) noexcept { + const Platform::DriverConfig& driverConfig) { // the refresh rate default value doesn't matter, we change it later int32_t const tid = gettid(); diff --git a/filament/backend/src/opengl/platforms/PlatformEGLHeadless.cpp b/filament/backend/src/opengl/platforms/PlatformEGLHeadless.cpp index 0558c6008f..f9543ad669 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGLHeadless.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGLHeadless.cpp @@ -39,7 +39,7 @@ bool PlatformEGLHeadless::isOpenGL() const noexcept { } backend::Driver* PlatformEGLHeadless::createDriver(void* sharedContext, - const Platform::DriverConfig& driverConfig) noexcept { + const Platform::DriverConfig& driverConfig) { EGLBoolean bindAPI = eglBindAPI(EGL_OPENGL_API); if (UTILS_UNLIKELY(!bindAPI)) { LOG(ERROR) << "eglBindAPI EGL_OPENGL_API failed"; diff --git a/filament/backend/src/opengl/platforms/PlatformGLX.cpp b/filament/backend/src/opengl/platforms/PlatformGLX.cpp index c1ec2fe882..aab7899f8c 100644 --- a/filament/backend/src/opengl/platforms/PlatformGLX.cpp +++ b/filament/backend/src/opengl/platforms/PlatformGLX.cpp @@ -132,7 +132,7 @@ namespace filament::backend { using namespace backend; Driver* PlatformGLX::createDriver(void* sharedGLContext, - const DriverConfig& driverConfig) noexcept { + const DriverConfig& driverConfig) { loadLibraries(); // Get the display device mGLXDisplay = g_x11.openDisplay(NULL); diff --git a/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp b/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp index b6841a8d53..3ad4398f1b 100644 --- a/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp +++ b/filament/backend/src/opengl/platforms/PlatformOSMesa.cpp @@ -113,7 +113,7 @@ private: }// anonymous namespace Driver* PlatformOSMesa::createDriver(void* sharedGLContext, - const DriverConfig& driverConfig) noexcept { + const DriverConfig& driverConfig) { OSMesaAPI* api = new OSMesaAPI(); mOsMesaApi = api; diff --git a/filament/backend/src/opengl/platforms/PlatformWGL.cpp b/filament/backend/src/opengl/platforms/PlatformWGL.cpp index 52392bdcd9..d223c13570 100644 --- a/filament/backend/src/opengl/platforms/PlatformWGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformWGL.cpp @@ -75,7 +75,7 @@ struct WGLSwapChain { static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr; Driver* PlatformWGL::createDriver(void* sharedGLContext, - const Platform::DriverConfig& driverConfig) noexcept { + const Platform::DriverConfig& driverConfig) { int result = 0; int pixelFormat = 0; DWORD dwError = 0; diff --git a/filament/backend/src/opengl/platforms/PlatformWebGL.cpp b/filament/backend/src/opengl/platforms/PlatformWebGL.cpp index 3e31ea074e..35dd06c628 100644 --- a/filament/backend/src/opengl/platforms/PlatformWebGL.cpp +++ b/filament/backend/src/opengl/platforms/PlatformWebGL.cpp @@ -21,7 +21,7 @@ namespace filament::backend { using namespace backend; Driver* PlatformWebGL::createDriver(void* sharedGLContext, - const Platform::DriverConfig& driverConfig) noexcept { + const Platform::DriverConfig& driverConfig) { return OpenGLPlatform::createDefaultDriver(this, sharedGLContext, driverConfig); } diff --git a/filament/backend/src/vulkan/platform/VulkanPlatform.cpp b/filament/backend/src/vulkan/platform/VulkanPlatform.cpp index c1da371f1b..ab46d09292 100644 --- a/filament/backend/src/vulkan/platform/VulkanPlatform.cpp +++ b/filament/backend/src/vulkan/platform/VulkanPlatform.cpp @@ -713,7 +713,7 @@ void VulkanPlatform::terminate() { // This is the main entry point for context creation. Driver* VulkanPlatform::createDriver(void* sharedContext, - Platform::DriverConfig const& driverConfig) noexcept { + Platform::DriverConfig const& driverConfig) { // Load Vulkan entry points. FILAMENT_CHECK_POSTCONDITION(bluevk::initialize()) << "BlueVK is unable to load entry points."; diff --git a/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp b/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp index 6f9f682e3c..f881420454 100644 --- a/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp +++ b/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp @@ -694,7 +694,7 @@ wgpu::Device WebGPUPlatform::requestDevice(wgpu::Adapter const& adapter) { } Driver* WebGPUPlatform::createDriver(void* sharedContext, - const Platform::DriverConfig& driverConfig) noexcept { + const Platform::DriverConfig& driverConfig) { if (sharedContext) { FWGPU_LOGW << "sharedContext is ignored/unused in the WebGPU backend. A non-null " "sharedContext was provided, but it will be ignored."; diff --git a/filament/src/FrameInfo.cpp b/filament/src/FrameInfo.cpp index 5069f55913..e99a4baa3b 100644 --- a/filament/src/FrameInfo.cpp +++ b/filament/src/FrameInfo.cpp @@ -107,18 +107,19 @@ void FrameInfoManager::beginFrame(DriverApi& driver, Config const& config, uint3 // read the pending timer queries until we find one that's not ready } +#if 0 // keep this just for debugging - if constexpr (false) { - using namespace utils; - auto h = getFrameInfoHistory(1); - if (!h.empty()) { - DLOG(INFO) << frameId << ": " << h[0].frameId << " (" << frameId - h[0].frameId << ")" - << ", Dm=" << h[0].endFrame - h[0].beginFrame - << ", L =" << h[0].backendBeginFrame - h[0].beginFrame - << ", Db=" << h[0].backendEndFrame - h[0].backendBeginFrame - << ", T =" << h[0].frameTime; - } + using namespace utils; + auto h = getFrameInfoHistory(1); // this can throw + if (!h.empty()) { + DLOG(INFO) << frameId << ": " << h[0].frameId << " (" << frameId - h[0].frameId << + ")" + << ", Dm=" << h[0].endFrame - h[0].beginFrame + << ", L =" << h[0].backendBeginFrame - h[0].beginFrame + << ", Db=" << h[0].backendEndFrame - h[0].backendBeginFrame + << ", T =" << h[0].frameTime; } +#endif } void FrameInfoManager::endFrame(DriverApi& driver) noexcept { @@ -172,7 +173,7 @@ void FrameInfoManager::denoiseFrameTime(FrameHistoryQueue& history, Config const } FixedCapacityVector FrameInfoManager::getFrameInfoHistory( - size_t historySize) const noexcept { + size_t historySize) const { auto result = FixedCapacityVector::with_capacity(MAX_FRAMETIME_HISTORY); auto const& history = mFrameTimeHistory; size_t i = 0; @@ -188,6 +189,7 @@ FixedCapacityVector FrameInfoManager::getFrameInfoHistory( for (; i < c && historySize; ++i, --historySize) { auto const& entry = history[i]; using namespace std::chrono; + // can't throw by construction result.push_back({ entry.frameId, duration_cast(entry.frameTime).count(), diff --git a/filament/src/FrameInfo.h b/filament/src/FrameInfo.h index 5393f789fc..a110f235c7 100644 --- a/filament/src/FrameInfo.h +++ b/filament/src/FrameInfo.h @@ -123,11 +123,11 @@ public: return *this; } - size_t capacity() const { + size_t capacity() const noexcept { return CAPACITY; } - size_t size() const { + size_t size() const noexcept { return mSize; } @@ -190,7 +190,7 @@ private: Storage mStorage[CAPACITY]; uint32_t mFront = 0; uint32_t mSize = 0; - [[nodiscard]] inline uint32_t advance(uint32_t const v) noexcept { + [[nodiscard]] uint32_t advance(uint32_t const v) noexcept { return (v + 1) % CAPACITY; } }; @@ -223,7 +223,7 @@ public: return pFront ? *pFront : details::FrameInfo{}; } - utils::FixedCapacityVector getFrameInfoHistory(size_t historySize) const noexcept; + utils::FixedCapacityVector getFrameInfoHistory(size_t historySize) const; private: using FrameHistoryQueue = CircularQueue; @@ -232,11 +232,11 @@ private: backend::Handle handle{}; FrameInfoImpl* pInfo = nullptr; }; - std::array mQueries; + std::array mQueries{}; uint32_t mIndex = 0; // index of current query uint32_t mLast = 0; // index of oldest query still active FrameInfoImpl* pFront = nullptr; // the most recent slot with a valid frame time - FrameHistoryQueue mFrameTimeHistory; + FrameHistoryQueue mFrameTimeHistory{}; };