Browse Source

Add the -Wconversion warning

Panagiotis Christopoulos Charitos 6 years ago
parent
commit
bede55c18c
100 changed files with 773 additions and 709 deletions
  1. 3 1
      CMakeLists.txt
  2. 1 1
      samples/physics_playground/Main.cpp
  3. 1 1
      samples/sponza/Main.cpp
  4. 6 6
      sandbox/Main.cpp
  5. 1 1
      shaders/glsl_cpp_common/ClusteredShading.h
  6. 92 92
      src/anki/Config.h.cmake
  7. 1 1
      src/anki/collision/ConvexHullShape.h
  8. 3 3
      src/anki/collision/FunctionsTestCollision.cpp
  9. 3 3
      src/anki/collision/FunctionsTestPlane.cpp
  10. 1 1
      src/anki/collision/Obb.cpp
  11. 13 13
      src/anki/core/App.cpp
  12. 3 3
      src/anki/core/App.h
  13. 1 1
      src/anki/core/DeveloperConsole.cpp
  14. 5 5
      src/anki/core/NativeWindowSdl.cpp
  15. 4 4
      src/anki/core/StagingGpuMemoryManager.cpp
  16. 22 25
      src/anki/gr/Common.h
  17. 16 16
      src/anki/gr/RenderGraph.cpp
  18. 2 2
      src/anki/gr/RenderGraph.h
  19. 4 4
      src/anki/gr/RenderGraph.inl.h
  20. 1 1
      src/anki/gr/Sampler.h
  21. 4 3
      src/anki/gr/ShaderCompiler.cpp
  22. 1 1
      src/anki/gr/TextureView.h
  23. 9 9
      src/anki/gr/common/ClassGpuAllocator.cpp
  24. 4 4
      src/anki/gr/common/ClassGpuAllocator.h
  25. 2 2
      src/anki/gr/common/StackGpuAllocator.cpp
  26. 2 2
      src/anki/gr/vulkan/BufferImpl.cpp
  27. 13 13
      src/anki/gr/vulkan/CommandBufferImpl.cpp
  28. 4 4
      src/anki/gr/vulkan/CommandBufferImpl.h
  29. 22 8
      src/anki/gr/vulkan/CommandBufferImpl.inl.h
  30. 2 2
      src/anki/gr/vulkan/Common.h
  31. 20 20
      src/anki/gr/vulkan/DescriptorSet.cpp
  32. 10 10
      src/anki/gr/vulkan/DescriptorSet.h
  33. 3 3
      src/anki/gr/vulkan/FramebufferImpl.cpp
  34. 2 2
      src/anki/gr/vulkan/FramebufferImpl.h
  35. 13 13
      src/anki/gr/vulkan/GpuMemoryManager.cpp
  36. 3 2
      src/anki/gr/vulkan/GpuMemoryManager.h
  37. 17 17
      src/anki/gr/vulkan/GrManagerImpl.cpp
  38. 2 2
      src/anki/gr/vulkan/GrManagerImplSdl.cpp
  39. 2 2
      src/anki/gr/vulkan/Pipeline.cpp
  40. 3 3
      src/anki/gr/vulkan/Pipeline.h
  41. 1 1
      src/anki/gr/vulkan/PipelineCache.cpp
  42. 1 1
      src/anki/gr/vulkan/PipelineLayout.cpp
  43. 1 1
      src/anki/gr/vulkan/QueryFactory.cpp
  44. 10 9
      src/anki/gr/vulkan/ShaderImpl.cpp
  45. 1 1
      src/anki/gr/vulkan/SwapchainFactory.cpp
  46. 6 5
      src/anki/gr/vulkan/TextureImpl.cpp
  47. 3 3
      src/anki/gr/vulkan/TextureImpl.h
  48. 1 1
      src/anki/gr/vulkan/TimestampQueryImpl.cpp
  49. 3 3
      src/anki/input/Input.h
  50. 4 4
      src/anki/input/InputSdl.cpp
  51. 5 5
      src/anki/math/F16.cpp
  52. 34 13
      src/anki/math/Functions.h
  53. 11 12
      src/anki/math/Mat.h
  54. 2 2
      src/anki/math/Quat.h
  55. 6 8
      src/anki/math/Simd.h
  56. 1 1
      src/anki/math/Transform.h
  57. 2 2
      src/anki/math/Vec.h
  58. 31 1
      src/anki/misc/ConfigSet.cpp
  59. 6 1
      src/anki/misc/ConfigSet.h
  60. 1 1
      src/anki/misc/Xml.cpp
  61. 1 1
      src/anki/misc/Xml.h
  62. 9 3
      src/anki/physics/Common.h
  63. 1 1
      src/anki/physics/PhysicsCollisionShape.cpp
  64. 2 2
      src/anki/physics/PhysicsTrigger.cpp
  65. 1 1
      src/anki/physics/PhysicsWorld.cpp
  66. 4 4
      src/anki/renderer/Bloom.cpp
  67. 22 21
      src/anki/renderer/ClusterBin.cpp
  68. 16 16
      src/anki/renderer/Common.h
  69. 5 5
      src/anki/renderer/Dbg.cpp
  70. 13 13
      src/anki/renderer/DepthDownscale.cpp
  71. 1 1
      src/anki/renderer/DepthDownscale.h
  72. 7 7
      src/anki/renderer/DownscaleBlur.cpp
  73. 6 6
      src/anki/renderer/DownscaleBlur.h
  74. 8 8
      src/anki/renderer/Drawer.cpp
  75. 1 1
      src/anki/renderer/Drawer.h
  76. 1 1
      src/anki/renderer/FinalComposite.cpp
  77. 4 4
      src/anki/renderer/ForwardShading.cpp
  78. 8 8
      src/anki/renderer/GBuffer.cpp
  79. 3 3
      src/anki/renderer/GBufferPost.cpp
  80. 39 32
      src/anki/renderer/GlobalIllumination.cpp
  81. 7 7
      src/anki/renderer/LensFlare.cpp
  82. 1 1
      src/anki/renderer/LightShading.cpp
  83. 6 6
      src/anki/renderer/MainRenderer.cpp
  84. 11 11
      src/anki/renderer/ProbeReflections.cpp
  85. 3 3
      src/anki/renderer/RenderQueue.cpp
  86. 1 1
      src/anki/renderer/RenderQueue.h
  87. 15 33
      src/anki/renderer/Renderer.cpp
  88. 2 11
      src/anki/renderer/Renderer.h
  89. 6 5
      src/anki/renderer/RendererObject.cpp
  90. 9 9
      src/anki/renderer/RendererObject.h
  91. 31 31
      src/anki/renderer/ShadowMapping.cpp
  92. 4 4
      src/anki/renderer/ShadowMapping.h
  93. 2 2
      src/anki/renderer/Ssao.cpp
  94. 4 4
      src/anki/renderer/Ssr.cpp
  95. 1 1
      src/anki/renderer/TemporalAA.cpp
  96. 46 43
      src/anki/renderer/TileAllocator.cpp
  97. 13 10
      src/anki/renderer/TileAllocator.h
  98. 1 1
      src/anki/renderer/Tonemapping.h
  99. 3 3
      src/anki/renderer/VolumetricFog.cpp
  100. 4 4
      src/anki/renderer/VolumetricLightingAccumulation.cpp

+ 3 - 1
CMakeLists.txt

@@ -363,7 +363,9 @@ endif()
 
 # AnKi compiler flags (Mainly warnings)
 if(NOT MSVC)
-	add_definitions("-pedantic -Wall -W -Wextra -Wstrict-aliasing -Wwrite-strings -Wunused -Wunused-variable -Wno-unused-parameter -Wundef -Wno-ignored-attributes -Wno-implicit-fallthrough -Wunused-result -std=c++14")
+	add_definitions("-pedantic -Wall -W -Wextra -Wstrict-aliasing -Wwrite-strings -Wunused -Wunused-variable "
+		"-Wno-unused-parameter -Wundef -Wno-ignored-attributes -Wno-implicit-fallthrough -Wunused-result"
+		"-Wconversion -Wfatal-errors -std=c++14")
 else()
 	add_definitions("/wd4996 /wd4244 /wd4262 /wd4267")
 endif()

+ 1 - 1
samples/physics_playground/Main.cpp

@@ -156,7 +156,7 @@ Error MyApp::sampleExtraInit()
 				"assets/Suzannedynamic-material.ankimdl"));
 
 			Transform trf(Vec4(-4.3f, 12.0f, -3.0f, 0.0f), Mat3x4::getIdentity(), 1.0f);
-			trf.getOrigin().y() -= i * 1.25f;
+			trf.getOrigin().y() -= F32(i) * 1.25f;
 			// trf.getOrigin().x() -= i * 0.25f;
 
 			// monkey->getComponent<MoveComponent>().setLocalTransform(trf);

+ 1 - 1
samples/sponza/Main.cpp

@@ -17,7 +17,7 @@ public:
 		ANKI_CHECK(getResourceManager().loadResource("assets/scene.lua", script));
 		ANKI_CHECK(getScriptManager().evalString(script->getSource()));
 
-		getMainRenderer().getOffscreenRenderer().getVolumetricFog().setFogParticleColor(Vec3(1.0, 0.9, 0.9));
+		getMainRenderer().getOffscreenRenderer().getVolumetricFog().setFogParticleColor(Vec3(1.0f, 0.9f, 0.9f));
 		getMainRenderer().getOffscreenRenderer().getVolumetricFog().setParticleDensity(2.0f);
 		return Error::NONE;
 	}

+ 6 - 6
sandbox/Main.cpp

@@ -45,7 +45,7 @@ Error MyApp::init(int argc, char* argv[])
 	MainRenderer& renderer = getMainRenderer();
 	ResourceManager& resources = getResourceManager();
 
-	renderer.getOffscreenRenderer().getVolumetricFog().setFogParticleColor(Vec3(1.0, 0.9, 0.9));
+	renderer.getOffscreenRenderer().getVolumetricFog().setFogParticleColor(Vec3(1.0f, 0.9f, 0.9f));
 	renderer.getOffscreenRenderer().getVolumetricFog().setParticleDensity(1.0f);
 
 	if(getenv("PROFILE"))
@@ -89,10 +89,10 @@ Error MyApp::init(int argc, char* argv[])
 
 Error MyApp::userMainLoop(Bool& quit)
 {
-	F32 dist = 0.1;
-	F32 ang = toRad(2.5);
-	F32 scale = 0.01;
-	F32 mouseSensivity = 9.0;
+	F32 dist = 0.1f;
+	F32 ang = toRad(2.5f);
+	F32 scale = 0.01f;
+	F32 mouseSensivity = 9.0f;
 	quit = false;
 
 	SceneGraph& scene = getSceneGraph();
@@ -121,7 +121,7 @@ Error MyApp::userMainLoop(Bool& quit)
 	{
 		/*Vec3 origin = mover->getWorldTransform().getOrigin().xyz();
 		printf("%f %f %f\n", origin.x(), origin.y(), origin.z());*/
-		mover->setLocalOrigin(Vec4(81.169312, -2.309618, 17.088392, 0.0));
+		mover->setLocalOrigin(Vec4(81.169312f, -2.309618f, 17.088392f, 0.0f));
 		// mover->setLocalRotation(Mat3x4::getIdentity());
 	}
 

+ 1 - 1
shaders/glsl_cpp_common/ClusteredShading.h

@@ -172,7 +172,7 @@ ANKI_SHADER_FUNC_INLINE U32 computeClusterK(ClustererMagicValues magic, Vec3 wor
 ANKI_SHADER_FUNC_INLINE U32 computeClusterIndex(
 	ClustererMagicValues magic, Vec2 uv, Vec3 worldPos, U32 clusterCountX, U32 clusterCountY)
 {
-	const UVec2 xy = UVec2(uv * Vec2(clusterCountX, clusterCountY));
+	const UVec2 xy = UVec2(uv * Vec2(F32(clusterCountX), F32(clusterCountY)));
 	const U32 k = computeClusterK(magic, worldPos);
 	return k * (clusterCountX * clusterCountY) + xy.y() * clusterCountX + xy.x();
 }

+ 92 - 92
src/anki/Config.h.cmake

@@ -3,6 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+// ====================== WARNING: THIS FILE IS AUTO-GENERATED BY THE BUILD SYSTEM. DON'T ALTER IT =====================
+
 #pragma once
 
 /// @addtogroup config
@@ -19,134 +21,130 @@
 #define ANKI_DEBUG_SYMBOLS ${ANKI_DEBUG_SYMBOLS}
 #define ANKI_OPTIMIZE ${ANKI_OPTIMIZE}
 #define ANKI_TESTS ${ANKI_TESTS}
+#define ANKI_ENABLE_TRACE ${_ANKI_ENABLE_TRACE}
 
 // Compiler
-#define ANKI_COMPILER_CLANG 0
-#define ANKI_COMPILER_GCC 1
-#define ANKI_COMPILER_MSVC 2
-
 #if defined(__clang__)
-#	define ANKI_COMPILER ANKI_COMPILER_CLANG
+#	define ANKI_COMPILER_CLANG 1
+#	define ANKI_COMPILER_GCC 0
+#	define ANKI_COMPILER_MSVC 0
+#	define ANKI_COMPILER_GCC_COMPATIBLE 1
 #	define ANKI_COMPILER_STR "clang " __VERSION__
 #elif defined(__GNUC__) || defined(__GNUG__)
-#	define ANKI_COMPILER ANKI_COMPILER_GCC
+#	define ANKI_COMPILER_CLANG 0
+#	define ANKI_COMPILER_GCC 1
+#	define ANKI_COMPILER_MSVC 0
+#	define ANKI_COMPILER_GCC_COMPATIBLE 1
 #	define ANKI_COMPILER_STR "gcc " __VERSION__
 #elif defined(_MSC_VER)
-#	define ANKI_COMPILER ANKI_COMPILER_MSVC
+#	define ANKI_COMPILER_CLANG 0
+#	define ANKI_COMPILER_GCC 0
+#	define ANKI_COMPILER_MSVC 1
+#	define ANKI_COMPILER_GCC_COMPATIBLE 0
 #	define ANKI_COMPILER_STR "MSVC " _ANKI_STR(_MSC_FULL_VER)
 #else
 #	error Unknown compiler
 #endif
 
 // Operating system
-#define ANKI_OS_LINUX 1
-#define ANKI_OS_ANDROID 2
-#define ANKI_OS_MACOS 3
-#define ANKI_OS_IOS 4
-#define ANKI_OS_WINDOWS 5
-
 #if defined(__WIN32__) || defined(_WIN32)
-#	define ANKI_OS ANKI_OS_WINDOWS
+#	define ANKI_OS_LINUX 0
+#	define ANKI_OS_ANDROID 0
+#	define ANKI_OS_MACOS 0
+#	define ANKI_OS_IOS 0
+#	define ANKI_OS_WINDOWS 1
+#	define ANKI_OS_STR "Windows"
 #elif defined(__APPLE_CC__)
-#	if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) \
-		&& __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000) \
-	|| (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000)
-#		define ANKI_OS ANKI_OS_IOS
+#	if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000)
+#		define ANKI_OS_LINUX 0
+#		define ANKI_OS_ANDROID 0
+#		define ANKI_OS_MACOS 0
+#		define ANKI_OS_IOS 1
+#		define ANKI_OS_WINDOWS 0
+#		define ANKI_OS_STR "iOS"
 #	else
-#		define ANKI_OS ANKI_OS_MACOS
+#		define ANKI_OS_LINUX 0
+#		define ANKI_OS_ANDROID 0
+#		define ANKI_OS_MACOS 1
+#		define ANKI_OS_IOS 0
+#		define ANKI_OS_WINDOWS 0
+#		define ANKI_OS_STR "MacOS"
 #	endif
 #elif defined(__ANDROID__)
-#	define ANKI_OS ANKI_OS_ANDROID
+#	define ANKI_OS_LINUX 0
+#	define ANKI_OS_ANDROID 1
+#	define ANKI_OS_MACOS 0
+#	define ANKI_OS_IOS 0
+#	define ANKI_OS_WINDOWS 0
+#	define ANKI_OS_STR "Android"
+#elif defined(__linux__)
+#	define ANKI_OS_LINUX 1
+#	define ANKI_OS_ANDROID 0
+#	define ANKI_OS_MACOS 0
+#	define ANKI_OS_IOS 0
+#	define ANKI_OS_WINDOWS 0
+#	define ANKI_OS_STR "Linux"
 #else
-#	define ANKI_OS ANKI_OS_LINUX
+#	error Unknown OS
 #endif
 
 // POSIX system or not
-#if ANKI_OS == ANKI_OS_LINUX || ANKI_OS == ANKI_OS_ANDROID || ANKI_OS == ANKI_OS_MACOS || ANKI_OS == ANKI_OS_IOS
+#if ANKI_OS_LINUX || ANKI_OS_ANDROID || ANKI_OS_MACOS || ANKI_OS_IOS
 #	define ANKI_POSIX 1
 #else
 #	define ANKI_POSIX 0
 #endif
 
 // CPU architecture
-#define ANKI_CPU_ARCH_INTEL 1
-#define ANKI_CPU_ARCH_ARM 2
-
-#if defined(__GNUC__)
+#if ANKI_COMPILER_GCC_COMPATIBLE
 #	if defined(__arm__)
-#		define ANKI_CPU_ARCH ANKI_CPU_ARCH_ARM
-#		define ANKI_CPU_ARCH_STR "ANKI_CPU_ARCH_ARM"
+#		define ANKI_CPU_ARCH_X86 0
+#		define ANKI_CPU_ARCH_ARM 1
 #	elif defined(__i386__) || defined(__amd64__)
-#		define ANKI_CPU_ARCH ANKI_CPU_ARCH_INTEL
-#		define ANKI_CPU_ARCH_STR "ANKI_CPU_ARCH_INTEL"
-#	else
-#		error "Unknown CPU arch"
+#		define ANKI_CPU_ARCH_X86 1
+#		define ANKI_CPU_ARCH_ARM 0
 #	endif
-#elif ANKI_COMPILER == ANKI_COMPILER_MSVC
+#elif ANKI_COMPILER_MSVC
 #	if defined(_M_ARM)
-#		define ANKI_CPU_ARCH ANKI_CPU_ARCH_ARM
-#		define ANKI_CPU_ARCH_STR "ANKI_CPU_ARCH_ARM"
+#		define ANKI_CPU_ARCH_X86 0
+#		define ANKI_CPU_ARCH_ARM 1
 #	elif defined(_M_X64) || defined(_M_IX86)
-#		define ANKI_CPU_ARCH ANKI_CPU_ARCH_INTEL
-#		define ANKI_CPU_ARCH_STR "ANKI_CPU_ARCH_INTEL"
-#	else
-#		error "Unknown CPU arch"
+#		define ANKI_CPU_ARCH_X86 1
+#		define ANKI_CPU_ARCH_ARM 0
 #	endif
+#endif
+
+#if defined(ANKI_CPU_ARCH_X86) && ANKI_CPU_ARCH_X86
+#	define ANKI_GPU_ARCH_STR "x86"
+#elif defined(ANKI_CPU_ARCH_ARM) && ANKI_CPU_ARCH_ARM
+#	define ANKI_GPU_ARCH_STR "arm"
 #else
-#	error "Unsupported compiler"
+#	error Unknown CPU arch
 #endif
 
 // SIMD
 #define ANKI_ENABLE_SIMD ${_ANKI_ENABLE_SIMD}
 
-#define ANKI_SIMD_NONE 1
-#define ANKI_SIMD_SSE 2
-#define ANKI_SIMD_NEON 3
-
 #if !ANKI_ENABLE_SIMD
-#	define ANKI_SIMD ANKI_SIMD_NONE
-#else
-#	if ANKI_CPU_ARCH == ANKI_CPU_ARCH_INTEL
-#		define ANKI_SIMD ANKI_SIMD_SSE
-#	elif ANKI_CPU_ARCH == ANKI_CPU_ARCH_ARM
-#		define ANKI_SIMD ANKI_SIMD_NEON
-#	endif
-#endif
-
-// Window backend
-#define ANKI_WINDOW_BACKEND_GLXX11 1
-#define ANKI_WINDOW_BACKEND_EGLX11 2
-#define ANKI_WINDOW_BACKEND_EGLFBDEV 3
-#define ANKI_WINDOW_BACKEND_MACOS 4
-#define ANKI_WINDOW_BACKEND_ANDROID 5
-#define ANKI_WINDOW_BACKEND_SDL 6
-#define ANKI_WINDOW_BACKEND ANKI_WINDOW_BACKEND_${ANKI_WINDOW_BACKEND}
-#define ANKI_WINDOW_BACKEND_STR "ANKI_WINDOW_BACKEND_${ANKI_WINDOW_BACKEND}"
-
-// OpenGL version
-#define ANKI_GL_DESKTOP 1
-#define ANKI_GL_ES 2
-#if ANKI_OS == ANKI_OS_LINUX || ANKI_OS == ANKI_OS_MACOS || ANKI_OS == ANKI_OS_WINDOWS
-#	define ANKI_GL ANKI_GL_DESKTOP
-#	define ANKI_GL_STR "ANKI_GL_DESKTOP"
+#	define ANKI_SIMD_NONE 1
+#	define ANKI_SIMD_SSE 0
+#	define ANKI_SIMD_NEON 0
+#elif ANKI_CPU_ARCH_X86
+#	define ANKI_SIMD_NONE 0
+#	define ANKI_SIMD_SSE 1
+#	define ANKI_SIMD_NEON 0
 #else
-#	define ANKI_GL ANKI_GL_ES
-#	define ANKI_GL_STR "ANKI_GL_ES"
+#	define ANKI_SIMD_NONE 0
+#	define ANKI_SIMD_SSE 0
+#	define ANKI_SIMD_NEON 1
 #endif
 
 // Graphics backend
-#define ANKI_GR_BACKEND_GL 1
-#define ANKI_GR_BACKEND_VULKAN 2
-#define ANKI_GR_BACKEND ANKI_GR_BACKEND_${ANKI_GR_BACKEND}
-
-// Enable performance counters
-#define ANKI_ENABLE_TRACE ${_ANKI_ENABLE_TRACE}
+#define ANKI_GR_BACKEND_GL 0
+#define ANKI_GR_BACKEND_VULKAN 1
 
-#define ANKI_FILE __FILE__
-#define ANKI_FUNC __func__
-
-// Some compiler struff
-#if defined(__GNUC__)
+// Some compiler attributes
+#if ANKI_COMPILER_GCC_COMPATIBLE
 #	define ANKI_LIKELY(x) __builtin_expect((x), 1)
 #	define ANKI_UNLIKELY(x) __builtin_expect((x), 0)
 #	define ANKI_RESTRICT __restrict
@@ -158,7 +156,7 @@
 #	define ANKI_HOT __attribute__ ((hot))
 #	define ANKI_UNREACHABLE() __builtin_unreachable()
 #	define ANKI_PREFETCH_MEMORY(addr) __builtin_prefetch(addr)
-#elif defined(_MSC_VER)
+#else
 #	define ANKI_LIKELY(x) ((x) == 1)
 #	define ANKI_UNLIKELY(x) ((x) == 1)
 #	define ANKI_RESTRICT
@@ -170,12 +168,10 @@
 #	define ANKI_HOT
 #	define ANKI_UNREACHABLE() __assume(false)
 #	define ANKI_PREFETCH_MEMORY(addr) (void)(addr)
-#else
-#	error Unsupported compiler
 #endif
 
 // Pack structs
-#if defined(_MSC_VER)
+#if ANKI_COMPILER_MSVC
 #	define ANKI_BEGIN_PACKED_STRUCT __pragma(pack (push, 1))
 #	define ANKI_END_PACKED_STRUCT __pragma(pack (pop))
 #else
@@ -183,20 +179,24 @@
 #	define ANKI_END_PACKED_STRUCT _Pragma("pack (pop)")
 #endif
 
-// Popcount
-#ifdef _MSC_VER
+// Builtins
+#if ANKI_COMPILER_MSVC
 #	include <intrin.h>
 #	define __builtin_popcount __popcnt
 #	define __builtin_clzll(x) ((int)__lzcnt64(x))
 #endif
 
+// Constants
+#define ANKI_SAFE_ALIGNMENT 16
+#define ANKI_CACHE_LINE_SIZE 64
+
+// Misc
+#define ANKI_FILE __FILE__
+#define ANKI_FUNC __func__
+
 #ifdef ANKI_BUILD
 #	define anki_internal public
 #else
 #	define anki_internal protected
 #endif
-
-// General config
-#define ANKI_SAFE_ALIGNMENT 16
-#define ANKI_CACHE_LINE_SIZE 64
 /// @}

+ 1 - 1
src/anki/collision/ConvexHullShape.h

@@ -34,7 +34,7 @@ public:
 	/// owner of the storage.
 	/// @param points The base of the storage buffer. Size should be @a pointCount * sizeof(Vec4)
 	/// @param pointCount The number of points
-	ConvexHullShape(const Vec4* points, U pointCount)
+	ConvexHullShape(const Vec4* points, U32 pointCount)
 		: m_trf(Transform::getIdentity())
 		, m_invTrf(Transform::getIdentity())
 		, m_points(points)

+ 3 - 3
src/anki/collision/FunctionsTestCollision.cpp

@@ -28,7 +28,7 @@ static Bool testCollisionGjk(const T& a, const Y& b)
 
 Bool testCollision(const Aabb& a, const Aabb& b)
 {
-#if ANKI_SIMD == ANKI_SIMD_SSE
+#if ANKI_SIMD_SSE
 	const __m128 gt0 = _mm_cmpgt_ps(a.getMin().getSimd(), b.getMax().getSimd());
 	const __m128 gt1 = _mm_cmpgt_ps(b.getMin().getSimd(), a.getMax().getSimd());
 
@@ -66,7 +66,7 @@ Bool testCollision(const Aabb& aabb, const Sphere& s)
 	const Vec4& c = s.getCenter();
 
 	// Find the box's closest point to the sphere
-#if ANKI_SIMD == ANKI_SIMD_SSE
+#if ANKI_SIMD_SSE
 	__m128 gt = _mm_cmpgt_ps(c.getSimd(), aabb.getMax().getSimd());
 	__m128 lt = _mm_cmplt_ps(c.getSimd(), aabb.getMin().getSimd());
 
@@ -416,4 +416,4 @@ Bool intersect(const Sphere& sphere, const Ray& ray, Array<Vec4, 2>& intersectio
 	}
 }
 
-} // end namespace anki
+} // end namespace anki

+ 3 - 3
src/anki/collision/FunctionsTestPlane.cpp

@@ -10,7 +10,7 @@ namespace anki
 
 F32 testPlane(const Plane& plane, const Aabb& aabb)
 {
-#if ANKI_SIMD == ANKI_SIMD_SSE
+#if ANKI_SIMD_SSE
 	__m128 gezero = _mm_cmpge_ps(plane.getNormal().getSimd(), _mm_setzero_ps());
 
 	Vec4 diagMin;
@@ -42,7 +42,7 @@ F32 testPlane(const Plane& plane, const Aabb& aabb)
 		return test;
 	}
 
-#if ANKI_SIMD == ANKI_SIMD_SSE
+#if ANKI_SIMD_SSE
 	Vec4 diagMax;
 	diagMax.getSimd() =
 		_mm_or_ps(_mm_and_ps(gezero, aabb.getMax().getSimd()), _mm_andnot_ps(gezero, aabb.getMin().getSimd()));
@@ -183,4 +183,4 @@ F32 testPlane(const Plane& plane, const LineSegment& ls)
 	}
 }
 
-} // end namespace anki
+} // end namespace anki

+ 1 - 1
src/anki/collision/Obb.cpp

@@ -37,7 +37,7 @@ void Obb::getExtremePoints(Array<Vec4, 8>& points) const
 	check();
 
 	// L: left, R: right, T: top, B: bottom, F: front, B: back
