Browse Source

Hack Glslang to disable explicit type conversions

Panagiotis Christopoulos Charitos 4 years ago
parent
commit
7af3d76a7e
50 changed files with 312 additions and 1049 deletions
  1. 45 6
      AnKi/ShaderCompiler/Glslang.cpp
  2. 51 51
      AnKi/ShaderCompiler/ShaderProgramParser.cpp
  3. 3 2
      AnKi/Shaders/ApplyIrradianceToReflection.ankiprog
  4. 1 1
      AnKi/Shaders/Bloom.ankiprog
  5. 2 2
      AnKi/Shaders/BloomUpscale.ankiprog
  6. 10 10
      AnKi/Shaders/ClusterBinning.ankiprog
  7. 6 6
      AnKi/Shaders/ClusteredShadingCommon.glsl
  8. 2 2
      AnKi/Shaders/DepthAwareBlur.glsl
  9. 2 2
      AnKi/Shaders/ExponentialShadowmappingResolve.ankiprog
  10. 3 3
      AnKi/Shaders/FinalComposite.ankiprog
  11. 2 2
      AnKi/Shaders/ForwardShadingCommonFrag.glsl
  12. 7 7
      AnKi/Shaders/Functions.glsl
  13. 0 158
      AnKi/Shaders/GBufferCommonFrag.glsl
  14. 0 317
      AnKi/Shaders/GBufferCommonTessc.glsl
  15. 0 157
      AnKi/Shaders/GBufferCommonTesse.glsl
  16. 0 150
      AnKi/Shaders/GBufferCommonVert.glsl
  17. 5 5
      AnKi/Shaders/GBufferGeneric.ankiprog
  18. 3 3
      AnKi/Shaders/GBufferPost.ankiprog
  19. 1 1
      AnKi/Shaders/GaussianBlur.glsl
  20. 2 2
      AnKi/Shaders/ImportanceSampling.glsl
  21. 2 2
      AnKi/Shaders/Include/Common.h
  22. 19 19
      AnKi/Shaders/Include/ModelTypes.h
  23. 8 8
      AnKi/Shaders/IrradianceDice.ankiprog
  24. 5 5
      AnKi/Shaders/LensFlareUpdateIndirectInfo.ankiprog
  25. 8 8
      AnKi/Shaders/LightShading.ankiprog
  26. 2 2
      AnKi/Shaders/LightShadingApplyFog.ankiprog
  27. 2 2
      AnKi/Shaders/LumaAwareBlur.ankiprog
  28. 1 1
      AnKi/Shaders/MotionVectors.ankiprog
  29. 1 1
      AnKi/Shaders/RtShadows.glsl
  30. 7 7
      AnKi/Shaders/RtShadowsDenoise.ankiprog
  31. 10 7
      AnKi/Shaders/RtShadowsHit.ankiprog
  32. 14 14
      AnKi/Shaders/RtShadowsRayGen.ankiprog
  33. 4 4
      AnKi/Shaders/RtShadowsSvgfAtrous.ankiprog
  34. 3 3
      AnKi/Shaders/RtShadowsSvgfVariance.ankiprog
  35. 4 4
      AnKi/Shaders/RtShadowsUpscale.ankiprog
  36. 1 1
      AnKi/Shaders/SceneDebug.ankiprog
  37. 11 11
      AnKi/Shaders/ShadowmapsResolve.ankiprog
  38. 2 2
      AnKi/Shaders/SsRaymarching.glsl
  39. 7 7
      AnKi/Shaders/Ssao.glsl
  40. 7 7
      AnKi/Shaders/Ssgi.ankiprog
  41. 4 4
      AnKi/Shaders/SsgiDenoise.ankiprog
  42. 16 16
      AnKi/Shaders/SsgiReconstruct.ankiprog
  43. 3 3
      AnKi/Shaders/Ssr.ankiprog
  44. 3 3
      AnKi/Shaders/TemporalAAResolve.ankiprog
  45. 3 3
      AnKi/Shaders/TonemappingAverageLuminance.ankiprog
  46. 3 3
      AnKi/Shaders/VolumetricFogAccumulation.ankiprog
  47. 6 6
      AnKi/Shaders/VolumetricLightingAccumulation.ankiprog
  48. 3 3
      AnKi/Util/StdTypes.h
  49. 6 6
      Tests/ShaderCompiler/ShaderProgramCompiler.cpp
  50. 2 0
      ThirdParty/Glslang/glslang/MachineIndependent/Intermediate.cpp

+ 45 - 6
AnKi/ShaderCompiler/Glslang.cpp

@@ -197,8 +197,41 @@ static EShLanguage ankiToGlslangShaderType(ShaderType shaderType)
 	return gslangShader;
 	return gslangShader;
 }
 }
 
 
-static void logShaderErrorCode(CString error, CString source, GenericMemoryPoolAllocator<U8> alloc)
+/// Parse Glslang's error message for the line of the error.
+static ANKI_USE_RESULT Error parseErrorLine(CString error, GenericMemoryPoolAllocator<U8> alloc, U32& lineNumber)
 {
 {
+	lineNumber = MAX_U32;
+
+	StringListAuto lines(alloc);
+	lines.splitString(error, '\n');
+	for(String& line : lines)
+	{
+		if(line.find("ERROR: ") == 0)
+		{
+			StringListAuto tokens(alloc);
+			tokens.splitString(line, ':');
+
+			if(tokens.getSize() < 3 || (tokens.getBegin() + 2)->toNumber(lineNumber) != Error::NONE)
+			{
+
+				ANKI_SHADER_COMPILER_LOGE("Failed to parse the error message: %s", error.cstr());
+				return Error::FUNCTION_FAILED;
+			}
+			else
+			{
+				break;
+			}
+		}
+	}
+
+	return Error::NONE;
+}
+
+static ANKI_USE_RESULT Error logShaderErrorCode(CString error, CString source, GenericMemoryPoolAllocator<U8> alloc)
+{
+	U32 errorLineNumber = 0;
+	ANKI_CHECK(parseErrorLine(error, alloc, errorLineNumber));
+
 	StringAuto prettySrc(alloc);
 	StringAuto prettySrc(alloc);
 	StringListAuto lines(alloc);
 	StringListAuto lines(alloc);
 
 
@@ -206,19 +239,23 @@ static void logShaderErrorCode(CString error, CString source, GenericMemoryPoolA
 
 
 	lines.splitString(source, '\n', true);
 	lines.splitString(source, '\n', true);
 
 
-	I lineno = 0;
+	U32 lineno = 0;
 	for(auto it = lines.getBegin(); it != lines.getEnd(); ++it)
 	for(auto it = lines.getBegin(); it != lines.getEnd(); ++it)
 	{
 	{
 		++lineno;
 		++lineno;
 		StringAuto tmp(alloc);
 		StringAuto tmp(alloc);
 
 
-		if(!it->isEmpty())
+		if(!it->isEmpty() && lineno == errorLineNumber)
 		{
 		{
-			tmp.sprintf("%8d: %s\n", lineno, &(*it)[0]);
+			tmp.sprintf(">>%8u: %s\n", lineno, &(*it)[0]);
+		}
+		else if(!it->isEmpty())
+		{
+			tmp.sprintf("  %8u: %s\n", lineno, &(*it)[0]);
 		}
 		}
 		else
 		else
 		{
 		{
-			tmp.sprintf("%8d:\n", lineno);
+			tmp.sprintf("  %8u:\n", lineno);
 		}
 		}
 
 
 		prettySrc.append(tmp);
 		prettySrc.append(tmp);
@@ -226,6 +263,8 @@ static void logShaderErrorCode(CString error, CString source, GenericMemoryPoolA
 
 
 	ANKI_SHADER_COMPILER_LOGE("Shader compilation failed:\n%s\n%s\n%s\n%s\n%s\n%s", padding, &error[0], padding,
 	ANKI_SHADER_COMPILER_LOGE("Shader compilation failed:\n%s\n%s\n%s\n%s\n%s\n%s", padding, &error[0], padding,
 							  &prettySrc[0], padding, &error[0]);
 							  &prettySrc[0], padding, &error[0]);
+
+	return Error::NONE;
 }
 }
 
 
 Error preprocessGlsl(CString in, StringAuto& out)
 Error preprocessGlsl(CString in, StringAuto& out)
@@ -278,7 +317,7 @@ Error compilerGlslToSpirv(CString src, ShaderType shaderType, GenericMemoryPoolA
 	shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_5);
 	shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_5);
 	if(!shader.parse(&GLSLANG_LIMITS, 100, false, messages))
 	if(!shader.parse(&GLSLANG_LIMITS, 100, false, messages))
 	{
 	{
-		logShaderErrorCode(shader.getInfoLog(), src, tmpAlloc);
+		ANKI_CHECK(logShaderErrorCode(shader.getInfoLog(), src, tmpAlloc));
 		return Error::USER_DATA;
 		return Error::USER_DATA;
 	}
 	}
 
 

+ 51 - 51
AnKi/ShaderCompiler/ShaderProgramParser.cpp

@@ -76,102 +76,102 @@ static const char* SHADER_HEADER = R"(#version 460 core
 	layout(set = set_, binding = 1) uniform readonly image2D u_bindlessImages2dF32[ANKI_MAX_BINDLESS_IMAGES]
 	layout(set = set_, binding = 1) uniform readonly image2D u_bindlessImages2dF32[ANKI_MAX_BINDLESS_IMAGES]
 
 
 #define F32 float
 #define F32 float
-#define _ANKI_SIZEOF_float 4
+#define _ANKI_SIZEOF_float 4u
 #define Vec2 vec2
 #define Vec2 vec2
-#define _ANKI_SIZEOF_vec2 8
+#define _ANKI_SIZEOF_vec2 8u
 #define Vec3 vec3
 #define Vec3 vec3
-#define _ANKI_SIZEOF_vec3 12
+#define _ANKI_SIZEOF_vec3 12u
 #define Vec4 vec4
 #define Vec4 vec4
-#define _ANKI_SIZEOF_vec4 16
+#define _ANKI_SIZEOF_vec4 16u
 
 
 #define F16 float16_t
 #define F16 float16_t
-#define _ANKI_SIZEOF_float16_t 2
+#define _ANKI_SIZEOF_float16_t 2u
 #define HVec2 f16vec2
 #define HVec2 f16vec2
-#define _ANKI_SIZEOF_f16vec2 4
+#define _ANKI_SIZEOF_f16vec2 4u
 #define HVec3 f16vec3
 #define HVec3 f16vec3
-#define _ANKI_SIZEOF_f16vec3 6
+#define _ANKI_SIZEOF_f16vec3 6u
 #define HVec4 f16vec4
 #define HVec4 f16vec4
-#define _ANKI_SIZEOF_f16vec4 8
+#define _ANKI_SIZEOF_f16vec4 8u
 
 
 #define U8 uint8_t
 #define U8 uint8_t
-#define _ANKI_SIZEOF_uint8_t 1
+#define _ANKI_SIZEOF_uint8_t 1u
 #define U8Vec2 u8vec2
 #define U8Vec2 u8vec2
-#define _ANKI_SIZEOF_u8vec2 2
+#define _ANKI_SIZEOF_u8vec2 2u
 #define U8Vec3 u8vec3
 #define U8Vec3 u8vec3
-#define _ANKI_SIZEOF_u8vec3 3
+#define _ANKI_SIZEOF_u8vec3 3u
 #define U8Vec4 u8vec4
 #define U8Vec4 u8vec4
-#define _ANKI_SIZEOF_u8vec4 4
+#define _ANKI_SIZEOF_u8vec4 4u
 
 
 #define I8 int8_t
 #define I8 int8_t
-#define _ANKI_SIZEOF_int8_t 1
+#define _ANKI_SIZEOF_int8_t 1u
 #define I8Vec2 i8vec2
 #define I8Vec2 i8vec2
-#define _ANKI_SIZEOF_i8vec2 2
+#define _ANKI_SIZEOF_i8vec2 2u
 #define I8Vec3 i8vec3
 #define I8Vec3 i8vec3
-#define _ANKI_SIZEOF_i8vec3 3
+#define _ANKI_SIZEOF_i8vec3 3u
 #define I8Vec4 i8vec4
 #define I8Vec4 i8vec4
-#define _ANKI_SIZEOF_i8vec4 4
+#define _ANKI_SIZEOF_i8vec4 4u
 
 
 #define U16 uint16_t
 #define U16 uint16_t
-#define _ANKI_SIZEOF_uint16_t 2
+#define _ANKI_SIZEOF_uint16_t 2u
 #define U16Vec2 u16vec2
 #define U16Vec2 u16vec2
-#define _ANKI_SIZEOF_u16vec2 4
+#define _ANKI_SIZEOF_u16vec2 4u
 #define U16Vec3 u16vec3
 #define U16Vec3 u16vec3
-#define _ANKI_SIZEOF_u16vec3 6
+#define _ANKI_SIZEOF_u16vec3 6u
 #define U16Vec4 u16vec4
 #define U16Vec4 u16vec4
-#define _ANKI_SIZEOF_u16vec4 8
+#define _ANKI_SIZEOF_u16vec4 8u
 
 
 #define I16 int16_t
 #define I16 int16_t
-#define _ANKI_SIZEOF_int16_t 2
+#define _ANKI_SIZEOF_int16_t 2u
 #define I16Vec2 i16vec2
 #define I16Vec2 i16vec2
-#define _ANKI_SIZEOF_i16vec2 4
+#define _ANKI_SIZEOF_i16vec2 4u
 #define I16Vec3 i16vec3
 #define I16Vec3 i16vec3
-#define _ANKI_SIZEOF_i16vec3 6
+#define _ANKI_SIZEOF_i16vec3 6u
 #define i16Vec4 i16vec4
 #define i16Vec4 i16vec4
-#define _ANKI_SIZEOF_i16vec4 8
+#define _ANKI_SIZEOF_i16vec4 8u
 
 
 #define U32 uint
 #define U32 uint
-#define _ANKI_SIZEOF_uint 4
+#define _ANKI_SIZEOF_uint 4u
 #define UVec2 uvec2
 #define UVec2 uvec2
-#define _ANKI_SIZEOF_uvec2 8
+#define _ANKI_SIZEOF_uvec2 8u
 #define UVec3 uvec3
 #define UVec3 uvec3
-#define _ANKI_SIZEOF_uvec3 12
+#define _ANKI_SIZEOF_uvec3 12u
 #define UVec4 uvec4
 #define UVec4 uvec4
-#define _ANKI_SIZEOF_uvec4 16
+#define _ANKI_SIZEOF_uvec4 16u
 
 
 #define I32 int
 #define I32 int
-#define _ANKI_SIZEOF_int 4
+#define _ANKI_SIZEOF_int 4u
 #define IVec2 ivec2
 #define IVec2 ivec2
-#define _ANKI_SIZEOF_ivec2 8
+#define _ANKI_SIZEOF_ivec2 8u
 #define IVec3 ivec3
 #define IVec3 ivec3
-#define _ANKI_SIZEOF_ivec3 12
+#define _ANKI_SIZEOF_ivec3 12u
 #define IVec4 ivec4
 #define IVec4 ivec4
-#define _ANKI_SIZEOF_ivec4 16
+#define _ANKI_SIZEOF_ivec4 16u
 
 
 #define U64 uint64_t
 #define U64 uint64_t
-#define _ANKI_SIZEOF_uint64_t 8
+#define _ANKI_SIZEOF_uint64_t 8u
 #define U64Vec2 u64vec2
 #define U64Vec2 u64vec2
-#define _ANKI_SIZEOF_u64vec2 16
+#define _ANKI_SIZEOF_u64vec2 16u
 #define U64Vec3 u64vec3
 #define U64Vec3 u64vec3
-#define _ANKI_SIZEOF_u64vec3 24
+#define _ANKI_SIZEOF_u64vec3 24u
 #define U64Vec4 u64vec4
 #define U64Vec4 u64vec4
-#define _ANKI_SIZEOF_u64vec4 32
+#define _ANKI_SIZEOF_u64vec4 32u
 
 
 #define I64 int64_t
 #define I64 int64_t
-#define _ANKI_SIZEOF_int64_t 8
+#define _ANKI_SIZEOF_int64_t 8u
 #define I64Vec2 i64vec2
 #define I64Vec2 i64vec2
-#define _ANKI_SIZEOF_i64vec2 16
+#define _ANKI_SIZEOF_i64vec2 16u
 #define I64Vec3 i64vec3
 #define I64Vec3 i64vec3
-#define _ANKI_SIZEOF_i64vec3 24
+#define _ANKI_SIZEOF_i64vec3 24u
 #define I64Vec4 i64vec4
 #define I64Vec4 i64vec4
-#define _ANKI_SIZEOF_i64vec4 32
+#define _ANKI_SIZEOF_i64vec4 32u
 
 
 #define Mat3 mat3
 #define Mat3 mat3
 
 
 #define Mat4 mat4
 #define Mat4 mat4
-#define _ANKI_SIZEOF_mat4 64
+#define _ANKI_SIZEOF_mat4 64u
 
 
 #define Mat3x4 mat3x4
 #define Mat3x4 mat3x4
-#define _ANKI_SIZEOF_mat3x4 48
+#define _ANKI_SIZEOF_mat3x4 48u
 
 
 #define Bool bool
 #define Bool bool
 
 
@@ -186,22 +186,22 @@ static const char* SHADER_HEADER = R"(#version 460 core
 	const U32 ANKI_CONCATENATE(n, _CONST_ID) = id
 	const U32 ANKI_CONCATENATE(n, _CONST_ID) = id
 
 
 #define _ANKI_SCONST_X2(type, componentType, n, id, constWorkaround) \
 #define _ANKI_SCONST_X2(type, componentType, n, id, constWorkaround) \
-	layout(constant_id = id + 0) const componentType ANKI_CONCATENATE(_anki_const_0_2_, n) = componentType(1); \
-	layout(constant_id = id + 1) const componentType ANKI_CONCATENATE(_anki_const_1_2_, n) = componentType(1); \
+	layout(constant_id = id + 0u) const componentType ANKI_CONCATENATE(_anki_const_0_2_, n) = componentType(1); \
+	layout(constant_id = id + 1u) const componentType ANKI_CONCATENATE(_anki_const_1_2_, n) = componentType(1); \
 	constWorkaround type n = type(ANKI_CONCATENATE(_anki_const_0_2_, n), ANKI_CONCATENATE(_anki_const_1_2_, n))
 	constWorkaround type n = type(ANKI_CONCATENATE(_anki_const_0_2_, n), ANKI_CONCATENATE(_anki_const_1_2_, n))
 
 
 #define _ANKI_SCONST_X3(type, componentType, n, id, constWorkaround) \
 #define _ANKI_SCONST_X3(type, componentType, n, id, constWorkaround) \
-	layout(constant_id = id + 0) const componentType ANKI_CONCATENATE(_anki_const_0_3_, n) = componentType(1); \
-	layout(constant_id = id + 1) const componentType ANKI_CONCATENATE(_anki_const_1_3_, n) = componentType(1); \
-	layout(constant_id = id + 2) const componentType ANKI_CONCATENATE(_anki_const_2_3_, n) = componentType(1); \
+	layout(constant_id = id + 0u) const componentType ANKI_CONCATENATE(_anki_const_0_3_, n) = componentType(1); \
+	layout(constant_id = id + 1u) const componentType ANKI_CONCATENATE(_anki_const_1_3_, n) = componentType(1); \
+	layout(constant_id = id + 2u) const componentType ANKI_CONCATENATE(_anki_const_2_3_, n) = componentType(1); \
 	constWorkaround type n = type(ANKI_CONCATENATE(_anki_const_0_3_, n), ANKI_CONCATENATE(_anki_const_1_3_, n), \
 	constWorkaround type n = type(ANKI_CONCATENATE(_anki_const_0_3_, n), ANKI_CONCATENATE(_anki_const_1_3_, n), \
 		ANKI_CONCATENATE(_anki_const_2_3_, n))
 		ANKI_CONCATENATE(_anki_const_2_3_, n))
 
 
 #define _ANKI_SCONST_X4(type, componentType, n, id, constWorkaround) \
 #define _ANKI_SCONST_X4(type, componentType, n, id, constWorkaround) \
-	layout(constant_id = id + 0) const componentType ANKI_CONCATENATE(_anki_const_0_4_, n) = componentType(1); \
-	layout(constant_id = id + 1) const componentType ANKI_CONCATENATE(_anki_const_1_4_, n) = componentType(1); \
-	layout(constant_id = id + 2) const componentType ANKI_CONCATENATE(_anki_const_2_4_, n) = componentType(1); \
-	layout(constant_id = id + 3) const componentType ANKI_CONCATENATE(_anki_const_3_4_, n) = componentType(1); \
+	layout(constant_id = id + 0u) const componentType ANKI_CONCATENATE(_anki_const_0_4_, n) = componentType(1); \
+	layout(constant_id = id + 1u) const componentType ANKI_CONCATENATE(_anki_const_1_4_, n) = componentType(1); \
+	layout(constant_id = id + 2u) const componentType ANKI_CONCATENATE(_anki_const_2_4_, n) = componentType(1); \
+	layout(constant_id = id + 3u) const componentType ANKI_CONCATENATE(_anki_const_3_4_, n) = componentType(1); \
 	constWorkaround type n = type(ANKI_CONCATENATE(_anki_const_0_4_, n), ANKI_CONCATENATE(_anki_const_1_4_, n), \
 	constWorkaround type n = type(ANKI_CONCATENATE(_anki_const_0_4_, n), ANKI_CONCATENATE(_anki_const_1_4_, n), \
 		ANKI_CONCATENATE(_anki_const_2_4_, n), ANKI_CONCATENATE(_anki_const_2_4_, n))
 		ANKI_CONCATENATE(_anki_const_2_4_, n), ANKI_CONCATENATE(_anki_const_2_4_, n))
 
 

+ 3 - 2
AnKi/Shaders/ApplyIrradianceToReflection.ankiprog

@@ -21,8 +21,9 @@ layout(set = 0, binding = 3, r11f_g11f_b10f) uniform imageCube u_cubeTex;
 
 
 void main()
 void main()
 {
 {
-	const Vec2 cubeSize = Vec2(imageSize(u_cubeTex));
-	if(gl_GlobalInvocationID.x >= cubeSize.x || gl_GlobalInvocationID.y >= cubeSize.y)
+	const UVec2 cubeSizeu = UVec2(imageSize(u_cubeTex));
+	const Vec2 cubeSize = Vec2(cubeSizeu);
+	if(gl_GlobalInvocationID.x >= cubeSizeu.x || gl_GlobalInvocationID.y >= cubeSizeu.y)
 	{
 	{
 		return;
 		return;
 	}
 	}

+ 1 - 1
AnKi/Shaders/Bloom.ankiprog

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u);
 const UVec2 WORKGROUP_SIZE = UVec2(16, 16);
 const UVec2 WORKGROUP_SIZE = UVec2(16, 16);
 
 
 #pragma anki start comp
 #pragma anki start comp

+ 2 - 2
AnKi/Shaders/BloomUpscale.ankiprog

@@ -3,8 +3,8 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEX_SIZE, 2);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEX_SIZE, 2u);
 const UVec2 WORKGROUP_SIZE = UVec2(16u, 16u);
 const UVec2 WORKGROUP_SIZE = UVec2(16u, 16u);
 
 
 #pragma anki start comp
 #pragma anki start comp

+ 10 - 10
AnKi/Shaders/ClusterBinning.ankiprog

@@ -3,11 +3,11 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_U32(TILE_COUNT_X, 1);
-ANKI_SPECIALIZATION_CONSTANT_U32(TILE_COUNT_Y, 2);
-ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 3);
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(RENDERING_SIZE, 4);
+ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_U32(TILE_COUNT_X, 1u);
+ANKI_SPECIALIZATION_CONSTANT_U32(TILE_COUNT_Y, 2u);
+ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 3u);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(RENDERING_SIZE, 4u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
@@ -132,12 +132,12 @@ void main()
 	const Vec3 rayDir = normalize(farWorldPos - rayOrigin);
 	const Vec3 rayDir = normalize(farWorldPos - rayOrigin);
 
 
 	// Zero shared memory
 	// Zero shared memory
-	s_tileMasks[localTileIdx] = 0u;
+	s_tileMasks[localTileIdx] = 0ul;
 	const U32 splitsPerInvocation = max(1u, Z_SPLIT_COUNT / WORKGROUP_SIZE);
 	const U32 splitsPerInvocation = max(1u, Z_SPLIT_COUNT / WORKGROUP_SIZE);
 	for(U32 i = gl_LocalInvocationIndex * splitsPerInvocation;
 	for(U32 i = gl_LocalInvocationIndex * splitsPerInvocation;
 		i < (gl_LocalInvocationIndex + 1u) * splitsPerInvocation && i < Z_SPLIT_COUNT; ++i)
 		i < (gl_LocalInvocationIndex + 1u) * splitsPerInvocation && i < Z_SPLIT_COUNT; ++i)
 	{
 	{
-		s_zSplitMasks[i] = 0u;
+		s_zSplitMasks[i] = 0ul;
 	}
 	}
 	memoryBarrierShared();
 	memoryBarrierShared();
 	barrier();
 	barrier();
@@ -238,7 +238,7 @@ void main()
 	if(collides)
 	if(collides)
 	{
 	{
 		// Set the tile
 		// Set the tile
-		const U64 mask = U64(1u) << U64(objectArrayIdx);
+		const U64 mask = 1ul << U64(objectArrayIdx);
 		atomicOr(s_tileMasks[localTileIdx], mask);
 		atomicOr(s_tileMasks[localTileIdx], mask);
 
 
 		// Compute and set the Z splits
 		// Compute and set the Z splits
@@ -276,7 +276,7 @@ void main()
 	barrier();
 	barrier();
 
 
 	// First sample writes the tile
 	// First sample writes the tile
-	if(sampleIdx == 0u && s_tileMasks[localTileIdx] != 0u)
+	if(sampleIdx == 0u && s_tileMasks[localTileIdx] != 0ul)
 	{
 	{
 		if(isPointLight())
 		if(isPointLight())
 		{
 		{
@@ -308,7 +308,7 @@ void main()
 	for(U32 i = gl_LocalInvocationIndex * splitsPerInvocation;
 	for(U32 i = gl_LocalInvocationIndex * splitsPerInvocation;
 		i < (gl_LocalInvocationIndex + 1u) * splitsPerInvocation && i < Z_SPLIT_COUNT; ++i)
 		i < (gl_LocalInvocationIndex + 1u) * splitsPerInvocation && i < Z_SPLIT_COUNT; ++i)
 	{
 	{
-		if(s_zSplitMasks[i] != 0u)
+		if(s_zSplitMasks[i] != 0ul)
 		{
 		{
 			if(isPointLight())
 			if(isPointLight())
 			{
 			{

+ 6 - 6
AnKi/Shaders/ClusteredShadingCommon.glsl

@@ -102,37 +102,37 @@ Vec3 clusterHeatmap(Cluster cluster, U32 objectTypeMask)
 	U32 maxObjects = 0u;
 	U32 maxObjects = 0u;
 	I32 count = 0;
 	I32 count = 0;
 
 
-	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_POINT_LIGHT)) != 0)
+	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_POINT_LIGHT)) != 0u)
 	{
 	{
 		maxObjects += MAX_VISIBLE_POINT_LIGHTS;
 		maxObjects += MAX_VISIBLE_POINT_LIGHTS;
 		count += I32(bitCount(cluster.m_pointLightsMask));
 		count += I32(bitCount(cluster.m_pointLightsMask));
 	}
 	}
 
 
-	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_SPOT_LIGHT)) != 0)
+	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_SPOT_LIGHT)) != 0u)
 	{
 	{
 		maxObjects += MAX_VISIBLE_SPOT_LIGHTS;
 		maxObjects += MAX_VISIBLE_SPOT_LIGHTS;
 		count += I32(bitCount(cluster.m_spotLightsMask));
 		count += I32(bitCount(cluster.m_spotLightsMask));
 	}
 	}
 
 
-	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_DECAL)) != 0)
+	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_DECAL)) != 0u)
 	{
 	{
 		maxObjects += MAX_VISIBLE_DECALS;
 		maxObjects += MAX_VISIBLE_DECALS;
 		count += I32(bitCount(cluster.m_decalsMask));
 		count += I32(bitCount(cluster.m_decalsMask));
 	}
 	}
 
 
