diff --git a/filament/include/filament/Camera.h b/filament/include/filament/Camera.h index 663b0a50a1..823a0c98bf 100644 --- a/filament/include/filament/Camera.h +++ b/filament/include/filament/Camera.h @@ -308,7 +308,7 @@ public: * between 1/8000 and 30. * * @param sensitivity Sensitivity in ISO, clamped between 10 and 204,800. - * A higher \p sensitivity increases the exposure. Realistice values are + * A higher \p sensitivity increases the exposure. Realistic values are * between 50 and 25600. * * @note diff --git a/filament/include/filament/IndirectLight.h b/filament/include/filament/IndirectLight.h index 54d6fd6677..d81b5b6546 100644 --- a/filament/include/filament/IndirectLight.h +++ b/filament/include/filament/IndirectLight.h @@ -192,7 +192,7 @@ public: * @return pointer to the newly created object or nullptr if exceptions are disabled and * an error occurred. * - * @exception utils::PostConditionPanic if a runtime error occured, such as running out of + * @exception utils::PostConditionPanic if a runtime error occurred, such as running out of * memory or other resources. * @exception utils::PreConditionPanic if a parameter to a builder function was invalid. */ diff --git a/filament/include/filament/LightManager.h b/filament/include/filament/LightManager.h index 8905464c7a..1a0f9e316d 100644 --- a/filament/include/filament/LightManager.h +++ b/filament/include/filament/LightManager.h @@ -193,7 +193,7 @@ public: /** Distance from the camera after which shadows are clipped. this is used to clip * shadows that are too far and wouldn't contribute to the scene much, improving - * performance and quality. This valie is always positive. + * performance and quality. This value is always positive. * Use 0.0f to use the camera far distance. */ float shadowFar = 0.0f; diff --git a/filament/include/filament/MaterialInstance.h b/filament/include/filament/MaterialInstance.h index 81f0f43c21..9ab466905e 100644 --- a/filament/include/filament/MaterialInstance.h +++ b/filament/include/filament/MaterialInstance.h @@ -75,7 +75,7 @@ public: * * @param name Name of the parameter as defined by Material. Cannot be nullptr. * @param type Whether the color value is encoded as Linear or sRGB. - * @param color Array of read, green, blue chanels values. + * @param color Array of read, green, blue channels values. * @throws utils::PreConditionPanic if name doesn't exist or no-op if exceptions are disabled. */ void setParameter(const char* name, RgbType type, math::float3 color) noexcept; diff --git a/filament/include/filament/Renderer.h b/filament/include/filament/Renderer.h index ff4373b35c..ab7846507d 100644 --- a/filament/include/filament/Renderer.h +++ b/filament/include/filament/Renderer.h @@ -216,7 +216,7 @@ public: * +--------------------+ * | | .stride .alignment * | | ----------------------->--> - * | | O----------------------+--+ low adresses + * | | O----------------------+--+ low addresses * | | | | | | * | w | | | .top | | * | <---------> | | V | | @@ -226,7 +226,7 @@ public: * +------>| v | | +---->| | | | * | +.........+ | | +.........+ | | * | ^ | | | | - * | y | | +----------------------+--+ high adresses + * | y | | +----------------------+--+ high addresses * O------------+-------+ * * diff --git a/filament/include/filament/TransformManager.h b/filament/include/filament/TransformManager.h index 0a1fd68416..d1ff20464d 100644 --- a/filament/include/filament/TransformManager.h +++ b/filament/include/filament/TransformManager.h @@ -97,7 +97,7 @@ public: * @param e An entity. * * @note If this transform had children, these are orphaned, which means their local - * transform becomes a world transform. Usually it's not sensical. It's recommended to make + * transform becomes a world transform. Usually it's nonsensical. It's recommended to make * sure that a destroyed transform doesn't have have children. * * @see create() diff --git a/filament/include/filament/View.h b/filament/include/filament/View.h index 7740aff750..067e956502 100644 --- a/filament/include/filament/View.h +++ b/filament/include/filament/View.h @@ -297,7 +297,7 @@ public: * correct when rendering a single view. * * However, when rendering a View on top of another one on the same render target, - * it is necessary toindicate that the color buffer cannot be discarded. + * it is necessary to indicate that the color buffer cannot be discarded. * * @param discard Buffers that need to be discarded before rendering. * diff --git a/filament/src/Engine.cpp b/filament/src/Engine.cpp index 9c4494042a..012a08115f 100644 --- a/filament/src/Engine.cpp +++ b/filament/src/Engine.cpp @@ -284,8 +284,8 @@ void FEngine::shutdown() { } cleanupResourceList(mFences); - for (size_t i = 0; i < POST_PROCESS_STAGES_COUNT; i++) { - driver.destroyProgram(mPostProcessPrograms[i]); + for (const auto& mPostProcessProgram : mPostProcessPrograms) { + driver.destroyProgram(mPostProcessProgram); } // There might be commands added by the terminate() calls @@ -702,7 +702,7 @@ bool FEngine::execute() { // wait until we get command buffers to be executed (or thread exit requested) auto buffers = mCommandBufferQueue.waitForCommands(); - if (UTILS_UNLIKELY(!buffers.size())) { + if (UTILS_UNLIKELY(buffers.empty())) { return false; } diff --git a/filament/src/FrameInfo.h b/filament/src/FrameInfo.h index fcaf79f926..76c319b0c7 100644 --- a/filament/src/FrameInfo.h +++ b/filament/src/FrameInfo.h @@ -33,7 +33,7 @@ #include #include -// set EXTRA_TIMING_INFO to enable and print extra timing infos about the render loop +// set EXTRA_TIMING_INFO to enable and print extra timing info about the render loop #define EXTRA_TIMING_INFO false namespace filament { @@ -75,7 +75,7 @@ class FrameInfoManager { static constexpr size_t HISTORY_COUNT = 5; static constexpr size_t POOL_COUNT = 8; - // set this to true to enable extra timing infos + // set this to true to enable extra timing info static constexpr bool mLapRecordsEnabled = EXTRA_TIMING_INFO; public: diff --git a/filament/src/Material.cpp b/filament/src/Material.cpp index 08e694a7f0..7f032003b7 100644 --- a/filament/src/Material.cpp +++ b/filament/src/Material.cpp @@ -127,7 +127,7 @@ FMaterial::FMaterial(FEngine& engine, const Material::Builder& builder) parser->getVertexDomain(&mVertexDomain); parser->getRequiredAttributes(&mRequiredAttributes); if (mBlendingMode == BlendingMode::MASKED) { - parser->getMaskThreshold(&mMaskTreshold); + parser->getMaskThreshold(&mMaskThreshold); } if (mShading == Shading::UNLIT) { parser->hasShadowMultiplier(&mHasShadowMultiplier); diff --git a/filament/src/RenderPass.cpp b/filament/src/RenderPass.cpp index 46c9ded0e3..ede941caa0 100644 --- a/filament/src/RenderPass.cpp +++ b/filament/src/RenderPass.cpp @@ -63,7 +63,7 @@ void RenderPass::render( // compute how much maximum storage we need for this pass uint32_t growBy = FScene::getPrimitiveCount(soa, vr.last); - // double the color pass for transparents that need to render twice + // double the color pass for transparent objects that need to render twice const bool colorPass = bool(commandTypeFlags & CommandTypeFlags::COLOR); const bool depthPass = bool(commandTypeFlags & (CommandTypeFlags::DEPTH | CommandTypeFlags::SHADOW)); growBy *= uint32_t(colorPass * 2 + depthPass); diff --git a/filament/src/RenderTargetPool.h b/filament/src/RenderTargetPool.h index a17cd8b358..06ed68eb21 100644 --- a/filament/src/RenderTargetPool.h +++ b/filament/src/RenderTargetPool.h @@ -43,7 +43,7 @@ class RenderTargetPool { // 1280 x 720 is ~ 7 MB for color buffer static constexpr size_t POOL_MAX_SIZE = 128 * 1024 * 1024; - // 2 pages is way enough for the entry sturctures (should be about 400) + // 2 pages is way enough for the entry structures (should be about 400) static constexpr size_t POOL_ENTRY_ARENA_SIZE = 8192; public: diff --git a/filament/src/Scene.cpp b/filament/src/Scene.cpp index 73291631c6..2b577bc951 100644 --- a/filament/src/Scene.cpp +++ b/filament/src/Scene.cpp @@ -49,7 +49,7 @@ FScene::FScene(FEngine& engine) : FScene::~FScene() noexcept = default; -void FScene::prepare(const math::mat4f& worldOriginTansform) { +void FScene::prepare(const math::mat4f& worldOriginTransform) { // TODO: can we skip this in most cases? Since we rely on indices staying the same, // we could only skip, if nothing changed in the RCM. @@ -103,7 +103,7 @@ void FScene::prepare(const math::mat4f& worldOriginTansform) { // get the world transform auto ti = tcm.getInstance(e); - const mat4f worldTransform = worldOriginTansform * tcm.getWorldTransform(ti); + const mat4f worldTransform = worldOriginTransform * tcm.getWorldTransform(ti); // don't even draw this object if it doesn't have a transform (which shouldn't happen // because one is always created when creating a Renderable component). diff --git a/filament/src/ShadowMap.cpp b/filament/src/ShadowMap.cpp index de7bbcab94..00155e389d 100644 --- a/filament/src/ShadowMap.cpp +++ b/filament/src/ShadowMap.cpp @@ -39,7 +39,7 @@ namespace details { // do this only if depth-clamp is available static constexpr bool USE_DEPTH_CLAMP = false; -// currently disabled because it creates shadow acnee problems at a distance +// currently disabled because it creates shadow acne problems at a distance static constexpr bool ENABLE_LISPSM = true; ShadowMap::ShadowMap(FEngine& engine) noexcept : diff --git a/filament/src/VertexBuffer.cpp b/filament/src/VertexBuffer.cpp index 7b07b6f4e7..c731587d17 100644 --- a/filament/src/VertexBuffer.cpp +++ b/filament/src/VertexBuffer.cpp @@ -71,11 +71,11 @@ VertexBuffer::Builder& VertexBuffer::Builder::attribute(VertexAttribute attribut #ifndef NDEBUG if (byteOffset & 0x3) { - utils::slog.d << "[performace] VertexBuffer::Builder::attribute() " + utils::slog.d << "[performance] VertexBuffer::Builder::attribute() " "byteOffset not multiple of 4" << utils::io::endl; } if (byteStride & 0x3) { - utils::slog.d << "[performace] VertexBuffer::Builder::attribute() " + utils::slog.d << "[performance] VertexBuffer::Builder::attribute() " "byteStride not multiple of 4" << utils::io::endl; } #endif diff --git a/filament/src/View.cpp b/filament/src/View.cpp index 300b5a4b96..4c08f64388 100644 --- a/filament/src/View.cpp +++ b/filament/src/View.cpp @@ -198,7 +198,7 @@ math::float2 FView::updateScale(duration frameTime) noexcept { const float maxMajorScale = minor / major; const float majorScale = std::max(scale, maxMajorScale); - // then the minor axis is scaled down to the original aspec-ratio + // then the minor axis is scaled down to the original aspect-ratio const float minorScale = std::max(scale / majorScale, majorScale * maxMajorScale); // if we have some scaling capacity left, scale homogeneously @@ -728,9 +728,9 @@ void FView::prepareVisibleLights(FLightManager& lcm, utils::JobSystem&, FScene:: } void FView::updatePrimitivesLod(FEngine& engine, const CameraInfo&, - FScene::RenderableSoa& renderableData, Range visibles) noexcept { + FScene::RenderableSoa& renderableData, Range visible) noexcept { FRenderableManager const& rcm = engine.getRenderableManager(); - for (uint32_t index : visibles) { + for (uint32_t index : visible) { uint8_t level = 0; // TODO: pick the proper level of detail auto ri = renderableData.elementAt(index); renderableData.elementAt(index) = rcm.getRenderPrimitives(ri, level); diff --git a/filament/src/components/RenderableManager.cpp b/filament/src/components/RenderableManager.cpp index a7f0272bdc..a5028fe10c 100644 --- a/filament/src/components/RenderableManager.cpp +++ b/filament/src/components/RenderableManager.cpp @@ -181,7 +181,7 @@ RenderableManager::Builder::Result RenderableManager::Builder::build(Engine& eng material = upcast(entry.materialInstance->getMaterial()); } - // primitves without indices or vertices will be ignored + // primitives without indices or vertices will be ignored if (!entry.indices || !entry.vertices) { continue; } diff --git a/filament/src/components/TransformManager.cpp b/filament/src/components/TransformManager.cpp index 219859e678..f470227e0b 100644 --- a/filament/src/components/TransformManager.cpp +++ b/filament/src/components/TransformManager.cpp @@ -173,7 +173,7 @@ void FTransformManager::insertNode(Instance i, Instance parent) noexcept { manager[i].parent = parent; manager[i].prev = 0; if (parent) { - // we insert ourself first in the parent's list + // we insert ourselves first in the parent's list Instance next = manager[parent].firstChild; manager[i].next = next; // we're our parent's first child now diff --git a/filament/src/details/Culler.h b/filament/src/details/Culler.h index 35ba1df78d..e45b730e17 100644 --- a/filament/src/details/Culler.h +++ b/filament/src/details/Culler.h @@ -49,7 +49,7 @@ public: using result_type = uint8_t; /* - * returns whether each AABB in an array intersects with the furstum + * returns whether each AABB in an array intersects with the frustum */ static void intersects(result_type* results, Frustum const& frustum, @@ -58,7 +58,7 @@ public: size_t count, size_t bit) noexcept; /* - * returns whether each shpere in an array intersects with the furstum + * returns whether each sphere in an array intersects with the frustum */ static void intersects( result_type* results, diff --git a/filament/src/details/Fence.h b/filament/src/details/Fence.h index 71eca69436..9a85076a7e 100644 --- a/filament/src/details/Fence.h +++ b/filament/src/details/Fence.h @@ -50,7 +50,7 @@ private: static std::condition_variable sCondition; struct FenceSignal { - FenceSignal(Type type) noexcept : mType(type) { } + explicit FenceSignal(Type type) noexcept : mType(type) { } enum State : uint8_t { UNSIGNALED, SIGNALED, DESTROYED }; // we store mType here instead of in FFence, because it allows sizeof(FFence) to be // much smaller (since it needs to be multiple of 8 on 64 bits architectures) diff --git a/filament/src/details/Material.h b/filament/src/details/Material.h index 4c1eb56ee0..3a6203007a 100644 --- a/filament/src/details/Material.h +++ b/filament/src/details/Material.h @@ -38,7 +38,6 @@ namespace filament { namespace details { class FEngine; -struct ShaderGenerator; class FMaterial : public Material { public: @@ -101,7 +100,7 @@ public: return mRasterState.depthFunc != Driver::RasterState::DepthFunc::A; } bool isDoubleSided() const noexcept { return mDoubleSided; } - float getMaskThreshold() const noexcept { return mMaskTreshold; } + float getMaskThreshold() const noexcept { return mMaskThreshold; } bool hasShadowMultiplier() const noexcept { return mHasShadowMultiplier; } AttributeBitset getRequiredAttributes() const noexcept { return mRequiredAttributes; } @@ -126,7 +125,7 @@ private: AttributeBitset mRequiredAttributes; bool mDoubleSided; CullingMode mCullingMode; - float mMaskTreshold; + float mMaskThreshold; bool mHasShadowMultiplier = false; bool mHasCustomDepthShader = false; bool mIsDefaultMaterial = false; diff --git a/filament/src/details/ResourceList.h b/filament/src/details/ResourceList.h index b4c1d6a427..7aa4e129e6 100644 --- a/filament/src/details/ResourceList.h +++ b/filament/src/details/ResourceList.h @@ -32,7 +32,7 @@ namespace details { class ResourceListBase { public: UTILS_NOINLINE - ResourceListBase(const char* typeName) + explicit ResourceListBase(const char* typeName) #ifndef NDEBUG : mTypeName(typeName) #endif diff --git a/filament/src/details/Scene.h b/filament/src/details/Scene.h index d1b4bc1069..5d336c68a4 100644 --- a/filament/src/details/Scene.h +++ b/filament/src/details/Scene.h @@ -80,7 +80,7 @@ public: ~FScene() noexcept; void terminate(FEngine& engine); - void prepare(const math::mat4f& worldOriginTansform); + void prepare(const math::mat4f& worldOriginTransform); void prepareDynamicLights(const CameraInfo& camera, ArenaScope& arena, Handle lightUbh) noexcept; void computeBounds(Aabb& castersBox, Aabb& receiversBox, uint32_t visibleLayers) const noexcept; @@ -128,13 +128,13 @@ public: static inline uint32_t getPrimitiveCount(RenderableSoa const& soa, uint32_t first, uint32_t last) noexcept { - // the caller must guarantee that last is dereferencable + // the caller must guarantee that last is dereferenceable return soa.elementAt(last) - soa.elementAt(first); } static inline uint32_t getPrimitiveCount(RenderableSoa const& soa, uint32_t last) noexcept { - // the caller must guarantee that last is dereferencable + // the caller must guarantee that last is dereferenceable return soa.elementAt(last); } diff --git a/filament/src/details/View.h b/filament/src/details/View.h index 6ddaa87b14..1c011e59fc 100644 --- a/filament/src/details/View.h +++ b/filament/src/details/View.h @@ -51,7 +51,6 @@ class FEngine; class FMaterialInstance; class FRenderer; class FScene; -class Froxelizer; class FView : public View { public: @@ -134,7 +133,7 @@ public: void updatePrimitivesLod( FEngine& engine, const CameraInfo& camera, - FScene::RenderableSoa& renderableData, Range visibles) noexcept; + FScene::RenderableSoa& renderableData, Range visible) noexcept; static void cullRenderables(utils::JobSystem& js, FScene::RenderableSoa& renderableData, Frustum const& frustum, size_t bit) noexcept; diff --git a/filament/src/driver/CommandBufferQueue.cpp b/filament/src/driver/CommandBufferQueue.cpp index 236db44da4..b3b1e16fea 100644 --- a/filament/src/driver/CommandBufferQueue.cpp +++ b/filament/src/driver/CommandBufferQueue.cpp @@ -35,7 +35,7 @@ CommandBufferQueue::CommandBufferQueue(size_t requiredSize, size_t bufferSize) } CommandBufferQueue::~CommandBufferQueue() { - assert(!mCommandBuffersToExecute.size()); + assert(mCommandBuffersToExecute.empty()); } void CommandBufferQueue::requestExit() { diff --git a/filament/src/driver/CommandBufferQueue.h b/filament/src/driver/CommandBufferQueue.h index 8894c9b392..092d927890 100644 --- a/filament/src/driver/CommandBufferQueue.h +++ b/filament/src/driver/CommandBufferQueue.h @@ -70,7 +70,7 @@ public: // call blocks until the CircularBuffer has at least mRequiredSize bytes available. void flush() noexcept; - // returns from waitForcommands() immediately. + // returns from waitForCommands() immediately. void requestExit(); }; diff --git a/filament/src/driver/CommandStream.cpp b/filament/src/driver/CommandStream.cpp index c38bcc4c42..f92cce3eb2 100644 --- a/filament/src/driver/CommandStream.cpp +++ b/filament/src/driver/CommandStream.cpp @@ -73,7 +73,6 @@ void CommandStream::execute(void* buffer) { Driver& UTILS_RESTRICT driver = *mDriver; CommandBase* UTILS_RESTRICT base = static_cast(buffer); - UTILS_ALIGN_LOOP while (UTILS_LIKELY(base)) { base = base->execute(driver); } @@ -96,7 +95,7 @@ void CommandStream::execute(void* buffer) { } void CommandStream::queueCommand(std::function command) { - new(allocateCommand(CustomCommand::align(sizeof(CustomCommand)))) CustomCommand(command); + new(allocateCommand(CustomCommand::align(sizeof(CustomCommand)))) CustomCommand(std::move(command)); } template @@ -119,7 +118,7 @@ void CommandType::Command::log() noexcept { } /* - * When DEBUG_COMMAND_STREAM is activated, we need to explicitely instantiate the log() method + * When DEBUG_COMMAND_STREAM is activated, we need to explicitly instantiate the log() method * (this is because we don't want it in the header file) */ diff --git a/filament/src/driver/CommandStream.h b/filament/src/driver/CommandStream.h index 1479e3ea7d..7ff08105c6 100644 --- a/filament/src/driver/CommandStream.h +++ b/filament/src/driver/CommandStream.h @@ -1,3 +1,5 @@ +#include + /* * Copyright (C) 2018 The Android Open Source Project * @@ -141,7 +143,7 @@ struct CommandType { } // A command can be moved - inline Command(Command&& rhs) = default; + inline Command(Command&& rhs) noexcept = default; template inline explicit constexpr Command(Execute execute, A&& ... args) @@ -160,11 +162,11 @@ struct CommandType { class CustomCommand : public CommandBase { std::function mCommand; - static void execute(Driver&, CommandBase* self, intptr_t* next) noexcept; + static void execute(Driver&, CommandBase* base, intptr_t* next) noexcept; public: inline CustomCommand(CustomCommand&& rhs) = default; - inline CustomCommand(const std::function& cmd) - : CommandBase(execute), mCommand(cmd) { } + inline explicit CustomCommand(std::function cmd) + : CommandBase(execute), mCommand(std::move(cmd)) { } }; // ------------------------------------------------------------------------------------------------ @@ -185,7 +187,7 @@ template class ConcreteDispatcher final : public Dispatcher { public: // initialize the dispatch table - ConcreteDispatcher(ConcreteDriver* driver) noexcept : Dispatcher() { + explicit ConcreteDispatcher(ConcreteDriver* driver) noexcept : Dispatcher() { #define DECL_DRIVER_API_SYNCHRONOUS(RetType, methodName, paramsDecl, params) #define DECL_DRIVER_API(methodName, paramsDecl, params) methodName##_ = methodName; #define DECL_DRIVER_API_RETURN(RetType, methodName, paramsDecl, params) methodName##_ = methodName; diff --git a/filament/src/driver/Driver.cpp b/filament/src/driver/Driver.cpp index 325654bc16..fbda76cc02 100644 --- a/filament/src/driver/Driver.cpp +++ b/filament/src/driver/Driver.cpp @@ -60,7 +60,7 @@ void DriverBase::scheduleDestroySlow(BufferDescriptor&& buffer) noexcept { // ------------------------------------------------------------------------------------------------ /* - * This array contains informations we might need about each texture internal formats. + * This array contains information we might need about each texture internal formats. * * All entries MUST be sorted by Driver::TextureFormat. */ diff --git a/filament/src/driver/Driver.h b/filament/src/driver/Driver.h index c5a16ca346..fcc82b5dbf 100644 --- a/filament/src/driver/Driver.h +++ b/filament/src/driver/Driver.h @@ -209,7 +209,8 @@ public: static size_t getElementTypeSize(ElementType type) noexcept; // This is here to be compatible with CommandStream (nice for debugging) - inline void queueCommand(const std::function& command) { + template + inline void queueCommand(CALLABLE command) { command(); } diff --git a/filament/src/driver/DriverBase.h b/filament/src/driver/DriverBase.h index 02d93a4ed3..4f45472cd6 100644 --- a/filament/src/driver/DriverBase.h +++ b/filament/src/driver/DriverBase.h @@ -1,3 +1,5 @@ +#include + /* * Copyright (C) 2015 The Android Open Source Project * @@ -82,7 +84,7 @@ struct HwRenderPrimitive : public HwBase { struct HwProgram : public HwBase { #ifndef NDEBUG - explicit HwProgram(const utils::CString& name) noexcept : name(name) { } + explicit HwProgram(utils::CString name) noexcept : name(std::move(name)) { } utils::CString name; #else explicit HwProgram(const utils::CString&) noexcept { } diff --git a/filament/src/driver/Handle.h b/filament/src/driver/Handle.h index 1904d0fb18..b0907bafb0 100644 --- a/filament/src/driver/Handle.h +++ b/filament/src/driver/Handle.h @@ -28,7 +28,6 @@ namespace filament { -struct HwBase; struct HwVertexBuffer; struct HwFence; struct HwIndexBuffer; diff --git a/filament/src/driver/SamplerBuffer.h b/filament/src/driver/SamplerBuffer.h index 73b76e4712..872232c922 100644 --- a/filament/src/driver/SamplerBuffer.h +++ b/filament/src/driver/SamplerBuffer.h @@ -46,7 +46,7 @@ public: SamplerParams s; }; - SamplerBuffer() noexcept { } + SamplerBuffer() noexcept { } // NOLINT(modernize-use-equals-default) // create a sampler buffer explicit SamplerBuffer(size_t count) noexcept; diff --git a/filament/src/driver/android/VirtualMachineEnv.h b/filament/src/driver/android/VirtualMachineEnv.h index 46b225d60d..7871813bff 100644 --- a/filament/src/driver/android/VirtualMachineEnv.h +++ b/filament/src/driver/android/VirtualMachineEnv.h @@ -67,7 +67,7 @@ public: return env; } - static void handleException(JNIEnv* const env) noexcept; + static void handleException(JNIEnv* env) noexcept; private: JNIEnv* getEnvironmentSlow() noexcept; diff --git a/filament/src/driver/noop/NoopDriver.h b/filament/src/driver/noop/NoopDriver.h index dc07be068a..b46edd2a91 100644 --- a/filament/src/driver/noop/NoopDriver.h +++ b/filament/src/driver/noop/NoopDriver.h @@ -26,13 +26,13 @@ namespace filament { class NoopDriver final : public DriverBase { NoopDriver() noexcept; - virtual ~NoopDriver() noexcept; + ~NoopDriver() noexcept override; public: static Driver* create(); private: - virtual ShaderModel getShaderModel() const noexcept override final { return ShaderModel::UNKNOWN; } + ShaderModel getShaderModel() const noexcept final { return ShaderModel::UNKNOWN; } /* * Driver interface diff --git a/filament/src/driver/opengl/NullGLES.h b/filament/src/driver/opengl/NullGLES.h index ad6de7a87d..c731825877 100644 --- a/filament/src/driver/opengl/NullGLES.h +++ b/filament/src/driver/opengl/NullGLES.h @@ -74,7 +74,7 @@ inline void glDrawRangeElements(GLenum, GLuint, GLuint, GLsizei, GLenum, const v inline void glBlitFramebuffer (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) { } inline void glReadPixels (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *) { } -inline GLenum glGetError(void) { return GL_NO_ERROR; } +inline GLenum glGetError() { return GL_NO_ERROR; } } // namespace nullgles diff --git a/filament/src/driver/opengl/OpenGLBlitter.h b/filament/src/driver/opengl/OpenGLBlitter.h index 1b460aa303..50720996bf 100644 --- a/filament/src/driver/opengl/OpenGLBlitter.h +++ b/filament/src/driver/opengl/OpenGLBlitter.h @@ -26,7 +26,7 @@ class OpenGLDriver; class OpenGLBlitter { public: - OpenGLBlitter(OpenGLDriver& openGLDriver) noexcept : mOpenGLDriver(openGLDriver) {} + explicit OpenGLBlitter(OpenGLDriver& openGLDriver) noexcept : mOpenGLDriver(openGLDriver) {} void init() noexcept; void terminate() noexcept; diff --git a/filament/src/driver/opengl/OpenGLDriver.cpp b/filament/src/driver/opengl/OpenGLDriver.cpp index 3254dc0ded..c5fbffc899 100644 --- a/filament/src/driver/opengl/OpenGLDriver.cpp +++ b/filament/src/driver/opengl/OpenGLDriver.cpp @@ -1221,8 +1221,8 @@ void OpenGLDriver::createStreamFromTextureId(Driver::StreamHandle sh, s->gl.externalTextureId = static_cast(externalTextureId); glGenTextures(GLStream::ROUND_ROBIN_TEXTURE_COUNT, s->user_thread.read); glGenTextures(GLStream::ROUND_ROBIN_TEXTURE_COUNT, s->user_thread.write); - for (size_t i = 0; i < GLStream::ROUND_ROBIN_TEXTURE_COUNT; i++) { - s->user_thread.infos[i].ets = mPlatform.createExternalTextureStorage(); + for (auto& info : s->user_thread.infos) { + info.ets = mPlatform.createExternalTextureStorage(); } } @@ -1677,7 +1677,7 @@ void OpenGLDriver::updateSamplerBuffer(Driver::SamplerBufferHandle sbh, DEBUG_MARKER() GLSamplerBuffer* sb = handle_cast(sbh); - *sb->sb = std::move(samplerBuffer); + *sb->sb = std::move(samplerBuffer); // NOLINT(performance-move-const-arg) } void OpenGLDriver::update2DImage(Driver::TextureHandle th, @@ -1984,7 +1984,7 @@ void OpenGLDriver::beginRenderPass(Driver::RenderTargetHandle rth, // glInvalidateFramebuffer appeared on GLES 3.0 and GL4.3, for simplicity we just // ignore it on GL (rather than having to do a runtime check). if (GLES31_HEADERS && !bugs.disable_invalidate_framebuffer) { - std::array attachments; + std::array attachments; // NOLINT(cppcoreguidelines-pro-type-member-init) GLsizei attachmentCount = getAttachments(attachments, rt, discardFlags); if (attachmentCount) { #if DEBUG_MARKER_LEVEL == DEBUG_MARKER_SYSTRACE @@ -2035,7 +2035,7 @@ void OpenGLDriver::endRenderPass(int) { GLRenderTarget* rt = handle_cast(mRenderPassTarget); bindFramebuffer(GL_FRAMEBUFFER, rt->gl.fbo); - std::array attachments; + std::array attachments; // NOLINT(cppcoreguidelines-pro-type-member-init) GLsizei attachmentCount = getAttachments(attachments, rt, discardFlags); if (attachmentCount) { #if DEBUG_MARKER_LEVEL == DEBUG_MARKER_SYSTRACE @@ -2067,7 +2067,7 @@ void OpenGLDriver::discardSubRenderTargetBuffers(Driver::RenderTargetHandle rth, if (left < right && bottom < top) { bindFramebuffer(GL_FRAMEBUFFER, rt->gl.fbo); - std::array attachments; + std::array attachments; // NOLINT(cppcoreguidelines-pro-type-member-init) GLsizei attachmentCount = getAttachments(attachments, rt, buffers); if (attachmentCount) { glInvalidateSubFramebuffer(GL_FRAMEBUFFER, attachmentCount, attachments.data(), diff --git a/filament/src/driver/opengl/OpenGLProgram.cpp b/filament/src/driver/opengl/OpenGLProgram.cpp index c35e715b1b..4b824ecedf 100644 --- a/filament/src/driver/opengl/OpenGLProgram.cpp +++ b/filament/src/driver/opengl/OpenGLProgram.cpp @@ -136,7 +136,8 @@ OpenGLProgram::OpenGLProgram(OpenGLDriver* gl, const Program& programBuilder) no // build unique name for this uniform (sampler) auto const& e = infos[j]; std::string e_name(e.name.c_str()); - std::string uniformSamplerName(sib_name + "_" + e_name); + std::string uniformSamplerName(sib_name); + uniformSamplerName.append("_").append(e_name); // find its location and associate a TMU to it GLint loc = glGetUniformLocation(program, uniformSamplerName.c_str()); @@ -219,7 +220,7 @@ void OpenGLProgram::updateSamplers(OpenGLDriver* gl) noexcept { if (UTILS_UNLIKELY(t->gl.fence)) { glWaitSync(t->gl.fence, 0, GL_TIMEOUT_IGNORED); glDeleteSync(t->gl.fence); - t->gl.fence = 0; + t->gl.fence = nullptr; } gl->bindTexture(tmu, t->gl.target, t, t->gl.targetIndex); diff --git a/filament/src/driver/opengl/PlatformCocoaGL.h b/filament/src/driver/opengl/PlatformCocoaGL.h index 5ce8fb311e..ff91536ea1 100644 --- a/filament/src/driver/opengl/PlatformCocoaGL.h +++ b/filament/src/driver/opengl/PlatformCocoaGL.h @@ -45,7 +45,7 @@ public: return driver::FenceStatus::ERROR; } - void setPresentationTime(int64_t presentationTimeInNanosecond) noexcept final override {} + void setPresentationTime(int64_t presentationTimeInNanosecond) noexcept final {} Stream* createStream(void* nativeStream) noexcept final { return nullptr; } void destroyStream(Stream* stream) noexcept final {} diff --git a/filament/src/driver/vulkan/VulkanBinder.cpp b/filament/src/driver/vulkan/VulkanBinder.cpp index 8c63abdfc2..f428a4b63d 100644 --- a/filament/src/driver/vulkan/VulkanBinder.cpp +++ b/filament/src/driver/vulkan/VulkanBinder.cpp @@ -383,9 +383,9 @@ void VulkanBinder::unbindUniformBuffer(VkBuffer uniformBuffer) noexcept { } void VulkanBinder::unbindImageView(VkImageView imageView) noexcept { - for (uint32_t bindingIndex = 0u; bindingIndex < NUM_SAMPLER_BINDINGS; ++bindingIndex) { - if (mDescriptorKey.samplers[bindingIndex].imageView == imageView) { - mDescriptorKey.samplers[bindingIndex] = { + for (auto& sampler : mDescriptorKey.samplers) { + if (sampler.imageView == imageView) { + sampler = { .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }; mDirtyDescriptor = true; diff --git a/filament/src/driver/vulkan/VulkanBinder.h b/filament/src/driver/vulkan/VulkanBinder.h index caf0cb9780..05a0769931 100644 --- a/filament/src/driver/vulkan/VulkanBinder.h +++ b/filament/src/driver/vulkan/VulkanBinder.h @@ -261,7 +261,7 @@ private: PipelineVal* mCurrentPipeline = nullptr; DescriptorVal* mCurrentDescriptor = nullptr; - // If one of these dirty flags is set, then one or more its contituent bindings have changed, so + // If one of these dirty flags is set, then one or more its constituent bindings have changed, so // a new pipeline or descriptor set needs to be retrieved from the cache or created. bool mDirtyPipeline = true; bool mDirtyDescriptor = true; diff --git a/filament/src/driver/vulkan/VulkanBuffer.cpp b/filament/src/driver/vulkan/VulkanBuffer.cpp index a995e74018..80922800e3 100644 --- a/filament/src/driver/vulkan/VulkanBuffer.cpp +++ b/filament/src/driver/vulkan/VulkanBuffer.cpp @@ -32,7 +32,7 @@ VulkanBuffer::VulkanBuffer(VulkanContext& context, VulkanStagePool& stagePool, VmaAllocationCreateInfo allocInfo { .usage = VMA_MEMORY_USAGE_GPU_ONLY }; - vmaCreateBuffer(context.allocator, &bufferInfo, &allocInfo, &mGpuBuffer, &mGpuMemory, 0); + vmaCreateBuffer(context.allocator, &bufferInfo, &allocInfo, &mGpuBuffer, &mGpuMemory, nullptr); } VulkanBuffer::~VulkanBuffer() { @@ -88,7 +88,7 @@ void VulkanBuffer::loadFromCpu(const void* cpuData, uint32_t byteOffset, uint32_ vkQueueSubmit(mContext.graphicsQueue, 1, &submitInfo, fence); // Enqueue some work to reclaim the staging area and free the command buffer. The pipeline - // barrier we already placed is a GPU-to-GPU sync point, but reclaimation of the staging area + // barrier we already placed is a GPU-to-GPU sync point, but reclamation of the staging area // needs GPU-CPU synchronization. That's what the fence is for. mContext.pendingWork.emplace_back([this, fence, device, cmdbuffer, stage] (VkCommandBuffer) { vkWaitForFences(device, 1, &fence, VK_FALSE, UINT64_MAX); diff --git a/filament/src/driver/vulkan/VulkanDriver.h b/filament/src/driver/vulkan/VulkanDriver.h index dac01778bf..440eec1a5b 100644 --- a/filament/src/driver/vulkan/VulkanDriver.h +++ b/filament/src/driver/vulkan/VulkanDriver.h @@ -49,12 +49,12 @@ private: void debugCommand(const char* methodName) override; #endif - inline VulkanDriver(driver::VulkanPlatform* const platform, + inline VulkanDriver(driver::VulkanPlatform* platform, const char* const* ppEnabledExtensions, uint32_t enabledExtensionCount) noexcept; - virtual ~VulkanDriver() noexcept; + ~VulkanDriver() noexcept override; - virtual ShaderModel getShaderModel() const noexcept override final; + ShaderModel getShaderModel() const noexcept final; template friend class ::filament::ConcreteDispatcher; @@ -71,10 +71,10 @@ private: #include "driver/DriverAPI.inc" -private: VulkanDriver(VulkanDriver const&) = delete; VulkanDriver& operator = (VulkanDriver const&) = delete; +private: driver::VulkanPlatform& mContextManager; // For now we're not bothering to store handles in pools, just simple on-demand allocation. diff --git a/filament/src/driver/vulkan/VulkanDriverImpl.cpp b/filament/src/driver/vulkan/VulkanDriverImpl.cpp index d3cd735c39..ab87d43d57 100644 --- a/filament/src/driver/vulkan/VulkanDriverImpl.cpp +++ b/filament/src/driver/vulkan/VulkanDriverImpl.cpp @@ -155,7 +155,7 @@ void createVirtualDevice(VulkanContext& context) { deviceCreateInfo.queueCreateInfoCount = 1; deviceCreateInfo.pQueueCreateInfos = deviceQueueCreateInfo; deviceCreateInfo.pEnabledFeatures = nullptr; - deviceCreateInfo.enabledExtensionCount = deviceExtensionNames.size(); + deviceCreateInfo.enabledExtensionCount = (uint32_t)deviceExtensionNames.size(); deviceCreateInfo.ppEnabledExtensionNames = deviceExtensionNames.data(); VkResult result = vkCreateDevice(context.physicalDevice, &deviceCreateInfo, VKALLOC, &context.device); @@ -642,14 +642,14 @@ VkFormat getVkFormat(TextureFormat format) { } uint32_t getBytesPerPixel(TextureFormat format) { - return details::FTexture::getFormatSize(format); + return (uint32_t)details::FTexture::getFormatSize(format); } // See also FTexture::computeTextureDataSize, which takes a public-facing Texture format rather // than a driver-level Texture format, and can account for a specified byte alignment. uint32_t computeSize(TextureFormat format, uint32_t w, uint32_t h, uint32_t d) { const size_t bytesPerTexel = details::FTexture::getFormatSize(format); - return bytesPerTexel * w * h * d; + return (uint32_t)(bytesPerTexel * w * h * d); } SwapContext& getSwapContext(VulkanContext& context) { @@ -658,12 +658,12 @@ SwapContext& getSwapContext(VulkanContext& context) { } bool hasPendingWork(VulkanContext& context) { - if (context.pendingWork.size() > 0) { + if (!context.pendingWork.empty()) { return true; } if (context.currentSurface) { for (auto& swapContext : context.currentSurface->swapContexts) { - if (swapContext.pendingWork.size() > 0) { + if (!swapContext.pendingWork.empty()) { return true; } } diff --git a/filament/src/driver/vulkan/VulkanFboCache.cpp b/filament/src/driver/vulkan/VulkanFboCache.cpp index ae03348cdd..350db37590 100644 --- a/filament/src/driver/vulkan/VulkanFboCache.cpp +++ b/filament/src/driver/vulkan/VulkanFboCache.cpp @@ -52,10 +52,10 @@ VkFramebuffer VulkanFboCache::getFramebuffer(FboKey config, uint32_t w, uint32_t iter.value().timestamp = mCurrentTime; return iter->second.handle; } - uint32_t nattachments = 0; + uint32_t nAttachments = 0; for (auto attachment : config.attachments) { if (attachment) { - nattachments++; + nAttachments++; } } VkFramebufferCreateInfo info { @@ -64,7 +64,7 @@ VkFramebuffer VulkanFboCache::getFramebuffer(FboKey config, uint32_t w, uint32_t .width = w, .height = h, .layers = 1, - .attachmentCount = nattachments, + .attachmentCount = nAttachments, .pAttachments = config.attachments }; mRenderPassRefCount[info.renderPass]++; diff --git a/filament/src/driver/vulkan/VulkanHandles.cpp b/filament/src/driver/vulkan/VulkanHandles.cpp index 70fbe7e9bc..cc0c0742df 100644 --- a/filament/src/driver/vulkan/VulkanHandles.cpp +++ b/filament/src/driver/vulkan/VulkanHandles.cpp @@ -334,7 +334,7 @@ VulkanUniformBuffer::VulkanUniformBuffer(VulkanContext& context, VulkanStagePool VmaAllocationCreateInfo allocInfo { .usage = VMA_MEMORY_USAGE_GPU_ONLY }; - vmaCreateBuffer(mContext.allocator, &bufferInfo, &allocInfo, &mGpuBuffer, &mGpuMemory, 0); + vmaCreateBuffer(mContext.allocator, &bufferInfo, &allocInfo, &mGpuBuffer, &mGpuMemory, nullptr); } void VulkanUniformBuffer::loadFromCpu(const void* cpuData, uint32_t numBytes) { diff --git a/filament/src/driver/vulkan/VulkanHandles.h b/filament/src/driver/vulkan/VulkanHandles.h index df18bb7dc3..9975b2ab0f 100644 --- a/filament/src/driver/vulkan/VulkanHandles.h +++ b/filament/src/driver/vulkan/VulkanHandles.h @@ -45,7 +45,7 @@ struct VulkanTexture; // - The attachment's VkImage is shared and the owner is VulkanSwapChain. // - The attachment's VkImage is shared and the owner is VulkanTexture. // -// We use private inheritence to shield clients from the width / height fields in HwRenderTarget, +// We use private inheritance to shield clients from the width / height fields in HwRenderTarget, // which are not representative when this is the default render target. struct VulkanRenderTarget : private HwRenderTarget { @@ -54,7 +54,7 @@ struct VulkanRenderTarget : private HwRenderTarget { mContext(context), mOffscreen(true) {} // Creates a special "default" render target (i.e. associated with the swap chain) - VulkanRenderTarget(VulkanContext& context) : HwRenderTarget(0, 0), mContext(context), + explicit VulkanRenderTarget(VulkanContext& context) : HwRenderTarget(0, 0), mContext(context), mOffscreen(false) {} ~VulkanRenderTarget(); @@ -139,7 +139,7 @@ private: }; struct VulkanRenderPrimitive : public HwRenderPrimitive { - VulkanRenderPrimitive(VulkanContext& context) {} + explicit VulkanRenderPrimitive(VulkanContext& context) {} void setPrimitiveType(Driver::PrimitiveType pt); void setBuffers(VulkanVertexBuffer* vertexBuffer, VulkanIndexBuffer* indexBuffer, uint32_t enabledAttributes); diff --git a/filament/src/driver/vulkan/VulkanStagePool.cpp b/filament/src/driver/vulkan/VulkanStagePool.cpp index c626e9ee03..f78213df74 100644 --- a/filament/src/driver/vulkan/VulkanStagePool.cpp +++ b/filament/src/driver/vulkan/VulkanStagePool.cpp @@ -47,7 +47,7 @@ VulkanStage const* VulkanStagePool::acquireStage(uint32_t numBytes) noexcept { VmaAllocationCreateInfo allocInfo { .usage = VMA_MEMORY_USAGE_CPU_ONLY }; - vmaCreateBuffer(mContext.allocator, &bufferInfo, &allocInfo, &stage->buffer, &stage->memory, 0); + vmaCreateBuffer(mContext.allocator, &bufferInfo, &allocInfo, &stage->buffer, &stage->memory, nullptr); return stage; } diff --git a/filament/test/depth_test.cpp b/filament/test/depth_test.cpp index adf4d9d474..209158ac62 100644 --- a/filament/test/depth_test.cpp +++ b/filament/test/depth_test.cpp @@ -97,7 +97,7 @@ void depthBufferPrecision(Projection proj, float nearVal, float farVal) { } } -int main(void) { +int main() { static constexpr float inf = std::numeric_limits::infinity(); const float near = 0.1f; diff --git a/filament/test/filament_benchmark.cpp b/filament/test/filament_benchmark.cpp index 53200d4fbc..c1ebe3a8f3 100644 --- a/filament/test/filament_benchmark.cpp +++ b/filament/test/filament_benchmark.cpp @@ -64,7 +64,7 @@ void benchmark(Profiler& p, const char* const name, T f) { // ------------------------------------------------------------------------------------------------ -int main(void) { +int main() { std::mt19937 gen; std::uniform_real_distribution rand(-100.0f, 100.0f); diff --git a/filament/test/filament_calls.cpp b/filament/test/filament_calls.cpp index 0cd9668648..b59769d843 100644 --- a/filament/test/filament_calls.cpp +++ b/filament/test/filament_calls.cpp @@ -86,7 +86,7 @@ void foo(void*) noexcept { __asm__ __volatile__( "" : : : "memory" ); } -int main(void) { +int main() { filament::details::EnginePerformanceTest* engine = new filament::details::EnginePerformanceTest(); filament::details::EnginePerformanceTest* ei = engine; filament::details::EnginePerformanceTest::PFN destroyUniverse = engine->getDestroyUniverseApi(); diff --git a/filament/test/filament_test.cpp b/filament/test/filament_test.cpp index 58eda0ee05..44734315d8 100644 --- a/filament/test/filament_test.cpp +++ b/filament/test/filament_test.cpp @@ -98,7 +98,7 @@ TEST(FilamentTest, TransformManager) { tcm.openLocalTransformTransaction(); tcm.setTransform(parent, mat4f{ float4{ 4 }}); - // check the transfroms ARE NOT propagated + // check the transforms ARE NOT propagated EXPECT_EQ(tcm.getTransform(parent), mat4f{ float4{ 4 }}); EXPECT_EQ(tcm.getWorldTransform(parent), mat4f{ float4{ 2 }}); EXPECT_EQ(tcm.getTransform(child), mat4f{ float4{ 1 }}); @@ -126,7 +126,7 @@ TEST(FilamentTest, TransformManager) { // make sure child/parent are out of order ASSERT_LT(child, newParent); - // local transaction reprders parent/child + // local transaction reorders parent/child tcm.openLocalTransformTransaction(); tcm.setTransform(newParent, mat4f{ float4{ 8 }}); tcm.commitLocalTransformTransaction(); diff --git a/libs/utils/include/utils/JobSystem.h b/libs/utils/include/utils/JobSystem.h index 85027ca72b..57be46ed05 100644 --- a/libs/utils/include/utils/JobSystem.h +++ b/libs/utils/include/utils/JobSystem.h @@ -57,14 +57,15 @@ public: // Size is chosen so that we can store at least std::function<> // the alignas() qualifier ensures we're multiple of a cache-line. - static constexpr size_t JOB_STORAGE_SIZE = // NOLINT(cert-err58-cpp) - (std::max(sizeof(std::function), size_t(48)) + sizeof(void*) - 1) - / sizeof(void*); + static constexpr size_t JOB_STORAGE_SIZE_BYTES = + sizeof(std::function) > 48 ? sizeof(std::function) : 48; + static constexpr size_t JOB_STORAGE_SIZE_WORDS = + (JOB_STORAGE_SIZE_BYTES + sizeof(void*) - 1) / sizeof(void*); // keep it first, so it's correctly aligned with all architectures // this is were we store the job's data, typically a std::function<> // v7 | v8 - void* storage[JOB_STORAGE_SIZE]; // 48 | 48 + void* storage[JOB_STORAGE_SIZE_WORDS]; // 48 | 48 JobFunc function; // 4 | 8 uint16_t parent; // 2 | 2 std::atomic runningJobCount = { 1 }; // 2 | 2 @@ -362,7 +363,7 @@ private: alignas(16) // at least we align to half (or quarter) cache-line aligned_vector mThreadStates; // actual data is stored offline - std::atomic mExitRequested = { 0 }; // this one is almost never written + std::atomic mExitRequested = { false }; // this one is almost never written std::atomic mAdoptedThreads = { 0 }; // this one is almost never written Job* const mJobStorageBase; // Base for conversion to indices uint16_t mThreadCount = 0; // total # of threads in the pool diff --git a/libs/utils/include/utils/Log.h b/libs/utils/include/utils/Log.h index b670454ee4..673ba6b244 100644 --- a/libs/utils/include/utils/Log.h +++ b/libs/utils/include/utils/Log.h @@ -51,7 +51,7 @@ public: DEBUG, ERROR, WARNING, INFO }; - ostream(Priority p) noexcept : mPriority(p) { } + explicit ostream(Priority p) noexcept : mPriority(p) { } ostream& operator<<(short value) noexcept; ostream& operator<<(unsigned short value) noexcept; diff --git a/libs/utils/include/utils/Panic.h b/libs/utils/include/utils/Panic.h index 890480aba3..a205b1402c 100644 --- a/libs/utils/include/utils/Panic.h +++ b/libs/utils/include/utils/Panic.h @@ -302,14 +302,14 @@ template class TPanic : public Panic { public: // std::exception protocol - virtual const char* what() const noexcept; + const char* what() const noexcept override; // Panic interface - virtual const char* getFunction() const noexcept; - virtual const char* getFile() const noexcept; - virtual int getLine() const noexcept; - virtual const CallStack& getCallStack() const noexcept; - virtual void log() const noexcept; + const char* getFunction() const noexcept override; + const char* getFile() const noexcept override; + int getLine() const noexcept override; + const CallStack& getCallStack() const noexcept override; + void log() const noexcept override; /** * Depending on the mode set, either throws an exception of type T with the given reason plus @@ -348,7 +348,7 @@ protected: * Creates a Panic. * @param reason a description of the cause of the error */ - explicit TPanic(const std::string& reason); + explicit TPanic(std::string reason); /** * Creates a Panic with extra information about the error-site. @@ -357,9 +357,9 @@ protected: * @param line the line in the above file where the error was detected * @param reason a description of the cause of the error */ - TPanic(char const* function, char const* file, int line, const std::string& reason); + TPanic(char const* function, char const* file, int line, std::string reason); - virtual ~TPanic(); + ~TPanic() override; private: void buildMessage(); diff --git a/libs/utils/include/utils/compiler.h b/libs/utils/include/utils/compiler.h index 26d545fff5..fcb5039578 100644 --- a/libs/utils/include/utils/compiler.h +++ b/libs/utils/include/utils/compiler.h @@ -109,13 +109,6 @@ #define UTILS_RESTRICT __restrict__ -// TODO: set the proper alignment for the target -#ifndef __EMSCRIPTEN__ -#define UTILS_ALIGN_LOOP {__asm__ __volatile__(".align 4");} -#else -#define UTILS_ALIGN_LOOP -#endif - #if __has_feature(cxx_thread_local) # ifdef ANDROID # // Android NDK lies about supporting cxx_thread_local diff --git a/libs/utils/src/Allocator.cpp b/libs/utils/src/Allocator.cpp index 8752eb411d..57f2a0a0ac 100644 --- a/libs/utils/src/Allocator.cpp +++ b/libs/utils/src/Allocator.cpp @@ -94,7 +94,10 @@ FreeList::FreeList(void* begin, void* end, AtomicFreeList::AtomicFreeList(void* begin, void* end, size_t elementSize, size_t alignment, size_t extra) noexcept { +#ifdef ANDROID + // on some platform (e.g. web) this returns false. we really only care about mobile though. assert(mHead.is_lock_free()); +#endif void* const p = pointermath::align(begin, alignment, extra); void* const n = pointermath::align(pointermath::add(p, elementSize), alignment, extra); diff --git a/libs/utils/src/Panic.cpp b/libs/utils/src/Panic.cpp index 359dac9cb7..f2e009a058 100644 --- a/libs/utils/src/Panic.cpp +++ b/libs/utils/src/Panic.cpp @@ -50,7 +50,8 @@ static std::string formatString(const char* format, ...) noexcept { return s; } -static std::string panicString(std::string msg, const char* function, int line, +static std::string panicString( + const std::string& msg, const char* function, int line, const char* file, const char* reason) { #ifndef NDEBUG return formatString("%s\nin %s:%d\nin file %s\nreason: %s", @@ -64,16 +65,15 @@ static std::string panicString(std::string msg, const char* function, int line, Panic::~Panic() noexcept = default; template -TPanic::TPanic(const std::string& reason) : - m_reason(reason) { +TPanic::TPanic(std::string reason) : + m_reason(std::move(reason)) { m_callstack.update(1); buildMessage(); } template -TPanic::TPanic( - const char* function, const char* file, int line, const std::string& reason) : - m_reason(reason), m_function(function), m_file(file), m_line(line) { +TPanic::TPanic(const char* function, const char* file, int line, std::string reason) + : m_reason(std::move(reason)), m_function(function), m_file(file), m_line(line) { m_callstack.update(1); buildMessage(); } diff --git a/libs/utils/src/Path.cpp b/libs/utils/src/Path.cpp index dae405070c..69fe2ea2b5 100644 --- a/libs/utils/src/Path.cpp +++ b/libs/utils/src/Path.cpp @@ -154,7 +154,7 @@ std::string Path::getExtension() const { } auto name = getName(); - auto index = name.rfind("."); + auto index = name.rfind('.'); if (index != std::string::npos && index != 0) { return name.substr(index + 1); } else { @@ -164,7 +164,7 @@ std::string Path::getExtension() const { std::string Path::getNameWithoutExtension() const { std::string name = getName(); - size_t index = name.rfind("."); + size_t index = name.rfind('.'); if (index != std::string::npos) { return name.substr(0, index); } @@ -199,7 +199,7 @@ std::vector Path::split() const { if (!segment.empty()) segments.push_back(segment); } while (next != std::string::npos); - if (segments.size() == 0) segments.push_back(m_path); + if (segments.empty()) segments.push_back(m_path); return segments; } @@ -227,17 +227,17 @@ std::string Path::getCanonicalPath(const std::string& path) { size_t size = segment.length(); // skip empty (keedp initial) - if (size == 0 && segments.size() > 0) { + if (size == 0 && !segments.empty()) { continue; } // skip . (keep initial) - if (segment == "." && segments.size() > 0) { + if (segment == "." && !segments.empty()) { continue; } // remove .. - if (segment == ".." && segments.size() > 0) { + if (segment == ".." && !segments.empty()) { if (segments.back().empty()) { // ignore if .. follows initial / continue; } diff --git a/libs/utils/src/linux/futex.cpp b/libs/utils/src/linux/futex.cpp index 7b5859faba..39a8436246 100644 --- a/libs/utils/src/linux/futex.cpp +++ b/libs/utils/src/linux/futex.cpp @@ -35,11 +35,11 @@ static inline int futex(volatile void* ftx, int op, int value, } int futex_wake(volatile void* ftx, int count) { - return futex(ftx, FUTEX_WAKE, count, NULL, 0); + return futex(ftx, FUTEX_WAKE, count, nullptr, 0); } int futex_wake_ex(volatile void* ftx, bool shared, int count) { - return futex(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, NULL, 0); + return futex(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, nullptr, 0); } int futex_wait(volatile void* ftx, int value, const struct timespec* timeout) { return futex(ftx, FUTEX_WAIT, value, timeout, 0); diff --git a/libs/utils/test/test_Allocators.cpp b/libs/utils/test/test_Allocators.cpp index 662ebe27f0..5f15694f80 100644 --- a/libs/utils/test/test_Allocators.cpp +++ b/libs/utils/test/test_Allocators.cpp @@ -14,10 +14,11 @@ * limitations under the License. */ -#include #include -#include #include +#include +#include +#include #include @@ -213,7 +214,7 @@ TEST(AllocatorTest, ScopedStackArena) { void* p = nullptr; struct Foo { - Foo(std::function f) : dtor(f) { } + explicit Foo(std::function f) : dtor(std::move(std::move(f))) { } ~Foo() { dtor(); } private: std::function dtor; diff --git a/libs/utils/test/test_BinaryTreeArray.cpp b/libs/utils/test/test_BinaryTreeArray.cpp index e570063db1..4955449196 100644 --- a/libs/utils/test/test_BinaryTreeArray.cpp +++ b/libs/utils/test/test_BinaryTreeArray.cpp @@ -26,7 +26,7 @@ TEST(BinaryTreeArray, basic) { struct Node { size_t index = 0; size_t next = 0; - bool visited = 0; + bool visited = false; }; Node array[256]; diff --git a/tools/filamesh/src/main.cpp b/tools/filamesh/src/main.cpp index 939c51aaae..39b1e0bdd5 100644 --- a/tools/filamesh/src/main.cpp +++ b/tools/filamesh/src/main.cpp @@ -353,7 +353,7 @@ int main(int argc, char* argv[]) { } const bool hasIndex16 = g_vertexCount < std::numeric_limits::max(); - const bool hasUV1 = g_uv1.size() > 0; + const bool hasUV1 = !g_uv1.empty(); Box aabb = meshes.at(0).aabb; for (size_t i = 1; i < meshes.size(); i++) {