Răsfoiți Sursa

Fix the Linux and Android builds and do some refactoring

Panagiotis Christopoulos Charitos 3 ani în urmă
părinte
comite
2b268df695

+ 9 - 9
AnKi/Core/ConfigSet.cpp

@@ -170,24 +170,24 @@ Error ConfigSet::saveToFile(CString filename) const
 	File file;
 	ANKI_CHECK(file.open(filename, FileOpenFlag::WRITE));
 
-	ANKI_CHECK(file.writeText("%s\n<config>\n", XmlDocument::XML_HEADER.cstr()));
+	ANKI_CHECK(file.writeTextf("%s\n<config>\n", XmlDocument::XML_HEADER.cstr()));
 
 #define ANKI_NUMERIC_UINT(name) \
-	ANKI_CHECK(file.writeText("\t<!-- %s -->\n", m_##name.m_description.cstr())); \
-	ANKI_CHECK( \
-		file.writeText("\t<%s>%llu</%s>\n", m_##name.m_name.cstr(), U64(m_##name.m_value), m_##name.m_name.cstr()));
+	ANKI_CHECK(file.writeTextf("\t<!-- %s -->\n", m_##name.m_description.cstr())); \
+	ANKI_CHECK(file.writeTextf("\t<%s>%" PRIu64 "</%s>\n", m_##name.m_name.cstr(), U64(m_##name.m_value), \
+							   m_##name.m_name.cstr()));
 
 #define ANKI_CONFIG_VAR_U8(name, defaultValue, minValue, maxValue, description) ANKI_NUMERIC_UINT(name)
 #define ANKI_CONFIG_VAR_U32(name, defaultValue, minValue, maxValue, description) ANKI_NUMERIC_UINT(name)
 #define ANKI_CONFIG_VAR_PTR_SIZE(name, defaultValue, minValue, maxValue, description) ANKI_NUMERIC_UINT(name)
 #define ANKI_CONFIG_VAR_F32(name, defaultValue, minValue, maxValue, description) ANKI_NUMERIC_UINT(name)
 #define ANKI_CONFIG_VAR_BOOL(name, defaultValue, description) \
-	ANKI_CHECK(file.writeText("\t<!-- %s -->\n", m_##name.m_description.cstr())); \
-	ANKI_CHECK(file.writeText("\t<%s>%s</%s>\n", m_##name.m_name.cstr(), (m_##name.m_value) ? "true" : "false", \
-							  m_##name.m_name.cstr()));
+	ANKI_CHECK(file.writeTextf("\t<!-- %s -->\n", m_##name.m_description.cstr())); \
+	ANKI_CHECK(file.writeTextf("\t<%s>%s</%s>\n", m_##name.m_name.cstr(), (m_##name.m_value) ? "true" : "false", \
+							   m_##name.m_name.cstr()));
 #define ANKI_CONFIG_VAR_STRING(name, defaultValue, description) \
-	ANKI_CHECK(file.writeText("\t<!-- %s -->\n", m_##name.m_description.cstr())); \
-	ANKI_CHECK(file.writeText("\t<%s>%s</%s>\n", m_##name.m_name.cstr(), m_##name.m_value, m_##name.m_name.cstr()));
+	ANKI_CHECK(file.writeTextf("\t<!-- %s -->\n", m_##name.m_description.cstr())); \
+	ANKI_CHECK(file.writeTextf("\t<%s>%s</%s>\n", m_##name.m_name.cstr(), m_##name.m_value, m_##name.m_name.cstr()));
 #include <AnKi/Core/AllConfigVars.defs.h>
 #undef ANKI_NUMERIC_UINT
 

+ 9 - 8
AnKi/Core/CoreTracer.cpp

@@ -191,9 +191,10 @@ Error CoreTracer::writeEvents(ThreadWorkItem& item)
 		// Do a hack
 		const ThreadId tid = (event.m_name == "GPU_TIME") ? 1 : item.m_tid;
 
-		ANKI_CHECK(m_traceJsonFile.writeText("{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"X\", "
-											 "\"pid\": 1, \"tid\": %llu, \"ts\": %lld, \"dur\": %lld},\n",
-											 event.m_name.cstr(), tid, startMicroSec, durMicroSec));
+		ANKI_CHECK(m_traceJsonFile.writeTextf("{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"X\", "
+											  "\"pid\": 1, \"tid\": %" PRIu64 ", \"ts\": %" PRIi64 ", \"dur\": %" PRIi64
+											  "},\n",
+											  event.m_name.cstr(), tid, startMicroSec, durMicroSec));
 	}
 
 	// Store counters
@@ -340,14 +341,14 @@ Error CoreTracer::writeCountersForReal()
 	ANKI_CHECK(m_countersCsvFile.writeText("Frame"));
 	for(U32 i = 0; i < m_counterNames.getSize(); ++i)
 	{
-		ANKI_CHECK(m_countersCsvFile.writeText(",%s", m_counterNames[i].cstr()));
+		ANKI_CHECK(m_countersCsvFile.writeTextf(",%s", m_counterNames[i].cstr()));
 	}
 	ANKI_CHECK(m_countersCsvFile.writeText("\n"));
 
 	// Write each frame
 	for(const PerFrameCounters& frame : m_frameCounters)
 	{
-		ANKI_CHECK(m_countersCsvFile.writeText("%llu", frame.m_frame));
+		ANKI_CHECK(m_countersCsvFile.writeTextf("%" PRIu64, frame.m_frame));
 
 		for(U32 j = 0; j < m_counterNames.getSize(); ++j)
 		{
@@ -362,7 +363,7 @@ Error CoreTracer::writeCountersForReal()
 				}
 			}
 
-			ANKI_CHECK(m_countersCsvFile.writeText(",%llu", value));
+			ANKI_CHECK(m_countersCsvFile.writeTextf(",%" PRIu64, value));
 		}
 
 		ANKI_CHECK(m_countersCsvFile.writeText("\n"));
@@ -377,8 +378,8 @@ Error CoreTracer::writeCountersForReal()
 		{
 			Array<char, 3> columnName;
 			getSpreadsheetColumnName(i + 1, columnName);
-			ANKI_CHECK(m_countersCsvFile.writeText(",=%s(%s2:%s%u)", func, &columnName[0], &columnName[0],
-												   m_frameCounters.getSize() + 1));
+			ANKI_CHECK(m_countersCsvFile.writeTextf(",=%s(%s2:%s%zu)", func, &columnName[0], &columnName[0],
+													m_frameCounters.getSize() + 1));
 		}
 
 		ANKI_CHECK(m_countersCsvFile.writeText("\n"));

+ 4 - 4
AnKi/Core/StatsUi.cpp

@@ -39,19 +39,19 @@ void StatsUi::labelBytes(PtrSize val, CString name) const
 	StringAuto timestamp(getAllocator());
 	if(gb)
 	{
-		timestamp.sprintf("%s: %u,%04u,%04u,%04u", name.cstr(), gb, mb, kb, b);
+		timestamp.sprintf("%s: %zu,%04zu,%04zu,%04zu", name.cstr(), gb, mb, kb, b);
 	}
 	else if(mb)
 	{
-		timestamp.sprintf("%s: %u,%04u,%04u", name.cstr(), mb, kb, b);
+		timestamp.sprintf("%s: %zu,%04zu,%04zu", name.cstr(), mb, kb, b);
 	}
 	else if(kb)
 	{
-		timestamp.sprintf("%s: %u,%04u", name.cstr(), kb, b);
+		timestamp.sprintf("%s: %zu,%04zu", name.cstr(), kb, b);
 	}
 	else
 	{
-		timestamp.sprintf("%s: %u", name.cstr(), b);
+		timestamp.sprintf("%s: %zu", name.cstr(), b);
 	}
 	ImGui::TextUnformatted(timestamp.cstr());
 }

+ 4 - 3
AnKi/Gr/Vulkan/GrManagerImpl.cpp

@@ -1509,7 +1509,7 @@ Error GrManagerImpl::printPipelineShaderInfoInternal(VkPipeline ppline, CString
 												   "stage 5 VGPR,stage 5 SGPR\n"));
 		}
 
-		ANKI_CHECK(m_shaderStatsFile.writeText("%s,0x%" PRIx64 ",", name.cstr(), hash));
+		ANKI_CHECK(m_shaderStatsFile.writeTextf("%s,0x%" PRIx64 ",", name.cstr(), hash));
 
 		StringAuto str(getAllocator());
 
@@ -1530,8 +1530,9 @@ Error GrManagerImpl::printPipelineShaderInfoInternal(VkPipeline ppline, CString
 						   .sprintf("Stage %u: VGRPS %02u, SGRPS %02u ", U32(type), stats.resourceUsage.numUsedVgprs,
 									stats.resourceUsage.numUsedSgprs));
 
-			ANKI_CHECK(m_shaderStatsFile.writeText((type != ShaderType::LAST) ? "%u,%u," : "%u,%u\n",
-												   stats.resourceUsage.numUsedVgprs, stats.resourceUsage.numUsedSgprs));
+			ANKI_CHECK(m_shaderStatsFile.writeTextf((type != ShaderType::LAST) ? "%u,%u," : "%u,%u\n",
+													stats.resourceUsage.numUsedVgprs,
+													stats.resourceUsage.numUsedSgprs));
 		}
 
 		ANKI_VK_LOGI("Pipeline \"%s\" (0x%016" PRIx64 ") stats: %s", name.cstr(), hash, str.cstr());

+ 80 - 80
AnKi/Importer/GltfImporter.cpp

@@ -229,7 +229,7 @@ Error GltfImporter::writeAll()
 	StringAuto sceneFname(m_alloc);
 	sceneFname.sprintf("%sScene.lua", m_outDir.cstr());
 	ANKI_CHECK(m_sceneFile.open(sceneFname.toCString(), FileOpenFlag::WRITE));
-	ANKI_CHECK(m_sceneFile.writeText("-- Generated by: %s\n", m_comment.cstr()));
+	ANKI_CHECK(m_sceneFile.writeTextf("-- Generated by: %s\n", m_comment.cstr()));
 	ANKI_CHECK(m_sceneFile.writeText("local scene = getSceneGraph()\nlocal events = getEventManager()\n"));
 
 	// Nodes
@@ -458,12 +458,12 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 				gpuParticles = true;
 			}
 
-			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:new%sParticleEmitterNode(\"%s\")\n",
-											 (gpuParticles) ? "Gpu" : "", getNodeName(node).cstr()));
+			ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:new%sParticleEmitterNode(\"%s\")\n",
+											  (gpuParticles) ? "Gpu" : "", getNodeName(node).cstr()));
 
-			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():get%sParticleEmitterComponent()\n",
-											 (gpuParticles) ? "Gpu" : ""));
-			ANKI_CHECK(m_sceneFile.writeText("comp:loadParticleEmitterResource(\"%s\")\n", fname.cstr()));
+			ANKI_CHECK(m_sceneFile.writeTextf("comp = node:getSceneNodeBase():get%sParticleEmitterComponent()\n",
+											  (gpuParticles) ? "Gpu" : ""));
+			ANKI_CHECK(m_sceneFile.writeTextf("comp:loadParticleEmitterResource(\"%s\")\n", fname.cstr()));
 
 			Transform localTrf;
 			ANKI_CHECK(getNodeTransform(node, localTrf));
@@ -474,7 +474,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 		{
 			// Atmosphere
 
-			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newSkyboxNode(\"%s\")\n", getNodeName(node).cstr()));
+			ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newSkyboxNode(\"%s\")\n", getNodeName(node).cstr()));
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getSkyboxComponent()\n"));
 
 			if((it = extras.find("skybox_solid_color")) != extras.getEnd())
@@ -502,40 +502,40 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 					solidColor[count++] = f;
 				}
 
-				ANKI_CHECK(m_sceneFile.writeText("comp:setSolidColor(Vec3.new(%f, %f, %f))\n", solidColor.x(),
-												 solidColor.y(), solidColor.z()));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setSolidColor(Vec3.new(%f, %f, %f))\n", solidColor.x(),
+												  solidColor.y(), solidColor.z()));
 			}
 			else if((it = extras.find("skybox_image")) != extras.getEnd())
 			{
-				ANKI_CHECK(m_sceneFile.writeText("comp:setImage(\"%s\")\n", it->cstr()));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setImage(\"%s\")\n", it->cstr()));
 			}
 
 			if((it = extras.find("fog_min_density")) != extras.getEnd())
 			{
 				F32 val;
 				ANKI_CHECK(it->toNumber(val));
-				ANKI_CHECK(m_sceneFile.writeText("comp:setMinFogDensity(\"%f\")\n", val));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setMinFogDensity(\"%f\")\n", val));
 			}
 
 			if((it = extras.find("fog_max_density")) != extras.getEnd())
 			{
 				F32 val;
 				ANKI_CHECK(it->toNumber(val));
-				ANKI_CHECK(m_sceneFile.writeText("comp:setMaxFogDensity(\"%f\")\n", val));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setMaxFogDensity(\"%f\")\n", val));
 			}
 
 			if((it = extras.find("fog_height_of_min_density")) != extras.getEnd())
 			{
 				F32 val;
 				ANKI_CHECK(it->toNumber(val));
-				ANKI_CHECK(m_sceneFile.writeText("comp:setHeightOfMinFogDensity(\"%f\")\n", val));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setHeightOfMinFogDensity(\"%f\")\n", val));
 			}
 
 			if((it = extras.find("fog_height_of_max_density")) != extras.getEnd())
 			{
 				F32 val;
 				ANKI_CHECK(it->toNumber(val));
-				ANKI_CHECK(m_sceneFile.writeText("comp:setHeightOfMaxFogDensity(\"%f\")\n", val));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setHeightOfMaxFogDensity(\"%f\")\n", val));
 			}
 
 			Transform localTrf;
@@ -545,11 +545,11 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 		else if((it = extras.find("collision")) != extras.getEnd() && (*it == "true" || *it == "1"))
 		{
 			ANKI_CHECK(
-				m_sceneFile.writeText("\nnode = scene:newStaticCollisionNode(\"%s\")\n", getNodeName(node).cstr()));
+				m_sceneFile.writeTextf("\nnode = scene:newStaticCollisionNode(\"%s\")\n", getNodeName(node).cstr()));
 
 			ANKI_CHECK(m_sceneFile.writeText("comp = scene:getSceneNodeBase():getBodyComponent()\n"));
 			const StringAuto meshFname = computeMeshResourceFilename(*node.mesh);
-			ANKI_CHECK(m_sceneFile.writeText("comp:loadMeshResource(\"%s%s\")\n", m_rpath.cstr(), meshFname.cstr()));
+			ANKI_CHECK(m_sceneFile.writeTextf("comp:loadMeshResource(\"%s%s\")\n", m_rpath.cstr(), meshFname.cstr()));
 
 			Transform localTrf;
 			ANKI_CHECK(getNodeTransform(node, localTrf));
@@ -565,11 +565,11 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 			const Vec3 boxSize = scale * 2.0f;
 
 			ANKI_CHECK(
-				m_sceneFile.writeText("\nnode = scene:newReflectionProbeNode(\"%s\")\n", getNodeName(node).cstr()));
+				m_sceneFile.writeTextf("\nnode = scene:newReflectionProbeNode(\"%s\")\n", getNodeName(node).cstr()));
 
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getReflectionProbeComponent()\n"));
-			ANKI_CHECK(m_sceneFile.writeText("comp:setBoxVolumeSize(Vec3.new(%f, %f, %f))\n", boxSize.x(), boxSize.y(),
-											 boxSize.z()));
+			ANKI_CHECK(m_sceneFile.writeTextf("comp:setBoxVolumeSize(Vec3.new(%f, %f, %f))\n", boxSize.x(), boxSize.y(),
+											  boxSize.z()));
 
 			const Transform localTrf = Transform(tsl.xyz0(), Mat3x4(Vec3(0.0f), rot), 1.0f);
 			ANKI_CHECK(writeTransform(parentTrf.combineTransformations(localTrf)));
@@ -595,20 +595,20 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 				ANKI_CHECK(it->toNumber(cellSize));
 			}
 
-			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newGlobalIlluminationProbeNode(\"%s\")\n",
-											 getNodeName(node).cstr()));
+			ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newGlobalIlluminationProbeNode(\"%s\")\n",
+											  getNodeName(node).cstr()));
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getGlobalIlluminationProbeComponent()\n"));
-			ANKI_CHECK(m_sceneFile.writeText("comp:setBoxVolumeSize(Vec3.new(%f, %f, %f))\n", boxSize.x(), boxSize.y(),
-											 boxSize.z()));
+			ANKI_CHECK(m_sceneFile.writeTextf("comp:setBoxVolumeSize(Vec3.new(%f, %f, %f))\n", boxSize.x(), boxSize.y(),
+											  boxSize.z()));
 
 			if(fadeDistance > 0.0f)
 			{
-				ANKI_CHECK(m_sceneFile.writeText("comp:setFadeDistance(%f)\n", fadeDistance));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setFadeDistance(%f)\n", fadeDistance));
 			}
 
 			if(cellSize > 0.0f)
 			{
-				ANKI_CHECK(m_sceneFile.writeText("comp:setCellSize(%f)\n", cellSize));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setCellSize(%f)\n", cellSize));
 			}
 
 			const Transform localTrf = Transform(tsl.xyz0(), Mat3x4(Vec3(0.0f), rot), 1.0f);