-	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME)) != 0)
+	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME)) != 0u)
 	{
 	{
 		maxObjects += MAX_VISIBLE_FOG_DENSITY_VOLUMES;
 		maxObjects += MAX_VISIBLE_FOG_DENSITY_VOLUMES;
 		count += bitCount(cluster.m_fogDensityVolumesMask);
 		count += bitCount(cluster.m_fogDensityVolumesMask);
 	}
 	}
 
 
-	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_REFLECTION_PROBE)) != 0)
+	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_REFLECTION_PROBE)) != 0u)
 	{
 	{
 		maxObjects += MAX_VISIBLE_REFLECTION_PROBES;
 		maxObjects += MAX_VISIBLE_REFLECTION_PROBES;
 		count += bitCount(cluster.m_reflectionProbesMask);
 		count += bitCount(cluster.m_reflectionProbesMask);
 	}
 	}
 
 
-	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE)) != 0)
+	if((objectTypeMask & (1u << CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE)) != 0u)
 	{
 	{
 		maxObjects += MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES;
 		maxObjects += MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES;
 		count += bitCount(cluster.m_giProbesMask);
 		count += bitCount(cluster.m_giProbesMask);

+ 2 - 2
AnKi/Shaders/DepthAwareBlur.glsl

@@ -7,7 +7,7 @@
 #pragma anki mutator SAMPLE_COUNT 3 5 7 9 11 13 15
 #pragma anki mutator SAMPLE_COUNT 3 5 7 9 11 13 15
 #pragma anki mutator COLOR_COMPONENTS 4 3 1
 #pragma anki mutator COLOR_COMPONENTS 4 3 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(TEXTURE_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(TEXTURE_SIZE, 0u);
 
 
 #include <AnKi/Shaders/Common.glsl>
 #include <AnKi/Shaders/Common.glsl>
 
 
@@ -113,7 +113,7 @@ void main()
 	Vec2 uvOffset = Vec2(0.0);
 	Vec2 uvOffset = Vec2(0.0);
 	uvOffset.X_OR_Y = 1.5 * TEXEL_SIZE.X_OR_Y;
 	uvOffset.X_OR_Y = 1.5 * TEXEL_SIZE.X_OR_Y;
 
 
-	ANKI_UNROLL for(U32 i = 0u; i < (SAMPLE_COUNT - 1u) / 2u; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < (U32(SAMPLE_COUNT) - 1u) / 2u; ++i)
 	{
 	{
 		sampleTex(uv + uvOffset, refDepth, color, weight);
 		sampleTex(uv + uvOffset, refDepth, color, weight);
 		sampleTex(uv - uvOffset, refDepth, color, weight);
 		sampleTex(uv - uvOffset, refDepth, color, weight);

+ 2 - 2
AnKi/Shaders/ExponentialShadowmappingResolve.ankiprog

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEXTURE_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEXTURE_SIZE, 0u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 #include <AnKi/Shaders/GaussianBlurCommon.glsl>
 #include <AnKi/Shaders/GaussianBlurCommon.glsl>
@@ -65,7 +65,7 @@ void main()
 	const F32 w1 = BOX_WEIGHTS[1u];
 	const F32 w1 = BOX_WEIGHTS[1u];
 	const F32 w2 = BOX_WEIGHTS[2u];
 	const F32 w2 = BOX_WEIGHTS[2u];
 	Vec4 moments;
 	Vec4 moments;
-	if(u_uniforms.m_blur != 0)
+	if(u_uniforms.m_blur != 0u)
 	{
 	{
 		moments = computeMoments(uv) * w0;
 		moments = computeMoments(uv) * w0;
 		moments += computeMoments(clamp(uv + Vec2(UV_OFFSET.x, 0.0), minUv, maxUv)) * w1;
 		moments += computeMoments(clamp(uv + Vec2(UV_OFFSET.x, 0.0), minUv, maxUv)) * w1;

+ 3 - 3
AnKi/Shaders/FinalComposite.ankiprog

@@ -7,9 +7,9 @@
 #pragma anki mutator BLOOM_ENABLED 0 1
 #pragma anki mutator BLOOM_ENABLED 0 1
 #pragma anki mutator DBG_ENABLED 0 1
 #pragma anki mutator DBG_ENABLED 0 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_U32(LUT_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 1);
-ANKI_SPECIALIZATION_CONSTANT_U32(MOTION_BLUR_SAMPLES, 3);
+ANKI_SPECIALIZATION_CONSTANT_U32(LUT_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 1u);
+ANKI_SPECIALIZATION_CONSTANT_U32(MOTION_BLUR_SAMPLES, 3u);
 
 
 #pragma anki start vert
 #pragma anki start vert
 #include <AnKi/Shaders/QuadVert.glsl>
 #include <AnKi/Shaders/QuadVert.glsl>

+ 2 - 2
AnKi/Shaders/ForwardShadingCommonFrag.glsl

@@ -43,7 +43,7 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos)
 	Cluster cluster = getClusterFragCoord(gl_FragCoord.xyz);
 	Cluster cluster = getClusterFragCoord(gl_FragCoord.xyz);
 
 
 	// Point lights
 	// Point lights
-	ANKI_LOOP while(cluster.m_pointLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_pointLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
@@ -68,7 +68,7 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos)
 	}
 	}
 
 
 	// Spot lights
 	// Spot lights
-	ANKI_LOOP while(cluster.m_spotLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_spotLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));

+ 7 - 7
AnKi/Shaders/Functions.glsl

@@ -111,23 +111,23 @@ Vec4 nearestDepthUpscale(Vec2 uv, texture2D depthFull, texture2D depthHalf, text
 		const Vec4 a = textureGather(sampler2D(colorTex, linearAnyClampSampler), uv, 3);
 		const Vec4 a = textureGather(sampler2D(colorTex, linearAnyClampSampler), uv, 3);
 
 
 		F32 minDiff = diffs.x;
 		F32 minDiff = diffs.x;
-		U32 comp = 0;
+		U32 comp = 0u;
 
 
 		if(diffs.y < minDiff)
 		if(diffs.y < minDiff)
 		{
 		{
-			comp = 1;
+			comp = 1u;
 			minDiff = diffs.y;
 			minDiff = diffs.y;
 		}
 		}
 
 
 		if(diffs.z < minDiff)
 		if(diffs.z < minDiff)
 		{
 		{
-			comp = 2;
+			comp = 2u;
 			minDiff = diffs.z;
 			minDiff = diffs.z;
 		}
 		}
 
 
 		if(diffs.w < minDiff)
 		if(diffs.w < minDiff)
 		{
 		{
-			comp = 3;
+			comp = 3u;
 		}
 		}
 
 
 		color = Vec4(r[comp], g[comp], b[comp], a[comp]);
 		color = Vec4(r[comp], g[comp], b[comp], a[comp]);
@@ -435,14 +435,14 @@ Mat3 rotationFromDirection(Vec3 zAxis)
 // See getOptimalGlobalInvocationId8x8Amd
 // See getOptimalGlobalInvocationId8x8Amd
 U32 ABfiM(U32 src, U32 ins, U32 bits)
 U32 ABfiM(U32 src, U32 ins, U32 bits)
 {
 {
-	const U32 mask = (1 << bits) - 1;
+	const U32 mask = (1u << bits) - 1u;
 	return (ins & mask) | (src & (~mask));
 	return (ins & mask) | (src & (~mask));
 }
 }
 
 
 // See getOptimalGlobalInvocationId8x8Amd
 // See getOptimalGlobalInvocationId8x8Amd
 U32 ABfe(U32 src, U32 off, U32 bits)
 U32 ABfe(U32 src, U32 off, U32 bits)
 {
 {
-	const U32 mask = (1 << bits) - 1;
+	const U32 mask = (1u << bits) - 1u;
 	return (src >> off) & mask;
 	return (src >> off) & mask;
 }
 }
 
 
@@ -552,4 +552,4 @@ I32 findLSB64(U64 v)
 	const I32 lsb1 = findLSB(U32(v));
 	const I32 lsb1 = findLSB(U32(v));
 	const I32 lsb2 = findLSB(U32(v >> 32ul));
 	const I32 lsb2 = findLSB(U32(v >> 32ul));
 	return (lsb1 >= 0) ? lsb1 : lsb2 + 32;
 	return (lsb1 >= 0) ? lsb1 : lsb2 + 32;
-}
+}

+ 0 - 158
AnKi/Shaders/GBufferCommonFrag.glsl

@@ -1,158 +0,0 @@
-// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Pack.glsl>
-#include <AnKi/Shaders/Common.glsl>
-
-//
-// Input
-//
-#if PASS == PASS_GB
-layout(location = 0) in highp Vec2 in_uv;
-layout(location = 1) in mediump Vec3 in_normal;
-layout(location = 2) in mediump Vec4 in_tangent;
-#	if CALC_BITANGENT_IN_VERT
-layout(location = 3) in mediump Vec3 in_bitangent;
-#	endif
-layout(location = 4) in mediump F32 in_distFromTheCamera; // Parallax
-layout(location = 5) in mediump Vec3 in_eyeTangentSpace; // Parallax
-layout(location = 6) in mediump Vec3 in_normalTangentSpace; // Parallax
-
-#	if VELOCITY
-layout(location = 7) in mediump Vec2 in_velocity; // Velocity
-#	endif
-#endif // PASS == PASS_GB
-
-//
-// Output
-//
-#if PASS == PASS_GB || PASS == PASS_EZ
-layout(location = 0) out Vec4 out_gbuffer0;
-layout(location = 1) out Vec4 out_gbuffer1;
-layout(location = 2) out Vec4 out_gbuffer2;
-layout(location = 3) out Vec2 out_gbuffer3;
-#endif
-
-//
-// Functions
-//
-#if PASS == PASS_GB
-// Do normal mapping
-Vec3 readNormalFromTexture(texture2D map, sampler sampl, highp Vec2 texCoords)
-{
-	// First read the texture
-	const Vec3 nAtTangentspace = normalize((texture(map, sampl, texCoords).rgb - 0.5) * 2.0);
-
-	const Vec3 n = normalize(in_normal);
-	const Vec3 t = normalize(in_tangent.xyz);
-#	if CALC_BITANGENT_IN_VERT
-	const Vec3 b = normalize(in_bitangent.xyz);
-#	else
-	const Vec3 b = cross(n, t) * in_tangent.w;
-#	endif
-
-	const Mat3 tbnMat = Mat3(t, b, n);
-
-	return tbnMat * nAtTangentspace;
-}
-
-// Using a 4-channel texture and a tolerance discard the fragment if the texture's alpha is less than the tolerance
-Vec3 readTextureRgbAlphaTesting(texture2D map, sampler sampl, highp Vec2 texCoords, F32 tolerance)
-{
-	const Vec4 col = Vec4(texture(map, sampl, texCoords));
-	if(col.a < tolerance)
-	{
-		discard;
-	}
-
-	return col.rgb;
-}
-
-Vec2 computeTextureCoordParallax(texture2D heightMap, sampler sampl, Vec2 uv, F32 heightMapScale)
-{
-	const U32 MAX_SAMPLES = 25;
-	const U32 MIN_SAMPLES = 1;
-	const F32 MAX_EFFECTIVE_DISTANCE = 32.0;
-
-	// Get that because we are sampling inside a loop
-	const Vec2 dPdx = dFdx(uv);
-	const Vec2 dPdy = dFdy(uv);
-
-	const Vec3 eyeTangentSpace = in_eyeTangentSpace;
-	const Vec3 normTangentSpace = in_normalTangentSpace;
-
-	F32 parallaxLimit = -length(eyeTangentSpace.xy) / eyeTangentSpace.z;
-	parallaxLimit *= heightMapScale;
-
-	const Vec2 offsetDir = normalize(eyeTangentSpace.xy);
-	const Vec2 maxOffset = offsetDir * parallaxLimit;
-
-	const Vec3 E = normalize(eyeTangentSpace);
-
-	const F32 factor0 = -dot(E, normTangentSpace);
-	const F32 factor1 = in_distFromTheCamera / -MAX_EFFECTIVE_DISTANCE;
-	const F32 factor = saturate((1.0 - factor0) * (1.0 - factor1));
-	const F32 sampleCountf = mix(F32(MIN_SAMPLES), F32(MAX_SAMPLES), factor);
-
-	const F32 stepSize = 1.0 / sampleCountf;
-
-	F32 crntRayHeight = 1.0;
-	Vec2 crntOffset = Vec2(0.0);
-	Vec2 lastOffset = Vec2(0.0);
-
-	F32 lastSampledHeight = 1.0;
-	F32 crntSampledHeight = 1.0;
-
-	U32 crntSample = 0;
-
-	const U32 sampleCount = U32(sampleCountf);
-	ANKI_LOOP while(crntSample < sampleCount)
-	{
-		crntSampledHeight = textureGrad(heightMap, sampl, uv + crntOffset, dPdx, dPdy).r;
-
-		if(crntSampledHeight > crntRayHeight)
-		{
-			const F32 delta1 = crntSampledHeight - crntRayHeight;
-			const F32 delta2 = (crntRayHeight + stepSize) - lastSampledHeight;
-			const F32 ratio = delta1 / (delta1 + delta2);
-
-			crntOffset = mix(crntOffset, lastOffset, ratio);
-
-			crntSample = sampleCount + 1;
-		}
-		else
-		{
-			crntSample++;
-
-			crntRayHeight -= stepSize;
-
-			lastOffset = crntOffset;
-			crntOffset += stepSize * maxOffset;
-
-			lastSampledHeight = crntSampledHeight;
-		}
-	}
-
-	return uv + crntOffset;
-}
-
-// Write the data to FAIs
-void writeRts(Vec3 diffColor, Vec3 normal, Vec3 specularColor, F32 roughness, F32 subsurface, Vec3 emission,
-			  F32 metallic, Vec2 velocity)
-{
-	GbufferInfo g;
-	g.m_diffuse = diffColor;
-	g.m_normal = normal;
-	g.m_specular = specularColor;
-	g.m_roughness = roughness;
-	g.m_subsurface = subsurface;
-	g.m_emission = (emission.r + emission.g + emission.b) / 3.0;
-	g.m_metallic = metallic;
-	g.m_velocity = velocity;
-	writeGBuffer(g, out_gbuffer0, out_gbuffer1, out_gbuffer2, out_gbuffer3);
-}
-#endif // PASS == PASS_GB

+ 0 - 317
AnKi/Shaders/GBufferCommonTessc.glsl

@@ -1,317 +0,0 @@
-// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Shaders/MsBsCommon.glsl>
-
-layout(vertices = 3) out;
-
-// Defines
-#define IID gl_InvocationID
-#define IN_POS4(i_) gl_in[i_].gl_Position
-#define IN_POS3(i_) gl_in[i_].gl_Position.xyz
-#define OUT_POS4(i_) gl_out[i_].gl_Position
-
-//
-// In
-//
-in gl_PerVertex
-{
-	Vec4 gl_Position;
-}
-gl_in[];
-
-layout(location = 0) in Vec2 inTexCoords[];
-layout(location = 1) in mediump Vec3 inNormal[];
-#if PASS == COLOR
-layout(location = 2) in mediump Vec4 inTangent[];
-#endif
-#if INSTANCE_ID_FRAGMENT_SHADER
-layout(location = 3) flat in U32 inInstanceId[];
-#endif
-
-//
-// Out
-//
-
-out gl_PerVertex
-{
-	Vec4 gl_Position;
-}
-gl_out[];
-
-layout(location = 0) out Vec2 outTexCoord[];
-layout(location = 1) out Vec3 outNormal[];
-#if PASS == COLOR
-layout(location = 2) out Vec4 outTangent[];
-#endif
-
-#if INSTANCE_ID_FRAGMENT_SHADER
-struct CommonPatch
-{
-	U32 instanceId;
-};
-#endif
-
-struct PNPatch
-{
-	Vec3 pos021;
-	Vec3 pos012;
-	Vec3 pos102;
-	Vec3 pos201;
-	Vec3 pos210;
-	Vec3 pos120;
-	Vec3 pos111;
-};
-
-struct PhongPatch
-{
-	Vec3 terms[3];
-};
-
-out patch PNPatch pnPatch;
-out patch PhongPatch phongPatch;
-#if INSTANCE_ID_FRAGMENT_SHADER
-out patch CommonPatch commonPatch;
-#endif
-
-// Project point to plane
-Vec3 projectToPlane(Vec3 point, Vec3 planePoint, Vec3 planeNormal)
-{
-	Vec3 v = point - planePoint;
-	F32 pen = dot(v, planeNormal);
-	Vec3 d = pen * planeNormal;
-	return (point - d);
-}
-
-// Calculate control points
-void calcPositions()
-{
-	// The original vertices stay the same
-	Vec3 pos030 = IN_POS3(0);
-	Vec3 pos003 = IN_POS3(1);
-	Vec3 pos300 = IN_POS3(2);
-
-	OUT_POS4(0) = IN_POS4(0);
-	OUT_POS4(1) = IN_POS4(1);
-	OUT_POS4(2) = IN_POS4(2);
-
-	// edges are names according to the opposing vertex
-	Vec3 edgeB300 = pos003 - pos030;
-	Vec3 edgeB030 = pos300 - pos003;
-	Vec3 edgeB003 = pos030 - pos300;
-
-	// Generate two midpoints on each edge
-	pnPatch.pos021 = pos030 + edgeB300 / 3.0;
-	pnPatch.pos012 = pos030 + edgeB300 * 2.0 / 3.0;
-	pnPatch.pos102 = pos003 + edgeB030 / 3.0;
-	pnPatch.pos201 = pos003 + edgeB030 * 2.0 / 3.0;
-	pnPatch.pos210 = pos300 + edgeB003 / 3.0;
-	pnPatch.pos120 = pos300 + edgeB003 * 2.0 / 3.0;
-
-	pnPatch.pos021 = projectToPlane(pnPatch.pos021, pos030, outNormal[0]);
-	pnPatch.pos012 = projectToPlane(pnPatch.pos012, pos003, outNormal[1]);
-	pnPatch.pos102 = projectToPlane(pnPatch.pos102, pos003, outNormal[1]);
-	pnPatch.pos201 = projectToPlane(pnPatch.pos201, pos300, outNormal[2]);
-	pnPatch.pos210 = projectToPlane(pnPatch.pos210, pos300, outNormal[2]);
-	pnPatch.pos120 = projectToPlane(pnPatch.pos120, pos030, outNormal[0]);
-
-	// Handle the center
-	Vec3 center = (pos003 + pos030 + pos300) / 3.0;
-	pnPatch.pos111 =
-		(pnPatch.pos021 + pnPatch.pos012 + pnPatch.pos102 + pnPatch.pos201 + pnPatch.pos210 + pnPatch.pos120) / 6.0;
-	pnPatch.pos111 += (pnPatch.pos111 - center) / 2.0;
-}
-
-Vec3 calcFaceNormal(in Vec3 v0, in Vec3 v1, in Vec3 v2)
-{
-	return normalize(cross(v1 - v0, v2 - v0));
-}
-
-F32 calcEdgeTessLevel(in Vec3 n0, in Vec3 n1, in F32 maxTessLevel)
-{
-	Vec3 norm = normalize(n0 + n1);
-	F32 tess = (1.0 - norm.z) * (maxTessLevel - 1.0) + 1.0;
-	return tess;
-}
-
-/*F32 calcEdgeTessLevel(in Vec2 p0, in Vec2 p1, in F32 maxTessLevel)
-{
-	F32 dist = distance(p0, p1) * 10.0;
-	return dist * (maxTessLevel - 1.0) + 1.0;
-}*/
-
-// Given the face positions in NDC caclulate if the face is front facing or not
-Bool isFaceFrontFacing(in Vec2 posNdc[3])
-{
-	Vec2 a = posNdc[1] - posNdc[0];
-	Vec2 b = posNdc[2] - posNdc[1];
-	Vec2 c = a.xy * b.yx;
-	return (c.x - c.y) > 0.0;
-}
-
-// Check if a single NDC position is outside the clip space
-Bool posOutsideClipSpace(in Vec2 posNdc)
-{
-	bvec2 compa = lessThan(posNdc, Vec2(-1.0));
-	bvec2 compb = greaterThan(posNdc, Vec2(1.0));
-	return all(bvec4(compa, compb));
-}
-
-// Check if a face in NDC is outside the clip space
-Bool isFaceOutsideClipSpace(in Vec2 posNdc[3])
-{
-	return any(bvec3(posOutsideClipSpace(posNdc[0]), posOutsideClipSpace(posNdc[1]), posOutsideClipSpace(posNdc[2])));
-}
-
-// Check if a face is visible
-Bool isFaceVisible(in Mat4 mvp)
-{
-	// Calculate clip positions
-	Vec2 clip[3];
-	for(I32 i = 0; i < 3; i++)
-	{
-		Vec4 v = mvp * IN_POS4(i);
-		clip[i] = v.xy / (v.w * 0.5 + 0.5);
-	}
-
-	// Check the face orientation and clipping
-	return isFaceFrontFacing(clip) && !isFaceOutsideClipSpace(clip);
-}
-
-void setSilhouetteTessLevels(in Mat3 normalMat, in F32 maxTessLevel)
-{
-	// Calculate the normals in view space
-	Vec3 nv[3];
-	for(I32 i = 0; i < 3; i++)
-	{
-		nv[i] = normalMat * inNormal[i];
-	}
-
-	gl_TessLevelOuter[0] = calcEdgeTessLevel(nv[1], nv[2], maxTessLevel);
-	gl_TessLevelOuter[1] = calcEdgeTessLevel(nv[2], nv[0], maxTessLevel);
-	gl_TessLevelOuter[2] = calcEdgeTessLevel(nv[0], nv[1], maxTessLevel);
-	gl_TessLevelInner[0] = (gl_TessLevelOuter[0] + gl_TessLevelOuter[1] + gl_TessLevelOuter[2]) / 3.0;
-}
-
-void setConstantTessLevels(in F32 maxTessLevel)
-{
-	gl_TessLevelOuter[0] = maxTessLevel;
-	gl_TessLevelOuter[1] = maxTessLevel;
-	gl_TessLevelOuter[2] = maxTessLevel;
-	gl_TessLevelInner[0] = maxTessLevel;
-}
-
-void discardPatch()
-{
-	gl_TessLevelOuter[0] = 0.0;
-	gl_TessLevelOuter[1] = 0.0;
-	gl_TessLevelOuter[2] = 0.0;
-	gl_TessLevelInner[0] = 0.0;
-}
-
-// Used in phong method
-F32 calcPhongTerm(I32 ivId, I32 i, Vec3 q)
-{
-	Vec3 qMinusP = q - IN_POS3(i);
-	return q[ivId] - dot(qMinusP, inNormal[i]) * inNormal[i][ivId];
-}
-
-// This function is part of the point-normal tessellation method
-#define tessellatePNPositionNormalTangentTexCoord_DEFINED
-void tessellatePNPositionNormalTangentTexCoord(in F32 maxTessLevel, in Mat4 mvp, in Mat3 normalMat)
-{
-	F32 tessLevel = 0.0;
-
-	// Calculate the face normal in view space
-	Vec3 faceNorm = calcFaceNormal(IN_POS3(0), IN_POS3(1), IN_POS3(2));
-	faceNorm = (normalMat * faceNorm);
-
-	if(faceNorm.z >= 0.0)
-	{
-		// The face is front facing
-
-		for(I32 i = 0; i < 3; i++)
-		{
-			outTexCoord[i] = inTexCoords[i];
-			outNormal[i] = inNormal[i];
-#if PASS == COLOR
-			outTangent[i] = inTangent[i];
-#endif
-		}
-
-		calcPositions();
-
-		// Calculate the tessLevel. It's 1.0 when the normal is facing the cam
-		// and maxTessLevel when it's facing away. This gives high tessellation
-		// on silhouettes
-		tessLevel = (1.0 - faceNorm.z) * (maxTessLevel - 1.0) + 1.0;
-	}
-
-	gl_TessLevelOuter[0] = tessLevel;
-	gl_TessLevelOuter[1] = tessLevel;
-	gl_TessLevelOuter[2] = tessLevel;
-	gl_TessLevelInner[0] = tessLevel;
-}
-
-#define tessellatePhongPositionNormalTangentTexCoord_DEFINED
-void tessellatePhongPositionNormalTangentTexCoord(in F32 maxTessLevel, in Mat4 mvp, in Mat3 normalMat)
-{
-	if(IID == 0)
-	{
-		if(isFaceVisible(mvp))
-		{
-			setSilhouetteTessLevels(normalMat, maxTessLevel);
-		}
-		else
-		{
-			discardPatch();
-		}
-	}
-
-	OUT_POS4(IID) = IN_POS4(IID); // Do that here to trick the barrier
-
-	barrier();
-
-	if(gl_TessLevelOuter[0] > 0.0)
-	{
-		outTexCoord[IID] = inTexCoords[IID];
-		outNormal[IID] = inNormal[IID];
-#if PASS == COLOR
-		outTangent[IID] = inTangent[IID];
-#endif
-
-		phongPatch.terms[IID][0] = calcPhongTerm(IID, 0, IN_POS3(1)) + calcPhongTerm(IID, 1, IN_POS3(0));
-		phongPatch.terms[IID][1] = calcPhongTerm(IID, 1, IN_POS3(2)) + calcPhongTerm(IID, 2, IN_POS3(1));
-		phongPatch.terms[IID][2] = calcPhongTerm(IID, 2, IN_POS3(0)) + calcPhongTerm(IID, 0, IN_POS3(2));
-	}
-}
-
-#define tessellateDispMapPositionNormalTangentTexCoord_DEFINED
-void tessellateDispMapPositionNormalTangentTexCoord(in F32 maxTessLevel, in Mat4 mvp, in Mat3 normalMat)
-{
-	if(IID == 0)
-	{
-		if(isFaceVisible(mvp))
-		{
-			setConstantTessLevels(maxTessLevel);
-
-#if INSTANCE_ID_FRAGMENT_SHADER
-			commonPatch.instanceId = inInstanceId[0];
-#endif
-		}
-		else
-		{
-			discardPatch();
-		}
-	}
-
-	// Passthrough
-	OUT_POS4(IID) = IN_POS4(IID);
-	outTexCoord[IID] = inTexCoords[IID];
-	outNormal[IID] = inNormal[IID];
-#if PASS == COLOR
-	outTangent[IID] = inTangent[IID];
-#endif
-}

+ 0 - 157
AnKi/Shaders/GBufferCommonTesse.glsl

@@ -1,157 +0,0 @@
-// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-layout(triangles, equal_spacing, ccw) in;
-
-#define IN_POS4(i_) gl_in[i_].gl_Position
-#define IN_POS3(i_) gl_in[i_].gl_Position.xyz
-
-//
-// Input
-//
-
-struct PNPatch
-{
-	Vec3 pos021;
-	Vec3 pos012;
-	Vec3 pos102;
-	Vec3 pos201;
-	Vec3 pos210;
-	Vec3 pos120;
-	Vec3 pos111;
-};
-
-struct PhongPatch
-{
-	Vec3 terms[3];
-};
-
-#if INSTANCE_ID_FRAGMENT_SHADER
-struct CommonPatch
-{
-	U32 instanceId;
-};
-#endif
-
-in gl_PerVertex
-{
-	Vec4 gl_Position;
-}
-gl_in[];
-
-in patch PNPatch pnPatch;
-in patch PhongPatch phongPatch;
-#if INSTANCE_ID_FRAGMENT_SHADER
-in patch CommonPatch commonPatch;
-#endif
-
-layout(location = 0) in Vec2 inTexCoord[];
-layout(location = 1) in Vec3 inNormal[];
-#if PASS == COLOR
-layout(location = 2) in Vec4 inTangent[];
-#endif
-
-//
-// Output
-//
-
-out gl_PerVertex
-{
-	Vec4 gl_Position;
-};
-
-layout(location = 0) out highp Vec2 outTexCoord;
-#if PASS == COLOR
-layout(location = 1) out mediump Vec3 outNormal;
-layout(location = 2) out mediump Vec4 outTangent;
-#endif
-
-#define INTERPOLATE(x_) (x_[0] * gl_TessCoord.x + x_[1] * gl_TessCoord.y + x_[2] * gl_TessCoord.z)
-
-// Smooth tessellation
-#define tessellatePNPositionNormalTangentTexCoord_DEFINED
-void tessellatePNPositionNormalTangentTexCoord(in Mat4 mvp, in Mat3 normalMat)
-{
-#if PASS == COLOR
-	outNormal = normalize(normalMat * INTERPOLATE(inNormal));
-	outTangent = INTERPOLATE(inTangent);
-	outTangent.xyz = normalize(normalMat * outTangent.xyz);
-#endif
-
-	outTexCoord = INTERPOLATE(inTexCoord);
-
-	F32 u = gl_TessCoord.x;
-	F32 v = gl_TessCoord.y;
-	F32 w = gl_TessCoord.z;
-
-	F32 uPow3 = pow(u, 3);
-	F32 vPow3 = pow(v, 3);
-	F32 wPow3 = pow(w, 3);
-	F32 uPow2 = pow(u, 2);
-	F32 vPow2 = pow(v, 2);
-	F32 wPow2 = pow(w, 2);
-
-	Vec3 pos030 = IN_POS3(0);
-	Vec3 pos003 = IN_POS3(1);
-	Vec3 pos300 = IN_POS3(2);
-
-	Vec3 pos = pos300 * wPow3 + pos030 * uPow3 + pos003 * vPow3 + pnPatch.pos210 * 3.0 * wPow2 * u
-			   + pnPatch.pos120 * 3.0 * w * uPow2 + pnPatch.pos201 * 3.0 * wPow2 * v + pnPatch.pos021 * 3.0 * uPow2 * v
-			   + pnPatch.pos102 * 3.0 * w * vPow2 + pnPatch.pos012 * 3.0 * u * vPow2 + pnPatch.pos111 * 6.0 * w * u * v;
-
-	gl_Position = mvp * Vec4(pos, 1.0);
-}
-
-#define tessellatePhongPositionNormalTangentTexCoord_DEFINED
-void tessellatePhongPositionNormalTangentTexCoord(in Mat4 mvp, in Mat3 normalMat)
-{
-#if PASS == COLOR
-	outNormal = normalize(normalMat * INTERPOLATE(inNormal));
-	outTangent = INTERPOLATE(inTangent);
-	outTangent.xyz = normalize(normalMat * outTangent.xyz);
-#endif
-
-	outTexCoord = INTERPOLATE(inTexCoord);
-
-	// interpolated position
-	Vec3 inpos[3] = Vec3[](IN_POS3(0), IN_POS3(1), IN_POS3(2));
-	Vec3 barPos = INTERPOLATE(inpos);
-
-	// build terms
-	Vec3 termIJ = Vec3(phongPatch.terms[0][0], phongPatch.terms[1][0], phongPatch.terms[2][0]);
-	Vec3 termJK = Vec3(phongPatch.terms[0][1], phongPatch.terms[1][1], phongPatch.terms[2][1]);
-	Vec3 termIK = Vec3(phongPatch.terms[0][2], phongPatch.terms[1][2], phongPatch.terms[2][2]);
-
-	Vec3 tc2 = gl_TessCoord * gl_TessCoord;
-
-	// phong tesselated pos
-	Vec3 phongPos = tc2[0] * inpos[0] + tc2[1] * inpos[1] + tc2[2] * inpos[2]
-					+ gl_TessCoord[0] * gl_TessCoord[1] * termIJ + gl_TessCoord[1] * gl_TessCoord[2] * termJK
-					+ gl_TessCoord[2] * gl_TessCoord[0] * termIK;
-
-	F32 tessAlpha = 1.0;
-	Vec3 finalPos = (1.0 - tessAlpha) * barPos + tessAlpha * phongPos;
-	gl_Position = mvp * Vec4(finalPos, 1.0);
-}
-
-#define tessellateDispMapPositionNormalTangentTexCoord_DEFINED
-void tessellateDispMapPositionNormalTangentTexCoord(in Mat4 mvp, in Mat3 normalMat, in sampler2D dispMap)
-{
-	Vec3 norm = INTERPOLATE(inNormal);
-#if PASS == COLOR
-	outNormal = normalize(normalMat * norm);
-	outTangent = INTERPOLATE(inTangent);
-	outTangent.xyz = normalize(normalMat * outTangent.xyz);
-#endif
-
-	outTexCoord = INTERPOLATE(inTexCoord);
-
-	F32 height = texture(dispMap, outTexCoord).r;
-	height = height * 0.7 - 0.35;
-
-	Vec3 inpos[3] = Vec3[](IN_POS3(0), IN_POS3(1), IN_POS3(2));
-	Vec3 pos = INTERPOLATE(inpos) + norm * height;
-	gl_Position = mvp * Vec4(pos, 1.0);
-}

+ 0 - 150
AnKi/Shaders/GBufferCommonVert.glsl

@@ -1,150 +0,0 @@
-// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Common.glsl>
-
-//
-// Uniforms
-//
-#if BONES
-layout(set = 0, binding = BINDING_COUNT, row_major) readonly buffer ss00_
-{
-	Mat4 u_boneTransforms[];
-};
-#endif
-
-//
-// Input
-//
-layout(location = POSITION_LOCATION) in highp Vec3 in_position;
-#if PASS == PASS_GB
-layout(location = TEXTURE_COORDINATE_LOCATION) in highp Vec2 in_uv;
-layout(location = NORMAL_LOCATION) in mediump Vec3 in_normal;
-layout(location = TANGENT_LOCATION) in mediump Vec4 in_tangent;
-#endif
-
-#if BONES
-layout(location = BONE_WEIGHTS_LOCATION) in mediump Vec4 in_boneWeights;
-layout(location = BONE_INDICES_LOCATION) in UVec4 in_boneIndices;
-#endif
-
-//
-// Output
-//
-out gl_PerVertex
-{
-	Vec4 gl_Position;
-};
-
-#if PASS == PASS_GB
-layout(location = 0) out highp Vec2 out_uv;
-layout(location = 1) out mediump Vec3 out_normal;
-layout(location = 2) out mediump Vec4 out_tangent;
-#	if CALC_BITANGENT_IN_VERT
-layout(location = 3) out mediump Vec3 out_bitangent;
-#	endif
-layout(location = 4) out mediump F32 out_distFromTheCamera; // Parallax
-layout(location = 5) out mediump Vec3 out_eyeTangentSpace; // Parallax
-layout(location = 6) out mediump Vec3 out_normalTangentSpace; // Parallax
-
-#	if VELOCITY
-layout(location = 7) out mediump Vec2 out_velocity; // Velocity
-#	endif
-#endif
-
-//
-// Globals
-//
-Vec3 g_position = in_position;
-#if PASS == PASS_GB
-highp Vec2 g_uv = in_uv;
-mediump Vec3 g_normal = in_normal;
-mediump Vec4 g_tangent = in_tangent;
-#endif
-
-//
-// Functions
-//
-
-// Common store function
-#if PASS == PASS_GB
-void positionUvNormalTangent(Mat4 mvp, Mat3 rotationMat)
-{
-	out_uv = g_uv;
-	gl_Position = mvp * Vec4(g_position, 1.0);
-
-	out_normal = rotationMat * g_normal.xyz;
-	out_tangent.xyz = rotationMat * g_tangent.xyz;
-	out_tangent.w = g_tangent.w;
-
-#	if CALC_BITANGENT_IN_VERT
-	out_bitangent = cross(out_normal, out_tangent.xyz) * out_tangent.w;
-#	endif
-}
-#endif // PASS == PASS_GB
-
-// Store stuff for parallax mapping
-#if PASS == PASS_GB
-void parallax(Mat4 modelViewMat)
-{
-	const Vec3 n = in_normal;
-	const Vec3 t = in_tangent.xyz;
-	const Vec3 b = cross(n, t) * in_tangent.w;
-
-	const Mat3 normalMat = Mat3(modelViewMat);
-	const Mat3 invTbn = transpose(normalMat * Mat3(t, b, n));
-
-	const Vec3 viewPos = (modelViewMat * Vec4(g_position, 1.0)).xyz;
-	out_distFromTheCamera = viewPos.z;
-
-	out_eyeTangentSpace = invTbn * viewPos;
-	out_normalTangentSpace = invTbn * n;
-}
-#endif // PASS == PASS_GB
-
-/// Will compute new position, normal and tangent
-#if BONES
-void skinning()
-{
-	Vec3 position = Vec3(0.0);
-	Vec3 normal = Vec3(0.0);
-	Vec3 tangent = Vec3(0.0);
-	for(U32 i = 0; i < 4; ++i)
-	{
-		const U32 boneIdx = in_boneIndices[i];
-		if(boneIdx < 0xFFFF)
-		{
-			const F32 boneWeight = in_boneWeights[i];
-
-			position += (u_boneTransforms[boneIdx] * Vec4(g_position * boneWeight, 1.0)).xyz;
-#	if PASS == PASS_GB
-			normal += (u_boneTransforms[boneIdx] * Vec4(g_normal * boneWeight, 0.0)).xyz;
-			tangent += (u_boneTransforms[boneIdx] * Vec4(g_tangent.xyz * boneWeight, 0.0)).xyz;
-#	endif
-		}
-	}
-
-	g_position = position;
-#	if PASS == PASS_GB
-	g_tangent.xyz = tangent;
-	g_normal = normal;
-#	endif
-}
-#endif
-
-#if VELOCITY && PASS == PASS_GB
-void velocity(Mat4 prevMvp)
-{
-	const Vec4 v4 = prevMvp * Vec4(g_position, 1.0);
-	const Vec2 prevNdc = v4.xy / v4.w;
-
-	const Vec2 crntNdc = gl_Position.xy / gl_Position.w;
-
-	// It's NDC_TO_UV(prevNdc) - NDC_TO_UV(crntNdc) or:
-	out_velocity = (prevNdc - crntNdc) * 0.5;
-}
-#endif

+ 5 - 5
AnKi/Shaders/GBufferGeneric.ankiprog

@@ -158,7 +158,7 @@ void skinning()
 {
 {
 	Mat4 skinMat = u_ankiBoneTransforms[in_boneIndices[0]] * in_boneWeights[0];
 	Mat4 skinMat = u_ankiBoneTransforms[in_boneIndices[0]] * in_boneWeights[0];
 	Mat4 prevSkinMat = u_ankiPrevFrameBoneTransforms[in_boneIndices[0]] * in_boneWeights[0];
 	Mat4 prevSkinMat = u_ankiPrevFrameBoneTransforms[in_boneIndices[0]] * in_boneWeights[0];
-	ANKI_UNROLL for(U32 i = 1; i < 4; ++i)
+	ANKI_UNROLL for(U32 i = 1u; i < 4u; ++i)
 	{
 	{
 		skinMat += u_ankiBoneTransforms[in_boneIndices[i]] * in_boneWeights[i];
 		skinMat += u_ankiBoneTransforms[in_boneIndices[i]] * in_boneWeights[i];
 		prevSkinMat += u_ankiPrevFrameBoneTransforms[in_boneIndices[i]] * in_boneWeights[i];
 		prevSkinMat += u_ankiPrevFrameBoneTransforms[in_boneIndices[i]] * in_boneWeights[i];
@@ -258,8 +258,8 @@ void main()
 #if REALLY_USING_PARALLAX
 #if REALLY_USING_PARALLAX
 Vec2 computeTextureCoordParallax(texture2D heightMap, sampler sampl, Vec2 uv, F32 heightMapScale)
 Vec2 computeTextureCoordParallax(texture2D heightMap, sampler sampl, Vec2 uv, F32 heightMapScale)
 {
 {
-	const U32 MAX_SAMPLES = 25;
-	const U32 MIN_SAMPLES = 1;
+	const U32 MAX_SAMPLES = 25u;
+	const U32 MIN_SAMPLES = 1u;
 	const F32 MAX_EFFECTIVE_DISTANCE = 32.0;
 	const F32 MAX_EFFECTIVE_DISTANCE = 32.0;
 
 
 	// Get that because we are sampling inside a loop
 	// Get that because we are sampling inside a loop
@@ -291,7 +291,7 @@ Vec2 computeTextureCoordParallax(texture2D heightMap, sampler sampl, Vec2 uv, F3
 	F32 lastSampledHeight = 1.0;
 	F32 lastSampledHeight = 1.0;
 	F32 crntSampledHeight = 1.0;
 	F32 crntSampledHeight = 1.0;
 
 
-	U32 crntSample = 0;
+	U32 crntSample = 0u;
 
 
 	const U32 sampleCount = U32(sampleCountf);
 	const U32 sampleCount = U32(sampleCountf);
 	ANKI_LOOP while(crntSample < sampleCount)
 	ANKI_LOOP while(crntSample < sampleCount)
@@ -306,7 +306,7 @@ Vec2 computeTextureCoordParallax(texture2D heightMap, sampler sampl, Vec2 uv, F3
 
 
 			crntOffset = mix(crntOffset, lastOffset, ratio);
 			crntOffset = mix(crntOffset, lastOffset, ratio);
 
 
-			crntSample = sampleCount + 1;
+			crntSample = sampleCount + 1u;
 		}
 		}
 		else
 		else
 		{
 		{

+ 3 - 3
AnKi/Shaders/GBufferPost.ankiprog

@@ -3,9 +3,9 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNTS, 0);
-ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 2);
-ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 3);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNTS, 0u);
+ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 2u);
+ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 3u);
 
 
 #pragma anki start vert
 #pragma anki start vert
 #include <AnKi/Shaders/QuadVert.glsl>
 #include <AnKi/Shaders/QuadVert.glsl>

+ 1 - 1
AnKi/Shaders/GaussianBlur.glsl

@@ -9,7 +9,7 @@
 #pragma anki mutator KERNEL_SIZE 3 5 7 9 11
 #pragma anki mutator KERNEL_SIZE 3 5 7 9 11
 #pragma anki mutator COLOR_COMPONENTS 4 3 1
 #pragma anki mutator COLOR_COMPONENTS 4 3 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(TEXTURE_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(TEXTURE_SIZE, 0u);
 
 
 #include <AnKi/Shaders/GaussianBlurCommon.glsl>
 #include <AnKi/Shaders/GaussianBlurCommon.glsl>
 
 

+ 2 - 2
AnKi/Shaders/ImportanceSampling.glsl

@@ -43,8 +43,8 @@ UVec3 rand3DPCG16(UVec3 v)
 // It will return a uniform 2D point inside [0.0, 1.0]. For random use rand3DPCG16()
 // It will return a uniform 2D point inside [0.0, 1.0]. For random use rand3DPCG16()
 Vec2 hammersleyRandom16(U32 sampleIdx, U32 sampleCount, UVec2 random)
 Vec2 hammersleyRandom16(U32 sampleIdx, U32 sampleCount, UVec2 random)
 {
 {
-	const F32 e1 = fract(F32(sampleIdx) / sampleCount + F32(random.x) * (1.0 / 65536.0));
-	const F32 e2 = F32((bitfieldReverse(sampleIdx) >> 16) ^ random.y) * (1.0 / 65536.0);
+	const F32 e1 = fract(F32(sampleIdx) / F32(sampleCount) + F32(random.x) * (1.0 / 65536.0));
+	const F32 e2 = F32((bitfieldReverse(sampleIdx) >> 16u) ^ random.y) * (1.0 / 65536.0);
 	return Vec2(e1, e2);
 	return Vec2(e1, e2);
 }
 }
 
 

+ 2 - 2
AnKi/Shaders/Include/Common.h

@@ -63,7 +63,7 @@ ANKI_END_NAMESPACE
 ANKI_BEGIN_NAMESPACE
 ANKI_BEGIN_NAMESPACE
 
 
 /// The renderer will group drawcalls into instances up to this number.
 /// The renderer will group drawcalls into instances up to this number.
-const U32 MAX_INSTANCE_COUNT = 64;
-const U32 MAX_LOD_COUNT = 3;
+const U32 MAX_INSTANCE_COUNT = 64u;
+const U32 MAX_LOD_COUNT = 3u;
 
 
 ANKI_END_NAMESPACE
 ANKI_END_NAMESPACE

+ 19 - 19
AnKi/Shaders/Include/ModelTypes.h

@@ -9,8 +9,8 @@
 
 
 ANKI_BEGIN_NAMESPACE
 ANKI_BEGIN_NAMESPACE
 
 
-const U32 UV_CHANNEL_0 = 0;
-const U32 UV_CHANNEL_COUNT = 1;
+const U32 UV_CHANNEL_0 = 0u;
+const U32 UV_CHANNEL_COUNT = 1u;
 
 
 /// The main vertex that contains normals, tangents and UVs
 /// The main vertex that contains normals, tangents and UVs
 struct MainVertex
 struct MainVertex
@@ -20,8 +20,8 @@ struct MainVertex
 	Vec2 m_uvs[UV_CHANNEL_COUNT];
 	Vec2 m_uvs[UV_CHANNEL_COUNT];
 };
 };
 
 
-const U32 _ANKI_SIZEOF_MainVertex = 4 * 4;
-const U32 _ANKI_ALIGNOF_MainVertex = 4;
+const U32 _ANKI_SIZEOF_MainVertex = 4u * 4u;
+const U32 _ANKI_ALIGNOF_MainVertex = 4u;
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MainVertex == sizeof(MainVertex));
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MainVertex == sizeof(MainVertex));
 
 
 /// The vertex that contains the bone influences.
 /// The vertex that contains the bone influences.
