Browse Source

Major refactoring: Moved from 80 columns to 120

Panagiotis Christopoulos Charitos 9 years ago
parent
commit
839ca8b35a
100 changed files with 603 additions and 1535 deletions
  1. 1 1
      .clang-format
  2. 1 1
      CMakeLists.txt
  3. 6 15
      samples/simple_scene/Main.cpp
  4. 8 17
      sandbox/Main.cpp
  5. 3 11
      shaders/Bloom.frag.glsl
  6. 2 8
      shaders/BloomUpscale.frag.glsl
  7. 7 22
      shaders/Clusterer.glsl
  8. 1 2
      shaders/Common.glsl
  9. 2 31
      shaders/DownscaleBlur.frag.glsl
  10. 0 7
      shaders/Final.frag.glsl
  11. 19 44
      shaders/FsCommonFrag.glsl
  12. 6 8
      shaders/FsCommonVert.glsl
  13. 0 4
      shaders/Functions.glsl
  14. 6 10
      shaders/GaussianBlurGeneric.frag.glsl
  15. 6 22
      shaders/Irradiance.frag.glsl
  16. 22 55
      shaders/Is.frag.glsl
  17. 4 8
      shaders/Is.vert.glsl
  18. 21 34
      shaders/IsFsCommon.glsl
  19. 4 5
      shaders/LfSpritePass.vert.glsl
  20. 5 10
      shaders/Light.frag.glsl
  21. 25 44
      shaders/LightFunctions.glsl
  22. 13 31
      shaders/MsCommonFrag.glsl
  23. 9 22
      shaders/MsCommonTessc.glsl
  24. 10 19
      shaders/MsCommonTesse.glsl
  25. 5 4
      shaders/MsCommonVert.glsl
  26. 6 2
      shaders/MsFsCommon.glsl
  27. 10 12
      shaders/NearDepthUpscale.frag.glsl
  28. 1 2
      shaders/NearDepthUpscale.vert.glsl
  29. 13 18
      shaders/Pack.glsl
  30. 0 8
      shaders/Pps.frag.glsl
  31. 1 2
      shaders/Quad.vert.glsl
  32. 4 8
      shaders/Ssao.frag.glsl
  33. 3 7
      shaders/Sslf.frag.glsl
  34. 2 5
      shaders/Sslr.glsl
  35. 2 6
      shaders/TilerMinMax.comp.glsl
  36. 4 11
      shaders/TmAverageLuminance.comp.glsl
  37. 1 3
      shaders/Tonemapping.glsl
  38. 2 5
      shaders/VariableSamplingBlurGeneric.frag.glsl
  39. 1 4
      shaders/Volumetric.frag.glsl
  40. 2 2
      src/anki/Collision.h
  41. 0 8
      src/anki/Config.h.cmake
  42. 8 9
      src/anki/Gr.h
  43. 2 2
      src/anki/Physics.h
  44. 4 9
      src/anki/Resource.h
  45. 0 2
      src/anki/Scene.h
  46. 31 31
      src/anki/Util.h
  47. 1 7
      src/anki/collision/Aabb.cpp
  48. 5 12
      src/anki/collision/Aabb.h
  49. 0 12
      src/anki/collision/CollisionShape.cpp
  50. 26 31
      src/anki/collision/CollisionShape.h
  51. 1 8
      src/anki/collision/CompoundShape.cpp
  52. 0 6
      src/anki/collision/CompoundShape.h
  53. 1 10
      src/anki/collision/ConvexHullShape.cpp
  54. 9 17
      src/anki/collision/ConvexHullShape.h
  55. 1 6
      src/anki/collision/ConvexShape.h
  56. 4 42
      src/anki/collision/Frustum.cpp
  57. 4 16
      src/anki/collision/Frustum.h
  58. 0 2
      src/anki/collision/Functions.cpp
  59. 7 17
      src/anki/collision/GjkEpa.cpp
  60. 3 6
      src/anki/collision/GjkEpa.h
  61. 2 4
      src/anki/collision/GjkEpaInternal.h
  62. 0 3
      src/anki/collision/LineSegment.cpp
  63. 4 10
      src/anki/collision/LineSegment.h
  64. 5 18
      src/anki/collision/Obb.cpp
  65. 3 12
      src/anki/collision/Obb.h
  66. 3 19
      src/anki/collision/Plane.cpp
  67. 17 19
      src/anki/collision/Plane.h
  68. 1 8
      src/anki/collision/Sphere.cpp
  69. 6 12
      src/anki/collision/Sphere.h
  70. 13 34
      src/anki/collision/Tests.cpp
  71. 12 41
      src/anki/core/App.cpp
  72. 2 6
      src/anki/core/App.h
  73. 1 4
      src/anki/core/Config.cpp
  74. 1 2
      src/anki/core/NativeWindow.h
  75. 2 20
      src/anki/core/NativeWindowAndroid.cpp
  76. 0 4
      src/anki/core/NativeWindowDummy.cpp
  77. 2 19
      src/anki/core/NativeWindowEglFbdev.cpp
  78. 3 10
      src/anki/core/NativeWindowSdl.cpp
  79. 1 5
      src/anki/core/StdinListener.cpp
  80. 2 4
      src/anki/core/StdinListener.h
  81. 56 82
      src/anki/core/Trace.cpp
  82. 12 17
      src/anki/core/Trace.h
  83. 1 5
      src/anki/event/AnimationEvent.cpp
  84. 1 2
      src/anki/event/AnimationEvent.h
  85. 0 7
      src/anki/event/Event.cpp
  86. 3 8
      src/anki/event/Event.h
  87. 2 13
      src/anki/event/EventManager.cpp
  88. 0 124
      src/anki/event/FollowPathEvent.cpp
  89. 0 39
      src/anki/event/FollowPathEvent.h
  90. 0 3
      src/anki/event/JitterMoveEvent.cpp
  91. 1 2
      src/anki/event/JitterMoveEvent.h
  92. 4 11
      src/anki/event/LightEvent.cpp
  93. 4 4
      src/anki/event/MainRendererPpsHdrEvent.cpp
  94. 46 102
      src/anki/gr/CommandBuffer.h
  95. 10 24
      src/anki/gr/CommandBuffer.inl.h
  96. 1 3
      src/anki/gr/Common.cpp
  97. 9 5
      src/anki/gr/Common.h
  98. 9 18
      src/anki/gr/Enums.h
  99. 4 6
      src/anki/gr/Framebuffer.h
  100. 15 23
      src/anki/gr/GrManager.h

+ 1 - 1
.clang-format

@@ -36,7 +36,7 @@ BreakBeforeBinaryOperators: NonAssignment
 BreakBeforeBraces: Custom
 BreakBeforeTernaryOperators: true
 BreakConstructorInitializersBeforeComma: true
-ColumnLimit:     80
+ColumnLimit:     120
 CommentPragmas:  '^ IWYU pragma:'
 ConstructorInitializerAllOnOneLineOrOnePerLine: false
 ConstructorInitializerIndentWidth: 4

+ 1 - 1
CMakeLists.txt

@@ -343,7 +343,7 @@ if(ANDROID)
 endif()
 
 # AnKi compiler flags (Mainly warnings)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -W -Wextra -Wstrict-aliasing -Wwrite-strings -Wunused -Wunused-variable -Wno-unused-parameter -Wundef -std=c++11 ")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -W -Wextra -Wstrict-aliasing -Wwrite-strings -Wunused -Wunused-variable -Wno-unused-parameter -Wundef -Wno-ignored-attributes -std=c++11 ")
 
 # Set platform specific
 if(LINUX)

+ 6 - 15
samples/simple_scene/Main.cpp

@@ -12,7 +12,6 @@ public:
 
 MyApp* app;
 
-//==============================================================================
 Error MyApp::init()
 {
 	// Init the super class
@@ -23,8 +22,7 @@ Error MyApp::init()
 
 	// Load the scene.lua
 	ScriptResourcePtr script;
-	ANKI_CHECK(
-		getResourceManager().loadResource("samples/assets/scene.lua", script));
+	ANKI_CHECK(getResourceManager().loadResource("samples/assets/scene.lua", script));
 	ANKI_CHECK(getScriptManager().evalString(script->getSource()));
 
 	// Input
@@ -33,13 +31,11 @@ Error MyApp::init()
 	getInput().moveCursor(Vec2(0.0));
 
 	// Some renderer stuff
-	getMainRenderer().getOffscreenRenderer().getVolumetric().setFog(
-		Vec3(1.0, 0.9, 0.9), 0.7);
+	getMainRenderer().getOffscreenRenderer().getVolumetric().setFog(Vec3(1.0, 0.9, 0.9), 0.7);
 
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 Error MyApp::userMainLoop(Bool& quit)
 {
 	const F32 MOVE_DISTANCE = 0.1;
@@ -57,8 +53,7 @@ Error MyApp::userMainLoop(Bool& quit)
 	}
 
 	// move the camera
-	static MoveComponent* mover =
-		&scene.getActiveCamera().getComponent<MoveComponent>();
+	static MoveComponent* mover = &scene.getActiveCamera().getComponent<MoveComponent>();
 
 	if(in.getKey(KeyCode::UP))
 	{
@@ -122,18 +117,15 @@ Error MyApp::userMainLoop(Bool& quit)
 
 	if(in.getMousePosition() != Vec2(0.0))
 	{
-		F32 angY = -ROTATE_ANGLE * in.getMousePosition().x() * MOUSE_SENSITIVITY
-			* getMainRenderer().getAspectRatio();
+		F32 angY = -ROTATE_ANGLE * in.getMousePosition().x() * MOUSE_SENSITIVITY * getMainRenderer().getAspectRatio();
 
 		mover->rotateLocalY(angY);
-		mover->rotateLocalX(
-			ROTATE_ANGLE * in.getMousePosition().y() * MOUSE_SENSITIVITY);
+		mover->rotateLocalX(ROTATE_ANGLE * in.getMousePosition().y() * MOUSE_SENSITIVITY);
 	}
 
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 int main(int argc, char* argv[])
 {
 	Error err = ErrorCode::NONE;
@@ -147,8 +139,7 @@ int main(int argc, char* argv[])
 
 	if(err)
 	{
-		ANKI_LOGE("Error reported. To run %s you have to navigate to the "
-				  "/path/to/anki/samples. And then execute it",
+		ANKI_LOGE("Error reported. To run %s you have to navigate to the /path/to/anki/samples. And then execute it",
 			argv[0]);
 	}
 	else

+ 8 - 17
sandbox/Main.cpp

@@ -24,13 +24,11 @@ public:
 
 MyApp* app = nullptr;
 
-//==============================================================================
 Error MyApp::init(int argc, char* argv[])
 {
 	if(argc < 3)
 	{
-		ANKI_LOGE("usage: %s /path/to/config.xml relative/path/to/scene.lua",
-			argv[0]);
+		ANKI_LOGE("usage: %s /path/to/config.xml relative/path/to/scene.lua", argv[0]);
 		return ErrorCode::USER_DATA;
 	}
 
@@ -46,8 +44,7 @@ Error MyApp::init(int argc, char* argv[])
 	MainRenderer& renderer = getMainRenderer();
 	ResourceManager& resources = getResourceManager();
 
-	renderer.getOffscreenRenderer().getVolumetric().setFog(
-		Vec3(1.0, 0.9, 0.9), 0.7);
+	renderer.getOffscreenRenderer().getVolumetric().setFog(Vec3(1.0, 0.9, 0.9), 0.7);
 
 	if(getenv("PROFILE"))
 	{
@@ -75,13 +72,11 @@ Error MyApp::init(int argc, char* argv[])
 	SceneNode& cam = scene.getActiveCamera();
 
 	PlayerNode* pnode;
-	ANKI_CHECK(scene.newSceneNode<PlayerNode>("player",
-		pnode,
-		cam.getComponent<MoveComponent>().getLocalOrigin()
-			- Vec4(0.0, 1.0, 0.0, 0.0)));
+	ANKI_CHECK(scene.newSceneNode<PlayerNode>(
+		"player", pnode, cam.getComponent<MoveComponent>().getLocalOrigin() - Vec4(0.0, 1.0, 0.0, 0.0)));
 
-	cam.getComponent<MoveComponent>().setLocalTransform(Transform(
-		Vec4(0.0), Mat3x4(Euler(toRad(0.0), toRad(180.0), toRad(0.0))), 1.0));
+	cam.getComponent<MoveComponent>().setLocalTransform(
+		Transform(Vec4(0.0), Mat3x4(Euler(toRad(0.0), toRad(180.0), toRad(0.0))), 1.0));
 
 	pnode->addChild(&cam);
 #endif
@@ -89,7 +84,6 @@ Error MyApp::init(int argc, char* argv[])
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 Error MyApp::userMainLoop(Bool& quit)
 {
 	F32 dist = 0.1;
@@ -109,8 +103,7 @@ Error MyApp::userMainLoop(Bool& quit)
 	}
 
 	// move the camera
-	static MoveComponent* mover =
-		&scene.getActiveCamera().getComponent<MoveComponent>();
+	static MoveComponent* mover = &scene.getActiveCamera().getComponent<MoveComponent>();
 
 	if(in.getKey(KeyCode::_1))
 	{
@@ -191,8 +184,7 @@ Error MyApp::userMainLoop(Bool& quit)
 #if !PLAYER && MOUSE
 	if(in.getMousePosition() != Vec2(0.0) && !m_profile)
 	{
-		F32 angY = -ang * in.getMousePosition().x() * mouseSensivity
-			* renderer.getAspectRatio();
+		F32 angY = -ang * in.getMousePosition().x() * mouseSensivity * renderer.getAspectRatio();
 
 		mover->rotateLocalY(angY);
 		mover->rotateLocalX(ang * in.getMousePosition().y() * mouseSensivity);
@@ -208,7 +200,6 @@ Error MyApp::userMainLoop(Bool& quit)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 int main(int argc, char* argv[])
 {
 	Error err = ErrorCode::NONE;

+ 3 - 11
shaders/Bloom.frag.glsl

@@ -29,18 +29,10 @@ void main()
 	out_color = textureLod(u_tex, in_texCoord, MIPMAP).rgb;
 	out_color += textureLod(u_tex, in_texCoord + TEXEL_SIZE, MIPMAP).rgb;
 	out_color += textureLod(u_tex, in_texCoord - TEXEL_SIZE, MIPMAP).rgb;
-	out_color +=
-		textureLod(
-			u_tex, in_texCoord + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), MIPMAP)
-			.rgb;
-	out_color +=
-		textureLod(
-			u_tex, in_texCoord + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), MIPMAP)
-			.rgb;
+	out_color += textureLod(u_tex, in_texCoord + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), MIPMAP).rgb;
+	out_color += textureLod(u_tex, in_texCoord + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), MIPMAP).rgb;
 
 	out_color /= 5.0;
 
-	out_color =
-		tonemap(out_color, u_averageLuminancePad3.x, u_thresholdScalePad2.x)
-		* u_thresholdScalePad2.y;
+	out_color = tonemap(out_color, u_averageLuminancePad3.x, u_thresholdScalePad2.x) * u_thresholdScalePad2.y;
 }

+ 2 - 8
shaders/BloomUpscale.frag.glsl

@@ -18,14 +18,8 @@ void main()
 	out_color = textureLod(u_tex, in_texCoord, MIPMAP).rgb;
 	out_color += textureLod(u_tex, in_texCoord + TEXEL_SIZE, MIPMAP).rgb;
 	out_color += textureLod(u_tex, in_texCoord - TEXEL_SIZE, MIPMAP).rgb;
-	out_color +=
-		textureLod(
-			u_tex, in_texCoord + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), MIPMAP)
-			.rgb;
-	out_color +=
-		textureLod(
-			u_tex, in_texCoord + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), MIPMAP)
-			.rgb;
+	out_color += textureLod(u_tex, in_texCoord + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), MIPMAP).rgb;
+	out_color += textureLod(u_tex, in_texCoord + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), MIPMAP).rgb;
 
 	out_color /= 5.0;
 }

+ 7 - 22
shaders/Clusterer.glsl

@@ -10,14 +10,9 @@
 
 #include "shaders/Common.glsl"
 
-//==============================================================================
 // Compute the cluster index using the tile index.
-uint computeClusterIndexUsingTileIdx(float near,
-	float clustererMagic,
-	float zVSpace,
-	uint tileIdx,
-	uint tileCountX,
-	uint tileCountY)
+uint computeClusterIndexUsingTileIdx(
+	float near, float clustererMagic, float zVSpace, uint tileIdx, uint tileCountX, uint tileCountY)
 {
 	float fk = sqrt((zVSpace + near) * clustererMagic);
 	uint k = uint(fk);
@@ -25,30 +20,20 @@ uint computeClusterIndexUsingTileIdx(float near,
 	return tileIdx + k * (tileCountX * tileCountY);
 }
 
-//==============================================================================
 // Compute the cluster index using the a custom gl_FragCoord.xy.
-uint computeClusterIndexUsingCustomFragCoord(float near,
-	float clustererMagic,
-	float zVSpace,
-	uint tileCountX,
-	uint tileCountY,
-	vec2 fragCoord)
+uint computeClusterIndexUsingCustomFragCoord(
+	float near, float clustererMagic, float zVSpace, uint tileCountX, uint tileCountY, vec2 fragCoord)
 {
 	// Compute tile idx
 	uvec2 f = uvec2(fragCoord) >> 6;
 	uint tileIdx = f.y * tileCountX + f.x;
 
-	return computeClusterIndexUsingTileIdx(
-		near, clustererMagic, zVSpace, tileIdx, tileCountX, tileCountY);
+	return computeClusterIndexUsingTileIdx(near, clustererMagic, zVSpace, tileIdx, tileCountX, tileCountY);
 }
 
-//==============================================================================
 // Compute the cluster index using the gl_FragCoord.xy.
-uint computeClusterIndexUsingFragCoord(float near,
-	float clustererMagic,
-	float zVSpace,
-	uint tileCountX,
-	uint tileCountY)
+uint computeClusterIndexUsingFragCoord(
+	float near, float clustererMagic, float zVSpace, uint tileCountX, uint tileCountY)
 {
 	return computeClusterIndexUsingCustomFragCoord(
 		near, clustererMagic, zVSpace, tileCountX, tileCountY, gl_FragCoord.xy);

+ 1 - 2
shaders/Common.glsl

@@ -3,8 +3,7 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
-// This file contains common code for all shaders. It's optional but it's
-// recomended to include it
+// This file contains common code for all shaders. It's optional but it's recomended to include it
 
 #ifndef ANKI_SHADERS_COMMON_GLSL
 #define ANKI_SHADERS_COMMON_GLSL

+ 2 - 31
shaders/DownscaleBlur.frag.glsl

@@ -18,37 +18,8 @@ void main()
 	out_color = textureLod(u_tex, in_uv, TEXTURE_MIPMAP).rgb;
 	out_color += textureLod(u_tex, in_uv + TEXEL_SIZE, TEXTURE_MIPMAP).rgb;
 	out_color += textureLod(u_tex, in_uv - TEXEL_SIZE, TEXTURE_MIPMAP).rgb;
-	out_color +=
-		textureLod(
-			u_tex, in_uv + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), TEXTURE_MIPMAP)
-			.rgb;
-	out_color +=
-		textureLod(
-			u_tex, in_uv + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), TEXTURE_MIPMAP)
-			.rgb;
+	out_color += textureLod(u_tex, in_uv + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), TEXTURE_MIPMAP).rgb;
+	out_color += textureLod(u_tex, in_uv + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), TEXTURE_MIPMAP).rgb;
 
-#if 0
-	out_color +=
-		textureLod(
-			u_tex, in_uv + TEXEL_SIZE2, TEXTURE_MIPMAP)
-			.rgb;
-
-	out_color +=
-		textureLod(
-			u_tex, in_uv - TEXEL_SIZE2, TEXTURE_MIPMAP)
-			.rgb;
-
-	out_color +=
-		textureLod(
-			u_tex, in_uv + vec2(-TEXEL_SIZE2.x, TEXEL_SIZE2.y), TEXTURE_MIPMAP)
-			.rgb;
-
-	out_color +=
-		textureLod(
-			u_tex, in_uv + vec2(TEXEL_SIZE2.x, -TEXEL_SIZE2.y), TEXTURE_MIPMAP)
-			.rgb;
-
-	out_color /= 9.0;
-#endif
 	out_color /= 5.0;
 }

+ 0 - 7
shaders/Final.frag.glsl

@@ -16,12 +16,5 @@ layout(location = 0) out vec3 out_color;
 void main()
 {
 	vec3 col = textureLod(u_tex, in_texCoord, 0.0).rgb;
-
-	/*vec2 depth = textureRt(u_tex, in_texCoord).rg;
-	float zNear = 0.2;
-	float zFar = 200.0;
-	depth = (2.0 * zNear) / (zFar + zNear - depth * (zFar - zNear));
-	vec3 col = vec3(depth.rg, 0.0);*/
-
 	out_color = col;
 }

+ 19 - 44
shaders/FsCommonFrag.glsl

@@ -1,7 +1,11 @@
+// Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#ifndef ANKI_SHADERS_FS_COMMON_FRAG_GLSL
+#define ANKI_SHADERS_FS_COMMON_FRAG_GLSL
+
 // Common code for all fragment shaders of BS
 #include "shaders/Common.glsl"
 #include "shaders/MsFsCommon.glsl"
@@ -24,23 +28,19 @@ layout(location = 1) flat in float in_alpha;
 
 layout(location = 0) out vec4 out_color;
 
-//==============================================================================
 #if PASS == COLOR
 #define texture_DEFINED
 #endif
 
-//==============================================================================
 #define getAlpha_DEFINED
 float getAlpha()
 {
 	return in_alpha;
 }
 
-//==============================================================================
 #define getPointCoord_DEFINED
 #define getPointCoord() gl_PointCoord
 
-//==============================================================================
 #if PASS == COLOR
 #define writeGBuffer_DEFINED
 void writeGBuffer(in vec4 color)
@@ -49,7 +49,6 @@ void writeGBuffer(in vec4 color)
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define particleAlpha_DEFINED
 void particleAlpha(in sampler2D tex, in float alpha)