@@ -652,17 +652,17 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 				ANKI_CHECK(it->toNumber(specularRougnessMetallicFactor));
 			}
 
-			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newDecalNode(\"%s\")\n", getNodeName(node).cstr()));
+			ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newDecalNode(\"%s\")\n", getNodeName(node).cstr()));
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getDecalComponent()\n"));
 			if(diffuseAtlas)
 			{
-				ANKI_CHECK(m_sceneFile.writeText("comp:setDiffuseDecal(\"%s\", \"%s\", %f)\n", diffuseAtlas.cstr(),
-												 diffuseSubtexture.cstr(), diffuseFactor));
+				ANKI_CHECK(m_sceneFile.writeTextf("comp:setDiffuseDecal(\"%s\", \"%s\", %f)\n", diffuseAtlas.cstr(),
+												  diffuseSubtexture.cstr(), diffuseFactor));
 			}
 
 			if(specularRougnessMetallicAtlas)
 			{
-				ANKI_CHECK(m_sceneFile.writeText(
+				ANKI_CHECK(m_sceneFile.writeTextf(
 					"comp:setSpecularRoughnessDecal(\"%s\", \"%s\", %f)\n", specularRougnessMetallicAtlas.cstr(),
 					specularRougnessMetallicSubtexture.cstr(), specularRougnessMetallicFactor));
 			}
@@ -771,15 +771,15 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 
 			if(selfCollision)
 			{
-				ANKI_CHECK(m_sceneFile.writeText("node2 = scene:newStaticCollisionNode(\"%s_cl\")\n",
-												 getNodeName(node).cstr()));
+				ANKI_CHECK(m_sceneFile.writeTextf("node2 = scene:newStaticCollisionNode(\"%s_cl\")\n",
+												  getNodeName(node).cstr()));
 
 				ANKI_CHECK(m_sceneFile.writeText("comp = node2:getSceneNodeBase():getBodyComponent()\n"));
 
 				const StringAuto meshFname = computeMeshResourceFilename(*node.mesh, maxLod);
 
 				ANKI_CHECK(
-					m_sceneFile.writeText("comp:loadMeshResource(\"%s%s\")\n", m_rpath.cstr(), meshFname.cstr()));
+					m_sceneFile.writeTextf("comp:loadMeshResource(\"%s%s\")\n", m_rpath.cstr(), meshFname.cstr()));
 				ANKI_CHECK(m_sceneFile.writeText("comp:setWorldTransform(trf)\n"));
 			}
 		}