@@ -31,8 +31,8 @@ struct BoneInfoVertex
 	U8Vec4 m_boneWeights;
 	U8Vec4 m_boneWeights;
 };
 };
 
 
-const U32 _ANKI_SIZEOF_BoneInfoVertex = 8;
-const U32 _ANKI_ALIGNOF_BoneInfoVertex = 1;
+const U32 _ANKI_SIZEOF_BoneInfoVertex = 8u;
+const U32 _ANKI_ALIGNOF_BoneInfoVertex = 1u;
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_BoneInfoVertex == sizeof(BoneInfoVertex));
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_BoneInfoVertex == sizeof(BoneInfoVertex));
 
 
 /// A structure that contains all the info of a geometry.
 /// A structure that contains all the info of a geometry.
@@ -48,20 +48,20 @@ struct MeshGpuDescriptor
 	Vec3 m_aabbMax;
 	Vec3 m_aabbMax;
 };
 };
 
 
-const U32 _ANKI_SIZEOF_MeshGpuDescriptor = 4 * ANKI_SIZEOF(U64) + 8 * ANKI_SIZEOF(F32);
-const U32 _ANKI_ALIGNOF_MeshGpuDescriptor = 8;
+const U32 _ANKI_SIZEOF_MeshGpuDescriptor = 4u * ANKI_SIZEOF(U64) + 8u * ANKI_SIZEOF(F32);
+const U32 _ANKI_ALIGNOF_MeshGpuDescriptor = 8u;
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MeshGpuDescriptor == sizeof(MeshGpuDescriptor));
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MeshGpuDescriptor == sizeof(MeshGpuDescriptor));
 
 
-const U32 TEXTURE_CHANNEL_DIFFUSE = 0;
-const U32 TEXTURE_CHANNEL_NORMAL = 1;
-const U32 TEXTURE_CHANNEL_ROUGHNESS_METALNESS = 2;
-const U32 TEXTURE_CHANNEL_EMISSION = 3;
-const U32 TEXTURE_CHANNEL_HEIGHT = 4;
-const U32 TEXTURE_CHANNEL_AUX_0 = 5;
-const U32 TEXTURE_CHANNEL_AUX_1 = 6;
-const U32 TEXTURE_CHANNEL_AUX_2 = 7;
+const U32 TEXTURE_CHANNEL_DIFFUSE = 0u;
+const U32 TEXTURE_CHANNEL_NORMAL = 1u;
+const U32 TEXTURE_CHANNEL_ROUGHNESS_METALNESS = 2u;
+const U32 TEXTURE_CHANNEL_EMISSION = 3u;
+const U32 TEXTURE_CHANNEL_HEIGHT = 4u;
+const U32 TEXTURE_CHANNEL_AUX_0 = 5u;
+const U32 TEXTURE_CHANNEL_AUX_1 = 6u;
+const U32 TEXTURE_CHANNEL_AUX_2 = 7u;
 
 
-const U32 TEXTURE_CHANNEL_COUNT = 8;
+const U32 TEXTURE_CHANNEL_COUNT = 8u;
 
 
 struct MaterialGpuDescriptor
 struct MaterialGpuDescriptor
 {
 {
@@ -74,8 +74,8 @@ struct MaterialGpuDescriptor
 };
 };
 
 
 const U32 _ANKI_SIZEOF_MaterialGpuDescriptor =
 const U32 _ANKI_SIZEOF_MaterialGpuDescriptor =
