소스 검색

Do some work on the material export. Add compile-time checking of format in the logger

Panagiotis Christopoulos Charitos 5 년 전
부모
커밋
91ae697ba1

+ 1 - 1
src/anki/core/App.cpp

@@ -357,7 +357,7 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 	}
 	}
 #endif
 #endif
 
 
-	ANKI_CORE_LOGI("Number of main threads: %u", U(config.getNumberU32("core_mainThreadCount")));
+	ANKI_CORE_LOGI("Number of main threads: %u", config.getNumberU32("core_mainThreadCount"));
 
 
 	//
 	//
 	// Core tracer
 	// Core tracer

+ 1 - 1
src/anki/core/StagingGpuMemoryManager.cpp

@@ -70,7 +70,7 @@ void* StagingGpuMemoryManager::allocateFrame(PtrSize size, StagingGpuMemoryType
 	Error err = buff.m_alloc.allocate(size, token.m_offset);
 	Error err = buff.m_alloc.allocate(size, token.m_offset);
 	if(err)
 	if(err)
 	{
 	{
-		ANKI_CORE_LOGF("Out of staging GPU memory. Usage: %u", usage);
+		ANKI_CORE_LOGF("Out of staging GPU memory. Usage: %u", U32(usage));
 	}
 	}
 
 
 	token.m_buffer = buff.m_buff;
 	token.m_buffer = buff.m_buff;

+ 2 - 2
src/anki/gr/vulkan/CommandBufferImpl.cpp

@@ -234,14 +234,14 @@ void CommandBufferImpl::endRecording()
 	{
 	{
 		if(m_commandCount > COMMAND_BUFFER_SMALL_BATCH_MAX_COMMANDS * 4)
 		if(m_commandCount > COMMAND_BUFFER_SMALL_BATCH_MAX_COMMANDS * 4)
 		{
 		{
-			ANKI_VK_LOGW("Command buffer has too many commands: %u", U(m_commandCount));
+			ANKI_VK_LOGW("Command buffer has too many commands: %u", m_commandCount);
 		}
 		}
 	}
 	}
 	else
 	else
 	{
 	{
 		if(m_commandCount <= COMMAND_BUFFER_SMALL_BATCH_MAX_COMMANDS / 4)
 		if(m_commandCount <= COMMAND_BUFFER_SMALL_BATCH_MAX_COMMANDS / 4)
 		{
 		{
-			ANKI_VK_LOGW("Command buffer has too few commands: %u", U(m_commandCount));
+			ANKI_VK_LOGW("Command buffer has too few commands: %u", m_commandCount);
 		}
 		}
 	}
 	}
 #endif
 #endif

+ 1 - 1
src/anki/gr/vulkan/GpuMemoryManager.cpp

@@ -187,7 +187,7 @@ void GpuMemoryManager::init(VkPhysicalDevice pdev, VkDevice dev, GrAllocator<U8>
 	ANKI_VK_LOGI("Initializing memory manager");
 	ANKI_VK_LOGI("Initializing memory manager");
 	for(const ClassInf& c : CLASSES)
 	for(const ClassInf& c : CLASSES)
 	{
 	{
-		ANKI_VK_LOGI("\tGPU mem class. Chunk size: %u, slotSize: %u, allocsPerChunk %u",
+		ANKI_VK_LOGI("\tGPU mem class. Chunk size: %lu, slotSize: %lu, allocsPerChunk %lu",
 			c.m_chunkSize,
 			c.m_chunkSize,
 			c.m_slotSize,
 			c.m_slotSize,
 			c.m_chunkSize / c.m_slotSize);
 			c.m_chunkSize / c.m_slotSize);

+ 1 - 1
src/anki/gr/vulkan/TextureImpl.cpp

@@ -263,7 +263,7 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 
 
 	if(!supported)
 	if(!supported)
 	{
 	{
-		ANKI_VK_LOGE("Unsupported texture format: %u", U(init.m_format));
+		ANKI_VK_LOGE("Unsupported texture format: %u", U32(init.m_format));
 		return Error::FUNCTION_FAILED;
 		return Error::FUNCTION_FAILED;
 	}
 	}
 
 

+ 5 - 5
src/anki/importer/GltfImporter.cpp

@@ -345,7 +345,7 @@ StringAuto GltfImporter::getNodeName(const cgltf_node& node)
 	return out;
 	return out;
 }
 }
 
 
-Error GltfImporter::parseArrayOfNumbers(CString str, DynamicArrayAuto<F64>& out, const U* expectedArraySize)
+Error GltfImporter::parseArrayOfNumbers(CString str, DynamicArrayAuto<F64>& out, const U32* expectedArraySize)
 {
 {
 	StringListAuto list(m_alloc);
 	StringListAuto list(m_alloc);
 	list.splitString(str, ' ');
 	list.splitString(str, ' ');
@@ -1126,7 +1126,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 		if(lsSpriteSize != extras.getEnd())
 		if(lsSpriteSize != extras.getEnd())
 		{
 		{
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			DynamicArrayAuto<F64> numbers(m_alloc);
-			const U count = 2;
+			const U32 count = 2;
 			ANKI_CHECK(parseArrayOfNumbers(lsSpriteSize->toCString(), numbers, &count));
 			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.writeText("lfcomp:setFirstFlareSize(Vec2.new(%f, %f))\n", numbers[0], numbers[1]));
@@ -1135,7 +1135,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 		if(lsColor != extras.getEnd())
 		if(lsColor != extras.getEnd())
 		{
 		{
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			DynamicArrayAuto<F64> numbers(m_alloc);
-			const U count = 4;
+			const U32 count = 4;
 			ANKI_CHECK(parseArrayOfNumbers(lsColor->toCString(), numbers, &count));
 			ANKI_CHECK(parseArrayOfNumbers(lsColor->toCString(), numbers, &count));
 
 
 			ANKI_CHECK(m_sceneFile.writeText("lfcomp:setColorMultiplier(Vec4.new(%f, %f, %f, %f))\n",
 			ANKI_CHECK(m_sceneFile.writeText("lfcomp:setColorMultiplier(Vec4.new(%f, %f, %f, %f))\n",
@@ -1155,7 +1155,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 		if(lightEventIntensity != extras.getEnd())
 		if(lightEventIntensity != extras.getEnd())
 		{
 		{
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			DynamicArrayAuto<F64> numbers(m_alloc);
-			const U count = 4;
+			const U32 count = 4;
 			ANKI_CHECK(parseArrayOfNumbers(lightEventIntensity->toCString(), numbers, &count));
 			ANKI_CHECK(parseArrayOfNumbers(lightEventIntensity->toCString(), numbers, &count));
 			ANKI_CHECK(m_sceneFile.writeText("event:setIntensityMultiplier(Vec4.new(%f, %f, %f, %f))\n",
 			ANKI_CHECK(m_sceneFile.writeText("event:setIntensityMultiplier(Vec4.new(%f, %f, %f, %f))\n",
 				numbers[0],
 				numbers[0],
@@ -1167,7 +1167,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 		if(lightEventFrequency != extras.getEnd())
 		if(lightEventFrequency != extras.getEnd())
 		{
 		{
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			DynamicArrayAuto<F64> numbers(m_alloc);
-			const U count = 2;
+			const U32 count = 2;
 			ANKI_CHECK(parseArrayOfNumbers(lightEventFrequency->toCString(), numbers, &count));
 			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.writeText("event:setFrequency(%f, %f)\n", numbers[0], numbers[1]));
 		}
 		}

+ 1 - 1
src/anki/importer/GltfImporter.h

@@ -76,7 +76,7 @@ private:
 	// Misc
 	// Misc
 	ANKI_USE_RESULT Error getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringAuto>& out);
 	ANKI_USE_RESULT Error getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringAuto>& out);
 	ANKI_USE_RESULT Error parseArrayOfNumbers(
 	ANKI_USE_RESULT Error parseArrayOfNumbers(
-		CString str, DynamicArrayAuto<F64>& out, const U* expectedArraySize = nullptr);
+		CString str, DynamicArrayAuto<F64>& out, const U32* expectedArraySize = nullptr);
 	void populateNodePtrToIdx();
 	void populateNodePtrToIdx();
 	void populateNodePtrToIdxInternal(const cgltf_node& node, U32& idx);
 	void populateNodePtrToIdxInternal(const cgltf_node& node, U32& idx);
 	StringAuto getNodeName(const cgltf_node& node);
 	StringAuto getNodeName(const cgltf_node& node);

+ 15 - 21
src/anki/importer/GltfImporterMaterial.cpp

@@ -11,7 +11,7 @@ namespace anki
 
 
 const char* MATERIAL_TEMPLATE = R"(<!-- This file is auto generated by ImporterMaterial.cpp -->
 const char* MATERIAL_TEMPLATE = R"(<!-- This file is auto generated by ImporterMaterial.cpp -->
 <material shaderProgram="shaders/GBufferGeneric.glslp">
 <material shaderProgram="shaders/GBufferGeneric.glslp">
-	<mutators>
+	<mutation>
 		<mutator name="DIFFUSE_TEX" value="%diffTexMutator%"/>
 		<mutator name="DIFFUSE_TEX" value="%diffTexMutator%"/>
 		<mutator name="SPECULAR_TEX" value="%specTexMutator%"/>
 		<mutator name="SPECULAR_TEX" value="%specTexMutator%"/>
 		<mutator name="ROUGHNESS_TEX" value="%roughnessTexMutator%"/>
 		<mutator name="ROUGHNESS_TEX" value="%roughnessTexMutator%"/>
@@ -19,13 +19,9 @@ const char* MATERIAL_TEMPLATE = R"(<!-- This file is auto generated by ImporterM
 		<mutator name="NORMAL_TEX" value="%normalTexMutator%"/>
 		<mutator name="NORMAL_TEX" value="%normalTexMutator%"/>
 		<mutator name="PARALLAX" value="%parallaxMutator%"/>
 		<mutator name="PARALLAX" value="%parallaxMutator%"/>
 		<mutator name="EMISSIVE_TEX" value="%emissiveTexMutator%"/>
 		<mutator name="EMISSIVE_TEX" value="%emissiveTexMutator%"/>
-	</mutators>
+	</mutation>
 
 
 	<inputs>
 	<inputs>
-		<input shaderInput="mvp" builtin="MODEL_VIEW_PROJECTION_MATRIX"/>
-		<input shaderInput="prevMvp" builtin="PREVIOUS_MODEL_VIEW_PROJECTION_MATRIX"/>
-		<input shaderInput="rotationMat" builtin="ROTATION_MATRIX"/>
-		<input shaderInput="globalSampler" builtin="GLOBAL_SAMPLER"/>
 		%parallaxInput%
 		%parallaxInput%
 
 
 		%diff%
 		%diff%
@@ -119,7 +115,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.base_color_texture).cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.base_color_texture).cstr());
 
 
 		xml.replaceAll(
 		xml.replaceAll(
-			"%diff%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"diffTex\" value=\"%s\"/>", uri.cstr()));
+			"%diff%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_diffTex\" value=\"%s\"/>", uri.cstr()));
 		xml.replaceAll("%diffTexMutator%", "1");
 		xml.replaceAll("%diffTexMutator%", "1");
 	}
 	}
 	else
 	else
@@ -128,7 +124,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 
 
 		xml.replaceAll("%diff%",
 		xml.replaceAll("%diff%",
 			StringAuto{m_alloc}.sprintf(
 			StringAuto{m_alloc}.sprintf(
-				"<input shaderInput=\"diffColor\" value=\"%f %f %f\"/>", diffCol[0], diffCol[1], diffCol[2]));
+				"<input shaderVar=\"m_diffColor\" value=\"%f %f %f\"/>", diffCol[0], diffCol[1], diffCol[2]));
 
 
 		xml.replaceAll("%diffTexMutator%", "0");
 		xml.replaceAll("%diffTexMutator%", "0");
 	}
 	}
@@ -161,7 +157,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 
 
 		xml.replaceAll("%spec%",
 		xml.replaceAll("%spec%",
 			StringAuto{m_alloc}.sprintf(
 			StringAuto{m_alloc}.sprintf(
-				"<input shaderInput=\"specColor\" value=\"%f %f %f\"/>", specular.x(), specular.y(), specular.z()));
+				"<input shaderVar=\"m_specColor\" value=\"%f %f %f\"/>", specular.x(), specular.y(), specular.z()));
 
 
 		xml.replaceAll("%specTexMutator%", "0");
 		xml.replaceAll("%specTexMutator%", "0");
 	}
 	}
@@ -183,7 +179,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 			"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
 			"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
 
 
 		xml.replaceAll("%roughness%",
 		xml.replaceAll("%roughness%",
-			StringAuto{m_alloc}.sprintf("<input shaderInput=\"roughnessTex\" value=\"%s\"/>", uri.cstr()));
+			StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_roughnessTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%roughnessTexMutator%", "1");
 		xml.replaceAll("%roughnessTexMutator%", "1");
 	}
 	}
@@ -194,7 +190,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 								  : mtl.pbr_metallic_roughness.roughness_factor;
 								  : mtl.pbr_metallic_roughness.roughness_factor;
 
 
 		xml.replaceAll(
 		xml.replaceAll(
-			"%roughness%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"roughness\" value=\"%f\"/>", roughness));
+			"%roughness%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_roughness\" value=\"%f\"/>", roughness));
 
 
 		xml.replaceAll("%roughnessTexMutator%", "0");
 		xml.replaceAll("%roughnessTexMutator%", "0");
 	}
 	}