@@ -810,18 +810,18 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
 Error GltfImporter::writeTransform(const Transform& trf)
 {
 	ANKI_CHECK(m_sceneFile.writeText("trf = Transform.new()\n"));
-	ANKI_CHECK(m_sceneFile.writeText("trf:setOrigin(Vec4.new(%f, %f, %f, 0))\n", trf.getOrigin().x(),
-									 trf.getOrigin().y(), trf.getOrigin().z()));
+	ANKI_CHECK(m_sceneFile.writeTextf("trf:setOrigin(Vec4.new(%f, %f, %f, 0))\n", trf.getOrigin().x(),
+									  trf.getOrigin().y(), trf.getOrigin().z()));
 
 	ANKI_CHECK(m_sceneFile.writeText("rot = Mat3x4.new()\n"));
 	ANKI_CHECK(m_sceneFile.writeText("rot:setAll("));
 	for(U i = 0; i < 12; i++)
 	{
-		ANKI_CHECK(m_sceneFile.writeText((i != 11) ? "%f, " : "%f)\n", trf.getRotation()[i]));
+		ANKI_CHECK(m_sceneFile.writeTextf((i != 11) ? "%f, " : "%f)\n", trf.getRotation()[i]));
 	}
 	ANKI_CHECK(m_sceneFile.writeText("trf:setRotation(rot)\n"));
 
-	ANKI_CHECK(m_sceneFile.writeText("trf:setScale(%f)\n", trf.getScale()));
+	ANKI_CHECK(m_sceneFile.writeTextf("trf:setScale(%f)\n", trf.getScale()));
 
 	ANKI_CHECK(m_sceneFile.writeText("node:getSceneNodeBase():getMoveComponent():setLocalTransform(trf)\n"));
 
@@ -852,24 +852,24 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh)
 		}
 		else
 		{
-			ANKI_CHECK(file.writeText("\t\t<modelPatch subMeshIndex=\"%u\">\n", primIdx));
+			ANKI_CHECK(file.writeTextf("\t\t<modelPatch subMeshIndex=\"%u\">\n", primIdx));
 		}
 
 		{
 			const StringAuto meshFname = computeMeshResourceFilename(mesh);
-			ANKI_CHECK(file.writeText("\t\t\t<mesh>%s%s</mesh>\n", m_rpath.cstr(), meshFname.cstr()));
+			ANKI_CHECK(file.writeTextf("\t\t\t<mesh>%s%s</mesh>\n", m_rpath.cstr(), meshFname.cstr()));
 		}
 
 		if(m_lodCount > 1 && !skipMeshLod(mesh, 1))
 		{
 			const StringAuto meshFname = computeMeshResourceFilename(mesh, 1);
-			ANKI_CHECK(file.writeText("\t\t\t<mesh1>%s%s</mesh1>\n", m_rpath.cstr(), meshFname.cstr()));
+			ANKI_CHECK(file.writeTextf("\t\t\t<mesh1>%s%s</mesh1>\n", m_rpath.cstr(), meshFname.cstr()));
 		}
 
 		if(m_lodCount > 2 && !skipMeshLod(mesh, 2))
 		{
 			const StringAuto meshFname = computeMeshResourceFilename(mesh, 2);
-			ANKI_CHECK(file.writeText("\t\t\t<mesh2>%s%s</mesh2>\n", m_rpath.cstr(), meshFname.cstr()));
+			ANKI_CHECK(file.writeTextf("\t\t\t<mesh2>%s%s</mesh2>\n", m_rpath.cstr(), meshFname.cstr()));
 		}
 
 		HashMapAuto<CString, StringAuto> materialExtras(m_alloc);