-	TEXTURE_CHANNEL_COUNT * ANKI_SIZEOF(U16) + 3 * ANKI_SIZEOF(Vec3) + 2 * ANKI_SIZEOF(F32);
-const U32 _ANKI_ALIGNOF_MaterialGpuDescriptor = 4;
+	TEXTURE_CHANNEL_COUNT * ANKI_SIZEOF(U16) + 3u * ANKI_SIZEOF(Vec3) + 2u * ANKI_SIZEOF(F32);
+const U32 _ANKI_ALIGNOF_MaterialGpuDescriptor = 4u;
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MaterialGpuDescriptor == sizeof(MaterialGpuDescriptor));
 ANKI_SHADER_STATIC_ASSERT(_ANKI_SIZEOF_MaterialGpuDescriptor == sizeof(MaterialGpuDescriptor));
 
 
 struct ModelGpuDescriptor
 struct ModelGpuDescriptor

+ 8 - 8
AnKi/Shaders/IrradianceDice.ankiprog

@@ -18,7 +18,7 @@
 
 
 #define DEBUG_MODE 0 // 0: disable, 1: different color per dice face, 2: different color per cell
 #define DEBUG_MODE 0 // 0: disable, 1: different color per dice face, 2: different color per cell
 
 
-const U32 WORKGROUP_SIZE = WORKGROUP_SIZE_XY * WORKGROUP_SIZE_XY;
+const U32 WORKGROUP_SIZE = U32(WORKGROUP_SIZE_XY) * U32(WORKGROUP_SIZE_XY);
 
 
 layout(local_size_x = WORKGROUP_SIZE_XY, local_size_y = WORKGROUP_SIZE_XY, local_size_z = 1) in;
 layout(local_size_x = WORKGROUP_SIZE_XY, local_size_y = WORKGROUP_SIZE_XY, local_size_z = 1) in;
 
 