@@ -207,7 +203,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 			"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
 			"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
 
 
 		xml.replaceAll(
 		xml.replaceAll(
-			"%metallic%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"metallicTex\" value=\"%s\"/>", uri.cstr()));
+			"%metallic%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_metallicTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%metalTexMutator%", "1");
 		xml.replaceAll("%metalTexMutator%", "1");
 	}
 	}
@@ -218,7 +214,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 								  : mtl.pbr_metallic_roughness.metallic_factor;
 								  : mtl.pbr_metallic_roughness.metallic_factor;
 
 
 		xml.replaceAll(
 		xml.replaceAll(
-			"%metallic%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"metallic\" value=\"%f\"/>", metalines));
+			"%metallic%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_metallic\" value=\"%f\"/>", metalines));
 
 
 		xml.replaceAll("%metalTexMutator%", "0");
 		xml.replaceAll("%metalTexMutator%", "0");
 	}
 	}
@@ -230,7 +226,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.normal_texture).cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.normal_texture).cstr());
 
 
 		xml.replaceAll(
 		xml.replaceAll(
-			"%normal%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"normalTex\" value=\"%s\"/>", uri.cstr()));
+			"%normal%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_normalTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%normalTexMutator%", "1");
 		xml.replaceAll("%normalTexMutator%", "1");
 	}
 	}