@@ -877,12 +877,12 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh)
 		auto mtlOverride = materialExtras.find("material_override");
 		if(mtlOverride != materialExtras.getEnd())
 		{
-			ANKI_CHECK(file.writeText("\t\t\t<material>%s</material>\n", mtlOverride->cstr()));
+			ANKI_CHECK(file.writeTextf("\t\t\t<material>%s</material>\n", mtlOverride->cstr()));
 		}
 		else
 		{
 			const StringAuto mtlFname = computeMaterialResourceFilename(*mesh.primitives[primIdx].material);
-			ANKI_CHECK(file.writeText("\t\t\t<material>%s%s</material>\n", m_rpath.cstr(), mtlFname.cstr()));
+			ANKI_CHECK(file.writeTextf("\t\t\t<material>%s%s</material>\n", m_rpath.cstr(), mtlFname.cstr()));
 		}
 
 		ANKI_CHECK(file.writeText("\t\t</modelPatch>\n"));
@@ -1150,12 +1150,12 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 	File file;
 	ANKI_CHECK(file.open(fname.toCString(), FileOpenFlag::WRITE));
 
-	ANKI_CHECK(file.writeText("%s\n<animation>\n", XML_HEADER));
+	ANKI_CHECK(file.writeTextf("%s\n<animation>\n", XML_HEADER));
 	ANKI_CHECK(file.writeText("\t<channels>\n"));
 
 	for(const GltfAnimChannel& channel : tempChannels)
 	{
-		ANKI_CHECK(file.writeText("\t\t<channel name=\"%s\">\n", channel.m_name.cstr()));
+		ANKI_CHECK(file.writeTextf("\t\t<channel name=\"%s\">\n", channel.m_name.cstr()));
 
 		// Positions
 		if(channel.m_positions.getSize())
@@ -1163,8 +1163,8 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 			ANKI_CHECK(file.writeText("\t\t\t<positionKeys>\n"));
 			for(const GltfAnimKey<Vec3>& key : channel.m_positions)
 			{
-				ANKI_CHECK(file.writeText("\t\t\t\t<key time=\"%f\">%f %f %f</key>\n", key.m_time, key.m_value.x(),
-										  key.m_value.y(), key.m_value.z()));
+				ANKI_CHECK(file.writeTextf("\t\t\t\t<key time=\"%f\">%f %f %f</key>\n", key.m_time, key.m_value.x(),
+										   key.m_value.y(), key.m_value.z()));
 			}
 			ANKI_CHECK(file.writeText("\t\t\t</positionKeys>\n"));
 		}
@@ -1175,8 +1175,8 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 			ANKI_CHECK(file.writeText("\t\t\t<rotationKeys>\n"));
 			for(const GltfAnimKey<Quat>& key : channel.m_rotations)
 			{
-				ANKI_CHECK(file.writeText("\t\t\t\t<key time=\"%f\">%f %f %f %f</key>\n", key.m_time, key.m_value.x(),
-										  key.m_value.y(), key.m_value.z(), key.m_value.w()));
+				ANKI_CHECK(file.writeTextf("\t\t\t\t<key time=\"%f\">%f %f %f %f</key>\n", key.m_time, key.m_value.x(),
+										   key.m_value.y(), key.m_value.z(), key.m_value.w()));
 			}
 			ANKI_CHECK(file.writeText("\t\t\t</rotationKeys>\n"));
 		}
@@ -1187,7 +1187,7 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 			ANKI_CHECK(file.writeText("\t\t\t<scaleKeys>\n"));
 			for(const GltfAnimKey<F32>& key : channel.m_scales)
 			{
-				ANKI_CHECK(file.writeText("\t\t\t\t<key time=\"%f\">%f</key>\n", key.m_time, key.m_value));
+				ANKI_CHECK(file.writeTextf("\t\t\t\t<key time=\"%f\">%f</key>\n", key.m_time, key.m_value));
 			}
 			ANKI_CHECK(file.writeText("\t\t\t</scaleKeys>\n"));
 		}
@@ -1220,8 +1220,8 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
 	File file;
 	ANKI_CHECK(file.open(fname.toCString(), FileOpenFlag::WRITE));
 
-	ANKI_CHECK(file.writeText("%s\n<skeleton>\n", XML_HEADER));
-	ANKI_CHECK(file.writeText("\t<bones>\n", XML_HEADER));
+	ANKI_CHECK(file.writeTextf("%s\n<skeleton>\n", XML_HEADER));
+	ANKI_CHECK(file.writeTextf("\t<bones>\n"));
 
 	for(U32 i = 0; i < skin.joints_count; ++i)
 	{
@@ -1230,10 +1230,10 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
 		StringAuto parent(m_alloc);
 
 		// Name & parent
-		ANKI_CHECK(file.writeText("\t\t<bone name=\"%s\" ", getNodeName(boneNode).cstr()));
+		ANKI_CHECK(file.writeTextf("\t\t<bone name=\"%s\" ", getNodeName(boneNode).cstr()));
 		if(boneNode.parent && getNodeName(*boneNode.parent) != skin.name)
 		{
-			ANKI_CHECK(file.writeText("parent=\"%s\" ", getNodeName(*boneNode.parent).cstr()));
+			ANKI_CHECK(file.writeTextf("parent=\"%s\" ", getNodeName(*boneNode.parent).cstr()));
 		}
 
 		// Bone transform
@@ -1242,7 +1242,7 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
 		btrf.transpose();
 		for(U32 j = 0; j < 16; j++)
 		{
-			ANKI_CHECK(file.writeText("%f ", btrf[j]));
+			ANKI_CHECK(file.writeTextf("%f ", btrf[j]));
 		}
 		ANKI_CHECK(file.writeText("\" "));
 
@@ -1253,7 +1253,7 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
 		ANKI_CHECK(file.writeText("transform=\""));
 		for(U j = 0; j < 16; j++)
 		{
-			ANKI_CHECK(file.writeText("%f ", mat[j]));
+			ANKI_CHECK(file.writeTextf("%f ", mat[j]));
 		}
 		ANKI_CHECK(file.writeText("\" "));
 
@@ -1292,14 +1292,14 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 		return Error::USER_DATA;
 	}
 