@@ -59,9 +59,9 @@ shared Vec3 s_diceIrradiance[6u];
 Vec3 sampleLightShadingTexture(const U32 face)
 Vec3 sampleLightShadingTexture(const U32 face)
 {
 {
 #if LIGHT_SHADING_TEX == 0
 #if LIGHT_SHADING_TEX == 0
-	const Vec2 INPUT_TEXTURES_SIZE = Vec2(WORKGROUP_SIZE_XY * 6u, WORKGROUP_SIZE_XY);
-	const Vec2 uv =
-		(Vec2(gl_LocalInvocationID.x + WORKGROUP_SIZE_XY * face, gl_LocalInvocationID.y) + 0.5) / INPUT_TEXTURES_SIZE;
+	const Vec2 INPUT_TEXTURES_SIZE = Vec2(U32(WORKGROUP_SIZE_XY) * 6u, U32(WORKGROUP_SIZE_XY));
+	const Vec2 uv = (Vec2(gl_LocalInvocationID.x + U32(WORKGROUP_SIZE_XY) * face, gl_LocalInvocationID.y) + 0.5)
+					/ INPUT_TEXTURES_SIZE;
 
 
 	return textureLod(u_lightShadingTex2d, u_nearestAnyClampSampler, uv, 0.0).rgb;
 	return textureLod(u_lightShadingTex2d, u_nearestAnyClampSampler, uv, 0.0).rgb;
 #else
 #else
@@ -95,8 +95,8 @@ void main()
 		const Vec3 irradiance = lightShading * lambert * cubeCoordSolidAngle(ndc, WORKGROUP_SIZE_XY_F);
 		const Vec3 irradiance = lightShading * lambert * cubeCoordSolidAngle(ndc, WORKGROUP_SIZE_XY_F);
 
 
 		// Store
 		// Store
-		u_integrationResults[f * WORKGROUP_SIZE + gl_LocalInvocationID.y * WORKGROUP_SIZE_XY + gl_LocalInvocationID.x] =
-			irradiance.xyzx;
+		u_integrationResults[f * WORKGROUP_SIZE + gl_LocalInvocationID.y * U32(WORKGROUP_SIZE_XY)
+							 + gl_LocalInvocationID.x] = irradiance.xyzx;
 	}
 	}
 
 
 	memoryBarrierBuffer();
 	memoryBarrierBuffer();
@@ -159,8 +159,8 @@ void main()
 			(firstBounceIrradiance + lightShading * lambert) * cubeCoordSolidAngle(ndc, WORKGROUP_SIZE_XY_F);
 			(firstBounceIrradiance + lightShading * lambert) * cubeCoordSolidAngle(ndc, WORKGROUP_SIZE_XY_F);
 
 
 		// Store
 		// Store
-		u_integrationResults[f * WORKGROUP_SIZE + gl_LocalInvocationID.y * WORKGROUP_SIZE_XY + gl_LocalInvocationID.x] =
-			irradiance.xyzx;
+		u_integrationResults[f * WORKGROUP_SIZE + gl_LocalInvocationID.y * U32(WORKGROUP_SIZE_XY)
+							 + gl_LocalInvocationID.x] = irradiance.xyzx;
 	}
 	}
 
 
 	memoryBarrierBuffer();
 	memoryBarrierBuffer();

+ 5 - 5
AnKi/Shaders/LensFlareUpdateIndirectInfo.ankiprog

@@ -3,12 +3,12 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(IN_DEPTH_MAP_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(IN_DEPTH_MAP_SIZE, 0u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 #include <AnKi/Shaders/Common.glsl>
 #include <AnKi/Shaders/Common.glsl>
 
 
-const U32 WORKGROUP_SIZE = 8;
+const U32 WORKGROUP_SIZE = 8u;
 layout(local_size_x = WORKGROUP_SIZE, local_size_y = WORKGROUP_SIZE, local_size_z = 1) in;
 layout(local_size_x = WORKGROUP_SIZE, local_size_y = WORKGROUP_SIZE, local_size_z = 1) in;
 
 
 struct DrawArraysIndirectInfo
 struct DrawArraysIndirectInfo
@@ -38,9 +38,9 @@ shared U32 s_maxDepth;
 void main()
 void main()
 {
 {
 	// Init the s_maxDepth
 	// Init the s_maxDepth
-	if(gl_LocalInvocationIndex == 0)
+	if(gl_LocalInvocationIndex == 0u)
 	{
 	{
-		s_maxDepth = 0;
+		s_maxDepth = 0u;
 	}
 	}
 	memoryBarrierShared();
 	memoryBarrierShared();
 	barrier();
 	barrier();
@@ -65,7 +65,7 @@ void main()
 	memoryBarrierShared();
 	memoryBarrierShared();
 	barrier();
 	barrier();
 
 
-	if(gl_LocalInvocationIndex == 0)
+	if(gl_LocalInvocationIndex == 0u)
 	{
 	{
 		const F32 refDepth2 = F32(s_maxDepth) / F32(MAX_U32);
 		const F32 refDepth2 = F32(s_maxDepth) / F32(MAX_U32);
 		u_indirectInfo[flareIdx].count = (depth > refDepth2) ? 0u : 4u;
 		u_indirectInfo[flareIdx].count = (depth > refDepth2) ? 0u : 4u;

+ 8 - 8
AnKi/Shaders/LightShading.ankiprog

@@ -5,10 +5,10 @@
 
 
 #pragma anki mutator USE_SHADOW_LAYERS 0 1
 #pragma anki mutator USE_SHADOW_LAYERS 0 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNTS, 0);
-ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 2);
-ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 3);
-ANKI_SPECIALIZATION_CONSTANT_U32(IR_MIPMAP_COUNT, 4);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNTS, 0u);
+ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 2u);
+ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 3u);
+ANKI_SPECIALIZATION_CONSTANT_U32(IR_MIPMAP_COUNT, 4u);
 
 
 #pragma anki start vert
 #pragma anki start vert
 #include <AnKi/Shaders/QuadVert.glsl>
 #include <AnKi/Shaders/QuadVert.glsl>
@@ -88,7 +88,7 @@ void main()
 	unpackRtShadows(textureLod(u_shadowLayersTex, u_nearestAnyClampSampler, in_uv, 0.0), resolvedSm);
 	unpackRtShadows(textureLod(u_shadowLayersTex, u_nearestAnyClampSampler, in_uv, 0.0), resolvedSm);
 #else
 #else
 	Vec4 resolvedSm = textureLod(u_resolvedSm, u_trilinearClampSampler, in_uv, 0.0);
 	Vec4 resolvedSm = textureLod(u_resolvedSm, u_trilinearClampSampler, in_uv, 0.0);
-	U32 resolvedSmIdx = 0;
+	U32 resolvedSmIdx = 0u;
 #endif
 #endif
 
 
 	// SSAO
 	// SSAO
@@ -104,7 +104,7 @@ void main()
 	if(dirLight.m_active != 0u)
 	if(dirLight.m_active != 0u)
 	{
 	{
 		F32 shadowFactor;
 		F32 shadowFactor;
-		if(dirLight.m_cascadeCount > 0)
+		if(dirLight.m_cascadeCount > 0u)
 		{
 		{
 #if USE_SHADOW_LAYERS
 #if USE_SHADOW_LAYERS
 			shadowFactor = resolvedSm[dirLight.m_shadowLayer];
 			shadowFactor = resolvedSm[dirLight.m_shadowLayer];
@@ -129,7 +129,7 @@ void main()
 	}
 	}
 
 
 	// Point lights
 	// Point lights
-	ANKI_LOOP while(cluster.m_pointLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_pointLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
@@ -151,7 +151,7 @@ void main()
 	}
 	}
 
 
 	// Spot lights
 	// Spot lights
-	ANKI_LOOP while(cluster.m_spotLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_spotLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));

+ 2 - 2
AnKi/Shaders/LightShadingApplyFog.ankiprog

@@ -3,8 +3,8 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 0);
-ANKI_SPECIALIZATION_CONSTANT_U32(FINAL_Z_SPLIT, 1);
+ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 0u);
+ANKI_SPECIALIZATION_CONSTANT_U32(FINAL_Z_SPLIT, 1u);
 
 
 #pragma anki start vert
 #pragma anki start vert
 #include <AnKi/Shaders/QuadVert.glsl>
 #include <AnKi/Shaders/QuadVert.glsl>