@@ -247,7 +243,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.emissive_texture).cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.emissive_texture).cstr());
 
 
 		xml.replaceAll(
 		xml.replaceAll(
-			"%emission%", StringAuto{m_alloc}.sprintf("<input shaderInput=\"emissiveTex\" value=\"%s\"/>", uri.cstr()));
+			"%emission%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_emissiveTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%emissiveTexMutator%", "1");
 		xml.replaceAll("%emissiveTexMutator%", "1");
 	}
 	}
@@ -256,7 +252,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		const F32* emissionCol = &mtl.emissive_factor[0];
 		const F32* emissionCol = &mtl.emissive_factor[0];
 
 
 		xml.replaceAll("%emission%",
 		xml.replaceAll("%emission%",
-			StringAuto{m_alloc}.sprintf("<input shaderInput=\"emission\" value=\"%f %f %f\"/>",
+			StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_emission\" value=\"%f %f %f\"/>",
 				emissionCol[0],
 				emissionCol[0],
 				emissionCol[1],
 				emissionCol[1],
 				emissionCol[2]));
 				emissionCol[2]));
@@ -278,7 +274,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		}
 		}
 
 
 		xml.replaceAll("%subsurface%",
 		xml.replaceAll("%subsurface%",
-			StringAuto{m_alloc}.sprintf("<input shaderInput=\"subsurface\" value=\"%f\"/>", subsurface));
+			StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_subsurface\" value=\"%f\"/>", subsurface));
 	}
 	}
 
 
 	// Height texture
 	// Height texture
@@ -289,12 +285,10 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		uri.sprintf("%s%s", m_texrpath.cstr(), it->cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), it->cstr());
 
 
 		xml.replaceAll("%height%",
 		xml.replaceAll("%height%",
-			StringAuto{m_alloc}.sprintf("<input shaderInput=\"heightTex\" value=\"%s\" \"/>\n"
-										"\t\t<input shaderInput=\"heightMapScale\" value=\"0.05\"/>",
+			StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_heightTex\" value=\"%s\" \"/>\n"
+										"\t\t<input shaderVar=\"m_heightmapScale\" value=\"0.05\"/>",
 				uri.cstr()));
 				uri.cstr()));
 
 
-		xml.replaceAll("%parallaxInput%", "<input shaderInput=\"modelViewMat\" builtin=\"MODEL_VIEW_MATRIX\"/>");
-
 		xml.replaceAll("%parallaxMutator%", "1");
 		xml.replaceAll("%parallaxMutator%", "1");
 	}
 	}
 	else
 	else

+ 1 - 1
src/anki/importer/GltfImporterMesh.cpp

@@ -412,7 +412,7 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 			ANKI_ASSERT(primitive->indices);
 			ANKI_ASSERT(primitive->indices);
 			if(primitive->indices->count == 0 || (primitive->indices->count % 3) != 0)
 			if(primitive->indices->count == 0 || (primitive->indices->count % 3) != 0)
 			{
 			{
-				ANKI_GLTF_LOGE("Incorect index count: %d", primitive->indices->count);
+				ANKI_GLTF_LOGE("Incorect index count: %lu", primitive->indices->count);
 				return Error::USER_DATA;
 				return Error::USER_DATA;
 			}
 			}
 			submesh.m_indices.create(U32(primitive->indices->count));
 			submesh.m_indices.create(U32(primitive->indices->count));

+ 1 - 1
src/anki/physics/PhysicsDrawer.h

@@ -55,7 +55,7 @@ private:
 
 
 		void reportErrorWarning(const char* warningString) override
 		void reportErrorWarning(const char* warningString) override
 		{
 		{
-			ANKI_PHYS_LOGW(warningString);
+			ANKI_PHYS_LOGW("%s", warningString);
 		}
 		}
 
 
 		void draw3dText(const btVector3& location, const char* textString) override
 		void draw3dText(const btVector3& location, const char* textString) override

+ 1 - 1
src/anki/renderer/DownscaleBlur.cpp