-	ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:new%sLightNode(\"%s\")\n", lightTypeStr.cstr(), nodeName.cstr()));
+	ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:new%sLightNode(\"%s\")\n", lightTypeStr.cstr(), nodeName.cstr()));
 	ANKI_CHECK(m_sceneFile.writeText("lcomp = node:getSceneNodeBase():getLightComponent()\n"));
 
 	Vec3 color(light.color[0], light.color[1], light.color[2]);
 	color *= light.intensity;
 	color *= m_lightIntensityScale;
 	ANKI_CHECK(
-		m_sceneFile.writeText("lcomp:setDiffuseColor(Vec4.new(%f, %f, %f, 1))\n", color.x(), color.y(), color.z()));
+		m_sceneFile.writeTextf("lcomp:setDiffuseColor(Vec4.new(%f, %f, %f, 1))\n", color.x(), color.y(), color.z()));
 
 	auto shadow = extras.find("shadow");
 	if(shadow != extras.getEnd())
@@ -1316,16 +1316,16 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 
 	if(light.type == cgltf_light_type_point)
 	{
-		ANKI_CHECK(m_sceneFile.writeText("lcomp:setRadius(%f)\n",
-										 (light.range > 0.0f) ? light.range : computeLightRadius(color)));
+		ANKI_CHECK(m_sceneFile.writeTextf("lcomp:setRadius(%f)\n",
+										  (light.range > 0.0f) ? light.range : computeLightRadius(color)));
 	}
 	else if(light.type == cgltf_light_type_spot)
 	{
-		ANKI_CHECK(m_sceneFile.writeText("lcomp:setDistance(%f)\n",
-										 (light.range > 0.0f) ? light.range : computeLightRadius(color)));
+		ANKI_CHECK(m_sceneFile.writeTextf("lcomp:setDistance(%f)\n",
+										  (light.range > 0.0f) ? light.range : computeLightRadius(color)));
 
 		const F32 outer = light.spot_outer_cone_angle * 2.0f;
-		ANKI_CHECK(m_sceneFile.writeText("lcomp:setOuterAngle(%f)\n", outer));
+		ANKI_CHECK(m_sceneFile.writeTextf("lcomp:setOuterAngle(%f)\n", outer));
 
 		auto angStr = extras.find("inner_cone_angle_factor");
 		F32 inner;
@@ -1345,14 +1345,14 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 			inner = 0.75f * outer;
 		}
 
-		ANKI_CHECK(m_sceneFile.writeText("lcomp:setInnerAngle(%f)\n", inner));
+		ANKI_CHECK(m_sceneFile.writeTextf("lcomp:setInnerAngle(%f)\n", inner));
 	}
 
 	auto lensFlaresFname = extras.find("lens_flare");
 	if(lensFlaresFname != extras.getEnd())
 	{
-		ANKI_CHECK(m_sceneFile.writeText("lfcomp = node:getSceneNodeBase():getLensFlareComponent()\n"));
-		ANKI_CHECK(m_sceneFile.writeText("lfcomp:loadImageResource(\"%s\")\n", lensFlaresFname->cstr()));
+		ANKI_CHECK(m_sceneFile.writeTextf("lfcomp = node:getSceneNodeBase():getLensFlareComponent()\n"));
+		ANKI_CHECK(m_sceneFile.writeTextf("lfcomp:loadImageResource(\"%s\")\n", lensFlaresFname->cstr()));
 
 		auto lsSpriteSize = extras.find("lens_flare_first_sprite_size");
 		auto lsColor = extras.find("lens_flare_color");
@@ -1363,7 +1363,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 			const U32 count = 2;
 			ANKI_CHECK(parseArrayOfNumbers(lsSpriteSize->toCString(), numbers, &count));
 
-			ANKI_CHECK(m_sceneFile.writeText("lfcomp:setFirstFlareSize(Vec2.new(%f, %f))\n", numbers[0], numbers[1]));
+			ANKI_CHECK(m_sceneFile.writeTextf("lfcomp:setFirstFlareSize(Vec2.new(%f, %f))\n", numbers[0], numbers[1]));
 		}
 
 		if(lsColor != extras.getEnd())
@@ -1372,8 +1372,8 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 			const U32 count = 4;
 			ANKI_CHECK(parseArrayOfNumbers(lsColor->toCString(), numbers, &count));
 
-			ANKI_CHECK(m_sceneFile.writeText("lfcomp:setColorMultiplier(Vec4.new(%f, %f, %f, %f))\n", numbers[0],
-											 numbers[1], numbers[2], numbers[3]));
+			ANKI_CHECK(m_sceneFile.writeTextf("lfcomp:setColorMultiplier(Vec4.new(%f, %f, %f, %f))\n", numbers[0],
+											  numbers[1], numbers[2], numbers[3]));
 		}
 	}
 
@@ -1388,8 +1388,8 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			const U32 count = 4;
 			ANKI_CHECK(parseArrayOfNumbers(lightEventIntensity->toCString(), numbers, &count));
-			ANKI_CHECK(m_sceneFile.writeText("event:setIntensityMultiplier(Vec4.new(%f, %f, %f, %f))\n", numbers[0],
-											 numbers[1], numbers[2], numbers[3]));
+			ANKI_CHECK(m_sceneFile.writeTextf("event:setIntensityMultiplier(Vec4.new(%f, %f, %f, %f))\n", numbers[0],
+											  numbers[1], numbers[2], numbers[3]));
 		}
 
 		if(lightEventFrequency != extras.getEnd())
@@ -1397,7 +1397,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			const U32 count = 2;
 			ANKI_CHECK(parseArrayOfNumbers(lightEventFrequency->toCString(), numbers, &count));
-			ANKI_CHECK(m_sceneFile.writeText("event:setFrequency(%f, %f)\n", numbers[0], numbers[1]));
+			ANKI_CHECK(m_sceneFile.writeTextf("event:setFrequency(%f, %f)\n", numbers[0], numbers[1]));
 		}
 	}
 
@@ -1416,14 +1416,14 @@ Error GltfImporter::writeCamera(const cgltf_node& node,
 	const cgltf_camera_perspective& cam = node.camera->data.perspective;
 	ANKI_IMPORTER_LOGV("Importing camera %s", getNodeName(node).cstr());
 
-	ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newPerspectiveCameraNode(\"%s\")\n", getNodeName(node).cstr()));
+	ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newPerspectiveCameraNode(\"%s\")\n", getNodeName(node).cstr()));
 	ANKI_CHECK(m_sceneFile.writeText("scene:setActiveCameraNode(node:getSceneNodeBase())\n"));
 	ANKI_CHECK(m_sceneFile.writeText("frustumc = node:getSceneNodeBase():getFrustumComponent()\n"));
 