-	enum
+	enum : U8
 	{
 		RTF,
 		LTF,

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

@@ -26,14 +26,14 @@
 #include <anki/ui/UiManager.h>
 #include <anki/ui/Canvas.h>
 
-#if ANKI_OS == ANKI_OS_ANDROID
+#if ANKI_OS_ANDROID
 #	include <android_native_app_glue.h>
 #endif
 
 namespace anki
 {
 
-#if ANKI_OS == ANKI_OS_ANDROID
+#if ANKI_OS_ANDROID
 /// The one and only android hack
 android_app* gAndroidApp = nullptr;
 #endif
@@ -85,7 +85,7 @@ public:
 	U64 m_vkGpuMem = 0;
 	U32 m_vkCmdbCount = 0;
 
-	U32 m_drawableCount = 0;
+	PtrSize m_drawableCount = 0;
 
 	static const U32 BUFFERED_FRAMES = 16;
 	U32 m_bufferedFrames = 0;
@@ -316,7 +316,7 @@ Error App::init(const ConfigSet& config, AllocAlignedCallback allocCb, void* all
 Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb, void* allocCbUserData)
 {
 	ConfigSet config = config_;
-	m_displayStats = config.getNumber("core.displayStats");
+	m_displayStats = config.getNumberU32("core.displayStats");
 
 	initMemoryCallbacks(allocCb, allocCbUserData);
 	m_heapAlloc = HeapAllocator<U8>(m_allocCb, m_allocCbData);
@@ -362,7 +362,7 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 	m_timerTick = 1.0 / 60.0; // in sec. 1.0 / period
 
 // Check SIMD support
-#if ANKI_SIMD == ANKI_SIMD_SSE && ANKI_COMPILER != ANKI_COMPILER_MSVC
+#if ANKI_SIMD_SSE && ANKI_COMPILER_GCC_COMPATIBLE
 	if(!__builtin_cpu_supports("sse4.2"))
 	{
 		ANKI_CORE_LOGF(
@@ -370,17 +370,17 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 	}
 #endif
 
-	ANKI_CORE_LOGI("Number of main threads: %u", U(config.getNumber("core.mainThreadCount")));
+	ANKI_CORE_LOGI("Number of main threads: %u", U(config.getNumberU32("core.mainThreadCount")));
 
 	//
 	// Window
 	//
 	NativeWindowInitInfo nwinit;
-	nwinit.m_width = config.getNumber("width");
-	nwinit.m_height = config.getNumber("height");
+	nwinit.m_width = config.getNumberU32("width");
+	nwinit.m_height = config.getNumberU32("height");
 	nwinit.m_depthBits = 0;
 	nwinit.m_stencilBits = 0;
-	nwinit.m_fullscreenDesktopRez = config.getNumber("window.fullscreen");
+	nwinit.m_fullscreenDesktopRez = config.getBool("window.fullscreen");
 	m_window = m_heapAlloc.newInstance<NativeWindow>();
 
 	ANKI_CHECK(m_window->init(nwinit, m_heapAlloc));
@@ -394,7 +394,7 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 	//
 	// ThreadPool
 	//
-	m_threadHive = m_heapAlloc.newInstance<ThreadHive>(config.getNumber("core.mainThreadCount"), m_heapAlloc, true);
+	m_threadHive = m_heapAlloc.newInstance<ThreadHive>(config.getNumberU32("core.mainThreadCount"), m_heapAlloc, true);
 
 	//
 	// Graphics API
@@ -493,7 +493,7 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 
 Error App::initDirs(const ConfigSet& cfg)
 {
-#if ANKI_OS != ANKI_OS_ANDROID
+#if !ANKI_OS_ANDROID
 	// Settings path
 	StringAuto home(m_heapAlloc);
 	ANKI_CHECK(getHomeDirectory(m_heapAlloc, home));
@@ -514,10 +514,10 @@ Error App::initDirs(const ConfigSet& cfg)
 	m_cacheDir.sprintf(m_heapAlloc, "%s/cache", &m_settingsDir[0]);
 
 	const Bool cacheDirExists = directoryExists(m_cacheDir.toCString());
-	if(cfg.getNumber("core.clearCaches") && cacheDirExists)
+	if(cfg.getBool("core.clearCaches") && cacheDirExists)
 	{
 		ANKI_CORE_LOGI("Will delete the cache dir and start fresh: %s", &m_cacheDir[0]);
-		ANKI_CHECK(removeDirectory(m_cacheDir.toCString()));
+		ANKI_CHECK(removeDirectory(m_cacheDir.toCString(), m_heapAlloc));
 		ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
 	}
 	else if(!cacheDirExists)

+ 3 - 3
src/anki/core/App.h

@@ -10,14 +10,14 @@
 #include <anki/util/String.h>
 #include <anki/util/Ptr.h>
 #include <anki/ui/UiImmediateModeBuilder.h>
-#if ANKI_OS == ANKI_OS_ANDROID
+#if ANKI_OS_ANDROID
 #	include <android_native_app_glue.h>
 #endif
 
 namespace anki
 {
 
-#if ANKI_OS == ANKI_OS_ANDROID
+#if ANKI_OS_ANDROID
 extern android_app* gAndroidApp;
 #endif
 
@@ -47,7 +47,7 @@ public:
 
 	ANKI_USE_RESULT Error init(const ConfigSet& config, AllocAlignedCallback allocCb, void* allocCbUserData);
 
-	F32 getTimerTick() const
+	Second getTimerTick() const
 	{
 		return m_timerTick;
 	}

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

@@ -45,7 +45,7 @@ void DeveloperConsole::build(CanvasPtr ctx)
 	ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoTitleBar);
 
 	ImGui::SetWindowPos(Vec2(0.0f, 0.0f));
-	ImGui::SetWindowSize(Vec2(ctx->getWidth(), ctx->getHeight() * (2.0f / 3.0f)));
+	ImGui::SetWindowSize(Vec2(F32(ctx->getWidth()), F32(ctx->getHeight()) * (2.0f / 3.0f)));
 
 	// Push the items
 	const F32 footerHeightToPreserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();

+ 5 - 5
src/anki/core/NativeWindowSdl.cpp

@@ -5,7 +5,7 @@
 
 #include <anki/core/NativeWindowSdl.h>
 #include <anki/util/Logger.h>
-#if ANKI_GR_BACKEND == ANKI_GR_BACKEND_VULKAN
+#if ANKI_GR_BACKEND_VULKAN
 #	include <SDL_vulkan.h>
 #endif
 
@@ -25,7 +25,7 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 		return Error::FUNCTION_FAILED;
 	}
 
-#if ANKI_GR_BACKEND == ANKI_GR_BACKEND_VULKAN
+#if ANKI_GR_BACKEND_VULKAN
 	if(SDL_Vulkan_LoadLibrary(nullptr))
 	{
 		ANKI_CORE_LOGE("SDL_Vulkan_LoadLibrary() failed: %s", SDL_GetError());
@@ -38,7 +38,7 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 	//
 	ANKI_CORE_LOGI("Creating SDL window. SDL version %u.%u", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
 
-#if ANKI_GR_BACKEND == ANKI_GR_BACKEND_GL
+#if ANKI_GR_BACKEND_GL
 	if(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, init.m_rgbaBits[0])
 		|| SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, init.m_rgbaBits[1])
 		|| SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, init.m_rgbaBits[2])
@@ -56,9 +56,9 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 	//
 	U32 flags = 0;
 
-#if ANKI_GR_BACKEND == ANKI_GR_BACKEND_GL
+#if ANKI_GR_BACKEND_GL
 	flags |= SDL_WINDOW_OPENGL;
-#elif ANKI_GR_BACKEND == ANKI_GR_BACKEND_VULKAN
+#elif ANKI_GR_BACKEND_VULKAN
 	flags |= SDL_WINDOW_VULKAN;
 #endif
 

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

@@ -26,10 +26,10 @@ Error StagingGpuMemoryManager::init(GrManager* gr, const ConfigSet& cfg)
 {
 	m_gr = gr;
 
-	m_perFrameBuffers[StagingGpuMemoryType::UNIFORM].m_size = cfg.getNumber("core.uniformPerFrameMemorySize");
-	m_perFrameBuffers[StagingGpuMemoryType::STORAGE].m_size = cfg.getNumber("core.storagePerFrameMemorySize");
-	m_perFrameBuffers[StagingGpuMemoryType::VERTEX].m_size = cfg.getNumber("core.vertexPerFrameMemorySize");
-	m_perFrameBuffers[StagingGpuMemoryType::TEXTURE].m_size = cfg.getNumber("core.textureBufferPerFrameMemorySize");
+	m_perFrameBuffers[StagingGpuMemoryType::UNIFORM].m_size = cfg.getNumberU32("core.uniformPerFrameMemorySize");
+	m_perFrameBuffers[StagingGpuMemoryType::STORAGE].m_size = cfg.getNumberU32("core.storagePerFrameMemorySize");
+	m_perFrameBuffers[StagingGpuMemoryType::VERTEX].m_size = cfg.getNumberU32("core.vertexPerFrameMemorySize");
+	m_perFrameBuffers[StagingGpuMemoryType::TEXTURE].m_size = cfg.getNumberU32("core.textureBufferPerFrameMemorySize");
 
 	initBuffer(StagingGpuMemoryType::UNIFORM,
 		gr->getDeviceCapabilities().m_uniformBufferBindOffsetAlignment,

+ 22 - 25
src/anki/gr/Common.h

@@ -37,19 +37,19 @@ class CommandBufferInitInfo;
 #define ANKI_GR_LOGF(...) ANKI_LOG("GR  ", FATAL, __VA_ARGS__)
 
 // Some constants
-const U MAX_VERTEX_ATTRIBUTES = 8;
-const U MAX_COLOR_ATTACHMENTS = 4;
-const U MAX_DESCRIPTOR_SETS = 2; ///< Groups that can be bound at the same time.
-const U MAX_BINDINGS_PER_DESCRIPTOR_SET = 32;
-const U MAX_BINDLESS_TEXTURES = 256;
-const U MAX_BINDLESS_IMAGES = 32;
+const U32 MAX_VERTEX_ATTRIBUTES = 8;
+const U32 MAX_COLOR_ATTACHMENTS = 4;
+const U32 MAX_DESCRIPTOR_SETS = 2; ///< Groups that can be bound at the same time.
+const U32 MAX_BINDINGS_PER_DESCRIPTOR_SET = 32;
+const U32 MAX_BINDLESS_TEXTURES = 256;
+const U32 MAX_BINDLESS_IMAGES = 32;
 
-const U MAX_FRAMES_IN_FLIGHT = 3; ///< Triple buffering.
+const U32 MAX_FRAMES_IN_FLIGHT = 3; ///< Triple buffering.
 
-const U MAX_GR_OBJECT_NAME_LENGTH = 31;
+const U32 MAX_GR_OBJECT_NAME_LENGTH = 31;
 
 /// The number of commands in a command buffer that make it a small batch command buffer.
-const U COMMAND_BUFFER_SMALL_BATCH_MAX_COMMANDS = 100;
+const U32 COMMAND_BUFFER_SMALL_BATCH_MAX_COMMANDS = 100;
 
 /// Smart pointer for resources.
 template<typename T>
@@ -100,25 +100,25 @@ class GpuDeviceCapabilities
 {
 public:
 	/// The alignment of offsets when bounding uniform buffers.
-	PtrSize m_uniformBufferBindOffsetAlignment = MAX_U32;
+	U32 m_uniformBufferBindOffsetAlignment = MAX_U32;
 
 	/// The max visible range of uniform buffers inside the shaders.
 	PtrSize m_uniformBufferMaxRange = 0;
 
 	/// The alignment of offsets when bounding storage buffers.
-	PtrSize m_storageBufferBindOffsetAlignment = MAX_U32;
+	U32 m_storageBufferBindOffsetAlignment = MAX_U32;
 
 	/// The max visible range of storage buffers inside the shaders.
 	PtrSize m_storageBufferMaxRange = 0;
 
 	/// The alignment of offsets when bounding texture buffers.
-	PtrSize m_textureBufferBindOffsetAlignment = MAX_U32;
+	U32 m_textureBufferBindOffsetAlignment = MAX_U32;
 
 	/// The max visible range of texture buffers inside the shaders.
 	PtrSize m_textureBufferMaxRange = 0;
 
 	/// Max push constant size.
-	U32 m_pushConstantsSize = 128;
+	PtrSize m_pushConstantsSize = 128;
 
 	/// GPU vendor.
 	GpuVendor m_gpuVendor = GpuVendor::UNKNOWN;
@@ -128,9 +128,6 @@ public:
 
 	/// API version.
 	U8 m_majorApiVersion = 0;
-
-	// WARNING Remember to pad it because valgrind complains.
-	U8 _m_padding[1];
 };
 
 /// The type of the allocator for heap allocations
@@ -187,7 +184,7 @@ public:
 
 	TextureSurfaceInfo(const TextureSurfaceInfo&) = default;
 
-	TextureSurfaceInfo(U level, U depth, U face, U layer)
+	TextureSurfaceInfo(U32 level, U32 depth, U32 face, U32 layer)
 		: m_level(level)
 		, m_depth(depth)
 		, m_face(face)
@@ -226,7 +223,7 @@ public:
 
 	TextureVolumeInfo(const TextureVolumeInfo&) = default;
 
-	TextureVolumeInfo(U level)
+	TextureVolumeInfo(U32 level)
 		: m_level(level)
 	{
 	}
@@ -261,7 +258,7 @@ public:
 		, m_mipmapCount(1)
 		, m_firstLayer(surf.m_layer)
 		, m_layerCount(1)
-		, m_firstFace(surf.m_face)
+		, m_firstFace(U8(surf.m_face))
 		, m_faceCount(1)
 		, m_depthStencilAspect(aspect)
 	{
@@ -358,11 +355,11 @@ private:
 };
 
 /// Compute max number of mipmaps for a 2D texture.
-inline U computeMaxMipmapCount2d(U w, U h, U minSizeOfLastMip = 1)
+inline U32 computeMaxMipmapCount2d(U32 w, U32 h, U32 minSizeOfLastMip = 1)
 {
 	ANKI_ASSERT(w >= minSizeOfLastMip && h >= minSizeOfLastMip);
-	U s = (w < h) ? w : h;
-	U count = 0;
+	U32 s = (w < h) ? w : h;
+	U32 count = 0;
 	while(s >= minSizeOfLastMip)
 	{
 		s /= 2;
@@ -373,11 +370,11 @@ inline U computeMaxMipmapCount2d(U w, U h, U minSizeOfLastMip = 1)
 }
 
 /// Compute max number of mipmaps for a 3D texture.
-inline U computeMaxMipmapCount3d(U w, U h, U d)
+inline U32 computeMaxMipmapCount3d(U32 w, U32 h, U32 d)
 {
-	U s = (w < h) ? w : h;
+	U32 s = (w < h) ? w : h;
 	s = (s < d) ? s : d;
-	U count = 0;
+	U32 count = 0;
 	while(s)
 	{
 		s /= 2;

+ 16 - 16
src/anki/gr/RenderGraph.cpp

@@ -683,11 +683,11 @@ RenderGraph::BakeContext* RenderGraph::newContext(const RenderGraphDescription&
 void RenderGraph::initRenderPassesAndSetDeps(const RenderGraphDescription& descr, StackAllocator<U8>& alloc)
 {
 	BakeContext& ctx = *m_ctx;
-	const U passCount = descr.m_passes.getSize();
+	const U32 passCount = U32(descr.m_passes.getSize());
 	ANKI_ASSERT(passCount > 0);
 
 	ctx.m_passes.create(alloc, passCount);
-	for(U passIdx = 0; passIdx < passCount; ++passIdx)
+	for(U32 passIdx = 0; passIdx < passCount; ++passIdx)
 	{
 		const RenderPassDescriptionBase& inPass = *descr.m_passes[passIdx];
 		Pass& outPass = ctx.m_passes[passIdx];
@@ -734,7 +734,7 @@ void RenderGraph::initRenderPassesAndSetDeps(const RenderGraphDescription& descr
 		}
 
 		// Set dependencies by checking all previous subpasses.
-		U prevPassIdx = passIdx;
+		U32 prevPassIdx = passIdx;
 		while(prevPassIdx--)
 		{
 			const RenderPassDescriptionBase& prevPass = *descr.m_passes[prevPassIdx];
@@ -761,7 +761,7 @@ void RenderGraph::initBatches()
 
 		Bool drawsToPresentable = false;
 
-		for(U i = 0; i < passCount; ++i)
+		for(U32 i = 0; i < passCount; ++i)
 		{
 			if(!m_ctx->m_passIsInBatch.get(i) && !passHasUnmetDependencies(*m_ctx, i))
 			{
@@ -807,7 +807,7 @@ void RenderGraph::initBatches()
 		for(U32 passIdx : m_ctx->m_batches.getBack().m_passIndices)
 		{
 			m_ctx->m_passIsInBatch.set(passIdx);
-			m_ctx->m_passes[passIdx].m_batchIdx = m_ctx->m_batches.getSize() - 1;
+			m_ctx->m_passes[passIdx].m_batchIdx = U32(m_ctx->m_batches.getSize() - 1);
 		}
 	}
 }
@@ -881,15 +881,15 @@ void RenderGraph::initGraphicsPasses(const RenderGraphDescription& descr, StackA
 template<typename TFunc>
 void RenderGraph::iterateSurfsOrVolumes(const TexturePtr& tex, const TextureSubresourceInfo& subresource, TFunc func)
 {
-	for(U mip = subresource.m_firstMipmap; mip < subresource.m_firstMipmap + subresource.m_mipmapCount; ++mip)
+	for(U32 mip = subresource.m_firstMipmap; mip < subresource.m_firstMipmap + subresource.m_mipmapCount; ++mip)
 	{
-		for(U layer = subresource.m_firstLayer; layer < subresource.m_firstLayer + subresource.m_layerCount; ++layer)
+		for(U32 layer = subresource.m_firstLayer; layer < subresource.m_firstLayer + subresource.m_layerCount; ++layer)
 		{
-			for(U face = subresource.m_firstFace; face < subresource.m_firstFace + subresource.m_faceCount; ++face)
+			for(U32 face = subresource.m_firstFace; face < subresource.m_firstFace + subresource.m_faceCount; ++face)
 			{
 				// Compute surf or vol idx
-				const U faceCount = textureTypeIsCube(tex->getTextureType()) ? 6 : 1;
-				const U idx = (faceCount * tex->getLayerCount()) * mip + faceCount * layer + face;
+				const U32 faceCount = textureTypeIsCube(tex->getTextureType()) ? 6 : 1;
+				const U32 idx = (faceCount * tex->getLayerCount()) * mip + faceCount * layer + face;
 				const TextureSurfaceInfo surf(mip, 0, face, layer);
 
 				if(!func(idx, surf))
@@ -906,8 +906,8 @@ void RenderGraph::setTextureBarrier(Batch& batch, const RenderPassDependency& de
 	ANKI_ASSERT(dep.m_isTexture);
 
 	BakeContext& ctx = *m_ctx;
-	const U batchIdx = &batch - &ctx.m_batches[0];
-	const U rtIdx = dep.m_texture.m_handle.m_idx;
+	const U32 batchIdx = U32(&batch - &ctx.m_batches[0]);
+	const U32 rtIdx = dep.m_texture.m_handle.m_idx;
 	const TextureUsageBit depUsage = dep.m_texture.m_usage;
 	RT& rt = ctx.m_rts[rtIdx];
 
@@ -944,7 +944,7 @@ void RenderGraph::setTextureBarrier(Batch& batch, const RenderPassDependency& de
 					batch.m_barriersBefore.emplaceBack(ctx.m_alloc, rtIdx, crntUsage, depUsage, surf);
 
 					crntUsage = depUsage;
-					rt.m_lastBatchThatTransitionedIt[surfOrVolIdx] = batchIdx;
+					rt.m_lastBatchThatTransitionedIt[surfOrVolIdx] = U16(batchIdx);
 				}
 			}
 
@@ -1101,7 +1101,7 @@ void RenderGraph::runSecondLevel(U32 threadIdx)
 
 	for(Pass& p : m_ctx->m_passes)
 	{
-		const U size = p.m_secondLevelCmdbs.getSize();
+		const U32 size = U32(p.m_secondLevelCmdbs.getSize());
 		if(threadIdx < size)
 		{
 			ANKI_ASSERT(!p.m_secondLevelCmdbs[threadIdx].isCreated());
@@ -1109,7 +1109,7 @@ void RenderGraph::runSecondLevel(U32 threadIdx)
 
 			ctx.m_commandBuffer = p.m_secondLevelCmdbs[threadIdx];
 			ctx.m_secondLevelCommandBufferCount = size;
-			ctx.m_passIdx = &p - &m_ctx->m_passes[0];
+			ctx.m_passIdx = U32(&p - &m_ctx->m_passes[0]);
 			ctx.m_batchIdx = p.m_batchIdx;
 			ctx.m_userData = p.m_userData;
 
@@ -1161,7 +1161,7 @@ void RenderGraph::run() const
 		}
 
 		// Call the passes
-		for(U passIdx : batch.m_passIndices)
+		for(U32 passIdx : batch.m_passIndices)
 		{
 			const Pass& pass = m_ctx->m_passes[passIdx];
 

+ 2 - 2
src/anki/gr/RenderGraph.h

@@ -179,7 +179,7 @@ public:
 	}
 
 	/// Convenience method to bind the whole texture as color.
-	void bindColorTexture(U32 set, U32 binding, RenderTargetHandle handle, U arrayIdx = 0)
+	void bindColorTexture(U32 set, U32 binding, RenderTargetHandle handle, U32 arrayIdx = 0)
 	{
 		TexturePtr tex = getTexture(handle);
 		TextureViewInitInfo viewInit(tex); // Use the whole texture
@@ -191,7 +191,7 @@ public:
 
 	/// Convenience method.
 	void bindImage(
-		U32 set, U32 binding, RenderTargetHandle handle, const TextureSubresourceInfo& subresource, U arrayIdx = 0)
+		U32 set, U32 binding, RenderTargetHandle handle, const TextureSubresourceInfo& subresource, U32 arrayIdx = 0)
 	{
 		TexturePtr tex;
 		TextureUsageBit usage;

+ 4 - 4
src/anki/gr/RenderGraph.inl.h

@@ -210,7 +210,7 @@ inline RenderTargetHandle RenderGraphDescription::importRenderTarget(TexturePtr
 	rt.setName(tex->getName());
 
 	RenderTargetHandle out;
-	out.m_idx = m_renderTargets.getSize() - 1;
+	out.m_idx = U32(m_renderTargets.getSize() - 1);
 	return out;
 }
 
@@ -233,7 +233,7 @@ inline RenderTargetHandle RenderGraphDescription::newRenderTarget(const RenderTa
 	rt.setName(initInf.getName());
 
 	RenderTargetHandle out;
-	out.m_idx = m_renderTargets.getSize() - 1;
+	out.m_idx = U32(m_renderTargets.getSize() - 1);
 	return out;
 }
 
@@ -251,8 +251,8 @@ inline RenderPassBufferHandle RenderGraphDescription::importBuffer(BufferPtr buf
 	b.m_importedBuff = buff;
 
 	RenderPassBufferHandle out;
-	out.m_idx = m_buffers.getSize() - 1;
+	out.m_idx = U32(m_buffers.getSize() - 1);
 	return out;
 }
 
-} // end namespace anki
+} // end namespace anki

+ 1 - 1
src/anki/gr/Sampler.h

@@ -22,7 +22,7 @@ public:
 	SamplingFilter m_minMagFilter = SamplingFilter::NEAREST;
 	SamplingFilter m_mipmapFilter = SamplingFilter::BASE;
 	CompareOperation m_compareOperation = CompareOperation::ALWAYS;
-	I8 m_anisotropyLevel = 0;
+	U8 m_anisotropyLevel = 0;
 	SamplingAddressing m_addressing = SamplingAddressing::REPEAT;
 	U8 _m_padding[3] = {0, 0, 0};
 

+ 4 - 3
src/anki/gr/ShaderCompiler.cpp

@@ -10,15 +10,16 @@
 #include <anki/util/Filesystem.h>
 #include <anki/core/Trace.h>
 
-#if defined(__GNUC__)
+#if ANKI_COMPILER_GCC_COMPATIBLE
 #	pragma GCC diagnostic push
 #	pragma GCC diagnostic ignored "-Wundef"
+#	pragma GCC diagnostic ignored "-Wconversion"
 #endif
 #include <glslang/Public/ShaderLang.h>
 #include <glslang/SPIRV/GlslangToSpv.h>
 #include <glslang/StandAlone/DirStackFileIncluder.h>
 #include <SPIRV-Cross/spirv_glsl.hpp>
-#if defined(__GNUC__)
+#if ANKI_COMPILER_GCC_COMPATIBLE
 #	pragma GCC diagnostic pop
 #endif
 
@@ -27,7 +28,7 @@ namespace anki
 
 void ShaderCompilerOptions::setFromGrManager(const GrManager& gr)
 {
-#if ANKI_GR_BACKEND == ANKI_GR_BACKEND_VULKAN
+#if ANKI_GR_BACKEND_VULKAN
 	m_outLanguage = ShaderLanguage::SPIRV;
 #else
 	m_outLanguage = ShaderLanguage::GLSL;

+ 1 - 1
src/anki/gr/TextureView.h

@@ -51,7 +51,7 @@ public:
 		m_mipmapCount = 1;
 		m_firstLayer = surf.m_layer;
 		m_layerCount = 1;
-		m_firstFace = surf.m_face;
+		m_firstFace = U8(surf.m_face);
 		m_faceCount = 1;
 		m_depthStencilAspect = aspect;
 		ANKI_ASSERT(isValid());

+ 9 - 9
src/anki/gr/common/ClassGpuAllocator.cpp

@@ -11,7 +11,7 @@ namespace anki
 {
 
 /// Max number of sub allocations (aka slots) per chunk.
-const U MAX_SLOTS_PER_CHUNK = 128;
+const U32 MAX_SLOTS_PER_CHUNK = 128;
 
 class ClassGpuAllocatorChunk : public IntrusiveListEnabled<ClassGpuAllocatorChunk>
 {
@@ -39,7 +39,7 @@ public:
 	PtrSize m_chunkSize = 0;
 
 	/// The max slot size for this class.
-	U32 m_maxSlotSize = 0;
+	PtrSize m_maxSlotSize = 0;
 
 	/// The number of slots for a single chunk.
 	U32 m_slotsPerChunkCount = 0;
@@ -67,11 +67,11 @@ void ClassGpuAllocator::init(GenericMemoryPoolAllocator<U8> alloc, ClassGpuAlloc
 	//
 	// Initialize the classes
 	//
-	U classCount = iface->getClassCount();
+	U32 classCount = iface->getClassCount();
 	ANKI_ASSERT(classCount > 0);
 	m_classes.create(m_alloc, classCount);
 
-	for(U i = 0; i < classCount; ++i)
+	for(U32 i = 0; i < classCount; ++i)
 	{
 		PtrSize slotSize = 0, chunkSize = 0;
 		m_iface->getClassInfo(i, slotSize, chunkSize);
@@ -84,7 +84,7 @@ void ClassGpuAllocator::init(GenericMemoryPoolAllocator<U8> alloc, ClassGpuAlloc
 		Class& c = m_classes[i];
 		c.m_chunkSize = chunkSize;
 		c.m_maxSlotSize = slotSize;
-		c.m_slotsPerChunkCount = chunkSize / slotSize;
+		c.m_slotsPerChunkCount = U32(chunkSize / slotSize);
 	}
 }
 
@@ -151,7 +151,7 @@ Error ClassGpuAllocator::createChunk(Class& cl, Chunk*& chunk)
 {
 	ClassGpuAllocatorMemory* mem = nullptr;
 
-	ANKI_CHECK(m_iface->allocate(&cl - &m_classes[0], mem));
+	ANKI_CHECK(m_iface->allocate(U32(&cl - &m_classes[0]), mem));
 	ANKI_ASSERT(mem);
 
 	chunk = m_alloc.newInstance<Chunk>();
@@ -194,8 +194,8 @@ Error ClassGpuAllocator::allocate(PtrSize size, U alignment, ClassGpuAllocatorHa
 	}
 
 	// Allocate from chunk
-	U bitCount = cl->m_slotsPerChunkCount;
-	for(U i = 0; i < bitCount; ++i)
+	U32 bitCount = cl->m_slotsPerChunkCount;
+	for(U32 i = 0; i < bitCount; ++i)
 	{
 		if(!chunk->m_inUseSlots.get(i))
 		{
@@ -225,7 +225,7 @@ void ClassGpuAllocator::free(ClassGpuAllocatorHandle& handle)
 	Class& cl = *chunk.m_class;
 
 	LockGuard<Mutex> lock(cl.m_mtx);
-	U slotIdx = handle.m_offset / cl.m_maxSlotSize;
+	const U32 slotIdx = U32(handle.m_offset / cl.m_maxSlotSize);
 
 	ANKI_ASSERT(chunk.m_inUseSlots.get(slotIdx));
 	ANKI_ASSERT(chunk.m_inUseSlotCount > 0);

+ 4 - 4
src/anki/gr/common/ClassGpuAllocator.h

@@ -31,17 +31,17 @@ public:
 	}
 
 	/// Allocate memory. Should be thread safe.
-	virtual ANKI_USE_RESULT Error allocate(U classIdx, ClassGpuAllocatorMemory*& mem) = 0;
+	virtual ANKI_USE_RESULT Error allocate(U32 classIdx, ClassGpuAllocatorMemory*& mem) = 0;
 
 	/// Free memory. Should be thread safe.
 	virtual void free(ClassGpuAllocatorMemory* mem) = 0;
 
 	/// Get the number of classes.
-	virtual U getClassCount() const = 0;
+	virtual U32 getClassCount() const = 0;
 
 	/// Get info for a class. Each chunk will be chunkSize size and it can host chunkSize/slotSize sub-allocations in
 	/// it.
-	virtual void getClassInfo(U classIdx, PtrSize& slotSize, PtrSize& chunkSize) const = 0;
+	virtual void getClassInfo(U32 classIdx, PtrSize& slotSize, PtrSize& chunkSize) const = 0;
 };
 
 /// The output of an allocation.
@@ -51,7 +51,7 @@ class ClassGpuAllocatorHandle
 
 public:
 	ClassGpuAllocatorMemory* m_memory = nullptr;
-	PtrSize m_offset = 0;
+	PtrSize m_offset = 0; ///< Relative offset inside m_memory
 
 	operator Bool() const
 	{

+ 2 - 2
src/anki/gr/common/StackGpuAllocator.cpp

@@ -13,7 +13,7 @@ class StackGpuAllocatorChunk
 public:
 	StackGpuAllocatorChunk* m_next;
 	StackGpuAllocatorMemory* m_mem;
-	Atomic<U32> m_offset;
+	Atomic<PtrSize> m_offset;
 	PtrSize m_size;
 };
 
@@ -91,7 +91,7 @@ Error StackGpuAllocator::allocate(PtrSize size, StackGpuAllocatorHandle& handle)
 					if(crntChunk)
 					{
 						crntChunk->m_next = newChunk;
-						newChunk->m_size = crntChunk->m_size * m_scale + m_bias;
+						newChunk->m_size = PtrSize(F32(crntChunk->m_size) * m_scale + F32(m_bias));
 					}
 					else
 					{

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

@@ -53,7 +53,7 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 	// Get mem requirements
 	VkMemoryRequirements req;
 	vkGetBufferMemoryRequirements(getDevice(), m_handle, &req);
-	U memIdx = MAX_U32;
+	U32 memIdx = MAX_U32;
 
 	if(access == BufferMapAccessBit::WRITE)
 	{
@@ -144,7 +144,7 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 	m_memoryFlags = props.memoryTypes[memIdx].propertyFlags;
 
 	// Allocate
-	getGrManagerImpl().getGpuMemoryManager().allocateMemory(memIdx, req.size, req.alignment, true, m_memHandle);
+	getGrManagerImpl().getGpuMemoryManager().allocateMemory(memIdx, req.size, U32(req.alignment), true, m_memHandle);
 
 	// Bind mem to buffer
 	{

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

@@ -257,10 +257,10 @@ void CommandBufferImpl::generateMipmaps2d(TextureViewPtr texView)
 	ANKI_ASSERT(tex.isSubresourceGoodForMipmapGeneration(view.getSubresource()));
 
 	const DepthStencilAspectBit aspect = view.getSubresource().m_depthStencilAspect;
-	const U face = view.getSubresource().m_firstFace;
-	const U layer = view.getSubresource().m_firstLayer;
+	const U32 face = view.getSubresource().m_firstFace;
+	const U32 layer = view.getSubresource().m_firstLayer;
 
-	for(U i = 0; i < tex.getMipmapCount() - 1u; ++i)
+	for(U32 i = 0; i < tex.getMipmapCount() - 1u; ++i)
 	{
 		// Transition source
 		if(i > 0)
@@ -304,7 +304,7 @@ void CommandBufferImpl::generateMipmaps2d(TextureViewPtr texView)
 
 		ANKI_ASSERT(srcWidth > 0 && srcHeight > 0 && dstWidth > 0 && dstHeight > 0);
 
-		U vkLayer = 0;
+		U32 vkLayer = 0;
 		switch(tex.getTextureType())
 		{
 		case TextureType::_2D:
@@ -404,7 +404,7 @@ void CommandBufferImpl::flushBarriers()
 	//
 
 	DynamicArrayAuto<VkImageMemoryBarrier> finalImgBarriers(m_alloc);
-	U finalImgBarrierCount = 0;
+	U32 finalImgBarrierCount = 0;
 	if(m_imgBarrierCount > 0)
 	{
 		DynamicArrayAuto<VkImageMemoryBarrier> squashedBarriers(m_alloc);
@@ -511,8 +511,8 @@ void CommandBufferImpl::flushQueryResets()
 			return a.m_queryIdx < b.m_queryIdx;
 		});
 
-	U firstQuery = m_queryResetAtoms[0].m_queryIdx;
-	U queryCount = 1;
+	U32 firstQuery = m_queryResetAtoms[0].m_queryIdx;
+	U32 queryCount = 1;
 	VkQueryPool pool = m_queryResetAtoms[0].m_pool;
 	for(U i = 1; i < m_queryResetAtomCount; ++i)
 	{
@@ -570,8 +570,8 @@ void CommandBufferImpl::flushWriteQueryResults()
 			return a.m_queryIdx < b.m_queryIdx;
 		});
 
-	U firstQuery = m_writeQueryAtoms[0].m_queryIdx;
-	U queryCount = 1;
+	U32 firstQuery = m_writeQueryAtoms[0].m_queryIdx;
+	U32 queryCount = 1;
 	VkQueryPool pool = m_writeQueryAtoms[0].m_pool;
 	PtrSize offset = m_writeQueryAtoms[0].m_offset;
 	VkBuffer buff = m_writeQueryAtoms[0].m_buffer;
@@ -624,10 +624,10 @@ void CommandBufferImpl::copyBufferToTextureViewInternal(
 	const TextureVolumeInfo vol(view.getSubresource().m_firstMipmap);
 
 	// Compute the sizes of the mip
-	const U width = tex.getWidth() >> surf.m_level;
-	const U height = tex.getHeight() >> surf.m_level;
+	const U32 width = tex.getWidth() >> surf.m_level;
+	const U32 height = tex.getHeight() >> surf.m_level;
 	ANKI_ASSERT(width && height);
-	const U depth = (is3D) ? (tex.getDepth() >> surf.m_level) : 1u;
+	const U32 depth = (is3D) ? (tex.getDepth() >> surf.m_level) : 1u;
 
 	if(!tex.m_workarounds)
 	{
@@ -711,7 +711,7 @@ void CommandBufferImpl::copyBufferToTextureViewInternal(
 			ANKI_CMD(vkCmdCopyBuffer(m_handle,
 						 static_cast<const BufferImpl&>(*buff).getHandle(),
 						 shadowHandle,
-						 regions.getSize(),
+						 U32(regions.getSize()),
 						 &regions[0]),
 				ANY_OTHER_COMMAND);
 		}

+ 4 - 4
src/anki/gr/vulkan/CommandBufferImpl.h

@@ -525,10 +525,10 @@ private:
 		ANKI_ASSERT(miny + height <= fbHeight);
 
 		VkViewport s = {};
-		s.x = minx;
-		s.y = (flipvp) ? (fbHeight - miny) : miny; // Move to the bottom;
-		s.width = width;
-		s.height = (flipvp) ? -F32(height) : height;
+		s.x = F32(minx);
+		s.y = (flipvp) ? F32(fbHeight - miny) : F32(miny); // Move to the bottom;
+		s.width = F32(width);
+		s.height = (flipvp) ? -F32(height) : F32(height);
 		s.minDepth = 0.0f;
 		s.maxDepth = 1.0f;
 		return s;

+ 22 - 8
src/anki/gr/vulkan/CommandBufferImpl.inl.h

@@ -313,22 +313,29 @@ inline void CommandBufferImpl::dispatchCompute(U32 groupCountX, U32 groupCountY,
 	commandCommon();
 
 	// Bind descriptors
-	for(U i = 0; i < MAX_DESCRIPTOR_SETS; ++i)
+	for(U32 i = 0; i < MAX_DESCRIPTOR_SETS; ++i)
 	{
 		if(m_computeProg->getReflectionInfo().m_descriptorSetMask.get(i))
 		{
 			DescriptorSet dset;
 			Bool dirty;
-			Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET> dynamicOffsets;
-			U dynamicOffsetCount;
+			Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET> dynamicOffsetsPtrSize;
+			U32 dynamicOffsetCount;
 			if(getGrManagerImpl().getDescriptorSetFactory().newDescriptorSet(
-				   m_tid, m_alloc, m_dsetState[i], dset, dirty, dynamicOffsets, dynamicOffsetCount))
+				   m_tid, m_alloc, m_dsetState[i], dset, dirty, dynamicOffsetsPtrSize, dynamicOffsetCount))
 			{
 				ANKI_VK_LOGF("Cannot recover");
 			}
 
 			if(dirty)
 			{
+				// Vulkan should have had the dynamic offsets as VkDeviceSize and not U32. Workaround that.
+				Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET> dynamicOffsets;
+				for(U32 i = 0; i < dynamicOffsetCount; ++i)
+				{
+					dynamicOffsets[i] = U32(dynamicOffsetsPtrSize[i]);
+				}
+
 				VkDescriptorSet dsHandle = dset.getHandle();
 
 				ANKI_CMD(vkCmdBindDescriptorSets(m_handle,
@@ -503,22 +510,29 @@ inline void CommandBufferImpl::drawcallCommon()
 	}
 
 	// Bind dsets
-	for(U i = 0; i < MAX_DESCRIPTOR_SETS; ++i)
+	for(U32 i = 0; i < MAX_DESCRIPTOR_SETS; ++i)
 	{
 		if(m_graphicsProg->getReflectionInfo().m_descriptorSetMask.get(i))
 		{
 			DescriptorSet dset;
 			Bool dirty;
-			Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET> dynamicOffsets;
-			U dynamicOffsetCount;
+			Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET> dynamicOffsetsPtrSize;
+			U32 dynamicOffsetCount;
 			if(getGrManagerImpl().getDescriptorSetFactory().newDescriptorSet(
-				   m_tid, m_alloc, m_dsetState[i], dset, dirty, dynamicOffsets, dynamicOffsetCount))
+				   m_tid, m_alloc, m_dsetState[i], dset, dirty, dynamicOffsetsPtrSize, dynamicOffsetCount))
 			{
 				ANKI_VK_LOGF("Cannot recover");
 			}
 
 			if(dirty)
 			{
+				// Vulkan should have had the dynamic offsets as VkDeviceSize and not U32. Workaround that.
+				Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET> dynamicOffsets;
+				for(U32 i = 0; i < dynamicOffsetCount; ++i)
+				{
+					dynamicOffsets[i] = U32(dynamicOffsetsPtrSize[i]);
+				}
+
 				VkDescriptorSet dsHandle = dset.getHandle();
 
 				ANKI_CMD(vkCmdBindDescriptorSets(m_handle,

+ 2 - 2
src/anki/gr/vulkan/Common.h

@@ -7,9 +7,9 @@
 
 #include <anki/gr/Common.h>
 
-#if ANKI_OS == ANKI_OS_LINUX
+#if ANKI_OS_LINUX
 #	define VK_USE_PLATFORM_XCB_KHR 1
-#elif ANKI_OS == ANKI_OS_WINDOWS
+#elif ANKI_OS_WINDOWS
 #	define VK_USE_PLATFORM_WIN32_KHR 1
 #else
 #	error TODO

+ 20 - 20
src/anki/gr/vulkan/DescriptorSet.cpp

@@ -102,7 +102,7 @@ public:
 
 	~DSLayoutCacheEntry();
 
-	ANKI_USE_RESULT Error init(const DescriptorBinding* bindings, U bindingCount, U64 hash);
+	ANKI_USE_RESULT Error init(const DescriptorBinding* bindings, U32 bindingCount, U64 hash);
 
 	ANKI_USE_RESULT Error getOrCreateThreadAllocator(ThreadId tid, DSThreadAllocator*& alloc);
 };
@@ -136,8 +136,8 @@ Error DSThreadAllocator::init()
 
 Error DSThreadAllocator::createNewPool()
 {
-	m_lastPoolDSCount =
-		(m_lastPoolDSCount != 0) ? (m_lastPoolDSCount * DESCRIPTOR_POOL_SIZE_SCALE) : DESCRIPTOR_POOL_INITIAL_SIZE;
+	m_lastPoolDSCount = (m_lastPoolDSCount != 0) ? U32(F32(m_lastPoolDSCount) * DESCRIPTOR_POOL_SIZE_SCALE)
+												 : DESCRIPTOR_POOL_INITIAL_SIZE;
 	m_lastPoolFreeDSCount = m_lastPoolDSCount;
 
 	// Set the create info
@@ -343,11 +343,11 @@ void DSThreadAllocator::writeSet(const Array<AnyBindingExtended, MAX_BINDINGS_PE
 	writeTemplate.dstSet = set.m_handle;
 	writeTemplate.descriptorCount = 1;
 
-	for(U bindingIdx = m_layoutEntry->m_minBinding; bindingIdx <= m_layoutEntry->m_maxBinding; ++bindingIdx)
+	for(U32 bindingIdx = m_layoutEntry->m_minBinding; bindingIdx <= m_layoutEntry->m_maxBinding; ++bindingIdx)
 	{
 		if(m_layoutEntry->m_activeBindings.get(bindingIdx))
 		{
-			for(U arrIdx = 0; arrIdx < m_layoutEntry->m_bindingArraySize[bindingIdx]; ++arrIdx)
+			for(U32 arrIdx = 0; arrIdx < m_layoutEntry->m_bindingArraySize[bindingIdx]; ++arrIdx)
 			{
 				const AnyBinding& b = (bindings[bindingIdx].m_arraySize == 1) ? bindings[bindingIdx].m_single
 																			  : bindings[bindingIdx].m_array[arrIdx];
@@ -378,7 +378,7 @@ void DSThreadAllocator::writeSet(const Array<AnyBindingExtended, MAX_BINDINGS_PE
 
 	// Write
 	vkUpdateDescriptorSets(m_layoutEntry->m_factory->m_dev,
-		writeInfos.getSize(),
+		U32(writeInfos.getSize()),
 		(writeInfos.getSize() > 0) ? &writeInfos[0] : nullptr,
 		0,
 		nullptr);
@@ -401,7 +401,7 @@ DSLayoutCacheEntry::~DSLayoutCacheEntry()
 	}
 }
 
-Error DSLayoutCacheEntry::init(const DescriptorBinding* bindings, U bindingCount, U64 hash)
+Error DSLayoutCacheEntry::init(const DescriptorBinding* bindings, U32 bindingCount, U64 hash)
 {
 	ANKI_ASSERT(bindings);
 	ANKI_ASSERT(hash > 0);
@@ -438,7 +438,7 @@ Error DSLayoutCacheEntry::init(const DescriptorBinding* bindings, U bindingCount
 	ANKI_VK_CHECK(vkCreateDescriptorSetLayout(m_factory->m_dev, &ci, nullptr, &m_layoutHandle));
 
 	// Create the pool info
-	U poolSizeCount = 0;
+	U32 poolSizeCount = 0;
 	for(U i = 0; i < bindingCount; ++i)
 	{
 		U j;
@@ -525,8 +525,8 @@ Error DSLayoutCacheEntry::getOrCreateThreadAllocator(ThreadId tid, DSThreadAlloc
 }
 
 void DescriptorSetState::flush(U64& hash,
-	Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-	U& dynamicOffsetCount,
+	Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
+	U32& dynamicOffsetCount,
 	DescriptorSet& customDSet)
 {
 	// Set some values
@@ -672,7 +672,7 @@ Error DescriptorSetFactory::newDescriptorSetLayout(const DescriptorSetLayoutInit
 {
 	// Compute the hash for the layout
 	Array<DescriptorBinding, MAX_BINDINGS_PER_DESCRIPTOR_SET> bindings;
-	U bindingCount = init.m_bindings.getSize();
+	U32 bindingCount = U32(init.m_bindings.getSize());
 	U64 hash;
 
 	if(init.m_bindings.getSize() > 0)
@@ -726,8 +726,8 @@ Error DescriptorSetFactory::newDescriptorSet(ThreadId tid,
 	DescriptorSetState& state,
 	DescriptorSet& set,
 	Bool& dirty,
-	Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-	U& dynamicOffsetCount)
+	Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
+	U32& dynamicOffsetCount)
 {
 	ANKI_TRACE_SCOPED_EVENT(VK_DESCRIPTOR_SET_GET_OR_CREATE);
 
@@ -846,19 +846,19 @@ Error BindlessDescriptorSet::init(const GrAllocator<U8>& alloc, VkDevice dev)
 	// Init the free arrays
 	{
 		m_freeTexIndices.create(m_alloc, MAX_BINDLESS_TEXTURES);
-		m_freeTexIndexCount = m_freeTexIndices.getSize();
+		m_freeTexIndexCount = U16(m_freeTexIndices.getSize());
 
 		for(U i = 0; i < m_freeTexIndices.getSize(); ++i)
 		{
-			m_freeTexIndices[i] = m_freeTexIndices.getSize() - i - 1;
+			m_freeTexIndices[i] = U16(m_freeTexIndices.getSize() - i - 1);
 		}
 
 		m_freeImgIndices.create(m_alloc, MAX_BINDLESS_IMAGES);
-		m_freeImgIndexCount = m_freeImgIndices.getSize();
+		m_freeImgIndexCount = U16(m_freeImgIndices.getSize());
 
 		for(U i = 0; i < m_freeImgIndices.getSize(); ++i)
 		{
-			m_freeImgIndices[i] = m_freeImgIndices.getSize() - i - 1;
+			m_freeImgIndices[i] = U16(m_freeImgIndices.getSize() - i - 1);
 		}
 	}
 
@@ -894,7 +894,7 @@ U32 BindlessDescriptorSet::bindTexture(const VkImageView view, const VkImageLayo
 
 	// Get the index
 	--m_freeTexIndexCount;
-	const U idx = m_freeTexIndices[m_freeTexIndexCount];
+	const U16 idx = m_freeTexIndices[m_freeTexIndexCount];
 	ANKI_ASSERT(idx < MAX_BINDLESS_TEXTURES);
 
 	// Update the set
@@ -925,7 +925,7 @@ U32 BindlessDescriptorSet::bindImage(const VkImageView view)
 
 	// Get the index
 	--m_freeImgIndexCount;
-	const U idx = m_freeImgIndices[m_freeImgIndexCount];
+	const U32 idx = m_freeImgIndices[m_freeImgIndexCount];
 	ANKI_ASSERT(idx < MAX_BINDLESS_IMAGES);
 
 	// Update the set
@@ -955,7 +955,7 @@ void BindlessDescriptorSet::unbindCommon(U32 idx, DynamicArray<U16>& freeIndices
 	LockGuard<Mutex> lock(m_mtx);
 	ANKI_ASSERT(freeIndexCount < freeIndices.getSize());
 
-	freeIndices[freeIndexCount] = idx;
+	freeIndices[freeIndexCount] = U16(idx);
 	++freeIndexCount;
 
 	// Sort the free indices to minimize fragmentation

+ 10 - 10
src/anki/gr/vulkan/DescriptorSet.h

@@ -182,7 +182,7 @@ public:
 	}
 
 	void bindTextureAndSampler(
-		U binding, U arrayIdx, const TextureView* texView, const Sampler* sampler, VkImageLayout layout)
+		U32 binding, U32 arrayIdx, const TextureView* texView, const Sampler* sampler, VkImageLayout layout)
 	{
 		const TextureViewImpl& viewImpl = static_cast<const TextureViewImpl&>(*texView);
 		ANKI_ASSERT(viewImpl.getTextureImpl().isSubresourceGoodForSampling(viewImpl.getSubresource()));
@@ -201,7 +201,7 @@ public:
 		unbindCustomDSet();
 	}
 
-	void bindTexture(U binding, U arrayIdx, const TextureView* texView, VkImageLayout layout)
+	void bindTexture(U32 binding, U32 arrayIdx, const TextureView* texView, VkImageLayout layout)
 	{
 		const TextureViewImpl& viewImpl = static_cast<const TextureViewImpl&>(*texView);
 		ANKI_ASSERT(viewImpl.getTextureImpl().isSubresourceGoodForSampling(viewImpl.getSubresource()));
@@ -218,7 +218,7 @@ public:
 		unbindCustomDSet();
 	}
 
-	void bindSampler(U binding, U arrayIdx, const Sampler* sampler)
+	void bindSampler(U32 binding, U32 arrayIdx, const Sampler* sampler)
 	{
 		AnyBinding& b = getBindingToPopulate(binding, arrayIdx);
 		b = {};
@@ -230,7 +230,7 @@ public:
 		unbindCustomDSet();
 	}
 
-	void bindUniformBuffer(U binding, U arrayIdx, const Buffer* buff, PtrSize offset, PtrSize range)
+	void bindUniformBuffer(U32 binding, U32 arrayIdx, const Buffer* buff, PtrSize offset, PtrSize range)
 	{
 		AnyBinding& b = getBindingToPopulate(binding, arrayIdx);
 		b = {};
@@ -245,7 +245,7 @@ public:
 		unbindCustomDSet();
 	}
 
-	void bindStorageBuffer(U binding, U arrayIdx, const Buffer* buff, PtrSize offset, PtrSize range)
+	void bindStorageBuffer(U32 binding, U32 arrayIdx, const Buffer* buff, PtrSize offset, PtrSize range)
 	{
 		AnyBinding& b = getBindingToPopulate(binding, arrayIdx);
 		b = {};
@@ -260,7 +260,7 @@ public:
 		unbindCustomDSet();
 	}
 
-	void bindImage(U binding, U arrayIdx, const TextureView* texView)
+	void bindImage(U32 binding, U32 arrayIdx, const TextureView* texView)
 	{
 		ANKI_ASSERT(texView);
 		const TextureViewImpl* impl = static_cast<const TextureViewImpl*>(texView);
@@ -301,8 +301,8 @@ private:
 	/// Only DescriptorSetFactory should call this.
 	/// @param hash If hash is zero then the DS doesn't need rebind.
 	void flush(U64& hash,
-		Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-		U& dynamicOffsetCount,
+		Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
+		U32& dynamicOffsetCount,
 		DescriptorSet& customDSet);
 
 	void unbindCustomDSet()
@@ -384,8 +384,8 @@ public:
 		DescriptorSetState& state,
 		DescriptorSet& set,
 		Bool& dirty,
-		Array<U32, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-		U& dynamicOffsetCount);
+		Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
+		U32& dynamicOffsetCount);
 
 	void endFrame()
 	{

+ 3 - 3
src/anki/gr/vulkan/FramebufferImpl.cpp

@@ -38,10 +38,10 @@ Error FramebufferImpl::init(const FramebufferInitInfo& init)
 	ANKI_ASSERT(init.isValid());
 
 	// Init common
-	for(U i = 0; i < init.m_colorAttachmentCount; ++i)
+	for(U32 i = 0; i < init.m_colorAttachmentCount; ++i)
 	{
 		m_colorAttachmentMask.set(i);
-		m_colorAttCount = i + 1;
+		m_colorAttCount = U8(i + 1);
 	}
 
 	if(init.m_depthStencilAttachment.m_textureView)
@@ -180,7 +180,7 @@ void FramebufferImpl::setupAttachmentDescriptor(
 void FramebufferImpl::initRpassCreateInfo(const FramebufferInitInfo& init)
 {
 	// Setup attachments and references
-	for(U i = 0; i < init.m_colorAttachmentCount; ++i)
+	for(U32 i = 0; i < init.m_colorAttachmentCount; ++i)
 	{
 		setupAttachmentDescriptor(
 			init.m_colorAttachments[i], m_attachmentDescriptions[i], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);

+ 2 - 2
src/anki/gr/vulkan/FramebufferImpl.h

@@ -57,7 +57,7 @@ public:
 		stencil = !!(m_aspect & DepthStencilAspectBit::STENCIL);
 	}
 
-	U getColorAttachmentCount() const
+	U32 getColorAttachmentCount() const
 	{
 		return m_colorAttCount;
 	}
@@ -67,7 +67,7 @@ public:
 		return !!m_aspect;
 	}
 
-	U getAttachmentCount() const
+	U32 getAttachmentCount() const
 	{
 		return m_colorAttCount + (hasDepthStencil() ? 1 : 0);
 	}

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

@@ -9,7 +9,7 @@
 namespace anki
 {
 
-const U CLASS_COUNT = 7;
+constexpr U32 CLASS_COUNT = 7;
 
 class ClassInf
 {
@@ -47,7 +47,7 @@ public:
 	VkDevice m_dev = VK_NULL_HANDLE;
 	U8 m_memTypeIdx = MAX_U8;
 
-	Error allocate(U classIdx, ClassGpuAllocatorMemory*& cmem)
+	Error allocate(U32 classIdx, ClassGpuAllocatorMemory*& cmem) override
 	{
 		Memory* mem;
 
@@ -70,7 +70,7 @@ public:
 			ci.memoryTypeIndex = m_memTypeIdx;
 			ANKI_VK_CHECKF(vkAllocateMemory(m_dev, &ci, nullptr, &mem->m_handle));
 
-			mem->m_classIdx = classIdx;
+			mem->m_classIdx = U8(classIdx);
 		}
 
 		ANKI_ASSERT(mem);
@@ -82,7 +82,7 @@ public:
 		return Error::NONE;
 	}
 
-	void free(ClassGpuAllocatorMemory* cmem)
+	void free(ClassGpuAllocatorMemory* cmem) override
 	{
 		ANKI_ASSERT(cmem);
 
@@ -100,12 +100,12 @@ public:
 		}
 	}
 
-	U getClassCount() const
+	U32 getClassCount() const override
 	{
 		return CLASS_COUNT;
 	}
 
-	void getClassInfo(U classIdx, PtrSize& slotSize, PtrSize& chunkSize) const
+	void getClassInfo(U32 classIdx, PtrSize& slotSize, PtrSize& chunkSize) const override
 	{
 		slotSize = CLASSES[classIdx].m_slotSize;
 		chunkSize = CLASSES[classIdx].m_chunkSize;
@@ -204,7 +204,7 @@ void GpuMemoryManager::init(VkPhysicalDevice pdev, VkDevice dev, GrAllocator<U8>
 
 		iface.m_alloc = alloc;
 		iface.m_dev = dev;
-		iface.m_memTypeIdx = i;
+		iface.m_memTypeIdx = U8(i);
 	}
 
 	// One allocator per type per linear/non-linear resources
@@ -221,7 +221,7 @@ void GpuMemoryManager::init(VkPhysicalDevice pdev, VkDevice dev, GrAllocator<U8>
 }
 
 void GpuMemoryManager::allocateMemory(
-	U memTypeIdx, PtrSize size, U alignment, Bool linearResource, GpuMemoryHandle& handle)
+	U32 memTypeIdx, PtrSize size, U32 alignment, Bool linearResource, GpuMemoryHandle& handle)
 {
 	ClassGpuAllocator& calloc = m_callocs[memTypeIdx * 2 + ((linearResource) ? 0 : 1)];
 	Error err = calloc.allocate(size, alignment, handle.m_classHandle);
@@ -230,7 +230,7 @@ void GpuMemoryManager::allocateMemory(
 	handle.m_memory = static_cast<Memory*>(handle.m_classHandle.m_memory)->m_handle;
 	handle.m_offset = handle.m_classHandle.m_offset;
 	handle.m_linear = linearResource;
-	handle.m_memTypeIdx = memTypeIdx;
+	handle.m_memTypeIdx = U8(memTypeIdx);
 }
 
 void GpuMemoryManager::freeMemory(GpuMemoryHandle& handle)
@@ -252,13 +252,13 @@ void* GpuMemoryManager::getMappedAddress(GpuMemoryHandle& handle)
 	return static_cast<void*>(out + handle.m_offset);
 }
 
-U GpuMemoryManager::findMemoryType(
-	U resourceMemTypeBits, VkMemoryPropertyFlags preferFlags, VkMemoryPropertyFlags avoidFlags) const
+U32 GpuMemoryManager::findMemoryType(
+	U32 resourceMemTypeBits, VkMemoryPropertyFlags preferFlags, VkMemoryPropertyFlags avoidFlags) const
 {
-	U prefered = MAX_U32;
+	U32 prefered = MAX_U32;
 
 	// Iterate all mem types
-	for(U i = 0; i < m_memoryProperties.memoryTypeCount; i++)
+	for(U32 i = 0; i < m_memoryProperties.memoryTypeCount; i++)
 	{
 		if(resourceMemTypeBits & (1u << i))
 		{

+ 3 - 2
src/anki/gr/vulkan/GpuMemoryManager.h

@@ -47,7 +47,7 @@ public:
 	void destroy();
 
 	/// Allocate memory.
-	void allocateMemory(U memTypeIdx, PtrSize size, U alignment, Bool linearResource, GpuMemoryHandle& handle);
+	void allocateMemory(U32 memTypeIdx, PtrSize size, U32 alignment, Bool linearResource, GpuMemoryHandle& handle);
 
 	/// Free memory.
 	void freeMemory(GpuMemoryHandle& handle);
@@ -56,7 +56,8 @@ public:
 	ANKI_USE_RESULT void* getMappedAddress(GpuMemoryHandle& handle);
 
 	/// Find a suitable memory type.
-	U findMemoryType(U resourceMemTypeBits, VkMemoryPropertyFlags preferFlags, VkMemoryPropertyFlags avoidFlags) const;
+	U32 findMemoryType(
+		U32 resourceMemTypeBits, VkMemoryPropertyFlags preferFlags, VkMemoryPropertyFlags avoidFlags) const;
 
 	/// Get some statistics.
 	void getAllocatedMemory(PtrSize& gpuMemory, PtrSize& cpuMemory) const;

+ 17 - 17
src/anki/gr/vulkan/GrManagerImpl.cpp

@@ -109,7 +109,7 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 	ANKI_CHECK(initDevice(init));
 	vkGetDeviceQueue(m_device, m_queueIdx, 0, &m_queue);
 
-	m_swapchainFactory.init(this, init.m_config->getNumber("window.vsync"));
+	m_swapchainFactory.init(this, init.m_config->getBool("window.vsync"));
 
 	m_crntSwapchain = m_swapchainFactory.newInstance();
 
@@ -221,8 +221,8 @@ Error GrManagerImpl::initInstance(const GrManagerInitInfo& init)
 
 	// Create the instance
 	//
-	const U32 vulkanMinor = init.m_config->getNumber("gr.vkminor");
-	const U32 vulkanMajor = init.m_config->getNumber("gr.vkmajor");
+	const U8 vulkanMinor = init.m_config->getNumberU8("gr.vkminor");
+	const U8 vulkanMajor = init.m_config->getNumberU8("gr.vkmajor");
 
 	VkApplicationInfo app = {};
 	app.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
@@ -239,7 +239,7 @@ Error GrManagerImpl::initInstance(const GrManagerInitInfo& init)
 	// Layers
 	static Array<const char*, 1> LAYERS = {{"VK_LAYER_KHRONOS_validation"}};
 	Array<const char*, LAYERS.getSize()> layersToEnable; // Keep it alive in the stack
-	if(init.m_config->getNumber("window.debugContext"))
+	if(init.m_config->getBool("window.debugContext"))
 	{
 		uint32_t count;
 		vkEnumerateInstanceLayerProperties(&count, nullptr);
@@ -295,17 +295,17 @@ Error GrManagerImpl::initInstance(const GrManagerInitInfo& init)
 			ANKI_VK_LOGI("\t%s", instExtensionInf[i].extensionName);
 		}
 
-		U instExtensionCount = 0;
+		U32 instExtensionCount = 0;
 
 		for(U i = 0; i < extCount; ++i)
 		{
-#if ANKI_OS == ANKI_OS_LINUX
+#if ANKI_OS_LINUX
 			if(CString(instExtensionInf[i].extensionName) == VK_KHR_XCB_SURFACE_EXTENSION_NAME)
 			{
 				m_extensions |= VulkanExtensions::KHR_XCB_SURFACE;
 				instExtensions[instExtensionCount++] = VK_KHR_XCB_SURFACE_EXTENSION_NAME;
 			}
-#elif ANKI_OS == ANKI_OS_WINDOWS
+#elif ANKI_OS_WINDOWS
 			if(CString(instExtensionInf[i].extensionName) == VK_KHR_WIN32_SURFACE_EXTENSION_NAME)
 			{
 				m_extensions |= VulkanExtensions::KHR_WIN32_SURFACE;
@@ -416,18 +416,18 @@ Error GrManagerImpl::initInstance(const GrManagerInitInfo& init)
 
 	vkGetPhysicalDeviceFeatures(m_physicalDevice, &m_devFeatures);
 	m_devFeatures.robustBufferAccess =
-		(init.m_config->getNumber("window.debugContext") && m_devFeatures.robustBufferAccess) ? true : false;
+		(init.m_config->getBool("window.debugContext") && m_devFeatures.robustBufferAccess) ? true : false;
 	ANKI_VK_LOGI("Robust buffer access is %s", (m_devFeatures.robustBufferAccess) ? "enabled" : "disabled");
 
 	// Set limits
 	m_capabilities.m_uniformBufferBindOffsetAlignment =
-		max<U32>(ANKI_SAFE_ALIGNMENT, m_devProps.limits.minUniformBufferOffsetAlignment);
+		max<U32>(ANKI_SAFE_ALIGNMENT, U32(m_devProps.limits.minUniformBufferOffsetAlignment));
 	m_capabilities.m_uniformBufferMaxRange = m_devProps.limits.maxUniformBufferRange;
 	m_capabilities.m_storageBufferBindOffsetAlignment =
-		max<U32>(ANKI_SAFE_ALIGNMENT, m_devProps.limits.minStorageBufferOffsetAlignment);
+		max<U32>(ANKI_SAFE_ALIGNMENT, U32(m_devProps.limits.minStorageBufferOffsetAlignment));
 	m_capabilities.m_storageBufferMaxRange = m_devProps.limits.maxStorageBufferRange;
 	m_capabilities.m_textureBufferBindOffsetAlignment =
-		max<U32>(ANKI_SAFE_ALIGNMENT, m_devProps.limits.minTexelBufferOffsetAlignment);
+		max<U32>(ANKI_SAFE_ALIGNMENT, U32(m_devProps.limits.minTexelBufferOffsetAlignment));
 	m_capabilities.m_textureBufferMaxRange = MAX_U32;
 
 	m_capabilities.m_majorApiVersion = vulkanMajor;
@@ -448,7 +448,7 @@ Error GrManagerImpl::initDevice(const GrManagerInitInfo& init)
 
 	uint32_t desiredFamilyIdx = MAX_U32;
 	const VkQueueFlags DESITED_QUEUE_FLAGS = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT;
-	for(U i = 0; i < count; ++i)
+	for(U32 i = 0; i < count; ++i)
 	{
 		if((queueInfos[i].queueFlags & DESITED_QUEUE_FLAGS) == DESITED_QUEUE_FLAGS)
 		{
@@ -495,7 +495,7 @@ Error GrManagerImpl::initDevice(const GrManagerInitInfo& init)
 	{
 		extensionInfos.create(extCount);
 		extensionsToEnable.create(extCount);
-		U extensionsToEnableCount = 0;
+		U32 extensionsToEnableCount = 0;
 		vkEnumerateDeviceExtensionProperties(m_physicalDevice, nullptr, &extCount, &extensionInfos[0]);
 
 		ANKI_VK_LOGI("Found the following device extensions:");
@@ -517,7 +517,7 @@ Error GrManagerImpl::initDevice(const GrManagerInitInfo& init)
 				extensionsToEnable[extensionsToEnableCount++] = VK_KHR_MAINTENANCE1_EXTENSION_NAME;
 			}
 			else if(CString(extensionInfos[extCount].extensionName) == VK_EXT_DEBUG_MARKER_EXTENSION_NAME
-					&& init.m_config->getNumber("window.debugMarkers"))
+					&& init.m_config->getBool("window.debugMarkers"))
 			{
 				m_extensions |= VulkanExtensions::EXT_DEBUG_MARKER;
 				extensionsToEnable[extensionsToEnableCount++] = VK_EXT_DEBUG_MARKER_EXTENSION_NAME;
@@ -533,7 +533,7 @@ Error GrManagerImpl::initDevice(const GrManagerInitInfo& init)
 				extensionsToEnable[extensionsToEnableCount++] = VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME;
 			}
 			else if(CString(extensionInfos[extCount].extensionName) == VK_AMD_SHADER_INFO_EXTENSION_NAME
-					&& init.m_config->getNumber("core.displayStats"))
+					&& init.m_config->getBool("core.displayStats"))
 			{
 				m_extensions |= VulkanExtensions::AMD_SHADER_INFO;
 				extensionsToEnable[extensionsToEnableCount++] = VK_AMD_SHADER_INFO_EXTENSION_NAME;
@@ -731,7 +731,7 @@ TexturePtr GrManagerImpl::acquireNextPresentableTexture()
 	}
 
 	ANKI_ASSERT(imageIdx < MAX_FRAMES_IN_FLIGHT);
-	m_acquiredImageIdx = imageIdx;
+	m_acquiredImageIdx = U8(imageIdx);
 	return m_crntSwapchain->m_textures[imageIdx];
 }
 
@@ -871,7 +871,7 @@ void GrManagerImpl::trySetVulkanHandleName(CString name, VkDebugReportObjectType
 			VkDebugMarkerObjectNameInfoEXT inf = {};
 			inf.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
 			inf.objectType = type;
-			inf.pObjectName = name.get();
+			inf.pObjectName = name.cstr();
 			inf.object = handle;
 
 			m_pfnDebugMarkerSetObjectNameEXT(m_device, &inf);

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

@@ -9,9 +9,9 @@
 #include <anki/core/NativeWindowSdl.h>
 #include <SDL_syswm.h>
 #include <SDL_vulkan.h>
-#if ANKI_OS == ANKI_OS_LINUX
+#if ANKI_OS_LINUX
 #	include <X11/Xlib-xcb.h>
-#elif ANKI_OS == ANKI_OS_WINDOWS
+#elif ANKI_OS_WINDOWS
 #	include <Winuser.h>
 #	include <anki/util/CleanupWindows.h>
 #else

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

@@ -213,7 +213,7 @@ const VkGraphicsPipelineCreateInfo& PipelineStateTracker::updatePipelineCreateIn
 	vertCi.pVertexBindingDescriptions = &m_ci.m_vertBindings[0];
 
 	BitSet<MAX_VERTEX_ATTRIBUTES, U8> bindingSet = {false};
-	for(U i = 0; i < MAX_VERTEX_ATTRIBUTES; ++i)
+	for(U32 i = 0; i < MAX_VERTEX_ATTRIBUTES; ++i)
 	{
 		if(m_shaderAttributeMask.get(i))
 		{
@@ -221,7 +221,7 @@ const VkGraphicsPipelineCreateInfo& PipelineStateTracker::updatePipelineCreateIn
 			attrib.binding = m_state.m_vertex.m_attributes[i].m_binding;
 			attrib.format = convertFormat(m_state.m_vertex.m_attributes[i].m_format);
 			attrib.location = i;
-			attrib.offset = m_state.m_vertex.m_attributes[i].m_offset;
+			attrib.offset = U32(m_state.m_vertex.m_attributes[i].m_offset);
 
 			if(!bindingSet.get(attrib.binding))
 			{

+ 3 - 3
src/anki/gr/vulkan/Pipeline.h

@@ -186,7 +186,7 @@ public:
 	void bindVertexBuffer(U32 binding, PtrSize stride, VertexStepRate stepRate)
 	{
 		PPVertexBufferBinding b;
-		b.m_stride = stride;
+		b.m_stride = U32(stride);
 		b.m_stepRate = stepRate;
 		if(m_state.m_vertex.m_bindings[binding] != b)
 		{
@@ -200,12 +200,12 @@ public:
 	void setVertexAttribute(U32 location, U32 buffBinding, const Format fmt, PtrSize relativeOffset)
 	{
 		PPVertexAttributeBinding b;
-		b.m_binding = buffBinding;
+		b.m_binding = U8(buffBinding);
 		b.m_format = fmt;
 		b.m_offset = relativeOffset;
 		if(m_state.m_vertex.m_attributes[location] != b)
 		{
-			m_state.m_vertex.m_attributes[location].m_binding = buffBinding;
+			m_state.m_vertex.m_attributes[location].m_binding = U8(buffBinding);
 			m_state.m_vertex.m_attributes[location].m_format = fmt;
 			m_state.m_vertex.m_attributes[location].m_offset = relativeOffset;
 			m_dirty.m_attribs.set(location);

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

@@ -15,7 +15,7 @@ Error PipelineCache::init(
 	VkDevice dev, VkPhysicalDevice pdev, CString cacheDir, const ConfigSet& cfg, GrAllocator<U8> alloc)
 {
 	ANKI_ASSERT(cacheDir && dev && pdev);
-	m_dumpSize = cfg.getNumber("gr.diskShaderCacheMaxSize");
+	m_dumpSize = cfg.getNumberU32("gr.diskShaderCacheMaxSize");
 	m_dumpFilename.sprintf(alloc, "%s/vk_pipeline_cache", &cacheDir[0]);
 
 	// Try read the pipeline cache file.

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

@@ -25,7 +25,7 @@ Error PipelineLayoutFactory::newPipelineLayout(
 {
 	U64 hash = computeHash(&pushConstantsSize, sizeof(pushConstantsSize));
 	Array<VkDescriptorSetLayout, MAX_DESCRIPTOR_SETS> vkDsetLayouts;
-	U dsetLayoutCount = 0;
+	U32 dsetLayoutCount = 0;
 	for(const DescriptorSetLayout& dl : dsetLayouts)
 	{
 		vkDsetLayouts[dsetLayoutCount++] = dl.getHandle();

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

@@ -59,7 +59,7 @@ Error QueryFactory::newQuery(MicroQuery& handle)
 	ANKI_ASSERT(chunk);
 
 	// Allocate from chunk
-	for(U i = 0; i < MAX_SUB_ALLOCATIONS_PER_QUERY_CHUNK; ++i)
+	for(U32 i = 0; i < MAX_SUB_ALLOCATIONS_PER_QUERY_CHUNK; ++i)
 	{
 		if(chunk->m_allocatedMask.get(i) == 0)
 		{

+ 10 - 9
src/anki/gr/vulkan/ShaderImpl.cpp

@@ -81,14 +81,14 @@ Error ShaderImpl::init(const ShaderInitInfo& inf)
 	// Set spec info
 	if(specConstIds.m_vec.size())
 	{
-		const U constCount = specConstIds.m_vec.size();
+		const U32 constCount = U32(specConstIds.m_vec.size());
 
 		m_specConstInfo.mapEntryCount = constCount;
 		m_specConstInfo.pMapEntries = getAllocator().newArray<VkSpecializationMapEntry>(constCount);
 		m_specConstInfo.dataSize = constCount * sizeof(I32);
 		m_specConstInfo.pData = getAllocator().newArray<I32>(constCount);
 
-		U count = 0;
+		U32 count = 0;
 		for(const spirv_cross::SpecializationConstant& sconst : specConstIds.m_vec)
 		{
 			// Set the entry
@@ -130,7 +130,7 @@ void ShaderImpl::doReflection(ConstWeakArray<U8> spirv, SpecConstsVector& specCo
 			ANKI_ASSERT(binding < MAX_BINDINGS_PER_DESCRIPTOR_SET);
 
 			const spirv_cross::SPIRType& typeInfo = spvc.get_type(r.type_id);
-			U arraySize = 1;
+			U32 arraySize = 1;
 			if(typeInfo.array.size() != 0)
 			{
 				ANKI_ASSERT(typeInfo.array.size() == 1 && "Only 1D arrays are supported");
@@ -142,8 +142,8 @@ void ShaderImpl::doReflection(ConstWeakArray<U8> spirv, SpecConstsVector& specCo
 			m_activeBindingMask[set].set(set);
 
 			// Check that there are no other descriptors with the same binding
-			U foundIdx = MAX_U;
-			for(U i = 0; i < counts[set]; ++i)
+			U32 foundIdx = MAX_U32;
+			for(U32 i = 0; i < counts[set]; ++i)
 			{
 				if(descriptors[set][i].m_binding == binding)
 				{
@@ -152,14 +152,14 @@ void ShaderImpl::doReflection(ConstWeakArray<U8> spirv, SpecConstsVector& specCo
 				}
 			}
 
-			if(foundIdx == MAX_U)
+			if(foundIdx == MAX_U32)
 			{
 				// New binding, init it
 				DescriptorBinding& descriptor = descriptors[set][counts[set]++];
-				descriptor.m_binding = binding;
+				descriptor.m_binding = U8(binding);
 				descriptor.m_type = type;
 				descriptor.m_stageMask = static_cast<ShaderTypeBit>(1 << m_shaderType);
-				descriptor.m_arraySizeMinusOne = arraySize - 1;
+				descriptor.m_arraySizeMinusOne = U8(arraySize - 1);
 			}
 			else
 			{
@@ -217,7 +217,8 @@ void ShaderImpl::doReflection(ConstWeakArray<U8> spirv, SpecConstsVector& specCo
 	// Push consts
 	if(rsrc.push_constant_buffers.size() == 1)
 	{
-		const U32 blockSize = spvc.get_declared_struct_size(spvc.get_type(rsrc.push_constant_buffers[0].base_type_id));
+		const U32 blockSize =
+			U32(spvc.get_declared_struct_size(spvc.get_type(rsrc.push_constant_buffers[0].base_type_id)));
 		ANKI_ASSERT(blockSize > 0);
 		ANKI_ASSERT(blockSize % 16 == 0 && "Should be aligned");
 		ANKI_ASSERT(blockSize <= getGrManagerImpl().getDeviceCapabilities().m_pushConstantsSize);

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

@@ -42,7 +42,7 @@ Error MicroSwapchain::initInternal()
 
 	// Get the surface size
 	VkSurfaceCapabilitiesKHR surfaceProperties;
-	U surfaceWidth = 0, surfaceHeight = 0;
+	U32 surfaceWidth = 0, surfaceHeight = 0;
 	{
 		ANKI_VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
 			m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(), &surfaceProperties));

+ 6 - 5
src/anki/gr/vulkan/TextureImpl.cpp

@@ -66,13 +66,13 @@ Error TextureImpl::initInternal(VkImage externalImage, const TextureInitInfo& in
 
 	if(m_texType == TextureType::_3D)
 	{
-		m_mipCount = min<U>(init.m_mipmapCount, computeMaxMipmapCount3d(m_width, m_height, m_depth));
+		m_mipCount = min<U32>(init.m_mipmapCount, computeMaxMipmapCount3d(m_width, m_height, m_depth));
 	}
 	else
 	{
-		m_mipCount = min<U>(init.m_mipmapCount, computeMaxMipmapCount2d(m_width, m_height));
+		m_mipCount = min<U32>(init.m_mipmapCount, computeMaxMipmapCount2d(m_width, m_height));
 	}
-	init.m_mipmapCount = m_mipCount;
+	init.m_mipmapCount = U8(m_mipCount);
 
 	m_layerCount = init.m_layerCount;
 
@@ -317,7 +317,7 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 	VkMemoryRequirements req = {};
 	vkGetImageMemoryRequirements(getDevice(), m_imageHandle, &req);
 
-	U memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
+	U32 memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
 		req.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
 
 	// Fallback
@@ -332,7 +332,8 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 	if(!useDedicatedMemory)
 	{
 		// Allocate
-		getGrManagerImpl().getGpuMemoryManager().allocateMemory(memIdx, req.size, req.alignment, false, m_memHandle);
+		getGrManagerImpl().getGpuMemoryManager().allocateMemory(
+			memIdx, req.size, U32(req.alignment), false, m_memHandle);
 
 		// Bind mem to image
 		ANKI_TRACE_SCOPED_EVENT(VK_BIND_OBJECT);

+ 3 - 3
src/anki/gr/vulkan/TextureImpl.h

@@ -100,9 +100,9 @@ public:
 	}
 
 	/// Compute the layer as defined by Vulkan.
-	U computeVkArrayLayer(const TextureSurfaceInfo& surf) const
+	U32 computeVkArrayLayer(const TextureSurfaceInfo& surf) const
 	{
-		U layer = 0;
+		U32 layer = 0;
 		switch(m_texType)
 		{
 		case TextureType::_2D:
@@ -124,7 +124,7 @@ public:
 		return layer;
 	}
 
-	U computeVkArrayLayer(const TextureVolumeInfo& vol) const
+	U32 computeVkArrayLayer(const TextureVolumeInfo& vol) const
 	{
 		ANKI_ASSERT(m_texType == TextureType::_3D);
 		return 0;

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

@@ -21,7 +21,7 @@ Error TimestampQueryImpl::init()
 {
 	ANKI_CHECK(getGrManagerImpl().getTimestampQueryFactory().newQuery(m_handle));
 
-	m_timestampPeriod = getGrManagerImpl().getPhysicalDeviceProperties().limits.timestampPeriod;
+	m_timestampPeriod = U64(getGrManagerImpl().getPhysicalDeviceProperties().limits.timestampPeriod);
 
 	return Error::NONE;
 }

+ 3 - 3
src/anki/input/Input.h

@@ -48,12 +48,12 @@ public:
 		return initInternal(nativeWindow);
 	}
 
-	U getKey(KeyCode i) const
+	U32 getKey(KeyCode i) const
 	{
-		return m_keys[static_cast<U>(i)];
+		return m_keys[i];
 	}
 
-	U getMouseButton(MouseButton i) const
+	U32 getMouseButton(MouseButton i) const
 	{
 		return m_mouseBtns[i];
 	}

+ 4 - 4
src/anki/input/InputSdl.cpp

@@ -359,8 +359,8 @@ Error Input::handleEvents()
 		case SDL_MOUSEMOTION:
 			m_mousePosWin.x() = event.button.x;
 			m_mousePosWin.y() = event.button.y;
-			m_mousePosNdc.x() = (F32)event.button.x / m_nativeWindow->getWidth() * 2.0 - 1.0;
-			m_mousePosNdc.y() = -((F32)event.button.y / m_nativeWindow->getHeight() * 2.0 - 1.0);
+			m_mousePosNdc.x() = F32(event.button.x) / F32(m_nativeWindow->getWidth()) * 2.0f - 1.0f;
+			m_mousePosNdc.y() = -(F32(event.button.y) / F32(m_nativeWindow->getHeight()) * 2.0f - 1.0f);
 			break;
 		case SDL_QUIT:
 			addEvent(InputEvent::WINDOW_CLOSED);
@@ -384,8 +384,8 @@ void Input::moveCursor(const Vec2& pos)
 {
 	if(pos != m_mousePosNdc)
 	{
-		const int x = m_nativeWindow->getWidth() * (pos.x() * 0.5f + 0.5f);
-		const int y = m_nativeWindow->getHeight() * (-pos.y() * 0.5f + 0.5f);
+		const I32 x = I32(F32(m_nativeWindow->getWidth()) * (pos.x() * 0.5f + 0.5f));
+		const I32 y = I32(F32(m_nativeWindow->getHeight()) * (-pos.y() * 0.5f + 0.5f));
 
 		SDL_WarpMouseInWindow(m_nativeWindow->getNative().m_window, x, y);
 

+ 5 - 5
src/anki/math/F16.cpp

@@ -40,19 +40,19 @@ F16 F16::toF16(F32 f)
 				m += 0x00002000;
 			}
 
-			out.m_data = s | (m >> 13);
+			out.m_data = U16(s | (m >> 13));
 		}
 	}
 	else if(e == 0xff - (127 - 15))
 	{
 		if(m == 0)
 		{
-			out.m_data = s | 0x7c00;
+			out.m_data = U16(s | 0x7c00);
 		}
 		else
 		{
 			m >>= 13;
-			out.m_data = s | 0x7c00 | m | (m == 0);
+			out.m_data = U16(s | 0x7c00 | m | (m == 0));
 		}
 	}
 	else
@@ -71,11 +71,11 @@ F16 F16::toF16(F32 f)
 		if(e > 30)
 		{
 			ANKI_ASSERT(0 && "Overflow");
-			out.m_data = s | 0x7c00;
+			out.m_data = U16(s | 0x7c00);
 		}
 		else
 		{
-			out.m_data = s | (e << 10) | (m >> 13);
+			out.m_data = U16(s | (e << 10) | (m >> 13));
 		}
 	}
 

+ 34 - 13
src/anki/math/Functions.h

@@ -5,7 +5,7 @@
 
 #pragma once
 
-#include <anki/util/StdTypes.h>
+#include <anki/util/Functions.h>
 #include <cmath>
 #include <cstdlib>
 
@@ -67,12 +67,18 @@ inline T atan2(const T x, const T y)
 void sinCos(const F32 a, F32& sina, F32& cosa);
 void sinCos(const F64 a, F64& sina, F64& cosa);
 
-template<typename T>
+template<typename T, ANKI_ENABLE(std::is_floating_point<T>::value)>
 inline T sqrt(const T x)
 {
 	return std::sqrt(x);
 }
 
+template<typename T, ANKI_ENABLE(std::is_integral<T>::value)>
+inline T sqrt(const T x)
+{
+	return T(std::sqrt(F64(x)));
+}
+
 template<typename T>
 inline T fract(const T x)
 {
@@ -109,6 +115,12 @@ inline T absolute(const T f)
 	return (f < T(0)) ? -f : f;
 }
 
+template<typename T>
+inline T pow(const T x, const T power)
+{
+	return T(std::pow(x, power));
+}
+
 template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
 inline Bool isZero(const T f, const T e = EPSILON)
 {
@@ -140,7 +152,7 @@ inline T toDegrees(const T rad)
 template<typename Type>
 inline Type linearInterpolate(const Type& from, const Type& to, F32 u)
 {
-	return from * (1.0f - u) + to * u;
+	return from * Type(1.0f - u) + to * Type(u);
 }
 
 /// Cosine interpolation
@@ -150,8 +162,8 @@ inline Type linearInterpolate(const Type& from, const Type& to, F32 u)
 template<typename Type>
 inline Type cosInterpolate(const Type& from, const Type& to, F32 u)
 {
-	F32 u2 = (1.0f - cos<Type>(u * PI)) / 2.0f;
-	return from * (1.0f - u2) + to * u2;
+	const F32 u2 = (1.0f - cos<Type>(u * PI)) / 2.0f;
+	return from * Type(1.0f - u2) + to * Type(u2);
 }
 
 /// Cubic interpolation
@@ -179,19 +191,28 @@ inline U32 packColorToR10G10B10A2SNorm(F32 r, F32 g, F32 b, F32 a)
 	{
 		struct
 		{
-			I m_x : 10;
-			I m_y : 10;
-			I m_z : 10;
-			I m_w : 2;
+			I32 m_x : 10;
+			I32 m_y : 10;
+			I32 m_z : 10;
+			I32 m_w : 2;
 		} m_unpacked;
 		U32 m_packed;
 	};
 
+#if ANKI_COMPILER_GCC_COMPATIBLE
+#	pragma GCC diagnostic push
+#	pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
 	SignedR10G10B10A10 out;
-	out.m_unpacked.m_x = I(round(r * 511.0f));
-	out.m_unpacked.m_y = I(round(g * 511.0f));
-	out.m_unpacked.m_z = I(round(b * 511.0f));
-	out.m_unpacked.m_w = I(round(a * 1.0f));
+	out.m_unpacked.m_x = I32(round(r * 511.0f));
+	out.m_unpacked.m_y = I32(round(g * 511.0f));
+	out.m_unpacked.m_z = I32(round(b * 511.0f));
+	out.m_unpacked.m_w = I32(round(a * 1.0f));
+
+#if ANKI_COMPILER_GCC_COMPATIBLE
+#	pragma GCC diagnostic pop
+#endif
 
 	return out.m_packed;
 }

+ 11 - 12
src/anki/math/Mat.h

@@ -31,10 +31,9 @@ public:
 	static constexpr U ROW_SIZE = J; ///< Number of rows
 	static constexpr U COLUMN_SIZE = I; ///< Number of columns
 	static constexpr U SIZE = J * I; ///< Number of total elements
-	static constexpr Bool HAS_SIMD = I == 4 && std::is_same<T, F32>::value && ANKI_SIMD == ANKI_SIMD_SSE;
-	static constexpr Bool HAS_MAT4_SIMD = J == 4 && I == 4 && std::is_same<T, F32>::value && ANKI_SIMD == ANKI_SIMD_SSE;
-	static constexpr Bool HAS_MAT3X4_SIMD =
-		J == 3 && I == 4 && std::is_same<T, F32>::value && ANKI_SIMD == ANKI_SIMD_SSE;
+	static constexpr Bool HAS_SIMD = I == 4 && std::is_same<T, F32>::value && ANKI_SIMD_SSE;
+	static constexpr Bool HAS_MAT4_SIMD = J == 4 && I == 4 && std::is_same<T, F32>::value && ANKI_SIMD_SSE;
+	static constexpr Bool HAS_MAT3X4_SIMD = J == 3 && I == 4 && std::is_same<T, F32>::value && ANKI_SIMD_SSE;
 
 	/// @name Constructors
 	/// @{
@@ -201,13 +200,13 @@ public:
 		setRotationPart(rot);
 		setTranslationPart(transl);
 		auto& m = *this;
-		m(3, 0) = m(3, 1) = m(3, 2) = 0.0;
+		m(3, 0) = m(3, 1) = m(3, 2) = T(0);
 	}
 
 	ANKI_ENABLE_METHOD(J == 4 && I == 4)
 	TMat(const TVec<T, 4>& transl, const TMat<T, 3, 3>& rot, const T scale)
 	{
-		if(isZero<T>(scale - 1.0))
+		if(isZero<T>(scale - T(1)))
 		{
 			setRotationPart(rot);
 		}
@@ -219,7 +218,7 @@ public:
 		setTranslationPart(transl);
 
 		auto& m = *this;
-		m(3, 0) = m(3, 1) = m(3, 2) = 0.0;
+		m(3, 0) = m(3, 1) = m(3, 2) = T(0);
 	}
 
 	ANKI_ENABLE_METHOD(J == 4 && I == 4)
@@ -972,17 +971,17 @@ public:
 		yz = q.y() * zs;
 		zz = q.z() * zs;
 
-		m(0, 0) = 1.0 - (yy + zz);
+		m(0, 0) = T(1) - (yy + zz);
 		m(0, 1) = xy - wz;
 		m(0, 2) = xz + wy;
 
 		m(1, 0) = xy + wz;
-		m(1, 1) = 1.0 - (xx + zz);
+		m(1, 1) = T(1) - (xx + zz);
 		m(1, 2) = yz - wx;
 
 		m(2, 0) = xz - wy;
 		m(2, 1) = yz + wx;
-		m(2, 2) = 1.0 - (xx + yy);
+		m(2, 2) = T(1) - (xx + yy);
 	}
 
 	void setRotationPart(const TEuler<T>& e)
@@ -1053,7 +1052,7 @@ public:
 	{
 		if(ROW_SIZE == 4)
 		{
-			ANKI_ASSERT(isZero<T>(v[3] - 1.0) && "w should be 1");
+			ANKI_ASSERT(isZero<T>(v[3] - T(1)) && "w should be 1");
 		}
 		setColumn(3, v);
 	}
@@ -1257,7 +1256,7 @@ public:
 		T det = in(0, 0) * m4(0, 0) + in(1, 0) * m4(0, 1) + in(2, 0) * m4(0, 2) + in(3, 0) * m4(0, 3);
 
 		ANKI_ASSERT(!isZero<T>(det)); // Cannot invert, det == 0
-		det = 1.0 / det;
+		det = T(1) / det;
 		m4 *= det;
 		return m4;
 	}

+ 2 - 2
src/anki/math/Quat.h

@@ -235,14 +235,14 @@ public:
 		}
 
 		const T halfTheta = acos<T>(cosHalfTheta);
-		const T sinHalfTheta = sqrt<T>(1.0 - cosHalfTheta * cosHalfTheta);
+		const T sinHalfTheta = sqrt<T>(T(1) - cosHalfTheta * cosHalfTheta);
 
 		if(absolute<T>(sinHalfTheta) < 0.001)
 		{
 			return TQuat((q0 + q1) * 0.5);
 		}
 
-		const T ratioA = sin<T>((1.0 - t) * halfTheta) / sinHalfTheta;
+		const T ratioA = sin<T>((T(1) - t) * halfTheta) / sinHalfTheta;
 		const T ratioB = sin<T>(t * halfTheta) / sinHalfTheta;
 		TQuat tmp, tmp1, sum;
 		tmp = q0 * ratioA;

+ 6 - 8
src/anki/math/Simd.h

@@ -7,13 +7,11 @@
 
 #include <anki/util/StdTypes.h>
 
-#if ANKI_SIMD == ANKI_SIMD_SSE
+#if ANKI_SIMD_SSE
 #	include <smmintrin.h>
-#elif ANKI_SIMD == ANKI_SIMD_NEON
+#elif ANKI_SIMD_NEON
 #	include <arm_neon.h>
-#elif ANKI_SIMD == ANKI_SIMD_NONE
-#	define ANKI_DUMMY_DUMMY_DUMMY 1
-#else
+#elif !ANKI_SIMD_NONE
 #	error "See file"
 #endif
 
@@ -29,7 +27,7 @@ public:
 	static constexpr U ALIGNMENT = alignof(T);
 };
 
-#if ANKI_SIMD == ANKI_SIMD_SSE
+#if ANKI_SIMD_SSE
 // Specialize for F32
 template<>
 class MathSimd<F32, 4>
@@ -38,7 +36,7 @@ public:
 	using Type = __m128;
 	static constexpr U ALIGNMENT = 16;
 };
-#elif ANKI_SIMD == ANKI_SIMD_NEON
+#elif ANKI_SIMD_NEON
 // Specialize for F32
 template<>
 class MathSimd<F32, 4>
@@ -49,4 +47,4 @@ public:
 };
 #endif
 
-} // end namespace anki
+} // end namespace anki

+ 1 - 1
src/anki/math/Transform.h

@@ -179,7 +179,7 @@ public:
 		TTransform o;
 		o.m_rotation = m_rotation;
 		o.m_rotation.transposeRotationPart();
-		o.m_scale = 1.0 / m_scale;
+		o.m_scale = T(1) / m_scale;
 		o.m_origin = -(o.m_rotation * (o.m_scale * m_origin)).xyz0();
 		return o;
 	}

+ 2 - 2
src/anki/math/Vec.h

@@ -24,7 +24,7 @@ public:
 	using Simd = typename MathSimd<T, N>::Type;
 	static constexpr U COMPONENT_COUNT = N;
 	static constexpr Bool IS_INTEGER = std::is_integral<T>::value;
-	static constexpr Bool HAS_VEC4_SIMD = N == 4 && std::is_same<T, F32>::value && ANKI_SIMD == ANKI_SIMD_SSE;
+	static constexpr Bool HAS_VEC4_SIMD = N == 4 && std::is_same<T, F32>::value && ANKI_SIMD_SSE;
 
 	/// @name Constructors
 	/// @{
@@ -55,7 +55,7 @@ public:
 	{
 		for(U i = 0; i < N; i++)
 		{
-			m_arr[i] = b[i];
+			m_arr[i] = T(b[i]);
 		}
 	}
 

+ 31 - 1
src/anki/misc/ConfigSet.cpp

@@ -126,7 +126,7 @@ void ConfigSet::set(const CString& name, const CString& value)
 	o->m_strVal.create(m_alloc, value);
 }
 
-F64 ConfigSet::getNumber(const CString& name) const
+F64 ConfigSet::getNumberF64(const CString& name) const
 {
 	const Option* option = tryFind(name);
 	ANKI_ASSERT(option);
@@ -134,6 +134,36 @@ F64 ConfigSet::getNumber(const CString& name) const
 	return option->m_fVal;
 }
 
+F32 ConfigSet::getNumberF32(const CString& name) const
+{
+	return F32(getNumberF64(name));
+}
+
+U32 ConfigSet::getNumberU32(const CString& name) const
+{
+	return U32(getNumberF64(name));
+}
+
+U16 ConfigSet::getNumberU16(const CString& name) const
+{
+	return U16(getNumberU32(name));
+}
+
+U8 ConfigSet::getNumberU8(const CString& name) const
+{
+	return U8(getNumberU32(name));
+}
+
+Bool ConfigSet::getBool(const CString& name) const
+{
+	const U32 val = getNumberU32(name);
+	if((val & ~U32(1)) != 0)
+	{
+		ANKI_MISC_LOGW("Expecting 0 or 1 for the config option \"%s\". Will mask out extra bits", name.cstr());
+	}
+	return val & 1;
+}
+
 CString ConfigSet::getString(const CString& name) const
 {
 	const Option* o = tryFind(name);

+ 6 - 1
src/anki/misc/ConfigSet.h

@@ -40,7 +40,12 @@ public:
 
 	/// @name Find an option and return it's value.
 	/// @{
-	F64 getNumber(const CString& name) const;
+	F64 getNumberF64(const CString& name) const;
+	F32 getNumberF32(const CString& name) const;
+	U32 getNumberU32(const CString& name) const;
+	U16 getNumberU16(const CString& name) const;
+	U8 getNumberU8(const CString& name) const;
+	Bool getBool(const CString& name) const;
 	CString getString(const CString& name) const;
 	/// @}
 

+ 1 - 1
src/anki/misc/Xml.cpp

@@ -237,7 +237,7 @@ Error XmlElement::getSiblingElementsCount(U32& out) const
 		++count;
 	} while(el);
 
-	out = count;
+	out = U32(count);
 
 	return Error::NONE;
 }

+ 1 - 1
src/anki/misc/Xml.h

@@ -202,7 +202,7 @@ public:
 			U count = 0;
 			for(F32 v : arr)
 			{
-				out[count++] = v;
+				out[count++] = typename T::Scalar(v);
 			}
 		}
 

+ 9 - 3
src/anki/physics/Common.h

@@ -10,8 +10,12 @@
 #include <anki/util/Ptr.h>
 #include <anki/Math.h>
 
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wall"
+#if ANKI_COMPILER_GCC_COMPATIBLE
+#	pragma GCC diagnostic push
+#	pragma GCC diagnostic ignored "-Wall"
+#	pragma GCC diagnostic ignored "-Wconversion"
+#	pragma GCC diagnostic ignored "-Wfloat-conversion"
+#endif
 #define BT_THREADSAFE 0
 #define BT_NO_PROFILE 1
 #include <btBulletCollisionCommon.h>
@@ -19,7 +23,9 @@
 #include <BulletCollision/CollisionDispatch/btGhostObject.h>
 #include <BulletDynamics/Character/btKinematicCharacterController.h>
 #include <BulletCollision/Gimpact/btGImpactShape.h>
-#pragma GCC diagnostic pop
+#if ANKI_COMPILER_GCC_COMPATIBLE
+#	pragma GCC diagnostic pop
+#endif
 
 namespace anki
 {

+ 1 - 1
src/anki/physics/PhysicsCollisionShape.cpp

@@ -66,7 +66,7 @@ PhysicsTriangleSoup::PhysicsTriangleSoup(
 	{
 		m_type = ShapeType::CONVEX; // Fake the type
 
-		m_convex.init(&positions[0][0], positions.getSize(), sizeof(Vec3));
+		m_convex.init(&positions[0][0], I32(positions.getSize()), sizeof(Vec3));
 		m_convex->setMargin(getWorld().getCollisionMargin());
 		m_convex->setUserPointer(static_cast<PhysicsObject*>(this));
 	}

+ 2 - 2
src/anki/physics/PhysicsTrigger.cpp

@@ -52,7 +52,7 @@ void PhysicsTrigger::processContacts()
 	}
 
 	// Process contacts
-	for(U i = 0; i < U(m_ghostShape->getOverlappingPairs().size()); ++i)
+	for(U32 i = 0; i < U32(m_ghostShape->getOverlappingPairs().size()); ++i)
 	{
 		btCollisionObject* obj = m_ghostShape->getOverlappingPairs()[i];
 
@@ -66,4 +66,4 @@ void PhysicsTrigger::processContacts()
 	}
 }
 
-} // end namespace anki
+} // end namespace anki

+ 1 - 1
src/anki/physics/PhysicsWorld.cpp

@@ -197,7 +197,7 @@ Error PhysicsWorld::update(Second dt)
 	// Update world
 	{
 		auto lock = lockBtWorld();
-		m_world->stepSimulation(dt, 1, 1.0 / 60.0);
+		m_world->stepSimulation(F32(dt), 1, 1.0f / 60.0f);
 	}
 
 	// Process trigger contacts

+ 4 - 4
src/anki/renderer/Bloom.cpp

@@ -24,11 +24,11 @@ Bloom::~Bloom()
 
 Error Bloom::initExposure(const ConfigSet& config)
 {
-	m_exposure.m_width = m_r->getDownscaleBlur().getPassWidth(MAX_U) * 2;
-	m_exposure.m_height = m_r->getDownscaleBlur().getPassHeight(MAX_U) * 2;
+	m_exposure.m_width = m_r->getDownscaleBlur().getPassWidth(MAX_U32) * 2;
+	m_exposure.m_height = m_r->getDownscaleBlur().getPassHeight(MAX_U32) * 2;
 
-	m_exposure.m_threshold = config.getNumber("r.bloom.threshold");
-	m_exposure.m_scale = config.getNumber("r.bloom.scale");
+	m_exposure.m_threshold = config.getNumberF32("r.bloom.threshold");
+	m_exposure.m_scale = config.getNumberF32("r.bloom.scale");
 
 	// Create RT info
 	m_exposure.m_rtDescr =

+ 22 - 21
src/anki/renderer/ClusterBin.cpp

@@ -114,7 +114,7 @@ void ClusterBin::init(
 
 	m_totalClusterCount = clusterCountX * clusterCountY * clusterCountZ;
 
-	m_avgObjectsPerCluster = cfg.getNumber("r.avgObjectsPerCluster");
+	m_avgObjectsPerCluster = cfg.getNumberU32("r.avgObjectsPerCluster");
 
 	// The actual indices per cluster are
 	// - the object indices per cluster
@@ -188,8 +188,8 @@ void ClusterBin::bin(ClusterBinIn& in, ClusterBinOut& out)
 			tileCtx.m_clusterInfos.create(clusterCountZ);
 			tileCtx.m_clusterCountZ = clusterCountZ;
 
-			const U tileCount = ctx.m_bin->m_clusterCounts[0] * ctx.m_bin->m_clusterCounts[1];
-			U tileIdx;
+			const U32 tileCount = ctx.m_bin->m_clusterCounts[0] * ctx.m_bin->m_clusterCounts[1];
+			U32 tileIdx;
 			while((tileIdx = ctx.m_tileIdxToProcess.fetchAdd(1)) < tileCount)
 			{
 				ctx.m_bin->binTile(tileIdx, ctx, tileCtx);
@@ -214,7 +214,7 @@ void ClusterBin::prepare(BinCtx& ctx)
 	const F32 near = ctx.m_in->m_renderQueue->m_cameraNear;
 	const F32 far = ctx.m_in->m_renderQueue->m_cameraFar;
 
-	const F32 calcNearOpt = (far - near) / (m_clusterCounts[2] * m_clusterCounts[2]);
+	const F32 calcNearOpt = (far - near) / F32(m_clusterCounts[2] * m_clusterCounts[2]);
 
 	// Compute magic val 0
 	// It's been used to calculate the 'k' of a cluster given the world position
@@ -240,8 +240,8 @@ void ClusterBin::prepare(BinCtx& ctx)
 		Plane nearPlane;
 		extractClipPlane(vp, FrustumPlaneType::NEAR, nearPlane);
 
-		Vec3 A = nearPlane.getNormal().xyz() * (m_clusterCounts[2] * m_clusterCounts[2]) / (far - near);
-		F32 B = nearPlane.getOffset() * (m_clusterCounts[2] * m_clusterCounts[2]) / (far - near);
+		Vec3 A = nearPlane.getNormal().xyz() * F32(m_clusterCounts[2] * m_clusterCounts[2]) / (far - near);
+		F32 B = nearPlane.getOffset() * F32(m_clusterCounts[2] * m_clusterCounts[2]) / (far - near);
 
 		ctx.m_out->m_shaderMagicValues.m_val0 = Vec4(A, B);
 	}
@@ -267,11 +267,12 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 		&m_clusterEdges[tileIdx * (m_clusterCounts[2] + 1) * 4], (m_clusterCounts[2] + 1) * 4);
 	if(ctx.m_clusterEdgesDirty)
 	{
-		const Vec2 tileSize = 2.0f / Vec2(m_clusterCounts[0], m_clusterCounts[1]);
-		const Vec2 startNdc = Vec2(F32(tileX) / m_clusterCounts[0], F32(tileY) / m_clusterCounts[1]) * 2.0f - 1.0f;
+		const Vec2 tileSize = 2.0f / Vec2(F32(m_clusterCounts[0]), F32(m_clusterCounts[1]));
+		const Vec2 startNdc =
+			Vec2(F32(tileX) / F32(m_clusterCounts[0]), F32(tileY) / F32(m_clusterCounts[1])) * 2.0f - 1.0f;
 		const Vec4& unprojParams = ctx.m_unprojParams;
 
-		for(U clusterZ = 0; clusterZ < m_clusterCounts[2] + 1; ++clusterZ)
+		for(U32 clusterZ = 0; clusterZ < m_clusterCounts[2] + 1; ++clusterZ)
 		{
 			const F32 zNear = -computeClusterNear(ctx.m_out->m_shaderMagicValues, clusterZ);
 			const U idx = clusterZ * 4;
@@ -348,7 +349,7 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 	// Point lights
 	{
 		Sphere lightSphere;
-		for(U i = 0; i < ctx.m_in->m_renderQueue->m_pointLights.getSize(); ++i)
+		for(U32 i = 0; i < ctx.m_in->m_renderQueue->m_pointLights.getSize(); ++i)
 		{
 			const PointLightQueueElement& plight = ctx.m_in->m_renderQueue->m_pointLights[i];
 			lightSphere.setCenter(plight.m_worldPosition.xyz0());
@@ -377,7 +378,7 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 		lightEdges[0] = Vec4(0.0f); // Eye
 		ConvexHullShape spotLightShape(&lightEdges[0], lightEdges.getSize());
 
-		for(U i = 0; i < ctx.m_in->m_renderQueue->m_spotLights.getSize(); ++i)
+		for(U32 i = 0; i < ctx.m_in->m_renderQueue->m_spotLights.getSize(); ++i)
 		{
 			const SpotLightQueueElement& slight = ctx.m_in->m_renderQueue->m_spotLights[i];
 
@@ -408,7 +409,7 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 	// Probes
 	{
 		Aabb probeBox;
-		for(U i = 0; i < ctx.m_in->m_renderQueue->m_reflectionProbes.getSize(); ++i)
+		for(U32 i = 0; i < ctx.m_in->m_renderQueue->m_reflectionProbes.getSize(); ++i)
 		{
 			const ReflectionProbeQueueElement& probe = ctx.m_in->m_renderQueue->m_reflectionProbes[i];
 			probeBox.setMin(probe.m_aabbMin);
@@ -434,7 +435,7 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 	// GI probes
 	{
 		Aabb probeBox;
-		for(U i = 0; i < ctx.m_in->m_renderQueue->m_giProbes.getSize(); ++i)
+		for(U32 i = 0; i < ctx.m_in->m_renderQueue->m_giProbes.getSize(); ++i)
 		{
 			const GlobalIlluminationProbeQueueElement& probe = ctx.m_in->m_renderQueue->m_giProbes[i];
 			probeBox.setMin(probe.m_aabbMin);
@@ -460,7 +461,7 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 	// Decals
 	{
 		Obb decalBox;
-		for(U i = 0; i < ctx.m_in->m_renderQueue->m_decals.getSize(); ++i)
+		for(U32 i = 0; i < ctx.m_in->m_renderQueue->m_decals.getSize(); ++i)
 		{
 			const DecalQueueElement& decal = ctx.m_in->m_renderQueue->m_decals[i];
 			decalBox.setCenter(decal.m_obbCenter.xyz0());
@@ -486,7 +487,7 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 
 	// Fog volumes
 	{
-		for(U i = 0; i < ctx.m_in->m_renderQueue->m_fogDensityVolumes.getSize(); ++i)
+		for(U32 i = 0; i < ctx.m_in->m_renderQueue->m_fogDensityVolumes.getSize(); ++i)
 		{
 			const FogDensityQueueElement& fogVol = ctx.m_in->m_renderQueue->m_fogDensityVolumes[i];
 
@@ -541,8 +542,8 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 		WeakArray<U32> inIndices = tileCtx.getClusterIndices(clusterZ);
 		const ClusterBin::TileCtx::ClusterMetaInfo& inf = tileCtx.m_clusterInfos[clusterZ];
 
-		const U other = (TYPED_OBJECT_COUNT - 1) + TYPED_OBJECT_COUNT;
-		const U indexCountPlusOther = inf.m_offset + other;
+		const U32 other = (TYPED_OBJECT_COUNT - 1) + TYPED_OBJECT_COUNT;
+		const U32 indexCountPlusOther = inf.m_offset + other;
 		ANKI_ASSERT(indexCountPlusOther <= m_avgObjectsPerCluster + other);
 		ANKI_ASSERT(indexCountPlusOther >= other);
 
@@ -552,7 +553,7 @@ void ClusterBin::binTile(U32 tileIdx, BinCtx& ctx, TileCtx& tileCtx)
 		WeakArray<U32> outIndices(&ctx.m_lightIds[firstIndex], indexCountPlusOther);
 
 		// Write the offsets
-		U offset = firstIndex + TYPED_OBJECT_COUNT - 1;
+		U32 offset = firstIndex + TYPED_OBJECT_COUNT - 1;
 		for(U i = 1; i < TYPED_OBJECT_COUNT; ++i)
 		{
 			offset += inf.m_counts[i - 1] + 1; // Count plus the stop
@@ -737,7 +738,7 @@ void ClusterBin::writeTypedObjectsToGpuBuffers(BinCtx& ctx) const
 			ReflectionProbe& out = gpuProbes[i];
 
 			out.m_position = in.m_worldPosition;
-			out.m_cubemapIndex = in.m_textureArrayIndex;
+			out.m_cubemapIndex = F32(in.m_textureArrayIndex);
 			out.m_aabbMin = in.m_aabbMin;
 			out.m_aabbMax = in.m_aabbMax;
 		}
@@ -801,8 +802,8 @@ void ClusterBin::writeTypedObjectsToGpuBuffers(BinCtx& ctx) const
 
 			out.m_aabbMin = in.m_aabbMin;
 			out.m_aabbMax = in.m_aabbMax;
-			out.m_textureIndex = &in - &rqueue.m_giProbes.getFront();
-			out.m_halfTexelSizeU = 1.0f / in.m_cellCounts.x() / 2.0f;
+			out.m_textureIndex = U32(&in - &rqueue.m_giProbes.getFront());
+			out.m_halfTexelSizeU = 1.0f / F32(in.m_cellCounts.x()) / 2.0f;
 			out.m_fadeDistance = in.m_fadeDistance;
 		}
 	}

+ 16 - 16
src/anki/renderer/Common.h

@@ -59,25 +59,25 @@ class ClusterBin;
 /// @{
 
 /// Don't create second level command buffers if they contain more drawcalls than this constant.
-const U MIN_DRAWCALLS_PER_2ND_LEVEL_COMMAND_BUFFER = 16;
+constexpr U32 MIN_DRAWCALLS_PER_2ND_LEVEL_COMMAND_BUFFER = 16;
 
 /// FS size is rendererSize/FS_FRACTION.
-const U FS_FRACTION = 2;
+constexpr U32 FS_FRACTION = 2;
 
 /// SSAO size is rendererSize/SSAO_FRACTION.
-const U SSAO_FRACTION = 2;
+constexpr U32 SSAO_FRACTION = 2;
 
 /// Bloom size is rendererSize/BLOOM_FRACTION.
-const U BLOOM_FRACTION = 4;
+constexpr U32 BLOOM_FRACTION = 4;
 
 /// Volumetric size is rendererSize/VOLUMETRIC_FRACTION.
-const U VOLUMETRIC_FRACTION = 4;
+constexpr U32 VOLUMETRIC_FRACTION = 4;
 
 /// SSR size is rendererSize/SSR_FRACTION.
-const U SSR_FRACTION = 2;
+constexpr U32 SSR_FRACTION = 2;
 
 /// Used to calculate the mipmap count of the HiZ map.
-const U HIERARCHICAL_Z_MIN_HEIGHT = 80;
+constexpr U32 HIERARCHICAL_Z_MIN_HEIGHT = 80;
 
 const TextureSubresourceInfo HIZ_HALF_DEPTH(TextureSurfaceInfo(0, 0, 0, 0));
 const TextureSubresourceInfo HIZ_QUARTER_DEPTH(TextureSurfaceInfo(1, 0, 0, 0));
@@ -89,26 +89,26 @@ inline void computeLinearizeDepthOptimal(F32 near, F32 far, F32& a, F32& b)
 	b = far / near;
 }
 
-const U GBUFFER_COLOR_ATTACHMENT_COUNT = 4;
+constexpr U32 GBUFFER_COLOR_ATTACHMENT_COUNT = 4;
 
 /// Downsample and blur down to a texture with size DOWNSCALE_BLUR_DOWN_TO
-const U DOWNSCALE_BLUR_DOWN_TO = 32;
+constexpr U32 DOWNSCALE_BLUR_DOWN_TO = 32;
 
 /// Use this size of render target for the avg lum calculation.
-const U AVERAGE_LUMINANCE_RENDER_TARGET_SIZE = 128;
+constexpr U32 AVERAGE_LUMINANCE_RENDER_TARGET_SIZE = 128;
 
 extern const Array<Format, GBUFFER_COLOR_ATTACHMENT_COUNT> GBUFFER_COLOR_ATTACHMENT_PIXEL_FORMATS;
 
-const Format GBUFFER_DEPTH_ATTACHMENT_PIXEL_FORMAT = Format::D32_SFLOAT;
+constexpr Format GBUFFER_DEPTH_ATTACHMENT_PIXEL_FORMAT = Format::D32_SFLOAT;
 
-const Format LIGHT_SHADING_COLOR_ATTACHMENT_PIXEL_FORMAT = Format::B10G11R11_UFLOAT_PACK32;
+constexpr Format LIGHT_SHADING_COLOR_ATTACHMENT_PIXEL_FORMAT = Format::B10G11R11_UFLOAT_PACK32;
 
-const Format FORWARD_SHADING_COLOR_ATTACHMENT_PIXEL_FORMAT = Format::R16G16B16A16_SFLOAT;
+constexpr Format FORWARD_SHADING_COLOR_ATTACHMENT_PIXEL_FORMAT = Format::R16G16B16A16_SFLOAT;
 
-const Format DBG_COLOR_ATTACHMENT_PIXEL_FORMAT = Format::R8G8B8A8_UNORM;
+constexpr Format DBG_COLOR_ATTACHMENT_PIXEL_FORMAT = Format::R8G8B8A8_UNORM;
 
-const Format SHADOW_DEPTH_PIXEL_FORMAT = Format::D32_SFLOAT;
-const Format SHADOW_COLOR_PIXEL_FORMAT = Format::R16_UNORM;
+constexpr Format SHADOW_DEPTH_PIXEL_FORMAT = Format::D32_SFLOAT;
+constexpr Format SHADOW_COLOR_PIXEL_FORMAT = Format::R16_UNORM;
 
 /// A convenience function to find empty cache entries. Used for various probes.
 template<typename THashMap, typename TCacheEntryArray, typename TAlloc>

+ 5 - 5
src/anki/renderer/Dbg.cpp

@@ -29,7 +29,7 @@ Dbg::~Dbg()
 
 Error Dbg::init(const ConfigSet& initializer)
 {
-	m_enabled = initializer.getNumber("r.dbg.enabled");
+	m_enabled = initializer.getBool("r.dbg.enabled");
 	return Error::NONE;
 }
 
@@ -83,9 +83,9 @@ void Dbg::run(RenderPassWorkContext& rgraphCtx, const RenderingContext& ctx)
 	dctx.m_debugDrawFlags = m_debugDrawFlags;
 
 	// Draw renderables
-	const U threadId = rgraphCtx.m_currentSecondLevelCommandBufferIndex;
-	const U threadCount = rgraphCtx.m_secondLevelCommandBufferCount;
-	const U problemSize = ctx.m_renderQueue->m_renderables.getSize();
+	const U32 threadId = rgraphCtx.m_currentSecondLevelCommandBufferIndex;
+	const U32 threadCount = rgraphCtx.m_secondLevelCommandBufferCount;
+	const U32 problemSize = U32(ctx.m_renderQueue->m_renderables.getSize());
 	U32 start, end;
 	splitThreadedProblem(threadId, threadCount, problemSize, start, end);
 
@@ -181,7 +181,7 @@ void Dbg::populateRenderGraph(RenderingContext& ctx)
 			self->run(rgraphCtx, *self->m_runCtx.m_ctx);
 		},
 		this,
-		computeNumberOfSecondLevelCommandBuffers(ctx.m_renderQueue->m_renderables.getSize()));
+		computeNumberOfSecondLevelCommandBuffers(U32(ctx.m_renderQueue->m_renderables.getSize())));
 	pass.setFramebufferInfo(m_fbDescr, {{m_runCtx.m_rt}}, m_r->getGBuffer().getDepthRt());
 
 	pass.newDependency({m_runCtx.m_rt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE});

+ 13 - 13
src/anki/renderer/DepthDownscale.cpp

@@ -20,13 +20,13 @@ DepthDownscale::~DepthDownscale()
 
 Error DepthDownscale::initInternal(const ConfigSet&)
 {
-	const U width = m_r->getWidth() >> 1;
-	const U height = m_r->getHeight() >> 1;
+	const U32 width = m_r->getWidth() >> 1;
+	const U32 height = m_r->getHeight() >> 1;
 
 	m_mipCount = computeMaxMipmapCount2d(width, height, HIERARCHICAL_Z_MIN_HEIGHT);
 
-	const U lastMipWidth = width >> (m_mipCount - 1);
-	const U lastMipHeight = height >> (m_mipCount - 1);
+	const U32 lastMipWidth = width >> (m_mipCount - 1);
+	const U32 lastMipHeight = height >> (m_mipCount - 1);
 
 	ANKI_R_LOGI("Initializing HiZ. Mip count %u, last mip size %ux%u", m_mipCount, lastMipWidth, lastMipHeight);
 
@@ -36,7 +36,7 @@ Error DepthDownscale::initInternal(const ConfigSet&)
 		Format::R32_SFLOAT,
 		TextureUsageBit::SAMPLED_FRAGMENT | TextureUsageBit::SAMPLED_COMPUTE | TextureUsageBit::IMAGE_COMPUTE_WRITE,
 		"HiZ");
-	texInit.m_mipmapCount = m_mipCount;
+	texInit.m_mipmapCount = U8(m_mipCount);
 	texInit.m_initialUsage = TextureUsageBit::SAMPLED_FRAGMENT;
 	m_hizTex = m_r->createAndClearRenderTarget(texInit);
 
@@ -108,7 +108,7 @@ void DepthDownscale::populateRenderGraph(RenderingContext& ctx)
 	static const Array<CString, 5> passNames = {{"HiZ #0", "HiZ #1", "HiZ #2", "HiZ #3", "HiZ #4"}};
 
 	// Every pass can do MIPS_WRITTEN_PER_PASS mips
-	for(U i = 0; i < m_mipCount; i += MIPS_WRITTEN_PER_PASS)
+	for(U32 i = 0; i < m_mipCount; i += MIPS_WRITTEN_PER_PASS)
 	{
 		const U mipsToFill = (i + 1 < m_mipCount) ? MIPS_WRITTEN_PER_PASS : 1;
 
@@ -150,15 +150,15 @@ void DepthDownscale::run(RenderPassWorkContext& rgraphCtx)
 {
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
 
-	const U level = m_runCtx.m_mip;
+	const U32 level = m_runCtx.m_mip;
 	m_runCtx.m_mip += MIPS_WRITTEN_PER_PASS;
-	const U mipsToFill = (level + 1 < m_mipCount) ? MIPS_WRITTEN_PER_PASS : 1;
-	const U copyToClientLevel = (level + mipsToFill == m_mipCount) ? mipsToFill - 1 : MAX_U;
+	const U32 mipsToFill = (level + 1 < m_mipCount) ? MIPS_WRITTEN_PER_PASS : 1;
+	const U32 copyToClientLevel = (level + mipsToFill == m_mipCount) ? mipsToFill - 1 : MAX_U32;
 
-	const U level0Width = m_r->getWidth() >> (level + 1);
-	const U level0Height = m_r->getHeight() >> (level + 1);
-	const U level1Width = level0Width >> 1;
-	const U level1Height = level0Height >> 1;
+	const U32 level0Width = m_r->getWidth() >> (level + 1);
+	const U32 level0Height = m_r->getHeight() >> (level + 1);
+	const U32 level1Width = level0Width >> 1;
+	const U32 level1Height = level0Height >> 1;
 
 	cmdb->bindShaderProgram(m_grProg);
 

+ 1 - 1
src/anki/renderer/DepthDownscale.h

@@ -66,7 +66,7 @@ private:
 	{
 	public:
 		RenderTargetHandle m_hizRt;
-		U8 m_mip;
+		U32 m_mip;
 	} m_runCtx; ///< Run context.
 
 	class

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

@@ -43,7 +43,7 @@ Error DownscaleBlur::initInternal(const ConfigSet&)
 	{
 		texinit.m_usage |= TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE;
 	}
-	texinit.m_mipmapCount = m_passCount;
+	texinit.m_mipmapCount = U8(m_passCount);
 	texinit.m_initialUsage = TextureUsageBit::SAMPLED_COMPUTE;
 	m_rtTex = m_r->createAndClearRenderTarget(texinit);
 
@@ -51,7 +51,7 @@ Error DownscaleBlur::initInternal(const ConfigSet&)
 	if(!m_useCompute)
 	{
 		m_fbDescrs.create(getAllocator(), m_passCount);
-		for(U pass = 0; pass < m_passCount; ++pass)
+		for(U32 pass = 0; pass < m_passCount; ++pass)
 		{
 			m_fbDescrs[pass].m_colorAttachmentCount = 1;
 			m_fbDescrs[pass].m_colorAttachments[0].m_loadOperation = AttachmentLoadOperation::DONT_CARE;
@@ -103,7 +103,7 @@ void DownscaleBlur::populateRenderGraph(RenderingContext& ctx)
 		"Down/Blur #7"}};
 	if(m_useCompute)
 	{
-		for(U i = 0; i < m_passCount; ++i)
+		for(U32 i = 0; i < m_passCount; ++i)
 		{
 			ComputeRenderPassDescription& pass = rgraph.newComputeRenderPass(passNames[i]);
 			pass.setWork(
@@ -135,7 +135,7 @@ void DownscaleBlur::populateRenderGraph(RenderingContext& ctx)
 	}
 	else
 	{
-		for(U i = 0; i < m_passCount; ++i)
+		for(U32 i = 0; i < m_passCount; ++i)
 		{
 			GraphicsRenderPassDescription& pass = rgraph.newGraphicsRenderPass(passNames[i]);
 			pass.setWork(
@@ -174,9 +174,9 @@ void DownscaleBlur::run(RenderPassWorkContext& rgraphCtx)
 
 	cmdb->bindShaderProgram(m_grProg);
 
-	const U passIdx = m_runCtx.m_crntPassIdx++;
-	const U vpWidth = m_rtTex->getWidth() >> passIdx;
-	const U vpHeight = m_rtTex->getHeight() >> passIdx;
+	const U32 passIdx = m_runCtx.m_crntPassIdx++;
+	const U32 vpWidth = m_rtTex->getWidth() >> passIdx;
+	const U32 vpHeight = m_rtTex->getHeight() >> passIdx;
 
 	cmdb->bindSampler(0, 0, m_r->getSamplers().m_trilinearClamp);
 

+ 6 - 6
src/anki/renderer/DownscaleBlur.h

@@ -32,17 +32,17 @@ anki_internal:
 	/// Populate the rendergraph.
 	void populateRenderGraph(RenderingContext& ctx);
 
-	U getPassWidth(U pass) const
+	U32 getPassWidth(U32 pass) const
 	{
-		return m_rtTex->getWidth() >> min<U32>(pass, m_passCount - 1);
+		return m_rtTex->getWidth() >> min(pass, m_passCount - 1);
 	}
 
-	U getPassHeight(U pass) const
+	U32 getPassHeight(U32 pass) const
 	{
-		return m_rtTex->getHeight() >> min<U32>(pass, m_passCount - 1);
+		return m_rtTex->getHeight() >> min(pass, m_passCount - 1);
 	}
 
-	U getMipmapCount() const
+	U32 getMipmapCount() const
 	{
 		return m_passCount;
 	}
@@ -56,7 +56,7 @@ private:
 	static const Bool m_useCompute = true;
 	Array<U32, 2> m_workgroupSize = {{16, 16}};
 
-	U8 m_passCount = 0; ///< It's also the mip count of the m_rtTex.
+	U32 m_passCount = 0; ///< It's also the mip count of the m_rtTex.
 
 	TexturePtr m_rtTex;
 

+ 8 - 8
src/anki/renderer/Drawer.cpp

@@ -25,8 +25,8 @@ public:
 	Array<RenderableQueueElement, MAX_INSTANCES> m_cachedRenderElements;
 	Array<U8, MAX_INSTANCES> m_cachedRenderElementLods;
 	Array<const void*, MAX_INSTANCES> m_userData;
-	U m_cachedRenderElementCount = 0;
-	U m_minLod = 0;
+	U32 m_cachedRenderElementCount = 0;
+	U32 m_minLod = 0;
 };
 
 /// Check if the drawcalls can be merged.
@@ -47,7 +47,7 @@ void RenderableDrawer::drawRange(Pass pass,
 	SamplerPtr sampler,
 	const RenderableQueueElement* begin,
 	const RenderableQueueElement* end,
-	U minLod)
+	U32 minLod)
 {
 	ANKI_ASSERT(begin && end && begin < end);
 
@@ -79,8 +79,8 @@ void RenderableDrawer::drawRange(Pass pass,
 
 void RenderableDrawer::flushDrawcall(DrawContext& ctx)
 {
-	ctx.m_queueCtx.m_key.m_lod = ctx.m_cachedRenderElementLods[0];
-	ctx.m_queueCtx.m_key.m_instanceCount = ctx.m_cachedRenderElementCount;
+	ctx.m_queueCtx.m_key.setLod(ctx.m_cachedRenderElementLods[0]);
+	ctx.m_queueCtx.m_key.setInstanceCount(ctx.m_cachedRenderElementCount);
 
 	ctx.m_cachedRenderElements[0].m_callback(
 		ctx.m_queueCtx, ConstWeakArray<void*>(const_cast<void**>(&ctx.m_userData[0]), ctx.m_cachedRenderElementCount));
@@ -102,8 +102,8 @@ void RenderableDrawer::drawSingle(DrawContext& ctx)
 
 	const RenderableQueueElement& rqel = *ctx.m_renderableElement;
 
-	U8 lod = min<U8>(m_r->calculateLod(rqel.m_distanceFromCamera), MAX_LOD_COUNT - 1);
-	lod = max<U8>(lod, ctx.m_minLod);
+	U32 lod = min(m_r->calculateLod(rqel.m_distanceFromCamera), MAX_LOD_COUNT - 1);
+	lod = max(lod, ctx.m_minLod);
 
 	const Bool shouldFlush =
 		ctx.m_cachedRenderElementCount > 0
@@ -117,7 +117,7 @@ void RenderableDrawer::drawSingle(DrawContext& ctx)
 
 	// Cache the new one
 	ctx.m_cachedRenderElements[ctx.m_cachedRenderElementCount] = rqel;
-	ctx.m_cachedRenderElementLods[ctx.m_cachedRenderElementCount] = lod;
+	ctx.m_cachedRenderElementLods[ctx.m_cachedRenderElementCount] = U8(lod);
 	ctx.m_userData[ctx.m_cachedRenderElementCount] = rqel.m_userData;
 	++ctx.m_cachedRenderElementCount;
 }

+ 1 - 1
src/anki/renderer/Drawer.h

@@ -40,7 +40,7 @@ public:
 		SamplerPtr sampler,
 		const RenderableQueueElement* begin,
 		const RenderableQueueElement* end,
-		U minLod = 0);
+		U32 minLod = 0);
 
 private:
 	Renderer* m_r;

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

@@ -51,7 +51,7 @@ Error FinalComposite::initInternal(const ConfigSet& config)
 	ShaderProgramResourceConstantValueInitList<3> consts(m_prog);
 	consts.add("LUT_SIZE", U32(LUT_SIZE))
 		.add("FB_SIZE", UVec2(m_r->getWidth(), m_r->getHeight()))
-		.add("MOTION_BLUR_SAMPLES", U32(config.getNumber("r.final.motionBlurSamples")));
+		.add("MOTION_BLUR_SAMPLES", config.getNumberU32("r.final.motionBlurSamples"));
 
 	const ShaderProgramResourceVariant* variant;
 	m_prog->getOrCreateVariant(mutations.get(), consts.get(), variant);

+ 4 - 4
src/anki/renderer/ForwardShading.cpp

@@ -29,10 +29,10 @@ Error ForwardShading::init(const ConfigSet& cfg)
 void ForwardShading::run(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx)
 {
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
-	const U threadId = rgraphCtx.m_currentSecondLevelCommandBufferIndex;
-	const U threadCount = rgraphCtx.m_secondLevelCommandBufferCount;
-	const U problemSize = ctx.m_renderQueue->m_forwardShadingRenderables.getSize();
-	U start, end;
+	const U32 threadId = rgraphCtx.m_currentSecondLevelCommandBufferIndex;
+	const U32 threadCount = rgraphCtx.m_secondLevelCommandBufferCount;
+	const U32 problemSize = U32(ctx.m_renderQueue->m_forwardShadingRenderables.getSize());
+	U32 start, end;
 	splitThreadedProblem(threadId, threadCount, problemSize, start, end);
 
 	if(start != end)

+ 8 - 8
src/anki/renderer/GBuffer.cpp

@@ -72,13 +72,13 @@ void GBuffer::runInThread(const RenderingContext& ctx, RenderPassWorkContext& rg
 	ANKI_TRACE_SCOPED_EVENT(R_MS);
 
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
-	const U threadId = rgraphCtx.m_currentSecondLevelCommandBufferIndex;
-	const U threadCount = rgraphCtx.m_secondLevelCommandBufferCount;
+	const U32 threadId = rgraphCtx.m_currentSecondLevelCommandBufferIndex;
+	const U32 threadCount = rgraphCtx.m_secondLevelCommandBufferCount;
 
 	// Get some stuff
-	const PtrSize earlyZCount = ctx.m_renderQueue->m_earlyZRenderables.getSize();
-	const U problemSize = ctx.m_renderQueue->m_renderables.getSize() + earlyZCount;
-	PtrSize start, end;
+	const U32 earlyZCount = U32(ctx.m_renderQueue->m_earlyZRenderables.getSize());
+	const U32 problemSize = U32(ctx.m_renderQueue->m_renderables.getSize() + earlyZCount);
+	U32 start, end;
 	splitThreadedProblem(threadId, threadCount, problemSize, start, end);
 	ANKI_ASSERT(end != start);
 
@@ -95,7 +95,7 @@ void GBuffer::runInThread(const RenderingContext& ctx, RenderPassWorkContext& rg
 	// First do early Z (if needed)
 	if(earlyZStart < earlyZEnd)
 	{
-		for(U i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
+		for(U32 i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
 		{
 			cmdb->setColorChannelWriteMask(i, ColorBit::NONE);
 		}
@@ -113,7 +113,7 @@ void GBuffer::runInThread(const RenderingContext& ctx, RenderPassWorkContext& rg
 		// Restore state for the color write
 		if(colorStart < colorEnd)
 		{
-			for(U i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
+			for(U32 i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
 			{
 				cmdb->setColorChannelWriteMask(i, ColorBit::ALL);
 			}
@@ -164,7 +164,7 @@ void GBuffer::populateRenderGraph(RenderingContext& ctx)
 		},
 		this,
 		computeNumberOfSecondLevelCommandBuffers(
-			ctx.m_renderQueue->m_earlyZRenderables.getSize() + ctx.m_renderQueue->m_renderables.getSize()));
+			U32(ctx.m_renderQueue->m_earlyZRenderables.getSize() + ctx.m_renderQueue->m_renderables.getSize())));
 
 	for(U i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT; ++i)
 	{

+ 3 - 3
src/anki/renderer/GBufferPost.cpp

@@ -34,9 +34,9 @@ Error GBufferPost::initInternal(const ConfigSet& cfg)
 	ANKI_CHECK(getResourceManager().loadResource("shaders/GBufferPost.glslp", m_prog));
 
 	ShaderProgramResourceConstantValueInitList<3> consts(m_prog);
-	consts.add("CLUSTER_COUNT_X", U32(cfg.getNumber("r.clusterSizeX")));
-	consts.add("CLUSTER_COUNT_Y", U32(cfg.getNumber("r.clusterSizeY")));
-	consts.add("CLUSTER_COUNT_Z", U32(cfg.getNumber("r.clusterSizeZ")));
+	consts.add("CLUSTER_COUNT_X", cfg.getNumberU32("r.clusterSizeX"));
+	consts.add("CLUSTER_COUNT_Y", cfg.getNumberU32("r.clusterSizeY"));
+	consts.add("CLUSTER_COUNT_Z", cfg.getNumberU32("r.clusterSizeZ"));
 
 	const ShaderProgramResourceVariant* variant;
 	m_prog->getOrCreateVariant(consts.get(), variant);

+ 39 - 32
src/anki/renderer/GlobalIllumination.cpp

@@ -15,7 +15,7 @@ namespace anki
 {
 
 /// Given a cell index compute its world position.
-static Vec3 computeProbeCellPosition(U cellIdx, const GlobalIlluminationProbeQueueElement& probe)
+static Vec3 computeProbeCellPosition(U32 cellIdx, const GlobalIlluminationProbeQueueElement& probe)
 {
 	ANKI_ASSERT(cellIdx < probe.m_totalCellCount);
 
@@ -88,7 +88,7 @@ void GlobalIllumination::setRenderGraphDependencies(
 void GlobalIllumination::bindVolumeTextures(
 	const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx, U32 set, U32 binding) const
 {
-	for(U idx = 0; idx < MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES; ++idx)
+	for(U32 idx = 0; idx < MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES; ++idx)
 	{
 		if(idx < ctx.m_renderQueue->m_giProbes.getSize())
 		{
@@ -117,9 +117,9 @@ Error GlobalIllumination::init(const ConfigSet& cfg)
 
 Error GlobalIllumination::initInternal(const ConfigSet& cfg)
 {
-	m_tileSize = cfg.getNumber("r.gi.tileResolution");
-	m_cacheEntries.create(getAllocator(), cfg.getNumber("r.gi.maxCachedProbes"));
-	m_maxVisibleProbes = cfg.getNumber("r.gi.maxVisibleProbes");
+	m_tileSize = cfg.getNumberU32("r.gi.tileResolution");
+	m_cacheEntries.create(getAllocator(), cfg.getNumberU32("r.gi.maxCachedProbes"));
+	m_maxVisibleProbes = cfg.getNumberU32("r.gi.maxVisibleProbes");
 	ANKI_ASSERT(m_maxVisibleProbes <= MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES);
 	ANKI_ASSERT(m_cacheEntries.getSize() >= m_maxVisibleProbes);
 
@@ -175,7 +175,7 @@ Error GlobalIllumination::initGBuffer(const ConfigSet& cfg)
 
 Error GlobalIllumination::initShadowMapping(const ConfigSet& cfg)
 {
-	const U resolution = cfg.getNumber("r.gi.shadowMapResolution");
+	const U32 resolution = cfg.getNumberU32("r.gi.shadowMapResolution");
 	ANKI_ASSERT(resolution > 8);
 
 	// RT descr
@@ -264,18 +264,19 @@ void GlobalIllumination::populateRenderGraph(RenderingContext& rctx)
 	}
 
 	// Compute task counts for some of the passes
-	U gbufferTaskCount, smTaskCount;
+	U32 gbufferTaskCount, smTaskCount;
 	{
 		giCtx->m_gbufferDrawcallCount = 0;
 		giCtx->m_smDrawcallCount = 0;
 		for(const RenderQueue* rq : giCtx->m_probeToUpdateThisFrame->m_renderQueues)
 		{
 			ANKI_ASSERT(rq);
-			giCtx->m_gbufferDrawcallCount += rq->m_renderables.getSize();
+			giCtx->m_gbufferDrawcallCount += U32(rq->m_renderables.getSize());
 
 			if(rq->m_directionalLight.hasShadow())
 			{
-				giCtx->m_smDrawcallCount += rq->m_directionalLight.m_shadowRenderQueues[0]->m_renderables.getSize();
+				giCtx->m_smDrawcallCount +=
+					U32(rq->m_directionalLight.m_shadowRenderQueues[0]->m_renderables.getSize());
 			}
 		}
 
@@ -499,7 +500,7 @@ void GlobalIllumination::prepareProbes(InternalContext& giCtx)
 
 			foundProbeToUpdateNextFrame = true;
 
-			const U cellToRender = (cacheEntryDirty) ? 0 : entry.m_renderedCells;
+			const U32 cellToRender = (cacheEntryDirty) ? 0 : entry.m_renderedCells;
 			const Vec3 cellPos = computeProbeCellPosition(cellToRender, probe);
 			probe.m_feedbackCallback(true, probe.m_feedbackCallbackUserData, cellPos.xyz0());
 			continue;
@@ -542,7 +543,7 @@ void GlobalIllumination::prepareProbes(InternalContext& giCtx)
 		}
 
 		// Compute the render position
-		const U cellToRender = entry.m_renderedCells++;
+		const U32 cellToRender = entry.m_renderedCells++;
 		ANKI_ASSERT(cellToRender < probe.m_totalCellCount);
 		unflatten3dArrayIndex(probe.m_cellCounts.z(),
 			probe.m_cellCounts.y(),
@@ -602,19 +603,22 @@ void GlobalIllumination::runGBufferInThread(RenderPassWorkContext& rgraphCtx, In
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
 	const GlobalIlluminationProbeQueueElement& probe = *giCtx.m_probeToUpdateThisFrame;
 
-	I start, end;
+	I32 start, end;
+	U32 startu, endu;
 	splitThreadedProblem(rgraphCtx.m_currentSecondLevelCommandBufferIndex,
 		rgraphCtx.m_secondLevelCommandBufferCount,
 		giCtx.m_gbufferDrawcallCount,
-		start,
-		end);
+		startu,
+		endu);
+	start = I32(startu);
+	end = I32(endu);
 
-	I drawcallCount = 0;
-	for(U faceIdx = 0; faceIdx < 6; ++faceIdx)
+	I32 drawcallCount = 0;
+	for(U32 faceIdx = 0; faceIdx < 6; ++faceIdx)
 	{
-		const I faceDrawcallCount = I(probe.m_renderQueues[faceIdx]->m_renderables.getSize());
-		const I localStart = max(I(0), start - drawcallCount);
-		const I localEnd = min(faceDrawcallCount, end - drawcallCount);
+		const I32 faceDrawcallCount = I32(probe.m_renderQueues[faceIdx]->m_renderables.getSize());
+		const I32 localStart = max(I32(0), start - drawcallCount);
+		const I32 localEnd = min(faceDrawcallCount, end - drawcallCount);
 
 		if(localStart < localEnd)
 		{
@@ -638,7 +642,7 @@ void GlobalIllumination::runGBufferInThread(RenderPassWorkContext& rgraphCtx, In
 
 		drawcallCount += faceDrawcallCount;
 	}
-	ANKI_ASSERT(giCtx.m_gbufferDrawcallCount == drawcallCount);
+	ANKI_ASSERT(giCtx.m_gbufferDrawcallCount == U32(drawcallCount));
 
 	// It's secondary, no need to restore the state
 }
@@ -650,18 +654,21 @@ void GlobalIllumination::runShadowmappingInThread(RenderPassWorkContext& rgraphC
 
 	const GlobalIlluminationProbeQueueElement& probe = *giCtx.m_probeToUpdateThisFrame;
 
-	I start, end;
+	I32 start, end;
+	U32 startu, endu;
 	splitThreadedProblem(rgraphCtx.m_currentSecondLevelCommandBufferIndex,
 		rgraphCtx.m_secondLevelCommandBufferCount,
 		giCtx.m_smDrawcallCount,
-		start,
-		end);
+		startu,
+		endu);
+	start = I32(startu);
+	end = I32(endu);
 
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
 	cmdb->setPolygonOffset(1.0f, 1.0f);
 
-	I drawcallCount = 0;
-	for(U faceIdx = 0; faceIdx < 6; ++faceIdx)
+	I32 drawcallCount = 0;
+	for(U32 faceIdx = 0; faceIdx < 6; ++faceIdx)
 	{
 		ANKI_ASSERT(probe.m_renderQueues[faceIdx]);
 		const RenderQueue& faceRenderQueue = *probe.m_renderQueues[faceIdx];
@@ -669,13 +676,13 @@ void GlobalIllumination::runShadowmappingInThread(RenderPassWorkContext& rgraphC
 		ANKI_ASSERT(faceRenderQueue.m_directionalLight.m_shadowRenderQueues[0]);
 		const RenderQueue& cascadeRenderQueue = *faceRenderQueue.m_directionalLight.m_shadowRenderQueues[0];
 
-		const I faceDrawcallCount = I(cascadeRenderQueue.m_renderables.getSize());
-		const I localStart = max(I(0), start - drawcallCount);
-		const I localEnd = min(faceDrawcallCount, end - drawcallCount);
+		const I32 faceDrawcallCount = I32(cascadeRenderQueue.m_renderables.getSize());
+		const I32 localStart = max(I32(0), start - drawcallCount);
+		const I32 localEnd = min(faceDrawcallCount, end - drawcallCount);
 
 		if(localStart < localEnd)
 		{
-			const U rez = m_shadowMapping.m_rtDescr.m_height;
+			const U32 rez = m_shadowMapping.m_rtDescr.m_height;
 			cmdb->setViewport(rez * faceIdx, 0, rez, rez);
 			cmdb->setScissor(rez * faceIdx, 0, rez, rez);
 
@@ -725,12 +732,12 @@ void GlobalIllumination::runLightShading(RenderPassWorkContext& rgraphCtx, Inter
 		}
 	}
 
-	for(U faceIdx = 0; faceIdx < 6; ++faceIdx)
+	for(U32 faceIdx = 0; faceIdx < 6; ++faceIdx)
 	{
 		ANKI_ASSERT(probe.m_renderQueues[faceIdx]);
 		const RenderQueue& rqueue = *probe.m_renderQueues[faceIdx];
 
-		const U rez = m_tileSize;
+		const U32 rez = m_tileSize;
 		cmdb->setScissor(rez * faceIdx, 0, rez, rez);
 		cmdb->setViewport(rez * faceIdx, 0, rez, rez);
 
@@ -770,7 +777,7 @@ void GlobalIllumination::runIrradiance(RenderPassWorkContext& rgraphCtx, Interna
 	cmdb->bindSampler(0, 0, m_r->getSamplers().m_nearestNearestClamp);
 	rgraphCtx.bindColorTexture(0, 1, giCtx.m_lightShadingRt);
 
-	for(U i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT - 1; ++i)
+	for(U32 i = 0; i < GBUFFER_COLOR_ATTACHMENT_COUNT - 1; ++i)
 	{
 		rgraphCtx.bindColorTexture(0, 2, giCtx.m_gbufferColorRts[i], i);
 	}

+ 7 - 7
src/anki/renderer/LensFlare.cpp

@@ -41,8 +41,8 @@ Error LensFlare::initInternal(const ConfigSet& config)
 
 Error LensFlare::initSprite(const ConfigSet& config)
 {
-	m_maxSpritesPerFlare = config.getNumber("r.lensFlare.maxSpritesPerFlare");
-	m_maxFlares = config.getNumber("r.lensFlare.maxFlares");
+	m_maxSpritesPerFlare = config.getNumberU8("r.lensFlare.maxSpritesPerFlare");
+	m_maxFlares = config.getNumberU8("r.lensFlare.maxFlares");
 
 	if(m_maxSpritesPerFlare < 1 || m_maxFlares < 1)
 	{
@@ -50,7 +50,7 @@ Error LensFlare::initSprite(const ConfigSet& config)
 		return Error::USER_DATA;
 	}
 
-	m_maxSprites = m_maxSpritesPerFlare * m_maxFlares;
+	m_maxSprites = U16(m_maxSpritesPerFlare * m_maxFlares);
 
 	// Load prog
 	ANKI_CHECK(getResourceManager().loadResource("shaders/LensFlareSprite.glslp", m_realProg));
@@ -77,7 +77,7 @@ Error LensFlare::initOcclusion(const ConfigSet& config)
 		getResourceManager().loadResource("shaders/LensFlareUpdateIndirectInfo.glslp", m_updateIndirectBuffProg));
 
 	ShaderProgramResourceConstantValueInitList<1> consts(m_updateIndirectBuffProg);
-	consts.add("IN_DEPTH_MAP_SIZE", Vec2(m_r->getWidth() / 2 / 2, m_r->getHeight() / 2 / 2));
+	consts.add("IN_DEPTH_MAP_SIZE", Vec2(F32(m_r->getWidth() / 2 / 2), F32(m_r->getHeight() / 2 / 2)));
 
 	const ShaderProgramResourceVariant* variant;
 	m_updateIndirectBuffProg->getOrCreateVariant(consts.get(), variant);
@@ -89,7 +89,7 @@ Error LensFlare::initOcclusion(const ConfigSet& config)
 void LensFlare::updateIndirectInfo(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx)
 {
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
-	U count = min<U>(ctx.m_renderQueue->m_lensFlares.getSize(), m_maxFlares);
+	U32 count = min<U32>(U32(ctx.m_renderQueue->m_lensFlares.getSize()), m_maxFlares);
 	ANKI_ASSERT(count > 0);
 
 	cmdb->bindShaderProgram(m_updateIndirectBuffGrProg);
@@ -184,8 +184,8 @@ void LensFlare::runDrawFlares(const RenderingContext& ctx, CommandBufferPtr& cmd
 		// First flare
 		sprites[c].m_posScale = Vec4(posNdc, flareEl.m_firstFlareSize * Vec2(1.0f, m_r->getAspectRatio()));
 		sprites[c].m_depthPad3 = Vec4(0.0f);
-		const F32 alpha = flareEl.m_colorMultiplier.w() * (1.0 - pow(absolute(posNdc.x()), 6.0f))
-						  * (1.0 - pow(absolute(posNdc.y()), 6.0)); // Fade the flare on the edges
+		const F32 alpha = flareEl.m_colorMultiplier.w() * (1.0f - pow(absolute(posNdc.x()), 6.0f))
+						  * (1.0f - pow(absolute(posNdc.y()), 6.0f)); // Fade the flare on the edges
 		sprites[c].m_color = Vec4(flareEl.m_colorMultiplier.xyz(), alpha);
 		++c;
 

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

@@ -189,7 +189,7 @@ void LightShading::populateRenderGraph(RenderingContext& ctx)
 	pass.setWork(
 		[](RenderPassWorkContext& rgraphCtx) { static_cast<LightShading*>(rgraphCtx.m_userData)->run(rgraphCtx); },
 		this,
-		computeNumberOfSecondLevelCommandBuffers(ctx.m_renderQueue->m_forwardShadingRenderables.getSize()));
+		computeNumberOfSecondLevelCommandBuffers(U32(ctx.m_renderQueue->m_forwardShadingRenderables.getSize())));
 	pass.setFramebufferInfo(m_lightShading.m_fbDescr, {{m_runCtx.m_rt}}, {m_r->getGBuffer().getDepthRt()});
 
 	// Light shading

+ 6 - 6
src/anki/renderer/MainRenderer.cpp

@@ -43,14 +43,14 @@ Error MainRenderer::init(ThreadHive* hive,
 	ANKI_R_LOGI("Initializing main renderer");
 
 	m_alloc = HeapAllocator<U8>(allocCb, allocCbUserData);
-	m_frameAlloc = StackAllocator<U8>(allocCb, allocCbUserData, 1024 * 1024 * 10, 1.0);
+	m_frameAlloc = StackAllocator<U8>(allocCb, allocCbUserData, 1024 * 1024 * 10, 1.0f);
 
 	// Init renderer and manipulate the width/height
-	m_width = config.getNumber("width");
-	m_height = config.getNumber("height");
+	m_width = config.getNumberU32("width");
+	m_height = config.getNumberU32("height");
 	ConfigSet config2 = config;
-	m_renderingQuality = config.getNumber("r.renderingQuality");
-	UVec2 size(m_renderingQuality * F32(m_width), m_renderingQuality * F32(m_height));
+	m_renderingQuality = config.getNumberF32("r.renderingQuality");
+	UVec2 size(U32(m_renderingQuality * F32(m_width)), U32(m_renderingQuality * F32(m_height)));
 
 	config2.set("width", size.x());
 	config2.set("height", size.y());
@@ -167,7 +167,7 @@ Error MainRenderer::render(RenderQueue& rqueue, TexturePtr presentTex)
 		tasks[i].m_callback = [](void* userData, U32 threadId, ThreadHive& hive, ThreadHiveSemaphore* signalSemaphore) {
 			MainRenderer& self = *static_cast<MainRenderer*>(userData);
 
-			const U taskId = self.m_runCtx.m_secondaryTaskId.fetchAdd(1);
+			const U32 taskId = self.m_runCtx.m_secondaryTaskId.fetchAdd(1);
 			self.m_rgraph->runSecondLevel(taskId);
 		};
 	}

+ 11 - 11
src/anki/renderer/ProbeReflections.cpp

@@ -44,7 +44,7 @@ Error ProbeReflections::init(const ConfigSet& config)
 Error ProbeReflections::initInternal(const ConfigSet& config)
 {
 	// Init cache entries
-	m_cacheEntries.create(getAllocator(), config.getNumber("r.indirect.maxSimultaneousProbeCount"));
+	m_cacheEntries.create(getAllocator(), config.getNumberU32("r.indirect.maxSimultaneousProbeCount"));
 
 	ANKI_CHECK(initGBuffer(config));
 	ANKI_CHECK(initLightShading(config));
@@ -68,7 +68,7 @@ Error ProbeReflections::initInternal(const ConfigSet& config)
 
 Error ProbeReflections::initGBuffer(const ConfigSet& config)
 {
-	m_gbuffer.m_tileSize = config.getNumber("r.indirect.reflectionResolution");
+	m_gbuffer.m_tileSize = config.getNumberU32("r.indirect.reflectionResolution");
 
 	// Create RT descriptions
 	{
@@ -115,7 +115,7 @@ Error ProbeReflections::initGBuffer(const ConfigSet& config)
 
 Error ProbeReflections::initLightShading(const ConfigSet& config)
 {
-	m_lightShading.m_tileSize = config.getNumber("r.indirect.reflectionResolution");
+	m_lightShading.m_tileSize = config.getNumberU32("r.indirect.reflectionResolution");
 	m_lightShading.m_mipCount = computeMaxMipmapCount2d(m_lightShading.m_tileSize, m_lightShading.m_tileSize, 8);
 
 	// Init cube arr
@@ -127,9 +127,9 @@ Error ProbeReflections::initLightShading(const ConfigSet& config)
 				| TextureUsageBit::IMAGE_COMPUTE_READ_WRITE | TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE
 				| TextureUsageBit::GENERATE_MIPMAPS,
 			"CubeRefl refl");
-		texinit.m_mipmapCount = m_lightShading.m_mipCount;
+		texinit.m_mipmapCount = U8(m_lightShading.m_mipCount);
 		texinit.m_type = TextureType::CUBE_ARRAY;
-		texinit.m_layerCount = m_cacheEntries.getSize();
+		texinit.m_layerCount = U32(m_cacheEntries.getSize());
 		texinit.m_initialUsage = TextureUsageBit::SAMPLED_FRAGMENT;
 
 		m_lightShading.m_cubeArr = m_r->createAndClearRenderTarget(texinit);
@@ -143,7 +143,7 @@ Error ProbeReflections::initLightShading(const ConfigSet& config)
 
 Error ProbeReflections::initIrradiance(const ConfigSet& config)
 {
-	m_irradiance.m_workgroupSize = config.getNumber("r.indirect.irradianceResolution");
+	m_irradiance.m_workgroupSize = config.getNumberU32("r.indirect.irradianceResolution");
 
 	// Create prog
 	{
@@ -188,7 +188,7 @@ Error ProbeReflections::initIrradianceToRefl(const ConfigSet& cfg)
 
 Error ProbeReflections::initShadowMapping(const ConfigSet& cfg)
 {
-	const U resolution = cfg.getNumber("r.indirect.shadowMapResolution");
+	const U32 resolution = cfg.getNumberU32("r.indirect.shadowMapResolution");
 	ANKI_ASSERT(resolution > 8);
 
 	// RT descr
@@ -220,7 +220,7 @@ void ProbeReflections::initCacheEntry(U32 cacheEntryIdx)
 {
 	CacheEntry& cacheEntry = m_cacheEntries[cacheEntryIdx];
 
-	for(U faceIdx = 0; faceIdx < 6; ++faceIdx)
+	for(U32 faceIdx = 0; faceIdx < 6; ++faceIdx)
 	{
 		// Light pass FB
 		FramebufferDescription& fbDescr = cacheEntry.m_lightShadingFbDescrs[faceIdx];
@@ -631,7 +631,7 @@ void ProbeReflections::populateRenderGraph(RenderingContext& rctx)
 			"CubeRefl LightShad #3",
 			"CubeRefl LightShad #4",
 			"CubeRefl LightShad #5"}};
-		for(U faceIdx = 0; faceIdx < 6; ++faceIdx)
+		for(U32 faceIdx = 0; faceIdx < 6; ++faceIdx)
 		{
 			GraphicsRenderPassDescription& pass = rgraph.newGraphicsRenderPass(passNames[faceIdx]);
 			pass.setFramebufferInfo(m_cacheEntries[probeToUpdateCacheEntryIdx].m_lightShadingFbDescrs[faceIdx],
@@ -719,7 +719,7 @@ void ProbeReflections::populateRenderGraph(RenderingContext& rctx)
 			"CubeRefl Mip #3",
 			"CubeRefl Mip #4",
 			"CubeRefl Mip #5"}};
-		for(U faceIdx = 0; faceIdx < 6; ++faceIdx)
+		for(U32 faceIdx = 0; faceIdx < 6; ++faceIdx)
 		{
 			GraphicsRenderPassDescription& pass = rgraph.newGraphicsRenderPass(passNames[faceIdx]);
 			pass.setWork(callbacks[faceIdx], this, 0);
@@ -750,7 +750,7 @@ void ProbeReflections::runShadowMapping(U32 faceIdx, CommandBufferPtr& cmdb)
 		return;
 	}
 
-	const U rez = m_shadowMapping.m_rtDescr.m_height;
+	const U32 rez = m_shadowMapping.m_rtDescr.m_height;
 	cmdb->setViewport(rez * faceIdx, 0, rez, rez);
 	cmdb->setScissor(rez * faceIdx, 0, rez, rez);
 

+ 3 - 3
src/anki/renderer/RenderQueue.cpp

@@ -8,9 +8,9 @@
 namespace anki
 {
 
-U RenderQueue::countAllRenderables() const
+PtrSize RenderQueue::countAllRenderables() const
 {
-	U drawableCount = 0;
+	PtrSize drawableCount = 0;
 	drawableCount += m_earlyZRenderables.getSize();
 	drawableCount += m_renderables.getSize();
 	drawableCount += m_forwardShadingRenderables.getSize();
@@ -48,4 +48,4 @@ U RenderQueue::countAllRenderables() const
 	return drawableCount;
 }
 
-} // end namespace anki
+} // end namespace anki

+ 1 - 1
src/anki/renderer/RenderQueue.h

@@ -382,7 +382,7 @@ public:
 		zeroMemory(m_directionalLight);
 	}
 
-	U countAllRenderables() const;
+	PtrSize countAllRenderables() const;
 };
 
 static_assert(std::is_trivially_destructible<RenderQueue>::value == true, "Should be trivially destructible");

+ 15 - 33
src/anki/renderer/Renderer.cpp

@@ -76,18 +76,18 @@ Error Renderer::init(ThreadHive* hive,
 Error Renderer::initInternal(const ConfigSet& config)
 {
 	// Set from the config
-	m_width = config.getNumber("width");
-	m_height = config.getNumber("height");
+	m_width = config.getNumberU32("width");
+	m_height = config.getNumberU32("height");
 	ANKI_R_LOGI("Initializing offscreen renderer. Size %ux%u", m_width, m_height);
 
 	ANKI_ASSERT(m_lodDistances.getSize() == 2);
-	m_lodDistances[0] = config.getNumber("r.lodDistance0");
-	m_lodDistances[1] = config.getNumber("r.lodDistance1");
+	m_lodDistances[0] = config.getNumberF32("r.lodDistance0");
+	m_lodDistances[1] = config.getNumberF32("r.lodDistance1");
 	m_frameCount = 0;
 
-	m_clusterCount[0] = config.getNumber("r.clusterSizeX");
-	m_clusterCount[1] = config.getNumber("r.clusterSizeY");
-	m_clusterCount[2] = config.getNumber("r.clusterSizeZ");
+	m_clusterCount[0] = config.getNumberU32("r.clusterSizeX");
+	m_clusterCount[1] = config.getNumberU32("r.clusterSizeY");
+	m_clusterCount[2] = config.getNumberU32("r.clusterSizeZ");
 	m_clusterCount[3] = m_clusterCount[0] * m_clusterCount[1] * m_clusterCount[2];
 
 	m_clusterBin.init(m_alloc, m_clusterCount[0], m_clusterCount[1], m_clusterCount[2], config);
@@ -201,7 +201,7 @@ Error Renderer::initInternal(const ConfigSet& config)
 		sinit.m_addressing = SamplingAddressing::REPEAT;
 		m_samplers.m_trilinearRepeat = m_gr->newSampler(sinit);
 
-		sinit.m_anisotropyLevel = config.getNumber("r.textureAnisotropy");
+		sinit.m_anisotropyLevel = U8(config.getNumberU32("r.textureAnisotropy"));
 		m_samplers.m_trilinearRepeatAniso = m_gr->newSampler(sinit);
 	}
 
@@ -231,7 +231,7 @@ void Renderer::initJitteredMats()
 
 	for(U i = 0; i < 16; ++i)
 	{
-		Vec2 texSize(1.0f / Vec2(m_width, m_height)); // Texel size
+		Vec2 texSize(1.0f / Vec2(F32(m_width), F32(m_height))); // Texel size
 		texSize *= 2.0f; // Move it to NDC
 
 		Vec2 S = SAMPLE_LOCS_16[i] / 8.0f; // In [-1, 1]
@@ -254,7 +254,7 @@ void Renderer::initJitteredMats()
 
 	for(U i = 0; i < 8; ++i)
 	{
-		Vec2 texSize(1.0f / Vec2(m_width, m_height)); // Texel size
+		Vec2 texSize(1.0f / Vec2(F32(m_width), F32(m_height))); // Texel size
 		texSize *= 2.0f; // Move it to NDC
 
 		Vec2 S = SAMPLE_LOCS_8[i] / 8.0f; // In [-1, 1]
@@ -364,24 +364,6 @@ void Renderer::finalize(const RenderingContext& ctx)
 	}
 }
 
-Vec3 Renderer::unproject(
-	const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat, const int view[4])
-{
-	Mat4 invPm = projectionMat * modelViewMat;
-	invPm.invert();
-
-	// the vec is in NDC space meaning: -1<=vec.x<=1 -1<=vec.y<=1 -1<=vec.z<=1
-	Vec4 vec;
-	vec.x() = (2.0 * (windowCoords.x() - view[0])) / view[2] - 1.0;
-	vec.y() = (2.0 * (windowCoords.y() - view[1])) / view[3] - 1.0;
-	vec.z() = 2.0 * windowCoords.z() - 1.0;
-	vec.w() = 1.0;
-
-	Vec4 out = invPm * vec;
-	out /= out.w();
-	return out.xyz();
-}
-
 TextureInitInfo Renderer::create2DRenderTargetInitInfo(U32 w, U32 h, Format format, TextureUsageBit usage, CString name)
 {
 	ANKI_ASSERT(
@@ -451,11 +433,11 @@ TexturePtr Renderer::createAndClearRenderTarget(const TextureInitInfo& inf, cons
 	}
 	CommandBufferPtr cmdb = m_gr->newCommandBuffer(cmdbinit);
 
-	for(U mip = 0; mip < inf.m_mipmapCount; ++mip)
+	for(U32 mip = 0; mip < inf.m_mipmapCount; ++mip)
 	{
-		for(U face = 0; face < faceCount; ++face)
+		for(U32 face = 0; face < faceCount; ++face)
 		{
-			for(U layer = 0; layer < inf.m_layerCount; ++layer)
+			for(U32 layer = 0; layer < inf.m_layerCount; ++layer)
 			{
 				TextureSurfaceInfo surf(mip, 0, face, layer);
 
@@ -561,8 +543,8 @@ void Renderer::updateLightShadingUniforms(RenderingContext& ctx) const
 	// Start writing
 	blk->m_unprojectionParams = ctx.m_unprojParams;
 
-	blk->m_rendererSize = Vec2(m_width, m_height);
-	blk->m_time = HighRezTimer::getCurrentTime();
+	blk->m_rendererSize = Vec2(F32(m_width), F32(m_height));
+	blk->m_time = F32(HighRezTimer::getCurrentTime());
 	blk->m_near = ctx.m_renderQueue->m_cameraNear;
 
 	blk->m_clusterCount = UVec4(m_clusterCount[0], m_clusterCount[1], m_clusterCount[2], m_clusterCount[3]);

+ 2 - 11
src/anki/renderer/Renderer.h

@@ -207,7 +207,7 @@ public:
 
 	F32 getAspectRatio() const
 	{
-		return F32(m_width) / m_height;
+		return F32(m_width) / F32(m_height);
 	}
 
 	/// Init the renderer.
@@ -257,17 +257,8 @@ anki_internal:
 		return *m_ui;
 	}
 
-	/// My version of gluUnproject
-	/// @param windowCoords Window screen coords
-	/// @param modelViewMat The modelview matrix
-	/// @param projectionMat The projection matrix
-	/// @param view The view vector
-	/// @return The unprojected coords
-	static Vec3 unproject(
-		const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat, const int view[4]);
-
 	/// Get the LOD given the distance of an object from the camera
-	U calculateLod(F32 distance) const
+	U32 calculateLod(F32 distance) const
 	{
 		ANKI_ASSERT(m_lodDistances.getSize() == 2);
 		if(distance < m_lodDistances[0])

+ 6 - 5
src/anki/renderer/RendererObject.cpp

@@ -36,7 +36,8 @@ void* RendererObject::allocateFrameStagingMemory(PtrSize size, StagingGpuMemoryT
 	return m_r->getStagingGpuMemoryManager().allocateFrame(size, usage, token);
 }
 
-void RendererObject::bindUniforms(CommandBufferPtr& cmdb, U set, U binding, const StagingGpuMemoryToken& token) const
+void RendererObject::bindUniforms(
+	CommandBufferPtr& cmdb, U32 set, U32 binding, const StagingGpuMemoryToken& token) const
 {
 	if(token && !token.isUnused())
 	{
@@ -48,7 +49,7 @@ void RendererObject::bindUniforms(CommandBufferPtr& cmdb, U set, U binding, cons
 	}
 }
 
-void RendererObject::bindStorage(CommandBufferPtr& cmdb, U set, U binding, const StagingGpuMemoryToken& token) const
+void RendererObject::bindStorage(CommandBufferPtr& cmdb, U32 set, U32 binding, const StagingGpuMemoryToken& token) const
 {
 	if(token && !token.isUnused())
 	{
@@ -62,11 +63,11 @@ void RendererObject::bindStorage(CommandBufferPtr& cmdb, U set, U binding, const
 
 U32 RendererObject::computeNumberOfSecondLevelCommandBuffers(U32 drawcallCount) const
 {
-	const U drawcallsPerThread = drawcallCount / m_r->getThreadHive().getThreadCount();
-	U secondLevelCmdbCount;
+	const U32 drawcallsPerThread = drawcallCount / m_r->getThreadHive().getThreadCount();
+	U32 secondLevelCmdbCount;
 	if(drawcallsPerThread < MIN_DRAWCALLS_PER_2ND_LEVEL_COMMAND_BUFFER)
 	{
-		secondLevelCmdbCount = max<U>(1u, drawcallCount / MIN_DRAWCALLS_PER_2ND_LEVEL_COMMAND_BUFFER);
+		secondLevelCmdbCount = max(1u, drawcallCount / MIN_DRAWCALLS_PER_2ND_LEVEL_COMMAND_BUFFER);
 	}
 	else
 	{

+ 9 - 9
src/anki/renderer/RendererObject.h

@@ -60,8 +60,8 @@ protected:
 	static void dispatchPPCompute(
 		CommandBufferPtr& cmdb, U32 workgroupSizeX, U32 workgroupSizeY, U32 outImageWidth, U32 outImageHeight)
 	{
-		const U sizeX = (outImageWidth + workgroupSizeX - 1) / workgroupSizeX;
-		const U sizeY = (outImageHeight + workgroupSizeY - 1) / workgroupSizeY;
+		const U32 sizeX = (outImageWidth + workgroupSizeX - 1) / workgroupSizeX;
+		const U32 sizeY = (outImageHeight + workgroupSizeY - 1) / workgroupSizeY;
 		cmdb->dispatchCompute(sizeX, sizeY, 1);
 	}
 
@@ -73,9 +73,9 @@ protected:
 		U32 outImageHeight,
 		U32 outImageDepth)
 	{
-		const U sizeX = (outImageWidth + workgroupSizeX - 1) / workgroupSizeX;
-		const U sizeY = (outImageHeight + workgroupSizeY - 1) / workgroupSizeY;
-		const U sizeZ = (outImageDepth + workgroupSizeZ - 1) / workgroupSizeZ;
+		const U32 sizeX = (outImageWidth + workgroupSizeX - 1) / workgroupSizeX;
+		const U32 sizeY = (outImageHeight + workgroupSizeY - 1) / workgroupSizeY;
+		const U32 sizeZ = (outImageDepth + workgroupSizeZ - 1) / workgroupSizeZ;
 		cmdb->dispatchCompute(sizeX, sizeY, sizeZ);
 	}
 
@@ -85,10 +85,10 @@ protected:
 		return static_cast<TPtr>(allocateFrameStagingMemory(size, StagingGpuMemoryType::UNIFORM, token));
 	}
 
-	void bindUniforms(CommandBufferPtr& cmdb, U set, U binding, const StagingGpuMemoryToken& token) const;
+	void bindUniforms(CommandBufferPtr& cmdb, U32 set, U32 binding, const StagingGpuMemoryToken& token) const;
 
 	template<typename TPtr>
-	TPtr allocateAndBindUniforms(PtrSize size, CommandBufferPtr& cmdb, U set, U binding)
+	TPtr allocateAndBindUniforms(PtrSize size, CommandBufferPtr& cmdb, U32 set, U32 binding)
 	{
 		StagingGpuMemoryToken token;
 		TPtr ptr = allocateUniforms<TPtr>(size, token);
@@ -102,10 +102,10 @@ protected:
 		return static_cast<TPtr>(allocateFrameStagingMemory(size, StagingGpuMemoryType::STORAGE, token));
 	}
 
-	void bindStorage(CommandBufferPtr& cmdb, U set, U binding, const StagingGpuMemoryToken& token) const;
+	void bindStorage(CommandBufferPtr& cmdb, U32 set, U32 binding, const StagingGpuMemoryToken& token) const;
 
 	template<typename TPtr>
-	TPtr allocateAndBindStorage(PtrSize size, CommandBufferPtr& cmdb, U set, U binding)
+	TPtr allocateAndBindStorage(PtrSize size, CommandBufferPtr& cmdb, U32 set, U32 binding)
 	{
 		StagingGpuMemoryToken token;
 		TPtr ptr = allocateStorage<TPtr>(size, token);

+ 31 - 31
src/anki/renderer/ShadowMapping.cpp

@@ -70,9 +70,9 @@ Error ShadowMapping::initScratch(const ConfigSet& cfg)
 {
 	// Init the shadowmaps and FBs
 	{
-		m_scratch.m_tileCountX = cfg.getNumber("r.shadowMapping.scratchTileCountX");
-		m_scratch.m_tileCountY = cfg.getNumber("r.shadowMapping.scratchTileCountY");
-		m_scratch.m_tileResolution = cfg.getNumber("r.shadowMapping.tileResolution");
+		m_scratch.m_tileCountX = cfg.getNumberU32("r.shadowMapping.scratchTileCountX");
+		m_scratch.m_tileCountY = cfg.getNumberU32("r.shadowMapping.scratchTileCountY");
+		m_scratch.m_tileResolution = cfg.getNumberU32("r.shadowMapping.tileResolution");
 
 		// RT
 		m_scratch.m_rtDescr = m_r->create2DRenderTargetDescription(m_scratch.m_tileResolution * m_scratch.m_tileCountX,
@@ -97,8 +97,8 @@ Error ShadowMapping::initAtlas(const ConfigSet& cfg)
 {
 	// Init RT
 	{
-		m_atlas.m_tileResolution = cfg.getNumber("r.shadowMapping.tileResolution");
-		m_atlas.m_tileCountBothAxis = cfg.getNumber("r.shadowMapping.tileCountPerRowOrColumn");
+		m_atlas.m_tileResolution = cfg.getNumberU32("r.shadowMapping.tileResolution");
+		m_atlas.m_tileCountBothAxis = cfg.getNumberU32("r.shadowMapping.tileCountPerRowOrColumn");
 
 		// RT
 		TextureInitInfo texinit = m_r->create2DRenderTargetInitInfo(
@@ -140,8 +140,8 @@ Error ShadowMapping::initInternal(const ConfigSet& cfg)
 	ANKI_CHECK(initScratch(cfg));
 	ANKI_CHECK(initAtlas(cfg));
 
-	m_lodDistances[0] = cfg.getNumber("r.shadowMapping.lightLodDistance0");
-	m_lodDistances[1] = cfg.getNumber("r.shadowMapping.lightLodDistance1");
+	m_lodDistances[0] = cfg.getNumberF32("r.shadowMapping.lightLodDistance0");
+	m_lodDistances[1] = cfg.getNumberF32("r.shadowMapping.lightLodDistance1");
 
 	return Error::NONE;
 }
@@ -292,7 +292,7 @@ void ShadowMapping::populateRenderGraph(RenderingContext& ctx)
 
 Mat4 ShadowMapping::createSpotLightTextureMatrix(const Viewport& viewport) const
 {
-	const F32 atlasSize = m_atlas.m_tileResolution * m_atlas.m_tileCountBothAxis;
+	const F32 atlasSize = F32(m_atlas.m_tileResolution * m_atlas.m_tileCountBothAxis);
 	const Vec2 uv(F32(viewport[0]) / atlasSize, F32(viewport[1]) / atlasSize);
 	ANKI_ASSERT(uv >= Vec2(0.0f) && uv <= Vec2(1.0f));
 
@@ -317,7 +317,7 @@ Mat4 ShadowMapping::createSpotLightTextureMatrix(const Viewport& viewport) const
 		1.0f);
 }
 
-U ShadowMapping::choseLod(const Vec4& cameraOrigin, const PointLightQueueElement& light, Bool& blurAtlas) const
+U32 ShadowMapping::choseLod(const Vec4& cameraOrigin, const PointLightQueueElement& light, Bool& blurAtlas) const
 {
 	const F32 distFromTheCamera = (cameraOrigin - light.m_worldPosition.xyz0()).getLength() - light.m_radius;
 	if(distFromTheCamera < m_lodDistances[0])
@@ -333,7 +333,7 @@ U ShadowMapping::choseLod(const Vec4& cameraOrigin, const PointLightQueueElement
 	}
 }
 
-U ShadowMapping::choseLod(const Vec4& cameraOrigin, const SpotLightQueueElement& light, Bool& blurAtlas) const
+U32 ShadowMapping::choseLod(const Vec4& cameraOrigin, const SpotLightQueueElement& light, Bool& blurAtlas) const
 {
 	// Get some data
 	const Vec4 coneOrigin = light.m_worldTransform.getTranslationPart().xyz0();
@@ -346,7 +346,7 @@ U ShadowMapping::choseLod(const Vec4& cameraOrigin, const SpotLightQueueElement&
 	const F32 V1len = V.dot(coneDir);
 	const F32 distFromTheCamera = cos(coneAngle) * sqrt(VlenSq - V1len * V1len) - V1len * sin(coneAngle);
 
-	U lod;
+	U32 lod;
 	if(distFromTheCamera < m_lodDistances[0])
 	{
 		blurAtlas = true;
@@ -514,9 +514,9 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 		Array<U32, MAX_SHADOW_CASCADES> lods;
 		Array<Bool, MAX_SHADOW_CASCADES> blurAtlass;
 
-		U activeCascades = 0;
+		U32 activeCascades = 0;
 
-		for(U cascade = 0; cascade < light.m_shadowCascadeCount; ++cascade)
+		for(U32 cascade = 0; cascade < light.m_shadowCascadeCount; ++cascade)
 		{
 			ANKI_ASSERT(light.m_shadowRenderQueues[cascade]);
 			if(light.m_shadowRenderQueues[cascade]->m_renderables.getSize() > 0)
@@ -601,12 +601,12 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 		Array<Viewport, 6> scratchViewports;
 		Array<TileAllocatorResult, 6> subResults;
 		Array<U32, 6> lods;
-		U numOfFacesThatHaveDrawcalls = 0;
+		U32 numOfFacesThatHaveDrawcalls = 0;
 
 		Bool blurAtlas;
-		const U lod = choseLod(cameraOrigin, *light, blurAtlas);
+		const U32 lod = choseLod(cameraOrigin, *light, blurAtlas);
 
-		for(U face = 0; face < 6; ++face)
+		for(U32 face = 0; face < 6; ++face)
 		{
 			ANKI_ASSERT(light->m_shadowRenderQueues[face]);
 			if(light->m_shadowRenderQueues[face]->m_renderables.getSize())
@@ -618,7 +618,7 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 					light->m_shadowRenderQueues[face]->m_shadowRenderablesLastUpdateTimestamp;
 
 				drawcallCounts[numOfFacesThatHaveDrawcalls] =
-					light->m_shadowRenderQueues[face]->m_renderables.getSize();
+					U32(light->m_shadowRenderQueues[face]->m_renderables.getSize());
 
 				lods[numOfFacesThatHaveDrawcalls] = lod;
 
@@ -643,7 +643,7 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 			// All good, update the lights
 
 			const F32 atlasResolution = F32(m_atlas.m_tileResolution * m_atlas.m_tileCountBothAxis);
-			F32 superTileSize = atlasViewports[0][2]; // Should be the same for all tiles and faces
+			F32 superTileSize = F32(atlasViewports[0][2]); // Should be the same for all tiles and faces
 			superTileSize -= 1.0f; // Remove 2 half texels to avoid bilinear filtering bleeding
 
 			light->m_shadowAtlasTileSize = superTileSize / atlasResolution;
@@ -680,9 +680,9 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 				{
 					// Doesn't have renderables, point the face to the empty tile
 					Viewport atlasViewport = emptyTileViewport;
-					ANKI_ASSERT(atlasViewport[2] <= superTileSize && atlasViewport[3] <= superTileSize);
-					atlasViewport[2] = superTileSize;
-					atlasViewport[3] = superTileSize;
+					ANKI_ASSERT(F32(atlasViewport[2]) <= superTileSize && F32(atlasViewport[3]) <= superTileSize);
+					atlasViewport[2] = U32(superTileSize);
+					atlasViewport[3] = U32(superTileSize);
 
 					light->m_shadowAtlasTileOffsets[face].x() = (F32(atlasViewport[0]) + 0.5f) / atlasResolution;
 					light->m_shadowAtlasTileOffsets[face].y() = (F32(atlasViewport[1]) + 0.5f) / atlasResolution;
@@ -706,7 +706,7 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 		TileAllocatorResult subResult;
 		Viewport atlasViewport;
 		Viewport scratchViewport;
-		const U32 localDrawcallCount = light->m_shadowRenderQueue->m_renderables.getSize();
+		const U32 localDrawcallCount = U32(light->m_shadowRenderQueue->m_renderables.getSize());
 
 		Bool blurAtlas;
 		const U32 lod = choseLod(cameraOrigin, *light, blurAtlas);
@@ -753,24 +753,24 @@ void ShadowMapping::processLights(RenderingContext& ctx, U32& threadCountForScra
 	{
 		DynamicArrayAuto<Scratch::WorkItem> workItems(ctx.m_tempAllocator);
 		Scratch::LightToRenderToScratchInfo* lightToRender = lightsToRender.getBegin();
-		U lightToRenderDrawcallCount = lightToRender->m_drawcallCount;
+		U32 lightToRenderDrawcallCount = lightToRender->m_drawcallCount;
 		const Scratch::LightToRenderToScratchInfo* lightToRenderEnd = lightsToRender.getEnd();
 
-		const U threadCount = computeNumberOfSecondLevelCommandBuffers(drawcallCount);
+		const U32 threadCount = computeNumberOfSecondLevelCommandBuffers(drawcallCount);
 		threadCountForScratchPass = threadCount;
-		for(U taskId = 0; taskId < threadCount; ++taskId)
+		for(U32 taskId = 0; taskId < threadCount; ++taskId)
 		{
-			PtrSize start, end;
+			U32 start, end;
 			splitThreadedProblem(taskId, threadCount, drawcallCount, start, end);
 
 			// While there are drawcalls in this task emit new work items
-			U taskDrawcallCount = end - start;
+			U32 taskDrawcallCount = end - start;
 			ANKI_ASSERT(taskDrawcallCount > 0 && "Because we used computeNumberOfSecondLevelCommandBuffers()");
 
 			while(taskDrawcallCount)
 			{
 				ANKI_ASSERT(lightToRender != lightToRenderEnd);
-				const U workItemDrawcallCount = min(lightToRenderDrawcallCount, taskDrawcallCount);
+				const U32 workItemDrawcallCount = min(lightToRenderDrawcallCount, taskDrawcallCount);
 
 				Scratch::WorkItem workItem;
 				workItem.m_viewport = lightToRender->m_viewport;
@@ -836,13 +836,13 @@ void ShadowMapping::newScratchAndAtlasResloveRenderWorkItems(const Viewport& atl
 		Scratch::LightToRenderToScratchInfo toRender = {
 			scratchVewport, lightRenderQueue, U32(lightRenderQueue->m_renderables.getSize())};
 		scratchWorkItem.emplaceBack(toRender);
-		drawcallCount += lightRenderQueue->m_renderables.getSize();
+		drawcallCount += U32(lightRenderQueue->m_renderables.getSize());
 	}
 
 	// Atlas resolve work item
 	{
-		const F32 scratchAtlasWidth = m_scratch.m_tileCountX * m_scratch.m_tileResolution;
-		const F32 scratchAtlasHeight = m_scratch.m_tileCountY * m_scratch.m_tileResolution;
+		const F32 scratchAtlasWidth = F32(m_scratch.m_tileCountX * m_scratch.m_tileResolution);
+		const F32 scratchAtlasHeight = F32(m_scratch.m_tileCountY * m_scratch.m_tileResolution);
 
 		Atlas::ResolveWorkItem atlasItem;
 		atlasItem.m_uvIn[0] = F32(scratchVewport[0]) / scratchAtlasWidth;

+ 4 - 4
src/anki/renderer/ShadowMapping.h

@@ -101,15 +101,15 @@ private:
 	/// @name Misc & common
 	/// @{
 
-	static const U m_lodCount = 3;
-	static const U m_pointLightsMaxLod = 1;
+	static const U32 m_lodCount = 3;
+	static const U32 m_pointLightsMaxLod = 1;
 
 	Array<F32, m_lodCount - 1> m_lodDistances;
 
 	/// Find the lod of the light
-	U choseLod(const Vec4& cameraOrigin, const PointLightQueueElement& light, Bool& blurAtlas) const;
+	U32 choseLod(const Vec4& cameraOrigin, const PointLightQueueElement& light, Bool& blurAtlas) const;
 	/// Find the lod of the light
-	U choseLod(const Vec4& cameraOrigin, const SpotLightQueueElement& light, Bool& blurAtlas) const;
+	U32 choseLod(const Vec4& cameraOrigin, const SpotLightQueueElement& light, Bool& blurAtlas) const;
 
 	/// Try to allocate a number of scratch tiles and regular tiles.
 	TileAllocatorResult allocateTilesAndScratchTiles(U64 lightUuid,

+ 2 - 2
src/anki/renderer/Ssao.cpp

@@ -156,8 +156,8 @@ void Ssao::runMain(const RenderingContext& ctx, RenderPassWorkContext& rgraphCtx
 	{
 		rgraphCtx.bindImage(0, 5, m_runCtx.m_rts[0], TextureSubresourceInfo());
 
-		const U sizeX = (m_width + m_workgroupSize[0] - 1) / m_workgroupSize[0];
-		const U sizeY = (m_height + m_workgroupSize[1] - 1) / m_workgroupSize[1];
+		const U32 sizeX = (m_width + m_workgroupSize[0] - 1) / m_workgroupSize[0];
+		const U32 sizeY = (m_height + m_workgroupSize[1] - 1) / m_workgroupSize[1];
 		cmdb->dispatchCompute(sizeX, sizeY, 1);
 	}
 	else

+ 4 - 4
src/anki/renderer/Ssr.cpp

@@ -50,9 +50,9 @@ Error Ssr::initInternal(const ConfigSet& cfg)
 	ShaderProgramResourceConstantValueInitList<5> consts(m_prog);
 	consts.add("FB_SIZE", UVec2(width, height));
 	consts.add("WORKGROUP_SIZE", UVec2(m_workgroupSize[0], m_workgroupSize[1]));
-	consts.add("MAX_STEPS", U32(cfg.getNumber("r.ssr.maxSteps")));
+	consts.add("MAX_STEPS", cfg.getNumberU32("r.ssr.maxSteps"));
 	consts.add("LIGHT_BUFFER_MIP_COUNT", U32(m_r->getDownscaleBlur().getMipmapCount()));
-	consts.add("HISTORY_COLOR_BLEND_FACTOR", F32(cfg.getNumber("r.ssr.historyBlendFactor")));
+	consts.add("HISTORY_COLOR_BLEND_FACTOR", cfg.getNumberF32("r.ssr.historyBlendFactor"));
 
 	ShaderProgramResourceMutationInitList<1> mutators(m_prog);
 	mutators.add("VARIANT", 0);
@@ -120,8 +120,8 @@ void Ssr::run(RenderPassWorkContext& rgraphCtx)
 	unis->m_normalMat = Mat3x4(ctx.m_matrices.m_view.getRotationPart());
 
 	// Dispatch
-	const U sizeX = (m_r->getWidth() / SSR_FRACTION + m_workgroupSize[0] - 1) / m_workgroupSize[0];
-	const U sizeY = (m_r->getHeight() / SSR_FRACTION + m_workgroupSize[1] - 1) / m_workgroupSize[1];
+	const U32 sizeX = (m_r->getWidth() / SSR_FRACTION + m_workgroupSize[0] - 1) / m_workgroupSize[0];
+	const U32 sizeY = (m_r->getHeight() / SSR_FRACTION + m_workgroupSize[1] - 1) / m_workgroupSize[1];
 	cmdb->dispatchCompute(sizeX / 2, sizeY, 1);
 }
 

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

@@ -38,7 +38,7 @@ Error TemporalAA::initInternal(const ConfigSet& config)
 {
 	ANKI_CHECK(m_r->getResourceManager().loadResource("shaders/TemporalAAResolve.glslp", m_prog));
 
-	for(U i = 0; i < 2; ++i)
+	for(U32 i = 0; i < 2; ++i)
 	{
 		ShaderProgramResourceConstantValueInitList<4> consts(m_prog);
 		consts.add("VARIANCE_CLIPPING_GAMMA", 1.7f)

+ 46 - 43
src/anki/renderer/TileAllocator.cpp

@@ -15,9 +15,9 @@ public:
 	Timestamp m_lastUsedTimestamp = 0; ///< The last timestamp this tile was used
 	U64 m_lightUuid = 0;
 	U32 m_lightDrawcallCount = 0;
-	Array<U16, 4> m_viewport = {};
-	Array<U16, 4> m_subTiles = {{MAX_U16, MAX_U16, MAX_U16, MAX_U16}};
-	U16 m_superTile = MAX_U16;
+	Array<U32, 4> m_viewport = {};
+	Array<U32, 4> m_subTiles = {{MAX_U32, MAX_U32, MAX_U32, MAX_U32}};
+	U32 m_superTile = MAX_U32;
 	U8 m_lightLod = 0;
 	U8 m_lightFace = 0;
 };
@@ -49,19 +49,19 @@ void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY
 	ANKI_ASSERT(lodCount > 0);
 
 	// Store some stuff
-	m_tileCountX = tileCountX;
-	m_tileCountY = tileCountY;
-	m_lodCount = lodCount;
+	m_tileCountX = U16(tileCountX);
+	m_tileCountY = U16(tileCountY);
+	m_lodCount = U8(lodCount);
 	m_alloc = alloc;
 	m_cachingEnabled = enableCaching;
 	m_lodFirstTileIndex.create(m_alloc, lodCount + 1);
 
 	// Create the tile array & index ranges
-	U tileCount = 0;
-	for(U lod = 0; lod < lodCount; ++lod)
+	U32 tileCount = 0;
+	for(U32 lod = 0; lod < lodCount; ++lod)
 	{
-		const U lodTileCountX = tileCountX >> lod;
-		const U lodTileCountY = tileCountY >> lod;
+		const U32 lodTileCountX = tileCountX >> lod;
+		const U32 lodTileCountY = tileCountY >> lod;
 		ANKI_ASSERT((lodTileCountX << lod) == tileCountX && "Every LOD should be power of 2 of its parent LOD");
 		ANKI_ASSERT((lodTileCountY << lod) == tileCountY && "Every LOD should be power of 2 of its parent LOD");
 
@@ -69,20 +69,20 @@ void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY
 
 		tileCount += lodTileCountX * lodTileCountY;
 	}
-	ANKI_ASSERT(tileCount >= tileCountX * tileCountY && tileCount < MAX_U16);
+	ANKI_ASSERT(tileCount >= tileCountX * tileCountY);
 	m_allTiles.create(m_alloc, tileCount);
 	m_lodFirstTileIndex[lodCount] = tileCount - 1;
 
 	// Init the tiles
-	U tileIdx = 0;
-	for(U lod = 0; lod < lodCount; ++lod)
+	U32 tileIdx = 0;
+	for(U32 lod = 0; lod < lodCount; ++lod)
 	{
-		const U lodTileCountX = tileCountX >> lod;
-		const U lodTileCountY = tileCountY >> lod;
+		const U32 lodTileCountX = tileCountX >> lod;
+		const U32 lodTileCountY = tileCountY >> lod;
 
-		for(U y = 0; y < lodTileCountY; ++y)
+		for(U32 y = 0; y < lodTileCountY; ++y)
 		{
-			for(U x = 0; x < lodTileCountX; ++x)
+			for(U32 x = 0; x < lodTileCountX; ++x)
 			{
 				ANKI_ASSERT(tileIdx >= m_lodFirstTileIndex[lod] && tileIdx <= m_lodFirstTileIndex[lod + 1]);
 				Tile& tile = m_allTiles[tileIdx];
@@ -95,11 +95,11 @@ void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY
 				if(lod > 0)
 				{
 					// Has sub tiles
-					for(U j = 0; j < 2; ++j)
+					for(U32 j = 0; j < 2; ++j)
 					{
-						for(U i = 0; i < 2; ++i)
+						for(U32 i = 0; i < 2; ++i)
 						{
-							const U subTileIdx = translateTileIdx((x << 1) + i, (y << 1) + j, lod - 1);
+							const U32 subTileIdx = translateTileIdx((x << 1) + i, (y << 1) + j, lod - 1);
 							m_allTiles[subTileIdx].m_superTile = tileIdx;
 
 							tile.m_subTiles[j * 2 + i] = subTileIdx;
@@ -119,12 +119,12 @@ void TileAllocator::init(HeapAllocator<U8> alloc, U32 tileCountX, U32 tileCountY
 
 void TileAllocator::updateSubTiles(const Tile& updateFrom)
 {
-	if(updateFrom.m_subTiles[0] == MAX_U16)
+	if(updateFrom.m_subTiles[0] == MAX_U32)
 	{
 		return;
 	}
 
-	for(U16 idx : updateFrom.m_subTiles)
+	for(U32 idx : updateFrom.m_subTiles)
 	{
 		m_allTiles[idx].m_lightTimestamp = updateFrom.m_lightTimestamp;
 		m_allTiles[idx].m_lastUsedTimestamp = updateFrom.m_lastUsedTimestamp;
@@ -139,7 +139,7 @@ void TileAllocator::updateSubTiles(const Tile& updateFrom)
 
 void TileAllocator::updateSuperTiles(const Tile& updateFrom)
 {
-	if(updateFrom.m_superTile != MAX_U16)
+	if(updateFrom.m_superTile != MAX_U32)
 	{
 		m_allTiles[updateFrom.m_superTile].m_lightUuid = 0;
 		m_allTiles[updateFrom.m_superTile].m_lastUsedTimestamp = updateFrom.m_lastUsedTimestamp;
@@ -147,12 +147,12 @@ void TileAllocator::updateSuperTiles(const Tile& updateFrom)
 	}
 }
 
-Bool TileAllocator::searchTileRecursively(U crntTileIdx,
-	U crntTileLod,
-	U allocationLod,
+Bool TileAllocator::searchTileRecursively(U32 crntTileIdx,
+	U32 crntTileLod,
+	U32 allocationLod,
 	Timestamp crntTimestamp,
-	U& emptyTileIdx,
-	U& toKickTileIdx,
+	U32& emptyTileIdx,
+	U32& toKickTileIdx,
 	Timestamp& tileToKickMinTimestamp) const
 {
 	const Tile& tile = m_allTiles[crntTileIdx];
@@ -169,13 +169,13 @@ Bool TileAllocator::searchTileRecursively(U crntTileIdx,
 			return true;
 		}
 	}
-	else if(tile.m_subTiles[0] != MAX_U16)
+	else if(tile.m_subTiles[0] != MAX_U32)
 	{
 		// Move down the hierarchy
 
 		ANKI_ASSERT(allocationLod < crntTileLod);
 
-		for(const U16 idx : tile.m_subTiles)
+		for(const U32 idx : tile.m_subTiles)
 		{
 			const Bool done = searchTileRecursively(idx,
 				crntTileLod >> 1,
@@ -195,8 +195,11 @@ Bool TileAllocator::searchTileRecursively(U crntTileIdx,
 	return false;
 }
 
-Bool TileAllocator::evaluateCandidate(
-	U tileIdx, Timestamp crntTimestamp, U& emptyTileIdx, U& toKickTileIdx, Timestamp& tileToKickMinTimestamp) const
+Bool TileAllocator::evaluateCandidate(U32 tileIdx,
+	Timestamp crntTimestamp,
+	U32& emptyTileIdx,
+	U32& toKickTileIdx,
+	Timestamp& tileToKickMinTimestamp) const
 {
 	const Tile& tile = m_allTiles[tileIdx];
 
@@ -286,15 +289,15 @@ TileAllocatorResult TileAllocator::allocate(Timestamp crntTimestamp,
 
 	// Start searching for a suitable tile. Do a hieratchical search to end up with better locality and not better
 	// utilization of the atlas' space
-	U emptyTileIdx = MAX_U;
-	U toKickTileIdx = MAX_U;
+	U32 emptyTileIdx = MAX_U32;
+	U32 toKickTileIdx = MAX_U32;
 	Timestamp tileToKickMinTimestamp = MAX_TIMESTAMP;
-	const U maxLod = m_lodCount - 1;
+	const U32 maxLod = m_lodCount - 1;
 	if(lod == maxLod)
 	{
 		// This search is simple, iterate the tiles of the max LOD
 
-		for(U tileIdx = m_lodFirstTileIndex[maxLod]; tileIdx <= m_lodFirstTileIndex[maxLod + 1]; ++tileIdx)
+		for(U32 tileIdx = m_lodFirstTileIndex[maxLod]; tileIdx <= m_lodFirstTileIndex[maxLod + 1]; ++tileIdx)
 		{
 			const Bool done =
 				evaluateCandidate(tileIdx, crntTimestamp, emptyTileIdx, toKickTileIdx, tileToKickMinTimestamp);
@@ -309,7 +312,7 @@ TileAllocatorResult TileAllocator::allocate(Timestamp crntTimestamp,
 	{
 		// Need to do a recursive search
 
-		for(U tileIdx = m_lodFirstTileIndex[maxLod]; tileIdx <= m_lodFirstTileIndex[maxLod + 1]; ++tileIdx)
+		for(U32 tileIdx = m_lodFirstTileIndex[maxLod]; tileIdx <= m_lodFirstTileIndex[maxLod + 1]; ++tileIdx)
 		{
 			const Bool done = searchTileRecursively(
 				tileIdx, maxLod, lod, crntTimestamp, emptyTileIdx, toKickTileIdx, tileToKickMinTimestamp);
@@ -321,12 +324,12 @@ TileAllocatorResult TileAllocator::allocate(Timestamp crntTimestamp,
 		}
 	}
 
-	U allocatedTileIdx;
-	if(emptyTileIdx != MAX_U)
+	U32 allocatedTileIdx;
+	if(emptyTileIdx != MAX_U32)
 	{
 		allocatedTileIdx = emptyTileIdx;
 	}
-	else if(toKickTileIdx != MAX_U)
+	else if(toKickTileIdx != MAX_U32)
 	{
 		allocatedTileIdx = toKickTileIdx;
 	}
@@ -344,8 +347,8 @@ TileAllocatorResult TileAllocator::allocate(Timestamp crntTimestamp,
 	allocatedTile.m_lastUsedTimestamp = crntTimestamp;
 	allocatedTile.m_lightUuid = lightUuid;
 	allocatedTile.m_lightDrawcallCount = drawcallCount;
-	allocatedTile.m_lightLod = lod;
-	allocatedTile.m_lightFace = lightFace;
+	allocatedTile.m_lightLod = U8(lod);
+	allocatedTile.m_lightFace = U8(lightFace);
 
 	updateTileHierarchy(allocatedTile);
 
@@ -380,4 +383,4 @@ void TileAllocator::invalidateCache(U64 lightUuid, U32 lightFace)
 	}
 }
 
-} // end namespace anki
+} // end namespace anki

+ 13 - 10
src/anki/renderer/TileAllocator.h

@@ -61,8 +61,8 @@ private:
 
 	U32 translateTileIdx(U32 x, U32 y, U32 lod) const
 	{
-		const U lodWidth = m_tileCountX >> lod;
-		const U idx = y * lodWidth + x + m_lodFirstTileIndex[lod];
+		const U32 lodWidth = m_tileCountX >> lod;
+		const U32 idx = y * lodWidth + x + m_lodFirstTileIndex[lod];
 		ANKI_ASSERT(idx < m_allTiles.getSize());
 		return idx;
 	}
@@ -79,17 +79,20 @@ private:
 	}
 
 	/// Search for a tile recursively.
-	Bool searchTileRecursively(U crntTileIdx,
-		U crntTileLod,
-		U allocationLod,
+	Bool searchTileRecursively(U32 crntTileIdx,
+		U32 crntTileLod,
+		U32 allocationLod,
 		Timestamp crntTimestamp,
-		U& emptyTileIdx,
-		U& toKickTileIdx,
+		U32& emptyTileIdx,
+		U32& toKickTileIdx,
 		Timestamp& tileToKickMinTimestamp) const;
 
-	Bool evaluateCandidate(
-		U tileIdx, Timestamp crntTimestamp, U& emptyTileIdx, U& toKickTileIdx, Timestamp& tileToKickMinTimestamp) const;
+	Bool evaluateCandidate(U32 tileIdx,
+		Timestamp crntTimestamp,
+		U32& emptyTileIdx,
+		U32& toKickTileIdx,
+		Timestamp& tileToKickMinTimestamp) const;
 };
 /// @}
 
-} // end namespace anki
+} // end namespace anki

+ 1 - 1
src/anki/renderer/Tonemapping.h

@@ -37,7 +37,7 @@ anki_internal:
 private:
 	ShaderProgramResourcePtr m_prog;
 	ShaderProgramPtr m_grProg;
-	U8 m_inputTexMip;
+	U32 m_inputTexMip;
 
 	BufferPtr m_luminanceBuff;
 

+ 3 - 3
src/anki/renderer/VolumetricFog.cpp

@@ -18,11 +18,11 @@ namespace anki
 Error VolumetricFog::init(const ConfigSet& config)
 {
 	// Misc
-	const U fractionXY = config.getNumber("r.volumetricLightingAccumulation.clusterFractionXY");
+	const U32 fractionXY = config.getNumberU32("r.volumetricLightingAccumulation.clusterFractionXY");
 	ANKI_ASSERT(fractionXY >= 1);
-	const U fractionZ = config.getNumber("r.volumetricLightingAccumulation.clusterFractionZ");
+	const U32 fractionZ = config.getNumberU32("r.volumetricLightingAccumulation.clusterFractionZ");
 	ANKI_ASSERT(fractionZ >= 1);
-	m_finalClusterZ = config.getNumber("r.volumetricLightingAccumulation.finalClusterInZ");
+	m_finalClusterZ = config.getNumberU32("r.volumetricLightingAccumulation.finalClusterInZ");
 	ANKI_ASSERT(m_finalClusterZ > 0 && m_finalClusterZ < m_r->getClusterCount()[2]);
 
 	m_volumeSize[0] = m_r->getClusterCount()[0] * fractionXY;

+ 4 - 4
src/anki/renderer/VolumetricLightingAccumulation.cpp

@@ -25,11 +25,11 @@ VolumetricLightingAccumulation::~VolumetricLightingAccumulation()
 Error VolumetricLightingAccumulation::init(const ConfigSet& config)
 {
 	// Misc
-	const U fractionXY = config.getNumber("r.volumetricLightingAccumulation.clusterFractionXY");
+	const U32 fractionXY = config.getNumberU32("r.volumetricLightingAccumulation.clusterFractionXY");
 	ANKI_ASSERT(fractionXY >= 1);
-	const U fractionZ = config.getNumber("r.volumetricLightingAccumulation.clusterFractionZ");
+	const U32 fractionZ = config.getNumberU32("r.volumetricLightingAccumulation.clusterFractionZ");
 	ANKI_ASSERT(fractionZ >= 1);
-	m_finalClusterZ = config.getNumber("r.volumetricLightingAccumulation.finalClusterInZ");
+	m_finalClusterZ = config.getNumberU32("r.volumetricLightingAccumulation.finalClusterInZ");
 	ANKI_ASSERT(m_finalClusterZ > 0 && m_finalClusterZ < m_r->getClusterCount()[2]);
 
 	m_volumeSize[0] = m_r->getClusterCount()[0] * fractionXY;
@@ -135,7 +135,7 @@ void VolumetricLightingAccumulation::run(RenderPassWorkContext& rgraphCtx)
 		Vec3 m_padding;
 		F32 m_noiseOffset;
 	} regs;
-	const F32 texelSize = 1.0f / m_noiseTex->getDepth();
+	const F32 texelSize = 1.0f / F32(m_noiseTex->getDepth());
 	regs.m_noiseOffset = texelSize * F32(m_r->getFrameCount() % m_noiseTex->getDepth()) + texelSize / 2.0f;
 
 	cmdb->setPushConstants(&regs, sizeof(regs));

Some files were not shown because too many files changed in this diff