@@ -29,7 +29,7 @@ Error DownscaleBlur::init(const ConfigSet& cfg)
 Error DownscaleBlur::initInternal(const ConfigSet&)
 Error DownscaleBlur::initInternal(const ConfigSet&)
 {
 {
 	m_passCount = computeMaxMipmapCount2d(m_r->getWidth(), m_r->getHeight(), DOWNSCALE_BLUR_DOWN_TO) - 1;
 	m_passCount = computeMaxMipmapCount2d(m_r->getWidth(), m_r->getHeight(), DOWNSCALE_BLUR_DOWN_TO) - 1;
-	ANKI_R_LOGI("Initializing dowscale blur (passCount: %u)", U(m_passCount));
+	ANKI_R_LOGI("Initializing dowscale blur (passCount: %u)", m_passCount);
 
 
 	// Create the miped texture
 	// Create the miped texture
 	TextureInitInfo texinit = m_r->create2DRenderTargetDescription(
 	TextureInitInfo texinit = m_r->create2DRenderTargetDescription(

+ 3 - 3
src/anki/resource/MaterialResource.cpp

@@ -184,7 +184,7 @@ Error MaterialResource::parseMutators(XmlElement mutatorsEl)
 	{
 	{
 		if(m_passMutator->getValues().getSize() != U32(Pass::COUNT))
 		if(m_passMutator->getValues().getSize() != U32(Pass::COUNT))
 		{
 		{
-			ANKI_RESOURCE_LOGE("Mutator PASS should have %u values in the program", U(Pass::COUNT));
+			ANKI_RESOURCE_LOGE("Mutator PASS should have %u values in the program", U32(Pass::COUNT));
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
@@ -211,7 +211,7 @@ Error MaterialResource::parseMutators(XmlElement mutatorsEl)
 	{
 	{
 		if(m_lodMutator->getValues().getSize() > MAX_LOD_COUNT)
 		if(m_lodMutator->getValues().getSize() > MAX_LOD_COUNT)
 		{
 		{
-			ANKI_RESOURCE_LOGE("Mutator LOD should have at least %u values in the program", U(MAX_LOD_COUNT));
+			ANKI_RESOURCE_LOGE("Mutator LOD should have at least %u values in the program", U32(MAX_LOD_COUNT));
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
@@ -324,7 +324,7 @@ Error MaterialResource::parseInputs(XmlElement inputsEl, Bool async)
 
 
 		if(!foundVar->acceptAllMutations(m_mutations))
 		if(!foundVar->acceptAllMutations(m_mutations))
 		{
 		{
-			ANKI_RESOURCE_LOGE("Variable \"%s\" is not needed by the material's mutations");
+			ANKI_RESOURCE_LOGE("Variable \"%s\" is not needed by the material's mutations", varName.cstr());
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 

+ 83 - 51
src/anki/resource/MaterialResource2.cpp

@@ -11,6 +11,9 @@
 namespace anki
 namespace anki
 {
 {
 
 
+static const Array<CString, U32(BuiltinMutatorId2::COUNT)> BUILTIN_MUTATOR_NAMES = {
+	{"NONE", "ANKI_INSTANCE_COUNT", "ANKI_PASS", "ANKI_LOD", "ANKI_BONES", "ANKI_VELOCITY"}};
+
 class BuiltinVarInfo
 class BuiltinVarInfo
 {
 {
 public:
 public:
@@ -195,10 +198,23 @@ Error MaterialResource2::parseMutators(XmlElement mutatorsEl)
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
-		if(mutatorName == "ANKI_INSTANCE_COUNT" || mutatorName == "ANKI_PASS" || mutatorName == "ANKI_LOD"
-			|| mutatorName == "ANKI_BONES" || mutatorName == "ANKI_VELOCITY")
+		for(BuiltinMutatorId2 id : EnumIterable<BuiltinMutatorId2>())
+		{
+			if(id == BuiltinMutatorId2::NONE)
+			{
+				continue;
+			}
+
+			if(mutatorName = BUILTIN_MUTATOR_NAMES[id])
+			{
+				ANKI_RESOURCE_LOGE("Cannot list builtin mutator: %s", mutatorName.cstr());
+				return Error::USER_DATA;
+			}
+		}
+
+		if(mutatorName.find("ANKI_") == 0)
 		{
 		{
-			ANKI_RESOURCE_LOGE("Cannot list builtin mutator \"%s\"", &mutatorName[0]);
+			ANKI_RESOURCE_LOGE("Mutators can't start with ANKI_: %s", mutatorName.cstr());
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
@@ -232,20 +248,24 @@ Error MaterialResource2::parseMutators(XmlElement mutatorsEl)
 	//
 	//
 	U builtinMutatorCount = 0;
 	U builtinMutatorCount = 0;
 
 
-	m_instancingMutator = m_prog->tryFindMutator("ANKI_INSTANCE_COUNT");
-	if(m_instancingMutator)
+	m_builtinMutators[BuiltinMutatorId2::INSTANCE_COUNT] =
+		m_prog->tryFindMutator(BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::INSTANCE_COUNT]);
+	if(m_builtinMutators[BuiltinMutatorId2::INSTANCE_COUNT])
 	{
 	{
-		if(m_instancingMutator->m_values.getSize() != MAX_INSTANCE_GROUPS)
+		if(m_builtinMutators[BuiltinMutatorId2::INSTANCE_COUNT]->m_values.getSize() != MAX_INSTANCE_GROUPS)
 		{
 		{
-			ANKI_RESOURCE_LOGE("Mutator ANKI_INSTANCE_COUNT should have %u values in the program", MAX_INSTANCE_GROUPS);
+			ANKI_RESOURCE_LOGE("Mutator %s should have %u values in the program",
+				BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::INSTANCE_COUNT].cstr(),
+				MAX_INSTANCE_GROUPS);
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
 		for(U32 i = 0; i < MAX_INSTANCE_GROUPS; ++i)
 		for(U32 i = 0; i < MAX_INSTANCE_GROUPS; ++i)
 		{
 		{
-			if(m_instancingMutator->m_values[i] != (1 << i))
+			if(m_builtinMutators[BuiltinMutatorId2::INSTANCE_COUNT]->m_values[i] != (1 << i))
 			{
 			{
-				ANKI_RESOURCE_LOGE("Values of the ANKI_INSTANCE_COUNT mutator in the program are not the expected");
+				ANKI_RESOURCE_LOGE("Values of the %s mutator in the program are not the expected",
+					BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::INSTANCE_COUNT].cstr());
 				return Error::USER_DATA;
 				return Error::USER_DATA;
 			}
 			}
 		}
 		}
@@ -253,20 +273,23 @@ Error MaterialResource2::parseMutators(XmlElement mutatorsEl)
 		++builtinMutatorCount;
 		++builtinMutatorCount;
 	}
 	}
 
 
-	m_passMutator = m_prog->tryFindMutator("ANKI_PASS");
-	if(m_passMutator)
+	m_builtinMutators[BuiltinMutatorId2::PASS] = m_prog->tryFindMutator(BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::PASS]);
+	if(m_builtinMutators[BuiltinMutatorId2::PASS])
 	{
 	{
-		if(m_passMutator->m_values.getSize() != U32(Pass::COUNT))
+		if(m_builtinMutators[BuiltinMutatorId2::PASS]->m_values.getSize() != U32(Pass::COUNT))
 		{
 		{
-			ANKI_RESOURCE_LOGE("Mutator ANKI_PASS should have %u values in the program", U(Pass::COUNT));
+			ANKI_RESOURCE_LOGE("Mutator %s should have %u values in the program",
+				BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::PASS].cstr(),
+				U32(Pass::COUNT));
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
 		for(U32 i = 0; i < U(Pass::COUNT); ++i)
 		for(U32 i = 0; i < U(Pass::COUNT); ++i)
 		{
 		{
-			if(m_passMutator->m_values[i] != I(i))
+			if(m_builtinMutators[BuiltinMutatorId2::PASS]->m_values[i] != I(i))
 			{
 			{
-				ANKI_RESOURCE_LOGE("Values of the ANKI_PASS mutator in the program are not the expected");
+				ANKI_RESOURCE_LOGE("Values of the %s mutator in the program are not the expected",
+					BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::PASS].cstr());
 				return Error::USER_DATA;
 				return Error::USER_DATA;
 			}
 			}
 		}
 		}
@@ -274,48 +297,54 @@ Error MaterialResource2::parseMutators(XmlElement mutatorsEl)
 		++builtinMutatorCount;
 		++builtinMutatorCount;
 	}
 	}
 
 
-	if(!m_forwardShading && !m_passMutator)
+	if(!m_forwardShading && !m_builtinMutators[BuiltinMutatorId2::PASS])
 	{
 	{
-		ANKI_RESOURCE_LOGE("ANKI_PASS mutator is required");
+		ANKI_RESOURCE_LOGE("%s mutator is required", BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::PASS].cstr());
 		return Error::USER_DATA;
 		return Error::USER_DATA;
 	}
 	}
 
 
-	m_lodMutator = m_prog->tryFindMutator("ANKI_LOD");
-	if(m_lodMutator)
+	m_builtinMutators[BuiltinMutatorId2::LOD] = m_prog->tryFindMutator(BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::LOD]);
+	if(m_builtinMutators[BuiltinMutatorId2::LOD])
 	{
 	{
-		if(m_lodMutator->m_values.getSize() > MAX_LOD_COUNT)
+		if(m_builtinMutators[BuiltinMutatorId2::LOD]->m_values.getSize() > MAX_LOD_COUNT)
 		{
 		{
-			ANKI_RESOURCE_LOGE("Mutator ANKI_LOD should have at least %u values in the program", U(MAX_LOD_COUNT));
+			ANKI_RESOURCE_LOGE("Mutator %s should have at least %u values in the program",
+				BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::LOD].cstr(),
+				U32(MAX_LOD_COUNT));
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
-		for(U32 i = 0; i < m_lodMutator->m_values.getSize(); ++i)
+		for(U32 i = 0; i < m_builtinMutators[BuiltinMutatorId2::LOD]->m_values.getSize(); ++i)
 		{
 		{
-			if(m_lodMutator->m_values[i] != I(i))
+			if(m_builtinMutators[BuiltinMutatorId2::LOD]->m_values[i] != I(i))
 			{
 			{
-				ANKI_RESOURCE_LOGE("Values of the ANKI_LOD mutator in the program are not the expected");
+				ANKI_RESOURCE_LOGE("Values of the %s mutator in the program are not the expected",
+					BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::LOD].cstr());
 				return Error::USER_DATA;
 				return Error::USER_DATA;
 			}
 			}
 		}
 		}
 
 
-		m_lodCount = U8(m_lodMutator->m_values.getSize());
+		m_lodCount = U8(m_builtinMutators[BuiltinMutatorId2::LOD]->m_values.getSize());
 		++builtinMutatorCount;
 		++builtinMutatorCount;
 	}
 	}
 
 
-	m_bonesMutator = m_prog->tryFindMutator("ANKI_BONES");
-	if(m_bonesMutator)
+	m_builtinMutators[BuiltinMutatorId2::BONES] =
+		m_prog->tryFindMutator(BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::BONES]);
+	if(m_builtinMutators[BuiltinMutatorId2::BONES])
 	{
 	{
-		if(m_bonesMutator->m_values.getSize() != 2)
+		if(m_builtinMutators[BuiltinMutatorId2::BONES]->m_values.getSize() != 2)
 		{
 		{
-			ANKI_RESOURCE_LOGE("Mutator ANKI_BONES should have 2 values in the program");
+			ANKI_RESOURCE_LOGE("Mutator %s should have 2 values in the program",
+				BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::BONES].cstr());
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
-		for(U32 i = 0; i < m_bonesMutator->m_values.getSize(); ++i)
+		for(U32 i = 0; i < m_builtinMutators[BuiltinMutatorId2::BONES]->m_values.getSize(); ++i)
 		{
 		{
-			if(m_bonesMutator->m_values[i] != I(i))
+			if(m_builtinMutators[BuiltinMutatorId2::BONES]->m_values[i] != I(i))
 			{
 			{
-				ANKI_RESOURCE_LOGE("Values of the BONES mutator in the program are not the expected");
+				ANKI_RESOURCE_LOGE("Values of the %s mutator in the program are not the expected",
+					BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::BONES].cstr());
 				return Error::USER_DATA;
 				return Error::USER_DATA;
 			}
 			}
 		}
 		}
@@ -323,20 +352,23 @@ Error MaterialResource2::parseMutators(XmlElement mutatorsEl)
 		++builtinMutatorCount;
 		++builtinMutatorCount;
 	}
 	}
 
 
-	m_velocityMutator = m_prog->tryFindMutator("ANKI_VELOCITY");
-	if(m_velocityMutator)
+	m_builtinMutators[BuiltinMutatorId2::VELOCITY] =
+		m_prog->tryFindMutator(BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::VELOCITY]);
+	if(m_builtinMutators[BuiltinMutatorId2::VELOCITY])
 	{
 	{
-		if(m_velocityMutator->m_values.getSize() != 2)
+		if(m_builtinMutators[BuiltinMutatorId2::VELOCITY]->m_values.getSize() != 2)
 		{
 		{
-			ANKI_RESOURCE_LOGE("Mutator ANKI_VELOCITY should have 2 values in the program");
+			ANKI_RESOURCE_LOGE("Mutator %s should have 2 values in the program",
+				BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::VELOCITY].cstr());
 			return Error::USER_DATA;
 			return Error::USER_DATA;
 		}
 		}
 
 
-		for(U32 i = 0; i < m_velocityMutator->m_values.getSize(); ++i)
+		for(U32 i = 0; i < m_builtinMutators[BuiltinMutatorId2::VELOCITY]->m_values.getSize(); ++i)
 		{
 		{
-			if(m_velocityMutator->m_values[i] != I(i))
+			if(m_builtinMutators[BuiltinMutatorId2::VELOCITY]->m_values[i] != I(i))
 			{
 			{
-				ANKI_RESOURCE_LOGE("Values of the ANKI_VELOCITY mutator in the program are not the expected");
+				ANKI_RESOURCE_LOGE("Values of the %s mutator in the program are not the expected",
+					BUILTIN_MUTATOR_NAMES[BuiltinMutatorId2::VELOCITY].cstr());
 				return Error::USER_DATA;
 				return Error::USER_DATA;
 			}
 			}
 		}
 		}
@@ -704,8 +736,8 @@ const MaterialVariant2& MaterialResource2::getOrCreateVariant(const RenderingKey
 		ANKI_ASSERT(key.getInstanceCount() == 1);
 		ANKI_ASSERT(key.getInstanceCount() == 1);
 	}
 	}
 
 
-	ANKI_ASSERT(!key.isSkinned() || m_bonesMutator);
-	ANKI_ASSERT(!key.hasVelocity() || m_velocityMutator);
+	ANKI_ASSERT(!key.isSkinned() || m_builtinMutators[BuiltinMutatorId2::BONES]);
+	ANKI_ASSERT(!key.hasVelocity() || m_builtinMutators[BuiltinMutatorId2::VELOCITY]);
 
 
 	key.setInstanceCount(1 << getInstanceGroupIdx(key.getInstanceCount()));
 	key.setInstanceCount(1 << getInstanceGroupIdx(key.getInstanceCount()));
 
 
@@ -737,29 +769,29 @@ const MaterialVariant2& MaterialResource2::getOrCreateVariant(const RenderingKey
 		initInfo.addMutation(m.m_mutator->m_name, m.m_value);
 		initInfo.addMutation(m.m_mutator->m_name, m.m_value);
 	}
 	}
 
 
-	if(m_instancingMutator)
+	if(m_builtinMutators[BuiltinMutatorId2::INSTANCE_COUNT])
 	{
 	{
-		initInfo.addMutation(m_instancingMutator->m_name, key.getInstanceCount());
+		initInfo.addMutation(m_builtinMutators[BuiltinMutatorId2::INSTANCE_COUNT]->m_name, key.getInstanceCount());
 	}
 	}
 
 
-	if(m_passMutator)
+	if(m_builtinMutators[BuiltinMutatorId2::PASS])
 	{
 	{
-		initInfo.addMutation(m_passMutator->m_name, MutatorValue(key.getPass()));
+		initInfo.addMutation(m_builtinMutators[BuiltinMutatorId2::PASS]->m_name, MutatorValue(key.getPass()));
 	}
 	}
 
 
-	if(m_lodMutator)
+	if(m_builtinMutators[BuiltinMutatorId2::LOD])
 	{
 	{
-		initInfo.addMutation(m_lodMutator->m_name, MutatorValue(key.getLod()));
+		initInfo.addMutation(m_builtinMutators[BuiltinMutatorId2::LOD]->m_name, MutatorValue(key.getLod()));
 	}
 	}
 
 
-	if(m_bonesMutator)
+	if(m_builtinMutators[BuiltinMutatorId2::BONES])
 	{
 	{
-		initInfo.addMutation(m_bonesMutator->m_name, key.isSkinned() != 0);
+		initInfo.addMutation(m_builtinMutators[BuiltinMutatorId2::BONES]->m_name, key.isSkinned() != 0);
 	}
 	}
 
 
-	if(m_velocityMutator)
+	if(m_builtinMutators[BuiltinMutatorId2::VELOCITY])
 	{
 	{
-		initInfo.addMutation(m_velocityMutator->m_name, key.hasVelocity() != 0);
+		initInfo.addMutation(m_builtinMutators[BuiltinMutatorId2::VELOCITY]->m_name, key.hasVelocity() != 0);
 	}
 	}
 
 
 	for(const MaterialVariable2& var : m_vars)
 	for(const MaterialVariable2& var : m_vars)

+ 18 - 7
src/anki/resource/MaterialResource2.h

@@ -20,7 +20,7 @@ class XmlElement;
 /// @addtogroup resource
 /// @addtogroup resource
 /// @{
 /// @{
 
 
-/// The ID of a buildin material variable
+/// The ID of a buildin material variable.
 enum class BuiltinMaterialVariableId2 : U8
 enum class BuiltinMaterialVariableId2 : U8
 {
 {
 	NONE = 0,
 	NONE = 0,
@@ -42,6 +42,21 @@ enum class BuiltinMaterialVariableId2 : U8
 };
 };
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(BuiltinMaterialVariableId2, inline)
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(BuiltinMaterialVariableId2, inline)
 
 
+/// The ID of builtin mutators.
+enum class BuiltinMutatorId2 : U8
+{
+	NONE = 0,
+	INSTANCE_COUNT,
+	PASS,
+	LOD,
+	BONES,
+	VELOCITY,
+
+	COUNT,
+	FIRST = 0
+};
+ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(BuiltinMutatorId2, inline)
+
 /// Holds the shader variables. It's a container for shader program variables that share the same name.
 /// Holds the shader variables. It's a container for shader program variables that share the same name.
 class MaterialVariable2 : public NonCopyable
 class MaterialVariable2 : public NonCopyable
 {
 {
@@ -294,7 +309,7 @@ public:
 
 
 	Bool isInstanced() const
 	Bool isInstanced() const
 	{
 	{
-		return m_instancingMutator != nullptr;
+		return m_builtinMutators[BuiltinMutatorId2::INSTANCE_COUNT] != nullptr;
 	}
 	}
 
 
 	ConstWeakArray<MaterialVariable2> getVariables() const
 	ConstWeakArray<MaterialVariable2> getVariables() const
@@ -319,11 +334,7 @@ private:
 
 
 	ShaderProgramResource2Ptr m_prog;
 	ShaderProgramResource2Ptr m_prog;
 
 
-	const ShaderProgramResourceMutator2* m_instancingMutator = nullptr;
-	const ShaderProgramResourceMutator2* m_passMutator = nullptr;
-	const ShaderProgramResourceMutator2* m_lodMutator = nullptr;
-	const ShaderProgramResourceMutator2* m_bonesMutator = nullptr;
-	const ShaderProgramResourceMutator2* m_velocityMutator = nullptr;
+	Array<const ShaderProgramResourceMutator2*, U32(BuiltinMutatorId2::COUNT)> m_builtinMutators = {};
 
 
 	Bool m_shadow = true;
 	Bool m_shadow = true;
 	Bool m_forwardShading = false;
 	Bool m_forwardShading = false;

+ 4 - 3
src/anki/resource/MeshLoader.cpp

@@ -132,8 +132,9 @@ Error MeshLoader::checkFormat(VertexAttributeLocation type, ConstWeakArray<Forma
 
 
 	if(!found)
 	if(!found)
 	{
 	{
-		ANKI_RESOURCE_LOGE(
-			"Vertex attribute %u has unsupported format %u", U(type), U(m_header.m_vertexAttributes[type].m_format));
+		ANKI_RESOURCE_LOGE("Vertex attribute %u has unsupported format %u",
+			U32(type),
+			U32(m_header.m_vertexAttributes[type].m_format));
 		return Error::USER_DATA;
 		return Error::USER_DATA;
 	}
 	}
 
 
@@ -146,7 +147,7 @@ Error MeshLoader::checkFormat(VertexAttributeLocation type, ConstWeakArray<Forma
 	// Scale should be 1.0 for now
 	// Scale should be 1.0 for now
 	if(attrib.m_scale != 1.0f)
 	if(attrib.m_scale != 1.0f)
 	{
 	{
-		ANKI_RESOURCE_LOGE("Vertex attribute %u should have 1.0 scale", U(type));
+		ANKI_RESOURCE_LOGE("Vertex attribute %u should have 1.0 scale", U32(type));
 		return Error::USER_DATA;
 		return Error::USER_DATA;
 	}
 	}
 
 

+ 3 - 3
src/anki/resource/ResourceFilesystem.cpp

@@ -237,7 +237,7 @@ void ResourceFilesystem::addCachePath(const CString& path)
 
 
 Error ResourceFilesystem::addNewPath(const CString& path)
 Error ResourceFilesystem::addNewPath(const CString& path)
 {
 {
-	U fileCount = 0;
+	U32 fileCount = 0;
 	static const CString extension(".ankizip");
 	static const CString extension(".ankizip");
 
 
 	auto pos = path.find(extension);
 	auto pos = path.find(extension);
@@ -300,7 +300,7 @@ Error ResourceFilesystem::addNewPath(const CString& path)
 		struct UserData
 		struct UserData
 		{
 		{
 			ResourceFilesystem* m_sys;
 			ResourceFilesystem* m_sys;
-			U* m_fileCount;
+			U32* m_fileCount;
 		} ud{this, &fileCount};
 		} ud{this, &fileCount};
 
 
 		ANKI_CHECK(walkDirectoryTree(path, &ud, [](const CString& fname, void* ud, Bool isDir) -> Error {
 		ANKI_CHECK(walkDirectoryTree(path, &ud, [](const CString& fname, void* ud, Bool isDir) -> Error {
@@ -313,7 +313,7 @@ Error ResourceFilesystem::addNewPath(const CString& path)
 			ResourceFilesystem* self = udd->m_sys;
 			ResourceFilesystem* self = udd->m_sys;
 
 
 			Path& p = self->m_paths.getFront();
 			Path& p = self->m_paths.getFront();
-			p.m_files.pushBackSprintf(self->m_alloc, "%s", &fname[0]);
+			p.m_files.pushBackSprintf(self->m_alloc, "%s", fname.cstr());
 
 
 			++(*udd->m_fileCount);
 			++(*udd->m_fileCount);
 			return Error::NONE;
 			return Error::NONE;

+ 1 - 1
src/anki/resource/TextureAtlasResource.cpp

@@ -52,7 +52,7 @@ Error TextureAtlasResource::load(const ResourceFilename& filename, Bool async)
 	ANKI_CHECK(el.getNumber(margin));
 	ANKI_CHECK(el.getNumber(margin));
 	if(margin >= I(m_tex->getWidth()) || margin >= I(m_tex->getHeight()) || margin < 0)
 	if(margin >= I(m_tex->getWidth()) || margin >= I(m_tex->getHeight()) || margin < 0)
 	{
 	{
-		ANKI_RESOURCE_LOGE("Too big margin %d", U(margin));
+		ANKI_RESOURCE_LOGE("Too big margin %d", I32(margin));
 		return Error::USER_DATA;
 		return Error::USER_DATA;
 	}
 	}
 	m_margin = U32(margin);
 	m_margin = U32(margin);

+ 3 - 3
src/anki/resource/TextureAtlasResource.h

@@ -52,17 +52,17 @@ public:
 		return m_tex->getGrTextureView();
 		return m_tex->getGrTextureView();
 	}
 	}
 
 
-	U getWidth() const
+	U32 getWidth() const
 	{
 	{
 		return m_size[0];
 		return m_size[0];
 	}
 	}
 
 
-	U getHeight() const
+	U32 getHeight() const
 	{
 	{
 		return m_size[1];
 		return m_size[1];
 	}
 	}
 
 
-	U getSubTextureMargin() const
+	U32 getSubTextureMargin() const
 	{
 	{
 		return m_margin;
 		return m_margin;
 	}
 	}

+ 1 - 1
src/anki/resource/TransferGpuAllocator.cpp

@@ -102,7 +102,7 @@ Error TransferGpuAllocator::init(PtrSize maxSize, GrManager* gr, ResourceAllocat
 	m_gr = gr;
 	m_gr = gr;
 
 
 	m_maxAllocSize = getAlignedRoundUp(CHUNK_INITIAL_SIZE * FRAME_COUNT, maxSize);
 	m_maxAllocSize = getAlignedRoundUp(CHUNK_INITIAL_SIZE * FRAME_COUNT, maxSize);
-	ANKI_RESOURCE_LOGI("Will use %uMB of memory for transfer scratch", m_maxAllocSize / 1024 / 1024);
+	ANKI_RESOURCE_LOGI("Will use %luMB of memory for transfer scratch", m_maxAllocSize / 1024 / 1024);
 
 
 	m_interface.reset(m_alloc.newInstance<Interface>());
 	m_interface.reset(m_alloc.newInstance<Interface>());
 	m_interface->m_gr = gr;
 	m_interface->m_gr = gr;

+ 1 - 1
src/anki/scene/components/DecalComponent.h

@@ -21,7 +21,7 @@ class DecalComponent : public SceneComponent
 {
 {
 public:
 public:
 	static const SceneComponentType CLASS_TYPE = SceneComponentType::DECAL;
 	static const SceneComponentType CLASS_TYPE = SceneComponentType::DECAL;
-	static constexpr U ATLAS_SUB_TEXTURE_MARGIN = 16;
+	static constexpr U32 ATLAS_SUB_TEXTURE_MARGIN = 16;
 
 
 	DecalComponent(SceneNode* node);
 	DecalComponent(SceneNode* node);
 
 

+ 3 - 3
src/anki/script/Logger.cpp

@@ -33,7 +33,7 @@ static inline int pwraplogi(lua_State* l)
 	}
 	}
 
 
 	// Call the function
 	// Call the function
-	ANKI_SCRIPT_LOGI(arg0);
+	ANKI_SCRIPT_LOGI("%s", arg0);
 
 
 	return 0;
 	return 0;
 }
 }
@@ -74,7 +74,7 @@ static inline int pwraploge(lua_State* l)
 	}
 	}
 
 
 	// Call the function
 	// Call the function
-	ANKI_SCRIPT_LOGE(arg0);
+	ANKI_SCRIPT_LOGE("%s", arg0);
 
 
 	return 0;
 	return 0;
 }
 }
@@ -115,7 +115,7 @@ static inline int pwraplogw(lua_State* l)
 	}
 	}
 
 
 	// Call the function
 	// Call the function
-	ANKI_SCRIPT_LOGW(arg0);
+	ANKI_SCRIPT_LOGW("%s", arg0);
 
 
 	return 0;
 	return 0;
 }
 }

+ 1 - 1
src/anki/script/LuaBinder.cpp

@@ -121,7 +121,7 @@ Error LuaBinder::evalString(lua_State* state, const CString& str)
 	int e = luaL_dostring(state, &str[0]);
 	int e = luaL_dostring(state, &str[0]);
 	if(e)
 	if(e)
 	{
 	{
-		ANKI_SCRIPT_LOGE("%s (line:%d)", lua_tostring(state, -1));
+		ANKI_SCRIPT_LOGE("%s", lua_tostring(state, -1));
 		lua_pop(state, 1);
 		lua_pop(state, 1);
 		err = Error::USER_DATA;
 		err = Error::USER_DATA;
 	}
 	}

+ 1 - 0
src/anki/util/Logger.h

@@ -78,6 +78,7 @@ public:
 		const char* msg);
 		const char* msg);
 
 
 	/// Send a formated message
 	/// Send a formated message
+	ANKI_CHECK_FORMAT(7, 8)
 	void writeFormated(const char* file,
 	void writeFormated(const char* file,
 		int line,
 		int line,
 		const char* func,
 		const char* func,

+ 1 - 1
src/anki/util/Memory.cpp

@@ -154,7 +154,7 @@ HeapMemoryPool::HeapMemoryPool()
 
 
 HeapMemoryPool::~HeapMemoryPool()
 HeapMemoryPool::~HeapMemoryPool()
 {
 {
-	U count = m_allocationsCount.load();
+	const U32 count = m_allocationsCount.load();
 	if(count != 0)
 	if(count != 0)
 	{
 	{
 		ANKI_UTIL_LOGW("Memory pool destroyed before all memory being released "
 		ANKI_UTIL_LOGW("Memory pool destroyed before all memory being released "

+ 1 - 2
tests/util/HashMap.cpp

@@ -216,8 +216,7 @@ ANKI_TEST(Util, HashMap)
 			timer.stop();
 			timer.stop();
 			Second stlTime = timer.getElapsedTime();
 			Second stlTime = timer.getElapsedTime();
 
 
-			ANKI_TEST_LOGI(
-				"Find bench: STL %f AnKi %f | %f%% (%lld)", stlTime, akTime, stlTime / akTime * 100.0, count);
+			ANKI_TEST_LOGI("Find bench: STL %f AnKi %f | %f%% (%ld)", stlTime, akTime, stlTime / akTime * 100.0, count);
 		}
 		}
 
 
 		// Delete
 		// Delete

+ 3 - 3
tests/util/Process.cpp

@@ -21,7 +21,7 @@ ANKI_TEST(Util, Process)
 		HeapAllocator<U8> alloc(allocAligned, nullptr);
 		HeapAllocator<U8> alloc(allocAligned, nullptr);
 		StringAuto stdOut(alloc);
 		StringAuto stdOut(alloc);
 		ANKI_TEST_EXPECT_NO_ERR(proc.readFromStdout(stdOut));
 		ANKI_TEST_EXPECT_NO_ERR(proc.readFromStdout(stdOut));
-		ANKI_TEST_LOGI(stdOut.cstr());
+		ANKI_TEST_LOGI("%s", stdOut.cstr());
 	}
 	}
 
 
 	// Stderr and stdOut
 	// Stderr and stdOut
@@ -58,14 +58,14 @@ done
 			ANKI_TEST_EXPECT_NO_ERR(proc.readFromStdout(stdOut));
 			ANKI_TEST_EXPECT_NO_ERR(proc.readFromStdout(stdOut));
 			if(stdOut.getLength())
 			if(stdOut.getLength())
 			{
 			{
-				ANKI_TEST_LOGI(stdOut.cstr());
+				ANKI_TEST_LOGI("%s", stdOut.cstr());
 			}
 			}
 
 
 			StringAuto stderrStr(alloc);
 			StringAuto stderrStr(alloc);
 			ANKI_TEST_EXPECT_NO_ERR(proc.readFromStderr(stderrStr));
 			ANKI_TEST_EXPECT_NO_ERR(proc.readFromStderr(stderrStr));
 			if(stderrStr.getLength())
 			if(stderrStr.getLength())
 			{
 			{
-				ANKI_TEST_LOGI(stderrStr.cstr());
+				ANKI_TEST_LOGI("%s", stderrStr.cstr());
 			}
 			}
 		}
 		}
 
 

+ 1 - 1
tests/util/SparseArray.cpp

@@ -407,7 +407,7 @@ ANKI_TEST(Util, SparseArrayBench)
 	// Mem usage
 	// Mem usage
 	const I64 stlMemUsage = stlMaxAllocSize + sizeof(stdMap);
 	const I64 stlMemUsage = stlMaxAllocSize + sizeof(stdMap);
 	const I64 akMemUsage = akMaxAllocSize + sizeof(akMap);
 	const I64 akMemUsage = akMaxAllocSize + sizeof(akMap);
-	ANKI_TEST_LOGI("Max mem usage: STL %lli AnKi %lli | %f%% (At any given time what was the max mem usage)",
+	ANKI_TEST_LOGI("Max mem usage: STL %li AnKi %li | %f%% (At any given time what was the max mem usage)",
 		stlMemUsage,
 		stlMemUsage,
 		akMemUsage,
 		akMemUsage,
 		F64(stlMemUsage) / F32(akMemUsage) * 100.0f);
 		F64(stlMemUsage) / F32(akMemUsage) * 100.0f);