@@ -60,11 +59,9 @@ void particleAlpha(in sampler2D tex, in float alpha)
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define particleSoftTextureAlpha_DEFINED
-void particleSoftTextureAlpha(
-	in sampler2D depthMap, in sampler2D tex, in float alpha)
+void particleSoftTextureAlpha(in sampler2D depthMap, in sampler2D tex, in float alpha)
 {
 	vec2 screenSize = 1.0 / RENDERER_SIZE;
 
@@ -81,7 +78,6 @@ void particleSoftTextureAlpha(
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define particleTextureAlpha_DEFINED
 void particleTextureAlpha(in sampler2D tex, in float alpha)
@@ -93,11 +89,9 @@ void particleTextureAlpha(in sampler2D tex, in float alpha)
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define particleSoftColorAlpha_DEFINED
-void particleSoftColorAlpha(
-	in sampler2D depthMap, in vec3 icolor, in float alpha)
+void particleSoftColorAlpha(in sampler2D depthMap, in vec3 icolor, in float alpha)
 {
 	vec2 screenSize = 1.0 / RENDERER_SIZE;
 
@@ -116,7 +110,6 @@ void particleSoftColorAlpha(
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define computeLightColor_DEFINED
 vec3 computeLightColor(vec3 diffCol)
@@ -127,8 +120,7 @@ vec3 computeLightColor(vec3 diffCol)
 	vec3 fragPos;
 	{
 		float depth = gl_FragCoord.z;
-		fragPos.z = u_lightingUniforms.projectionParams.z
-			/ (u_lightingUniforms.projectionParams.w + depth);
+		fragPos.z = u_lightingUniforms.projectionParams.z / (u_lightingUniforms.projectionParams.w + depth);
 
 		vec2 screenSize = 1.0 / RENDERER_SIZE;
 
@@ -141,8 +133,7 @@ vec3 computeLightColor(vec3 diffCol)
 	uint idxOffset;
 	uint idx;
 	{
-		uint clusterIdx = computeClusterIndexUsingCustomFragCoord(
-			u_lightingUniforms.nearFarClustererMagicPad1.x,
+		uint clusterIdx = computeClusterIndexUsingCustomFragCoord(u_lightingUniforms.nearFarClustererMagicPad1.x,
 			u_lightingUniforms.nearFarClustererMagicPad1.z,
 			fragPos.z,
 			u_lightingUniforms.tileCountPad1.x,
@@ -160,8 +151,7 @@ vec3 computeLightColor(vec3 diffCol)
 		COPY_POINT_LIGHT(u_pointLights[u_lightIndices[idxOffset]], light);
 		++idxOffset;
 
-		vec3 diffC =
-			computeDiffuseColor(diffCol, light.diffuseColorShadowmapId.rgb);
+		vec3 diffC = computeDiffuseColor(diffCol, light.diffuseColorShadowmapId.rgb);
 
 		vec3 frag2Light = light.posRadius.xyz - fragPos;
 		float att = computeAttenuationFactor(light.posRadius.w, frag2Light);
@@ -173,11 +163,8 @@ vec3 computeLightColor(vec3 diffCol)
 		float shadowmapLayerIdx = light.diffuseColorShadowmapId.w;
 		if(light.diffuseColorShadowmapId.w < 128.0)
 		{
-			shadow = computeShadowFactorOmni(frag2Light,
-				shadowmapLayerIdx,
-				-1.0 / light.posRadius.w,
-				u_lightingUniforms.viewMat,
-				u_omniMapArr);
+			shadow = computeShadowFactorOmni(
+				frag2Light, shadowmapLayerIdx, -1.0 / light.posRadius.w, u_lightingUniforms.viewMat, u_omniMapArr);
 		}
 #endif
 
@@ -192,18 +179,14 @@ vec3 computeLightColor(vec3 diffCol)
 		COPY_SPOT_LIGHT(u_spotLights[u_lightIndices[idxOffset]], light);
 		++idxOffset;
 
-		vec3 diffC =
-			computeDiffuseColor(diffCol, light.diffuseColorShadowmapId.rgb);
+		vec3 diffC = computeDiffuseColor(diffCol, light.diffuseColorShadowmapId.rgb);
 
 		vec3 frag2Light = light.posRadius.xyz - fragPos;
 		float att = computeAttenuationFactor(light.posRadius.w, frag2Light);
 
 		vec3 l = normalize(frag2Light);
 
-		float spot = computeSpotFactor(l,
-			light.outerCosInnerCos.x,
-			light.outerCosInnerCos.y,
-			light.lightDir.xyz);
+		float spot = computeSpotFactor(l, light.outerCosInnerCos.x, light.outerCosInnerCos.y, light.lightDir.xyz);
 
 #if LOD > 1
 		const float shadow = 1.0;
@@ -212,11 +195,7 @@ vec3 computeLightColor(vec3 diffCol)
 		float shadowmapLayerIdx = light.diffuseColorShadowmapId.w;
 		if(shadowmapLayerIdx < 128.0)
 		{
-			shadow = computeShadowFactorSpot(light.texProjectionMat,
-				fragPos,
-				shadowmapLayerIdx,
-				1,
-				u_spotMapArr);
+			shadow = computeShadowFactorSpot(light.texProjectionMat, fragPos, shadowmapLayerIdx, 1, u_spotMapArr);
 		}
 #endif
 
@@ -227,7 +206,6 @@ vec3 computeLightColor(vec3 diffCol)
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define particleTextureAlphaLight_DEFINED
 void particleTextureAlphaLight(in sampler2D tex, in float alpha)
@@ -241,14 +219,11 @@ void particleTextureAlphaLight(in sampler2D tex, in float alpha)
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define particleAnimatedTextureAlphaLight_DEFINED
-void particleAnimatedTextureAlphaLight(
-	sampler2DArray tex, float alpha, float layerCount, float period)
+void particleAnimatedTextureAlphaLight(sampler2DArray tex, float alpha, float layerCount, float period)
 {
-	vec4 color = readAnimatedTextureRgba(
-		tex, layerCount, period, gl_PointCoord, anki_u_time);
+	vec4 color = readAnimatedTextureRgba(tex, layerCount, period, gl_PointCoord, anki_u_time);
 	color.a *= alpha;
 
 	color.rgb = computeLightColor(color.rgb);
@@ -257,7 +232,6 @@ void particleAnimatedTextureAlphaLight(
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define fog_DEFINED
 void fog(in sampler2D depthMap, in vec3 color, in float fogScale)
@@ -272,8 +246,7 @@ void fog(in sampler2D depthMap, in vec3 color, in float fogScale)
 	{
 		float zNear = u_lightingUniforms.nearFarClustererMagicPad1.x;
 		float zFar = u_lightingUniforms.nearFarClustererMagicPad1.y;
-		vec2 linearDepths = (2.0 * zNear)
-			/ (zFar + zNear - vec2(depth, gl_FragCoord.z) * (zFar - zNear));
+		vec2 linearDepths = (2.0 * zNear) / (zFar + zNear - vec2(depth, gl_FragCoord.z) * (zFar - zNear));
 
 		diff = linearDepths.x - linearDepths.y;
 	}
@@ -287,3 +260,5 @@ void fog(in sampler2D depthMap, in vec3 color, in float fogScale)
 	writeGBuffer(vec4(color, diff * fogScale));
 }
 #endif
+
+#endif

+ 6 - 8
shaders/FsCommonVert.glsl

@@ -3,6 +3,9 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#ifndef ANKI_SHADERS_FS_COMMON_VERT_GLSL
+#define ANKI_SHADERS_FS_COMMON_VERT_GLSL
+
 // Common code for all vertex shaders of FS
 #include "shaders/MsFsCommon.glsl"
 
@@ -30,47 +33,42 @@ out gl_PerVertex
 	float gl_PointSize;
 };
 
-//==============================================================================
 #define setPositionVec3_DEFINED
 void setPositionVec3(in vec3 pos)
 {
 	gl_Position = vec4(pos, 1.0);
 }
 
-//==============================================================================
 #define setPositionVec4_DEFINED
 void setPositionVec4(in vec4 pos)
 {
 	gl_Position = pos;
 }
 
-//==============================================================================
 #define writePositionMvp_DEFINED
 void writePositionMvp(in mat4 mvp)
 {
 	gl_Position = mvp * vec4(in_position, 1.0);
 }
 
-//==============================================================================
 #define particle_DEFINED
 void particle(in mat4 mvp)
 {
 	gl_Position = mvp * vec4(in_position, 1);
 	out_alpha = in_alpha;
-	gl_PointSize = in_scale * u_lightingUniforms.rendererSizeTimePad1.x * 0.5
-		/ gl_Position.w;
+	gl_PointSize = in_scale * u_lightingUniforms.rendererSizeTimePad1.x * 0.5 / gl_Position.w;
 }
 
-//==============================================================================
 #define writeAlpha_DEFINED
 void writeAlpha(in float alpha)
 {
 	out_alpha = alpha;
 }
 
-//==============================================================================
 #define writeVertPosViewSpace_DEFINED
 void writeVertPosViewSpace(in mat4 modelViewMat)
 {
 	out_vertPosViewSpace = vec3(modelViewMat * vec4(in_position, 1.0));
 }
+
+#endif

+ 0 - 4
shaders/Functions.glsl

@@ -6,7 +6,6 @@
 #ifndef ANKI_SHADERS_FUNCTIONS_GLSL
 #define ANKI_SHADERS_FUNCTIONS_GLSL
 
-//==============================================================================
 vec3 dither(in vec3 col, in float C)
 {
 	vec3 vDither = vec3(dot(vec2(171.0, 231.0), gl_FragCoord.xy));
@@ -19,7 +18,6 @@ vec3 dither(in vec3 col, in float C)
 	return col;
 }
 
-//==============================================================================
 float dither(in float col, in float C)
 {
 	float vDither = dot(vec2(171.0, 231.0), gl_FragCoord.xy);
@@ -32,14 +30,12 @@ float dither(in float col, in float C)
 	return col;
 }
 
-//==============================================================================
 // Convert to linear depth
 float linearizeDepth(in float depth, in float zNear, in float zFar)
 {
 	return (2.0 * zNear) / (zFar + zNear - depth * (zFar - zNear));
 }
 
-//==============================================================================
 // This is the optimal linearizeDepth where a=(f+n)/2n and b=(n-f)/2n
 float linearizeDepthOptimal(in float depth, in float a, in float b)
 {

+ 6 - 10
shaders/GaussianBlurGeneric.frag.glsl

@@ -70,16 +70,12 @@ const float WEIGHTS[STEP_COUNT] = {0.19955, 0.18945, 0.08376, 0.02321, 0.00403};
 const float OFFSETS[STEP_COUNT] = {0.65319, 2.42547, 4.36803, 6.31412, 8.26479};
 #elif KERNEL_SIZE == 23
 const uint STEP_COUNT = 6u;
-const float WEIGHTS[STEP_COUNT] = {
-	0.16501, 0.17507, 0.10112, 0.04268, 0.01316, 0.00296};
-const float OFFSETS[STEP_COUNT] = {
-	0.65772, 2.45017, 4.41096, 6.37285, 8.33626, 10.30153};
+const float WEIGHTS[STEP_COUNT] = {0.16501, 0.17507, 0.10112, 0.04268, 0.01316, 0.00296};
+const float OFFSETS[STEP_COUNT] = {0.65772, 2.45017, 4.41096, 6.37285, 8.33626, 10.30153};
 #elif KERNEL_SIZE == 27
 const int STEP_COUNT = 7;
-const float WEIGHTS[STEP_COUNT] = {
-	0.14090, 0.15927, 0.10715, 0.05747, 0.02457, 0.00837, 0.00228};
-const float OFFSETS[STEP_COUNT] = {
-	0.66025, 2.46415, 4.43572, 6.40771, 8.38028, 10.35359, 12.32779};
+const float WEIGHTS[STEP_COUNT] = {0.14090, 0.15927, 0.10715, 0.05747, 0.02457, 0.00837, 0.00228};
+const float OFFSETS[STEP_COUNT] = {0.66025, 2.46415, 4.43572, 6.40771, 8.38028, 10.35359, 12.32779};
 #else
 #error See file
 #endif
@@ -96,8 +92,8 @@ void main()
 	for(uint i = 0; i < STEP_COUNT; ++i)
 	{
 		vec2 texCoordOffset = OFFSETS[i] * TEXEL_SIZE;
-		COL_TYPE col = texture(u_tex, in_uv + texCoordOffset).TEX_FETCH
-			+ texture(u_tex, in_uv - texCoordOffset).TEX_FETCH;
+		COL_TYPE col =
+			texture(u_tex, in_uv + texCoordOffset).TEX_FETCH + texture(u_tex, in_uv - texCoordOffset).TEX_FETCH;
 		out_color += WEIGHTS[i] * col;
 	}
 }

+ 6 - 22
shaders/Irradiance.frag.glsl

@@ -19,29 +19,13 @@ layout(ANKI_UBO_BINDING(0, 0)) uniform u0_
 	uvec4 u_faceIdxArrayIdxPad2;
 };
 
-const mat3 CUBE_ROTATIONS[6] = mat3[](mat3(vec3(0.000000, 0.000000, -1.000000),
-										  vec3(0.000000, -1.000000, 0.000000),
-										  vec3(-1.000000, 0.000000, 0.000000)),
+const mat3 CUBE_ROTATIONS[6] = mat3[](mat3(vec3(0.0, 0.0, -1.0), vec3(0.0, -1.0, 0.0), vec3(-1.0, 0.0, 0.0)),
+	mat3(vec3(0.0, 0.0, 1.0), vec3(0.0, -1.0, 0.0), vec3(1.0, 0.0, 0.0)),
+	mat3(vec3(1.0, 0.0, -0.0), vec3(0.0, -0.0, 1.0), vec3(0.0, -1.0, -0.0)),
+	mat3(vec3(1.0, 0.0, -0.0), vec3(0.0, -0.0, -1.0), vec3(-0.0, 1.0, -0.0)),
+	mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0), vec3(0.0, 0.0, -1.0)),
+	mat3(vec3(-1.0, -0.0, 0.0), vec3(0.0, -1.0, 0.0), vec3(0.0, 0.0, 1.0)));
 
-	mat3(vec3(0.000000, 0.000000, 1.000000),
-										  vec3(0.000000, -1.000000, 0.000000),
-										  vec3(1.000000, 0.000000, 0.000000)),
-
-	mat3(vec3(1.000000, 0.000000, -0.000000),
-										  vec3(0.000000, -0.000000, 1.000000),
-										  vec3(0.000000, -1.000000, -0.000000)),
-
-	mat3(vec3(1.000000, 0.000000, -0.000000),
-										  vec3(0.000000, -0.000000, -1.000000),
-										  vec3(-0.000000, 1.000000, -0.000000)),
-	mat3(vec3(1.000000, 0.000000, 0.000000),
-										  vec3(0.000000, -1.000000, 0.000000),
-										  vec3(0.000000, 0.000000, -1.000000)),
-	mat3(vec3(-1.000000, -0.000000, 0.000000),
-										  vec3(0.000000, -1.000000, 0.000000),
-										  vec3(0.000000, 0.000000, 1.000000)));
-
-//==============================================================================
 // Integrate the environment map to compute the irradiance for a single fragment
 void main()
 {

+ 22 - 55
shaders/Is.frag.glsl

@@ -30,45 +30,37 @@ layout(location = 0) out vec3 out_color;
 
 const uint TILE_COUNT = TILE_COUNT_X * TILE_COUNT_Y;
 
-//==============================================================================
 // Return frag pos in view space
 vec3 getFragPosVSpace()
 {
 	float depth = textureRt(u_msDepthRt, in_texCoord).r;
 
 	vec3 fragPos;
-	fragPos.z = u_lightingUniforms.projectionParams.z
-		/ (u_lightingUniforms.projectionParams.w + depth);
+	fragPos.z = u_lightingUniforms.projectionParams.z / (u_lightingUniforms.projectionParams.w + depth);
 	fragPos.xy = in_projectionParams * fragPos.z;
 
 	return fragPos;
 }
 
-//==============================================================================
 // Common code for lighting
 
-#define LIGHTING_COMMON_BRDF()                                                 \
-	vec3 frag2Light = light.posRadius.xyz - fragPos;                           \
-	vec3 l = normalize(frag2Light);                                            \
-	float nol = max(0.0, dot(normal, l));                                      \
-	vec3 specC = computeSpecularColorBrdf(                                     \
-		viewDir, l, normal, specCol, light.specularColorTexId.rgb, a2, nol);   \
-	vec3 diffC =                                                               \
-		computeDiffuseColor(diffCol, light.diffuseColorShadowmapId.rgb);       \
-	float att = computeAttenuationFactor(light.posRadius.w, frag2Light);       \
+#define LIGHTING_COMMON_BRDF()                                                                                         \
+	vec3 frag2Light = light.posRadius.xyz - fragPos;                                                                   \
+	vec3 l = normalize(frag2Light);                                                                                    \
+	float nol = max(0.0, dot(normal, l));                                                                              \
+	vec3 specC = computeSpecularColorBrdf(viewDir, l, normal, specCol, light.specularColorTexId.rgb, a2, nol);         \
+	vec3 diffC = computeDiffuseColor(diffCol, light.diffuseColorShadowmapId.rgb);                                      \
+	float att = computeAttenuationFactor(light.posRadius.w, frag2Light);                                               \
 	float lambert = nol;
 
-//==============================================================================
 void debugIncorrectColor(inout vec3 c)
 {
-	if(isnan(c.x) || isnan(c.y) || isnan(c.z) || isinf(c.x) || isinf(c.y)
-		|| isinf(c.z))
+	if(isnan(c.x) || isnan(c.y) || isnan(c.z) || isinf(c.x) || isinf(c.y) || isinf(c.z))
 	{
 		c = vec3(1.0, 0.0, 1.0);
 	}
 }
 
-//==============================================================================
 void readIndirect(in uint idxOffset,
 	in vec3 posVSpace,
 	in vec3 r,
@@ -85,8 +77,7 @@ void readIndirect(in uint idxOffset,
 	while(count-- != 0)
 	{
 		ReflectionProbe probe;
-		COPY_REFLECTION_PROBE(
-			u_reflectionProbes[u_lightIndices[idxOffset]], probe);
+		COPY_REFLECTION_PROBE(u_reflectionProbes[u_lightIndices[idxOffset]], probe);
 		++idxOffset;
 
 		float R2 = probe.positionRadiusSq.w;
@@ -96,8 +87,7 @@ void readIndirect(in uint idxOffset,
 		vec3 f = posVSpace - center;
 
 		// Cubemap UV in view space
-		vec3 uv = computeCubemapVecAccurate(
-			r, R2, f, u_lightingUniforms.invViewRotation);
+		vec3 uv = computeCubemapVecAccurate(r, R2, f, u_lightingUniforms.invViewRotation);
 
 		// Read!
 		float cubemapIndex = probe.cubemapIndexPad3.x;
@@ -111,21 +101,12 @@ void readIndirect(in uint idxOffset,
 		// Same as: specIndirect = c * (1.0 - factor) + specIndirect * factor
 
 		// Do the same for diffuse
-		uv = computeCubemapVecCheap(
-			n, R2, f, u_lightingUniforms.invViewRotation);
+		uv = computeCubemapVecCheap(n, R2, f, u_lightingUniforms.invViewRotation);
 		vec3 id = texture(u_irradianceTex, vec4(uv, cubemapIndex)).rgb;
 		diffIndirect = mix(id, diffIndirect, factor);
 	}
 }
 
-bool getNewIndex(inout uint idxOffset, out uint idx)
-{
-	idx = u_lightIndices[idxOffset];
-	++idxOffset;
-	return idx != MAX_U32;
-}
-
-//==============================================================================
 void main()
 {
 	// Get frag pos in view space
@@ -157,8 +138,7 @@ void main()
 	out_color = diffCol * emission;
 
 	// Get counts and offsets
-	uint clusterIdx = computeClusterIndexUsingTileIdx(
-		u_lightingUniforms.nearFarClustererMagicPad1.x,
+	uint clusterIdx = computeClusterIndexUsingTileIdx(u_lightingUniforms.nearFarClustererMagicPad1.x,
 		u_lightingUniforms.nearFarClustererMagicPad1.z,
 		fragPos.z,
 		in_instanceId,
@@ -169,8 +149,7 @@ void main()
 	uint idx;
 
 	// Shadowpass sample count
-	uint shadowSampleCount =
-		computeShadowSampleCount(SHADOW_SAMPLE_COUNT, fragPos.z);
+	uint shadowSampleCount = computeShadowSampleCount(SHADOW_SAMPLE_COUNT, fragPos.z);
 
 	// Point lights
 	uint count = u_lightIndices[idxOffset++];
@@ -186,17 +165,13 @@ void main()
 		float shadowmapLayerIdx = light.diffuseColorShadowmapId.w;
 		if(light.diffuseColorShadowmapId.w < 128.0)
 		{
-			shadow = computeShadowFactorOmni(frag2Light,
-				shadowmapLayerIdx,
-				1.0 / sqrt(light.posRadius.w),
-				u_lightingUniforms.viewMat,
-				u_omniMapArr);
+			shadow = computeShadowFactorOmni(
+				frag2Light, shadowmapLayerIdx, 1.0 / sqrt(light.posRadius.w), u_lightingUniforms.viewMat, u_omniMapArr);
 
 			shadow = dither(shadow, 64.0);
 		}
 
-		out_color +=
-			(specC + diffC) * (att * max(subsurface, lambert * shadow));
+		out_color += (specC + diffC) * (att * max(subsurface, lambert * shadow));
 	}
 
 	// Spot lights
@@ -209,26 +184,19 @@ void main()
 
 		LIGHTING_COMMON_BRDF();
 
-		float spot = computeSpotFactor(l,
-			light.outerCosInnerCos.x,
-			light.outerCosInnerCos.y,
-			light.lightDir.xyz);
+		float spot = computeSpotFactor(l, light.outerCosInnerCos.x, light.outerCosInnerCos.y, light.lightDir.xyz);
 
 		float shadow = 1.0;
 		float shadowmapLayerIdx = light.diffuseColorShadowmapId.w;
 		if(shadowmapLayerIdx < 128.0)
 		{
-			shadow = computeShadowFactorSpot(light.texProjectionMat,
-				fragPos,
-				shadowmapLayerIdx,
-				shadowSampleCount,
-				u_spotMapArr);
+			shadow = computeShadowFactorSpot(
+				light.texProjectionMat, fragPos, shadowmapLayerIdx, shadowSampleCount, u_spotMapArr);
 
 			shadow = dither(shadow, 64.0);
 		}
 
-		out_color +=
-			(diffC + specC) * (att * spot * max(subsurface, lambert * shadow));
+		out_color += (diffC + specC) * (att * spot * max(subsurface, lambert * shadow));
 	}
 
 #if INDIRECT_ENABLED
@@ -237,8 +205,7 @@ void main()
 	float reflLod = float(IR_MIPMAP_COUNT) * gbuffer.roughness;
 
 	vec3 specIndirect, diffIndirect;
-	readIndirect(
-		idxOffset, fragPos, r, normal, reflLod, specIndirect, diffIndirect);
+	readIndirect(idxOffset, fragPos, r, normal, reflLod, specIndirect, diffIndirect);
 
 	diffIndirect *= gbuffer.diffuse;
 

+ 4 - 8
shaders/Is.vert.glsl

@@ -21,18 +21,14 @@ void main()
 {
 	float instIdF = float(gl_InstanceID);
 
-	vec2 ij = vec2(mod(instIdF, float(TILE_COUNT_X)),
-		floor(instIdF / float(TILE_COUNT_X)));
+	vec2 ij = vec2(mod(instIdF, float(TILE_COUNT_X)), floor(instIdF / float(TILE_COUNT_X)));
 
 	out_instanceId = int(gl_InstanceID);
 
-	const vec2 SIZES =
-		vec2(1.0 / float(TILE_COUNT_X), 1.0 / float(TILE_COUNT_Y));
+	const vec2 SIZES = vec2(1.0 / float(TILE_COUNT_X), 1.0 / float(TILE_COUNT_Y));
 
-	const vec2 UVS[4] = vec2[](vec2(0.0, 0.0) * SIZES,
-		vec2(1.0, 0.0) * SIZES,
-		vec2(0.0, 1.0) * SIZES,
-		vec2(1.0, 1.0) * SIZES);
+	const vec2 UVS[4] =
+		vec2[](vec2(0.0, 0.0) * SIZES, vec2(1.0, 0.0) * SIZES, vec2(0.0, 1.0) * SIZES, vec2(1.0, 1.0) * SIZES);
 
 	out_texCoord = UVS[gl_VertexID] + ij * SIZES;
 	vec2 pos = out_texCoord * 2.0 - 1.0;

+ 21 - 34
shaders/IsFsCommon.glsl

@@ -28,9 +28,9 @@ struct PointLight
 };
 
 // WORKAROUND: See glslang issue 304
-#define COPY_POINT_LIGHT(src_, dst_)                                           \
-	dst_.posRadius = src_.posRadius;                                           \
-	dst_.diffuseColorShadowmapId = src_.diffuseColorShadowmapId;               \
+#define COPY_POINT_LIGHT(src_, dst_)                                                                                   \
+	dst_.posRadius = src_.posRadius;                                                                                   \
+	dst_.diffuseColorShadowmapId = src_.diffuseColorShadowmapId;                                                       \
 	dst_.specularColorTexId = src_.specularColorTexId
 
 // Spot light
@@ -45,12 +45,12 @@ struct SpotLight
 };
 
 // WORKAROUND: See glslang issue 304
-#define COPY_SPOT_LIGHT(src_, dst_)                                            \
-	dst_.posRadius = src_.posRadius;                                           \
-	dst_.diffuseColorShadowmapId = src_.diffuseColorShadowmapId;               \
-	dst_.specularColorTexId = src_.specularColorTexId;                         \
-	dst_.lightDir = src_.lightDir;                                             \
-	dst_.outerCosInnerCos = src_.outerCosInnerCos;                             \
+#define COPY_SPOT_LIGHT(src_, dst_)                                                                                    \
+	dst_.posRadius = src_.posRadius;                                                                                   \
+	dst_.diffuseColorShadowmapId = src_.diffuseColorShadowmapId;                                                       \
+	dst_.specularColorTexId = src_.specularColorTexId;                                                                 \
+	dst_.lightDir = src_.lightDir;                                                                                     \
+	dst_.outerCosInnerCos = src_.outerCosInnerCos;                                                                     \
 	dst_.texProjectionMat = src_.texProjectionMat
 
 // Representation of a reflection probe
@@ -64,13 +64,11 @@ struct ReflectionProbe
 };
 
 // WORKAROUND: See glslang issue 304
-#define COPY_REFLECTION_PROBE(src_, dst_)                                      \
-	dst_.positionRadiusSq = src_.positionRadiusSq;                             \
+#define COPY_REFLECTION_PROBE(src_, dst_)                                                                              \
+	dst_.positionRadiusSq = src_.positionRadiusSq;                                                                     \
 	dst_.cubemapIndexPad3.x = src_.cubemapIndexPad3.x
 
-layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING),
-	std140,
-	row_major) uniform u0_
+layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING), std140, row_major) uniform u0_
 {
 	LightingUniforms u_lightingUniforms;
 };
@@ -82,45 +80,34 @@ layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 1), std140) uniform u1_
 	PointLight u_pointLights[UBO_MAX_SIZE / (3 * 4 * 4)];
 };
 
-layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 2),
-	std140,
-	row_major) uniform u2_
+layout(ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 2), std140, row_major) uniform u2_
 {
 	SpotLight u_spotLights[UBO_MAX_SIZE / (9 * 4 * 4)];
 };
 
-layout(std140,
-	row_major,
-	ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 3)) uniform u3_
+layout(std140, row_major, ANKI_UBO_BINDING(LIGHT_SET, LIGHT_UBO_BINDING + 3)) uniform u3_
 {
 	ReflectionProbe u_reflectionProbes[UBO_MAX_SIZE / (2 * 4 * 4)];
 };
 
-layout(ANKI_SS_BINDING(LIGHT_SET, LIGHT_SS_BINDING + 0),
-	std430) readonly buffer s0_
+layout(ANKI_SS_BINDING(LIGHT_SET, LIGHT_SS_BINDING + 0), std430) readonly buffer s0_
 {
 	uint u_clusters[];
 };
 
-layout(std430,
-	ANKI_SS_BINDING(LIGHT_SET, LIGHT_SS_BINDING + 1)) readonly buffer s1_
+layout(std430, ANKI_SS_BINDING(LIGHT_SET, LIGHT_SS_BINDING + 1)) readonly buffer s1_
 {
 	uint u_lightIndices[];
 };
 
-layout(ANKI_TEX_BINDING(LIGHT_SET,
-	LIGHT_TEX_BINDING)) uniform highp sampler2DArrayShadow u_spotMapArr;
-layout(ANKI_TEX_BINDING(LIGHT_SET,
-	LIGHT_TEX_BINDING + 1)) uniform highp samplerCubeArrayShadow u_omniMapArr;
+layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING)) uniform highp sampler2DArrayShadow u_spotMapArr;
+layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 1)) uniform highp samplerCubeArrayShadow u_omniMapArr;
 
-layout(ANKI_TEX_BINDING(LIGHT_SET,
-	LIGHT_TEX_BINDING + 2)) uniform samplerCubeArray u_reflectionsTex;
+layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 2)) uniform samplerCubeArray u_reflectionsTex;
 
-layout(ANKI_TEX_BINDING(
-	LIGHT_SET, LIGHT_TEX_BINDING + 3)) uniform samplerCubeArray u_irradianceTex;
+layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 3)) uniform samplerCubeArray u_irradianceTex;
 
-layout(ANKI_TEX_BINDING(
-	LIGHT_SET, LIGHT_TEX_BINDING + 4)) uniform sampler2D u_integrationLut;
+layout(ANKI_TEX_BINDING(LIGHT_SET, LIGHT_TEX_BINDING + 4)) uniform sampler2D u_integrationLut;
 
 #endif // FRAGMENT_SHADER
 

+ 4 - 5
shaders/LfSpritePass.vert.glsl

@@ -16,9 +16,9 @@ struct Sprite
 };
 
 // WORKAROUND: See glslang issue 304
-#define COPY_SPRITE(src_, dst_)                                                \
-	dst_.posScale = src_.posScale;                                             \
-	dst_.color = src_.color;                                                   \
+#define COPY_SPRITE(src_, dst_)                                                                                        \
+	dst_.posScale = src_.posScale;                                                                                     \
+	dst_.color = src_.color;                                                                                           \
 	dst_.depthPad3.x = src_.depthPad3.x
 
 // The block contains data for all flares
@@ -37,8 +37,7 @@ out gl_PerVertex
 
 void main()
 {
-	const vec2 POSITIONS[4] = vec2[](
-		vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0));
+	const vec2 POSITIONS[4] = vec2[](vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0), vec2(1.0, 1.0));
 
 	vec2 position = POSITIONS[gl_VertexID];
 

+ 5 - 10
shaders/Light.frag.glsl

@@ -56,11 +56,9 @@ vec3 readPosition(in vec2 uv)
 	vec3 fragPosVspace;
 
 	float depth = texture(u_msDepthRt, uv).r;
-	fragPosVspace.z =
-		u_light.projectionParams.z / (u_light.projectionParams.w + depth);
+	fragPosVspace.z = u_light.projectionParams.z / (u_light.projectionParams.w + depth);
 
-	fragPosVspace.xy =
-		(2.0 * uv - 1.0) * u_light.projectionParams.xy * fragPosVspace.z;
+	fragPosVspace.xy = (2.0 * uv - 1.0) * u_light.projectionParams.xy * fragPosVspace.z;
 
 	return fragPosVspace;
 }
@@ -80,8 +78,7 @@ void main()
 	vec3 l = normalize(frag2Light);
 	float nol = max(0.0, dot(gbuffer.normal, l));
 
-	vec3 specC = computeSpecularColorBrdf(
-		viewDir, l, gbuffer.normal, gbuffer.specular, u_lspec, a2, nol);
+	vec3 specC = computeSpecularColorBrdf(viewDir, l, gbuffer.normal, gbuffer.specular, u_lspec, a2, nol);
 
 	vec3 diffC = computeDiffuseColor(gbuffer.diffuse, u_ldiff);
 
@@ -91,10 +88,8 @@ void main()
 #if defined(POINT_LIGHT)
 	out_color = (specC + diffC) * (att * lambert);
 #else
-	float spot = computeSpotFactor(l,
-		u_light.diffuseColorOuterCos.w,
-		u_light.specularColorInnerCos.w,
-		u_light.lightDirPad1.xyz);
+	float spot =
+		computeSpotFactor(l, u_light.diffuseColorOuterCos.w, u_light.specularColorInnerCos.w, u_light.lightDirPad1.xyz);
 
 	out_color = (diffC + specC) * (att * spot * lambert);
 #endif

+ 25 - 44
shaders/LightFunctions.glsl

@@ -15,7 +15,6 @@ const float OMNI_LIGHT_FRUSTUM_NEAR_PLANE = 0.1 / 4.0;
 
 const uint SHADOW_SAMPLE_COUNT = 16;
 
-//==============================================================================
 float computeAttenuationFactor(float lightRadius, vec3 frag2Light)
 {
 	float fragLightDist = dot(frag2Light, frag2Light);
@@ -24,7 +23,6 @@ float computeAttenuationFactor(float lightRadius, vec3 frag2Light)
 	return att * att;
 }
 