-	ANKI_CHECK(m_sceneFile.writeText("frustumc:setPerspective(%f, %f, getMainRenderer():getAspectRatio() * %f, %f)\n",
-									 cam.znear, cam.zfar, cam.yfov, cam.yfov));
+	ANKI_CHECK(m_sceneFile.writeTextf("frustumc:setPerspective(%f, %f, getMainRenderer():getAspectRatio() * %f, %f)\n",
+									  cam.znear, cam.zfar, cam.yfov, cam.yfov));
 	ANKI_CHECK(m_sceneFile.writeText("frustumc:setShadowCascadesDistancePower(1.5)\n"));
-	ANKI_CHECK(m_sceneFile.writeText("frustumc:setEffectiveShadowDistance(%f)\n", min(cam.zfar, 100.0f)));
+	ANKI_CHECK(m_sceneFile.writeTextf("frustumc:setEffectiveShadowDistance(%f)\n", min(cam.zfar, 100.0f)));
 
 	return Error::NONE;
 }
@@ -1437,14 +1437,14 @@ Error GltfImporter::writeModelNode(const cgltf_node& node, const HashMapAuto<CSt
 
 	const StringAuto modelFname = computeModelResourceFilename(*node.mesh);
 
-	ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newModelNode(\"%s\")\n", getNodeName(node).cstr()));
-	ANKI_CHECK(m_sceneFile.writeText("node:getSceneNodeBase():getModelComponent():loadModelResource(\"%s%s\")\n",
-									 m_rpath.cstr(), modelFname.cstr()));
+	ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newModelNode(\"%s\")\n", getNodeName(node).cstr()));
+	ANKI_CHECK(m_sceneFile.writeTextf("node:getSceneNodeBase():getModelComponent():loadModelResource(\"%s%s\")\n",
+									  m_rpath.cstr(), modelFname.cstr()));
 
 	if(node.skin)
 	{
-		ANKI_CHECK(m_sceneFile.writeText("node:getSceneNodeBase():getSkinComponent():loadSkeletonResource(\"%s%s\")\n",
-										 m_rpath.cstr(), computeSkeletonResourceFilename(*node.skin).cstr()));
+		ANKI_CHECK(m_sceneFile.writeTextf("node:getSceneNodeBase():getSkinComponent():loadSkeletonResource(\"%s%s\")\n",
+										  m_rpath.cstr(), computeSkeletonResourceFilename(*node.skin).cstr()));
 	}
 
 	return Error::NONE;

+ 1 - 1
AnKi/Importer/GltfImporterMaterial.cpp

@@ -336,7 +336,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl, Bool writeRayTracin
 	// Write file
 	File file;
 	ANKI_CHECK(file.open(fname.toCString(), FileOpenFlag::WRITE));
-	ANKI_CHECK(file.writeText("%s", xml.cstr()));
+	ANKI_CHECK(file.writeText(xml));
 
 	return Error::NONE;
 }

+ 1 - 1
AnKi/Renderer/IndirectDiffuseProbes.cpp

@@ -130,7 +130,7 @@ Error IndirectDiffuseProbes::initGBuffer()
 			m_tileSize * 6, m_tileSize, GBUFFER_COLOR_ATTACHMENT_PIXEL_FORMATS[0], "GI GBuffer");
 
 		// Create color RT descriptions