+ 2 - 2
AnKi/Shaders/LumaAwareBlur.ankiprog

@@ -7,7 +7,7 @@
 #pragma anki mutator KERNEL_SIZE 3 5 7 9 11 13 15
 #pragma anki mutator KERNEL_SIZE 3 5 7 9 11 13 15
 #pragma anki mutator COLOR_COMPONENTS 4 3 1
 #pragma anki mutator COLOR_COMPONENTS 4 3 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(TEXTURE_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(TEXTURE_SIZE, 0u);
 
 
 #pragma anki start vert
 #pragma anki start vert
 #include <AnKi/Shaders/QuadVert.glsl>
 #include <AnKi/Shaders/QuadVert.glsl>
@@ -61,7 +61,7 @@ void main()
 	F32 weight = 1.0;
 	F32 weight = 1.0;
 	Vec2 texCoordOffset = 1.5 * TEXEL_SIZE;
 	Vec2 texCoordOffset = 1.5 * TEXEL_SIZE;
 
 
-	for(U32 i = 0u; i < KERNEL_SIZE; ++i)
+	for(U32 i = 0u; i < U32(KERNEL_SIZE); ++i)
 	{
 	{
 		COL_TYPE col = textureLod(u_tex, u_linearAnyClampSampler, in_uv + texCoordOffset, 0.0).TEX_FETCH;
 		COL_TYPE col = textureLod(u_tex, u_linearAnyClampSampler, in_uv + texCoordOffset, 0.0).TEX_FETCH;
 		F32 w = computeLumaWeight(refLuma, col);
 		F32 w = computeLumaWeight(refLuma, col);

+ 1 - 1
AnKi/Shaders/MotionVectors.ankiprog

@@ -5,7 +5,7 @@
 
 
 // Calculates the motion vectors that will be used to sample from the previous frame
 // Calculates the motion vectors that will be used to sample from the previous frame
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u);
 const F32 MAX_REJECTION_DISTANCE = 2.0; // In meters
 const F32 MAX_REJECTION_DISTANCE = 2.0; // In meters
 #define VARIANCE_CLIPPING 0
 #define VARIANCE_CLIPPING 0
 const F32 VARIANCE_CLIPPING_GAMMA = 2.0;
 const F32 VARIANCE_CLIPPING_GAMMA = 2.0;

+ 1 - 1
AnKi/Shaders/RtShadows.glsl

@@ -33,7 +33,7 @@ void unpackRtShadows(UVec4 packed, out F32 shadowFactors[MAX_RT_SHADOW_LAYERS])
 
 
 void zeroRtShadowLayers(out F32 shadowFactors[MAX_RT_SHADOW_LAYERS])
 void zeroRtShadowLayers(out F32 shadowFactors[MAX_RT_SHADOW_LAYERS])
 {
 {
-	ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 	{
 	{
 		shadowFactors[i] = 0.0;
 		shadowFactors[i] = 0.0;
 	}
 	}

+ 7 - 7
AnKi/Shaders/RtShadowsDenoise.ankiprog

@@ -7,9 +7,9 @@
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(OUT_IMAGE_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_U32(MIN_SAMPLE_COUNT, 2);
-ANKI_SPECIALIZATION_CONSTANT_U32(MAX_SAMPLE_COUNT, 3);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(OUT_IMAGE_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_U32(MIN_SAMPLE_COUNT, 2u);
+ANKI_SPECIALIZATION_CONSTANT_U32(MAX_SAMPLE_COUNT, 3u);
 
 
 #include <AnKi/Shaders/BilateralFilter.glsl>
 #include <AnKi/Shaders/BilateralFilter.glsl>
 #include <AnKi/Shaders/Pack.glsl>
 #include <AnKi/Shaders/Pack.glsl>
@@ -111,7 +111,7 @@ void main()
 		sampleCount = U32(sampleCountf);
 		sampleCount = U32(sampleCountf);
 	}
 	}
 
 
-	sampleCount = sampleCount / 2;
+	sampleCount = sampleCount / 2u;
 
 
 	// Sample
 	// Sample
 	F32 weight = 1.0; // TODO fix that
 	F32 weight = 1.0; // TODO fix that
@@ -136,9 +136,9 @@ void main()
 		// F32 w = calculateBilateralWeighPlane(depthCenter, depthTap, 1.0);
 		// F32 w = calculateBilateralWeighPlane(depthCenter, depthTap, 1.0);
 		F32 w = calculateBilateralWeightPlane(positionCenter, normalCenter, positionTap, normalTap, 1.0);
 		F32 w = calculateBilateralWeightPlane(positionCenter, normalCenter, positionTap, normalTap, 1.0);
 
 
-		w *= gaussianWeight(0.4, abs(F32(i)) / F32(sampleCount + 1));
+		w *= gaussianWeight(0.4, abs(F32(i)) / F32(sampleCount + 1u));
 
 
-		ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+		ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 		{
 		{
 			shadowFactors[i] += localShadowFactors[i] * w;
 			shadowFactors[i] += localShadowFactors[i] * w;
 		}
 		}
@@ -147,7 +147,7 @@ void main()
 	}
 	}
 
 
 	// Write value
 	// Write value
-	ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 	{
 	{
 		shadowFactors[i] /= weight;
 		shadowFactors[i] /= weight;
 	}
 	}

+ 10 - 7
AnKi/Shaders/RtShadowsHit.ankiprog

@@ -37,20 +37,23 @@ void main()
 	const ModelGpuDescriptor model = u_modelDescriptor;
 	const ModelGpuDescriptor model = u_modelDescriptor;
 	const MeshGpuDescriptor mesh = model.m_mesh;
 	const MeshGpuDescriptor mesh = model.m_mesh;
 
 
-	const U32 offset = gl_PrimitiveID * ANKI_SIZEOF(U16Vec3);
-	const U16Vec3 indices = U16Vec3Ref(mesh.m_indexBufferPtr + offset).m_value;
+	const U32 offset = U32(gl_PrimitiveID) * ANKI_SIZEOF(U16Vec3);
+	const UVec3 indices = UVec3(U16Vec3Ref(mesh.m_indexBufferPtr + U64(offset)).m_value);
 
 
-	const MainVertex vert0 = MainVertexRef(mesh.m_mainVertexBufferPtr + indices[0] * ANKI_SIZEOF(MainVertex)).m_value;
-	const MainVertex vert1 = MainVertexRef(mesh.m_mainVertexBufferPtr + indices[1] * ANKI_SIZEOF(MainVertex)).m_value;
-	const MainVertex vert2 = MainVertexRef(mesh.m_mainVertexBufferPtr + indices[2] * ANKI_SIZEOF(MainVertex)).m_value;
+	const MainVertex vert0 =
+		MainVertexRef(mesh.m_mainVertexBufferPtr + U64(indices[0] * ANKI_SIZEOF(MainVertex))).m_value;
+	const MainVertex vert1 =
+		MainVertexRef(mesh.m_mainVertexBufferPtr + U64(indices[1] * ANKI_SIZEOF(MainVertex))).m_value;
+	const MainVertex vert2 =
+		MainVertexRef(mesh.m_mainVertexBufferPtr + U64(indices[2] * ANKI_SIZEOF(MainVertex))).m_value;
 
 
 	const Vec3 barycentrics = Vec3(1.0f - g_attribs.x - g_attribs.y, g_attribs.x, g_attribs.y);
 	const Vec3 barycentrics = Vec3(1.0f - g_attribs.x - g_attribs.y, g_attribs.x, g_attribs.y);
 
 
 	const Vec2 uv = vert0.m_uvs[UV_CHANNEL_0] * barycentrics.x + vert1.m_uvs[UV_CHANNEL_0] * barycentrics.y
 	const Vec2 uv = vert0.m_uvs[UV_CHANNEL_0] * barycentrics.x + vert1.m_uvs[UV_CHANNEL_0] * barycentrics.y
 					+ vert2.m_uvs[UV_CHANNEL_0] * barycentrics.z;
 					+ vert2.m_uvs[UV_CHANNEL_0] * barycentrics.z;
 
 
-	const U32 texIdx = model.m_material.m_bindlessTextureIndices[TEXTURE_CHANNEL_DIFFUSE];
-	const F32 alpha = textureLod(u_bindlessTextures2dF32[nonuniformEXT(texIdx)], u_sampler, uv, 3).a;
+	const U32 texIdx = U32(model.m_material.m_bindlessTextureIndices[TEXTURE_CHANNEL_DIFFUSE]);
+	const F32 alpha = textureLod(u_bindlessTextures2dF32[nonuniformEXT(texIdx)], u_sampler, uv, 3.0).a;
 
 
 	g_payload += alpha;
 	g_payload += alpha;
 
 

+ 14 - 14
AnKi/Shaders/RtShadowsRayGen.ankiprog

@@ -49,10 +49,10 @@ layout(location = 0) rayPayloadEXT F32 g_payload;
 F32 trace(const Vec3 rayOrigin, const Vec3 rayDir, F32 tMax)
 F32 trace(const Vec3 rayOrigin, const Vec3 rayDir, F32 tMax)
 {
 {
 	const U32 flags = gl_RayFlagsOpaqueEXT | gl_RayFlagsTerminateOnFirstHitEXT | gl_RayFlagsSkipClosestHitShaderEXT;
 	const U32 flags = gl_RayFlagsOpaqueEXT | gl_RayFlagsTerminateOnFirstHitEXT | gl_RayFlagsSkipClosestHitShaderEXT;
-	const U32 cullMask = 0xFF;
-	const U32 sbtRecordOffset = 0;
-	const U32 sbtRecordStride = 0;
-	const U32 missIndex = 0;
+	const U32 cullMask = 0xFFu;
+	const U32 sbtRecordOffset = 0u;
+	const U32 sbtRecordStride = 0u;
+	const U32 missIndex = 0u;
 	const F32 tMin = 0.1;
 	const F32 tMin = 0.1;
 	const I32 payloadLocation = 0;
 	const I32 payloadLocation = 0;
 	g_payload = 0.0;
 	g_payload = 0.0;
@@ -94,9 +94,9 @@ void main()
 
 
 	// Get a random factor
 	// Get a random factor
 	Vec3 random[RAYS_PER_PIXEL];
 	Vec3 random[RAYS_PER_PIXEL];
-	for(U32 i = 0; i < RAYS_PER_PIXEL; ++i)
+	for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 	{
 	{
-		const U32 frameIdx = u_clusteredShading.m_frame * RAYS_PER_PIXEL + i;
+		const U32 frameIdx = u_clusteredShading.m_frame * U32(RAYS_PER_PIXEL + i);
 #if 0
 #if 0
 		const UVec3 irandom = rand3DPCG16(UVec3(gl_LaunchIDEXT.xy, frameIdx));
 		const UVec3 irandom = rand3DPCG16(UVec3(gl_LaunchIDEXT.xy, frameIdx));
 		random[i] = Vec3(irandom) / F32(0xFFFF) * 2.0 - 1.0; // In [-1.0, 1.0]
 		random[i] = Vec3(irandom) / F32(0xFFFF) * 2.0 - 1.0; // In [-1.0, 1.0]
@@ -110,9 +110,9 @@ void main()
 
 
 	// Dir light
 	// Dir light
 	const DirectionalLight dirLight = u_clusteredShading.m_directionalLight;
 	const DirectionalLight dirLight = u_clusteredShading.m_directionalLight;
-	ANKI_BRANCH if(dirLight.m_active != 0u && dirLight.m_cascadeCount > 0)
+	ANKI_BRANCH if(dirLight.m_active != 0u && dirLight.m_cascadeCount > 0u)
 	{
 	{
-		for(U32 i = 0; i < RAYS_PER_PIXEL; ++i)
+		for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 		{
 		{
 			const Vec3 dirLightPos = worldPos + -dirLight.m_direction * 10.0 + random[i];
 			const Vec3 dirLightPos = worldPos + -dirLight.m_direction * 10.0 + random[i];
 			const Vec3 rayDir = normalize(dirLightPos - worldPos);
 			const Vec3 rayDir = normalize(dirLightPos - worldPos);
@@ -126,7 +126,7 @@ void main()
 	}
 	}
 
 
 	// Point lights
 	// Point lights
-	ANKI_LOOP while(cluster.m_pointLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_pointLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
@@ -134,7 +134,7 @@ void main()
 
 
 		ANKI_BRANCH if(light.m_shadowAtlasTileScale >= 0.0)
 		ANKI_BRANCH if(light.m_shadowAtlasTileScale >= 0.0)
 		{
 		{
-			for(U32 i = 0; i < RAYS_PER_PIXEL; ++i)
+			for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 			{
 			{
 				const Vec3 lightPos = light.m_position + 0.05 * light.m_radius * random[i];
 				const Vec3 lightPos = light.m_position + 0.05 * light.m_radius * random[i];
 				const Vec3 toLight = lightPos - worldPos;
 				const Vec3 toLight = lightPos - worldPos;
@@ -153,7 +153,7 @@ void main()
 	}
 	}
 
 
 	// Spot lights
 	// Spot lights
-	ANKI_LOOP while(cluster.m_spotLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_spotLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));
@@ -161,7 +161,7 @@ void main()
 
 
 		ANKI_BRANCH if(light.m_shadowLayer != MAX_U32)
 		ANKI_BRANCH if(light.m_shadowLayer != MAX_U32)
 		{
 		{
-			for(U32 i = 0; i < RAYS_PER_PIXEL; ++i)
+			for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 			{
 			{
 				const Vec3 lightPos = light.m_position + 0.05 * light.m_radius * random[i];
 				const Vec3 lightPos = light.m_position + 0.05 * light.m_radius * random[i];
 				const Vec3 toLight = lightPos - worldPos;
 				const Vec3 toLight = lightPos - worldPos;
@@ -208,7 +208,7 @@ void main()
 	const UVec4 packedhistory = textureLod(u_historyShadowsTex, u_nearestAnyClampSampler, historyUv, 0.0);
 	const UVec4 packedhistory = textureLod(u_historyShadowsTex, u_nearestAnyClampSampler, historyUv, 0.0);
 	F32 history[MAX_RT_SHADOW_LAYERS];
 	F32 history[MAX_RT_SHADOW_LAYERS];
 	unpackRtShadows(packedhistory, history);
 	unpackRtShadows(packedhistory, history);
-	for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+	for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 	{
 	{
 		const F32 lerp = min(1.0, u_unis.historyRejectFactor[i] + blendFactor);
 		const F32 lerp = min(1.0, u_unis.historyRejectFactor[i] + blendFactor);
 		shadowFactors[i] = mix(history[i], shadowFactors[i], lerp);
 		shadowFactors[i] = mix(history[i], shadowFactors[i], lerp);
@@ -220,7 +220,7 @@ void main()
 
 
 	// Compute the moments that will give temporal variance
 	// Compute the moments that will give temporal variance
 	Vec2 moments = Vec2(0.0);
 	Vec2 moments = Vec2(0.0);
-	ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 	{
 	{
 		moments.x += shadowFactors[i];
 		moments.x += shadowFactors[i];
 	}
 	}

+ 4 - 4
AnKi/Shaders/RtShadowsSvgfAtrous.ankiprog

@@ -5,7 +5,7 @@
 
 
 #pragma anki mutator LAST_PASS 0 1
 #pragma anki mutator LAST_PASS 0 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
@@ -45,7 +45,7 @@ Vec3 toViewspace(Vec2 uv, F32 depth)
 F32 computeShadowsLuma(F32 shadowLayers[MAX_RT_SHADOW_LAYERS])
 F32 computeShadowsLuma(F32 shadowLayers[MAX_RT_SHADOW_LAYERS])
 {
 {
 	F32 l = 0.0;
 	F32 l = 0.0;
-	ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 	{
 	{
 		l += shadowLayers[i];
 		l += shadowLayers[i];
 	}
 	}
@@ -141,7 +141,7 @@ void main()
 			// w *= KERNEL_WEIGHTS[abs(offsetx)] * KERNEL_WEIGHTS[abs(offsety)];
 			// w *= KERNEL_WEIGHTS[abs(offsetx)] * KERNEL_WEIGHTS[abs(offsety)];
 
 
 			// Sum
 			// Sum
-			ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+			ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 			{
 			{
 				sumShadowLayers[i] += shadowLayers[i] * w;
 				sumShadowLayers[i] += shadowLayers[i] * w;
 			}
 			}
@@ -154,7 +154,7 @@ void main()
 	// Normalize
 	// Normalize
 	sumWeight += EPSILON;
 	sumWeight += EPSILON;
 
 
-	ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 	{
 	{
 		sumShadowLayers[i] /= sumWeight;
 		sumShadowLayers[i] /= sumWeight;
 	}
 	}

+ 3 - 3
AnKi/Shaders/RtShadowsSvgfVariance.ankiprog

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
@@ -97,7 +97,7 @@ void main()
 
 
 				F32 shadowLayers[MAX_RT_SHADOW_LAYERS];
 				F32 shadowLayers[MAX_RT_SHADOW_LAYERS];
 				unpackRtShadows(textureLod(u_shadowsTex, u_nearestAnyClampSampler, sampleUv, 0.0), shadowLayers);
 				unpackRtShadows(textureLod(u_shadowsTex, u_nearestAnyClampSampler, sampleUv, 0.0), shadowLayers);
-				ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+				ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 				{
 				{
 					sumShadowLayers[i] += shadowLayers[i] * w;
 					sumShadowLayers[i] += shadowLayers[i] * w;
 				}
 				}
@@ -108,7 +108,7 @@ void main()
 
 
 		sumWeight += EPSILON;
 		sumWeight += EPSILON;
 
 
-		ANKI_UNROLL for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+		ANKI_UNROLL for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 		{
 		{
 			sumShadowLayers[i] /= sumWeight;
 			sumShadowLayers[i] /= sumWeight;
 		}
 		}

+ 4 - 4
AnKi/Shaders/RtShadowsUpscale.ankiprog

@@ -9,7 +9,7 @@
 #include <AnKi/Shaders/Functions.glsl>
 #include <AnKi/Shaders/Functions.glsl>
 #include <AnKi/Shaders/BilateralFilter.glsl>
 #include <AnKi/Shaders/BilateralFilter.glsl>
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(OUT_IMAGE_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(OUT_IMAGE_SIZE, 0u);
 
 
 const UVec2 WORKGROUP_SIZE = UVec2(8u, 8u);
 const UVec2 WORKGROUP_SIZE = UVec2(8u, 8u);
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
@@ -37,7 +37,7 @@ void main()
 	zeroRtShadowLayers(sumShadowLayers);
 	zeroRtShadowLayers(sumShadowLayers);
 
 
 	// Do a bilateral upscale
 	// Do a bilateral upscale
-	const Vec2 texelSize = 1.0 / Vec2(OUT_IMAGE_SIZE / 2);
+	const Vec2 texelSize = 1.0 / Vec2(OUT_IMAGE_SIZE / 2u);
 	const I32 radius = 1;
 	const I32 radius = 1;
 	F32 sumWeight = EPSILON;
 	F32 sumWeight = EPSILON;
 	for(I32 x = -radius; x <= radius; ++x)
 	for(I32 x = -radius; x <= radius; ++x)
@@ -52,7 +52,7 @@ void main()
 			F32 shadowLayers[MAX_RT_SHADOW_LAYERS];
 			F32 shadowLayers[MAX_RT_SHADOW_LAYERS];
 			unpackRtShadows(textureLod(u_quarterShadowsTex, u_nearestAnyClampSampler, sampleUv, 0.0), shadowLayers);
 			unpackRtShadows(textureLod(u_quarterShadowsTex, u_nearestAnyClampSampler, sampleUv, 0.0), shadowLayers);
 
 
-			for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+			for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 			{
 			{
 				sumShadowLayers[i] += shadowLayers[i] * w;
 				sumShadowLayers[i] += shadowLayers[i] * w;
 			}
 			}
@@ -61,7 +61,7 @@ void main()
 		}
 		}
 	}
 	}
 
 
-	for(U32 i = 0; i < MAX_RT_SHADOW_LAYERS; ++i)
+	for(U32 i = 0u; i < MAX_RT_SHADOW_LAYERS; ++i)
 	{
 	{
 		sumShadowLayers[i] /= sumWeight;
 		sumShadowLayers[i] /= sumWeight;
 	}
 	}

+ 1 - 1
AnKi/Shaders/SceneDebug.ankiprog

@@ -6,7 +6,7 @@
 #pragma anki mutator COLOR_TEXTURE 0 1
 #pragma anki mutator COLOR_TEXTURE 0 1
 #pragma anki mutator DITHERED_DEPTH_TEST 0 1
 #pragma anki mutator DITHERED_DEPTH_TEST 0 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_U32(INSTANCE_COUNT, 0);
+ANKI_SPECIALIZATION_CONSTANT_U32(INSTANCE_COUNT, 0u);
 
 
 layout(set = 1, binding = 0, row_major) uniform u0_
 layout(set = 1, binding = 0, row_major) uniform u0_
 {
 {

+ 11 - 11
AnKi/Shaders/ShadowmapsResolve.ankiprog

@@ -5,10 +5,10 @@
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNTS, 2);
-ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 4);
-ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 5);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNTS, 2u);
+ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 4u);
+ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 5u);
 
 
 #define CLUSTERED_SHADING_SET 0
 #define CLUSTERED_SHADING_SET 0
 #define CLUSTERED_SHADING_UNIFORMS_BINDING 0
 #define CLUSTERED_SHADING_UNIFORMS_BINDING 0
@@ -43,13 +43,13 @@ void main()
 										  u_clusteredShading.m_zSplitMagic.x, u_clusteredShading.m_zSplitMagic.y);
 										  u_clusteredShading.m_zSplitMagic.x, u_clusteredShading.m_zSplitMagic.y);
 
 
 	// Layers
 	// Layers
-	U32 shadowCasterCountPerFragment = 0;
-	const U32 maxShadowCastersPerFragment = 4;
+	U32 shadowCasterCountPerFragment = 0u;
+	const U32 maxShadowCastersPerFragment = 4u;
 	F32 shadowFactors[maxShadowCastersPerFragment] = F32[](0.0, 0.0, 0.0, 0.0);
 	F32 shadowFactors[maxShadowCastersPerFragment] = F32[](0.0, 0.0, 0.0, 0.0);
 
 
 	// Dir light
 	// Dir light
 	const DirectionalLight dirLight = u_clusteredShading.m_directionalLight;
 	const DirectionalLight dirLight = u_clusteredShading.m_directionalLight;
-	if(dirLight.m_active != 0u && dirLight.m_cascadeCount > 0)
+	if(dirLight.m_active != 0u && dirLight.m_cascadeCount > 0u)
 	{
 	{
 		const F32 positiveZViewSpace =
 		const F32 positiveZViewSpace =
 			testPlanePoint(u_clusteredShading.m_nearPlaneWSpace.xyz, u_clusteredShading.m_nearPlaneWSpace.w, worldPos)
 			testPlanePoint(u_clusteredShading.m_nearPlaneWSpace.xyz, u_clusteredShading.m_nearPlaneWSpace.w, worldPos)
@@ -79,7 +79,7 @@ void main()
 	}
 	}
 
 
 	// Point lights
 	// Point lights
-	ANKI_LOOP while(cluster.m_pointLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_pointLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
@@ -91,12 +91,12 @@ void main()
 
 
 			const F32 shadowFactor =
 			const F32 shadowFactor =
 				computeShadowFactorPointLight(light, frag2Light, u_shadowAtlasTex, u_linearAnyClampSampler);
 				computeShadowFactorPointLight(light, frag2Light, u_shadowAtlasTex, u_linearAnyClampSampler);
-			shadowFactors[min(maxShadowCastersPerFragment - 1, shadowCasterCountPerFragment++)] = shadowFactor;
+			shadowFactors[min(maxShadowCastersPerFragment - 1u, shadowCasterCountPerFragment++)] = shadowFactor;
 		}
 		}
 	}
 	}
 
 
 	// Spot lights
 	// Spot lights
-	ANKI_LOOP while(cluster.m_spotLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_spotLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));
@@ -106,7 +106,7 @@ void main()
 		{
 		{
 			const F32 shadowFactor =
 			const F32 shadowFactor =
 				computeShadowFactorSpotLight(light, worldPos, u_shadowAtlasTex, u_linearAnyClampSampler);
 				computeShadowFactorSpotLight(light, worldPos, u_shadowAtlasTex, u_linearAnyClampSampler);
-			shadowFactors[min(maxShadowCastersPerFragment - 1, shadowCasterCountPerFragment++)] = shadowFactor;
+			shadowFactors[min(maxShadowCastersPerFragment - 1u, shadowCasterCountPerFragment++)] = shadowFactor;
 		}
 		}
 	}
 	}
 
 

+ 2 - 2
AnKi/Shaders/SsRaymarching.glsl

@@ -97,7 +97,7 @@ void raymarch(Vec3 rayOrigin, // Ray origin in view space
 
 
 	// Start looping
 	// Start looping
 	I32 mipLevel = 0;
 	I32 mipLevel = 0;
-	while(mipLevel > -1 && maxIterations > 0)
+	while(mipLevel > -1 && maxIterations > 0u)
 	{
 	{
 		// Step to the next cell
 		// Step to the next cell
 		Vec3 newOrigin;
 		Vec3 newOrigin;
@@ -182,7 +182,7 @@ void raymarchGroundTruth(Vec3 rayOrigin, // Ray origin in view space
 
 
 	// Iterate
 	// Iterate
 	Vec3 origin;
 	Vec3 origin;
-	ANKI_LOOP while(maxIterations-- != 0)
+	ANKI_LOOP while(maxIterations-- != 0u)
 	{
 	{
 		origin = start + dir * (F32(step) * stepSize);
 		origin = start + dir * (F32(step) * stepSize);
 
 

+ 7 - 7
AnKi/Shaders/Ssao.glsl

@@ -8,12 +8,12 @@
 #pragma anki mutator USE_NORMAL 0 1
 #pragma anki mutator USE_NORMAL 0 1
 #pragma anki mutator SOFT_BLUR 0 1
 #pragma anki mutator SOFT_BLUR 0 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_U32(NOISE_MAP_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 1);
-ANKI_SPECIALIZATION_CONSTANT_F32(RADIUS, 3);
-ANKI_SPECIALIZATION_CONSTANT_F32(BIAS, 4);
-ANKI_SPECIALIZATION_CONSTANT_F32(STRENGTH, 5);
-ANKI_SPECIALIZATION_CONSTANT_U32(SAMPLE_COUNT, 6);
+ANKI_SPECIALIZATION_CONSTANT_U32(NOISE_MAP_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 1u);
+ANKI_SPECIALIZATION_CONSTANT_F32(RADIUS, 3u);
+ANKI_SPECIALIZATION_CONSTANT_F32(BIAS, 4u);
+ANKI_SPECIALIZATION_CONSTANT_F32(STRENGTH, 5u);
+ANKI_SPECIALIZATION_CONSTANT_U32(SAMPLE_COUNT, 6u);
 
 
 #pragma once
 #pragma once
 
 
@@ -169,7 +169,7 @@ void main(void)
 	const F32 randFactor = readRandom(uv, 0.0).r;
 	const F32 randFactor = readRandom(uv, 0.0).r;
 	F32 ssao = 0.0;
 	F32 ssao = 0.0;
 	const F32 SAMPLE_COUNTF = F32(SAMPLE_COUNT);
 	const F32 SAMPLE_COUNTF = F32(SAMPLE_COUNT);
-	ANKI_UNROLL for(U32 i = 0; i < SAMPLE_COUNT; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < SAMPLE_COUNT; ++i)
 	{
 	{
 		// Compute disk. Basically calculate a point in a spiral. See how it looks here
 		// Compute disk. Basically calculate a point in a spiral. See how it looks here
 		// https://shadertoy.com/view/Md3fDr
 		// https://shadertoy.com/view/Md3fDr

+ 7 - 7
AnKi/Shaders/Ssgi.ankiprog

@@ -39,16 +39,16 @@ layout(set = 0, binding = 8) uniform texture2D u_motionVectorRejectionTex;
 void main()
 void main()
 {
 {
 	// Compute a global invocation ID that takes the checkerboard pattern into account
 	// Compute a global invocation ID that takes the checkerboard pattern into account
-	UVec2 fixedGlobalInvocationId = IVec2(gl_GlobalInvocationID.xy);
-	fixedGlobalInvocationId *= 2;
+	UVec2 fixedGlobalInvocationId = gl_GlobalInvocationID.xy;
+	fixedGlobalInvocationId *= 2u;
 #if VARIANT == 0
 #if VARIANT == 0
 	// Nothing
 	// Nothing
 #elif VARIANT == 1
 #elif VARIANT == 1
-	fixedGlobalInvocationId.x += 1;
+	fixedGlobalInvocationId.x += 1u;
 #elif VARIANT == 2
 #elif VARIANT == 2
-	fixedGlobalInvocationId += 1;
+	fixedGlobalInvocationId += 1u;
 #else
 #else
-	fixedGlobalInvocationId.y += 1;
+	fixedGlobalInvocationId.y += 1u;
 #endif
 #endif
 
 
 	if(fixedGlobalInvocationId.x >= u_unis.m_framebufferSize.x
 	if(fixedGlobalInvocationId.x >= u_unis.m_framebufferSize.x
@@ -74,14 +74,14 @@ void main()
 
 
 	// Get a random point inside the hemisphere. Use hemisphereSampleCos to avoid perpendicular vecs to viewNormal
 	// Get a random point inside the hemisphere. Use hemisphereSampleCos to avoid perpendicular vecs to viewNormal
 	const UVec2 random = rand3DPCG16(UVec3(gl_GlobalInvocationID.xy, u_unis.m_frameCount)).xy;
 	const UVec2 random = rand3DPCG16(UVec3(gl_GlobalInvocationID.xy, u_unis.m_frameCount)).xy;
-	Vec2 randomCircle = hammersleyRandom16(0, 0xFFFFu, random);
+	Vec2 randomCircle = hammersleyRandom16(0u, 0xFFFFu, random);
 	randomCircle.x *= 0.85; // Reduce the cone angle a bit to avoid self-collisions
 	randomCircle.x *= 0.85; // Reduce the cone angle a bit to avoid self-collisions
 	const Vec3 randomHemisphere = rotationFromDirection(viewNormal) * hemisphereSampleCos(randomCircle);
 	const Vec3 randomHemisphere = rotationFromDirection(viewNormal) * hemisphereSampleCos(randomCircle);
 
 
 	// Trace
 	// Trace
 	Vec3 hitPoint;
 	Vec3 hitPoint;
 	F32 hitAttenuation;
 	F32 hitAttenuation;
-	const U32 lod = 0;
+	const U32 lod = 0u;
 	const F32 minStepf = 4.0;
 	const F32 minStepf = 4.0;
 	const F32 noise = F32(random.x) * (1.0 / 65536.0);
 	const F32 noise = F32(random.x) * (1.0 / 65536.0);
 	raymarchGroundTruth(viewPos, randomHemisphere, uv, depth, u_unis.m_projMat, u_unis.m_maxSteps, u_depthRt,
 	raymarchGroundTruth(viewPos, randomHemisphere, uv, depth, u_unis.m_projMat, u_unis.m_maxSteps, u_depthRt,

+ 4 - 4
AnKi/Shaders/SsgiDenoise.ankiprog

@@ -7,7 +7,7 @@
 #pragma anki mutator ORIENTATION 0 1 // 0: VERTICAL, 1: HORIZONTAL
 #pragma anki mutator ORIENTATION 0 1 // 0: VERTICAL, 1: HORIZONTAL
 #pragma anki mutator SAMPLE_COUNT 3 5 7 9 11 13 15
 #pragma anki mutator SAMPLE_COUNT 3 5 7 9 11 13 15
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(IN_TEXTURE_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(IN_TEXTURE_SIZE, 0u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
@@ -82,10 +82,10 @@ void main()
 #else
 #else
 	const UVec2 depthReadOffset = UVec2(1, 0);
 	const UVec2 depthReadOffset = UVec2(1, 0);
 #endif
 #endif
-	const Vec2 depthUv = (Vec2(gl_GlobalInvocationID.xy * 2 + depthReadOffset) + 0.5) / Vec2(IN_TEXTURE_SIZE * 2);
+	const Vec2 depthUv = (Vec2(gl_GlobalInvocationID.xy * 2u + depthReadOffset) + 0.5) / Vec2(IN_TEXTURE_SIZE * 2u);
 
 
 	const Vec2 IN_TEXEL_SIZE = 1.0 / Vec2(IN_TEXTURE_SIZE);
 	const Vec2 IN_TEXEL_SIZE = 1.0 / Vec2(IN_TEXTURE_SIZE);
-	const Vec2 DEPTH_TEXEL_SIZE = 1.0 / Vec2(IN_TEXTURE_SIZE * 2);
+	const Vec2 DEPTH_TEXEL_SIZE = 1.0 / Vec2(IN_TEXTURE_SIZE * 2u);
 
 
 	// Reference
 	// Reference
 	Vec3 color = textureLod(u_inTex, u_linearAnyClampSampler, inUv, 0.0).rgb;
 	Vec3 color = textureLod(u_inTex, u_linearAnyClampSampler, inUv, 0.0).rgb;
@@ -106,7 +106,7 @@ void main()
 	Vec2 depthUvOffset = Vec2(0.0);
 	Vec2 depthUvOffset = Vec2(0.0);
 	depthUvOffset.X_OR_Y = 2.0 * DEPTH_TEXEL_SIZE.X_OR_Y;
 	depthUvOffset.X_OR_Y = 2.0 * DEPTH_TEXEL_SIZE.X_OR_Y;
 
 
-	ANKI_UNROLL for(U32 i = 0u; i < (SAMPLE_COUNT - 1u) / 2u; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < (U32(SAMPLE_COUNT) - 1u) / 2u; ++i)
 	{
 	{
 		sampleTex(inUv + inUvOffset, depthUv + depthUvOffset, positionCenter, normalCenter, color, weight);
 		sampleTex(inUv + inUvOffset, depthUv + depthUvOffset, positionCenter, normalCenter, color, weight);
 		sampleTex(inUv - inUvOffset, depthUv - depthUvOffset, positionCenter, normalCenter, color, weight);
 		sampleTex(inUv - inUvOffset, depthUv - depthUvOffset, positionCenter, normalCenter, color, weight);

+ 16 - 16
AnKi/Shaders/SsgiReconstruct.ankiprog

@@ -11,7 +11,7 @@
 
 
 #pragma anki mutator VARIANT 0 1 2 3
 #pragma anki mutator VARIANT 0 1 2 3
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 0u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
@@ -55,31 +55,31 @@ void reconstructAll(Vec4 depthRefs, Vec3 masterColor)
 	const IVec2 localInvocationId = IVec2(gl_LocalInvocationID.xy);
 	const IVec2 localInvocationId = IVec2(gl_LocalInvocationID.xy);
 
 
 #if VARIANT == 0
 #if VARIANT == 0
-	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2);
+	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2u);
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(1, 0), IVec2(1, 1), IVec2(0, 1));
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(1, 0), IVec2(1, 1), IVec2(0, 1));
-	const U32 masterDrefIdx = 3;
-	const U32 slaveDrefIdx[3] = U32[](2, 1, 0);
+	const U32 masterDrefIdx = 3u;
+	const U32 slaveDrefIdx[3] = U32[](2u, 1u, 0u);
 #elif VARIANT == 1
 #elif VARIANT == 1
-	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2) + IVec2(1, 0);
+	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2u) + IVec2(1, 0);
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(-1, 0), IVec2(0, 1), IVec2(-1, 1));
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(-1, 0), IVec2(0, 1), IVec2(-1, 1));
-	const U32 masterDrefIdx = 2;
-	const U32 slaveDrefIdx[3] = U32[](3, 1, 0);
+	const U32 masterDrefIdx = 2u;
+	const U32 slaveDrefIdx[3] = U32[](3u, 1u, 0u);
 #elif VARIANT == 2
 #elif VARIANT == 2
-	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2) + IVec2(1, 1);
+	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2u) + IVec2(1, 1);
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(-1, -1), IVec2(0, -1), IVec2(-1, 0));
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(-1, -1), IVec2(0, -1), IVec2(-1, 0));
-	const U32 masterDrefIdx = 1;
-	const U32 slaveDrefIdx[3] = U32[](3, 2, 0);
+	const U32 masterDrefIdx = 1u;
+	const U32 slaveDrefIdx[3] = U32[](3u, 2u, 0u);
 #else
 #else
-	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2) + IVec2(0, 1);
+	const IVec2 masterStoreCoord = IVec2(gl_GlobalInvocationID.xy * 2u) + IVec2(0, 1);
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(0, -1), IVec2(1, -1), IVec2(1, 0));
 	const IVec2 slaveRelativeCoords[3] = IVec2[](IVec2(0, -1), IVec2(1, -1), IVec2(1, 0));
-	const U32 masterDrefIdx = 0;
-	const U32 slaveDrefIdx[3] = U32[](3, 2, 1);
+	const U32 masterDrefIdx = 0u;
+	const U32 slaveDrefIdx[3] = U32[](3u, 2u, 1u);
 #endif
 #endif
 
 
 	const Vec4 masterColorAndDepth = Vec4(masterColor, depthRefs[masterDrefIdx]);
 	const Vec4 masterColorAndDepth = Vec4(masterColor, depthRefs[masterDrefIdx]);
 	imageStore(u_outImg, masterStoreCoord, Vec4(masterColor, 0.0));
 	imageStore(u_outImg, masterStoreCoord, Vec4(masterColor, 0.0));
 
 
-	ANKI_UNROLL for(U32 i = 0; i < 3; ++i)
+	ANKI_UNROLL for(U32 i = 0u; i < 3u; ++i)
 	{
 	{
 		const IVec2 sharedCoord =
 		const IVec2 sharedCoord =
 			clamp(localInvocationId + slaveRelativeCoords[i], IVec2(0), IVec2(WORKGROUP_SIZE) - 1);
 			clamp(localInvocationId + slaveRelativeCoords[i], IVec2(0), IVec2(WORKGROUP_SIZE) - 1);
@@ -92,10 +92,10 @@ void reconstructAll(Vec4 depthRefs, Vec3 masterColor)
 
 
 void main()
 void main()
 {
 {
-	const UVec2 IN_TEXTURE_SIZE = FB_SIZE / 2;
+	const UVec2 IN_TEXTURE_SIZE = FB_SIZE / 2u;
 
 
 	// Initialize the storage for all threads, including helpers. The check should be a constexpr
 	// Initialize the storage for all threads, including helpers. The check should be a constexpr
-	if((WORKGROUP_SIZE.x % IN_TEXTURE_SIZE.x) != 0 || (WORKGROUP_SIZE.y % IN_TEXTURE_SIZE.y) != 0)
+	if((WORKGROUP_SIZE.x % IN_TEXTURE_SIZE.x) != 0u || (WORKGROUP_SIZE.y % IN_TEXTURE_SIZE.y) != 0u)
 	{
 	{
 		s_colors[gl_LocalInvocationID.y][gl_LocalInvocationID.x] = Vec3(0.0);
 		s_colors[gl_LocalInvocationID.y][gl_LocalInvocationID.x] = Vec3(0.0);
 		s_depths[gl_LocalInvocationID.y][gl_LocalInvocationID.x] = Vec4(1000.0); // High value so it has low weight
 		s_depths[gl_LocalInvocationID.y][gl_LocalInvocationID.x] = Vec4(1000.0); // High value so it has low weight

+ 3 - 3
AnKi/Shaders/Ssr.ankiprog

@@ -77,15 +77,15 @@ void main()
 
 
 	// Rand idx
 	// Rand idx
 	const Vec2 noiseUv = Vec2(u_unis.m_framebufferSize) / NOISE_TEX_SIZE * uv;
 	const Vec2 noiseUv = Vec2(u_unis.m_framebufferSize) / NOISE_TEX_SIZE * uv;
-	const Vec2 noiseShift = 1.0 / NOISE_TEX_SIZE * (u_unis.m_frameCount % 4u);
+	const Vec2 noiseShift = 1.0 / NOISE_TEX_SIZE * F32(u_unis.m_frameCount % 4u);
 	const F32 noise = textureLod(u_noiseTex, u_trilinearRepeatSampler, noiseUv + noiseShift, 0.0).r;
 	const F32 noise = textureLod(u_noiseTex, u_trilinearRepeatSampler, noiseUv + noiseShift, 0.0).r;
 
 
 	// Do the heavy work
 	// Do the heavy work
 	Vec3 hitPoint;
 	Vec3 hitPoint;
 	F32 hitAttenuation;
 	F32 hitAttenuation;
-	const U32 lod = 0;
+	const U32 lod = 0u;
 	const U32 step = u_unis.m_firstStepPixels;
 	const U32 step = u_unis.m_firstStepPixels;
-	const F32 stepf = step;
+	const F32 stepf = F32(step);
 	const F32 minStepf = stepf / 4.0;
 	const F32 minStepf = stepf / 4.0;
 	raymarchGroundTruth(viewPos, reflVec, uv, depth, u_unis.m_projMat, u_unis.m_maxSteps, u_depthRt,
 	raymarchGroundTruth(viewPos, reflVec, uv, depth, u_unis.m_projMat, u_unis.m_maxSteps, u_depthRt,
 						u_trilinearClampSampler, F32(lod), u_unis.m_depthBufferSize, step,
 						u_trilinearClampSampler, F32(lod), u_unis.m_depthBufferSize, step,

+ 3 - 3
AnKi/Shaders/TemporalAAResolve.ankiprog

@@ -8,9 +8,9 @@
 #pragma anki mutator TONEMAP_FIX 0 1
 #pragma anki mutator TONEMAP_FIX 0 1
 #pragma anki mutator YCBCR 0 1
 #pragma anki mutator YCBCR 0 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_F32(VARIANCE_CLIPPING_GAMMA, 0);
-ANKI_SPECIALIZATION_CONSTANT_F32(BLEND_FACTOR, 1);
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 2);
+ANKI_SPECIALIZATION_CONSTANT_F32(VARIANCE_CLIPPING_GAMMA, 0u);
+ANKI_SPECIALIZATION_CONSTANT_F32(BLEND_FACTOR, 1u);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 2u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 #include <AnKi/Shaders/Functions.glsl>
 #include <AnKi/Shaders/Functions.glsl>

+ 3 - 3
AnKi/Shaders/TonemappingAverageLuminance.ankiprog

@@ -3,7 +3,7 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEX_SIZE, 0);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEX_SIZE, 0u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 #define LOG_AVG 0
 #define LOG_AVG 0
@@ -34,9 +34,9 @@ void main()
 	const U32 xStart = gl_LocalInvocationID.x * PIXELS_PER_TILE.x;
 	const U32 xStart = gl_LocalInvocationID.x * PIXELS_PER_TILE.x;
 
 
 	F32 avgLum = 0.0;
 	F32 avgLum = 0.0;
-	ANKI_UNROLL for(U32 y = 0; y < PIXELS_PER_TILE.y; ++y)
+	ANKI_UNROLL for(U32 y = 0u; y < PIXELS_PER_TILE.y; ++y)
 	{
 	{
-		ANKI_UNROLL for(U32 x = 0; x < PIXELS_PER_TILE.x; ++x)
+		ANKI_UNROLL for(U32 x = 0u; x < PIXELS_PER_TILE.x; ++x)
 		{
 		{
 			const UVec2 uv = UVec2(xStart, yStart) + UVec2(x, y);
 			const UVec2 uv = UVec2(xStart, yStart) + UVec2(x, y);
 			if(uv.x >= INPUT_TEX_SIZE.x || uv.y >= INPUT_TEX_SIZE.y)
 			if(uv.x >= INPUT_TEX_SIZE.x || uv.y >= INPUT_TEX_SIZE.y)

+ 3 - 3
AnKi/Shaders/VolumetricFogAccumulation.ankiprog

@@ -3,9 +3,9 @@
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC3(VOLUME_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_U32(FINAL_Z_SPLIT, 3);
-ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 4);
+ANKI_SPECIALIZATION_CONSTANT_UVEC3(VOLUME_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_U32(FINAL_Z_SPLIT, 3u);
+ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 4u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 

+ 6 - 6
AnKi/Shaders/VolumetricLightingAccumulation.ankiprog

@@ -7,10 +7,10 @@
 
 
 #pragma anki mutator ENABLE_SHADOWS 0 1
 #pragma anki mutator ENABLE_SHADOWS 0 1
 
 
-ANKI_SPECIALIZATION_CONSTANT_UVEC3(VOLUME_SIZE, 0);
-ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNT, 3);
-ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 5);
-ANKI_SPECIALIZATION_CONSTANT_U32(FINAL_Z_SPLIT, 6);
+ANKI_SPECIALIZATION_CONSTANT_UVEC3(VOLUME_SIZE, 0u);
+ANKI_SPECIALIZATION_CONSTANT_UVEC2(TILE_COUNT, 3u);
+ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 5u);
+ANKI_SPECIALIZATION_CONSTANT_U32(FINAL_Z_SPLIT, 6u);
 
 
 #pragma anki start comp
 #pragma anki start comp
 
 
@@ -120,7 +120,7 @@ Vec4 accumulateLightsAndFog(Cluster cluster, Vec3 worldPos, F32 negativeZViewSpa
 	}
 	}
 
 
 	// Point lights
 	// Point lights
-	ANKI_LOOP while(cluster.m_pointLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_pointLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		const I32 idx = findLSB64(cluster.m_pointLightsMask);
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
 		cluster.m_pointLightsMask &= ~(1ul << U64(idx));
@@ -142,7 +142,7 @@ Vec4 accumulateLightsAndFog(Cluster cluster, Vec3 worldPos, F32 negativeZViewSpa
 	}
 	}
 
 
 	// Spot lights
 	// Spot lights
-	ANKI_LOOP while(cluster.m_spotLightsMask != 0u)
+	ANKI_LOOP while(cluster.m_spotLightsMask != 0ul)
 	{
 	{
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		const I32 idx = findLSB64(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));
 		cluster.m_spotLightsMask &= ~(1ul << U64(idx));

+ 3 - 3
AnKi/Util/StdTypes.h

@@ -197,10 +197,10 @@ private:
 #define ANKI_CHECK(x_) \
 #define ANKI_CHECK(x_) \
 	do \
 	do \
 	{ \
 	{ \
-		const Error error = x_; \
-		if(error) \
+		const Error retError = x_; \
+		if(retError) \
 		{ \
 		{ \
-			return error; \
+			return retError; \
 		} \
 		} \
 	} while(0)
 	} while(0)
 
 

+ 6 - 6
Tests/ShaderCompiler/ShaderProgramCompiler.cpp

@@ -213,37 +213,37 @@ layout(set = 0, binding = 0) uniform ankiMaterial
 #if PASS == 0
 #if PASS == 0
 
 
 #if DIFFUSE_TEX == 0
 #if DIFFUSE_TEX == 0
-ANKI_SPECIALIZATION_CONSTANT_VEC3(diffColor, 0);
+ANKI_SPECIALIZATION_CONSTANT_VEC3(diffColor, 0u);
 #else
 #else
 layout(set = 0, binding = 1) uniform texture2D diffTex;
 layout(set = 0, binding = 1) uniform texture2D diffTex;
 #endif
 #endif
 
 
 #if SPECULAR_TEX == 0
 #if SPECULAR_TEX == 0
-ANKI_SPECIALIZATION_CONSTANT_VEC3(specColor, 3);
+ANKI_SPECIALIZATION_CONSTANT_VEC3(specColor, 3u);
 #else
 #else
 layout(set = 0, binding = 2) uniform texture2D specTex;
 layout(set = 0, binding = 2) uniform texture2D specTex;
 #endif
 #endif
 
 
 #if ROUGHNESS_TEX == 0
 #if ROUGHNESS_TEX == 0
-ANKI_SPECIALIZATION_CONSTANT_F32(roughness, 6);
+ANKI_SPECIALIZATION_CONSTANT_F32(roughness, 6u);
 #else
 #else
 layout(set = 0, binding = 3) uniform texture2D roughnessTex;
 layout(set = 0, binding = 3) uniform texture2D roughnessTex;
 #endif
 #endif
 
 
 #if METAL_TEX == 0
 #if METAL_TEX == 0
-ANKI_SPECIALIZATION_CONSTANT_F32(metallic, 7);
+ANKI_SPECIALIZATION_CONSTANT_F32(metallic, 7u);
 #else
 #else
 layout(set = 0, binding = 4) uniform texture2D metallicTex;
 layout(set = 0, binding = 4) uniform texture2D metallicTex;
 #endif
 #endif
 
 
 #if EMISSIVE_TEX == 0
 #if EMISSIVE_TEX == 0
-ANKI_SPECIALIZATION_CONSTANT_VEC3(emission, 8, Vec3(0.0));
+ANKI_SPECIALIZATION_CONSTANT_VEC3(emission, 8u, Vec3(0.0));
 #else
 #else
 layout(set = 0, binding = 5) uniform texture2D emissiveTex;
 layout(set = 0, binding = 5) uniform texture2D emissiveTex;
 #endif
 #endif
 
 
 #if PARALLAX == 1 && LOD == 0
 #if PARALLAX == 1 && LOD == 0
-ANKI_SPECIALIZATION_CONSTANT_F32(heightMapScale, 11);
+ANKI_SPECIALIZATION_CONSTANT_F32(heightMapScale, 11u);
 layout(set = 0, binding = 6) uniform texture2D heightTex;
 layout(set = 0, binding = 6) uniform texture2D heightTex;
 #endif
 #endif
 
 

+ 2 - 0
ThirdParty/Glslang/glslang/MachineIndependent/Intermediate.cpp

@@ -1616,6 +1616,8 @@ bool TIntermediate::isFPIntegralConversion(TBasicType from, TBasicType to) const
 //
 //
 bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op) const
 bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op) const
 {
 {
+    return (from == to); // godlike: Because I like explicitness
+
     if ((isEsProfile() && version < 310 ) || version == 110)
     if ((isEsProfile() && version < 310 ) || version == 110)
         return false;
         return false;