Browse Source

Merge pull request #110 from godlikepanos/move_operator

Move operator
Panagiotis Christopoulos Charitos 3 years ago
parent
commit
8698684303

+ 3 - 3
AnKi/Gr/RenderGraph.cpp

@@ -478,7 +478,7 @@ FramebufferPtr RenderGraph::getOrCreateFramebuffer(const FramebufferDescription&
 										 TextureSubresourceInfo(inAtt.m_surface), "RenderGraph");
 			TextureViewPtr view = getManager().newTextureView(viewInit);
 
-			outAtt.m_textureView = view;
+			outAtt.m_textureView = std::move(view);
 		}
 
 		if(!!fbDescr.m_depthStencilAttachment.m_aspect)
@@ -497,7 +497,7 @@ FramebufferPtr RenderGraph::getOrCreateFramebuffer(const FramebufferDescription&
 										 TextureSubresourceInfo(inAtt.m_surface, inAtt.m_aspect), "RenderGraph");
 			TextureViewPtr view = getManager().newTextureView(viewInit);
 
-			outAtt.m_textureView = view;
+			outAtt.m_textureView = std::move(view);
 		}
 
 		if(fbDescr.m_shadingRateAttachmentTexelWidth > 0)
@@ -508,7 +508,7 @@ FramebufferPtr RenderGraph::getOrCreateFramebuffer(const FramebufferDescription&
 
 			fbInit.m_shadingRateImage.m_texelWidth = fbDescr.m_shadingRateAttachmentTexelWidth;
 			fbInit.m_shadingRateImage.m_texelHeight = fbDescr.m_shadingRateAttachmentTexelHeight;
-			fbInit.m_shadingRateImage.m_textureView = view;
+			fbInit.m_shadingRateImage.m_textureView = std::move(view);
 		}
 
 		// Set FB name

+ 2 - 2
AnKi/Gr/RenderGraph.inl.h