-		for(U i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
+		for(U32 i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
 		{
 			texinit.m_format = GBUFFER_COLOR_ATTACHMENT_PIXEL_FORMATS[i];
 			m_gbuffer.m_colorRtDescrs[i] = texinit;

+ 1 - 1
AnKi/Renderer/ProbeReflections.cpp

@@ -74,7 +74,7 @@ Error ProbeReflections::initGBuffer()
 												 GBUFFER_COLOR_ATTACHMENT_PIXEL_FORMATS[0], "CubeRefl GBuffer");
 
 		// Create color RT descriptions
-		for(U i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
+		for(U32 i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
 		{
 			texinit.m_format = GBUFFER_COLOR_ATTACHMENT_PIXEL_FORMATS[i];
 			m_gbuffer.m_colorRtDescrs[i] = texinit;

+ 1 - 1
AnKi/ShaderCompiler/MaliOfflineCompiler.cpp

@@ -312,7 +312,7 @@ Error runMaliOfflineCompiler(CString maliocExecutable, ConstWeakArray<U8> spirv,
 	StringAuto tmpDir(tmpAlloc);
 	ANKI_CHECK(getTempDirectory(tmpDir));
 	StringAuto spirvFilename(tmpAlloc);
-	spirvFilename.sprintf("%s/AnKiMaliocTmpSpirv_%llu.spv", tmpDir.cstr(), getRandom());
+	spirvFilename.sprintf("%s/AnKiMaliocTmpSpirv_%" PRIu64 ".spv", tmpDir.cstr(), getRandom());
 
 	File spirvFile;
 	ANKI_CHECK(spirvFile.open(spirvFilename, FileOpenFlag::WRITE | FileOpenFlag::BINARY));

+ 2 - 2
AnKi/ShaderCompiler/ShaderProgramParser.cpp

@@ -713,8 +713,8 @@ Error ShaderProgramParser::parseLine(CString line, CString fname, Bool& foundPra
 			// Add the guard unique for this file
 			foundPragmaOnce = true;
 			const U64 hash = fname.computeHash();
-			m_codeLines.pushBackSprintf("#ifndef _ANKI_INCL_GUARD_%llu\n"
-										"#define _ANKI_INCL_GUARD_%llu",
+			m_codeLines.pushBackSprintf("#ifndef _ANKI_INCL_GUARD_%" PRIu64 "\n"
+										"#define _ANKI_INCL_GUARD_%" PRIu64,
 										hash, hash);
 		}
 		else if(*token == "anki")

+ 24 - 4
AnKi/Util/File.cpp

@@ -336,12 +336,11 @@ Error File::write(const void* buff, PtrSize size)
 	else
 #endif
 	{
-		PtrSize writeSize = 0;
-		writeSize = std::fwrite(buff, 1, size, ANKI_CFILE);
+		const PtrSize writeSize = fwrite(buff, 1, size, ANKI_CFILE);
 
 		if(writeSize != size)
 		{
-			ANKI_UTIL_LOGE("std::fwrite() failed");
+			ANKI_UTIL_LOGE("fwrite() failed");
 			err = Error::FILE_ACCESS;
 		}
 	}
@@ -349,7 +348,7 @@ Error File::write(const void* buff, PtrSize size)
 	return err;
 }
 
-Error File::writeText(const Char* format, ...)
+Error File::writeTextf(const Char* format, ...)
 {
 	ANKI_ASSERT(m_file);
 	ANKI_ASSERT(m_flags != FileOpenFlag::NONE);
@@ -376,6 +375,27 @@ Error File::writeText(const Char* format, ...)
 	return err;
 }
 
+Error File::writeText(CString text)
+{
+	ANKI_ASSERT(m_file);
+	ANKI_ASSERT(m_flags != FileOpenFlag::NONE);
+	ANKI_ASSERT((m_flags & FileOpenFlag::WRITE) != FileOpenFlag::NONE);
+	ANKI_ASSERT((m_flags & FileOpenFlag::BINARY) == FileOpenFlag::NONE);
+
+	const PtrSize writeSize = text.getLength() + 1;
+	const PtrSize writenSize = fwrite(text.cstr(), 1, writeSize, ANKI_CFILE);
+
+	if(writeSize != writenSize)
+	{
+		ANKI_UTIL_LOGE("fwrite() failed");
+		return Error::FILE_ACCESS;
+	}
+	else
+	{
+		return Error::NONE;
+	}
+}
+
 Error File::seek(PtrSize offset, FileSeekOrigin origin)
 {
 	ANKI_ASSERT(m_file);

+ 4 - 1
AnKi/Util/File.h

@@ -103,7 +103,10 @@ public:
 
 	/// Write formated text
 	ANKI_CHECK_FORMAT(1, 2)
-	Error writeText(const Char* format, ...);
+	Error writeTextf(const Char* format, ...);
+
+	/// Write plain text.
+	Error writeText(CString text);
 
 	/// Set the position indicator to a new position.
 	/// @param offset Number of bytes to offset from origin

+ 2 - 2
AnKi/Util/Logger.cpp

@@ -284,8 +284,8 @@ void Logger::fileMessageHandler(void* pfile, const LoggerMessageInfo& info)
 {
 	File* file = reinterpret_cast<File*>(pfile);
 
-	Error err = file->writeText("[%s] %s (%s:%d %s)\n", MSG_TEXT[U(info.m_type)], info.m_msg, info.m_file, info.m_line,
-								info.m_func);
+	Error err = file->writeTextf("[%s] %s (%s:%d %s)\n", MSG_TEXT[U(info.m_type)], info.m_msg, info.m_file, info.m_line,
+								 info.m_func);
 
 	if(!err)
 	{

+ 25 - 8
AnKi/Util/String.cpp

@@ -241,15 +241,14 @@ void String::appendInternal(Allocator& alloc, const Char* str, PtrSize strLen)
 	m_data = std::move(newData);
 }
 
-String& String::sprintf(Allocator alloc, const Char* fmt, ...)
+void String::sprintf(Allocator& alloc, const Char* fmt, va_list& args)
 {
-	ANKI_ASSERT(fmt);
 	Array<Char, 512> buffer;
-	va_list args;
 
-	va_start(args, fmt);
+	va_list args2;
+	va_copy(args2, args); // vsnprintf will alter "args". Copy it case we need to call vsnprintf in the else bellow
+
 	I len = std::vsnprintf(&buffer[0], sizeof(buffer), fmt, args);
-	va_end(args);
 
 	if(len < 0)
 	{
@@ -260,9 +259,7 @@ String& String::sprintf(Allocator alloc, const Char* fmt, ...)
 		I size = len + 1;
 		m_data.create(alloc, size);
 
-		va_start(args, fmt);
-		len = std::vsnprintf(&m_data[0], size, fmt, args);
-		va_end(args);
+		len = std::vsnprintf(&m_data[0], size, fmt, args2);
 
 		ANKI_ASSERT((len + 1) == size);
 	}
@@ -272,6 +269,17 @@ String& String::sprintf(Allocator alloc, const Char* fmt, ...)
 		create(alloc, CString(&buffer[0]));
 	}
 
+	va_end(args2);
+}
+
+String& String::sprintf(Allocator alloc, const Char* fmt, ...)
+{
+	ANKI_ASSERT(fmt);
+	va_list args;
+	va_start(args, fmt);
+	sprintf(alloc, fmt, args);
+	va_end(args);
+
 	return *this;
 }
 
@@ -309,4 +317,13 @@ String& String::replaceAll(Allocator alloc, CString from, CString to)
 	return *this;
 }
 
+StringAuto& StringAuto::sprintf(const Char* fmt, ...)
+{
+	va_list args;
+	va_start(args, fmt);
+	Base::sprintf(m_alloc, fmt, args);
+	va_end(args);
+	return *this;
+}
+
 } // end namespace anki

+ 4 - 6
AnKi/Util/String.h

@@ -648,6 +648,9 @@ public:
 		});
 	}
 
+	/// Internal don't use it.
+	ANKI_INTERNAL void sprintf(Allocator& alloc, const Char* fmt, va_list& args);
+
 protected:
 	DynamicArray<Char, PtrSize> m_data;
 
@@ -811,13 +814,8 @@ public:
 	}
 
 	/// Create formated string.
-	template<typename... TArgs>
 	ANKI_CHECK_FORMAT(1, 2)
-	StringAuto& sprintf(const Char* fmt, TArgs... args)
-	{
-		Base::sprintf(m_alloc, fmt, args...);
-		return *this;
-	}
+	StringAuto& sprintf(const Char* fmt, ...);
 
 	/// Convert a number to a string.
 	template<typename TNumber>

+ 49 - 0
AnKi/Util/StringList.cpp

@@ -4,6 +4,7 @@
 // http://www.anki3d.org/LICENSE
 
 #include <AnKi/Util/StringList.h>
+#include <cstdarg>
 
 namespace anki {
 
@@ -146,4 +147,52 @@ I StringList::getIndexOf(const CString& value) const
 	return (pos == Base::getSize()) ? -1 : pos;
 }
 
+void StringList::pushBackSprintf(Allocator alloc, const Char* fmt, ...)
+{
+	String str;
+	va_list args;
+	va_start(args, fmt);
+	str.sprintf(alloc, fmt, args);
+	va_end(args);
+
+	Base::emplaceBack(alloc);
+	Base::getBack() = std::move(str);
+}
+
+void StringList::pushFrontSprintf(Allocator alloc, const Char* fmt, ...)
+{
+	String str;
+	va_list args;
+	va_start(args, fmt);
+	str.sprintf(alloc, fmt, args);
+	va_end(args);
+
+	Base::emplaceFront(alloc);
+	Base::getFront() = std::move(str);
+}
+
+void StringListAuto::pushBackSprintf(const Char* fmt, ...)
+{
+	String str;
+	va_list args;
+	va_start(args, fmt);
+	str.sprintf(m_alloc, fmt, args);
+	va_end(args);
+
+	Base::emplaceBack(m_alloc);
+	Base::getBack() = std::move(str);
+}
+
+void StringListAuto::pushFrontSprintf(const Char* fmt, ...)
+{
+	String str;
+	va_list args;
+	va_start(args, fmt);
+	str.sprintf(m_alloc, fmt, args);
+	va_end(args);
+
+	Base::emplaceFront(m_alloc);
+	Base::getFront() = std::move(str);
+}
+
 } // end namespace anki

+ 6 - 28
AnKi/Util/StringList.h

@@ -53,27 +53,12 @@ public:
 	void sortAll(const Sort method = Sort::ASCENDING);
 
 	/// Push at the end of the list a formated string.
-	template<typename... TArgs>
 	ANKI_CHECK_FORMAT(2, 3)
-	void pushBackSprintf(Allocator alloc, const Char* fmt, TArgs... args)
-	{
-		String str;
-		str.sprintf(alloc, fmt, args...);
-
-		Base::emplaceBack(alloc);
-		Base::getBack() = std::move(str);
-	}
+	void pushBackSprintf(Allocator alloc, const Char* fmt, ...);
 
 	/// Push at the beginning of the list a formated string.