-//==============================================================================
 // Performs BRDF specular lighting
 vec3 computeSpecularColorBrdf(vec3 v, // view dir
 	vec3 l, // light dir
@@ -43,8 +41,7 @@ vec3 computeSpecularColorBrdf(vec3 v, // view dir
 	vec3 F = specCol + (1.0 - specCol) * pow((1.0 + EPSILON - loh), 5.0);
 #else
 	// Unreal
-	vec3 F =
-		specCol + (1.0 - specCol) * pow(2.0, (-5.55473 * voh - 6.98316) * voh);
+	vec3 F = specCol + (1.0 - specCol) * pow(2.0, (-5.55473 * voh - 6.98316) * voh);
 #endif
 
 	// D(n,h) aka NDF: GGX Trowbridge-Reitz
@@ -72,13 +69,11 @@ vec3 computeSpecularColorBrdf(vec3 v, // view dir
 	return F * (V * D) * lightSpecCol;
 }
 
-//==============================================================================
 vec3 computeDiffuseColor(vec3 diffCol, vec3 lightDiffCol)
 {
 	return diffCol * lightDiffCol;
 }
 
-//==============================================================================
 float computeSpotFactor(vec3 l, float outerCos, float innerCos, vec3 spotDir)
 {
 	float costheta = -dot(l, spotDir);
@@ -86,7 +81,6 @@ float computeSpotFactor(vec3 l, float outerCos, float innerCos, vec3 spotDir)
 	return spotFactor;
 }
 
-//==============================================================================
 uint computeShadowSampleCount(const uint COUNT, float zVSpace)
 {
 	const float MAX_DISTANCE = 5.0;
@@ -99,34 +93,29 @@ uint computeShadowSampleCount(const uint COUNT, float zVSpace)
 	return sampleCount;
 }
 
-//==============================================================================
-float computeShadowFactorSpot(mat4 lightProjectionMat,
-	vec3 fragPos,
-	float layer,
-	uint sampleCount,
-	sampler2DArrayShadow spotMapArr)
+float computeShadowFactorSpot(
+	mat4 lightProjectionMat, vec3 fragPos, float layer, uint sampleCount, sampler2DArrayShadow spotMapArr)
 {
 	vec4 texCoords4 = lightProjectionMat * vec4(fragPos, 1.0);
 	vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
 
 #if POISSON == 1
-	const vec2 poissonDisk[SHADOW_SAMPLE_COUNT] =
-		vec2[](vec2(0.751688, 0.619709) * 2.0 - 1.0,
-			vec2(0.604741, 0.778485) * 2.0 - 1.0,
-			vec2(0.936216, 0.463094) * 2.0 - 1.0,
-			vec2(0.808758, 0.284966) * 2.0 - 1.0,
-			vec2(0.812927, 0.786332) * 2.0 - 1.0,
-			vec2(0.608651, 0.303919) * 2.0 - 1.0,
-			vec2(0.482117, 0.573285) * 2.0 - 1.0,
-			vec2(0.55819, 0.988451) * 2.0 - 1.0,
-			vec2(0.340001, 0.728732) * 2.0 - 1.0,
-			vec2(0.681775, 0.119789) * 2.0 - 1.0,
-			vec2(0.217429, 0.522558) * 2.0 - 1.0,
-			vec2(0.384257, 0.352163) * 2.0 - 1.0,
-			vec2(0.143769, 0.738606) * 2.0 - 1.0,
-			vec2(0.383474, 0.910019) * 2.0 - 1.0,
-			vec2(0.409305, 0.177022) * 2.0 - 1.0,
-			vec2(0.158647, 0.239097) * 2.0 - 1.0);
+	const vec2 poissonDisk[SHADOW_SAMPLE_COUNT] = vec2[](vec2(0.751688, 0.619709) * 2.0 - 1.0,
+		vec2(0.604741, 0.778485) * 2.0 - 1.0,
+		vec2(0.936216, 0.463094) * 2.0 - 1.0,
+		vec2(0.808758, 0.284966) * 2.0 - 1.0,
+		vec2(0.812927, 0.786332) * 2.0 - 1.0,
+		vec2(0.608651, 0.303919) * 2.0 - 1.0,
+		vec2(0.482117, 0.573285) * 2.0 - 1.0,
+		vec2(0.55819, 0.988451) * 2.0 - 1.0,
+		vec2(0.340001, 0.728732) * 2.0 - 1.0,
+		vec2(0.681775, 0.119789) * 2.0 - 1.0,
+		vec2(0.217429, 0.522558) * 2.0 - 1.0,
+		vec2(0.384257, 0.352163) * 2.0 - 1.0,
+		vec2(0.143769, 0.738606) * 2.0 - 1.0,
+		vec2(0.383474, 0.910019) * 2.0 - 1.0,
+		vec2(0.409305, 0.177022) * 2.0 - 1.0,
+		vec2(0.158647, 0.239097) * 2.0 - 1.0);
 
 	float shadowFactor = 0.0;
 
@@ -149,12 +138,8 @@ float computeShadowFactorSpot(mat4 lightProjectionMat,
 #endif
 }
 
-//==============================================================================
-float computeShadowFactorOmni(in vec3 frag2Light,
-	in float layer,
-	in float radius,
-	in mat4 viewMat,
-	in samplerCubeArrayShadow omniMapArr)
+float computeShadowFactorOmni(
+	in vec3 frag2Light, in float layer, in float radius, in mat4 viewMat, in samplerCubeArrayShadow omniMapArr)
 {
 	vec3 dir = (viewMat * vec4(-frag2Light, 1.0)).xyz;
 	vec3 dirabs = abs(dir);
@@ -177,11 +162,9 @@ float computeShadowFactorOmni(in vec3 frag2Light,
 	return shadowFactor;
 }
 
-//==============================================================================
-// Compute the cubemap texture lookup vector given the reflection vector (r)
-// the radius squared of the probe (R2) and the frag pos in sphere space (f)
-vec3 computeCubemapVecAccurate(
-	in vec3 r, in float R2, in vec3 f, in mat3 invViewRotation)
+// Compute the cubemap texture lookup vector given the reflection vector (r) the radius squared of the probe (R2) and
+// the frag pos in sphere space (f)
+vec3 computeCubemapVecAccurate(in vec3 r, in float R2, in vec3 f, in mat3 invViewRotation)
 {
 	// Compute the collision of the r to the inner part of the sphere
 	// From now on we work on the sphere's space
@@ -205,10 +188,8 @@ vec3 computeCubemapVecAccurate(
 	return uv;
 }
 
-//==============================================================================
 // Cheap version of computeCubemapVecAccurate
-vec3 computeCubemapVecCheap(
-	in vec3 r, in float R2, in vec3 f, in mat3 invViewRotation)
+vec3 computeCubemapVecCheap(in vec3 r, in float R2, in vec3 f, in mat3 invViewRotation)
 {
 	return invViewRotation * r;
 }

+ 13 - 31
shaders/MsCommonFrag.glsl

@@ -12,10 +12,6 @@ layout(early_fragment_tests) in;
 #include "shaders/Pack.glsl"
 #include "shaders/MsFsCommon.glsl"
 
-//==============================================================================
-// Variables                                                                   =
-//==============================================================================
-
 //
 // Input
 //
@@ -45,10 +41,6 @@ layout(location = 2) out vec4 out_msRt2;
 #define out_msRt2_DEFINED
 #endif
 
-//==============================================================================
-// Functions                                                                   =
-//==============================================================================
-
 // Getter
 #if PASS == COLOR
 #define getNormal_DEFINED
@@ -94,8 +86,7 @@ vec3 getPositionViewSpace()
 // Do normal mapping
 #if PASS == COLOR
 #define readNormalFromTexture_DEFINED
-vec3 readNormalFromTexture(
-	in vec3 normal, in vec4 tangent, in sampler2D map, in highp vec2 texCoords)
+vec3 readNormalFromTexture(in vec3 normal, in vec4 tangent, in sampler2D map, in highp vec2 texCoords)
 {
 #if LOD > 0
 	return normalize(normal);
@@ -128,10 +119,8 @@ vec3 combineNormalFromTextures(in vec3 normal,
 	return normalize(normal);
 #else
 	// First read the textures
-	vec3 nAtTangentspace0 =
-		normalize((texture(map, texCoords).rgb - 0.5) * 2.0);
-	vec3 nAtTangentspace1 =
-		normalize((texture(map2, texCoords * texCoords2Scale).rgb - 0.5) * 2.0);
+	vec3 nAtTangentspace0 = normalize((texture(map, texCoords).rgb - 0.5) * 2.0);
+	vec3 nAtTangentspace1 = normalize((texture(map2, texCoords * texCoords2Scale).rgb - 0.5) * 2.0);
 
 	vec3 nAtTangentspace = (nAtTangentspace0 + nAtTangentspace1) / 2.0;
 
@@ -149,11 +138,10 @@ vec3 combineNormalFromTextures(in vec3 normal,
 // Do environment mapping
 #if PASS == COLOR
 #define readEnvironmentColor_DEFINED
-vec3 readEnvironmentColor(
-	in vec3 vertPosViewSpace, in vec3 normal, in sampler2D map)
+vec3 readEnvironmentColor(in vec3 vertPosViewSpace, in vec3 normal, in sampler2D map)
 {
-	// In case of normal mapping I could play with vertex's normal but this
-	// gives better results and its allready computed
+	// In case of normal mapping I could play with vertex's normal but this gives better results and its allready
+	// computed
 
 	vec3 u = normalize(vertPosViewSpace);
 	vec3 r = reflect(u, normal);
@@ -166,11 +154,9 @@ vec3 readEnvironmentColor(
 }
 #endif
 
-// Using a 4-channel texture and a tolerance discard the fragment if the
-// texture's alpha is less than the tolerance
+// Using a 4-channel texture and a tolerance discard the fragment if the texture's alpha is less than the tolerance
 #define readTextureRgbAlphaTesting_DEFINED
-vec3 readTextureRgbAlphaTesting(
-	in sampler2D map, in highp vec2 texCoords, in float tolerance)
+vec3 readTextureRgbAlphaTesting(in sampler2D map, in highp vec2 texCoords, in float tolerance)
 {
 #if PASS == COLOR
 	vec4 col = vec4(texture(map, texCoords));
@@ -221,8 +207,7 @@ float readRFromTexture(in sampler2D tex, in highp vec2 texCoords)
 #endif
 
 #define computeTextureCoordParallax_DEFINED
-vec2 computeTextureCoordParallax(
-	in sampler2D heightMap, in vec2 uv, in float heightMapScale)
+vec2 computeTextureCoordParallax(in sampler2D heightMap, in vec2 uv, in float heightMapScale)
 {
 #if PASS == COLOR && LOD == 0
 	const uint MAX_SAMPLES = 25;
@@ -244,11 +229,9 @@ vec2 computeTextureCoordParallax(
 
 	vec3 E = normalize(eyeTangentSpace);
 
-	float sampleCountf =
-		mix(float(MAX_SAMPLES),
-			float(MIN_SAMPLES),
-			min(dot(E, normTangentSpace),
-				in_vertPosViewSpace.z / -MAX_EFFECTIVE_DISTANCE));
+	float sampleCountf = mix(float(MAX_SAMPLES),
+		float(MIN_SAMPLES),
+		min(dot(E, normTangentSpace), in_vertPosViewSpace.z / -MAX_EFFECTIVE_DISTANCE));
 
 	float stepSize = 1.0 / sampleCountf;
 
@@ -264,8 +247,7 @@ vec2 computeTextureCoordParallax(
 	uint sampleCount = uint(sampleCountf);
 	while(crntSample < sampleCount)
 	{
-		crntSampledHeight =
-			textureGrad(heightMap, uv + crntOffset, dPdx, dPdy).r;
+		crntSampledHeight = textureGrad(heightMap, uv + crntOffset, dPdx, dPdy).r;
 
 		if(crntSampledHeight > crntRayHeight)
 		{

+ 9 - 22
shaders/MsCommonTessc.glsl

@@ -120,10 +120,7 @@ void calcPositions()
 	// 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.pos021 + pnPatch.pos012 + pnPatch.pos102 + pnPatch.pos201 + pnPatch.pos210 + pnPatch.pos120) / 6.0;
 	pnPatch.pos111 += (pnPatch.pos111 - center) / 2.0;
 }
 
@@ -165,9 +162,7 @@ bool posOutsideClipSpace(in vec2 posNdc)
 // 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])));
+	return any(bvec3(posOutsideClipSpace(posNdc[0]), posOutsideClipSpace(posNdc[1]), posOutsideClipSpace(posNdc[2])));
 }
 
 // Check if a face is visible
@@ -197,9 +192,7 @@ void setSilhouetteTessLevels(in mat3 normalMat, in float maxTessLevel)
 	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;
+	gl_TessLevelInner[0] = (gl_TessLevelOuter[0] + gl_TessLevelOuter[1] + gl_TessLevelOuter[2]) / 3.0;
 }
 
 void setConstantTessLevels(in float maxTessLevel)
@@ -227,8 +220,7 @@ float calcPhongTerm(int ivId, int i, vec3 q)
 
 // This function is part of the point-normal tessellation method
 #define tessellatePNPositionNormalTangentTexCoord_DEFINED
-void tessellatePNPositionNormalTangentTexCoord(
-	in float maxTessLevel, in mat4 mvp, in mat3 normalMat)
+void tessellatePNPositionNormalTangentTexCoord(in float maxTessLevel, in mat4 mvp, in mat3 normalMat)
 {
 	float tessLevel = 0.0;
 
@@ -264,8 +256,7 @@ void tessellatePNPositionNormalTangentTexCoord(
 }
 
 #define tessellatePhongPositionNormalTangentTexCoord_DEFINED
-void tessellatePhongPositionNormalTangentTexCoord(
-	in float maxTessLevel, in mat4 mvp, in mat3 normalMat)
+void tessellatePhongPositionNormalTangentTexCoord(in float maxTessLevel, in mat4 mvp, in mat3 normalMat)
 {
 	if(IID == 0)
 	{
@@ -291,18 +282,14 @@ void tessellatePhongPositionNormalTangentTexCoord(
 		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));
+		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 float maxTessLevel, in mat4 mvp, in mat3 normalMat)
+void tessellateDispMapPositionNormalTangentTexCoord(in float maxTessLevel, in mat4 mvp, in mat3 normalMat)
 {
 	if(IID == 0)
 	{

+ 10 - 19
shaders/MsCommonTesse.glsl

@@ -68,8 +68,7 @@ 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)
+#define INTERPOLATE(x_) (x_[0] * gl_TessCoord.x + x_[1] * gl_TessCoord.y + x_[2] * gl_TessCoord.z)
 
 // Smooth tessellation
 #define tessellatePNPositionNormalTangentTexCoord_DEFINED
@@ -98,18 +97,15 @@ void tessellatePNPositionNormalTangentTexCoord(in mat4 mvp, in mat3 normalMat)
 	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;
+	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)
+void tessellatePhongPositionNormalTangentTexCoord(in mat4 mvp, in mat3 normalMat)
 {
 #if PASS == COLOR
 	outNormal = normalize(normalMat * INTERPOLATE(inNormal));
@@ -124,19 +120,15 @@ void tessellatePhongPositionNormalTangentTexCoord(
 	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 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[0] * gl_TessCoord[1] * termIJ + gl_TessCoord[1] * gl_TessCoord[2] * termJK
 		+ gl_TessCoord[2] * gl_TessCoord[0] * termIK;
 
 	float tessAlpha = 1.0;
@@ -145,8 +137,7 @@ void tessellatePhongPositionNormalTangentTexCoord(
 }
 
 #define tessellateDispMapPositionNormalTangentTexCoord_DEFINED
-void tessellateDispMapPositionNormalTangentTexCoord(
-	in mat4 mvp, in mat3 normalMat, in sampler2D dispMap)
+void tessellateDispMapPositionNormalTangentTexCoord(in mat4 mvp, in mat3 normalMat, in sampler2D dispMap)
 {
 	vec3 norm = INTERPOLATE(inNormal);
 #if PASS == COLOR

+ 5 - 4
shaders/MsCommonVert.glsl

@@ -3,6 +3,9 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#ifndef ANKI_SHADERS_MS_COMMON_VERT_GLSL
+#define ANKI_SHADERS_MS_COMMON_VERT_GLSL
+
 #include "shaders/MsFsCommon.glsl"
 
 //
@@ -44,7 +47,6 @@ layout(location = 4) out mediump vec3 out_eyeTangentSpace; // Parallax
 layout(location = 5) out mediump vec3 out_normalTangentSpace; // Parallax
 #endif
 
-//==============================================================================
 #define writePositionAndUv_DEFINED
 void writePositionAndUv(in mat4 mvp)
 {
@@ -67,7 +69,6 @@ void writePositionAndUv(in mat4 mvp)
 #endif
 }
 
-//==============================================================================
 #if PASS == COLOR
 #define writeNormalAndTangent_DEFINED
 void writeNormalAndTangent(in mat3 normalMat)
@@ -93,7 +94,6 @@ void writeNormalAndTangent(in mat3 normalMat)
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define writeVertPosViewSpace_DEFINED
 void writeVertPosViewSpace(in mat4 modelViewMat)
@@ -102,7 +102,6 @@ void writeVertPosViewSpace(in mat4 modelViewMat)
 }
 #endif
 
-//==============================================================================
 #if PASS == COLOR
 #define writeParallax_DEFINED
 void writeParallax(in mat3 normalMat, in mat4 modelViewMat)
@@ -118,3 +117,5 @@ void writeParallax(in mat3 normalMat, in mat4 modelViewMat)
 	out_normalTangentSpace = invTbn * n;
 }
 #endif
+
+#endif

+ 6 - 2
shaders/MsFsCommon.glsl

@@ -3,6 +3,9 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#ifndef ANKI_SHADERS_MS_FS_COMMON_GLSL
+#define ANKI_SHADERS_MS_FS_COMMON_GLSL
+
 #include "shaders/Common.glsl"
 
 // Misc
@@ -33,9 +36,10 @@
 
 // Read from animated texture
 #define readAnimatedTextureRgba_DEFINED
-vec4 readAnimatedTextureRgba(
-	sampler2DArray tex, float layerCount, float period, vec2 uv, float time)
+vec4 readAnimatedTextureRgba(sampler2DArray tex, float layerCount, float period, vec2 uv, float time)
 {
 	float layer = mod(time * layerCount / period, layerCount);
 	return texture(tex, vec3(uv, layer));
 }
+
+#endif

+ 10 - 12
shaders/NearDepthUpscale.frag.glsl

@@ -27,15 +27,14 @@ const float DEPTH_THRESHOLD = 1.0 / 1000.0;
 
 const vec2 COLOR_TEX_TEXEL_SIZE = 1.0 / vec2(TEXTURE_WIDTH, TEXTURE_HEIGHT);
 
-const vec2 OFFSETS[8] =
-	vec2[](vec2(-COLOR_TEX_TEXEL_SIZE.x, -COLOR_TEX_TEXEL_SIZE.y),
-		vec2(0.0, -COLOR_TEX_TEXEL_SIZE.y),
-		vec2(COLOR_TEX_TEXEL_SIZE.x, -COLOR_TEX_TEXEL_SIZE.y),
-		vec2(COLOR_TEX_TEXEL_SIZE.x, 0.0),
-		vec2(COLOR_TEX_TEXEL_SIZE.x, COLOR_TEX_TEXEL_SIZE.y),
-		vec2(0.0, COLOR_TEX_TEXEL_SIZE.y),
-		vec2(-COLOR_TEX_TEXEL_SIZE.x, COLOR_TEX_TEXEL_SIZE.y),
-		vec2(-COLOR_TEX_TEXEL_SIZE.x, 0.0));
+const vec2 OFFSETS[8] = vec2[](vec2(-COLOR_TEX_TEXEL_SIZE.x, -COLOR_TEX_TEXEL_SIZE.y),
+	vec2(0.0, -COLOR_TEX_TEXEL_SIZE.y),
+	vec2(COLOR_TEX_TEXEL_SIZE.x, -COLOR_TEX_TEXEL_SIZE.y),
+	vec2(COLOR_TEX_TEXEL_SIZE.x, 0.0),
+	vec2(COLOR_TEX_TEXEL_SIZE.x, COLOR_TEX_TEXEL_SIZE.y),
+	vec2(0.0, COLOR_TEX_TEXEL_SIZE.y),
+	vec2(-COLOR_TEX_TEXEL_SIZE.x, COLOR_TEX_TEXEL_SIZE.y),
+	vec2(-COLOR_TEX_TEXEL_SIZE.x, 0.0));
 
 void main()
 {
@@ -67,9 +66,8 @@ void main()
 		}
 	}
 
-// Check for depth discontinuites. Use textureLod because it's undefined
-// if you are sampling mipmaped in a conditional branch. See
-// http://teknicool.tumblr.com/post/77263472964/glsl-dynamic-branching-and-texture-samplers
+// Check for depth discontinuites. Use textureLod because it's undefined if you are sampling mipmaped in a conditional
+// branch. See http://teknicool.tumblr.com/post/77263472964/glsl-dynamic-branching-and-texture-samplers
 #if 0
 	float a = u_linearizePad2.x;
 	float b = u_linearizePad2.y;

+ 1 - 2
shaders/NearDepthUpscale.vert.glsl

@@ -14,8 +14,7 @@ layout(location = 0) out vec2 out_uv;
 
 void main()
 {
-	const vec2 POSITIONS[3] =
-		vec2[](vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0));
+	const vec2 POSITIONS[3] = vec2[](vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0));
 
 	vec2 pos = POSITIONS[gl_VertexID];
 	gl_Position = vec4(pos, 0.0, 1.0);

+ 13 - 18
shaders/Pack.glsl

@@ -30,6 +30,7 @@ vec3 unpackNormal(in vec2 enc)
 }
 
 #if GL_ES || __VERSION__ < 400
+
 // Vectorized version. See clean one at <= r1048
 uint packUnorm4x8(in vec4 v)
 {
@@ -113,27 +114,26 @@ struct GbufferInfo
 // Populate the G buffer
 void writeGBuffer(in GbufferInfo g, out vec4 rt0, out vec4 rt1, out vec4 rt2)
 {
-	float comp =
-		packUnorm2ToUnorm1(vec2(g.subsurface, g.emission / MAX_EMISSION));
+	float comp = packUnorm2ToUnorm1(vec2(g.subsurface, g.emission / MAX_EMISSION));
 	rt0 = vec4(g.diffuse, comp);
 	rt1 = vec4(g.specular, g.roughness);
 	rt2 = vec4(g.normal * 0.5 + 0.5, g.metallic);
 }
 
 // Read from G-buffer
-#define readSpecularRoughnessFromGBuffer(rt1_, uv_, lod_, g_)                  \
-	{                                                                          \
-		vec4 comp = textureLod(rt1_, uv_, lod_);                               \
-		g_.specular = comp.xyz;                                                \
-		g_.roughness = max(EPSILON, comp.w);                                   \
+#define readSpecularRoughnessFromGBuffer(rt1_, uv_, lod_, g_)                                                          \
+	{                                                                                                                  \
+		vec4 comp = textureLod(rt1_, uv_, lod_);                                                                       \
+		g_.specular = comp.xyz;                                                                                        \
+		g_.roughness = max(EPSILON, comp.w);                                                                           \
 	}
 
 // Read from G-buffer
-#define readNormalMetallicFromGBuffer(rt2_, uv_, lod_, g_)                     \
-	{                                                                          \
-		vec4 comp = textureLod(rt2_, uv_, lod_);                               \
-		g_.normal = comp.xyz * 2.0 - 1.0;                                      \
-		g_.metallic = comp.w;                                                  \
+#define readNormalMetallicFromGBuffer(rt2_, uv_, lod_, g_)                                                             \
+	{                                                                                                                  \
+		vec4 comp = textureLod(rt2_, uv_, lod_);                                                                       \
+		g_.normal = comp.xyz * 2.0 - 1.0;                                                                              \
+		g_.metallic = comp.w;                                                                                          \
 	}
 
 // Read from G-buffer
@@ -143,12 +143,7 @@ void readNormalFromGBuffer(in sampler2D rt2, in vec2 uv, out vec3 normal)
 }
 
 // Read from the G buffer
-void readGBuffer(in sampler2D rt0,
-	in sampler2D rt1,
-	in sampler2D rt2,
-	in vec2 uv,
-	in float lod,
-	out GbufferInfo g)
+void readGBuffer(in sampler2D rt0, in sampler2D rt1, in sampler2D rt2, in vec2 uv, in float lod, out GbufferInfo g)
 {
 	vec4 comp = textureLod(rt0, uv, lod);
 	g.diffuse = comp.xyz;

+ 0 - 8
shaders/Pps.frag.glsl

@@ -38,14 +38,12 @@ const vec2 KERNEL[8] = vec2[](vec2(TEX_OFFSET.x, TEX_OFFSET.y),
 	vec2(TEX_OFFSET.x, -TEX_OFFSET.y),
 	vec2(TEX_OFFSET.x, 0.0));
 
-//==============================================================================
 vec3 grayScale(in vec3 col)
 {
 	float grey = (col.r + col.g + col.b) * 0.333333333; // aka: / 3.0
 	return vec3(grey);
 }
 
-//==============================================================================
 vec3 saturation(in vec3 col, in float factor)
 {
 	const vec3 lumCoeff = vec3(0.2125, 0.7154, 0.0721);
@@ -54,19 +52,16 @@ vec3 saturation(in vec3 col, in float factor)
 	return mix(intensity, col, factor);
 }
 
-//==============================================================================
 vec3 gammaCorrection(in float gamma, in vec3 col)
 {
 	return pow(col, vec3(1.0 / gamma));
 }
 
-//==============================================================================
 vec3 gammaCorrectionRgb(in vec3 gamma, in vec3 col)
 {
 	return pow(col, 1.0 / gamma);
 }
 
-//==============================================================================
 vec3 sharpen(in sampler2D tex, in vec2 texCoords)
 {
 	const float sharpenFactor = 0.25;
@@ -84,7 +79,6 @@ vec3 sharpen(in sampler2D tex, in vec2 texCoords)
 	return max(col, vec3(EPSILON));
 }
 
-//==============================================================================
 vec3 erosion(in sampler2D tex, in vec2 texCoords)
 {
 	vec3 minValue = textureRt(tex, texCoords).rgb;
@@ -98,7 +92,6 @@ vec3 erosion(in sampler2D tex, in vec2 texCoords)
 	return minValue;
 }
 
-//==============================================================================
 vec3 colorGrading(in vec3 color)
 {
 	const vec3 LUT_SCALE = vec3((LUT_SIZE - 1.0) / LUT_SIZE);
@@ -109,7 +102,6 @@ vec3 colorGrading(in vec3 color)
 	return textureLod(u_lut, lutCoords, 0.0).rgb;
 }
 
-//==============================================================================
 void main()
 {
 #if SHARPEN_ENABLED

+ 1 - 2
shaders/Quad.vert.glsl

@@ -18,8 +18,7 @@ layout(location = 0) out vec2 out_uv;
 
 void main()
 {
-	const vec2 POSITIONS[3] =
-		vec2[](vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0));
+	const vec2 POSITIONS[3] = vec2[](vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0));
 
 	vec2 pos = POSITIONS[gl_VertexID];
 	out_uv = pos * 0.5 + (0.5 + UV_OFFSET);

+ 4 - 8
shaders/Ssao.frag.glsl

@@ -44,8 +44,7 @@ vec3 readNormal(in vec2 uv)
 // Read the noise tex
 vec3 readRandom(in vec2 uv)
 {
-	const vec2 tmp = vec2(float(WIDTH) / float(NOISE_MAP_SIZE),
-		float(HEIGHT) / float(NOISE_MAP_SIZE));
+	const vec2 tmp = vec2(float(WIDTH) / float(NOISE_MAP_SIZE), float(HEIGHT) / float(NOISE_MAP_SIZE));
 
 	vec3 noise = texture(u_noiseMap, tmp * uv).xyz;
 	// return normalize(noise * 2.0 - 1.0);
@@ -56,8 +55,7 @@ vec3 readRandom(in vec2 uv)
 float readZ(in vec2 uv)
 {
 	float depth = texture(u_mMsDepthRt, uv).r;
-	float z =
-		u_uniforms.projectionParams.z / (u_uniforms.projectionParams.w + depth);
+	float z = u_uniforms.projectionParams.z / (u_uniforms.projectionParams.w + depth);
 	return z;
 }
 
@@ -67,8 +65,7 @@ vec3 readPosition(in vec2 uv)
 	vec3 fragPosVspace;
 	fragPosVspace.z = readZ(uv);
 
-	fragPosVspace.xy =
-		(2.0 * uv - 1.0) * u_uniforms.projectionParams.xy * fragPosVspace.z;
+	fragPosVspace.xy = (2.0 * uv - 1.0) * u_uniforms.projectionParams.xy * fragPosVspace.z;
 
 	return fragPosVspace;
 }
@@ -78,8 +75,7 @@ void main(void)
 	vec3 origin = readPosition(in_texCoords);
 
 	// Chose the number of samples dynamicaly
-	float sampleCountf =
-		max(1.0 + origin.z / MAX_DISTANCE, 0.0) * float(KERNEL_SIZE);
+	float sampleCountf = max(1.0 + origin.z / MAX_DISTANCE, 0.0) * float(KERNEL_SIZE);
 	uint sampleCount = uint(sampleCountf);
 
 	vec3 normal = readNormal(in_texCoords);

+ 3 - 7
shaders/Sslf.frag.glsl

@@ -45,9 +45,7 @@ void main()
 
 	const vec2 texelSize = 1.0 / vec2(TEX_DIMENSIONS);
 
-	const vec3 distortion = vec3(-texelSize.x * CHROMATIC_DISTORTION,
-		0.0,
-		texelSize.x * CHROMATIC_DISTORTION);
+	const vec3 distortion = vec3(-texelSize.x * CHROMATIC_DISTORTION, 0.0, texelSize.x * CHROMATIC_DISTORTION);
 
 	const float lenOfHalf = length(vec2(0.5));
 
@@ -63,8 +61,7 @@ void main()
 		float weight = length(vec2(0.5) - offset) / lenOfHalf;
 		weight = pow(1.0 - weight, 10.0);
 
-		result +=
-			textureDistorted(u_rt, offset, direction, distortion) * weight;
+		result += textureDistorted(u_rt, offset, direction, distortion) * weight;
 	}
 
 // sample halo
@@ -72,8 +69,7 @@ void main()
 	vec2 haloVec = normalize(ghostVec) * HALO_WIDTH;
 	float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / lenOfHalf;
 	weight = pow(1.0 - weight, 20.0);
-	result += textureDistorted(u_rt, texcoord + haloVec, direction, distortion)
-		* (weight * HALO_OPACITY);
+	result += textureDistorted(u_rt, texcoord + haloVec, direction, distortion) * (weight * HALO_OPACITY);
 #endif
 
 	// lens dirt

+ 2 - 5
shaders/Sslr.glsl

@@ -10,7 +10,6 @@
 
 const float ONE = 0.9;
 
-//==============================================================================
 // Returns the Z of the position in view space
 float readZ(in vec2 uv)
 {
@@ -19,14 +18,12 @@ float readZ(in vec2 uv)
 	return z;
 }
 
-//==============================================================================
 vec2 projectXy(in vec3 p)
 {
 	vec4 a = u_projectionMat * vec4(p, 1.0);
 	return a.xy / a.w;
 }
 
-//==============================================================================
 vec3 doSslr(in vec3 r, in vec3 posVSpace, in vec2 uv, out float contribution)
 {
 	contribution = 0.5;
@@ -81,8 +78,8 @@ vec3 doSslr(in vec3 r, in vec3 posVSpace, in vec2 uv, out float contribution)
 		a.xy = ndc * u_projectionParams.xy * a.z; // Unproject
 		a = normalize(a);
 
-		// Compute the intersection between 'a' (before normalization) and r
-		// 'k' is the value to multiply to 'a' to get the intersection
+		// Compute the intersection between 'a' (before normalization) and r 'k' is the value to multiply to 'a' to get 
+		// the intersection
 		// c0 = cross(a, r);
 		// c1 = cross(p0, r);
 		// k = c1.x / c0.x; and the optimized:

+ 2 - 6
shaders/TilerMinMax.comp.glsl

@@ -22,14 +22,11 @@ layout(std430, binding = 0) writeonly buffer _blk
 	vec2 u_depthLimits[];
 };
 
-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;
 
 shared uint g_minDepth;
 shared uint g_maxDepth;
 
-//==============================================================================
 void main()
 {
 	// Init
@@ -40,8 +37,7 @@ void main()
 	barrier();
 
 	// Get max/min depth
-	ivec2 coord =
-		ivec2(gl_GlobalInvocationID.xy) * ivec2(PIXEL_READ_X, PIXEL_READ_Y);
+	ivec2 coord = ivec2(gl_GlobalInvocationID.xy) * ivec2(PIXEL_READ_X, PIXEL_READ_Y);
 
 	float mind = 10.0;
 	float maxd = -10.0;

+ 4 - 11
shaders/TmAverageLuminance.comp.glsl

@@ -14,9 +14,7 @@ const uint WORKGROUP_SIZE_X = 16u;
 const uint WORKGROUP_SIZE_Y = 16u;
 const uint WORKGROUP_SIZE = WORKGROUP_SIZE_X * WORKGROUP_SIZE_Y;
 
-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;
 
 const uint MIPMAP_WIDTH = ANKI_RENDERER_WIDTH / (2u << (IS_RT_MIPMAP - 1u));
 const uint MIPMAP_HEIGHT = ANKI_RENDERER_HEIGHT / (2u << (IS_RT_MIPMAP - 1u));
@@ -46,10 +44,7 @@ void main()
 			ivec2 uv = ivec2(xStart, yStart) + ivec2(x, y);
 // WORKAROUND
 #if defined(ANKI_VK) && defined(ANKI_VENDOR_NVIDIA)
-			vec3 color = textureLod(u_isRt,
-							 vec2(uv) / vec2(MIPMAP_WIDTH, MIPMAP_HEIGHT),
-							 IS_RT_MIPMAP)
-							 .rgb;
+			vec3 color = textureLod(u_isRt, vec2(uv) / vec2(MIPMAP_WIDTH, MIPMAP_HEIGHT), IS_RT_MIPMAP).rgb;
 #else
 			vec3 color = texelFetch(u_isRt, uv, IS_RT_MIPMAP).rgb;
 #endif
@@ -70,8 +65,7 @@ void main()
 	{
 		if(gl_LocalInvocationIndex < s)
 		{
-			g_avgLum[gl_LocalInvocationIndex] +=
-				g_avgLum[gl_LocalInvocationIndex + s];
+			g_avgLum[gl_LocalInvocationIndex] += g_avgLum[gl_LocalInvocationIndex + s];
 		}
 
 		memoryBarrierShared();
@@ -90,8 +84,7 @@ void main()
 
 		// Lerp between previous and new L value
 		const float INTERPOLATION_FACTOR = 0.05;
-		u_averageLuminancePad3.x = prevLum * (1.0 - INTERPOLATION_FACTOR)
-			+ crntLum * INTERPOLATION_FACTOR;
+		u_averageLuminancePad3.x = prevLum * (1.0 - INTERPOLATION_FACTOR) + crntLum * INTERPOLATION_FACTOR;
 #else
 		u_averageLuminancePad3.x = crntLum;
 #endif

+ 1 - 3
shaders/Tonemapping.glsl

@@ -47,9 +47,7 @@ vec3 tonemapUncharted2(in vec3 color)
 	const float E = 0.02;
 	const float F = 0.30;
 
-	return ((color * (A * color + C * B) + D * E)
-			   / (color * (A * color + B) + D * F))
-		- E / F;
+	return ((color * (A * color + C * B) + D * E) / (color * (A * color + B) + D * F)) - E / F;
 }
 
 vec3 tonemap(in vec3 color, in float avgLum, in float threshold)

+ 2 - 5
shaders/VariableSamplingBlurGeneric.frag.glsl

@@ -56,9 +56,7 @@ layout(location = 0) in vec2 in_texCoord;
 #endif
 
 // Calc the kernel. Use offsets of 3 to take advantage of bilinear filtering
-#define BLURRING(val, sign_)                                                   \
-	((float(val) * (float(BLURRING_DIST) + 1.0) / float(IMG_DIMENSION))        \
-		* float(sign_))
+#define BLURRING(val, sign_) ((float(val) * (float(BLURRING_DIST) + 1.0) / float(IMG_DIMENSION)) * float(sign_))
 
 #if defined(HPASS)
 #define BLURRING_OFFSET_X(val, sign_) BLURRING(val, sign_)
@@ -68,8 +66,7 @@ layout(location = 0) in vec2 in_texCoord;
 #define BLURRING_OFFSET_Y(val, sign_) BLURRING(val, sign_)
 #endif
 
-#define BLURRING_OFFSET(v, s)                                                  \
-	vec2(BLURRING_OFFSET_X(v, s), BLURRING_OFFSET_Y(v, s))
+#define BLURRING_OFFSET(v, s) vec2(BLURRING_OFFSET_X(v, s), BLURRING_OFFSET_Y(v, s))
 
 const vec2 KERNEL[SAMPLES - 1] = vec2[](BLURRING_OFFSET(1, -1),
 	BLURRING_OFFSET(1, 1)

+ 1 - 4
shaders/Volumetric.frag.glsl

@@ -18,19 +18,16 @@ layout(std140, ANKI_UBO_BINDING(0, 0)) uniform ubo0_
 
 layout(location = 0) out vec3 out_color;
 
-//==============================================================================
 vec3 fog(vec2 uv)
 {
 	float depth = textureLod(u_msDepthRt, uv, 1.0).r;
 
-	float linearDepth =
-		linearizeDepthOptimal(depth, u_linearizePad2.x, u_linearizePad2.y);
+	float linearDepth = linearizeDepthOptimal(depth, u_linearizePad2.x, u_linearizePad2.y);
 
 	float t = linearDepth * u_fogColorFogFactor.w;
 	return dither(u_fogColorFogFactor.rgb * t, 4.0);
 }
 
-//==============================================================================
 void main()
 {
 	out_color = fog(in_uv);

+ 2 - 2
src/anki/Collision.h

@@ -5,8 +5,6 @@
 
 #pragma once
 
-/// @defgroup collision Collision detection module
-
 #include <anki/collision/Plane.h>
 #include <anki/collision/Sphere.h>
 #include <anki/collision/Obb.h>
@@ -19,3 +17,5 @@
 #include <anki/collision/GjkEpa.h>
 #include <anki/collision/Functions.h>
 #include <anki/collision/Tests.h>
+
+/// @defgroup collision Collision detection module

+ 0 - 8
src/anki/Config.h.cmake

@@ -113,10 +113,6 @@
 // Enable performance counters
 #define ANKI_ENABLE_TRACE ${_ANKI_ENABLE_TRACE}
 
-//==============================================================================
-// Other                                                                       =
-//==============================================================================
-
 #define ANKI_FILE __FILE__
 #define ANKI_FUNC __func__
 
@@ -143,10 +139,6 @@
 #	define anki_internal protected
 #endif
 
-//==============================================================================
-// Engine config                                                               =
-//==============================================================================
-
 // General config
 #define ANKI_SAFE_ALIGNMENT 16
 

+ 8 - 9
src/anki/Gr.h

@@ -3,17 +3,8 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
-/// @file
-/// This file contains the public OpenGL headers and all the GL classes that
-/// the rest of AnKi should use
-
 #pragma once
 
-/// @defgroup graphics Graphics backend abstraction
-
-/// @defgroup opengl OpenGL backend
-/// @ingroup graphics
-
 #include <anki/gr/Buffer.h>
 #include <anki/gr/Texture.h>
 #include <anki/gr/Sampler.h>
@@ -24,3 +15,11 @@
 #include <anki/gr/OcclusionQuery.h>
 #include <anki/gr/ResourceGroup.h>
 #include <anki/gr/GrManager.h>
+
+/// @defgroup graphics Graphics API abstraction
+
+/// @defgroup opengl OpenGL backend
+/// @ingroup graphics
+
+/// @defgroup vulkan Vulkan backend
+/// @ingroup graphics

+ 2 - 2
src/anki/Physics.h

@@ -5,6 +5,6 @@
 
 #pragma once
 
-/// @defgroup physics Physics subsystem
-
 #include <anki/physics/PhysicsWorld.h>
+
+/// @defgroup physics Physics subsystem

+ 4 - 9
src/anki/Resource.h

@@ -3,17 +3,12 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
-/// @file
-/// This file contains the public resource headers and all the resource classes
-/// that the rest of AnKi should use
-
 #pragma once
 
+#include <anki/resource/ResourceManager.h>
+#include <anki/resource/Script.h>
+
 /// @defgroup resource Collection of resources and management
 
-/// @defgroup resource_private Private resource interfaces
-/// Other modules should not use them.
+/// @defgroup resource_private Private resource interfaces. Other modules should not use them.
 /// @ingroup resource
-
-#include <anki/resource/ResourceManager.h>
-#include <anki/resource/Script.h>

+ 0 - 2
src/anki/Scene.h

@@ -10,12 +10,10 @@
 #include <anki/scene/BodyComponent.h>
 #include <anki/scene/Sector.h>
 #include <anki/scene/ModelNode.h>
-#include <anki/scene/SkinNode.h>
 #include <anki/scene/StaticGeometryNode.h>
 #include <anki/scene/ParticleEmitter.h>
 #include <anki/scene/Camera.h>
 #include <anki/scene/Light.h>
-#include <anki/scene/Path.h>
 #include <anki/scene/StaticCollisionNode.h>
 #include <anki/scene/BodyNode.h>
 #include <anki/scene/ReflectionProbe.h>

+ 31 - 31
src/anki/Util.h

@@ -3,6 +3,37 @@
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 
+#pragma once
+
+#include <anki/util/Allocator.h>
+#include <anki/util/Array.h>
+#include <anki/util/Assert.h>
+#include <anki/util/Atomic.h>
+#include <anki/util/BitSet.h>
+#include <anki/util/BitMask.h>
+#include <anki/util/DynamicArray.h>
+#include <anki/util/Dictionary.h>
+#include <anki/util/Enum.h>
+#include <anki/util/File.h>
+#include <anki/util/Filesystem.h>
+#include <anki/util/Functions.h>
+#include <anki/util/Hash.h>
+#include <anki/util/HighRezTimer.h>
+#include <anki/util/List.h>
+#include <anki/util/Logger.h>
+#include <anki/util/Memory.h>
+#include <anki/util/NonCopyable.h>
+#include <anki/util/Hierarchy.h>
+#include <anki/util/Ptr.h>
+#include <anki/util/Singleton.h>
+#include <anki/util/StdTypes.h>
+#include <anki/util/String.h>
+#include <anki/util/StringList.h>
+#include <anki/util/System.h>
+#include <anki/util/Thread.h>
+#include <anki/util/ThreadPool.h>
+#include <anki/util/Visitor.h>
+
 /// @defgroup util Utilities (like STL)
 
 /// @defgroup util_containers STL compatible containers
@@ -37,34 +68,3 @@
 
 /// @defgroup util_private Private interfaces
 /// @ingroup util
-
-#pragma once
-
-#include <anki/util/Allocator.h>
-#include <anki/util/Array.h>
-#include <anki/util/Assert.h>
-#include <anki/util/Atomic.h>
-#include <anki/util/BitSet.h>
-#include <anki/util/BitMask.h>
-#include <anki/util/DynamicArray.h>
-#include <anki/util/Dictionary.h>
-#include <anki/util/Enum.h>
-#include <anki/util/File.h>
-#include <anki/util/Filesystem.h>
-#include <anki/util/Functions.h>
-#include <anki/util/Hash.h>
-#include <anki/util/HighRezTimer.h>
-#include <anki/util/List.h>
-#include <anki/util/Logger.h>
-#include <anki/util/Memory.h>
-#include <anki/util/NonCopyable.h>
-#include <anki/util/Hierarchy.h>
-#include <anki/util/Ptr.h>
-#include <anki/util/Singleton.h>
-#include <anki/util/StdTypes.h>
-#include <anki/util/String.h>
-#include <anki/util/StringList.h>
-#include <anki/util/System.h>
-#include <anki/util/Thread.h>
-#include <anki/util/ThreadPool.h>
-#include <anki/util/Visitor.h>

+ 1 - 7
src/anki/collision/Aabb.cpp

@@ -11,7 +11,6 @@
 namespace anki
 {
 
-//==============================================================================
 Aabb Aabb::getTransformed(const Transform& trf) const
 {
 	Mat3x4 absM;
@@ -29,7 +28,6 @@ Aabb Aabb::getTransformed(const Transform& trf) const
 	return Aabb(newC - newE, newC + newE);
 }
 
-//==============================================================================
 F32 Aabb::testPlane(const Plane& p) const
 {
 	const Aabb& aabb = *this;
@@ -69,7 +67,6 @@ F32 Aabb::testPlane(const Plane& p) const
 	}
 }
 
-//==============================================================================
 Aabb Aabb::getCompoundShape(const Aabb& b) const
 {
 	Aabb out;
@@ -84,9 +81,7 @@ Aabb Aabb::getCompoundShape(const Aabb& b) const
 	return out;
 }
 
-//==============================================================================
-void Aabb::setFromPointCloud(
-	const void* buff, U count, PtrSize stride, PtrSize buffSize)
+void Aabb::setFromPointCloud(const void* buff, U count, PtrSize stride, PtrSize buffSize)
 {
 	m_min = Vec4(Vec3(MAX_F32), 0.0);
 	m_max = Vec4(Vec3(MIN_F32), 0.0);
@@ -106,7 +101,6 @@ void Aabb::setFromPointCloud(
 	});
 }
 
-//==============================================================================
 Vec4 Aabb::computeSupport(const Vec4& dir) const
 {
 	Vec4 ret(0.0);

+ 5 - 12
src/anki/collision/Aabb.h

@@ -20,18 +20,13 @@ class Aabb : public ConvexShape
 public:
 	using Base = ConvexShape;
 
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() == Type::AABB;
-	}
-
 	Aabb()
-		: Base(Type::AABB)
+		: Base(CollisionShapeType::AABB)
 	{
 	}
 
 	Aabb(const Vec4& min, const Vec4& max)
-		: Base(Type::AABB)
+		: Base(CollisionShapeType::AABB)
 		, m_min(min)
 		, m_max(max)
 	{
@@ -39,7 +34,7 @@ public:
 	}
 
 	Aabb(const Aabb& b)
-		: Base(Type::AABB)
+		: Base(CollisionShapeType::AABB)
 	{
 		operator=(b);
 	}
@@ -111,13 +106,11 @@ public:
 	/// It uses a nice trick to avoid unwanted calculations
 	Aabb getTransformed(const Transform& transform) const;
 
-	/// Get a collision shape that includes this and the given. Its not
-	/// very accurate
+	/// Get a collision shape that includes this and the given. Its not very accurate
 	Aabb getCompoundShape(const Aabb& b) const;
 
 	/// Calculate from a set of points
-	void setFromPointCloud(
-		const void* buff, U count, PtrSize stride, PtrSize buffSize);
+	void setFromPointCloud(const void* buff, U count, PtrSize stride, PtrSize buffSize);
 
 private:
 	Vec4 m_min;

+ 0 - 12
src/anki/collision/CollisionShape.cpp

@@ -1,12 +0,0 @@
-// Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <anki/collision/CollisionShape.h>
-#include <anki/Collision.h>
-
-namespace anki
-{
-
-} // end namespace anki

+ 26 - 31
src/anki/collision/CollisionShape.h

@@ -17,27 +17,27 @@ namespace anki
 /// @addtogroup collision
 /// @{
 
-/// Abstract class for collision shapes. It also features a visitor for
-/// implementing specific code outside the collision codebase (eg rendering)
+/// Collision shape type
+/// @note WARNING: Order is important
+enum class CollisionShapeType : U8
+{
+	PLANE,
+	LINE_SEG,
+	COMPOUND,
+	AABB,
+	SPHERE,
+	OBB,
+	CONVEX_HULL,
+
+	COUNT,
+	LAST_CONVEX = CONVEX_HULL
+};
+
+/// Abstract class for collision shapes. It also features a visitor for implementing specific code outside the
+/// collision codebase (eg rendering)
 class CollisionShape
 {
 public:
-	/// Collision shape type
-	/// @note WARNING: Order is important
-	enum class Type : U8
-	{
-		PLANE,
-		LINE_SEG,
-		COMPOUND,
-		AABB,
-		SPHERE,
-		OBB,
-		CONVEX_HULL,
-
-		COUNT,
-		LAST_CONVEX = CONVEX_HULL
-	};
-
 	/// Generic mutable visitor
 	class MutableVisitor
 	{
@@ -72,7 +72,7 @@ public:
 		virtual void visit(const ConvexHullShape&) = 0;
 	};
 
-	CollisionShape(Type cid)
+	CollisionShape(CollisionShapeType cid)
 		: m_cid(cid)
 	{
 	}
@@ -94,15 +94,13 @@ public:
 		return *this;
 	}
 
-	Type getType() const
+	CollisionShapeType getType() const
 	{
 		return m_cid;
 	}
 
-	/// If the collision shape intersects with the plane then the method
-	/// returns 0.0, else it returns the distance. If the distance is < 0.0
-	/// then the collision shape lies behind the plane and if > 0.0 then
-	/// in front of it
+	/// If the collision shape intersects with the plane then the method returns 0.0, else it returns the distance. If
+	/// the distance is < 0.0 then the collision shape lies behind the plane and if > 0.0 then in front of it
 	virtual F32 testPlane(const Plane& p) const = 0;
 
 	/// Transform
@@ -119,8 +117,7 @@ public:
 protected:
 	/// Function that iterates a point cloud
 	template<typename TFunc>
-	void iteratePointCloud(
-		const void* buff, U count, PtrSize stride, PtrSize buffSize, TFunc func)
+	void iteratePointCloud(const void* buff, U count, PtrSize stride, PtrSize buffSize, TFunc func)
 	{
 		ANKI_ASSERT(buff);
 		ANKI_ASSERT(count > 1);
@@ -130,8 +127,7 @@ protected:
 		const U8* ptr = (const U8*)buff;
 		while(count-- != 0)
 		{
-			ANKI_ASSERT(
-				(((PtrSize)ptr + sizeof(Vec3)) - (PtrSize)buff) <= buffSize);
+			ANKI_ASSERT((((PtrSize)ptr + sizeof(Vec3)) - (PtrSize)buff) <= buffSize);
 			const Vec3* pos = (const Vec3*)(ptr);
 
 			func(*pos);
@@ -141,9 +137,8 @@ protected:
 	}
 
 private:
-	/// Keep an ID to avoid (in some cases) the visitor and thus the cost of
-	/// virtuals
-	Type m_cid;
+	/// Keep an ID to avoid (in some cases) the visitor and thus the cost of virtuals
+	CollisionShapeType m_cid;
 };
 /// @}
 

+ 1 - 8
src/anki/collision/CompoundShape.cpp

@@ -10,14 +10,12 @@
 namespace anki
 {
 
-//==============================================================================
 CompoundShape::CompoundShape()
-	: CollisionShape(Type::COMPOUND)
+	: CollisionShape(CollisionShapeType::COMPOUND)
 {
 	memset(&m_dflt, 0, sizeof(m_dflt));
 }
 
-//==============================================================================
 F32 CompoundShape::testPlane(const Plane& p) const
 {
 	F32 minv = MAX_F32;
@@ -43,7 +41,6 @@ F32 CompoundShape::testPlane(const Plane& p) const
 	return 0.0;
 }
 
-//==============================================================================
 void CompoundShape::accept(MutableVisitor& v)
 {
 	Error err = iterateShapes([&](CollisionShape& cs) -> Error {
@@ -53,7 +50,6 @@ void CompoundShape::accept(MutableVisitor& v)
 	(void)err;
 }
 
-//==============================================================================
 void CompoundShape::accept(ConstVisitor& v) const
 {
 	Error err = iterateShapes([&](const CollisionShape& cs) -> Error {
@@ -63,7 +59,6 @@ void CompoundShape::accept(ConstVisitor& v) const
 	(void)err;
 }
 
-//==============================================================================
 void CompoundShape::transform(const Transform& trf)
 {
 	Error err = iterateShapes([&](CollisionShape& cs) -> Error {
@@ -73,7 +68,6 @@ void CompoundShape::transform(const Transform& trf)
 	(void)err;
 }
 
-//==============================================================================
 void CompoundShape::computeAabb(Aabb& out) const
 {
 	Vec4 minv(Vec3(MAX_F32), 0.0), maxv(Vec3(MIN_F32), 0.0);
@@ -95,7 +89,6 @@ void CompoundShape::computeAabb(Aabb& out) const
 	out.setMax(maxv);
 }
 
-//==============================================================================
 void CompoundShape::addShape(CollisionShape* shape)
 {
 	Chunk* chunk = &m_dflt;

+ 0 - 6
src/anki/collision/CompoundShape.h

@@ -18,11 +18,6 @@ namespace anki
 class CompoundShape : public CollisionShape, public NonCopyable
 {
 public:
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() == Type::COMPOUND;
-	}
-
 	CompoundShape();
 
 	/// Implements CollisionShape::testPlane
@@ -59,7 +54,6 @@ private:
 	Chunk m_dflt;
 };
 
-//==============================================================================
 template<typename TFunc>
 Error CompoundShape::iterateShapes(TFunc f) const
 {

+ 1 - 10
src/anki/collision/ConvexHullShape.cpp

@@ -11,7 +11,6 @@
 namespace anki
 {
 
-//==============================================================================
 void ConvexHullShape::destroy()
 {
 	if(m_ownsTheStorage)
@@ -30,7 +29,6 @@ void ConvexHullShape::destroy()
 	m_trfIdentity = true;
 }
 
-//==============================================================================
 void ConvexHullShape::move(ConvexHullShape& b)
 {
 	destroy();
@@ -58,20 +56,17 @@ void ConvexHullShape::move(ConvexHullShape& b)
 	b.m_trfIdentity = true;
 }
 
-//==============================================================================
 void ConvexHullShape::initStorage(CollisionAllocator<U8>& alloc, U pointCount)
 {
 	destroy();
 
-	m_points =
-		reinterpret_cast<Vec4*>(alloc.allocate(pointCount * sizeof(Vec4)));
+	m_points = reinterpret_cast<Vec4*>(alloc.allocate(pointCount * sizeof(Vec4)));
 
 	m_alloc = alloc;
 	m_ownsTheStorage = true;
 	m_pointsCount = pointCount;
 }
 
-//==============================================================================
 void ConvexHullShape::initStorage(void* buffer, U pointCount)
 {
 	ANKI_ASSERT(buffer);
@@ -83,7 +78,6 @@ void ConvexHullShape::initStorage(void* buffer, U pointCount)
 	ANKI_ASSERT(m_ownsTheStorage == false);
 }
 
-//==============================================================================
 F32 ConvexHullShape::testPlane(const Plane& p) const
 {
 	// Compute the invert transformation of the plane instead
@@ -121,7 +115,6 @@ F32 ConvexHullShape::testPlane(const Plane& p) const
 	}
 }
 
-//==============================================================================
 void ConvexHullShape::transform(const Transform& trf)
 {
 	m_trf = m_trf.combineTransformations(trf);
@@ -129,7 +122,6 @@ void ConvexHullShape::transform(const Transform& trf)
 	m_trfIdentity = false;
 }
 
-//==============================================================================
 void ConvexHullShape::computeAabb(Aabb& aabb) const
 {
 	ANKI_ASSERT(m_points);
@@ -151,7 +143,6 @@ void ConvexHullShape::computeAabb(Aabb& aabb) const
 	aabb = Aabb(mina.xyz0(), maxa.xyz0());
 }
 
-//==============================================================================
 Vec4 ConvexHullShape::computeSupport(const Vec4& dir) const
 {
 	F32 m = MIN_F32;

+ 9 - 17
src/anki/collision/ConvexHullShape.h

@@ -21,18 +21,13 @@ class ConvexHullShape : public NonCopyable, public ConvexShape
 public:
 	using Base = ConvexShape;
 
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() == Type::CONVEX_HULL;
-	}
-
 	ConvexHullShape()
-		: Base(Type::CONVEX_HULL)
+		: Base(CollisionShapeType::CONVEX_HULL)
 	{
 	}
 
 	ConvexHullShape(ConvexHullShape&& b)
-		: Base(Type::CONVEX_HULL)
+		: Base(CollisionShapeType::CONVEX_HULL)
 	{
 		move(b);
 	}
@@ -66,21 +61,18 @@ public:
 		return m_trf;
 	}
 
-	/// Calculate from a set of points. You have to call initStorage before
-	/// calling this method.
-	void setFromPointCloud(
-		const Vec3* buff, U count, PtrSize stride, PtrSize buffSize);
+	/// Calculate from a set of points. You have to call initStorage before calling this method.
+	void setFromPointCloud(const Vec3* buff, U count, PtrSize stride, PtrSize buffSize);
 
-	/// This function initializes the storage that holds the point cloud. This
-	/// method allocates a storage and the owner is the convex hull.
+	/// This function initializes the storage that holds the point cloud. This method allocates a storage and the owner
+	/// is the convex hull.
 	/// @param alloc The allocator to use for the point cloud
 	/// @param pointCount The number of points
 	void initStorage(CollisionAllocator<U8>& alloc, U pointCount);
 
-	/// This function initializes the storage that holds the point cloud using
-	/// a predefined buffer. The convex hull is not the owner of the storage.
-	/// @param buffer The base of the storage buffer. Size should be
-	///               @a pointCount * sizeof(Vec4)
+	/// This function initializes the storage that holds the point cloud using a predefined buffer. The convex hull is
+	/// not the owner of the storage.
+	/// @param buffer The base of the storage buffer. Size should be @a pointCount * sizeof(Vec4)
 	/// @param pointCount The number of points
 	void initStorage(void* buffer, U pointCount);
 

+ 1 - 6
src/anki/collision/ConvexShape.h

@@ -19,7 +19,7 @@ class ConvexShape : public CollisionShape
 public:
 	using Base = CollisionShape;
 
-	ConvexShape(Type cid)
+	ConvexShape(CollisionShapeType cid)
 		: Base(cid)
 	{
 	}
@@ -39,11 +39,6 @@ public:
 
 	/// Get a support vector for the GJK algorithm
 	virtual Vec4 computeSupport(const Vec4& dir) const = 0;
-
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() >= Type::AABB && c.getType() <= Type::LAST_CONVEX;
-	}
 };
 /// @}
 

+ 4 - 42
src/anki/collision/Frustum.cpp

@@ -10,11 +10,6 @@
 namespace anki
 {
 
-//==============================================================================
-// Frustum                                                                     =
-//==============================================================================
-
-//==============================================================================
 Frustum& Frustum::operator=(const Frustum& b)
 {
 	ANKI_ASSERT(m_type == b.m_type);
@@ -27,35 +22,30 @@ Frustum& Frustum::operator=(const Frustum& b)
 	return *this;
 }
 
-//==============================================================================
 void Frustum::accept(MutableVisitor& v)
 {
 	update();
 	CompoundShape::accept(v);
 }
 
-//==============================================================================
 void Frustum::accept(ConstVisitor& v) const
 {
 	update();
 	CompoundShape::accept(v);
 }
 
-//==============================================================================
 F32 Frustum::testPlane(const Plane& p) const
 {
 	update();
 	return CompoundShape::testPlane(p);
 }
 
-//==============================================================================
 void Frustum::computeAabb(Aabb& aabb) const
 {
 	update();
 	CompoundShape::computeAabb(aabb);
 }
 
-//==============================================================================
 Bool Frustum::insideFrustum(const CollisionShape& b) const
 {
 	update();
@@ -71,14 +61,12 @@ Bool Frustum::insideFrustum(const CollisionShape& b) const
 	return true;
 }
 
-//==============================================================================
 void Frustum::transform(const Transform& trf)
 {
 	Transform trfa = m_trf.combineTransformations(trf);
 	resetTransform(trfa);
 }
 
-//==============================================================================
 void Frustum::resetTransform(const Transform& trf)
 {
 	m_trf = trf;
@@ -101,7 +89,6 @@ void Frustum::resetTransform(const Transform& trf)
 	}
 }
 
-//==============================================================================
 void Frustum::update() const
 {
 	Frustum& self = *const_cast<Frustum*>(this);
@@ -111,7 +98,6 @@ void Frustum::update() const
 	}
 }
 
-//==============================================================================
 void Frustum::updateInternal()
 {
 	ANKI_ASSERT(m_frustumDirty);
@@ -128,11 +114,6 @@ void Frustum::updateInternal()
 	}
 }
 
-//==============================================================================
-// PerspectiveFrustum                                                          =
-//==============================================================================
-
-//==============================================================================
 PerspectiveFrustum::PerspectiveFrustum()
 	: Frustum(Type::PERSPECTIVE)
 {
@@ -140,7 +121,6 @@ PerspectiveFrustum::PerspectiveFrustum()
 	m_hull.initStorage(&m_pointsW[0], m_pointsW.getSize());
 }
 
-//==============================================================================
 PerspectiveFrustum& PerspectiveFrustum::operator=(const PerspectiveFrustum& b)
 {
 	Frustum::operator=(b);
@@ -151,7 +131,6 @@ PerspectiveFrustum& PerspectiveFrustum::operator=(const PerspectiveFrustum& b)
 	return *this;
 }
 
-//==============================================================================
 void PerspectiveFrustum::onTransform()
 {
 	// Eye
@@ -163,7 +142,6 @@ void PerspectiveFrustum::onTransform()
 	}
 }
 
-//==============================================================================
 void PerspectiveFrustum::recalculate()
 {
 	// Planes
@@ -201,27 +179,18 @@ void PerspectiveFrustum::recalculate()
 	m_pointsL[3] = Vec4(x, -y, z, 0.0); // bot right
 }
 
-//==============================================================================
 Mat4 PerspectiveFrustum::calculateProjectionMatrix() const
 {
-	return Mat4::calculatePerspectiveProjectionMatrix(
-		m_fovX, m_fovY, m_near, m_far);
+	return Mat4::calculatePerspectiveProjectionMatrix(m_fovX, m_fovY, m_near, m_far);
 }
 
-//==============================================================================
-// OrthographicFrustum                                                         =
-//==============================================================================
-
-//==============================================================================
 OrthographicFrustum::OrthographicFrustum()
 	: Frustum(Type::ORTHOGRAPHIC)
 {
 	addShape(&m_obbW);
 }
 
-//==============================================================================
-OrthographicFrustum& OrthographicFrustum::operator=(
-	const OrthographicFrustum& b)
+OrthographicFrustum& OrthographicFrustum::operator=(const OrthographicFrustum& b)
 {
 	Frustum::operator=(b);
 	m_left = b.m_left;
@@ -233,14 +202,11 @@ OrthographicFrustum& OrthographicFrustum::operator=(
 	return *this;
 }
 
-//==============================================================================
 Mat4 OrthographicFrustum::calculateProjectionMatrix() const
 {
-	return Mat4::calculateOrthographicProjectionMatrix(
-		m_right, m_left, m_top, m_bottom, m_near, m_far);
+	return Mat4::calculateOrthographicProjectionMatrix(m_right, m_left, m_top, m_bottom, m_near, m_far);
 }
 
-//==============================================================================
 void OrthographicFrustum::recalculate()
 {
 	// Planes
@@ -253,15 +219,11 @@ void OrthographicFrustum::recalculate()
 	m_planesL[(U)PlaneType::BOTTOM] = Plane(Vec4(0.0, 1.0, 0.0, 0.0), m_bottom);
 
 	// OBB
-	Vec4 c((m_right + m_left) * 0.5,
-		(m_top + m_bottom) * 0.5,
-		-(m_far + m_near) * 0.5,
-		0.0);
+	Vec4 c((m_right + m_left) * 0.5, (m_top + m_bottom) * 0.5, -(m_far + m_near) * 0.5, 0.0);
 	Vec4 e = Vec4(m_right, m_top, -m_far, 0.0) - c;
 	m_obbL = Obb(c, Mat3x4::getIdentity(), e);
 }
 
-//==============================================================================
 void OrthographicFrustum::onTransform()
 {
 	m_obbW = m_obbL.getTransformed(m_trf);

+ 4 - 16
src/anki/collision/Frustum.h

@@ -18,8 +18,8 @@ namespace anki
 /// @addtogroup Collision
 /// @{
 
-/// Frustum collision shape. This shape consists from 6 planes. The planes are
-/// being used to find shapes that are inside the frustum
+/// Frustum collision shape. This shape consists from 6 planes. The planes are being used to find shapes that are
+/// inside the frustum
 class Frustum : public CompoundShape
 {
 public:
@@ -122,8 +122,7 @@ protected:
 	/// It's true when the frustum changed
 	Bool8 m_frustumDirty = true;
 
-	/// Called when a viewing variable changes. It recalculates the planes and
-	/// the other variables.
+	/// Called when a viewing variable changes. It recalculates the planes and the other variables.
 	virtual void recalculate() = 0;
 
 	/// Called when there is a change in the transformation.
@@ -144,11 +143,6 @@ private:
 class PerspectiveFrustum : public Frustum
 {
 public:
-	static Bool classof(const Frustum& c)
-	{
-		return c.getType() == Type::PERSPECTIVE;
-	}
-
 	/// Default
 	PerspectiveFrustum();
 
@@ -248,11 +242,6 @@ private:
 class OrthographicFrustum : public Frustum
 {
 public:
-	static Bool classof(const Frustum& c)
-	{
-		return c.getType() == Type::ORTHOGRAPHIC;
-	}
-
 	/// Default
 	OrthographicFrustum();
 
@@ -264,8 +253,7 @@ public:
 	}
 
 	/// Set all
-	OrthographicFrustum(
-		F32 left, F32 right, F32 near, F32 far, F32 top, F32 bottom)
+	OrthographicFrustum(F32 left, F32 right, F32 near, F32 far, F32 top, F32 bottom)
 		: OrthographicFrustum()
 	{
 		setAll(left, right, near, far, top, bottom);

+ 0 - 2
src/anki/collision/Functions.cpp

@@ -9,7 +9,6 @@
 namespace anki
 {
 
-//==============================================================================
 static void setPlane(const Vec4& abcd, Plane& p)
 {
 	Vec4 n = abcd.xyz0();
@@ -17,7 +16,6 @@ static void setPlane(const Vec4& abcd, Plane& p)
 	p = Plane(n / len, -abcd.w() / len);
 }
 
-//==============================================================================
 void extractClipPlanes(const Mat4& mvp, Array<Plane*, 6>& planes)
 {
 	// Plane equation coefficients

+ 7 - 17
src/anki/collision/GjkEpa.cpp

@@ -10,13 +10,11 @@
 namespace anki
 {
 
-//==============================================================================
 /// Helper of (axb)xa
 static Vec4 crossAba(const Vec4& a, const Vec4& b)
 {
-	// We need to calculate the (axb)xa but we can use the triple product
-	// property ax(bxc) = b(a.c) - c(a.b) to make it faster
-	// Vec4 out = b * (a.dot(a)) - a * (a.dot(b));
+	// We need to calculate the (axb)xa but we can use the triple product property ax(bxc) = b(a.c) - c(a.b) to make it
+	// faster Vec4 out = b * (a.dot(a)) - a * (a.dot(b));
 	Vec4 out = a.cross(b.cross(a));
 	// printf("+%f %f %f %f\n", out.x(), out.y(), out.z(), out.w());
 	// out = b * (a.dot(a)) - a * (a.dot(b));
@@ -25,18 +23,13 @@ static Vec4 crossAba(const Vec4& a, const Vec4& b)
 	return out;
 }
 
-//==============================================================================
-void Gjk::support(const ConvexShape& shape0,
-	const ConvexShape& shape1,
-	const Vec4& dir,
-	Support& support)
+void Gjk::support(const ConvexShape& shape0, const ConvexShape& shape1, const Vec4& dir, Support& support)
 {
 	support.m_v0 = shape0.computeSupport(dir);
 	support.m_v1 = shape1.computeSupport(-dir);
 	support.m_v = support.m_v0 - support.m_v1;
 }
 
-//==============================================================================
 Bool Gjk::update(const Support& a)
 {
 	if(m_count == 2)
@@ -50,8 +43,7 @@ Bool Gjk::update(const Support& a)
 		// Compute the triangle's normal
 		Vec4 abc = ab.cross(ac);
 
-		// Compute a vector within the plane of the triangle,
-		// Pointing away from the edge ab
+		// Compute a vector within the plane of the triangle, Pointing away from the edge ab
 		Vec4 abp = ab.cross(abc);
 
 		if(abp.dot(ao) > 0.0)
@@ -76,8 +68,8 @@ Bool Gjk::update(const Support& a)
 			return false;
 		}
 
-		// If we get here, then the origin must be within the triangle,
-		// but we care whether it is above or below it, so test
+		// If we get here, then the origin must be within the triangle, but we care whether it is above or below it, so
+		// test
 		if(abc.dot(ao) > 0.0)
 		{
 			m_simplex[3] = m_simplex[2];
@@ -155,8 +147,7 @@ Bool Gjk::update(const Support& a)
 
 	check_face:
 
-		// We have a CCW wound triangle ABC
-		// the point is in front of this triangle
+		// We have a CCW wound triangle ABC the point is in front of this triangle
 		// it is NOT "below" edge BC
 		// it is NOT "above" the plane through A that's parallel to BC
 		Vec4 abp = ab.cross(abc);
@@ -198,7 +189,6 @@ Bool Gjk::update(const Support& a)
 	return true;
 }
 
-//==============================================================================
 Bool Gjk::intersect(const ConvexShape& shape0, const ConvexShape& shape1)
 {
 	// Chose random direction

+ 3 - 6
src/anki/collision/GjkEpa.h

@@ -34,8 +34,8 @@ public:
 /// @addtogroup collision
 /// @{
 
-/// The implementation of the GJK algorithm. This algorithm is being used for
-/// checking the intersection between convex shapes.
+/// The implementation of the GJK algorithm. This algorithm is being used for checking the intersection between convex
+/// shapes.
 class Gjk
 {
 	friend class GjkEpa;
@@ -52,10 +52,7 @@ private:
 	Vec4 m_dir;
 
 	/// Compute the support
-	static void support(const ConvexShape& shape0,
-		const ConvexShape& shape1,
-		const Vec4& dir,
-		Support& support);
+	static void support(const ConvexShape& shape0, const ConvexShape& shape1, const Vec4& dir, Support& support);
 
 	/// Update simplex
 	Bool update(const Support& a);

+ 2 - 4
src/anki/collision/GjkEpaInternal.h

@@ -37,8 +37,7 @@ public:
 
 	Bool operator==(const Edge& b) const
 	{
-		return (m_idx[0] == b.m_idx[1] && m_idx[1] == b.m_idx[0])
-			|| (m_idx[0] == b.m_idx[0] && m_idx[1] == b.m_idx[1]);
+		return (m_idx[0] == b.m_idx[1] && m_idx[1] == b.m_idx[0]) || (m_idx[0] == b.m_idx[0] && m_idx[1] == b.m_idx[1]);
 	}
 };
 
@@ -140,8 +139,7 @@ class Polytope
 	friend class Face;
 
 public:
-	Polytope(
-		CollisionTempAllocator<U8>& alloc, U32 maxSimplexSize, U32 maxFaceCount)
+	Polytope(CollisionTempAllocator<U8>& alloc, U32 maxSimplexSize, U32 maxFaceCount)
 		: m_maxSimplexSize(maxSimplexSize)
 		, m_maxFaceCount(maxFaceCount)
 		, m_simplex(alloc)

+ 0 - 3
src/anki/collision/LineSegment.cpp

@@ -11,7 +11,6 @@
 namespace anki
 {
 
-//==============================================================================
 F32 LineSegment::testPlane(const Plane& p) const
 {
 	const Vec4& p0 = m_origin;
@@ -44,7 +43,6 @@ F32 LineSegment::testPlane(const Plane& p) const
 	}
 }
 
-//==============================================================================
 LineSegment LineSegment::getTransformed(const Transform& trf) const
 {
 	LineSegment out;
@@ -53,7 +51,6 @@ LineSegment LineSegment::getTransformed(const Transform& trf) const
 	return out;
 }
 
-//==============================================================================
 void LineSegment::computeAabb(Aabb& aabb) const
 {
 	Vec4 min = m_origin;

+ 4 - 10
src/anki/collision/LineSegment.h

@@ -14,34 +14,28 @@ namespace anki
 /// @addtogroup Collision
 /// @{
 
-/// Line segment. Line from a point to a point. P0 = origin and
-/// P1 = direction + origin
+/// Line segment. Line from a point to a point. P0 = origin and P1 = direction + origin
 class LineSegment : public CollisionShape
 {
 public:
 	using Base = CollisionShape;
 
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() == Type::LINE_SEG;
-	}
-
 	LineSegment()
-		: Base(Type::LINE_SEG)
+		: Base(CollisionShapeType::LINE_SEG)
 		, m_origin(0.0)
 		, m_dir(0.0)
 	{
 	}
 
 	LineSegment(const Vec4& origin, const Vec4& direction)
-		: Base(Type::LINE_SEG)
+		: Base(CollisionShapeType::LINE_SEG)
 		, m_origin(origin)
 		, m_dir(direction)
 	{
 	}
 
 	LineSegment(const LineSegment& b)
-		: Base(Type::LINE_SEG)
+		: Base(CollisionShapeType::LINE_SEG)
 	{
 		operator=(b);
 	}

+ 5 - 18
src/anki/collision/Obb.cpp

@@ -10,9 +10,8 @@
 namespace anki
 {
 
-//==============================================================================
 Obb::Obb()
-	: Base(Type::OBB)
+	: Base(CollisionShapeType::OBB)
 	, m_center(Vec4(0.0))
 	, m_rotation(Mat3x4::getIdentity())
 	, m_transposedRotation(Mat3x4::getIdentity())
@@ -20,16 +19,14 @@ Obb::Obb()
 {
 }
 
-//==============================================================================
 Obb::Obb(const Obb& b)
-	: Base(Type::OBB)
+	: Base(CollisionShapeType::OBB)
 {
 	operator=(b);
 }
 
-//==============================================================================
 Obb::Obb(const Vec4& center, const Mat3x4& rotation, const Vec4& extend)
-	: Base(Type::OBB)
+	: Base(CollisionShapeType::OBB)
 	, m_center(center)
 	, m_rotation(rotation)
 	, m_transposedRotation(rotation)
@@ -38,7 +35,6 @@ Obb::Obb(const Vec4& center, const Mat3x4& rotation, const Vec4& extend)
 	m_transposedRotation.transposeRotationPart();
 }
 
-//==============================================================================
 Obb& Obb::operator=(const Obb& b)
 {
 	m_center = b.m_center;
@@ -51,7 +47,6 @@ Obb& Obb::operator=(const Obb& b)
 	return *this;
 }
 
-//==============================================================================
 F32 Obb::testPlane(const Plane& p) const
 {
 	Vec4 xNormal = (m_transposedRotation * p.getNormal()).xyz0();
@@ -79,7 +74,6 @@ F32 Obb::testPlane(const Plane& p) const
 	}
 }
 
-//==============================================================================
 Obb Obb::getTransformed(const Transform& trf) const
 {
 	Obb out;
@@ -91,7 +85,6 @@ Obb Obb::getTransformed(const Transform& trf) const
 	return out;
 }
 
-//==============================================================================
 Obb Obb::getCompoundShape(const Obb& b) const
 {
 	Obb out;
@@ -109,12 +102,10 @@ Obb Obb::getCompoundShape(const Obb& b) const
 		points[i + 8] = points1[i];
 	}
 
-	out.setFromPointCloud(
-		&points[0], points.size(), sizeof(Vec4), sizeof(Vec4) * points.size());
+	out.setFromPointCloud(&points[0], points.size(), sizeof(Vec4), sizeof(Vec4) * points.size());
 	return out;
 }
 
-//==============================================================================
 void Obb::getExtremePoints(Array<Vec4, 8>& points) const
 {
 	if(!m_cache.m_dirtyExtremePoints)
@@ -167,7 +158,6 @@ void Obb::getExtremePoints(Array<Vec4, 8>& points) const
 	m_cache.m_extremePoints = points;
 }
 
-//==============================================================================
 void Obb::computeAabb(Aabb& aabb) const
 {
 	// Check cache
@@ -194,9 +184,7 @@ void Obb::computeAabb(Aabb& aabb) const
 	m_cache.m_aabb = aabb;
 }
 
-//==============================================================================
-void Obb::setFromPointCloud(
-	const void* buff, U count, PtrSize stride, PtrSize buffSize)
+void Obb::setFromPointCloud(const void* buff, U count, PtrSize stride, PtrSize buffSize)
 {
 	Vec4 min = Vec4(Vec3(MAX_F32), 0.0);
 	Vec4 max = Vec4(Vec3(MIN_F32), 0.0);
@@ -225,7 +213,6 @@ void Obb::setFromPointCloud(
 	makeDirty();
 }
 
-//==============================================================================
 Vec4 Obb::computeSupport(const Vec4& dir) const
 {
 	Array<Vec4, 8> points;

+ 3 - 12
src/anki/collision/Obb.h

@@ -22,11 +22,6 @@ class Obb : public ConvexShape
 public:
 	using Base = ConvexShape;
 
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() == Type::OBB;
-	}
-
 	Obb();
 
 	Obb(const Obb& b);
@@ -95,13 +90,11 @@ public:
 
 	Obb getTransformed(const Transform& transform) const;
 
-	/// Get a collision shape that includes this and the given. Its not
-	/// very accurate
+	/// Get a collision shape that includes this and the given. Its not very accurate
 	Obb getCompoundShape(const Obb& b) const;
 
 	/// Calculate from a set of points
-	void setFromPointCloud(
-		const void* buff, U count, PtrSize stride, PtrSize buffSize);
+	void setFromPointCloud(const void* buff, U count, PtrSize stride, PtrSize buffSize);
 
 	/// Get extreme points in 3D space
 	void getExtremePoints(Array<Vec4, 8>& points) const;
@@ -113,9 +106,7 @@ public:
 	Vec4 m_center;
 	Mat3x4 m_rotation;
 	Mat3x4 m_transposedRotation; ///< Used for visibility tests
-	/// With identity rotation this points to max (front, right, top in
-	/// our case)
-	Vec4 m_extend;
+	Vec4 m_extend; ///< With identity rotation this points to max (front, right, top in our case)
 
 	struct
 	{

+ 3 - 19
src/anki/collision/Plane.cpp

@@ -9,22 +9,12 @@
 namespace anki
 {
 
-//==============================================================================
-Plane::Plane(const Vec4& normal, F32 offset)
-	: CollisionShape(Type::PLANE)
-	, m_normal(normal)
-	, m_offset(offset)
-{
-}
-
-//==============================================================================
 F32 Plane::testPlane(const Plane& /*p*/) const
 {
 	ANKI_ASSERT(0 && "Ambiguous call");
 	return 0.0;
 }
 
-//==============================================================================
 void Plane::setFrom3Points(const Vec4& p0, const Vec4& p1, const Vec4& p2)
 {
 	ANKI_ASSERT(p0.w() == 0.0 && p1.w() == 0.0 && p2.w() == 0.0);
@@ -42,7 +32,6 @@ void Plane::setFrom3Points(const Vec4& p0, const Vec4& p1, const Vec4& p2)
 	m_offset = m_normal.dot(p0);
 }
 
-//==============================================================================
 void Plane::setFromPlaneEquation(F32 a, F32 b, F32 c, F32 d)
 {
 	m_normal = Vec4(a, b, c, 0.0);
@@ -53,7 +42,6 @@ void Plane::setFromPlaneEquation(F32 a, F32 b, F32 c, F32 d)
 	m_offset = d;
 }
 
-//==============================================================================
 Plane Plane::getTransformed(const Transform& trf) const
 {
 	Plane plane;
@@ -70,13 +58,11 @@ Plane Plane::getTransformed(const Transform& trf) const
 	return plane;
 }
 
-//==============================================================================
 void Plane::computeAabb(Aabb&) const
 {
 	ANKI_ASSERT(0 && "Can't do that");
 }
 
-//==============================================================================
 Bool Plane::intersectVector(const Vec4& p, Vec4& intersection) const
 {
 	ANKI_ASSERT(p.w() == 0.0);
@@ -95,9 +81,7 @@ Bool Plane::intersectVector(const Vec4& p, Vec4& intersection) const
 	}
 }
 
-//==============================================================================
-Bool Plane::intersectRay(
-	const Vec4& rayOrigin, const Vec4& rayDir, Vec4& intersection) const
+Bool Plane::intersectRay(const Vec4& rayOrigin, const Vec4& rayDir, Vec4& intersection) const
 {
 	ANKI_ASSERT(rayOrigin.w() == 0.0 && rayDir.w() == 0.0);
 	Bool intersects = false;
@@ -107,8 +91,8 @@ Bool Plane::intersectRay(
 
 	if(d > 0.0 && a < 0.0)
 	{
-		// To have intersection the d should be positive and the s as well. So
-		// the 'a' must be negative and not zero because of the division.
+		// To have intersection the d should be positive and the s as well. So the 'a' must be negative and not zero
+		// because of the division.
 		F32 s = -d / a;
 		ANKI_ASSERT(s > 0.0);
 

+ 17 - 19
src/anki/collision/Plane.h

@@ -20,37 +20,37 @@ class Plane : public CollisionShape
 public:
 	using Base = CollisionShape;
 
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() == Type::PLANE;
-	}
-
 	/// Default constructor
 	Plane()
-		: CollisionShape(Type::PLANE)
+		: CollisionShape(CollisionShapeType::PLANE)
 	{
 	}
 
 	/// Copy constructor
 	Plane(const Plane& b)
-		: CollisionShape(Type::PLANE)
+		: CollisionShape(CollisionShapeType::PLANE)
 	{
 		operator=(b);
 	}
 
 	/// Constructor
-	Plane(const Vec4& normal, F32 offset);
+	Plane(const Vec4& normal, F32 offset)
+		: CollisionShape(CollisionShapeType::PLANE)
+		, m_normal(normal)
+		, m_offset(offset)
+	{
+	}
 
 	/// @see setFrom3Points
 	Plane(const Vec4& p0, const Vec4& p1, const Vec4& p2)
-		: CollisionShape(Type::PLANE)
+		: CollisionShape(CollisionShapeType::PLANE)
 	{
 		setFrom3Points(p0, p1, p2);
 	}
 
 	/// @see setFromPlaneEquation
 	Plane(F32 a, F32 b, F32 c, F32 d)
-		: CollisionShape(Type::PLANE)
+		: CollisionShape(CollisionShapeType::PLANE)
 	{
 		setFromPlaneEquation(a, b, c, d);
 	}
@@ -115,9 +115,8 @@ public:
 	/// Return the transformed
 	Plane getTransformed(const Transform& trf) const;
 
-	/// It gives the distance between a point and a plane. It returns >0 if the
-	/// point lies in front of the plane, <0 if it's behind and ==0 when it's
-	/// co-planar.
+	/// It gives the distance between a point and a plane. It returns >0 if the point lies in front of the plane, <0
+	/// if it's behind and ==0 when it's co-planar.
 	F32 test(const Vec4& point) const
 	{
 		ANKI_ASSERT(isZero<F32>(point.w()));
@@ -130,8 +129,8 @@ public:
 		return absolute(test(point));
 	}
 
-	/// Returns the perpedicular point of a given point in this plane.
-	/// Plane's normal and returned-point are perpedicular
+	/// Returns the perpedicular point of a given point in this plane. Plane's normal and returned-point are
+	/// perpedicular
 	Vec4 getClosestPoint(const Vec4& point) const
 	{
 		return point - m_normal * test(point);
@@ -140,10 +139,9 @@ public:
 	/// Find intersection with a vector.
 	Bool intersectVector(const Vec4& p, Vec4& intersection) const;
 
-	/// Find the intersection point of this plane and a ray. If the ray hits
-	/// the back of the plane then there is no intersection.
-	Bool intersectRay(
-		const Vec4& rayOrigin, const Vec4& rayDir, Vec4& intersection) const;
+	/// Find the intersection point of this plane and a ray. If the ray hits the back of the plane then there is no
+	/// intersection.
+	Bool intersectRay(const Vec4& rayOrigin, const Vec4& rayDir, Vec4& intersection) const;
 
 	/// Test a CollisionShape
 	template<typename T>

+ 1 - 8
src/anki/collision/Sphere.cpp

@@ -10,7 +10,6 @@
 namespace anki
 {
 
-//==============================================================================
 F32 Sphere::testPlane(const Plane& p) const
 {
 	F32 dist = p.test(m_center);
@@ -36,7 +35,6 @@ F32 Sphere::testPlane(const Plane& p) const
 	return out;
 }
 
-//==============================================================================
 Sphere Sphere::getTransformed(const Transform& trf) const
 {
 	Sphere newSphere;
@@ -46,7 +44,6 @@ Sphere Sphere::getTransformed(const Transform& trf) const
 	return newSphere;
 }
 
-//==============================================================================
 Sphere Sphere::getCompoundShape(const Sphere& b) const
 {
 	const Sphere& a = *this;
@@ -99,16 +96,13 @@ Sphere Sphere::getCompoundShape(const Sphere& b) const
 	return Sphere((ca + cb) / 2.0, (ca - cb).getLength() / 2.0);
 }
 
-//==============================================================================
 void Sphere::computeAabb(Aabb& aabb) const
 {
 	aabb.setMin(m_center - m_radius);
 	aabb.setMax(m_center + m_radius);
 }
 
-//==============================================================================
-void Sphere::setFromPointCloud(
-	const void* buff, U count, PtrSize stride, PtrSize buffSize)
+void Sphere::setFromPointCloud(const void* buff, U count, PtrSize stride, PtrSize buffSize)
 {
 	// Calc min/max
 	Vec4 min(Vec3(MAX_F32), 0.0);
@@ -144,7 +138,6 @@ void Sphere::setFromPointCloud(
 	m_radius = sqrt(maxDist);
 }
 
-//==============================================================================
 Vec4 Sphere::computeSupport(const Vec4& dir) const
 {
 	return m_center + dir.getNormalized() * m_radius;

+ 6 - 12
src/anki/collision/Sphere.h

@@ -20,27 +20,22 @@ class Sphere : public ConvexShape
 public:
 	using Base = ConvexShape;
 
-	static Bool classof(const CollisionShape& c)
-	{
-		return c.getType() == Type::SPHERE;
-	}
-
 	/// Default constructor
 	Sphere()
-		: Base(Type::SPHERE)
+		: Base(CollisionShapeType::SPHERE)
 	{
 	}
 
 	/// Copy constructor
 	Sphere(const Sphere& b)
-		: Base(Type::SPHERE)
+		: Base(CollisionShapeType::SPHERE)
 	{
 		operator=(b);
 	}
 
 	/// Constructor
 	Sphere(const Vec4& center, F32 radius)
-		: Base(Type::SPHERE)
+		: Base(CollisionShapeType::SPHERE)
 		, m_center(center)
 		, m_radius(radius)
 	{
@@ -109,13 +104,12 @@ public:
 
 	Sphere getTransformed(const Transform& transform) const;
 
-	/// Get the sphere that includes this sphere and the given. See a
-	/// drawing in the docs dir for more info about the algorithm
+	/// Get the sphere that includes this sphere and the given. See a drawing in the docs dir for more info about the
+	/// algorithm
 	Sphere getCompoundShape(const Sphere& b) const;
 
 	/// Calculate from a set of points
-	void setFromPointCloud(
-		const void* buff, U count, PtrSize stride, PtrSize buffSize);
+	void setFromPointCloud(const void* buff, U count, PtrSize stride, PtrSize buffSize);
 
 	/// Implements CompoundShape::computeSupport
 	Vec4 computeSupport(const Vec4& dir) const;

+ 13 - 34
src/anki/collision/Tests.cpp

@@ -12,24 +12,16 @@
 #include <anki/collision/Obb.h>
 #include <anki/collision/ConvexHullShape.h>
 #include <anki/collision/GjkEpa.h>
-#include <anki/util/Rtti.h>
 
 namespace anki
 {
 
-//==============================================================================
-// Misc                                                                        =
-//==============================================================================
-
-//==============================================================================
 static Bool gjk(const CollisionShape& a, const CollisionShape& b)
 {
 	Gjk gjk;
-	return gjk.intersect(
-		dcast<const ConvexShape&>(a), dcast<const ConvexShape&>(b));
+	return gjk.intersect(static_cast<const ConvexShape&>(a), static_cast<const ConvexShape&>(b));
 }
 
-//==============================================================================
 static Bool test(const Aabb& a, const Aabb& b)
 {
 	// if separated in x direction
@@ -54,7 +46,6 @@ static Bool test(const Aabb& a, const Aabb& b)
 	return true;
 }
 
-//==============================================================================
 Bool test(const Aabb& aabb, const LineSegment& ls)
 {
 	F32 maxS = MIN_F32;
@@ -67,8 +58,7 @@ Bool test(const Aabb& aabb, const LineSegment& ls)
 		if(isZero(ls.getDirection()[i]))
 		{
 			// segment passes by box
-			if(ls.getOrigin()[i] < aabb.getMin()[i]
-				|| ls.getOrigin()[i] > aabb.getMax()[i])
+			if(ls.getOrigin()[i] < aabb.getMin()[i] || ls.getOrigin()[i] > aabb.getMax()[i])
 			{
 				return false;
 			}
@@ -76,10 +66,8 @@ Bool test(const Aabb& aabb, const LineSegment& ls)
 		else
 		{
 			// compute intersection parameters and sort
-			F32 s =
-				(aabb.getMin()[i] - ls.getOrigin()[i]) / ls.getDirection()[i];
-			F32 t =
-				(aabb.getMax()[i] - ls.getOrigin()[i]) / ls.getDirection()[i];
+			F32 s = (aabb.getMin()[i] - ls.getOrigin()[i]) / ls.getDirection()[i];
+			F32 t = (aabb.getMax()[i] - ls.getOrigin()[i]) / ls.getDirection()[i];
 			if(s > t)
 			{
 				F32 temp = s;
@@ -109,7 +97,6 @@ Bool test(const Aabb& aabb, const LineSegment& ls)
 	return true;
 }
 
-//==============================================================================
 static Bool test(const Aabb& aabb, const Sphere& s)
 {
 	const Vec4& c = s.getCenter();
@@ -118,8 +105,7 @@ static Bool test(const Aabb& aabb, const Sphere& s)
 	Vec4 cp(0.0); // Closest Point
 	for(U i = 0; i < 3; i++)
 	{
-		// if the center is greater than the max then the closest
-		// point is the max
+		// if the center is greater than the max then the closest point is the max
 		if(c[i] > aabb.getMax()[i])
 		{
 			cp[i] = aabb.getMax()[i];
@@ -137,9 +123,8 @@ static Bool test(const Aabb& aabb, const Sphere& s)
 
 	F32 rsq = s.getRadius() * s.getRadius();
 
-	// if the c lies totally inside the box then the sub is the zero,
-	// this means that the length is also zero and thus its always smaller
-	// than rsq
+	// if the c lies totally inside the box then the sub is the zero, this means that the length is also zero and thus
+	// it's always smaller than rsq
 	Vec4 sub = c - cp;
 
 	if(sub.getLengthSquared() <= rsq)
@@ -150,7 +135,6 @@ static Bool test(const Aabb& aabb, const Sphere& s)
 	return false;
 }
 
-//==============================================================================
 static Bool test(const LineSegment& ls, const Obb& obb)
 {
 	F32 maxS = MIN_F32;
@@ -212,7 +196,6 @@ static Bool test(const LineSegment& ls, const Obb& obb)
 	return true;
 }
 
-//==============================================================================
 Bool test(const LineSegment& ls, const Sphere& s)
 {
 	const Vec4& v = ls.getDirection();
@@ -238,34 +221,29 @@ Bool test(const LineSegment& ls, const Sphere& s)
 	return tmp.getLengthSquared() <= rsq;
 }
 
-//==============================================================================
 static Bool test(const Sphere& a, const Sphere& b)
 {
 	F32 tmp = a.getRadius() + b.getRadius();
 	return (a.getCenter() - b.getCenter()).getLengthSquared() <= tmp * tmp;
 }
 
-//==============================================================================
-// Matrix                                                                      =
-//==============================================================================
-
 template<typename A, typename B>
 static Bool t(const CollisionShape& a, const CollisionShape& b)
 {
-	return test(dcast<const A&>(a), dcast<const B&>(b));
+	return test(static_cast<const A&>(a), static_cast<const B&>(b));
 }
 
 template<typename A, typename B>
 static Bool tr(const CollisionShape& a, const CollisionShape& b)
 {
-	return test(dcast<const B&>(b), dcast<const A&>(a));
+	return test(static_cast<const B&>(b), static_cast<const A&>(a));
 }
 
 /// Test plane.
 template<typename A>
 static Bool txp(const CollisionShape& a, const CollisionShape& b)
 {
-	return dcast<const A&>(a).testPlane(dcast<const Plane&>(b));
+	return static_cast<const A&>(a).testPlane(static_cast<const Plane&>(b));
 }
 
 /// Test plane.
@@ -279,7 +257,8 @@ static Bool tpx(const CollisionShape& a, const CollisionShape& b)
 static Bool tcx(const CollisionShape& a, const CollisionShape& b)
 {
 	Bool inside = false;
-	const CompoundShape& c = dcast<const CompoundShape&>(a);
+	ANKI_ASSERT(a.getType() == CollisionShapeType::COMPOUND);
+	const CompoundShape& c = static_cast<const CompoundShape&>(a);
 
 	// Use the error to stop the loop
 	Error err = c.iterateShapes([&](const CollisionShape& cs) {
@@ -304,7 +283,7 @@ static Bool txc(const CollisionShape& a, const CollisionShape& b)
 
 using Callback = Bool (*)(const CollisionShape& a, const CollisionShape& b);
 
-static const U COUNT = U(CollisionShape::Type::COUNT);
+static const U COUNT = U(CollisionShapeType::COUNT);
 
 // clang-format off
 static const Callback matrix[COUNT][COUNT] = {

+ 12 - 41
src/anki/core/App.cpp

@@ -32,24 +32,20 @@
 namespace anki
 {
 
-//==============================================================================
 #if ANKI_OS == ANKI_OS_ANDROID
 /// The one and only android hack
 android_app* gAndroidApp = nullptr;
 #endif
 
-//==============================================================================
 App::App()
 {
 }
 
-//==============================================================================
 App::~App()
 {
 	cleanup();
 }
 
-//==============================================================================
 void App::cleanup()
 {
 	if(m_script)
@@ -126,10 +122,7 @@ void App::cleanup()
 #endif
 }
 
-//==============================================================================
-Error App::init(const ConfigSet& config,
-	AllocAlignedCallback allocCb,
-	void* allocCbUserData)
+Error App::init(const ConfigSet& config, AllocAlignedCallback allocCb, void* allocCbUserData)
 {
 	Error err = initInternal(config, allocCb, allocCbUserData);
 	if(err)
@@ -141,10 +134,7 @@ Error App::init(const ConfigSet& config,
 	return err;
 }
 
-//==============================================================================
-Error App::initInternal(const ConfigSet& config_,
-	AllocAlignedCallback allocCb,
-	void* allocCbUserData)
+Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb, void* allocCbUserData)
 {
 	m_allocCb = allocCb;
 	m_allocCbData = allocCbUserData;
@@ -183,8 +173,7 @@ Error App::initInternal(const ConfigSet& config_,
 #endif
 
 #if ANKI_ENABLE_TRACE
-	ANKI_CHECK(TraceManagerSingleton::get().create(
-		m_heapAlloc, m_settingsDir.toCString()));
+	ANKI_CHECK(TraceManagerSingleton::get().create(m_heapAlloc, m_settingsDir.toCString()));
 #endif
 
 	//
@@ -195,8 +184,7 @@ Error App::initInternal(const ConfigSet& config_,
 	nwinit.m_height = config.getNumber("height");
 	nwinit.m_depthBits = 0;
 	nwinit.m_stencilBits = 0;
-	nwinit.m_fullscreenDesktopRez =
-		config.getNumber("fullscreenDesktopResolution");
+	nwinit.m_fullscreenDesktopRez = config.getNumber("fullscreenDesktopResolution");
 	m_window = m_heapAlloc.newInstance<NativeWindow>();
 
 	ANKI_CHECK(m_window->init(nwinit, m_heapAlloc));
@@ -212,8 +200,7 @@ Error App::initInternal(const ConfigSet& config_,
 	// ThreadPool
 	//
 	m_threadpool = m_heapAlloc.newInstance<ThreadPool>(getCpuCoresCount());
-	m_threadHive =
-		m_heapAlloc.newInstance<ThreadHive>(getCpuCoresCount(), m_heapAlloc);
+	m_threadHive = m_heapAlloc.newInstance<ThreadHive>(getCpuCoresCount(), m_heapAlloc);
 
 	//
 	// Graphics API
@@ -268,30 +255,18 @@ Error App::initInternal(const ConfigSet& config_,
 
 	m_renderer = m_heapAlloc.newInstance<MainRenderer>();
 
-	ANKI_CHECK(m_renderer->create(m_threadpool,
-		m_resources,
-		m_gr,
-		m_allocCb,
-		m_allocCbData,
-		config,
-		&m_globalTimestamp));
+	ANKI_CHECK(
+		m_renderer->create(m_threadpool, m_resources, m_gr, m_allocCb, m_allocCbData, config, &m_globalTimestamp));
 
-	m_resources->_setShadersPrependedSource(
-		m_renderer->getMaterialShaderSource().toCString());
+	m_resources->_setShadersPrependedSource(m_renderer->getMaterialShaderSource().toCString());
 
 	//
 	// Scene
 	//
 	m_scene = m_heapAlloc.newInstance<SceneGraph>();
 
-	ANKI_CHECK(m_scene->init(m_allocCb,
-		m_allocCbData,
-		m_threadpool,
-		m_threadHive,
-		m_resources,
-		m_input,
-		&m_globalTimestamp,
-		config));
+	ANKI_CHECK(m_scene->init(
+		m_allocCb, m_allocCbData, m_threadpool, m_threadHive, m_resources, m_input, &m_globalTimestamp, config));
 
 	//
 	// Script
@@ -304,7 +279,6 @@ Error App::initInternal(const ConfigSet& config_,
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 Error App::initDirs()
 {
 #if ANKI_OS != ANKI_OS_ANDROID
@@ -353,7 +327,6 @@ Error App::initDirs()
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 Error App::mainLoop()
 {
 	ANKI_LOGI("Entering main loop");
@@ -390,10 +363,8 @@ Error App::mainLoop()
 		m_gr->swapBuffers();
 
 		// Update the trace info with some async loader stats
-		U64 asyncTaskCount =
-			m_resources->getAsyncLoader().getCompletedTaskCount();
-		ANKI_TRACE_INC_COUNTER(RESOURCE_ASYNC_TASKS,
-			asyncTaskCount - m_resourceCompletedAsyncTaskCount);
+		U64 asyncTaskCount = m_resources->getAsyncLoader().getCompletedTaskCount();
+		ANKI_TRACE_INC_COUNTER(RESOURCE_ASYNC_TASKS, asyncTaskCount - m_resourceCompletedAsyncTaskCount);
 		m_resourceCompletedAsyncTaskCount = asyncTaskCount;
 
 		// Now resume the loader

+ 2 - 6
src/anki/core/App.h

@@ -41,9 +41,7 @@ public:
 	App();
 	virtual ~App();
 
-	ANKI_USE_RESULT Error init(const ConfigSet& config,
-		AllocAlignedCallback allocCb,
-		void* allocCbUserData);
+	ANKI_USE_RESULT Error init(const ConfigSet& config, AllocAlignedCallback allocCb, void* allocCbUserData);
 
 	F32 getTimerTick() const
 	{
@@ -166,9 +164,7 @@ private:
 	F32 m_timerTick;
 	U64 m_resourceCompletedAsyncTaskCount = 0;
 
-	ANKI_USE_RESULT Error initInternal(const ConfigSet& config,
-		AllocAlignedCallback allocCb,
-		void* allocCbUserData);
+	ANKI_USE_RESULT Error initInternal(const ConfigSet& config, AllocAlignedCallback allocCb, void* allocCbUserData);
 
 	ANKI_USE_RESULT Error initDirs();
 	void cleanup();

+ 1 - 4
src/anki/core/Config.cpp

@@ -8,7 +8,6 @@
 namespace anki
 {
 
-//==============================================================================
 Config::Config()
 {
 	//
@@ -73,8 +72,7 @@ Config::Config()
 	newOption("gr.storagePerFrameMemorySize", 1024 * 1024 * 16);
 	newOption("gr.vertexPerFrameMemorySize", 1024 * 1024 * 10);
 	newOption("gr.transferPerFrameMemorySize", 1024 * 1024 * 1);
-	newOption(
-		"gr.transferPersistentMemorySize", (4096 / 4) * (4096 / 4) * 16 * 4);
+	newOption("gr.transferPersistentMemorySize", (4096 / 4) * (4096 / 4) * 16 * 4);
 
 	//
 	// Resource
@@ -92,7 +90,6 @@ Config::Config()
 	newOption("debugContext", false);
 }
 
-//==============================================================================
 Config::~Config()
 {
 }

+ 1 - 2
src/anki/core/NativeWindow.h

@@ -46,8 +46,7 @@ public:
 		destroy();
 	}
 
-	ANKI_USE_RESULT Error init(
-		NativeWindowInitInfo& initializer, HeapAllocator<U8>& alloc);
+	ANKI_USE_RESULT Error init(NativeWindowInitInfo& initializer, HeapAllocator<U8>& alloc);
 
 	NativeWindowImpl& getNative()
 	{

+ 2 - 20
src/anki/core/NativeWindowAndroid.cpp

@@ -13,7 +13,6 @@
 namespace anki
 {
 
-//==============================================================================
 static void loopUntilWindowIsReady(android_app& app)
 {
 	while(app.window == nullptr)
@@ -23,9 +22,7 @@ static void loopUntilWindowIsReady(android_app& app)
 		android_poll_source* source;
 
 		const U timeoutMs = 5;
-		while(
-			(ident = ALooper_pollAll(timeoutMs, NULL, &events, (void**)&source))
-			>= 0)
+		while((ident = ALooper_pollAll(timeoutMs, NULL, &events, (void**)&source)) >= 0)
 		{
 			if(source != NULL)
 			{
@@ -35,11 +32,6 @@ static void loopUntilWindowIsReady(android_app& app)
 	}
 }
 
-//==============================================================================
-// NativeWindowImpl                                                            =
-//==============================================================================
-
-//==============================================================================
 void NativeWindowImpl::create(NativeWindowInitInfo& init)
 {
 	Array<EGLint, 256> attribs;
@@ -99,8 +91,7 @@ void NativeWindowImpl::create(NativeWindowInitInfo& init)
 
 	attribs[attr++] = EGL_NONE;
 
-	if(eglChooseConfig(display, &attribs[0], &config, 1, &configsCount)
-		== EGL_FALSE)
+	if(eglChooseConfig(display, &attribs[0], &config, 1, &configsCount) == EGL_FALSE)
 	{
 		throw ANKI_EXCEPTION("Failed to query required EGL configs");
 	}
@@ -148,7 +139,6 @@ void NativeWindowImpl::create(NativeWindowInitInfo& init)
 	init.height = h;
 }
 
-//==============================================================================
 void NativeWindowImpl::destroy()
 {
 	if(display != EGL_NO_DISPLAY)
@@ -169,16 +159,10 @@ void NativeWindowImpl::destroy()
 	}
 }
 
-//==============================================================================
-// NativeWindow                                                                =
-//==============================================================================
-
-//==============================================================================
 NativeWindow::~NativeWindow()
 {
 }
 
-//==============================================================================
 void NativeWindow::init(NativeWindowInitInfo& initializer)
 {
 	impl.reset(new NativeWindowImpl);
@@ -190,13 +174,11 @@ void NativeWindow::init(NativeWindowInitInfo& initializer)
 	height = initializer.height;
 }
 
-//==============================================================================
 void NativeWindow::destroy()
 {
 	impl.reset();
 }
 
-//==============================================================================
 void NativeWindow::swapBuffers()
 {
 	ANKI_COUNTER_START_TIMER(SWAP_BUFFERS_TIME);

+ 0 - 4
src/anki/core/NativeWindowDummy.cpp

@@ -8,22 +8,18 @@
 namespace anki
 {
 
-//==============================================================================
 NativeWindow::~NativeWindow
 {
 }
 
-//==============================================================================
 void NativeWindow::create(NativeWindowInitInfo&)
 {
 }
 
-//==============================================================================
 void NativeWindow::destroy()
 {
 }
 
-//==============================================================================
 void NativeWindow::swapBuffers()
 {
 }

+ 2 - 19
src/anki/core/NativeWindowEglFbdev.cpp

@@ -11,11 +11,6 @@
 namespace anki
 {
 
-//==============================================================================
-// NativeWindowImpl                                                            =
-//==============================================================================
-
-//==============================================================================
 void NativeWindowImpl::create(NativeWindowInitInfo& init)
 {
 	// Create window
@@ -84,9 +79,7 @@ void NativeWindowImpl::create(NativeWindowInitInfo& init)
 	attribs[attr++] = EGL_NONE;
 
 	EGLint configsCount;
-	if(eglChooseConfig(
-		   display, &attribs[0], &configs[0], maxConfigs, &configsCount)
-		== EGL_FALSE)
+	if(eglChooseConfig(display, &attribs[0], &configs[0], maxConfigs, &configsCount) == EGL_FALSE)
 	{
 		throw ANKI_EXCEPTION("Failed to query required EGL configs");
 	}
@@ -158,8 +151,7 @@ void NativeWindowImpl::create(NativeWindowInitInfo& init)
 
 	// Surface
 	//
-	surface = eglCreateWindowSurface(
-		display, config_, static_cast<EGLNativeWindowType>(fbwin), NULL);
+	surface = eglCreateWindowSurface(display, config_, static_cast<EGLNativeWindowType>(fbwin), NULL);
 
 	if(surface == EGL_NO_SURFACE)
 	{
@@ -183,22 +175,15 @@ void NativeWindowImpl::create(NativeWindowInitInfo& init)
 	}
 }
 
-//==============================================================================
 void NativeWindowImpl::destroy()
 {
 	// XXX
 }
 
-//==============================================================================
-// NativeWindow                                                                =
-//==============================================================================
-
-//==============================================================================
 NativeWindow::~NativeWindow()
 {
 }
 
-//==============================================================================
 void NativeWindow::init(NativeWindowInitInfo& initializer)
 {
 	impl.reset(new NativeWindowImpl);
@@ -210,13 +195,11 @@ void NativeWindow::init(NativeWindowInitInfo& initializer)
 	height = initializer.height;
 }
 
-//==============================================================================
 void NativeWindow::destroy()
 {
 	impl.reset();
 }
 
-//==============================================================================
 void NativeWindow::swapBuffers()
 {
 	ANKI_ASSERT(isCreated());

+ 3 - 10
src/anki/core/NativeWindowSdl.cpp

@@ -9,10 +9,8 @@
 namespace anki
 {
 
-const U32 INIT_SUBSYSTEMS = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS
-	| SDL_INIT_GAMECONTROLLER;
+const U32 INIT_SUBSYSTEMS = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER;
 
-//==============================================================================
 Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 {
 	m_alloc = alloc;
@@ -56,12 +54,8 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 		flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
 	}
 
-	m_impl->m_window = SDL_CreateWindow(&init.m_title[0],
-		SDL_WINDOWPOS_UNDEFINED,
-		SDL_WINDOWPOS_UNDEFINED,
-		init.m_width,
-		init.m_height,
-		flags);
+	m_impl->m_window = SDL_CreateWindow(
+		&init.m_title[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, init.m_width, init.m_height, flags);
 
 	if(m_impl->m_window == nullptr)
 	{
@@ -88,7 +82,6 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 void NativeWindow::destroy()
 {
 	if(m_impl != nullptr)

+ 1 - 5
src/anki/core/StdinListener.cpp

@@ -11,7 +11,6 @@
 namespace anki
 {
 
-//==============================================================================
 StdinListener::~StdinListener()
 {
 	m_quit = true;
@@ -29,7 +28,6 @@ StdinListener::~StdinListener()
 	m_q.destroy(m_alloc);
 }
 
-//==============================================================================
 Error StdinListener::create(HeapAllocator<String>& alloc)
 {
 	m_alloc = alloc;
@@ -38,8 +36,7 @@ Error StdinListener::create(HeapAllocator<String>& alloc)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
-Error StdinListener::workingFunc(Thread::Info& info)
+Error StdinListener::workingFunc(ThreadCallbackInfo& info)
 {
 	StdinListener& self = *reinterpret_cast<StdinListener*>(info.m_userData);
 	Array<char, 512> buff;
@@ -59,7 +56,6 @@ Error StdinListener::workingFunc(Thread::Info& info)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 String StdinListener::getLine()
 {
 	String ret;

+ 2 - 4
src/anki/core/StdinListener.h

@@ -15,9 +15,7 @@ namespace anki
 /// @addtogroup core
 /// @{
 
-/// The listener of the stdin.
-/// It initiates a thread that constantly reads the stdin and puts the results
-/// in a queue
+/// The listener of the stdin. It initiates a thread that constantly reads the stdin and puts the results in a queue
 class StdinListener
 {
 public:
@@ -40,7 +38,7 @@ private:
 	Thread m_thrd; ///< The thread
 	Bool8 m_quit = false;
 
-	static Error workingFunc(Thread::Info& info); ///< The thread function
+	static Error workingFunc(ThreadCallbackInfo& info); ///< The thread function
 };
 
 /// @}

+ 56 - 82
src/anki/core/Trace.cpp

@@ -11,79 +11,66 @@
 namespace anki
 {
 
-//==============================================================================
-// Misc                                                                        =
-//==============================================================================
-
-static Array<const char*, U(TraceEventType::COUNT)> eventNames = {
-	{"SCENE_UPDATE",
-		"SCENE_DELETE_STUFF",
-		"SCENE_PHYSICS_UPDATE",
-		"SCENE_NODES_UPDATE",
-		"SCENE_VISIBILITY_TESTS",
-		"VIS_TEST",
-		"VIS_COMBINE_RESULTS",
-		"VIS_ITERATE_SECTORS",
-		"VIS_GATHER_TRIANGLES",
-		"VIS_RASTERIZE",
-		"VIS_RASTERIZER_TEST",
-		"RENDER",
-		"RENDER_MS",
-		"RENDER_IS",
-		"RENDER_SM",
-		"RENDER_IR",
-		"RENDER_DRAWER",
-		"RENDERER_COMMAND_BUFFER_BUILDING",
-		"RENDERER_LIGHT_BINNING",
-		"GL_THREAD",
-		"GL_2ND_LEVEL_CMD_BUFFER",
-		"GL_BIND_RESOURCES",
-		"GL_BIND_PPLINE",
-		"GL_CMD_BUFFER_DESTROY",
-		"SWAP_BUFFERS",
-		"BARRIER_WAIT"}};
-
-static Array<const char*, U(TraceCounterType::COUNT)> counterNames = {
-	{"GR_DRAWCALLS",
-		"GR_DYNAMIC_UNIFORMS_SIZE",
-		"GR_DYNAMIC_STORAGE_SIZE",
-		"GR_VERTICES",
-		"GR_PIPELINES_CREATED",
-		"GR_PIPELINE_BINDS_SKIPPED",
-		"GR_PIPELINE_BINDS_HAPPENED",
-		"RENDERER_LIGHTS",
-		"RENDERER_SHADOW_PASSES",
-		"RENDERER_MERGED_DRAWCALLS",
-		"RENDERER_REFLECTIONS",
-		"RESOURCE_ASYNC_TASKS",
-		"SCENE_NODES_UPDATED"}};
-
-#define ANKI_TRACE_FILE_ERROR()                                                \
-	if(err)                                                                    \
-	{                                                                          \
-		ANKI_LOGE("Error writing the trace file");                             \
+static Array<const char*, U(TraceEventType::COUNT)> eventNames = {{"SCENE_UPDATE",
+	"SCENE_DELETE_STUFF",
+	"SCENE_PHYSICS_UPDATE",
+	"SCENE_NODES_UPDATE",
+	"SCENE_VISIBILITY_TESTS",
+	"VIS_TEST",
+	"VIS_COMBINE_RESULTS",
+	"VIS_ITERATE_SECTORS",
+	"VIS_GATHER_TRIANGLES",
+	"VIS_RASTERIZE",
+	"VIS_RASTERIZER_TEST",
+	"RENDER",
+	"RENDER_MS",
+	"RENDER_IS",
+	"RENDER_SM",
+	"RENDER_IR",
+	"RENDER_DRAWER",
+	"RENDERER_COMMAND_BUFFER_BUILDING",
+	"RENDERER_LIGHT_BINNING",
+	"GL_THREAD",
+	"GL_2ND_LEVEL_CMD_BUFFER",
+	"GL_BIND_RESOURCES",
+	"GL_BIND_PPLINE",
+	"GL_CMD_BUFFER_DESTROY",
+	"SWAP_BUFFERS",
+	"BARRIER_WAIT"}};
+
+static Array<const char*, U(TraceCounterType::COUNT)> counterNames = {{"GR_DRAWCALLS",
+	"GR_DYNAMIC_UNIFORMS_SIZE",
+	"GR_DYNAMIC_STORAGE_SIZE",
+	"GR_VERTICES",
+	"GR_PIPELINES_CREATED",
+	"GR_PIPELINE_BINDS_SKIPPED",
+	"GR_PIPELINE_BINDS_HAPPENED",
+	"RENDERER_LIGHTS",
+	"RENDERER_SHADOW_PASSES",
+	"RENDERER_MERGED_DRAWCALLS",
+	"RENDERER_REFLECTIONS",
+	"RESOURCE_ASYNC_TASKS",
+	"SCENE_NODES_UPDATED"}};
+
+#define ANKI_TRACE_FILE_ERROR()                                                                                        \
+	if(err)                                                                                                            \
+	{                                                                                                                  \
+		ANKI_LOGE("Error writing the trace file");                                                                     \
 	}
 
 const U MAX_EVENTS_DEPTH = 20;
 thread_local HighRezTimer::Scalar g_traceEventStartTime[MAX_EVENTS_DEPTH];
 thread_local I g_traceEventsInFlight = 0;
 
-//==============================================================================
-// TraceManager                                                                =
-//==============================================================================
-
-//==============================================================================
 TraceManager::~TraceManager()
 {
 	// No need to close the json (no need to add ']'). Chrome will take care
 	// of that
 }
 
-//==============================================================================
 Error TraceManager::create(HeapAllocator<U8> alloc, const CString& cacheDir)
 {
-	if(getenv("ANKI_DISABLE_TRACE")
-		&& CString(getenv("ANKI_DISABLE_TRACE")) == "1")
+	if(getenv("ANKI_DISABLE_TRACE") && CString(getenv("ANKI_DISABLE_TRACE")) == "1")
 	{
 		m_disabled = true;
 		return ErrorCode::NONE;
@@ -99,8 +86,7 @@ Error TraceManager::create(HeapAllocator<U8> alloc, const CString& cacheDir)
 	// Create per frame file
 	StringAuto perFrameFname(alloc);
 	perFrameFname.sprintf("%s/per_frame.csv", &cacheDir[0]);
-	ANKI_CHECK(
-		m_perFrameFile.open(perFrameFname.toCString(), File::OpenFlag::WRITE));
+	ANKI_CHECK(m_perFrameFile.open(perFrameFname.toCString(), File::OpenFlag::WRITE));
 
 	ANKI_CHECK(m_perFrameFile.writeText("FPS, "));
 	for(U i = 0; i < U(TraceCounterType::COUNT); ++i)
@@ -117,7 +103,6 @@ Error TraceManager::create(HeapAllocator<U8> alloc, const CString& cacheDir)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 void TraceManager::startEvent()
 {
 	if(ANKI_UNLIKELY(m_disabled))
@@ -132,7 +117,6 @@ void TraceManager::startEvent()
 	g_traceEventStartTime[i] = HighRezTimer::getCurrentTime();
 }
 
-//==============================================================================
 void TraceManager::stopEvent(TraceEventType type)
 {
 	if(ANKI_UNLIKELY(m_disabled))
@@ -140,8 +124,7 @@ void TraceManager::stopEvent(TraceEventType type)
 		return;
 	}
 
-	ANKI_ASSERT(g_traceEventsInFlight > 0
-		&& g_traceEventsInFlight < I(MAX_EVENTS_DEPTH));
+	ANKI_ASSERT(g_traceEventsInFlight > 0 && g_traceEventsInFlight < I(MAX_EVENTS_DEPTH));
 	I i = --g_traceEventsInFlight;
 	ANKI_ASSERT(i >= 0 && i < I(MAX_EVENTS_DEPTH));
 	auto startedTime = g_traceEventStartTime[i];
@@ -152,11 +135,9 @@ void TraceManager::stopEvent(TraceEventType type)
 		auto now = HighRezTimer::getCurrentTime();
 		auto dur = now - startedTime;
 
-		m_entries[id] =
-			Entry{type, startedTime, dur, Thread::getCurrentThreadId()};
+		m_entries[id] = Entry{type, startedTime, dur, Thread::getCurrentThreadId()};
 
-		m_perFrameCounters[U(TraceCounterType::COUNT) + U(type)].fetchAdd(
-			U64(dur * 1000000000.0));
+		m_perFrameCounters[U(TraceCounterType::COUNT) + U(type)].fetchAdd(U64(dur * 1000000000.0));
 	}
 	else
 	{
@@ -165,7 +146,6 @@ void TraceManager::stopEvent(TraceEventType type)
 	}
 }
 
-//==============================================================================
 Error TraceManager::flushCounters()
 {
 	if(ANKI_UNLIKELY(m_disabled))
@@ -177,9 +157,8 @@ Error TraceManager::flushCounters()
 	HighRezTimer::Scalar now = HighRezTimer::getCurrentTime();
 	HighRezTimer::Scalar time = now - m_startFrameTime;
 	F32 fps = 1.0 / time;
-	ANKI_CHECK(m_traceFile.writeText(
-		"{\"name\": \"FPS\", \"cat\": \"PERF\", \"ph\": \"C\", "
-		"\"pid\": 1, \"ts\": %llu, \"args\": {\"val\": %f}},\n",
+	ANKI_CHECK(m_traceFile.writeText("{\"name\": \"FPS\", \"cat\": \"PERF\", \"ph\": \"C\", "
+									 "\"pid\": 1, \"ts\": %llu, \"args\": {\"val\": %f}},\n",
 		U64(m_startFrameTime * 1000000.0),
 		fps));
 
@@ -189,9 +168,8 @@ Error TraceManager::flushCounters()
 	{
 		auto count = m_perFrameCounters[i].exchange(0);
 
-		ANKI_CHECK(m_traceFile.writeText(
-			"{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"C\", "
-			"\"pid\": 1, \"ts\": %llu, \"args\": {\"val\": %llu}},\n",
+		ANKI_CHECK(m_traceFile.writeText("{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"C\", "
+										 "\"pid\": 1, \"ts\": %llu, \"args\": {\"val\": %llu}},\n",
 			counterNames[i],
 			U64(m_startFrameTime * 1000000.0),
 			count));
@@ -202,7 +180,6 @@ Error TraceManager::flushCounters()
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 Error TraceManager::flushEvents()
 {
 	if(ANKI_UNLIKELY(m_disabled))
@@ -226,9 +203,8 @@ Error TraceManager::flushEvents()
 			continue;
 		}
 
-		ANKI_CHECK(m_traceFile.writeText(
-			"{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"X\", "
-			"\"pid\": 1, \"tid\": %llu, \"ts\": %llu, \"dur\": %llu},\n",
+		ANKI_CHECK(m_traceFile.writeText("{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"X\", "
+										 "\"pid\": 1, \"tid\": %llu, \"ts\": %llu, \"dur\": %llu},\n",
 			eventNames[e.m_event],
 			e.m_tid,
 			startMicroSec,
@@ -245,7 +221,6 @@ Error TraceManager::flushEvents()
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 void TraceManager::startFrame()
 {
 	if(ANKI_UNLIKELY(m_disabled))
@@ -256,7 +231,6 @@ void TraceManager::startFrame()
 	m_startFrameTime = HighRezTimer::getCurrentTime();
 }
 
-//==============================================================================
 void TraceManager::stopFrame()
 {
 	if(ANKI_UNLIKELY(m_disabled))

+ 12 - 17
src/anki/core/Trace.h

@@ -83,8 +83,7 @@ public:
 
 	~TraceManager();
 
-	ANKI_USE_RESULT Error create(
-		HeapAllocator<U8> alloc, const CString& cacheDir);
+	ANKI_USE_RESULT Error create(HeapAllocator<U8> alloc, const CString& cacheDir);
 
 	void startEvent();
 
@@ -109,7 +108,7 @@ private:
 		TraceEventType m_event;
 		HighRezTimer::Scalar m_timestamp; ///< When it started.
 		HighRezTimer::Scalar m_duration;
-		Thread::Id m_tid;
+		ThreadId m_tid;
 	};
 
 	static const U BUFFERED_ENTRIES = 1024 * 20;
@@ -120,10 +119,8 @@ private:
 	File m_perRunFile;
 	HighRezTimer::Scalar m_startFrameTime;
 
-	Array<Atomic<U64>, U(TraceEventType::COUNT) + U(TraceCounterType::COUNT)>
-		m_perFrameCounters = {{}};
-	Array<Atomic<U64>, U(TraceEventType::COUNT) + U(TraceCounterType::COUNT)>
-		m_perRunCounters = {{}};
+	Array<Atomic<U64>, U(TraceEventType::COUNT) + U(TraceCounterType::COUNT)> m_perFrameCounters = {{}};
+	Array<Atomic<U64>, U(TraceEventType::COUNT) + U(TraceCounterType::COUNT)> m_perRunCounters = {{}};
 
 	Bool m_disabled = false;
 
@@ -140,11 +137,9 @@ using TraceManagerSingleton = Singleton<TraceManager>;
 
 #define ANKI_TRACE_START_EVENT(name_) TraceManagerSingleton::get().startEvent()
 
-#define ANKI_TRACE_STOP_EVENT(name_)                                           \
-	TraceManagerSingleton::get().stopEvent(TraceEventType::name_)
+#define ANKI_TRACE_STOP_EVENT(name_) TraceManagerSingleton::get().stopEvent(TraceEventType::name_)
 
-#define ANKI_TRACE_INC_COUNTER(name_, val_)                                    \
-	TraceManagerSingleton::get().incCounter(TraceCounterType::name_, val_)
+#define ANKI_TRACE_INC_COUNTER(name_, val_) TraceManagerSingleton::get().incCounter(TraceCounterType::name_, val_)
 
 #define ANKI_TRACE_START_FRAME() TraceManagerSingleton::get().startFrame()
 
@@ -160,12 +155,12 @@ using TraceManagerSingleton = Singleton<TraceManager>;
 
 #endif
 
-#define ANKI_TRACE_START_STOP_EVENT(execute, event)                            \
-	do                                                                         \
-	{                                                                          \
-		ANKI_TRACE_START_EVENT(event);                                         \
-		execute;                                                               \
-		ANKI_TRACE_STOP_EVENT(event);                                          \
+#define ANKI_TRACE_START_STOP_EVENT(execute, event)                                                                    \
+	do                                                                                                                 \
+	{                                                                                                                  \
+		ANKI_TRACE_START_EVENT(event);                                                                                 \
+		execute;                                                                                                       \
+		ANKI_TRACE_STOP_EVENT(event);                                                                                  \
 	} while(0)
 /// @}
 

+ 1 - 5
src/anki/event/AnimationEvent.cpp

@@ -12,15 +12,12 @@
 namespace anki
 {
 
-//==============================================================================
 AnimationEvent::AnimationEvent(EventManager* manager)
 	: Event(manager)
 {
 }
 
-//==============================================================================
-Error AnimationEvent::init(
-	const AnimationResourcePtr& anim, SceneNode* movableSceneNode)
+Error AnimationEvent::init(const AnimationResourcePtr& anim, SceneNode* movableSceneNode)
 {
 	ANKI_ASSERT(movableSceneNode);
 	m_anim = anim;
@@ -33,7 +30,6 @@ Error AnimationEvent::init(
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 Error AnimationEvent::update(F32 prevUpdateTime, F32 crntTime)
 {
 	ANKI_ASSERT(getSceneNode());

+ 1 - 2
src/anki/event/AnimationEvent.h

@@ -18,8 +18,7 @@ class AnimationEvent : public Event
 public:
 	AnimationEvent(EventManager* manager);
 
-	ANKI_USE_RESULT Error init(
-		const AnimationResourcePtr& anim, SceneNode* movableSceneNode);
+	ANKI_USE_RESULT Error init(const AnimationResourcePtr& anim, SceneNode* movableSceneNode);
 
 	/// Implements Event::update
 	ANKI_USE_RESULT Error update(F32 prevUpdateTime, F32 crntTime) override;

+ 0 - 7
src/anki/event/Event.cpp

@@ -11,18 +11,15 @@
 namespace anki
 {
 
-//==============================================================================
 Event::Event(EventManager* manager)
 	: m_manager(manager)
 {
 }
 
-//==============================================================================
 Event::~Event()
 {
 }
 
-//==============================================================================
 void Event::init(F32 startTime, F32 duration, SceneNode* snode, Flag flags)
 {
 	m_startTime = startTime;
@@ -37,7 +34,6 @@ void Event::init(F32 startTime, F32 duration, SceneNode* snode, Flag flags)
 	}
 }
 
-//==============================================================================
 void Event::setMarkedForDeletion()
 {
 	if(!getMarkedForDeletion())
@@ -47,7 +43,6 @@ void Event::setMarkedForDeletion()
 	}
 }
 
-//==============================================================================
 F32 Event::getDelta(F32 crntTime) const
 {
 	F32 d = crntTime - m_startTime; // delta
@@ -55,13 +50,11 @@ F32 Event::getDelta(F32 crntTime) const
 	return dp;
 }
 
-//==============================================================================
 SceneGraph& Event::getSceneGraph()
 {
 	return m_manager->getSceneGraph();
 }
 
-//==============================================================================
 const SceneGraph& Event::getSceneGraph() const
 {
 	return m_manager->getSceneGraph();

+ 3 - 8
src/anki/event/Event.h

@@ -40,10 +40,7 @@ public:
 
 	virtual ~Event();
 
-	void init(F32 startTime,
-		F32 duration,
-		SceneNode* snode = nullptr,
-		Flag flags = Flag::NONE);
+	void init(F32 startTime, F32 duration, SceneNode* snode = nullptr, Flag flags = Flag::NONE);
 
 	F32 getStartTime() const
 	{
@@ -89,8 +86,7 @@ public:
 
 	void setReanimate(Bool reanimate)
 	{
-		m_flags = (reanimate) ? (m_flags | Flag::REANIMATE)
-							  : (m_flags & ~Flag::REANIMATE);
+		m_flags = (reanimate) ? (m_flags | Flag::REANIMATE) : (m_flags & ~Flag::REANIMATE);
 	}
 
 	Bool getReanimate() const
@@ -111,8 +107,7 @@ public:
 	/// @param prevUpdateTime The time of the previous update (sec)
 	/// @param crntTime The current time (sec)
 	/// @param[out] Return false if you don't want to be killed
-	virtual ANKI_USE_RESULT Error onKilled(
-		F32 prevUpdateTime, F32 crntTime, Bool& kill)
+	virtual ANKI_USE_RESULT Error onKilled(F32 prevUpdateTime, F32 crntTime, Bool& kill)
 	{
 		(void)prevUpdateTime;
 		(void)crntTime;

+ 2 - 13
src/anki/event/EventManager.cpp

@@ -9,12 +9,10 @@
 namespace anki
 {
 
-//==============================================================================
 EventManager::EventManager()
 {
 }
 
-//==============================================================================
 EventManager::~EventManager()
 {
 	Error err = iterateEvents([&](Event& event) -> Error {
@@ -26,7 +24,6 @@ EventManager::~EventManager()
 	deleteEventsMarkedForDeletion();
 }
 
-//==============================================================================
 Error EventManager::create(SceneGraph* scene)
 {
 	ANKI_ASSERT(scene);
@@ -34,33 +31,28 @@ Error EventManager::create(SceneGraph* scene)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 SceneAllocator<U8> EventManager::getSceneAllocator() const
 {
 	return m_scene->getAllocator();
 }
 
-//==============================================================================
 SceneFrameAllocator<U8> EventManager::getFrameAllocator() const
 {
 	return m_scene->getFrameAllocator();
 }
 
-//==============================================================================
 void EventManager::registerEvent(Event* event)
 {
 	ANKI_ASSERT(event);
 	m_events.pushBack(getSceneAllocator(), event);
 }
 
-//==============================================================================
 void EventManager::unregisterEvent(List<Event*>::Iterator it)
 {
 	ANKI_ASSERT(it != m_events.getEnd());
 	m_events.erase(getSceneAllocator(), it);
 }
 
-//==============================================================================
 Error EventManager::updateAllEvents(F32 prevUpdateTime, F32 crntTime)
 {
 	Error err = ErrorCode::NONE;
@@ -73,15 +65,13 @@ Error EventManager::updateAllEvents(F32 prevUpdateTime, F32 crntTime)
 	{
 		Event* event = *it;
 
-		// If event or the node's event is marked for deletion then dont
-		// do anything else for that event
+		// If event or the node's event is marked for deletion then dont do anything else for that event
 		if(event->getMarkedForDeletion())
 		{
 			continue;
 		}
 
-		if(event->getSceneNode() != nullptr
-			&& event->getSceneNode()->getMarkedForDeletion())
+		if(event->getSceneNode() != nullptr && event->getSceneNode()->getMarkedForDeletion())
 		{
 			event->setMarkedForDeletion();
 			continue;
@@ -127,7 +117,6 @@ Error EventManager::updateAllEvents(F32 prevUpdateTime, F32 crntTime)
 	return err;
 }
 
-//==============================================================================
 void EventManager::deleteEventsMarkedForDeletion()
 {
 	SceneAllocator<U8> alloc = getSceneAllocator();

+ 0 - 124
src/anki/event/FollowPathEvent.cpp

@@ -1,124 +0,0 @@
-// Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <anki/event/FollowPathEvent.h>
-#include <anki/scene/Path.h>
-
-namespace anki
-{
-
-#if 0
-
-//==============================================================================
-FollowPathEvent::FollowPathEvent(
-	EventManager* manager, F32 startTime, F32 duration, U8 flags,
-	SceneNode* movableSceneNode_, Path* path_, F32 distPerTime_)
-	:	Event(manager, startTime, duration, nullptr, flags),
-		distPerTime(distPerTime_),
-		movableSceneNode(movableSceneNode_),
-		path(path_)
-{
-	ANKI_ASSERT(path && movableSceneNode);
-}
-
-//==============================================================================
-void FollowPathEvent::update(F32 prevUpdateTime, F32 crntTime)
-{
-	MoveComponent& move = movableSceneNode->getComponent<MoveComponent>();
-
-	I pointA = 0;
-	I pointB = 0;
-
-	// Calculate the current distance. Clamp it to max distance
-	F32 crntDistance = distPerTime * (crntTime - getStartTime());
-	ANKI_ASSERT(crntDistance >= 0.0);
-	crntDistance = std::min(crntDistance, path->getDistance());
-
-	const I pointsCount = path->getPoints().size();
-	ANKI_ASSERT(pointsCount > 1);
-
-	// Find the points that we lie between
-	for(I i = 1; i < pointsCount; i++)
-	{
-		const PathPoint& ppa = path->getPoints()[i - 1];
-		const PathPoint& ppb = path->getPoints()[i];
-
-		if(crntDistance > ppa.getDistanceFromFirst() 
-			&& crntDistance <= ppb.getDistanceFromFirst())
-		{
-			pointA = i - 1;
-			pointB = i;
-			break;
-		}
-	}
-
-	ANKI_ASSERT(pointA < pointsCount && pointB < pointsCount);
-
-	I preA = std::max((I)0, pointA - 1);
-	I postB = std::min(pointsCount - 1, pointB + 1);
-	/*I pminus2 = std::max((I)0, pointA - 2);
-	I pminus1 = std::max((I)0, pointA - 1);*/
-
-	// Calculate the u [0.0, 1.0]
-	F32 u = path->getPoints()[pointB].getDistance() + getEpsilon<F32>();
-	ANKI_ASSERT(u != 0.0);
-
-	const F32 c = crntDistance 
-		- path->getPoints()[pointA].getDistanceFromFirst();
-
-	u = c / u;
-
-	// Calculate and set new position and rotation for the movable
-	/*Vec3 newPos = cubicInterpolate(
-		path->getPoints()[preA].getPosition(),
-		path->getPoints()[pointA].getPosition(),
-		path->getPoints()[pointB].getPosition(),
-		path->getPoints()[postB].getPosition(),
-		u);*/
-	Vec3 newPos = interpolate(
-		path->getPoints()[pointA].getPosition(),
-		path->getPoints()[pointB].getPosition(),
-		u);
-
-	{
-		F32 u2 = u * u;
-		Vec4 us(1, u, u2, u2 * u);
-		F32 t = 0.7;
-		
-		Mat4 tentionMat(
-			0.0, 1.0, 0.0, 0.0,
-			-t, 0.0, t, 0.0,
-			2.0 * t, t - 3.0, 3.0 - 2.0 * t, -t,
-			-t, 2.0 - t, t - 2.0, t);
-
-		Vec4 tmp = us * tentionMat;
-
-		Mat4 posMat;
-		posMat.setRows(
-			Vec4(path->getPoints()[preA].getPosition(), 1.0),
-			Vec4(path->getPoints()[pointA].getPosition(), 1.0),
-			Vec4(path->getPoints()[pointB].getPosition(), 1.0),
-			Vec4(path->getPoints()[postB].getPosition(), 1.0));
-
-		Vec4 finalPos = tmp * posMat;
-
-		newPos = finalPos.xyz();
-	}
-
-	Quat newRot = path->getPoints()[pointA].getRotation().slerp(
-			path->getPoints()[pointB].getRotation(),
-			u);
-
-	F32 scale = move.getLocalTransform().getScale();
-	Transform trf;
-	trf.setOrigin(newPos);
-	trf.setRotation(Mat3(newRot));
-	trf.setScale(scale);
-	move.setLocalTransform(trf);
-}
-
-#endif
-
-} // end namespace anki

+ 0 - 39
src/anki/event/FollowPathEvent.h

@@ -1,39 +0,0 @@
-// Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <anki/event/Event.h>
-#include <anki/scene/SceneNode.h>
-
-namespace anki
-{
-
-#if 0
-
-class FollowPathEvent: public Event
-{
-public:
-	/// @name Constructors/Destructor
-	/// @{
-
-	/// Constructor
-	FollowPathEvent(
-		EventManager* manager, F32 startTime, F32 duration, U8 flags, // Event
-		SceneNode* movableSceneNode, Path* path, F32 distPerTime);
-	/// @}
-
-	/// Implements Event::update
-	void update(F32 prevUpdateTime, F32 crntTime);
-
-private:
-	F32 distPerTime;
-	SceneNode* movableSceneNode;
-	Path* path;
-};
-
-#endif
-
-} // end namespace anki

+ 0 - 3
src/anki/event/JitterMoveEvent.cpp

@@ -11,7 +11,6 @@
 namespace anki
 {
 
-//==============================================================================
 Error JitterMoveEvent::init(F32 startTime, F32 duration, SceneNode* node)
 {
 	ANKI_ASSERT(node);
@@ -24,7 +23,6 @@ Error JitterMoveEvent::init(F32 startTime, F32 duration, SceneNode* node)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 void JitterMoveEvent::setPositionLimits(const Vec4& posMin, const Vec4& posMax)
 {
 	for(U i = 0; i < 3; i++)
@@ -36,7 +34,6 @@ void JitterMoveEvent::setPositionLimits(const Vec4& posMin, const Vec4& posMax)
 	m_newPos += m_originalPos;
 }
 
-//==============================================================================
 Error JitterMoveEvent::update(F32 prevUpdateTime, F32 crntTime)
 {
 	SceneNode* node = getSceneNode();

+ 1 - 2
src/anki/event/JitterMoveEvent.h

@@ -24,8 +24,7 @@ public:
 	{
 	}
 
-	ANKI_USE_RESULT Error init(
-		F32 startTime, F32 duration, SceneNode* movableSceneNode);
+	ANKI_USE_RESULT Error init(F32 startTime, F32 duration, SceneNode* movableSceneNode);
 
 	/// Implements Event::update
 	ANKI_USE_RESULT Error update(F32 prevUpdateTime, F32 crntTime);

+ 4 - 11
src/anki/event/LightEvent.cpp

@@ -10,7 +10,6 @@
 namespace anki
 {
 
-//==============================================================================
 Error LightEvent::init(F32 startTime, F32 duration, SceneNode* light)
 {
 	Event::init(startTime, duration, light);
@@ -38,7 +37,6 @@ Error LightEvent::init(F32 startTime, F32 duration, SceneNode* light)
 	return ErrorCode::NONE;
 }
 
-//==============================================================================
 Error LightEvent::update(F32 prevUpdateTime, F32 crntTime)
 {
 	F32 freq = randRange(m_freq - m_freqDeviation, m_freq + m_freqDeviation);
@@ -68,22 +66,17 @@ Error LightEvent::update(F32 prevUpdateTime, F32 crntTime)
 	{
 		Vec4 outCol = m_originalDiffColor + factor * m_intensityMultiplier;
 
-		LensFlareComponent* lfc =
-			getSceneNode()->tryGetComponent<LensFlareComponent>();
+		LensFlareComponent* lfc = getSceneNode()->tryGetComponent<LensFlareComponent>();
 
-		if(lfc
-			&& lfc->getColorMultiplier().xyz()
-				== lightc.getDiffuseColor().xyz())
+		if(lfc && lfc->getColorMultiplier().xyz() == lightc.getDiffuseColor().xyz())
 		{
-			lfc->setColorMultiplier(
-				Vec4(outCol.xyz(), lfc->getColorMultiplier().w()));
+			lfc->setColorMultiplier(Vec4(outCol.xyz(), lfc->getColorMultiplier().w()));
 		}
 
 		lightc.setDiffuseColor(outCol);
 	}
 
-	lightc.setSpecularColor(
-		m_originalSpecColor + factor * m_specularIntensityMultiplier);
+	lightc.setSpecularColor(m_originalSpecColor + factor * m_specularIntensityMultiplier);
 
 	return ErrorCode::NONE;
 }

+ 4 - 4
src/anki/event/MainRendererPpsHdrEvent.cpp

@@ -11,7 +11,7 @@ namespace anki
 
 #if 0
 
-//==============================================================================
+
 MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(float startTime,
 	float duration,
 	float exposure_,
@@ -30,7 +30,7 @@ MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(float startTime,
 	//originalData.blurringDist = hdr.getBlurringDistance();
 }
 
-//==============================================================================
+
 MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(
 	const MainRendererPpsHdrEvent& b)
 	: Event(ET_MAIN_RENDERER_PPS_HDR, 0.0, 0.0)
@@ -38,7 +38,7 @@ MainRendererPpsHdrEvent::MainRendererPpsHdrEvent(
 	*this = b;
 }
 
-//==============================================================================
+
 MainRendererPpsHdrEvent& MainRendererPpsHdrEvent::operator=(
 	const MainRendererPpsHdrEvent& b)
 {
@@ -48,7 +48,7 @@ MainRendererPpsHdrEvent& MainRendererPpsHdrEvent::operator=(
 	return *this;
 }
 
-//==============================================================================
+
 void MainRendererPpsHdrEvent::updateSp(float /*prevUpdateTime*/, float crntTime)
 {
 	float d = crntTime - getStartTime(); // delta

+ 46 - 102
src/anki/gr/CommandBuffer.h

@@ -15,8 +15,7 @@ namespace anki
 /// @addtogroup graphics
 /// @{
 
-/// The draw indirect structure for index drawing, also the parameters of a
-/// regular drawcall
+/// The draw indirect structure for index drawing, also the parameters of a regular drawcall
 class DrawElementsIndirectInfo
 {
 public:
@@ -24,11 +23,7 @@ public:
 	{
 	}
 
-	DrawElementsIndirectInfo(U32 count,
-		U32 instanceCount,
-		U32 firstIndex,
-		U32 baseVertex,
-		U32 baseInstance)
+	DrawElementsIndirectInfo(U32 count, U32 instanceCount, U32 firstIndex, U32 baseVertex, U32 baseInstance)
 		: m_count(count)
 		, m_instanceCount(instanceCount)
 		, m_firstIndex(firstIndex)
@@ -44,8 +39,7 @@ public:
 	U32 m_baseInstance = 0;
 };
 
-/// The draw indirect structure for arrays drawing, also the parameters of a
-/// regular drawcall
+/// The draw indirect structure for arrays drawing, also the parameters of a regular drawcall
 class DrawArraysIndirectInfo
 {
 public:
@@ -53,8 +47,7 @@ public:
 	{
 	}
 
-	DrawArraysIndirectInfo(
-		U32 count, U32 instanceCount, U32 first, U32 baseInstance)
+	DrawArraysIndirectInfo(U32 count, U32 instanceCount, U32 first, U32 baseInstance)
 		: m_count(count)
 		, m_instanceCount(instanceCount)
 		, m_first(first)
@@ -68,8 +61,7 @@ public:
 	U32 m_baseInstance = 0;
 };
 
-/// Command buffer initialization hints. They are used to optimize the
-/// allocators of a command buffer.
+/// Command buffer initialization hints. They are used to optimize the allocators of a command buffer.
 class CommandBufferInitHints
 {
 	friend class CommandBufferImpl;
@@ -158,20 +150,14 @@ public:
 	void endRenderPass();
 
 	/// Bind resources.
-	void bindResourceGroup(
-		ResourceGroupPtr rc, U slot, const TransientMemoryInfo* dynInfo);
+	void bindResourceGroup(ResourceGroupPtr rc, U slot, const TransientMemoryInfo* dynInfo);
 	/// @}
 
 	/// @name Jobs
 	/// @{
-	void drawElements(U32 count,
-		U32 instanceCount = 1,
-		U32 firstIndex = 0,
-		U32 baseVertex = 0,
-		U32 baseInstance = 0);
+	void drawElements(U32 count, U32 instanceCount = 1, U32 firstIndex = 0, U32 baseVertex = 0, U32 baseInstance = 0);
 
-	void drawArrays(
-		U32 count, U32 instanceCount = 1, U32 first = 0, U32 baseInstance = 0);
+	void drawArrays(U32 count, U32 instanceCount = 1, U32 first = 0, U32 baseInstance = 0);
 
 	void drawElementsConditional(OcclusionQueryPtr query,
 		U32 count,
@@ -180,11 +166,8 @@ public:
 		U32 baseVertex = 0,
 		U32 baseInstance = 0);
 
-	void drawArraysConditional(OcclusionQueryPtr query,
-		U32 count,
-		U32 instanceCount = 1,
-		U32 first = 0,
-		U32 baseInstance = 0);
+	void drawArraysConditional(
+		OcclusionQueryPtr query, U32 count, U32 instanceCount = 1, U32 first = 0, U32 baseInstance = 0);
 
 	void dispatchCompute(U32 groupCountX, U32 groupCountY, U32 groupCountZ);
 
@@ -194,31 +177,22 @@ public:
 	/// Generate mipmaps only for 3D textures.
 	void generateMipmaps3d(TexturePtr tex);
 
-	void copyTextureSurfaceToTextureSurface(TexturePtr src,
-		const TextureSurfaceInfo& srcSurf,
-		TexturePtr dest,
-		const TextureSurfaceInfo& destSurf);
+	void copyTextureSurfaceToTextureSurface(
+		TexturePtr src, const TextureSurfaceInfo& srcSurf, TexturePtr dest, const TextureSurfaceInfo& destSurf);
 
-	void copyTextureVolumeToTextureVolume(TexturePtr src,
-		const TextureVolumeInfo& srcVol,
-		TexturePtr dest,
-		const TextureVolumeInfo& destVol);
+	void copyTextureVolumeToTextureVolume(
+		TexturePtr src, const TextureVolumeInfo& srcVol, TexturePtr dest, const TextureVolumeInfo& destVol);
 
 	void clearTexture(TexturePtr tex, const ClearValue& clearValue);
 
-	void clearTextureSurface(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		const ClearValue& clearValue);
+	void clearTextureSurface(TexturePtr tex, const TextureSurfaceInfo& surf, const ClearValue& clearValue);
 
-	void clearTextureVolume(TexturePtr tex,
-		const TextureVolumeInfo& vol,
-		const ClearValue& clearValue);
+	void clearTextureVolume(TexturePtr tex, const TextureVolumeInfo& vol, const ClearValue& clearValue);
 
 	/// Fill a buffer with some value.
 	/// @param[in,out] buff The buffer to fill.
 	/// @param offset From where to start filling. Must be multiple of 4.
-	/// @param size The bytes to fill. Must be multiple of 4 or MAX_PTR_SIZE to
-	///             indicate the whole buffer.
+	/// @param size The bytes to fill. Must be multiple of 4 or MAX_PTR_SIZE to indicate the whole buffer.
 	/// @param value The value to fill the buffer with.
 	void fillBuffer(BufferPtr buff, PtrSize offset, PtrSize size, U32 value);
 	/// @}
@@ -226,71 +200,41 @@ public:
 	/// @name Resource upload
 	/// @{
 
-	/// Upload data to a texture surface. It's the base of all texture surface
-	/// upload methods.
-	void uploadTextureSurface(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		const TransientMemoryToken& token);
-
-	/// Same as uploadTextureSurface but it will perform the transient
-	/// allocation as well. If that allocation fails expect the defaul OOM
-	/// behaviour (crash).
-	void uploadTextureSurfaceData(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		void*& data,
-		PtrSize& dataSize);
-
-	/// Same as uploadTextureSurfaceData but it will return a nullptr in @a data
-	/// if there is a OOM condition.
-	void tryUploadTextureSurfaceData(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		void*& data,
-		PtrSize& dataSize);
-
-	/// Same as uploadTextureSurface but it will perform the transient
-	/// allocation and copy to it the @a data. If that allocation fails expect
-	/// the defaul OOM behaviour (crash).
-	void uploadTextureSurfaceCopyData(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		void* data,
-		PtrSize dataSize);
-
-	/// Upload data to a texture volume. It's the base of all texture volume
-	/// upload methods.
-	void uploadTextureVolume(TexturePtr tex,
-		const TextureVolumeInfo& vol,
-		const TransientMemoryToken& token);
-
-	/// Same as uploadTextureVolume but it will perform the transient
-	/// allocation and copy to it the @a data. If that allocation fails expect
-	/// the defaul OOM behaviour (crash).
-	void uploadTextureVolumeCopyData(TexturePtr tex,
-		const TextureVolumeInfo& surf,
-		void* data,
-		PtrSize dataSize);
+	/// Upload data to a texture surface. It's the base of all texture surface upload methods.
+	void uploadTextureSurface(TexturePtr tex, const TextureSurfaceInfo& surf, const TransientMemoryToken& token);
+
+	/// Same as uploadTextureSurface but it will perform the transient allocation as well. If that allocation fails
+	/// expect the defaul OOM behaviour (crash).
+	void uploadTextureSurfaceData(TexturePtr tex, const TextureSurfaceInfo& surf, void*& data, PtrSize& dataSize);
+
+	/// Same as uploadTextureSurfaceData but it will return a nullptr in @a data if there is a OOM condition.
+	void tryUploadTextureSurfaceData(TexturePtr tex, const TextureSurfaceInfo& surf, void*& data, PtrSize& dataSize);
+
+	/// Same as uploadTextureSurface but it will perform the transient allocation and copy to it the @a data. If that
+	/// allocation fails expect the defaul OOM behaviour (crash).
+	void uploadTextureSurfaceCopyData(TexturePtr tex, const TextureSurfaceInfo& surf, void* data, PtrSize dataSize);
+
+	/// Upload data to a texture volume. It's the base of all texture volume upload methods.
+	void uploadTextureVolume(TexturePtr tex, const TextureVolumeInfo& vol, const TransientMemoryToken& token);
+
+	/// Same as uploadTextureVolume but it will perform the transient allocation and copy to it the @a data. If that
+	/// allocation fails expect the defaul OOM behaviour (crash).
+	void uploadTextureVolumeCopyData(TexturePtr tex, const TextureVolumeInfo& surf, void* data, PtrSize dataSize);
 
 	/// Upload data to a buffer.
-	void uploadBuffer(
-		BufferPtr buff, PtrSize offset, const TransientMemoryToken& token);
+	void uploadBuffer(BufferPtr buff, PtrSize offset, const TransientMemoryToken& token);
 	/// @}
 
 	/// @name Sync
 	/// @{
-	void setTextureSurfaceBarrier(TexturePtr tex,
-		TextureUsageBit prevUsage,
-		TextureUsageBit nextUsage,
-		const TextureSurfaceInfo& surf);
-
-	void setTextureVolumeBarrier(TexturePtr tex,
-		TextureUsageBit prevUsage,
-		TextureUsageBit nextUsage,
-		const TextureVolumeInfo& vol);
-
-	void setBufferBarrier(BufferPtr buff,
-		BufferUsageBit prevUsage,
-		BufferUsageBit nextUsage,
-		PtrSize offset,
-		PtrSize size);
+	void setTextureSurfaceBarrier(
+		TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSurfaceInfo& surf);
+
+	void setTextureVolumeBarrier(
+		TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureVolumeInfo& vol);
+
+	void setBufferBarrier(
+		BufferPtr buff, BufferUsageBit prevUsage, BufferUsageBit nextUsage, PtrSize offset, PtrSize size);
 	/// @}
 
 	/// @name Other

+ 10 - 24
src/anki/gr/CommandBuffer.inl.h

@@ -9,11 +9,8 @@
 namespace anki
 {
 
-//==============================================================================
-inline void CommandBuffer::uploadTextureSurfaceData(TexturePtr tex,
-	const TextureSurfaceInfo& surf,
-	void*& data,
-	PtrSize& dataSize)
+inline void CommandBuffer::uploadTextureSurfaceData(
+	TexturePtr tex, const TextureSurfaceInfo& surf, void*& data, PtrSize& dataSize)
 {
 	PtrSize allocationSize;
 	const BufferUsageBit usage = BufferUsageBit::TEXTURE_UPLOAD_SOURCE;
@@ -21,17 +18,13 @@ inline void CommandBuffer::uploadTextureSurfaceData(TexturePtr tex,
 	ANKI_ASSERT(dataSize <= allocationSize);
 
 	TransientMemoryToken token;
-	data =
-		getManager().allocateFrameTransientMemory(allocationSize, usage, token);
+	data = getManager().allocateFrameTransientMemory(allocationSize, usage, token);
 
 	uploadTextureSurface(tex, surf, token);
 }
 
-//==============================================================================
-inline void CommandBuffer::tryUploadTextureSurfaceData(TexturePtr tex,
-	const TextureSurfaceInfo& surf,
-	void*& data,
-	PtrSize& dataSize)
+inline void CommandBuffer::tryUploadTextureSurfaceData(
+	TexturePtr tex, const TextureSurfaceInfo& surf, void*& data, PtrSize& dataSize)
 {
 	PtrSize allocationSize;
 	const BufferUsageBit usage = BufferUsageBit::TEXTURE_UPLOAD_SOURCE;
@@ -39,8 +32,7 @@ inline void CommandBuffer::tryUploadTextureSurfaceData(TexturePtr tex,
 	ANKI_ASSERT(dataSize <= allocationSize);
 
 	TransientMemoryToken token;
-	data = getManager().tryAllocateFrameTransientMemory(
-		allocationSize, usage, token);
+	data = getManager().tryAllocateFrameTransientMemory(allocationSize, usage, token);
 
 	if(data)
 	{
@@ -48,11 +40,8 @@ inline void CommandBuffer::tryUploadTextureSurfaceData(TexturePtr tex,
 	}
 }
 
-//==============================================================================
-inline void CommandBuffer::uploadTextureSurfaceCopyData(TexturePtr tex,
-	const TextureSurfaceInfo& surf,
-	void* data,
-	PtrSize dataSize)
+inline void CommandBuffer::uploadTextureSurfaceCopyData(
+	TexturePtr tex, const TextureSurfaceInfo& surf, void* data, PtrSize dataSize)
 {
 	PtrSize allocationSize;
 	const BufferUsageBit usage = BufferUsageBit::TEXTURE_UPLOAD_SOURCE;
@@ -60,14 +49,12 @@ inline void CommandBuffer::uploadTextureSurfaceCopyData(TexturePtr tex,
 	ANKI_ASSERT(dataSize <= allocationSize);
 
 	TransientMemoryToken token;
-	void* ptr =
-		getManager().allocateFrameTransientMemory(allocationSize, usage, token);
+	void* ptr = getManager().allocateFrameTransientMemory(allocationSize, usage, token);
 	memcpy(ptr, data, dataSize);
 
 	uploadTextureSurface(tex, surf, token);
 }
 
-//==============================================================================
 inline void CommandBuffer::uploadTextureVolumeCopyData(
 	TexturePtr tex, const TextureVolumeInfo& vol, void* data, PtrSize dataSize)
 {
@@ -77,8 +64,7 @@ inline void CommandBuffer::uploadTextureVolumeCopyData(
 	ANKI_ASSERT(dataSize <= allocationSize);
 
 	TransientMemoryToken token;
-	void* ptr =
-		getManager().allocateFrameTransientMemory(allocationSize, usage, token);
+	void* ptr = getManager().allocateFrameTransientMemory(allocationSize, usage, token);
 	memcpy(ptr, data, dataSize);
 
 	uploadTextureVolume(tex, vol, token);

+ 1 - 3
src/anki/gr/Common.cpp

@@ -8,8 +8,6 @@
 namespace anki
 {
 
-//==============================================================================
-Array<CString, U(GpuVendor::COUNT)> GPU_VENDOR_STR = {
-	{"UNKNOWN", "ARM", "NVIDIA", "AMD", "INTEL"}};
+Array<CString, U(GpuVendor::COUNT)> GPU_VENDOR_STR = {{"UNKNOWN", "ARM", "NVIDIA", "AMD", "INTEL"}};
 
 } // end namespace anki

+ 9 - 5
src/anki/gr/Common.h

@@ -32,9 +32,9 @@ class ResourceGroupInitInfo;
 template<typename T>
 using GrObjectPtr = IntrusivePtr<T, DefaultPtrDeleter<T>>;
 
-#define ANKI_GR_CLASS(x_)                                                      \
-	class x_##Impl;                                                            \
-	class x_;                                                                  \
+#define ANKI_GR_CLASS(x_)                                                                                              \
+	class x_##Impl;                                                                                                    \
+	class x_;                                                                                                          \
 	using x_##Ptr = GrObjectPtr<x_>;
 
 ANKI_GR_CLASS(Buffer)
@@ -169,14 +169,18 @@ class TransientMemoryToken
 anki_internal:
 	PtrSize m_offset = 0;
 	PtrSize m_range = 0;
-	TransientMemoryTokenLifetime m_lifetime =
-		TransientMemoryTokenLifetime::PER_FRAME;
+	TransientMemoryTokenLifetime m_lifetime = TransientMemoryTokenLifetime::PER_FRAME;
 	BufferUsageBit m_usage = BufferUsageBit::NONE;
 
 	void markUnused()
 	{
 		m_offset = m_range = MAX_U32;
 	}
+
+	Bool isUnused() const
+	{
+		return m_offset == MAX_U32 && m_range == MAX_U32;
+	}
 };
 
 /// Struct to help update the offset of the dynamic buffers.

+ 9 - 18
src/anki/gr/Enums.h

@@ -171,8 +171,7 @@ enum class TextureUsageBit : U16
 	SAMPLED_GEOMETRY = 1 << 3,
 	SAMPLED_FRAGMENT = 1 << 4,
 	SAMPLED_COMPUTE = 1 << 5,
-	SAMPLED_ALL_GRAPHICS = SAMPLED_VERTEX | SAMPLED_TESSELLATION_CONTROL
-		| SAMPLED_TESSELLATION_EVALUATION
+	SAMPLED_ALL_GRAPHICS = SAMPLED_VERTEX | SAMPLED_TESSELLATION_CONTROL | SAMPLED_TESSELLATION_EVALUATION
 		| SAMPLED_GEOMETRY
 		| SAMPLED_FRAGMENT,
 	SAMPLED_ALL = SAMPLED_ALL_GRAPHICS | SAMPLED_COMPUTE,
@@ -190,8 +189,7 @@ enum class TextureUsageBit : U16
 	/// @{
 	FRAMEBUFFER_ATTACHMENT_READ = 1 << 8,
 	FRAMEBUFFER_ATTACHMENT_WRITE = 1 << 9,
-	FRAMEBUFFER_ATTACHMENT_READ_WRITE =
-		FRAMEBUFFER_ATTACHMENT_READ | FRAMEBUFFER_ATTACHMENT_WRITE,
+	FRAMEBUFFER_ATTACHMENT_READ_WRITE = FRAMEBUFFER_ATTACHMENT_READ | FRAMEBUFFER_ATTACHMENT_WRITE,
 	/// @}
 
 	/// @name Misc
@@ -332,8 +330,7 @@ enum class BufferUsageBit : U32
 	UNIFORM_GEOMETRY = 1 << 3,
 	UNIFORM_FRAGMENT = 1 << 4,
 	UNIFORM_COMPUTE = 1 << 5,
-	UNIFORM_ALL_GRAPHICS = UNIFORM_VERTEX | UNIFORM_TESSELLATION_EVALUATION
-		| UNIFORM_TESSELLATION_CONTROL
+	UNIFORM_ALL_GRAPHICS = UNIFORM_VERTEX | UNIFORM_TESSELLATION_EVALUATION | UNIFORM_TESSELLATION_CONTROL
 		| UNIFORM_GEOMETRY
 		| UNIFORM_FRAGMENT,
 	UNIFORM_ALL = UNIFORM_ALL_GRAPHICS | UNIFORM_COMPUTE,
@@ -344,25 +341,20 @@ enum class BufferUsageBit : U32
 	STORAGE_TESSELLATION_EVALUATION_READ = 1 << 8,
 	STORAGE_TESSELLATION_EVALUATION_WRITE = 1 << 9,
 	STORAGE_TESSELLATION_EVALUATION_READ_WRITE =
-		STORAGE_TESSELLATION_EVALUATION_READ
-		| STORAGE_TESSELLATION_EVALUATION_WRITE,
+		STORAGE_TESSELLATION_EVALUATION_READ | STORAGE_TESSELLATION_EVALUATION_WRITE,
 	STORAGE_TESSELLATION_CONTROL_READ = 1 << 10,
 	STORAGE_TESSELLATION_CONTROL_WRITE = 1 << 11,
-	STORAGE_TESSELLATION_CONTROL_READ_WRITE =
-		STORAGE_TESSELLATION_CONTROL_READ | STORAGE_TESSELLATION_CONTROL_WRITE,
+	STORAGE_TESSELLATION_CONTROL_READ_WRITE = STORAGE_TESSELLATION_CONTROL_READ | STORAGE_TESSELLATION_CONTROL_WRITE,
 	STORAGE_GEOMETRY_READ = 1 << 12,
 	STORAGE_GEOMETRY_WRITE = 1 << 13,
-	STORAGE_GEOMETRY_READ_WRITE =
-		STORAGE_GEOMETRY_READ | STORAGE_GEOMETRY_WRITE,
+	STORAGE_GEOMETRY_READ_WRITE = STORAGE_GEOMETRY_READ | STORAGE_GEOMETRY_WRITE,
 	STORAGE_FRAGMENT_READ = 1 << 14,
 	STORAGE_FRAGMENT_WRITE = 1 << 15,
-	STORAGE_FRAGMENT_READ_WRITE =
-		STORAGE_FRAGMENT_READ | STORAGE_FRAGMENT_WRITE,
+	STORAGE_FRAGMENT_READ_WRITE = STORAGE_FRAGMENT_READ | STORAGE_FRAGMENT_WRITE,
 	STORAGE_COMPUTE_READ = 1 << 16,
 	STORAGE_COMPUTE_WRITE = 1 << 17,
 	STORAGE_COMPUTE_READ_WRITE = STORAGE_COMPUTE_READ | STORAGE_COMPUTE_WRITE,
-	STORAGE_ALL_GRAPHICS = STORAGE_VERTEX_READ | STORAGE_VERTEX_WRITE
-		| STORAGE_TESSELLATION_EVALUATION_READ
+	STORAGE_ALL_GRAPHICS = STORAGE_VERTEX_READ | STORAGE_VERTEX_WRITE | STORAGE_TESSELLATION_EVALUATION_READ
 		| STORAGE_TESSELLATION_EVALUATION_WRITE
 		| STORAGE_TESSELLATION_CONTROL_READ
 		| STORAGE_TESSELLATION_CONTROL_WRITE
@@ -380,8 +372,7 @@ enum class BufferUsageBit : U32
 	BUFFER_UPLOAD_SOURCE = 1 << 22,
 	BUFFER_UPLOAD_DESTINATION = 1 << 23, ///< Destination of buffer upload.
 	TEXTURE_UPLOAD_SOURCE = 1 << 24, ///< Source for texture upload.
-	TRANSFER_ALL = FILL | BUFFER_UPLOAD_SOURCE | BUFFER_UPLOAD_DESTINATION
-		| TEXTURE_UPLOAD_SOURCE,
+	TRANSFER_ALL = FILL | BUFFER_UPLOAD_SOURCE | BUFFER_UPLOAD_DESTINATION | TEXTURE_UPLOAD_SOURCE,
 };
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(BufferUsageBit, inline)
 

+ 4 - 6
src/anki/gr/Framebuffer.h

@@ -24,8 +24,7 @@ public:
 	AttachmentLoadOperation m_loadOperation = AttachmentLoadOperation::CLEAR;
 	AttachmentStoreOperation m_storeOperation = AttachmentStoreOperation::STORE;
 	ClearValue m_clearValue;
-	TextureUsageBit m_usageInsideRenderPass =
-		TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE;
+	TextureUsageBit m_usageInsideRenderPass = TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE;
 
 	FramebufferAttachmentInfo() = default;
 
@@ -47,8 +46,8 @@ public:
 	}
 };
 
-/// Framebuffer initializer. If you require the default framebuffer then set
-/// m_colorAttachmentCount to 1 and don't set a color texture.
+/// Framebuffer initializer. If you require the default framebuffer then set m_colorAttachmentCount to 1 and don't set a
+/// color texture.
 class FramebufferInitInfo
 {
 public:
@@ -79,8 +78,7 @@ public:
 
 	Bool refersToDefaultFramebuffer() const
 	{
-		return m_colorAttachmentCount == 1
-			&& !m_colorAttachments[0].m_texture.isCreated();
+		return m_colorAttachmentCount == 1 && !m_colorAttachments[0].m_texture.isCreated();
 	}
 };
 

+ 15 - 23
src/anki/gr/GrManager.h

@@ -63,37 +63,31 @@ public:
 	template<typename T, typename... Args>
 	GrObjectPtr<T> newInstance(Args&&... args);
 
-	/// Create a new graphics object and use the cache to avoid duplication.
-	/// It's thread safe.
+	/// Create a new graphics object and use the cache to avoid duplication. It's thread safe.
 	template<typename T, typename TArg>
 	GrObjectPtr<T> newInstanceCached(const TArg& arg);
 
-	/// Allocate transient memory for various operations. The memory will be
-	/// reclaimed at the begining of the N-(MAX_FRAMES_IN_FLIGHT-1) frame.
-	ANKI_USE_RESULT void* allocateFrameTransientMemory(
-		PtrSize size, BufferUsageBit usage, TransientMemoryToken& token);
+	/// Allocate transient memory for various operations. The memory will be reclaimed at the begining of the
+	/// N-(MAX_FRAMES_IN_FLIGHT-1) frame.
+	ANKI_USE_RESULT void* allocateFrameTransientMemory(PtrSize size, BufferUsageBit usage, TransientMemoryToken& token);
 
-	/// Allocate transient memory for various operations. The memory will be
-	/// reclaimed at the begining of the N-(MAX_FRAMES_IN_FLIGHT-1) frame.
+	/// Allocate transient memory for various operations. The memory will be reclaimed at the begining of the
+	/// N-(MAX_FRAMES_IN_FLIGHT-1) frame.
 	ANKI_USE_RESULT void* tryAllocateFrameTransientMemory(
 		PtrSize size, BufferUsageBit usage, TransientMemoryToken& token);
 
-	/// Call this before calling allocateFrameTransientMemory or
-	/// tryAllocateFrameTransientMemory to get the exact memory that will be
-	/// required for the CommandBuffer::uploadTextureSurface.
+	/// Call this before calling allocateFrameTransientMemory or tryAllocateFrameTransientMemory to get the exact memory
+	/// that will be required for the CommandBuffer::uploadTextureSurface.
 	///
-	/// If the expectedTransientAllocationSize is greater than the expected you
-	/// are required to allocate that amount and write your pixels to be
-	/// uploaded to the first part of the memory as before and leave the rest of
-	/// the memory for internal use.
-	void getTextureSurfaceUploadInfo(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		PtrSize& expectedTransientAllocationSize);
+	/// If the expectedTransientAllocationSize is greater than the expected you are required to allocate that amount and
+	/// write your pixels to be uploaded to the first part of the memory as before and leave the rest of the memory for
+	/// internal use.
+	void getTextureSurfaceUploadInfo(
+		TexturePtr tex, const TextureSurfaceInfo& surf, PtrSize& expectedTransientAllocationSize);
 
 	/// Same as getTextureSurfaceUploadInfo but for volumes.
-	void getTextureVolumeUploadInfo(TexturePtr tex,
-		const TextureVolumeInfo& vol,
-		PtrSize& expectedTransientAllocationSize);
+	void getTextureVolumeUploadInfo(
+		TexturePtr tex, const TextureVolumeInfo& vol, PtrSize& expectedTransientAllocationSize);
 
 anki_internal:
 	GrAllocator<U8>& getAllocator()
@@ -140,7 +134,6 @@ private:
 	U64 m_uuidIndex = 1;
 };
 
-//==============================================================================
 template<typename T, typename... Args>
 GrObjectPtr<T> GrManager::newInstance(Args&&... args)
 {
@@ -150,7 +143,6 @@ GrObjectPtr<T> GrManager::newInstance(Args&&... args)
 	return ptr;
 }
 
-//==============================================================================
 template<typename T, typename TArg>
 GrObjectPtr<T> GrManager::newInstanceCached(const TArg& arg)
 {

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