@@ -314,7 +314,7 @@ inline BufferHandle RenderGraphDescription::importBuffer(BufferPtr buff, BufferU
 	Buffer& b = *m_buffers.emplaceBack(m_alloc);
 	b.setName(buff->getName());
 	b.m_usage = usage;
-	b.m_importedBuff = buff;
+	b.m_importedBuff = std::move(buff);
 	b.m_offset = offset;
 	b.m_range = range;
 
@@ -333,7 +333,7 @@ RenderGraphDescription::importAccelerationStructure(AccelerationStructurePtr as,
 
 	AS& a = *m_as.emplaceBack(m_alloc);
 	a.setName(as->getName());
-	a.m_importedAs = as;
+	a.m_importedAs = std::move(as);
 	a.m_usage = usage;
 
 	AccelerationStructureHandle handle;

+ 1 - 1
AnKi/Gr/Vulkan/FenceFactory.h

@@ -98,7 +98,7 @@ public:
 	void init(GrAllocator<U8> alloc, VkDevice dev)
 	{
 		ANKI_ASSERT(dev);
-		m_alloc = alloc;
+		m_alloc = std::move(alloc);
 		m_dev = dev;
 	}
 

+ 1 - 1
AnKi/Gr/Vulkan/FrameGarbageCollector.cpp

@@ -123,7 +123,7 @@ void FrameGarbageCollector::setNewFrame(MicroFencePtr frameFence)
 	if(!m_frames.isEmpty() && !m_frames.getBack().m_fence.isCreated())
 	{
 		// Last frame is without a fence, asign the fence to not not have it garbage collected
-		m_frames.getBack().m_fence = frameFence;
+		m_frames.getBack().m_fence = std::move(frameFence);
 	}
 
 	collectGarbage();

+ 4 - 4
AnKi/Physics/PhysicsJoint.cpp

@@ -28,7 +28,7 @@ void PhysicsJoint::unregisterFromWorld()
 PhysicsPoint2PointJoint::PhysicsPoint2PointJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, const Vec3& relPos)
 	: PhysicsJoint(world, JointType::kP2P)
 {
-	m_bodyA = bodyA;
+	m_bodyA = std::move(bodyA);
 	m_p2p.init(*m_bodyA->getBtBody(), toBt(relPos));
 	getJoint()->setUserConstraintPtr(static_cast<PhysicsObject*>(this));
 }
@@ -38,8 +38,8 @@ PhysicsPoint2PointJoint::PhysicsPoint2PointJoint(PhysicsWorld* world, PhysicsBod
 	: PhysicsJoint(world, JointType::kP2P)
 {
 	ANKI_ASSERT(bodyA != bodyB);
-	m_bodyA = bodyA;
-	m_bodyB = bodyB;
+	m_bodyA = std::move(bodyA);
+	m_bodyB = std::move(bodyB);
 
 	m_p2p.init(*m_bodyA->getBtBody(), *m_bodyB->getBtBody(), toBt(relPosA), toBt(relPosB));
 	getJoint()->setUserConstraintPtr(static_cast<PhysicsObject*>(this));
@@ -53,7 +53,7 @@ PhysicsPoint2PointJoint::~PhysicsPoint2PointJoint()
 PhysicsHingeJoint::PhysicsHingeJoint(PhysicsWorld* world, PhysicsBodyPtr bodyA, const Vec3& relPos, const Vec3& axis)
 	: PhysicsJoint(world, JointType::kHinge)
 {
-	m_bodyA = bodyA;
+	m_bodyA = std::move(bodyA);
 	m_hinge.init(*m_bodyA->getBtBody(), toBt(relPos), toBt(axis));
 	getJoint()->setUserConstraintPtr(static_cast<PhysicsObject*>(this));
 }

+ 2 - 2
AnKi/Renderer/Renderer.cpp

@@ -105,7 +105,7 @@ Error Renderer::init(ThreadHive* hive, ResourceManager* resources, GrManager* gl
 	m_gr = gl;
 	m_stagingMem = stagingMem;
 	m_ui = ui;
-	m_alloc = alloc;
+	m_alloc = std::move(alloc);
 	m_config = config;
 
 	const Error err = initInternal(swapchainSize);
@@ -505,7 +505,7 @@ TexturePtr Renderer::createAndClearRenderTarget(const TextureInitInfo& inf, Text
 
 						TextureViewPtr view = getGrManager().newTextureView(TextureViewInitInfo(tex, surf, aspect));
 
-						fbInit.m_depthStencilAttachment.m_textureView = view;
+						fbInit.m_depthStencilAttachment.m_textureView = std::move(view);
 						fbInit.m_depthStencilAttachment.m_loadOperation = AttachmentLoadOperation::kClear;
 						fbInit.m_depthStencilAttachment.m_stencilLoadOperation = AttachmentLoadOperation::kClear;
 						fbInit.m_depthStencilAttachment.m_clearValue = clearVal;

+ 1 - 1
AnKi/Renderer/TileAllocator.cpp

@@ -51,7 +51,7 @@ void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY
 	m_tileCountX = U16(tileCountX);
 	m_tileCountY = U16(tileCountY);
 	m_lodCount = U8(lodCount);
-	m_alloc = alloc;
+	m_alloc = std::move(alloc);
 	m_cachingEnabled = enableCaching;
 	m_lodFirstTileIndex.create(m_alloc, lodCount + 1);
 

+ 1 - 1
AnKi/Resource/ImageLoader.cpp

@@ -680,7 +680,7 @@ Error ImageLoader::loadStb(Bool isFloat, FileInterface& fs, U32& width, U32& hei
 Error ImageLoader::load(ResourceFilePtr rfile, const CString& filename, U32 maxImageSize)
 {
 	RsrcFile file;
-	file.m_rfile = rfile;
+	file.m_rfile = std::move(rfile);
 
 	const Error err = loadInternal(file, filename, maxImageSize);
 	if(err)

+ 1 - 1
AnKi/Resource/MeshResource.cpp

@@ -212,7 +212,7 @@ Error MeshResource::load(const ResourceFilename& filename, Bool async)
 		PtrSize stride;
 		getVertexBufferInfo(bufferIdx, buffer, offset, stride);
 
-		inf.m_bottomLevel.m_positionBuffer = buffer;
+		inf.m_bottomLevel.m_positionBuffer = std::move(buffer);
 		inf.m_bottomLevel.m_positionBufferOffset = offset;
 		inf.m_bottomLevel.m_positionStride = U32(stride);
 		inf.m_bottomLevel.m_positionsFormat = format;

+ 1 - 1
AnKi/Resource/ResourceManager.h

@@ -62,7 +62,7 @@ protected:
 
 	void init(ResourceAllocator<U8> alloc)
 	{
-		m_alloc = alloc;
+		m_alloc = std::move(alloc);
 	}
 
 private:

+ 1 - 1
AnKi/Resource/ShaderProgramResource.cpp

@@ -401,7 +401,7 @@ ShaderProgramResource::createNewVariant(const ShaderProgramResourceVariantInitIn
 			}
 			else if(shaderType == ShaderType::kCompute)
 			{
-				progInf.m_computeShader = shader;
+				progInf.m_computeShader = std::move(shader);
 			}
 			else
 			{

+ 1 - 1
AnKi/Resource/TransferGpuAllocator.cpp

@@ -47,7 +47,7 @@ TransferGpuAllocator::~TransferGpuAllocator()
 
 Error TransferGpuAllocator::init(PtrSize maxSize, GrManager* gr, ResourceAllocator<U8> alloc)
 {
-	m_alloc = alloc;
+	m_alloc = std::move(alloc);
 	m_gr = gr;
 
 	m_maxAllocSize = getAlignedRoundUp(CHUNK_INITIAL_SIZE * POOL_COUNT, maxSize);

+ 2 - 2
AnKi/Scene/Components/JointComponent.cpp

@@ -70,7 +70,7 @@ void JointComponent::newJoint(const Vec3& relPosFactor, F32 breakingImpulse, TAr
 		joint->setBreakingImpulseThreshold(breakingImpulse);
 
 		JointNode* newNode = m_node->getAllocator().newInstance<JointNode>();
-		newNode->m_joint = joint;
+		newNode->m_joint = std::move(joint);
 		m_jointList.pushBack(newNode);
 	}
 	else
@@ -103,7 +103,7 @@ void JointComponent::newPoint2PointJoint2(const Vec3& relPosFactorA, const Vec3&
 		joint->setBreakingImpulseThreshold(breakingImpulse);
 
 		JointNode* newNode = m_node->getAllocator().newInstance<JointNode>();
-		newNode->m_joint = joint;
+		newNode->m_joint = std::move(joint);
 		newNode->m_parentNode = m_node->getParent();
 		m_jointList.pushBack(newNode);
 	}

+ 1 - 1
AnKi/Scene/Components/ModelComponent.cpp

@@ -30,7 +30,7 @@ Error ModelComponent::loadModelResource(CString filename)
 
 	ModelResourcePtr rsrc;
 	ANKI_CHECK(m_node->getSceneGraph().getResourceManager().loadResource(filename, rsrc));
-	m_model = rsrc;
+	m_model = std::move(rsrc);
 
 	m_modelPatchMergeKeys.destroy(m_node->getAllocator());
 	m_modelPatchMergeKeys.create(m_node->getAllocator(), m_model->getModelPatches().getSize());

+ 1 - 1
AnKi/Scene/Components/ParticleEmitterComponent.cpp

@@ -232,7 +232,7 @@ Error ParticleEmitterComponent::loadParticleEmitterResource(CString filename)
 			m_props.m_particle.m_minInitialSize / 2.0f);
 
 		PhysicsBodyInitInfo binit;
-		binit.m_shape = collisionShape;
+		binit.m_shape = std::move(collisionShape);
 
 		m_physicsParticles.resizeStorage(m_node->getAllocator(), m_props.m_maxNumOfParticles);
 		for(U32 i = 0; i < m_props.m_maxNumOfParticles; i++)

+ 1 - 1
AnKi/Script/LuaBinder.cpp

@@ -50,7 +50,7 @@ Error LuaBinder::init(ScriptAllocator alloc, LuaBinderOtherSystems* otherSystems
 {
 	ANKI_ASSERT(otherSystems);
 	m_otherSystems = otherSystems;
-	m_alloc = alloc;
+	m_alloc = std::move(alloc);
 
 	m_l = lua_newstate(luaAllocCallback, this);
 	luaL_openlibs(m_l);

+ 1 - 1
AnKi/Util/BuddyAllocatorBuilder.inl.h

@@ -17,7 +17,7 @@ void BuddyAllocatorBuilder<kMaxMemoryRangeLog2, TLock>::init(GenericMemoryPoolAl
 	const U32 orderCount = maxMemoryRangeLog2 + 1;
 	m_maxMemoryRange = pow2<PtrSize>(maxMemoryRangeLog2);
 
-	m_alloc = alloc;
+	m_alloc = std::move(alloc);
 	m_freeLists.create(m_alloc, orderCount);
 }
 

+ 1 - 1
AnKi/Util/ClassAllocatorBuilder.inl.h

@@ -10,7 +10,7 @@ namespace anki {
 template<typename TChunk, typename TInterface, typename TLock>
 void ClassAllocatorBuilder<TChunk, TInterface, TLock>::init(GenericMemoryPoolAllocator<U8> alloc)
 {
-	m_alloc = alloc;
+	m_alloc = std::move(alloc);
 
 	m_classes.create(m_alloc, m_interface.getClassCount());
 

+ 2 - 1
AnKi/Util/Serializer.inl.h

@@ -30,8 +30,9 @@ Error BinarySerializer::serializeInternal(const T& x, GenericMemoryPoolAllocator
 	// Misc
 	m_file = &file;
 	ANKI_ASSERT(m_file->tell() == 0);
+
 	m_err = Error::kNone;
-	m_alloc = tmpAllocator;
+	m_alloc = std::move(tmpAllocator);
 
 	// Write the empty header (will be filled later)
 	detail::BinarySerializerHeader header = {};

+ 1 - 1
AnKi/Util/Xml.cpp

@@ -140,7 +140,7 @@ Error XmlDocument::loadFile(CString filename, GenericMemoryPoolAllocator<U8> all
 
 Error XmlDocument::parse(CString xmlText, GenericMemoryPoolAllocator<U8> alloc)
 {
-	m_alloc = alloc;
+	m_alloc = std::move(alloc);
 
 	if(m_doc.Parse(&xmlText[0]))
 	{

+ 1 - 1
Tools/Image/ImageViewerMain.cpp

@@ -300,7 +300,7 @@ public:
 		SceneGraph& scene = getSceneGraph();
 		TextureViewerUiNode* node;
 		ANKI_CHECK(scene.newSceneNode("TextureViewer", node));
-		node->m_imageResource = image;
+		node->m_imageResource = std::move(image);
 
 		return Error::kNone;
 	}