-	template<typename... TArgs>
-	void pushFrontSprintf(Allocator alloc, CString fmt, TArgs... args)
-	{
-		String str;
-		str.sprintf(alloc, fmt, args...);
-
-		Base::emplaceFront(alloc);
-		Base::getFront() = std::move(str);
-	}
+	ANKI_CHECK_FORMAT(2, 3)
+	void pushFrontSprintf(Allocator alloc, const Char* fmt, ...);
 
 	/// Push back plain CString.
 	void pushBack(Allocator alloc, CString cstr)
@@ -139,19 +124,12 @@ public:
 	}
 
 	/// Push at the end of the list a formated string
-	template<typename... TArgs>
 	ANKI_CHECK_FORMAT(1, 2)
-	void pushBackSprintf(const Char* fmt, TArgs... args)
-	{
-		Base::pushBackSprintf(m_alloc, fmt, args...);
-	}
+	void pushBackSprintf(const Char* fmt, ...);
 
 	/// Push at the beginning of the list a formated string
-	template<typename... TArgs>
-	void pushFrontSprintf(CString fmt, TArgs... args)
-	{
-		Base::pushFrontSprintf(m_alloc, fmt, args...);
-	}
+	ANKI_CHECK_FORMAT(1, 2)
+	void pushFrontSprintf(const Char* fmt, ...);
 
 	/// Push back plain CString.
 	void pushBack(CString cstr)

+ 3 - 3
Samples/PhysicsPlayground/Main.cpp

@@ -153,7 +153,7 @@ Error MyApp::sampleExtraInit()
 		const U LINKS = 5;
 
 		BodyNode* prevBody = nullptr;
-		for(U i = 0; i < LINKS; ++i)
+		for(U32 i = 0; i < LINKS; ++i)
 		{
 			ModelNode* monkey;
 			ANKI_CHECK(getSceneGraph().newSceneNode<ModelNode>(
@@ -290,7 +290,7 @@ Error MyApp::userMainLoop(Bool& quit, [[maybe_unused]] Second elapsedTime)
 	{
 		ANKI_LOGI("Firing a monkey");
 
-		static U instance = 0;
+		static U32 instance = 0;
 
 		Transform camTrf =
 			getSceneGraph().getActiveCameraNode().getFirstComponentOfType<MoveComponent>().getWorldTransform();
@@ -347,7 +347,7 @@ Error MyApp::userMainLoop(Bool& quit, [[maybe_unused]] Second elapsedTime)
 			Transform trf(ray.m_hitPosition.xyz0(), rot, 1.0f);
 
 			// Create an obj
-			static U id = 0;
+			static U32 id = 0;
 			ModelNode* monkey;
 			ANKI_CHECK(getSceneGraph().newSceneNode(
 				StringAuto(getSceneGraph().getFrameAllocator()).sprintf("decal%u", id++).toCString(), monkey));

+ 2 - 2
Tests/ShaderCompiler/ShaderProgramCompiler.cpp

@@ -78,7 +78,7 @@ void main()
 	{
 		File file;
 		ANKI_TEST_EXPECT_NO_ERR(file.open("test.glslp", FileOpenFlag::WRITE));
-		ANKI_TEST_EXPECT_NO_ERR(file.writeText("%s", sourceCode.cstr()));
+		ANKI_TEST_EXPECT_NO_ERR(file.writeText(sourceCode));
 	}
 
 	class Fsystem : public ShaderProgramFilesystemInterface
@@ -275,7 +275,7 @@ void main()
 	{
 		File file;
 		ANKI_TEST_EXPECT_NO_ERR(file.open("test.glslp", FileOpenFlag::WRITE));
-		ANKI_TEST_EXPECT_NO_ERR(file.writeText("%s", sourceCode.cstr()));
+		ANKI_TEST_EXPECT_NO_ERR(file.writeText(sourceCode));
 	}
 
 	class Fsystem : public ShaderProgramFilesystemInterface

+ 1 - 1
Tests/Util/Process.cpp

@@ -16,7 +16,7 @@ static void createBashScript(CString code)
 	File file;
 
 	ANKI_TEST_EXPECT_NO_ERR(file.open("process_test.sh", FileOpenFlag::WRITE));
-	ANKI_TEST_EXPECT_NO_ERR(file.writeText("#!/bin/bash\n%s\n", code.cstr()));
+	ANKI_TEST_EXPECT_NO_ERR(file.writeTextf("#!/bin/bash\n%s\n", code.cstr()));
 }
 
 } // end namespace anki

+ 1 - 0
ThirdParty/Glslang/SPIRV/GlslangToSpv.cpp

@@ -4090,6 +4090,7 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
     // Name and decorate the non-hidden members
     int offset = -1;
     int locationOffset = 0;  // for use within the members of this struct
+    (void)locationOffset;
     bool memberLocationInvalid = type.isArrayOfArrays() ||
         (type.isArray() && (type.getQualifier().isArrayedIo(glslangIntermediate->getStage()) == false));
     for (int i = 0; i < (int)glslangMembers->size(); i++) {

+ 1 - 0
ThirdParty/Sdl2/src/video/yuv2rgb/yuv_rgb_std_func.h

@@ -107,6 +107,7 @@ void STD_FUNCTION_NAME(
         uint8_t *rgb_ptr2=RGB+(y+1)*RGB_stride;
 		#endif
 
+		(void)y_ptr2;
 		for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
 		{
 			// Compute U and V contributions, common to the four pixels

+ 2 - 2
Tools/GltfImporter/Main.cpp

@@ -63,7 +63,7 @@ static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 				}
 				else
 				{
-					info.m_texRpath.sprintf("");
+					info.m_texRpath.create("");
 				}
 			}
 			else
@@ -88,7 +88,7 @@ static Error parseCommandLineArgs(int argc, char** argv, CmdLineArgs& info)
 				}
 				else
 				{
-					info.m_rpath.sprintf("");
+					info.m_rpath.create("");
 				}
 			}
 			else

+ 2 - 3
Tools/Image/ImageViewerMain.cpp

@@ -124,8 +124,7 @@ private:
 			StringListAuto mipLabels(getFrameAllocator());
 			for(U32 mip = 0; mip < grTex.getMipmapCount(); ++mip)
 			{
-				mipLabels.pushBackSprintf("Mip %u (%llu x %llu)", mip, grTex.getWidth() >> mip,
-										  grTex.getHeight() >> mip);
+				mipLabels.pushBackSprintf("Mip %u (%u x %u)", mip, grTex.getWidth() >> mip, grTex.getHeight() >> mip);
 			}
 
 			const U32 lastCrntMip = m_crntMip;
@@ -293,7 +292,7 @@ public:
 
 		// Change window name
 		StringAuto title(alloc);
-		title.sprintf("%s %llu x %llu Mips %u Format %s", argv[1], image->getWidth(), image->getHeight(),
+		title.sprintf("%s %u x %u Mips %u Format %s", argv[1], image->getWidth(), image->getHeight(),
 					  image->getTexture()->getMipmapCount(), getFormatInfo(image->getTexture()->getFormat()).m_name);
 		getWindow().setWindowTitle(title);