Browse Source

Update clang-format and slightly the formatting

Panagiotis Christopoulos Charitos 5 years ago
parent
commit
a8ab4c83c2
100 changed files with 1127 additions and 1755 deletions
  1. 36 12
      .clang-format
  2. 2 2
      samples/common/Framework.cpp
  3. 4 8
      samples/physics_playground/Main.cpp
  4. 1 1
      samples/skeletal_animation/Main.cpp
  5. 1 1
      samples/sponza/Main.cpp
  6. 3 7
      shaders/ApplyIrradianceToReflection.ankiprog
  7. 5 7
      shaders/BloomUpscale.ankiprog
  8. 3 9
      shaders/FinalComposite.ankiprog
  9. 2 2
      shaders/ForwardShadingCommonFrag.glsl
  10. 2 2
      shaders/ForwardShadingParticles.ankiprog
  11. 26 126
      shaders/Functions.glsl
  12. 2 8
      shaders/GBufferCommon.glsl
  13. 2 8
      shaders/GBufferCommonFrag.glsl
  14. 5 9
      shaders/IrradianceDice.ankiprog
  15. 12 23
      shaders/LightFunctions.glsl
  16. 5 5
      shaders/LightShading.ankiprog
  17. 3 9
      shaders/MotionBlur.glsl
  18. 2 3
      shaders/ShadowmapsResolve.ankiprog
  19. 13 26
      shaders/SsRaymarching.glsl
  20. 4 15
      shaders/Ssgi.ankiprog
  21. 4 15
      shaders/Ssr.ankiprog
  22. 6 6
      shaders/VolumetricLightingAccumulation.ankiprog
  23. 4 4
      shaders/glsl_cpp_common/ClusteredShading.h
  24. 2 2
      src/anki/collision/GjkEpa.cpp
  25. 2 2
      src/anki/collision/GjkEpa.h
  26. 2 2
      src/anki/collision/Ray.h
  27. 7 13
      src/anki/core/App.cpp
  28. 10 12
      src/anki/core/ConfigSet.cpp
  29. 10 18
      src/anki/core/CoreTracer.cpp
  30. 7 13
      src/anki/core/DeveloperConsole.cpp
  31. 7 7
      src/anki/core/NativeWindowSdl.cpp
  32. 9 18
      src/anki/core/StagingGpuMemoryManager.cpp
  33. 2 2
      src/anki/core/StagingGpuMemoryManager.h
  34. 5 5
      src/anki/gr/AccelerationStructure.h
  35. 23 35
      src/anki/gr/CommandBuffer.h
  36. 1 1
      src/anki/gr/Common.h
  37. 65 82
      src/anki/gr/RenderGraph.cpp
  38. 20 35
      src/anki/gr/RenderGraph.h
  39. 11 23
      src/anki/gr/RenderGraph.inl.h
  40. 2 4
      src/anki/gr/TextureView.h
  41. 55 74
      src/anki/gr/gl/CommandBuffer.cpp
  42. 4 6
      src/anki/gr/gl/CommandBufferImpl.cpp
  43. 2 2
      src/anki/gr/gl/Common.cpp
  44. 2 2
      src/anki/gr/gl/Common.h
  45. 1 1
      src/anki/gr/gl/Error.cpp
  46. 4 4
      src/anki/gr/gl/Fence.cpp
  47. 13 25
      src/anki/gr/gl/FramebufferImpl.cpp
  48. 2 2
      src/anki/gr/gl/FramebufferImpl.h
  49. 16 21
      src/anki/gr/gl/GlState.cpp
  50. 3 3
      src/anki/gr/gl/GlState.h
  51. 4 5
      src/anki/gr/gl/GrManagerImplSdl.cpp
  52. 4 4
      src/anki/gr/gl/RenderingThread.cpp
  53. 3 4
      src/anki/gr/gl/Shader.cpp
  54. 2 6
      src/anki/gr/gl/ShaderImpl.cpp
  55. 6 14
      src/anki/gr/gl/ShaderProgram.cpp
  56. 4 5
      src/anki/gr/gl/ShaderProgramImpl.cpp
  57. 2 2
      src/anki/gr/gl/ShaderProgramImpl.h
  58. 14 20
      src/anki/gr/gl/StateTracker.h
  59. 15 22
      src/anki/gr/gl/TextureImpl.cpp
  60. 8 21
      src/anki/gr/utils/Functions.cpp
  61. 6 16
      src/anki/gr/utils/Functions.h
  62. 9 11
      src/anki/gr/vulkan/AccelerationStructureImpl.cpp
  63. 8 11
      src/anki/gr/vulkan/AccelerationStructureImpl.h
  64. 19 20
      src/anki/gr/vulkan/BufferImpl.cpp
  65. 3 6
      src/anki/gr/vulkan/BufferImpl.h
  66. 28 32
      src/anki/gr/vulkan/CommandBuffer.cpp
  67. 9 11
      src/anki/gr/vulkan/CommandBufferFactory.cpp
  68. 131 166
      src/anki/gr/vulkan/CommandBufferImpl.cpp
  69. 26 45
      src/anki/gr/vulkan/CommandBufferImpl.h
  70. 55 81
      src/anki/gr/vulkan/CommandBufferImpl.inl.h
  71. 30 48
      src/anki/gr/vulkan/DescriptorSet.cpp
  72. 8 13
      src/anki/gr/vulkan/DescriptorSet.h
  73. 11 12
      src/anki/gr/vulkan/FramebufferImpl.cpp
  74. 4 4
      src/anki/gr/vulkan/FramebufferImpl.h
  75. 18 23
      src/anki/gr/vulkan/GpuMemoryManager.cpp
  76. 4 8
      src/anki/gr/vulkan/GpuMemoryManager.h
  77. 34 63
      src/anki/gr/vulkan/GrManagerImpl.cpp
  78. 10 15
      src/anki/gr/vulkan/GrManagerImpl.h
  79. 4 8
      src/anki/gr/vulkan/OcclusionQueryImpl.cpp
  80. 20 27
      src/anki/gr/vulkan/Pipeline.cpp
  81. 10 12
      src/anki/gr/vulkan/Pipeline.h
  82. 2 2
      src/anki/gr/vulkan/PipelineCache.cpp
  83. 2 2
      src/anki/gr/vulkan/PipelineCache.h
  84. 2 2
      src/anki/gr/vulkan/PipelineLayout.cpp
  85. 2 2
      src/anki/gr/vulkan/PipelineLayout.h
  86. 6 9
      src/anki/gr/vulkan/ShaderImpl.cpp
  87. 8 8
      src/anki/gr/vulkan/ShaderProgramImpl.cpp
  88. 12 16
      src/anki/gr/vulkan/SwapchainFactory.cpp
  89. 23 34
      src/anki/gr/vulkan/TextureImpl.cpp
  90. 7 11
      src/anki/gr/vulkan/TextureImpl.h
  91. 2 8
      src/anki/gr/vulkan/TimestampQueryImpl.cpp
  92. 51 99
      src/anki/importer/GltfImporter.cpp
  93. 6 14
      src/anki/importer/GltfImporter.h
  94. 29 34
      src/anki/importer/GltfImporterMaterial.cpp
  95. 24 46
      src/anki/importer/GltfImporterMesh.cpp
  96. 2 5
      src/anki/input/InputSdl.h
  97. 1 1
      src/anki/math/Axisang.h
  98. 1 1
      src/anki/math/Functions.h
  99. 2 2
      src/anki/math/Mat.h
  100. 2 2
      src/anki/math/Transform.h

+ 36 - 12
.clang-format

@@ -2,25 +2,30 @@
 Language:        Cpp
 Language:        Cpp
 # BasedOnStyle:  LLVM
 # BasedOnStyle:  LLVM
 AccessModifierOffset: -4
 AccessModifierOffset: -4
-AlignAfterOpenBracket: DontAlign
+AlignAfterOpenBracket: Align
+AlignConsecutiveMacros: false
 AlignConsecutiveAssignments: false
 AlignConsecutiveAssignments: false
 AlignConsecutiveDeclarations: false
 AlignConsecutiveDeclarations: false
 AlignEscapedNewlines: DontAlign
 AlignEscapedNewlines: DontAlign
 AlignOperands:   true
 AlignOperands:   true
 AlignTrailingComments: false
 AlignTrailingComments: false
+AllowAllArgumentsOnNextLine: false
+AllowAllConstructorInitializersOnNextLine: true
 AllowAllParametersOfDeclarationOnNextLine: true
 AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Never
 AllowShortCaseLabelsOnASingleLine: false
 AllowShortCaseLabelsOnASingleLine: false
 AllowShortFunctionsOnASingleLine: None
 AllowShortFunctionsOnASingleLine: None
-AllowShortIfStatementsOnASingleLine: false
+AllowShortLambdasOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Never
 AllowShortLoopsOnASingleLine: false
 AllowShortLoopsOnASingleLine: false
 AlwaysBreakAfterDefinitionReturnType: None
 AlwaysBreakAfterDefinitionReturnType: None
 AlwaysBreakAfterReturnType: None
 AlwaysBreakAfterReturnType: None
 AlwaysBreakBeforeMultilineStrings: false
 AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: true
-BinPackArguments: false
-BinPackParameters: false
+AlwaysBreakTemplateDeclarations: Yes
+BinPackArguments: true
+BinPackParameters: true
 BraceWrapping:
 BraceWrapping:
+  AfterCaseLabel:  true
   AfterClass:      true
   AfterClass:      true
   AfterControlStatement: true
   AfterControlStatement: true
   AfterEnum:       true
   AfterEnum:       true
@@ -39,6 +44,7 @@ BraceWrapping:
 BreakBeforeBinaryOperators: NonAssignment
 BreakBeforeBinaryOperators: NonAssignment
 BreakBeforeBraces: Custom
 BreakBeforeBraces: Custom
 BreakBeforeInheritanceComma: false
 BreakBeforeInheritanceComma: false
+BreakInheritanceList: AfterColon
 BreakBeforeTernaryOperators: true
 BreakBeforeTernaryOperators: true
 BreakConstructorInitializersBeforeComma: true
 BreakConstructorInitializersBeforeComma: true
 BreakConstructorInitializers: BeforeColon
 BreakConstructorInitializers: BeforeColon
@@ -51,24 +57,30 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: false
 ConstructorInitializerIndentWidth: 4
 ConstructorInitializerIndentWidth: 4
 ContinuationIndentWidth: 4
 ContinuationIndentWidth: 4
 Cpp11BracedListStyle: true
 Cpp11BracedListStyle: true
+DeriveLineEnding: true
 DerivePointerAlignment: false
 DerivePointerAlignment: false
 DisableFormat:   false
 DisableFormat:   false
 ExperimentalAutoDetectBinPacking: false
 ExperimentalAutoDetectBinPacking: false
-FixNamespaceComments: false
-ForEachMacros:   
+FixNamespaceComments: true
+ForEachMacros:
   - foreach
   - foreach
   - Q_FOREACH
   - Q_FOREACH
   - BOOST_FOREACH
   - BOOST_FOREACH
 IncludeBlocks:   Preserve
 IncludeBlocks:   Preserve
-IncludeCategories: 
+IncludeCategories:
   - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
   - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
     Priority:        2
     Priority:        2
+    SortPriority:    0
   - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
   - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
     Priority:        3
     Priority:        3
+    SortPriority:    0
   - Regex:           '.*'
   - Regex:           '.*'
     Priority:        1
     Priority:        1
+    SortPriority:    0
 IncludeIsMainRegex: '(Test)?$'
 IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
 IndentCaseLabels: false
 IndentCaseLabels: false
+IndentGotoLabels: true
 IndentPPDirectives: AfterHash
 IndentPPDirectives: AfterHash
 IndentWidth:     4
 IndentWidth:     4
 IndentWrappedFunctionNames: false
 IndentWrappedFunctionNames: false
@@ -88,6 +100,7 @@ PenaltyBreakBeforeFirstCallParameter: 19
 PenaltyBreakComment: 300
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakString: 1000
 PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
 PenaltyReturnTypeOnItsOwnLine: 60
 PointerAlignment: Left
 PointerAlignment: Left
@@ -95,19 +108,30 @@ ReflowComments:  true
 SortIncludes:    true
 SortIncludes:    true
 SortUsingDeclarations: false
 SortUsingDeclarations: false
 SpaceAfterCStyleCast: false
 SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
 SpaceAfterTemplateKeyword: false
 SpaceAfterTemplateKeyword: false
 SpaceBeforeAssignmentOperators: true
 SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: false
+SpaceBeforeInheritanceColon: true
 SpaceBeforeParens: Never
 SpaceBeforeParens: Never
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyBlock: false
 SpaceInEmptyParentheses: false
 SpaceInEmptyParentheses: false
 SpacesBeforeTrailingComments: 1
 SpacesBeforeTrailingComments: 1
 SpacesInAngles:  false
 SpacesInAngles:  false
+SpacesInConditionalStatement: false
 SpacesInContainerLiterals: true
 SpacesInContainerLiterals: true
 SpacesInCStyleCastParentheses: false
 SpacesInCStyleCastParentheses: false
 SpacesInParentheses: false
 SpacesInParentheses: false
 SpacesInSquareBrackets: false
 SpacesInSquareBrackets: false
-Standard:        Cpp11
+SpaceBeforeSquareBrackets: false
+Standard:        Latest
+StatementMacros:
+  - Q_UNUSED
+  - QT_REQUIRE_VERSION
 TabWidth:        4
 TabWidth:        4
-UseTab:          Always
+UseCRLF:         false
+UseTab:          ForContinuationAndIndentation
 ...
 ...
 
 
-

+ 2 - 2
samples/common/Framework.cpp

@@ -81,8 +81,8 @@ Error SampleApp::userMainLoop(Bool& quit)
 
 
 	if(in.getKey(KeyCode::O) == 1)
 	if(in.getKey(KeyCode::O) == 1)
 	{
 	{
-		renderer.setCurrentDebugRenderTarget(
-			(renderer.getCurrentDebugRenderTarget() == "SM_resolve") ? "" : "SM_resolve");
+		renderer.setCurrentDebugRenderTarget((renderer.getCurrentDebugRenderTarget() == "SM_resolve") ? ""
+																									  : "SM_resolve");
 	}
 	}
 
 
 	if(in.getKey(KeyCode::P) == 1)
 	if(in.getKey(KeyCode::P) == 1)

+ 4 - 8
samples/physics_playground/Main.cpp

@@ -151,8 +151,7 @@ Error MyApp::sampleExtraInit()
 		{
 		{
 			ModelNode* monkey;
 			ModelNode* monkey;
 			ANKI_CHECK(getSceneGraph().newSceneNode<ModelNode>(
 			ANKI_CHECK(getSceneGraph().newSceneNode<ModelNode>(
-				StringAuto(getAllocator()).sprintf("monkey_chain%u", i).toCString(),
-				monkey,
+				StringAuto(getAllocator()).sprintf("monkey_chain%u", i).toCString(), monkey,
 				"assets/Suzannedynamic-material.ankimdl"));
 				"assets/Suzannedynamic-material.ankimdl"));
 
 
 			Transform trf(Vec4(-4.3f, 12.0f, -3.0f, 0.0f), Mat3x4::getIdentity(), 1.0f);
 			Transform trf(Vec4(-4.3f, 12.0f, -3.0f, 0.0f), Mat3x4::getIdentity(), 1.0f);
@@ -241,8 +240,7 @@ Error MyApp::userMainLoop(Bool& quit)
 
 
 		ModelNode* monkey;
 		ModelNode* monkey;
 		ANKI_CHECK(getSceneGraph().newSceneNode<ModelNode>(
 		ANKI_CHECK(getSceneGraph().newSceneNode<ModelNode>(
-			StringAuto(getAllocator()).sprintf("monkey%u", instance++).toCString(),
-			monkey,
+			StringAuto(getAllocator()).sprintf("monkey%u", instance++).toCString(), monkey,
 			"assets/Suzannedynamic-material.ankimdl"));
 			"assets/Suzannedynamic-material.ankimdl"));
 		// monkey->getComponent<MoveComponent>().setLocalTransform(camTrf);
 		// monkey->getComponent<MoveComponent>().setLocalTransform(camTrf);
 
 
@@ -290,8 +288,7 @@ Error MyApp::userMainLoop(Bool& quit)
 			static U id = 0;
 			static U id = 0;
 			ModelNode* monkey;
 			ModelNode* monkey;
 			ANKI_CHECK(getSceneGraph().newSceneNode(
 			ANKI_CHECK(getSceneGraph().newSceneNode(
-				StringAuto(getSceneGraph().getFrameAllocator()).sprintf("decal%u", id++).toCString(),
-				monkey,
+				StringAuto(getSceneGraph().getFrameAllocator()).sprintf("decal%u", id++).toCString(), monkey,
 				"assets/Suzannedynamic-material.ankimdl"));
 				"assets/Suzannedynamic-material.ankimdl"));
 			monkey->getComponent<MoveComponent>().setLocalTransform(trf);
 			monkey->getComponent<MoveComponent>().setLocalTransform(trf);
 
 
@@ -301,8 +298,7 @@ Error MyApp::userMainLoop(Bool& quit)
 			// Create some particles
 			// Create some particles
 			ParticleEmitterNode* particles;
 			ParticleEmitterNode* particles;
 			ANKI_CHECK(getSceneGraph().newSceneNode(
 			ANKI_CHECK(getSceneGraph().newSceneNode(
-				StringAuto(getSceneGraph().getFrameAllocator()).sprintf("parts%u", id++).toCString(),
-				particles,
+				StringAuto(getSceneGraph().getFrameAllocator()).sprintf("parts%u", id++).toCString(), particles,
 				"assets/smoke.ankipart"));
 				"assets/smoke.ankipart"));
 			particles->getComponent<MoveComponent>().setLocalTransform(trf);
 			particles->getComponent<MoveComponent>().setLocalTransform(trf);
 			createDestructionEvent(particles);
 			createDestructionEvent(particles);

+ 1 - 1
samples/skeletal_animation/Main.cpp

@@ -72,7 +72,7 @@ int main(int argc, char* argv[])
 	{
 	{
 		ANKI_LOGE("Error reported. To run %s you have to navigate to the /path/to/anki/samples/sponza. "
 		ANKI_LOGE("Error reported. To run %s you have to navigate to the /path/to/anki/samples/sponza. "
 				  "And then execute it",
 				  "And then execute it",
-			argv[0]);
+				  argv[0]);
 	}
 	}
 	else
 	else
 	{
 	{

+ 1 - 1
samples/sponza/Main.cpp

@@ -38,7 +38,7 @@ int main(int argc, char* argv[])
 	{
 	{
 		ANKI_LOGE("Error reported. To run %s you have to navigate to the /path/to/anki/samples/sponza. "
 		ANKI_LOGE("Error reported. To run %s you have to navigate to the /path/to/anki/samples/sponza. "
 				  "And then execute it",
 				  "And then execute it",
-			argv[0]);
+				  argv[0]);
 	}
 	}
 	else
 	else
 	{
 	{

+ 3 - 7
shaders/ApplyIrradianceToReflection.ankiprog

@@ -39,13 +39,9 @@ void main()
 	readGBuffer(u_gbufferTex[0u], u_gbufferTex[1u], u_gbufferTex[2u], u_nearestAnyClampSampler, sampleUv, 0.0, gbuffer);
 	readGBuffer(u_gbufferTex[0u], u_gbufferTex[1u], u_gbufferTex[2u], u_nearestAnyClampSampler, sampleUv, 0.0, gbuffer);
 
 
 	// Sample
 	// Sample
-	const Vec3 irradiance = sampleAmbientDice(u_irradianceDice[0u].xyz,
-		u_irradianceDice[1u].xyz,
-		u_irradianceDice[2u].xyz,
-		u_irradianceDice[3u].xyz,
-		u_irradianceDice[4u].xyz,
-		u_irradianceDice[5u].xyz,
-		gbuffer.m_normal);
+	const Vec3 irradiance = sampleAmbientDice(u_irradianceDice[0u].xyz, u_irradianceDice[1u].xyz,
+											  u_irradianceDice[2u].xyz, u_irradianceDice[3u].xyz,
+											  u_irradianceDice[4u].xyz, u_irradianceDice[5u].xyz, gbuffer.m_normal);
 
 
 	// Compute the indirect term
 	// Compute the indirect term
 	const Vec3 indirect = gbuffer.m_diffuse * irradiance;
 	const Vec3 indirect = gbuffer.m_diffuse * irradiance;

+ 5 - 7
shaders/BloomUpscale.ankiprog

@@ -27,16 +27,14 @@ const F32 CHROMATIC_DISTORTION = 3.0;
 #define ENABLE_HALO 1
 #define ENABLE_HALO 1
 const F32 HALO_OPACITY = 0.5;
 const F32 HALO_OPACITY = 0.5;
 
 
-Vec3 textureDistorted(texture2D tex,
-	sampler sampl,
-	Vec2 uv,
-	Vec2 direction, // direction of DISTORTION
-	Vec3 DISTORTION) // per-channel DISTORTION factor
+Vec3 textureDistorted(texture2D tex, sampler sampl, Vec2 uv,
+					  Vec2 direction, // direction of DISTORTION
+					  Vec3 DISTORTION) // per-channel DISTORTION factor
 {
 {
 #if ENABLE_CHROMATIC_DISTORTION
 #if ENABLE_CHROMATIC_DISTORTION
 	return Vec3(textureLod(tex, sampl, uv + direction * DISTORTION.r, 0.0).r,
 	return Vec3(textureLod(tex, sampl, uv + direction * DISTORTION.r, 0.0).r,
-		textureLod(tex, sampl, uv + direction * DISTORTION.g, 0.0).g,
-		textureLod(tex, sampl, uv + direction * DISTORTION.b, 0.0).b);
+				textureLod(tex, sampl, uv + direction * DISTORTION.g, 0.0).g,
+				textureLod(tex, sampl, uv + direction * DISTORTION.b, 0.0).b);
 #else
 #else
 	return textureLod(tex, uv, 0.0).rgb;
 	return textureLod(tex, uv, 0.0).rgb;
 #endif
 #endif

+ 3 - 9
shaders/FinalComposite.ankiprog

@@ -68,15 +68,9 @@ void main()
 
 
 	if(MOTION_BLUR_SAMPLES > 0u)
 	if(MOTION_BLUR_SAMPLES > 0u)
 	{
 	{
-		out_color = motionBlur(u_velocityRt,
-			u_nearestAnyClampSampler,
-			u_lightShadingRt,
-			u_linearAnyClampSampler,
-			u_depthRt,
-			u_nearestAnyClampSampler,
-			uv,
-			u_prevViewProjMatMulInvViewProjMat,
-			MOTION_BLUR_SAMPLES);
+		out_color =
+			motionBlur(u_velocityRt, u_nearestAnyClampSampler, u_lightShadingRt, u_linearAnyClampSampler, u_depthRt,
+					   u_nearestAnyClampSampler, uv, u_prevViewProjMatMulInvViewProjMat, MOTION_BLUR_SAMPLES);
 	}
 	}
 	else
 	else
 	{
 	{

+ 2 - 2
shaders/ForwardShadingCommonFrag.glsl

@@ -43,8 +43,8 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos)
 	Vec3 outColor = Vec3(0.0);
 	Vec3 outColor = Vec3(0.0);
 
 
 	// Find the cluster and then the light counts
 	// Find the cluster and then the light counts
-	const U32 clusterIdx = computeClusterIndex(
-		u_clustererMagic, gl_FragCoord.xy / RENDERER_SIZE, worldPos, u_clusterCountX, u_clusterCountY);
+	const U32 clusterIdx = computeClusterIndex(u_clustererMagic, gl_FragCoord.xy / RENDERER_SIZE, worldPos,
+											   u_clusterCountX, u_clusterCountY);
 
 
 	U32 idxOffset = u_clusters[clusterIdx];
 	U32 idxOffset = u_clusters[clusterIdx];
 
 

+ 2 - 2
shaders/ForwardShadingParticles.ankiprog

@@ -61,8 +61,8 @@ layout(location = 2) in Vec3 in_worldPos;
 void main()
 void main()
 {
 {
 #if ANIMATED_TEXTURE == 1
 #if ANIMATED_TEXTURE == 1
-	Vec4 texCol = readAnimatedTextureRgba(
-		u_diffuseMapArr, u_ankiGlobalSampler, u_ankiPerDraw.m_animationPeriod, in_uv, anki_u_time);
+	Vec4 texCol = readAnimatedTextureRgba(u_diffuseMapArr, u_ankiGlobalSampler, u_ankiPerDraw.m_animationPeriod, in_uv,
+										  anki_u_time);
 #else
 #else
 	Vec4 texCol = texture(u_diffuseMap, u_ankiGlobalSampler, in_uv);
 	Vec4 texCol = texture(u_diffuseMap, u_ankiGlobalSampler, in_uv);
 #endif
 #endif

+ 26 - 126
shaders/Functions.glsl

@@ -72,7 +72,7 @@ Vec4 textureCatmullRom4Samples(texture2D tex, sampler sampl, Vec2 uv, Vec2 texSi
 	const Vec2 sum1 = (2.0 * f - 2.5) * f - 0.5;
 	const Vec2 sum1 = (2.0 * f - 2.5) * f - 0.5;
 	Vec4 w = Vec4(f * sum0 + 1.0, f * sum1);
 	Vec4 w = Vec4(f * sum0 + 1.0, f * sum1);
 	const Vec4 pos = Vec4((((-2.0 * f + 3.0) * f + 0.5) * f - 1.5) * f / (w.xy * texSize) + uv,
 	const Vec4 pos = Vec4((((-2.0 * f + 3.0) * f + 0.5) * f - 1.5) * f / (w.xy * texSize) + uv,
-		(((-2.0 * f + 5.0) * f - 2.5) * f - 0.5) / (sum1 * texSize) + uv);
+						  (((-2.0 * f + 5.0) * f - 2.5) * f - 0.5) / (sum1 * texSize) + uv);
 	w.xz *= halff.x * halff.y > 0.0 ? 1.0 : -1.0;
 	w.xz *= halff.x * halff.y > 0.0 ? 1.0 : -1.0;
 
 
 	return (texture(tex, sampl, pos.xy) * w.x + texture(tex, sampl, pos.zy) * w.z) * w.y
 	return (texture(tex, sampl, pos.xy) * w.x + texture(tex, sampl, pos.zy) * w.z) * w.y
@@ -85,13 +85,8 @@ F32 rand(Vec2 n)
 	return 0.5 + 0.5 * fract(sin(dot(n, Vec2(12.9898, 78.233))) * 43758.5453);
 	return 0.5 + 0.5 * fract(sin(dot(n, Vec2(12.9898, 78.233))) * 43758.5453);
 }
 }
 
 
-Vec4 nearestDepthUpscale(Vec2 uv,
-	texture2D depthFull,
-	texture2D depthHalf,
-	texture2D colorTex,
-	sampler linearAnyClampSampler,
-	Vec2 linearDepthCf,
-	F32 depthThreshold)
+Vec4 nearestDepthUpscale(Vec2 uv, texture2D depthFull, texture2D depthHalf, texture2D colorTex,
+						 sampler linearAnyClampSampler, Vec2 linearDepthCf, F32 depthThreshold)
 {
 {
 	F32 fullDepth = textureLod(depthFull, linearAnyClampSampler, uv, 0.0).r; // Sampler not important.
 	F32 fullDepth = textureLod(depthFull, linearAnyClampSampler, uv, 0.0).r; // Sampler not important.
 	fullDepth = linearizeDepthOptimal(fullDepth, linearDepthCf.x, linearDepthCf.y);
 	fullDepth = linearizeDepthOptimal(fullDepth, linearDepthCf.x, linearDepthCf.y);
@@ -148,17 +143,9 @@ F32 _calcDepthWeight(texture2D depthLow, sampler nearestAnyClamp, Vec2 uv, F32 r
 	return 1.0 / (EPSILON + abs(ref - linearD));
 	return 1.0 / (EPSILON + abs(ref - linearD));
 }
 }
 
 
-Vec4 _sampleAndWeight(texture2D depthLow,
-	texture2D colorLow,
-	sampler linearAnyClamp,
-	sampler nearestAnyClamp,
-	const Vec2 lowInvSize,
-	Vec2 uv,
-	const Vec2 offset,
-	const F32 ref,
-	const F32 weight,
-	const Vec2 linearDepthCf,
-	inout F32 normalize)
+Vec4 _sampleAndWeight(texture2D depthLow, texture2D colorLow, sampler linearAnyClamp, sampler nearestAnyClamp,
+					  const Vec2 lowInvSize, Vec2 uv, const Vec2 offset, const F32 ref, const F32 weight,
+					  const Vec2 linearDepthCf, inout F32 normalize)
 {
 {
 	uv += offset * lowInvSize;
 	uv += offset * lowInvSize;
 	const F32 dw = _calcDepthWeight(depthLow, nearestAnyClamp, uv, ref, linearDepthCf);
 	const F32 dw = _calcDepthWeight(depthLow, nearestAnyClamp, uv, ref, linearDepthCf);
@@ -167,119 +154,32 @@ Vec4 _sampleAndWeight(texture2D depthLow,
 	return v * dw * weight;
 	return v * dw * weight;
 }
 }
 
 
-Vec4 bilateralUpsample(texture2D depthHigh,
-	texture2D depthLow,
-	texture2D colorLow,
-	sampler linearAnyClamp,
-	sampler nearestAnyClamp,
-	const Vec2 lowInvSize,
-	const Vec2 uv,
-	const Vec2 linearDepthCf)
+Vec4 bilateralUpsample(texture2D depthHigh, texture2D depthLow, texture2D colorLow, sampler linearAnyClamp,
+					   sampler nearestAnyClamp, const Vec2 lowInvSize, const Vec2 uv, const Vec2 linearDepthCf)
 {
 {
 	const Vec3 WEIGHTS = Vec3(0.25, 0.125, 0.0625);
 	const Vec3 WEIGHTS = Vec3(0.25, 0.125, 0.0625);
 	const F32 depthRef =
 	const F32 depthRef =
 		linearizeDepthOptimal(textureLod(depthHigh, nearestAnyClamp, uv, 0.0).r, linearDepthCf.x, linearDepthCf.y);
 		linearizeDepthOptimal(textureLod(depthHigh, nearestAnyClamp, uv, 0.0).r, linearDepthCf.x, linearDepthCf.y);
 	F32 normalize = 0.0;
 	F32 normalize = 0.0;
 
 
-	Vec4 sum = _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(0.0, 0.0),
-		depthRef,
-		WEIGHTS.x,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(-1.0, 0.0),
-		depthRef,
-		WEIGHTS.y,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(0.0, -1.0),
-		depthRef,
-		WEIGHTS.y,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(1.0, 0.0),
-		depthRef,
-		WEIGHTS.y,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(0.0, 1.0),
-		depthRef,
-		WEIGHTS.y,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(1.0, 1.0),
-		depthRef,
-		WEIGHTS.z,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(1.0, -1.0),
-		depthRef,
-		WEIGHTS.z,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(-1.0, 1.0),
-		depthRef,
-		WEIGHTS.z,
-		linearDepthCf,
-		normalize);
-	sum += _sampleAndWeight(depthLow,
-		colorLow,
-		linearAnyClamp,
-		nearestAnyClamp,
-		lowInvSize,
-		uv,
-		Vec2(-1.0, -1.0),
-		depthRef,
-		WEIGHTS.z,
-		linearDepthCf,
-		normalize);
+	Vec4 sum = _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(0.0, 0.0),
+								depthRef, WEIGHTS.x, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(-1.0, 0.0),
+							depthRef, WEIGHTS.y, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(0.0, -1.0),
+							depthRef, WEIGHTS.y, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(1.0, 0.0),
+							depthRef, WEIGHTS.y, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(0.0, 1.0),
+							depthRef, WEIGHTS.y, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(1.0, 1.0),
+							depthRef, WEIGHTS.z, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(1.0, -1.0),
+							depthRef, WEIGHTS.z, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(-1.0, 1.0),
+							depthRef, WEIGHTS.z, linearDepthCf, normalize);
+	sum += _sampleAndWeight(depthLow, colorLow, linearAnyClamp, nearestAnyClamp, lowInvSize, uv, Vec2(-1.0, -1.0),
+							depthRef, WEIGHTS.z, linearDepthCf, normalize);
 
 
 	return sum / normalize;
 	return sum / normalize;
 }
 }

+ 2 - 8
shaders/GBufferCommon.glsl

@@ -89,14 +89,8 @@ layout(location = 3) out Vec2 out_gbuffer3;
 
 
 // Write the data to RTs
 // Write the data to RTs
 #if defined(ANKI_FRAGMENT_SHADER) && ANKI_PASS == PASS_GB
 #if defined(ANKI_FRAGMENT_SHADER) && ANKI_PASS == PASS_GB
-void writeGBuffer(Vec3 diffColor,
-	Vec3 normal,
-	Vec3 specularColor,
-	F32 roughness,
-	F32 subsurface,
-	Vec3 emission,
-	F32 metallic,
-	Vec2 velocity)
+void writeGBuffer(Vec3 diffColor, Vec3 normal, Vec3 specularColor, F32 roughness, F32 subsurface, Vec3 emission,
+				  F32 metallic, Vec2 velocity)
 {
 {
 	GbufferInfo g;
 	GbufferInfo g;
 	g.m_diffuse = diffColor;
 	g.m_diffuse = diffColor;

+ 2 - 8
shaders/GBufferCommonFrag.glsl

@@ -141,14 +141,8 @@ Vec2 computeTextureCoordParallax(texture2D heightMap, sampler sampl, Vec2 uv, F3
 }
 }
 
 
 // Write the data to FAIs
 // Write the data to FAIs
-void writeRts(Vec3 diffColor,
-	Vec3 normal,
-	Vec3 specularColor,
-	F32 roughness,
-	F32 subsurface,
-	Vec3 emission,
-	F32 metallic,
-	Vec2 velocity)
+void writeRts(Vec3 diffColor, Vec3 normal, Vec3 specularColor, F32 roughness, F32 subsurface, Vec3 emission,
+			  F32 metallic, Vec2 velocity)
 {
 {
 	GbufferInfo g;
 	GbufferInfo g;
 	g.m_diffuse = diffColor;
 	g.m_diffuse = diffColor;

+ 5 - 9
shaders/IrradianceDice.ankiprog

@@ -144,17 +144,13 @@ void main()
 		gbufferUv.x *= 1.0 / 6.0;
 		gbufferUv.x *= 1.0 / 6.0;
 		gbufferUv.x += (1.0 / 6.0) * F32(f);
 		gbufferUv.x += (1.0 / 6.0) * F32(f);
 		GbufferInfo gbuffer;
 		GbufferInfo gbuffer;
-		readGBuffer(
-			u_gbufferTex[0u], u_gbufferTex[1u], u_gbufferTex[2u], u_nearestAnyClampSampler, gbufferUv, 0.0, gbuffer);
+		readGBuffer(u_gbufferTex[0u], u_gbufferTex[1u], u_gbufferTex[2u], u_nearestAnyClampSampler, gbufferUv, 0.0,
+					gbuffer);
 
 
 		// Sample irradiance
 		// Sample irradiance
-		Vec3 firstBounceIrradiance = sampleAmbientDice(s_diceIrradiance[0],
-			s_diceIrradiance[1],
-			s_diceIrradiance[2],
-			s_diceIrradiance[3],
-			s_diceIrradiance[4],
-			s_diceIrradiance[5],
-			gbuffer.m_normal);
+		Vec3 firstBounceIrradiance =
+			sampleAmbientDice(s_diceIrradiance[0], s_diceIrradiance[1], s_diceIrradiance[2], s_diceIrradiance[3],
+							  s_diceIrradiance[4], s_diceIrradiance[5], gbuffer.m_normal);
 		firstBounceIrradiance = gbuffer.m_diffuse * firstBounceIrradiance;
 		firstBounceIrradiance = gbuffer.m_diffuse * firstBounceIrradiance;
 
 
 		// Compute 2nd bounce
 		// Compute 2nd bounce

+ 12 - 23
shaders/LightFunctions.glsl

@@ -215,8 +215,8 @@ F32 computeShadowFactorPointLight(PointLight light, Vec3 frag2Light, texture2D s
 }
 }
 
 
 // Compute the shadow factor of a directional light
 // Compute the shadow factor of a directional light
-F32 computeShadowFactorDirLight(
-	DirectionalLight light, U32 cascadeIdx, Vec3 worldPos, texture2D shadowMap, sampler shadowMapSampler)
+F32 computeShadowFactorDirLight(DirectionalLight light, U32 cascadeIdx, Vec3 worldPos, texture2D shadowMap,
+								sampler shadowMapSampler)
 {
 {
 #define ANKI_FAST_CASCADES_WORKAROUND 1 // Doesn't make sense but it's super fast
 #define ANKI_FAST_CASCADES_WORKAROUND 1 // Doesn't make sense but it's super fast
 
 
@@ -250,8 +250,8 @@ F32 computeShadowFactorDirLight(
 }
 }
 
 
 // Compute the shadow factor of a directional light
 // Compute the shadow factor of a directional light
-F32 computeShadowFactorDirLight(
-	Mat4 lightProjectionMat, Vec3 worldPos, texture2D shadowMap, samplerShadow shadowMapSampler)
+F32 computeShadowFactorDirLight(Mat4 lightProjectionMat, Vec3 worldPos, texture2D shadowMap,
+								samplerShadow shadowMapSampler)
 {
 {
 	const Vec4 texCoords4 = lightProjectionMat * Vec4(worldPos, 1.0);
 	const Vec4 texCoords4 = lightProjectionMat * Vec4(worldPos, 1.0);
 	const Vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
 	const Vec3 texCoords3 = texCoords4.xyz / texCoords4.w;
@@ -298,10 +298,9 @@ F32 computeAttenuationFactor(F32 squareRadiusOverOne, Vec3 frag2Light)
 
 
 // Given the probe properties trace a ray inside the probe and find the cube tex coordinates to sample
 // Given the probe properties trace a ray inside the probe and find the cube tex coordinates to sample
 Vec3 intersectProbe(Vec3 fragPos, // Ray origin
 Vec3 intersectProbe(Vec3 fragPos, // Ray origin
-	Vec3 rayDir, // Ray direction
-	Vec3 probeAabbMin,
-	Vec3 probeAabbMax,
-	Vec3 probeOrigin // Cubemap origin
+					Vec3 rayDir, // Ray direction
+					Vec3 probeAabbMin, Vec3 probeAabbMax,
+					Vec3 probeOrigin // Cubemap origin
 )
 )
 {
 {
 	// Compute the intersection point
 	// Compute the intersection point
@@ -315,9 +314,7 @@ Vec3 intersectProbe(Vec3 fragPos, // Ray origin
 // Compute a weight (factor) of fragPos against some probe's bounds. The weight will be zero when fragPos is close to
 // Compute a weight (factor) of fragPos against some probe's bounds. The weight will be zero when fragPos is close to
 // AABB bounds and 1.0 at fadeDistance and less.
 // AABB bounds and 1.0 at fadeDistance and less.
 F32 computeProbeBlendWeight(Vec3 fragPos, // Doesn't need to be inside the AABB
 F32 computeProbeBlendWeight(Vec3 fragPos, // Doesn't need to be inside the AABB
-	Vec3 probeAabbMin,
-	Vec3 probeAabbMax,
-	F32 fadeDistance)
+							Vec3 probeAabbMin, Vec3 probeAabbMax, F32 fadeDistance)
 {
 {
 	// Compute the min distance of fragPos from the edges of the AABB
 	// Compute the min distance of fragPos from the edges of the AABB
 	const Vec3 distFromMin = fragPos - probeAabbMin;
 	const Vec3 distFromMin = fragPos - probeAabbMin;
@@ -347,11 +344,8 @@ Vec3 sampleAmbientDice(Vec3 posx, Vec3 negx, Vec3 posy, Vec3 negy, Vec3 posz, Ve
 }
 }
 
 
 // Sample the irradiance term from the clipmap
 // Sample the irradiance term from the clipmap
-Vec3 sampleGlobalIllumination(const Vec3 worldPos,
-	const Vec3 normal,
-	const GlobalIlluminationProbe probe,
-	texture3D textures[MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES],
-	sampler linearAnyClampSampler)
+Vec3 sampleGlobalIllumination(const Vec3 worldPos, const Vec3 normal, const GlobalIlluminationProbe probe,
+							  texture3D textures[MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES], sampler linearAnyClampSampler)
 {
 {
 	// Find the UVW
 	// Find the UVW
 	Vec3 uvw = (worldPos - probe.m_aabbMin) / (probe.m_aabbMax - probe.m_aabbMin);
 	Vec3 uvw = (worldPos - probe.m_aabbMin) / (probe.m_aabbMax - probe.m_aabbMin);
@@ -375,13 +369,8 @@ Vec3 sampleGlobalIllumination(const Vec3 worldPos,
 	}
 	}
 
 
 	// Sample the irradiance
 	// Sample the irradiance
-	const Vec3 irradiance = sampleAmbientDice(irradiancePerDir[0],
-		irradiancePerDir[1],
-		irradiancePerDir[2],
-		irradiancePerDir[3],
-		irradiancePerDir[4],
-		irradiancePerDir[5],
-		normal);
+	const Vec3 irradiance = sampleAmbientDice(irradiancePerDir[0], irradiancePerDir[1], irradiancePerDir[2],
+											  irradiancePerDir[3], irradiancePerDir[4], irradiancePerDir[5], normal);
 
 
 	return irradiance;
 	return irradiance;
 }
 }

+ 5 - 5
shaders/LightShading.ankiprog

@@ -233,15 +233,15 @@ void main()
 
 
 		const U32 crntProbeIdx = u_lightIndices[idxOffset];
 		const U32 crntProbeIdx = u_lightIndices[idxOffset];
 		if(subgroupAllEqual(crntProbeIdx)
 		if(subgroupAllEqual(crntProbeIdx)
-			&& subgroupAll(crntProbeIdx != MAX_U32 && u_lightIndices[idxOffset + 1u] == MAX_U32))
+		   && subgroupAll(crntProbeIdx != MAX_U32 && u_lightIndices[idxOffset + 1u] == MAX_U32))
 		{
 		{
 			// All subgroups point to the same probe and there is only one probe, do a fast path without blend weight
 			// All subgroups point to the same probe and there is only one probe, do a fast path without blend weight
 
 
 			GlobalIlluminationProbe probe = u_giProbes[subgroupBroadcastFirst(crntProbeIdx)]; // It should be uniform
 			GlobalIlluminationProbe probe = u_giProbes[subgroupBroadcastFirst(crntProbeIdx)]; // It should be uniform
 
 
 			// Sample
 			// Sample
-			diffIndirect = sampleGlobalIllumination(
-				worldPos, gbuffer.m_normal, probe, u_globalIlluminationTextures, u_trilinearClampSampler);
+			diffIndirect = sampleGlobalIllumination(worldPos, gbuffer.m_normal, probe, u_globalIlluminationTextures,
+													u_trilinearClampSampler);
 		}
 		}
 		else
 		else
 		{
 		{
@@ -271,8 +271,8 @@ void main()
 						totalBlendWeight += blendWeight;
 						totalBlendWeight += blendWeight;
 
 
 						// Sample
 						// Sample
-						const Vec3 c = sampleGlobalIllumination(
-							worldPos, gbuffer.m_normal, probe, u_globalIlluminationTextures, u_trilinearClampSampler);
+						const Vec3 c = sampleGlobalIllumination(worldPos, gbuffer.m_normal, probe,
+																u_globalIlluminationTextures, u_trilinearClampSampler);
 						diffIndirect += c * blendWeight;
 						diffIndirect += c * blendWeight;
 					}
 					}
 				}
 				}

+ 3 - 9
shaders/MotionBlur.glsl

@@ -14,15 +14,9 @@
 #endif
 #endif
 
 
 // Perform motion blur.
 // Perform motion blur.
-Vec3 motionBlur(texture2D velocityTex,
-	sampler velocityTexSampler,
-	texture2D toBlurTex,
-	sampler toBlurTexSampler,
-	texture2D depthTex,
-	sampler depthTexSampler,
-	Vec2 nowUv,
-	Mat4 prevViewProjMatMulInvViewProjMat,
-	U32 maxSamples)
+Vec3 motionBlur(texture2D velocityTex, sampler velocityTexSampler, texture2D toBlurTex, sampler toBlurTexSampler,
+				texture2D depthTex, sampler depthTexSampler, Vec2 nowUv, Mat4 prevViewProjMatMulInvViewProjMat,
+				U32 maxSamples)
 {
 {
 	// Compute previous UV
 	// Compute previous UV
 	Vec2 velocity = textureLod(velocityTex, velocityTexSampler, nowUv, 0.0).rg;
 	Vec2 velocity = textureLod(velocityTex, velocityTexSampler, nowUv, 0.0).rg;

+ 2 - 3
shaders/ShadowmapsResolve.ankiprog

@@ -85,9 +85,8 @@ void main()
 	}
 	}
 
 
 	// Store
 	// Store
-	imageStore(out_img,
-		IVec2(gl_GlobalInvocationID.xy),
-		Vec4(shadowFactors[0], shadowFactors[1], shadowFactors[2], shadowFactors[3]));
+	imageStore(out_img, IVec2(gl_GlobalInvocationID.xy),
+			   Vec4(shadowFactors[0], shadowFactors[1], shadowFactors[2], shadowFactors[3]));
 }
 }
 
 
 #pragma anki end
 #pragma anki end

+ 13 - 26
shaders/SsRaymarching.glsl

@@ -57,19 +57,13 @@ void stepToNextCell(Vec3 rayOrigin, Vec3 rayDir, U32 mipLevel, UVec2 hizSize, ou
 
 
 // Note: All calculations in view space
 // Note: All calculations in view space
 void raymarch(Vec3 rayOrigin, // Ray origin in view space
 void raymarch(Vec3 rayOrigin, // Ray origin in view space
-	Vec3 rayDir, // Ray dir in view space
-	F32 tmin, // Shoot rays from
-	Vec2 uv, // UV the ray starts
-	F32 depthRef, // Depth the ray starts
-	Mat4 projMat, // Projection matrix
-	U32 randFrom0To3,
-	U32 maxIterations,
-	texture2D hizTex,
-	sampler hizSampler,
-	U32 hizMipCount,
-	UVec2 hizMip0Size,
-	out Vec3 hitPoint,
-	out F32 attenuation)
+			  Vec3 rayDir, // Ray dir in view space
+			  F32 tmin, // Shoot rays from
+			  Vec2 uv, // UV the ray starts
+			  F32 depthRef, // Depth the ray starts
+			  Mat4 projMat, // Projection matrix
+			  U32 randFrom0To3, U32 maxIterations, texture2D hizTex, sampler hizSampler, U32 hizMipCount,
+			  UVec2 hizMip0Size, out Vec3 hitPoint, out F32 attenuation)
 {
 {
 	attenuation = 0.0;
 	attenuation = 0.0;
 
 
@@ -149,19 +143,12 @@ void raymarch(Vec3 rayOrigin, // Ray origin in view space
 
 
 // Note: All calculations in view space
 // Note: All calculations in view space
 void raymarchGroundTruth(Vec3 rayOrigin, // Ray origin in view space
 void raymarchGroundTruth(Vec3 rayOrigin, // Ray origin in view space
-	Vec3 rayDir, // Ray dir in view space
-	Vec2 uv, // UV the ray starts
-	F32 depthRef, // Depth the ray starts
-	Mat4 projMat, // Projection matrix
-	U32 maxIterations,
-	texture2D depthTex,
-	sampler depthSampler,
-	F32 depthLod,
-	UVec2 depthTexSize,
-	U32 bigStep,
-	U32 randInitialStep,
-	out Vec3 hitPoint,
-	out F32 attenuation)
+						 Vec3 rayDir, // Ray dir in view space
+						 Vec2 uv, // UV the ray starts
+						 F32 depthRef, // Depth the ray starts
+						 Mat4 projMat, // Projection matrix
+						 U32 maxIterations, texture2D depthTex, sampler depthSampler, F32 depthLod, UVec2 depthTexSize,
+						 U32 bigStep, U32 randInitialStep, out Vec3 hitPoint, out F32 attenuation)
 {
 {
 	attenuation = 0.0;
 	attenuation = 0.0;
 
 

+ 4 - 15
shaders/Ssgi.ankiprog

@@ -50,7 +50,7 @@ void main()
 #endif
 #endif
 
 
 	if(fixedGlobalInvocationId.x >= u_unis.m_framebufferSize.x
 	if(fixedGlobalInvocationId.x >= u_unis.m_framebufferSize.x
-		|| fixedGlobalInvocationId.y >= u_unis.m_framebufferSize.y)
+	   || fixedGlobalInvocationId.y >= u_unis.m_framebufferSize.y)
 	{
 	{
 		// Skip threads outside the writable image
 		// Skip threads outside the writable image
 		return;
 		return;
@@ -81,20 +81,9 @@ void main()
 	const U32 lod = 0;
 	const U32 lod = 0;
 	const F32 minStepf = 4.0;
 	const F32 minStepf = 4.0;
 	const F32 noise = F32(random.x) * (1.0 / 65536.0);
 	const F32 noise = F32(random.x) * (1.0 / 65536.0);
-	raymarchGroundTruth(viewPos,
-		randomHemisphere,
-		uv,
-		depth,
-		u_unis.m_projMat,
-		u_unis.m_maxSteps,
-		u_depthRt,
-		u_trilinearClampSampler,
-		F32(lod),
-		u_unis.m_depthBufferSize,
-		u_unis.m_firstStepPixels,
-		U32(mix(minStepf, F32(u_unis.m_firstStepPixels), noise)),
-		hitPoint,
-		hitAttenuation);
+	raymarchGroundTruth(viewPos, randomHemisphere, uv, depth, u_unis.m_projMat, u_unis.m_maxSteps, u_depthRt,
+						u_trilinearClampSampler, F32(lod), u_unis.m_depthBufferSize, u_unis.m_firstStepPixels,
+						U32(mix(minStepf, F32(u_unis.m_firstStepPixels), noise)), hitPoint, hitAttenuation);
 
 
 	// Reject backfacing
 	// Reject backfacing
 	ANKI_BRANCH if(hitAttenuation > 0.0)
 	ANKI_BRANCH if(hitAttenuation > 0.0)

+ 4 - 15
shaders/Ssr.ankiprog

@@ -51,7 +51,7 @@ void main()
 #endif
 #endif
 
 
 	if(fixedGlobalInvocationId.x >= I32(u_unis.m_framebufferSize.x)
 	if(fixedGlobalInvocationId.x >= I32(u_unis.m_framebufferSize.x)
-		|| fixedGlobalInvocationId.y >= I32(u_unis.m_framebufferSize.y))
+	   || fixedGlobalInvocationId.y >= I32(u_unis.m_framebufferSize.y))
 	{
 	{
 		// Skip threads outside the writable image
 		// Skip threads outside the writable image
 		return;
 		return;
@@ -87,20 +87,9 @@ void main()
 	const U32 step = u_unis.m_firstStepPixels;
 	const U32 step = u_unis.m_firstStepPixels;
 	const F32 stepf = step;
 	const F32 stepf = step;
 	const F32 minStepf = stepf / 4.0;
 	const F32 minStepf = stepf / 4.0;
-	raymarchGroundTruth(viewPos,
-		reflVec,
-		uv,
-		depth,
-		u_unis.m_projMat,
-		u_unis.m_maxSteps,
-		u_depthRt,
-		u_trilinearClampSampler,
-		F32(lod),
-		u_unis.m_depthBufferSize,
-		step,
-		U32((stepf - minStepf) * noise + minStepf),
-		hitPoint,
-		hitAttenuation);
+	raymarchGroundTruth(viewPos, reflVec, uv, depth, u_unis.m_projMat, u_unis.m_maxSteps, u_depthRt,
+						u_trilinearClampSampler, F32(lod), u_unis.m_depthBufferSize, step,
+						U32((stepf - minStepf) * noise + minStepf), hitPoint, hitAttenuation);
 
 
 #if EXTRA_REJECTION
 #if EXTRA_REJECTION
 	// Reject backfacing
 	// Reject backfacing

+ 6 - 6
shaders/VolumetricLightingAccumulation.ankiprog

@@ -179,8 +179,8 @@ Vec4 accumulateLightsAndFog(U32 clusterIdx, Vec3 worldPos, F32 linearDepth)
 			GlobalIlluminationProbe probe = u_giProbes[u_lightIndices[idxOffset]];
 			GlobalIlluminationProbe probe = u_giProbes[u_lightIndices[idxOffset]];
 
 
 			// Sample
 			// Sample
-			diffIndirect = sampleGlobalIllumination(
-				worldPos, viewDir, probe, u_globalIlluminationTextures, u_linearAnyClampSampler);
+			diffIndirect = sampleGlobalIllumination(worldPos, viewDir, probe, u_globalIlluminationTextures,
+													u_linearAnyClampSampler);
 		}
 		}
 		else
 		else
 		{
 		{
@@ -200,8 +200,8 @@ Vec4 accumulateLightsAndFog(U32 clusterIdx, Vec3 worldPos, F32 linearDepth)
 				totalBlendWeight += blendWeight;
 				totalBlendWeight += blendWeight;
 
 
 				// Sample
 				// Sample
-				const Vec3 c = sampleGlobalIllumination(
-					worldPos, viewDir, probe, u_globalIlluminationTextures, u_linearAnyClampSampler);
+				const Vec3 c = sampleGlobalIllumination(worldPos, viewDir, probe, u_globalIlluminationTextures,
+														u_linearAnyClampSampler);
 				diffIndirect += c * blendWeight;
 				diffIndirect += c * blendWeight;
 			}
 			}
 
 
@@ -226,8 +226,8 @@ Vec4 accumulateLightsAndFog(U32 clusterIdx, Vec3 worldPos, F32 linearDepth)
 			F32 factor;
 			F32 factor;
 			ANKI_BRANCH if(vol.m_isBox == 1u)
 			ANKI_BRANCH if(vol.m_isBox == 1u)
 			{
 			{
-				factor = computeProbeBlendWeight(
-					worldPos, vol.m_aabbMinOrSphereCenter, vol.m_aabbMaxOrSphereRadiusSquared, 0.2);
+				factor = computeProbeBlendWeight(worldPos, vol.m_aabbMinOrSphereCenter,
+												 vol.m_aabbMaxOrSphereRadiusSquared, 0.2);
 			}
 			}
 			else
 			else
 			{
 			{

+ 4 - 4
shaders/glsl_cpp_common/ClusteredShading.h

@@ -169,8 +169,8 @@ ANKI_SHADER_FUNC_INLINE U32 computeClusterK(ClustererMagicValues magic, Vec3 wor
 }
 }
 
 
 // Compute cluster index
 // Compute cluster index
-ANKI_SHADER_FUNC_INLINE U32 computeClusterIndex(
-	ClustererMagicValues magic, Vec2 uv, Vec3 worldPos, U32 clusterCountX, U32 clusterCountY)
+ANKI_SHADER_FUNC_INLINE U32 computeClusterIndex(ClustererMagicValues magic, Vec2 uv, Vec3 worldPos, U32 clusterCountX,
+												U32 clusterCountY)
 {
 {
 	const UVec2 xy = UVec2(uv * Vec2(F32(clusterCountX), F32(clusterCountY)));
 	const UVec2 xy = UVec2(uv * Vec2(F32(clusterCountX), F32(clusterCountY)));
 	const U32 k = computeClusterK(magic, worldPos);
 	const U32 k = computeClusterK(magic, worldPos);
@@ -190,8 +190,8 @@ ANKI_SHADER_FUNC_INLINE F32 computeClusterNear(ClustererMagicValues magic, U32 k
 }
 }
 
 
 // Compute the UV coordinates of a volume texture that encloses the clusterer
 // Compute the UV coordinates of a volume texture that encloses the clusterer
-ANKI_SHADER_FUNC_INLINE Vec3 computeClustererVolumeTextureUvs(
-	ClustererMagicValues magic, Vec2 uv, Vec3 worldPos, U32 clusterCountZ)
+ANKI_SHADER_FUNC_INLINE Vec3 computeClustererVolumeTextureUvs(ClustererMagicValues magic, Vec2 uv, Vec3 worldPos,
+															  U32 clusterCountZ)
 {
 {
 	const F32 k = computeClusterKf(magic, worldPos);
 	const F32 k = computeClusterKf(magic, worldPos);
 	return Vec3(uv, k / F32(clusterCountZ));
 	return Vec3(uv, k / F32(clusterCountZ));

+ 2 - 2
src/anki/collision/GjkEpa.cpp

@@ -210,8 +210,8 @@ static Bool update(GjkContext& ctx, const GjkSupport& a)
 	return true;
 	return true;
 }
 }
 
 
-Bool gjkIntersection(
-	const void* shape0, GjkSupportCallback shape0Callback, const void* shape1, GjkSupportCallback shape1Callback)
+Bool gjkIntersection(const void* shape0, GjkSupportCallback shape0Callback, const void* shape1,
+					 GjkSupportCallback shape1Callback)
 {
 {
 	ANKI_ASSERT(shape0 && shape0Callback && shape1 && shape1Callback);
 	ANKI_ASSERT(shape0 && shape0Callback && shape1 && shape1Callback);
 
 

+ 2 - 2
src/anki/collision/GjkEpa.h

@@ -17,8 +17,8 @@ namespace anki
 using GjkSupportCallback = Vec4 (*)(const void* shape, const Vec4& dir);
 using GjkSupportCallback = Vec4 (*)(const void* shape, const Vec4& dir);
 
 
 /// Return true if the two convex shapes intersect.
 /// Return true if the two convex shapes intersect.
-Bool gjkIntersection(
-	const void* shape0, GjkSupportCallback shape0Callback, const void* shape1, GjkSupportCallback shape1Callback);
+Bool gjkIntersection(const void* shape0, GjkSupportCallback shape0Callback, const void* shape1,
+					 GjkSupportCallback shape1Callback);
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 2 - 2
src/anki/collision/Ray.h

@@ -109,8 +109,8 @@ private:
 
 
 	void check() const
 	void check() const
 	{
 	{
-		ANKI_ASSERT(
-			m_origin.w() == 0.0f && m_dir.w() == 0.0f && isZero(m_dir.getLengthSquared() - 1.0f, EPSILON * 100.0f));
+		ANKI_ASSERT(m_origin.w() == 0.0f && m_dir.w() == 0.0f
+					&& isZero(m_dir.getLengthSquared() - 1.0f, EPSILON * 100.0f));
 	}
 	}
 };
 };
 /// @}
 /// @}

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

@@ -339,12 +339,7 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 				   "compiler %s, "
 				   "compiler %s, "
 				   "build date %s, "
 				   "build date %s, "
 				   "commit %s)",
 				   "commit %s)",
-		ANKI_VERSION_MAJOR,
-		ANKI_VERSION_MINOR,
-		buildType,
-		ANKI_COMPILER_STR,
-		__DATE__,
-		ANKI_REVISION);
+				   ANKI_VERSION_MAJOR, ANKI_VERSION_MINOR, buildType, ANKI_COMPILER_STR, __DATE__, ANKI_REVISION);
 
 
 	m_timerTick = 1.0 / F32(config.getNumberU32("core_targetFps")); // in sec. 1.0 / period
 	m_timerTick = 1.0 / F32(config.getNumberU32("core_targetFps")); // in sec. 1.0 / period
 
 
@@ -455,8 +450,8 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 
 
 	m_renderer = m_heapAlloc.newInstance<MainRenderer>();
 	m_renderer = m_heapAlloc.newInstance<MainRenderer>();
 
 
-	ANKI_CHECK(m_renderer->init(
-		m_threadHive, m_resources, m_gr, m_stagingMem, m_ui, m_allocCb, m_allocCbData, config, &m_globalTimestamp));
+	ANKI_CHECK(m_renderer->init(m_threadHive, m_resources, m_gr, m_stagingMem, m_ui, m_allocCb, m_allocCbData, config,
+								&m_globalTimestamp));
 
 
 	//
 	//
 	// Script
 	// Script
@@ -469,8 +464,8 @@ Error App::initInternal(const ConfigSet& config_, AllocAlignedCallback allocCb,
 	//
 	//
 	m_scene = m_heapAlloc.newInstance<SceneGraph>();
 	m_scene = m_heapAlloc.newInstance<SceneGraph>();
 
 
-	ANKI_CHECK(m_scene->init(
-		m_allocCb, m_allocCbData, m_threadHive, m_resources, m_input, m_script, &m_globalTimestamp, config));
+	ANKI_CHECK(m_scene->init(m_allocCb, m_allocCbData, m_threadHive, m_resources, m_input, m_script, &m_globalTimestamp,
+							 config));
 
 
 	// Inform the script engine about some subsystems
 	// Inform the script engine about some subsystems
 	m_script->setRenderer(m_renderer);
 	m_script->setRenderer(m_renderer);
@@ -637,9 +632,8 @@ Error App::mainLoop()
 #if ANKI_ENABLE_TRACE
 #if ANKI_ENABLE_TRACE
 			if(m_renderer->getStats().m_renderingGpuTime >= 0.0)
 			if(m_renderer->getStats().m_renderingGpuTime >= 0.0)
 			{
 			{
-				ANKI_TRACE_CUSTOM_EVENT(GPU_TIME,
-					m_renderer->getStats().m_renderingGpuSubmitTimestamp,
-					m_renderer->getStats().m_renderingGpuTime);
+				ANKI_TRACE_CUSTOM_EVENT(GPU_TIME, m_renderer->getStats().m_renderingGpuSubmitTimestamp,
+										m_renderer->getStats().m_renderingGpuTime);
 			}
 			}
 #endif
 #endif
 
 

+ 10 - 12
src/anki/core/ConfigSet.cpp

@@ -320,21 +320,19 @@ Error ConfigSet::loadFromFile(CString filename)
 		{
 		{
 			if(option.m_type == Option::FLOAT)
 			if(option.m_type == Option::FLOAT)
 			{
 			{
-				ANKI_CORE_LOGW(
-					"Missing option for \"%s\". Will use the default value: %f", &option.m_name[0], option.m_float);
+				ANKI_CORE_LOGW("Missing option for \"%s\". Will use the default value: %f", &option.m_name[0],
+							   option.m_float);
 			}
 			}
 			else if(option.m_type == Option::UNSIGNED)
 			else if(option.m_type == Option::UNSIGNED)
 			{
 			{
-				ANKI_CORE_LOGW("Missing option for \"%s\". Will use the default value: %" PRIu64,
-					&option.m_name[0],
-					option.m_unsigned);
+				ANKI_CORE_LOGW("Missing option for \"%s\". Will use the default value: %" PRIu64, &option.m_name[0],
+							   option.m_unsigned);
 			}
 			}
 			else
 			else
 			{
 			{
 				ANKI_ASSERT(option.m_type == Option::STRING);
 				ANKI_ASSERT(option.m_type == Option::STRING);
-				ANKI_CORE_LOGW("Missing option for \"%s\". Will use the default value: %s",
-					option.m_name.cstr(),
-					option.m_str.cstr());
+				ANKI_CORE_LOGW("Missing option for \"%s\". Will use the default value: %s", option.m_name.cstr(),
+							   option.m_str.cstr());
 			}
 			}
 		}
 		}
 	}
 	}
@@ -364,14 +362,14 @@ Error ConfigSet::saveToFile(CString filename) const
 		}
 		}
 		else if(option.m_type == Option::UNSIGNED)
 		else if(option.m_type == Option::UNSIGNED)
 		{
 		{
-			ANKI_CHECK(file.writeText(
-				"\t<%s>%" PRIu64 "</%s>\n", option.m_name.cstr(), option.m_unsigned, option.m_name.cstr()));
+			ANKI_CHECK(file.writeText("\t<%s>%" PRIu64 "</%s>\n", option.m_name.cstr(), option.m_unsigned,
+									  option.m_name.cstr()));
 		}
 		}
 		else
 		else
 		{
 		{
 			ANKI_ASSERT(option.m_type == Option::STRING);
 			ANKI_ASSERT(option.m_type == Option::STRING);
-			ANKI_CHECK(file.writeText(
-				"\t<%s><![CDATA[%s]]></%s>\n", option.m_name.cstr(), option.m_str.cstr(), option.m_name.cstr()));
+			ANKI_CHECK(file.writeText("\t<%s><![CDATA[%s]]></%s>\n", option.m_name.cstr(), option.m_str.cstr(),
+									  option.m_name.cstr()));
 		}
 		}
 	}
 	}
 
 

+ 10 - 18
src/anki/core/CoreTracer.cpp

@@ -114,19 +114,15 @@ Error CoreTracer::init(GenericMemoryPoolAllocator<U8> alloc, CString directory)
 	ANKI_CORE_LOGI("Tracing is %s from the beginning", (enableTracer) ? "enabled" : "disabled");
 	ANKI_CORE_LOGI("Tracing is %s from the beginning", (enableTracer) ? "enabled" : "disabled");
 
 
 	m_alloc = alloc;
 	m_alloc = alloc;
-	m_thread.start(this,
-		[](ThreadCallbackInfo& info) -> Error { return static_cast<CoreTracer*>(info.m_userData)->threadWorker(); });
+	m_thread.start(this, [](ThreadCallbackInfo& info) -> Error {
+		return static_cast<CoreTracer*>(info.m_userData)->threadWorker();
+	});
 
 
 	std::time_t t = std::time(nullptr);
 	std::time_t t = std::time(nullptr);
 	std::tm* tm = std::localtime(&t);
 	std::tm* tm = std::localtime(&t);
 	StringAuto fname(m_alloc);
 	StringAuto fname(m_alloc);
-	fname.sprintf("%s/%d%02d%02d-%02d%02d_",
-		directory.cstr(),
-		tm->tm_year + 1900,
-		tm->tm_mon + 1,
-		tm->tm_mday,
-		tm->tm_hour,
-		tm->tm_min);
+	fname.sprintf("%s/%d%02d%02d-%02d%02d_", directory.cstr(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+				  tm->tm_hour, tm->tm_min);
 
 
 	ANKI_CHECK(m_traceJsonFile.open(StringAuto(alloc).sprintf("%strace.json", fname.cstr()), FileOpenFlag::WRITE));
 	ANKI_CHECK(m_traceJsonFile.open(StringAuto(alloc).sprintf("%strace.json", fname.cstr()), FileOpenFlag::WRITE));
 	ANKI_CHECK(m_traceJsonFile.writeText("[\n"));
 	ANKI_CHECK(m_traceJsonFile.writeText("[\n"));
@@ -200,10 +196,7 @@ Error CoreTracer::writeEvents(ThreadWorkItem& item)
 
 
 		ANKI_CHECK(m_traceJsonFile.writeText("{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"X\", "
 		ANKI_CHECK(m_traceJsonFile.writeText("{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\": \"X\", "
 											 "\"pid\": 1, \"tid\": %llu, \"ts\": %lld, \"dur\": %lld},\n",
 											 "\"pid\": 1, \"tid\": %llu, \"ts\": %lld, \"dur\": %lld},\n",
-			event.m_name.cstr(),
-			tid,
-			startMicroSec,
-			durMicroSec));
+											 event.m_name.cstr(), tid, startMicroSec, durMicroSec));
 	}
 	}
 
 
 	// Store counters
 	// Store counters
@@ -215,9 +208,8 @@ Error CoreTracer::writeEvents(ThreadWorkItem& item)
 void CoreTracer::gatherCounters(ThreadWorkItem& item)
 void CoreTracer::gatherCounters(ThreadWorkItem& item)
 {
 {
 	// Sort
 	// Sort
-	std::sort(item.m_counters.getBegin(), item.m_counters.getEnd(), [](const TracerCounter& a, const TracerCounter& b) {
-		return a.m_name < b.m_name;
-	});
+	std::sort(item.m_counters.getBegin(), item.m_counters.getEnd(),
+			  [](const TracerCounter& a, const TracerCounter& b) { return a.m_name < b.m_name; });
 
 
 	// Merge same
 	// Merge same
 	DynamicArrayAuto<TracerCounter> mergedCounters(m_alloc);
 	DynamicArrayAuto<TracerCounter> mergedCounters(m_alloc);
@@ -387,8 +379,8 @@ Error CoreTracer::writeCountersForReal()
 		{
 		{
 			Array<char, 3> columnName;
 			Array<char, 3> columnName;
 			getSpreadsheetColumnName(i + 1, columnName);
 			getSpreadsheetColumnName(i + 1, columnName);
-			ANKI_CHECK(m_countersCsvFile.writeText(
-				",=%s(%s2:%s%u)", func, &columnName[0], &columnName[0], m_frameCounters.getSize() + 1));
+			ANKI_CHECK(m_countersCsvFile.writeText(",=%s(%s2:%s%u)", func, &columnName[0], &columnName[0],
+												   m_frameCounters.getSize() + 1));
 		}
 		}
 
 
 		ANKI_CHECK(m_countersCsvFile.writeText("\n"));
 		ANKI_CHECK(m_countersCsvFile.writeText("\n"));

+ 7 - 13
src/anki/core/DeveloperConsole.cpp

@@ -49,10 +49,8 @@ void DeveloperConsole::build(CanvasPtr ctx)
 
 
 	// Push the items
 	// Push the items
 	const F32 footerHeightToPreserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
 	const F32 footerHeightToPreserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
-	ImGui::BeginChild("ScrollingRegion",
-		Vec2(0, -footerHeightToPreserve),
-		false,
-		ImGuiWindowFlags_HorizontalScrollbar); // Leave room for 1 separator + 1 InputText
+	ImGui::BeginChild("ScrollingRegion", Vec2(0, -footerHeightToPreserve), false,
+					  ImGuiWindowFlags_HorizontalScrollbar); // Leave room for 1 separator + 1 InputText
 
 
 	ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, Vec2(4.0f, 1.0f)); // Tighten spacing
 	ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, Vec2(4.0f, 1.0f)); // Tighten spacing
 
 
@@ -75,13 +73,9 @@ void DeveloperConsole::build(CanvasPtr ctx)
 		}
 		}
 
 
 		static const Array<const char*, static_cast<U>(LoggerMessageType::COUNT)> MSG_TEXT = {{"I", "E", "W", "F"}};
 		static const Array<const char*, static_cast<U>(LoggerMessageType::COUNT)> MSG_TEXT = {{"I", "E", "W", "F"}};
-		ImGui::TextWrapped("[%s][%s] %s (%s:%d %s)",
-			MSG_TEXT[static_cast<U>(item.m_type)],
-			(item.m_subsystem) ? item.m_subsystem : "N/A ",
-			item.m_msg.cstr(),
-			item.m_file,
-			item.m_line,
-			item.m_func);
+		ImGui::TextWrapped("[%s][%s] %s (%s:%d %s)", MSG_TEXT[static_cast<U>(item.m_type)],
+						   (item.m_subsystem) ? item.m_subsystem : "N/A ", item.m_msg.cstr(), item.m_file, item.m_line,
+						   item.m_func);
 
 
 		ImGui::PopStyleColor();
 		ImGui::PopStyleColor();
 	}
 	}
@@ -100,8 +94,8 @@ void DeveloperConsole::build(CanvasPtr ctx)
 	// Commands
 	// Commands
 	ImGui::Separator();
 	ImGui::Separator();
 	ImGui::PushItemWidth(-1.0f); // Use the whole size
 	ImGui::PushItemWidth(-1.0f); // Use the whole size
-	if(ImGui::InputText(
-		   "", &m_inputText[0], m_inputText.getSizeInBytes(), ImGuiInputTextFlags_EnterReturnsTrue, nullptr, nullptr))
+	if(ImGui::InputText("", &m_inputText[0], m_inputText.getSizeInBytes(), ImGuiInputTextFlags_EnterReturnsTrue,
+						nullptr, nullptr))
 	{
 	{
 		const Error err = m_scriptEnv.evalString(&m_inputText[0]);
 		const Error err = m_scriptEnv.evalString(&m_inputText[0]);
 		if(!err)
 		if(!err)

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

@@ -40,11 +40,11 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 
 
 #if ANKI_GR_BACKEND_GL
 #if ANKI_GR_BACKEND_GL
 	if(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, init.m_rgbaBits[0])
 	if(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, init.m_rgbaBits[0])
-		|| SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, init.m_rgbaBits[1])
-		|| SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, init.m_rgbaBits[2])
-		|| SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, init.m_rgbaBits[3])
-		|| SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, init.m_depthBits)
-		|| SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, init.m_doubleBuffer))
+	   || SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, init.m_rgbaBits[1])
+	   || SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, init.m_rgbaBits[2])
+	   || SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, init.m_rgbaBits[3])
+	   || SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, init.m_depthBits)
+	   || SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, init.m_doubleBuffer))
 	{
 	{
 		ANKI_CORE_LOGE("SDL_GL_SetAttribute() failed");
 		ANKI_CORE_LOGE("SDL_GL_SetAttribute() failed");
 		return Error::FUNCTION_FAILED;
 		return Error::FUNCTION_FAILED;
@@ -78,8 +78,8 @@ Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
 		init.m_height = mode.h;
 		init.m_height = mode.h;
 	}
 	}
 
 
-	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)
 	if(m_impl->m_window == nullptr)
 	{
 	{

+ 9 - 18
src/anki/core/StagingGpuMemoryManager.cpp

@@ -31,31 +31,22 @@ Error StagingGpuMemoryManager::init(GrManager* gr, const ConfigSet& cfg)
 	m_perFrameBuffers[StagingGpuMemoryType::VERTEX].m_size = cfg.getNumberU32("core_vertexPerFrameMemorySize");
 	m_perFrameBuffers[StagingGpuMemoryType::VERTEX].m_size = cfg.getNumberU32("core_vertexPerFrameMemorySize");
 	m_perFrameBuffers[StagingGpuMemoryType::TEXTURE].m_size = cfg.getNumberU32("core_textureBufferPerFrameMemorySize");
 	m_perFrameBuffers[StagingGpuMemoryType::TEXTURE].m_size = cfg.getNumberU32("core_textureBufferPerFrameMemorySize");
 
 
-	initBuffer(StagingGpuMemoryType::UNIFORM,
-		gr->getDeviceCapabilities().m_uniformBufferBindOffsetAlignment,
-		gr->getDeviceCapabilities().m_uniformBufferMaxRange,
-		BufferUsageBit::ALL_UNIFORM,
-		*gr);
-
-	initBuffer(StagingGpuMemoryType::STORAGE,
-		gr->getDeviceCapabilities().m_storageBufferBindOffsetAlignment,
-		gr->getDeviceCapabilities().m_storageBufferMaxRange,
-		BufferUsageBit::ALL_STORAGE,
-		*gr);
+	initBuffer(StagingGpuMemoryType::UNIFORM, gr->getDeviceCapabilities().m_uniformBufferBindOffsetAlignment,
+			   gr->getDeviceCapabilities().m_uniformBufferMaxRange, BufferUsageBit::ALL_UNIFORM, *gr);
+
+	initBuffer(StagingGpuMemoryType::STORAGE, gr->getDeviceCapabilities().m_storageBufferBindOffsetAlignment,
+			   gr->getDeviceCapabilities().m_storageBufferMaxRange, BufferUsageBit::ALL_STORAGE, *gr);
 
 
 	initBuffer(StagingGpuMemoryType::VERTEX, 16, MAX_U32, BufferUsageBit::VERTEX | BufferUsageBit::INDEX, *gr);
 	initBuffer(StagingGpuMemoryType::VERTEX, 16, MAX_U32, BufferUsageBit::VERTEX | BufferUsageBit::INDEX, *gr);
 
 
-	initBuffer(StagingGpuMemoryType::TEXTURE,
-		gr->getDeviceCapabilities().m_textureBufferBindOffsetAlignment,
-		gr->getDeviceCapabilities().m_textureBufferMaxRange,
-		BufferUsageBit::ALL_TEXTURE,
-		*gr);
+	initBuffer(StagingGpuMemoryType::TEXTURE, gr->getDeviceCapabilities().m_textureBufferBindOffsetAlignment,
+			   gr->getDeviceCapabilities().m_textureBufferMaxRange, BufferUsageBit::ALL_TEXTURE, *gr);
 
 
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-void StagingGpuMemoryManager::initBuffer(
-	StagingGpuMemoryType type, U32 alignment, PtrSize maxAllocSize, BufferUsageBit usage, GrManager& gr)
+void StagingGpuMemoryManager::initBuffer(StagingGpuMemoryType type, U32 alignment, PtrSize maxAllocSize,
+										 BufferUsageBit usage, GrManager& gr)
 {
 {
 	auto& perframe = m_perFrameBuffers[type];
 	auto& perframe = m_perFrameBuffers[type];
 
 

+ 2 - 2
src/anki/core/StagingGpuMemoryManager.h

@@ -95,8 +95,8 @@ private:
 	GrManager* m_gr = nullptr;
 	GrManager* m_gr = nullptr;
 	Array<PerFrameBuffer, U(StagingGpuMemoryType::COUNT)> m_perFrameBuffers;
 	Array<PerFrameBuffer, U(StagingGpuMemoryType::COUNT)> m_perFrameBuffers;
 
 
-	void initBuffer(
-		StagingGpuMemoryType type, U32 alignment, PtrSize maxAllocSize, BufferUsageBit usage, GrManager& gr);
+	void initBuffer(StagingGpuMemoryType type, U32 alignment, PtrSize maxAllocSize, BufferUsageBit usage,
+					GrManager& gr);
 };
 };
 /// @}
 /// @}
 
 

+ 5 - 5
src/anki/gr/AccelerationStructure.h

@@ -33,15 +33,15 @@ public:
 	Bool isValid() const
 	Bool isValid() const
 	{
 	{
 		if(m_indexBuffer.get() == nullptr || m_indexCount == 0 || m_indexType == IndexType::COUNT
 		if(m_indexBuffer.get() == nullptr || m_indexCount == 0 || m_indexType == IndexType::COUNT
-			|| m_positionBuffer.get() == nullptr || m_positionStride == 0 || m_positionsFormat == Format::NONE
-			|| m_positionCount == 0)
+		   || m_positionBuffer.get() == nullptr || m_positionStride == 0 || m_positionsFormat == Format::NONE
+		   || m_positionCount == 0)
 		{
 		{
 			return false;
 			return false;
 		}
 		}
 
 
 		const PtrSize posRange = m_positionBufferOffset + m_positionStride * m_positionCount;
 		const PtrSize posRange = m_positionBufferOffset + m_positionStride * m_positionCount;
 		if(m_positionStride < getFormatBytes(m_positionsFormat)
 		if(m_positionStride < getFormatBytes(m_positionsFormat)
-			|| (m_positionStride % getFormatBytes(m_positionsFormat)) != 0 || posRange > m_positionBuffer->getSize())
+		   || (m_positionStride % getFormatBytes(m_positionsFormat)) != 0 || posRange > m_positionBuffer->getSize())
 		{
 		{
 			return false;
 			return false;
 		}
 		}
@@ -131,8 +131,8 @@ protected:
 
 
 private:
 private:
 	/// Allocate and initialize new instance.
 	/// Allocate and initialize new instance.
-	static ANKI_USE_RESULT AccelerationStructure* newInstance(
-		GrManager* manager, const AccelerationStructureInitInfo& init);
+	static ANKI_USE_RESULT AccelerationStructure* newInstance(GrManager* manager,
+															  const AccelerationStructureInitInfo& init);
 };
 };
 /// @}
 /// @}
 
 

+ 23 - 35
src/anki/gr/CommandBuffer.h

@@ -136,8 +136,8 @@ public:
 	/// @{
 	/// @{
 
 
 	/// Bind vertex buffer.
 	/// Bind vertex buffer.
-	void bindVertexBuffer(
-		U32 binding, BufferPtr buff, PtrSize offset, PtrSize stride, VertexStepRate stepRate = VertexStepRate::VERTEX);
+	void bindVertexBuffer(U32 binding, BufferPtr buff, PtrSize offset, PtrSize stride,
+						  VertexStepRate stepRate = VertexStepRate::VERTEX);
 
 
 	/// Setup a vertex attribute.
 	/// Setup a vertex attribute.
 	void setVertexAttribute(U32 location, U32 buffBinding, Format fmt, PtrSize relativeOffset);
 	void setVertexAttribute(U32 location, U32 buffBinding, Format fmt, PtrSize relativeOffset);
@@ -165,10 +165,8 @@ public:
 	void setPolygonOffset(F32 factor, F32 units);
 	void setPolygonOffset(F32 factor, F32 units);
 
 
 	/// Set stencil operations. To disable stencil test put StencilOperation::KEEP to all operations.
 	/// Set stencil operations. To disable stencil test put StencilOperation::KEEP to all operations.
-	void setStencilOperations(FaceSelectionBit face,
-		StencilOperation stencilFail,
-		StencilOperation stencilPassDepthFail,
-		StencilOperation stencilPassDepthPass);
+	void setStencilOperations(FaceSelectionBit face, StencilOperation stencilFail,
+							  StencilOperation stencilPassDepthFail, StencilOperation stencilPassDepthPass);
 
 
 	/// Set stencil compare operation.
 	/// Set stencil compare operation.
 	void setStencilCompareOperation(FaceSelectionBit face, CompareOperation comp);
 	void setStencilCompareOperation(FaceSelectionBit face, CompareOperation comp);
@@ -229,8 +227,8 @@ public:
 	/// @param sampler The sampler to override the default sampler of the tex.
 	/// @param sampler The sampler to override the default sampler of the tex.
 	/// @param usage The state the tex is in.
 	/// @param usage The state the tex is in.
 	/// @param arrayIdx The array index if the binding is an array.
 	/// @param arrayIdx The array index if the binding is an array.
-	void bindTextureAndSampler(
-		U32 set, U32 binding, TextureViewPtr texView, SamplerPtr sampler, TextureUsageBit usage, U32 arrayIdx = 0);
+	void bindTextureAndSampler(U32 set, U32 binding, TextureViewPtr texView, SamplerPtr sampler, TextureUsageBit usage,
+							   U32 arrayIdx = 0);
 
 
 	/// Bind sampler.
 	/// Bind sampler.
 	/// @param set The set to bind to.
 	/// @param set The set to bind to.
@@ -283,8 +281,8 @@ public:
 	///              of the buffer.
 	///              of the buffer.
 	/// @param fmt The format of the buffer.
 	/// @param fmt The format of the buffer.
 	/// @param arrayIdx The array index if the binding is an array.
 	/// @param arrayIdx The array index if the binding is an array.
-	void bindTextureBuffer(
-		U32 set, U32 binding, BufferPtr buff, PtrSize offset, PtrSize range, Format fmt, U32 arrayIdx = 0);
+	void bindTextureBuffer(U32 set, U32 binding, BufferPtr buff, PtrSize offset, PtrSize range, Format fmt,
+						   U32 arrayIdx = 0);
 
 
 	/// Bind an acceleration structure.
 	/// Bind an acceleration structure.
 	/// @param set The set to bind to.
 	/// @param set The set to bind to.
@@ -316,13 +314,9 @@ public:
 	/// Begin renderpass.
 	/// Begin renderpass.
 	/// The minx, miny, width, height control the area that the load and store operations will happen. If the scissor is
 	/// The minx, miny, width, height control the area that the load and store operations will happen. If the scissor is
 	/// bigger than the render area the results are undefined.
 	/// bigger than the render area the results are undefined.
-	void beginRenderPass(FramebufferPtr fb,
-		const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
-		TextureUsageBit depthStencilAttachmentUsage,
-		U32 minx = 0,
-		U32 miny = 0,
-		U32 width = MAX_U32,
-		U32 height = MAX_U32);
+	void beginRenderPass(FramebufferPtr fb, const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
+						 TextureUsageBit depthStencilAttachmentUsage, U32 minx = 0, U32 miny = 0, U32 width = MAX_U32,
+						 U32 height = MAX_U32);
 
 
 	/// End renderpass.
 	/// End renderpass.
 	void endRenderPass();
 	void endRenderPass();
@@ -330,12 +324,8 @@ public:
 
 
 	/// @name Jobs
 	/// @name Jobs
 	/// @{
 	/// @{
-	void drawElements(PrimitiveTopology topology,
-		U32 count,
-		U32 instanceCount = 1,
-		U32 firstIndex = 0,
-		U32 baseVertex = 0,
-		U32 baseInstance = 0);
+	void drawElements(PrimitiveTopology topology, U32 count, U32 instanceCount = 1, U32 firstIndex = 0,
+					  U32 baseVertex = 0, U32 baseInstance = 0);
 
 
 	void drawArrays(PrimitiveTopology topology, U32 count, U32 instanceCount = 1, U32 first = 0, U32 baseInstance = 0);
 	void drawArrays(PrimitiveTopology topology, U32 count, U32 instanceCount = 1, U32 first = 0, U32 baseInstance = 0);
 
 
@@ -399,22 +389,20 @@ public:
 
 
 	/// @name Sync
 	/// @name Sync
 	/// @{
 	/// @{
-	void setTextureBarrier(TexturePtr tex,
-		TextureUsageBit prevUsage,
-		TextureUsageBit nextUsage,
-		const TextureSubresourceInfo& subresource);
+	void setTextureBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+						   const TextureSubresourceInfo& subresource);
 
 
-	void setTextureSurfaceBarrier(
-		TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSurfaceInfo& surf);
+	void setTextureSurfaceBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+								  const TextureSurfaceInfo& surf);
 
 
-	void setTextureVolumeBarrier(
-		TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureVolumeInfo& vol);
+	void setTextureVolumeBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+								 const TextureVolumeInfo& vol);
 
 
-	void setBufferBarrier(
-		BufferPtr buff, BufferUsageBit prevUsage, BufferUsageBit nextUsage, PtrSize offset, PtrSize size);
+	void setBufferBarrier(BufferPtr buff, BufferUsageBit prevUsage, BufferUsageBit nextUsage, PtrSize offset,
+						  PtrSize size);
 
 
-	void setAccelerationStructureBarrier(
-		AccelerationStructurePtr as, AccelerationStructureUsageBit prevUsage, AccelerationStructureUsageBit nextUsage);
+	void setAccelerationStructureBarrier(AccelerationStructurePtr as, AccelerationStructureUsageBit prevUsage,
+										 AccelerationStructureUsageBit nextUsage);
 	/// @}
 	/// @}
 
 
 	/// @name Other
 	/// @name Other

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

@@ -150,7 +150,7 @@ public:
 };
 };
 ANKI_END_PACKED_STRUCT
 ANKI_END_PACKED_STRUCT
 static_assert(sizeof(GpuDeviceCapabilities) == sizeof(PtrSize) * 4 + sizeof(U32) * 3 + sizeof(U8) * 3 + sizeof(Bool),
 static_assert(sizeof(GpuDeviceCapabilities) == sizeof(PtrSize) * 4 + sizeof(U32) * 3 + sizeof(U8) * 3 + sizeof(Bool),
-	"Should be packed");
+			  "Should be packed");
 
 
 /// Bindless related info.
 /// Bindless related info.
 class BindlessLimits
 class BindlessLimits

+ 65 - 82
src/anki/gr/RenderGraph.cpp

@@ -378,8 +378,9 @@ TexturePtr RenderGraph::getOrCreateRenderTarget(const TextureInitInfo& initInf,
 	return tex;
 	return tex;
 }
 }
 
 
-FramebufferPtr RenderGraph::getOrCreateFramebuffer(
-	const FramebufferDescription& fbDescr, const RenderTargetHandle* rtHandles, CString name, Bool& drawsToPresentable)
+FramebufferPtr RenderGraph::getOrCreateFramebuffer(const FramebufferDescription& fbDescr,
+												   const RenderTargetHandle* rtHandles, CString name,
+												   Bool& drawsToPresentable)
 {
 {
 	ANKI_ASSERT(rtHandles);
 	ANKI_ASSERT(rtHandles);
 	U64 hash = fbDescr.m_hash;
 	U64 hash = fbDescr.m_hash;
@@ -428,8 +429,8 @@ FramebufferPtr RenderGraph::getOrCreateFramebuffer(
 			outAtt.m_storeOperation = inAtt.m_storeOperation;
 			outAtt.m_storeOperation = inAtt.m_storeOperation;
 
 
 			// Create texture view
 			// Create texture view
-			TextureViewInitInfo viewInit(
-				m_ctx->m_rts[rtHandles[i].m_idx].m_texture, TextureSubresourceInfo(inAtt.m_surface), "RenderGraph");
+			TextureViewInitInfo viewInit(m_ctx->m_rts[rtHandles[i].m_idx].m_texture,
+										 TextureSubresourceInfo(inAtt.m_surface), "RenderGraph");
 			TextureViewPtr view = getManager().newTextureView(viewInit);
 			TextureViewPtr view = getManager().newTextureView(viewInit);
 
 
 			outAtt.m_textureView = view;
 			outAtt.m_textureView = view;
@@ -448,8 +449,7 @@ FramebufferPtr RenderGraph::getOrCreateFramebuffer(
 
 
 			// Create texture view
 			// Create texture view
 			TextureViewInitInfo viewInit(m_ctx->m_rts[rtHandles[MAX_COLOR_ATTACHMENTS].m_idx].m_texture,
 			TextureViewInitInfo viewInit(m_ctx->m_rts[rtHandles[MAX_COLOR_ATTACHMENTS].m_idx].m_texture,
-				TextureSubresourceInfo(inAtt.m_surface, inAtt.m_aspect),
-				"RenderGraph");
+										 TextureSubresourceInfo(inAtt.m_surface, inAtt.m_aspect), "RenderGraph");
 			TextureViewPtr view = getManager().newTextureView(viewInit);
 			TextureViewPtr view = getManager().newTextureView(viewInit);
 
 
 			outAtt.m_textureView = view;
 			outAtt.m_textureView = view;
@@ -718,8 +718,8 @@ void RenderGraph::initRenderPassesAndSetDeps(const RenderGraphDescription& descr
 			if(graphicsPass.hasFramebuffer())
 			if(graphicsPass.hasFramebuffer())
 			{
 			{
 				Bool drawsToPresentable;
 				Bool drawsToPresentable;
-				outPass.fb() = getOrCreateFramebuffer(
-					graphicsPass.m_fbDescr, &graphicsPass.m_rtHandles[0], inPass.m_name.cstr(), drawsToPresentable);
+				outPass.fb() = getOrCreateFramebuffer(graphicsPass.m_fbDescr, &graphicsPass.m_rtHandles[0],
+													  inPass.m_name.cstr(), drawsToPresentable);
 
 
 				outPass.m_fbRenderArea = graphicsPass.m_fbRenderArea;
 				outPass.m_fbRenderArea = graphicsPass.m_fbRenderArea;
 				outPass.m_drawsToPresentable = drawsToPresentable;
 				outPass.m_drawsToPresentable = drawsToPresentable;
@@ -837,10 +837,8 @@ void RenderGraph::initGraphicsPasses(const RenderGraphDescription& descr, StackA
 				TextureUsageBit usage;
 				TextureUsageBit usage;
 				for(U i = 0; i < graphicsPass.m_fbDescr.m_colorAttachmentCount; ++i)
 				for(U i = 0; i < graphicsPass.m_fbDescr.m_colorAttachmentCount; ++i)
 				{
 				{
-					getCrntUsage(graphicsPass.m_rtHandles[i],
-						outPass.m_batchIdx,
-						TextureSubresourceInfo(graphicsPass.m_fbDescr.m_colorAttachments[i].m_surface),
-						usage);
+					getCrntUsage(graphicsPass.m_rtHandles[i], outPass.m_batchIdx,
+								 TextureSubresourceInfo(graphicsPass.m_fbDescr.m_colorAttachments[i].m_surface), usage);
 
 
 					outPass.m_colorUsages[i] = usage;
 					outPass.m_colorUsages[i] = usage;
 				}
 				}
@@ -849,10 +847,10 @@ void RenderGraph::initGraphicsPasses(const RenderGraphDescription& descr, StackA
 				{
 				{
 					TextureSubresourceInfo subresource =
 					TextureSubresourceInfo subresource =
 						TextureSubresourceInfo(graphicsPass.m_fbDescr.m_depthStencilAttachment.m_surface,
 						TextureSubresourceInfo(graphicsPass.m_fbDescr.m_depthStencilAttachment.m_surface,
-							graphicsPass.m_fbDescr.m_depthStencilAttachment.m_aspect);
+											   graphicsPass.m_fbDescr.m_depthStencilAttachment.m_aspect);
 
 
-					getCrntUsage(
-						graphicsPass.m_rtHandles[MAX_COLOR_ATTACHMENTS], outPass.m_batchIdx, subresource, usage);
+					getCrntUsage(graphicsPass.m_rtHandles[MAX_COLOR_ATTACHMENTS], outPass.m_batchIdx, subresource,
+								 usage);
 
 
 					outPass.m_dsUsage = usage;
 					outPass.m_dsUsage = usage;
 				}
 				}
@@ -1019,36 +1017,35 @@ void RenderGraph::setBatchBarriers(const RenderGraphDescription& descr)
 
 
 #if ANKI_DBG_RENDER_GRAPH
 #if ANKI_DBG_RENDER_GRAPH
 		// Sort the barriers to ease the dumped graph
 		// Sort the barriers to ease the dumped graph
-		std::sort(batch.m_barriersBefore.getBegin(),
-			batch.m_barriersBefore.getEnd(),
-			[&](const Barrier& a, const Barrier& b) {
-				const U aidx = (a.m_isTexture) ? a.m_texture.m_idx : a.m_buffer.m_idx;
-				const U bidx = (b.m_isTexture) ? b.m_texture.m_idx : b.m_buffer.m_idx;
-
-				if(aidx == bidx && a.m_isTexture && b.m_isTexture)
-				{
-					if(a.m_texture.m_surface.m_level != b.m_texture.m_surface.m_level)
-					{
-						return a.m_texture.m_surface.m_level < b.m_texture.m_surface.m_level;
-					}
-					else if(a.m_texture.m_surface.m_face != b.m_texture.m_surface.m_face)
-					{
-						return a.m_texture.m_surface.m_face < b.m_texture.m_surface.m_face;
-					}
-					else if(a.m_texture.m_surface.m_layer != b.m_texture.m_surface.m_layer)
-					{
-						return a.m_texture.m_surface.m_layer < b.m_texture.m_surface.m_layer;
-					}
-					else
-					{
-						return false;
-					}
-				}
-				else
-				{
-					return aidx < bidx;
-				}
-			});
+		std::sort(batch.m_barriersBefore.getBegin(), batch.m_barriersBefore.getEnd(),
+				  [&](const Barrier& a, const Barrier& b) {
+					  const U aidx = (a.m_isTexture) ? a.m_texture.m_idx : a.m_buffer.m_idx;
+					  const U bidx = (b.m_isTexture) ? b.m_texture.m_idx : b.m_buffer.m_idx;
+
+					  if(aidx == bidx && a.m_isTexture && b.m_isTexture)
+					  {
+						  if(a.m_texture.m_surface.m_level != b.m_texture.m_surface.m_level)
+						  {
+							  return a.m_texture.m_surface.m_level < b.m_texture.m_surface.m_level;
+						  }
+						  else if(a.m_texture.m_surface.m_face != b.m_texture.m_surface.m_face)
+						  {
+							  return a.m_texture.m_surface.m_face < b.m_texture.m_surface.m_face;
+						  }
+						  else if(a.m_texture.m_surface.m_layer != b.m_texture.m_surface.m_layer)
+						  {
+							  return a.m_texture.m_surface.m_layer < b.m_texture.m_surface.m_layer;
+						  }
+						  else
+						  {
+							  return false;
+						  }
+					  }
+					  else
+					  {
+						  return aidx < bidx;
+					  }
+				  });
 #endif
 #endif
 	} // For all batches
 	} // For all batches
 }
 }
@@ -1149,17 +1146,13 @@ void RenderGraph::run() const
 			if(barrier.m_isTexture)
 			if(barrier.m_isTexture)
 			{
 			{
 				cmdb->setTextureSurfaceBarrier(m_ctx->m_rts[barrier.m_texture.m_idx].m_texture,
 				cmdb->setTextureSurfaceBarrier(m_ctx->m_rts[barrier.m_texture.m_idx].m_texture,
-					barrier.m_texture.m_usageBefore,
-					barrier.m_texture.m_usageAfter,
-					barrier.m_texture.m_surface);
+											   barrier.m_texture.m_usageBefore, barrier.m_texture.m_usageAfter,
+											   barrier.m_texture.m_surface);
 			}
 			}
 			else
 			else
 			{
 			{
 				cmdb->setBufferBarrier(m_ctx->m_buffers[barrier.m_buffer.m_idx].m_buffer,
 				cmdb->setBufferBarrier(m_ctx->m_buffers[barrier.m_buffer.m_idx].m_buffer,
-					barrier.m_buffer.m_usageBefore,
-					barrier.m_buffer.m_usageAfter,
-					0,
-					MAX_PTR_SIZE);
+									   barrier.m_buffer.m_usageBefore, barrier.m_buffer.m_usageAfter, 0, MAX_PTR_SIZE);
 			}
 			}
 		}
 		}
 
 
@@ -1170,13 +1163,8 @@ void RenderGraph::run() const
 
 
 			if(pass.fb().isCreated())
 			if(pass.fb().isCreated())
 			{
 			{
-				cmdb->beginRenderPass(pass.fb(),
-					pass.m_colorUsages,
-					pass.m_dsUsage,
-					pass.m_fbRenderArea[0],
-					pass.m_fbRenderArea[1],
-					pass.m_fbRenderArea[2],
-					pass.m_fbRenderArea[3]);
+				cmdb->beginRenderPass(pass.fb(), pass.m_colorUsages, pass.m_dsUsage, pass.m_fbRenderArea[0],
+									  pass.m_fbRenderArea[1], pass.m_fbRenderArea[2], pass.m_fbRenderArea[3]);
 			}
 			}
 
 
 			const U size = pass.m_secondLevelCmdbs.getSize();
 			const U size = pass.m_secondLevelCmdbs.getSize();
@@ -1227,8 +1215,8 @@ void RenderGraph::flush()
 	}
 	}
 }
 }
 
 
-void RenderGraph::getCrntUsage(
-	RenderTargetHandle handle, U32 batchIdx, const TextureSubresourceInfo& subresource, TextureUsageBit& usage) const
+void RenderGraph::getCrntUsage(RenderTargetHandle handle, U32 batchIdx, const TextureSubresourceInfo& subresource,
+							   TextureUsageBit& usage) const
 {
 {
 	usage = TextureUsageBit::NONE;
 	usage = TextureUsageBit::NONE;
 	const Batch& batch = m_ctx->m_batches[batchIdx];
 	const Batch& batch = m_ctx->m_batches[batchIdx];
@@ -1400,8 +1388,8 @@ StringAuto RenderGraph::bufferUsageToStr(StackAllocator<U8>& alloc, BufferUsageB
 	return str;
 	return str;
 }
 }
 
 
-Error RenderGraph::dumpDependencyDotFile(
-	const RenderGraphDescription& descr, const BakeContext& ctx, CString path) const
+Error RenderGraph::dumpDependencyDotFile(const RenderGraphDescription& descr, const BakeContext& ctx,
+										 CString path) const
 {
 {
 	ANKI_GR_LOGW("Running with debug code");
 	ANKI_GR_LOGW("Running with debug code");
 
 
@@ -1427,9 +1415,8 @@ Error RenderGraph::dumpDependencyDotFile(
 		{
 		{
 			CString passName = descr.m_passes[passIdx]->m_name.toCString();
 			CString passName = descr.m_passes[passIdx]->m_name.toCString();
 
 
-			slist.pushBackSprintf("\t\"%s\"[color=%s,style=%s,shape=box];\n",
-				passName.cstr(),
-				COLORS[batchIdx % COLORS.getSize()],
+			slist.pushBackSprintf(
+				"\t\"%s\"[color=%s,style=%s,shape=box];\n", passName.cstr(), COLORS[batchIdx % COLORS.getSize()],
 				(descr.m_passes[passIdx]->m_type == RenderPassDescriptionBase::Type::GRAPHICS) ? "bold" : "dashed");
 				(descr.m_passes[passIdx]->m_type == RenderPassDescriptionBase::Type::GRAPHICS) ? "bold" : "dashed");
 
 
 			for(U32 depIdx : ctx.m_passes[passIdx].m_dependsOn)
 			for(U32 depIdx : ctx.m_passes[passIdx].m_dependsOn)
@@ -1474,30 +1461,26 @@ Error RenderGraph::dumpDependencyDotFile(
 			if(barrier.m_isTexture)
 			if(barrier.m_isTexture)
 			{
 			{
 				barrierLabel.sprintf("<b>%s</b> (mip,dp,f,l)=(%u,%u,%u,%u)<br/>%s <b>to</b> %s",
 				barrierLabel.sprintf("<b>%s</b> (mip,dp,f,l)=(%u,%u,%u,%u)<br/>%s <b>to</b> %s",
-					&descr.m_renderTargets[barrier.m_texture.m_idx].m_name[0],
-					barrier.m_texture.m_surface.m_level,
-					barrier.m_texture.m_surface.m_depth,
-					barrier.m_texture.m_surface.m_face,
-					barrier.m_texture.m_surface.m_layer,
-					textureUsageToStr(alloc, barrier.m_texture.m_usageBefore).cstr(),
-					textureUsageToStr(alloc, barrier.m_texture.m_usageAfter).cstr());
+									 &descr.m_renderTargets[barrier.m_texture.m_idx].m_name[0],
+									 barrier.m_texture.m_surface.m_level, barrier.m_texture.m_surface.m_depth,
+									 barrier.m_texture.m_surface.m_face, barrier.m_texture.m_surface.m_layer,
+									 textureUsageToStr(alloc, barrier.m_texture.m_usageBefore).cstr(),
+									 textureUsageToStr(alloc, barrier.m_texture.m_usageAfter).cstr());
 
 
 				barrierName.sprintf("%s barrier%u", batchName.cstr(), barrierIdx);
 				barrierName.sprintf("%s barrier%u", batchName.cstr(), barrierIdx);
 			}
 			}
 			else
 			else
 			{
 			{
 				barrierLabel.sprintf("<b>%s</b><br/>%s <b>to</b> %s",
 				barrierLabel.sprintf("<b>%s</b><br/>%s <b>to</b> %s",
-					&descr.m_buffers[barrier.m_buffer.m_idx].m_name[0],
-					bufferUsageToStr(alloc, barrier.m_buffer.m_usageBefore).cstr(),
-					bufferUsageToStr(alloc, barrier.m_buffer.m_usageAfter).cstr());
+									 &descr.m_buffers[barrier.m_buffer.m_idx].m_name[0],
+									 bufferUsageToStr(alloc, barrier.m_buffer.m_usageBefore).cstr(),
+									 bufferUsageToStr(alloc, barrier.m_buffer.m_usageAfter).cstr());
 
 
 				barrierName.sprintf("%s barrier%u", batchName.cstr(), barrierIdx);
 				barrierName.sprintf("%s barrier%u", batchName.cstr(), barrierIdx);
 			}
 			}
 
 
-			slist.pushBackSprintf("\t\"%s\"[color=%s,style=bold,shape=box,label=< %s >];\n",
-				barrierName.cstr(),
-				COLORS[batchIdx % COLORS.getSize()],
-				barrierLabel.cstr());
+			slist.pushBackSprintf("\t\"%s\"[color=%s,style=bold,shape=box,label=< %s >];\n", barrierName.cstr(),
+								  COLORS[batchIdx % COLORS.getSize()], barrierLabel.cstr());
 			slist.pushBackSprintf("\t\"%s\"->\"%s\";\n", prevBubble.cstr(), barrierName.cstr());
 			slist.pushBackSprintf("\t\"%s\"->\"%s\";\n", prevBubble.cstr(), barrierName.cstr());
 
 
 			prevBubble = barrierName;
 			prevBubble = barrierName;
@@ -1508,8 +1491,8 @@ Error RenderGraph::dumpDependencyDotFile(
 			const RenderPassDescriptionBase& pass = *descr.m_passes[passIdx];
 			const RenderPassDescriptionBase& pass = *descr.m_passes[passIdx];
 			StringAuto passName(alloc);
 			StringAuto passName(alloc);
 			passName.sprintf("%s pass", pass.m_name.cstr());
 			passName.sprintf("%s pass", pass.m_name.cstr());
-			slist.pushBackSprintf(
-				"\t\"%s\"[color=%s,style=bold];\n", passName.cstr(), COLORS[batchIdx % COLORS.getSize()]);
+			slist.pushBackSprintf("\t\"%s\"[color=%s,style=bold];\n", passName.cstr(),
+								  COLORS[batchIdx % COLORS.getSize()]);
 			slist.pushBackSprintf("\t\"%s\"->\"%s\";\n", prevBubble.cstr(), passName.cstr());
 			slist.pushBackSprintf("\t\"%s\"->\"%s\";\n", prevBubble.cstr(), passName.cstr());
 
 
 			prevBubble = passName;
 			prevBubble = passName;

+ 20 - 35
src/anki/gr/RenderGraph.h

@@ -137,17 +137,12 @@ public:
 
 
 	void getBufferState(RenderPassBufferHandle handle, BufferPtr& buff) const;
 	void getBufferState(RenderPassBufferHandle handle, BufferPtr& buff) const;
 
 
-	void getRenderTargetState(RenderTargetHandle handle,
-		const TextureSubresourceInfo& subresource,
-		TexturePtr& tex,
-		TextureUsageBit& usage) const;
+	void getRenderTargetState(RenderTargetHandle handle, const TextureSubresourceInfo& subresource, TexturePtr& tex,
+							  TextureUsageBit& usage) const;
 
 
 	/// Convenience method.
 	/// Convenience method.
-	void bindTextureAndSampler(U32 set,
-		U32 binding,
-		RenderTargetHandle handle,
-		const TextureSubresourceInfo& subresource,
-		const SamplerPtr& sampler)
+	void bindTextureAndSampler(U32 set, U32 binding, RenderTargetHandle handle,
+							   const TextureSubresourceInfo& subresource, const SamplerPtr& sampler)
 	{
 	{
 		TexturePtr tex;
 		TexturePtr tex;
 		TextureUsageBit usage;
 		TextureUsageBit usage;
@@ -191,8 +186,8 @@ public:
 	}
 	}
 
 
 	/// Convenience method.
 	/// Convenience method.
-	void bindImage(
-		U32 set, U32 binding, RenderTargetHandle handle, const TextureSubresourceInfo& subresource, U32 arrayIdx = 0)
+	void bindImage(U32 set, U32 binding, RenderTargetHandle handle, const TextureSubresourceInfo& subresource,
+				   U32 arrayIdx = 0)
 	{
 	{
 		TexturePtr tex;
 		TexturePtr tex;
 		TextureUsageBit usage;
 		TextureUsageBit usage;
@@ -245,8 +240,8 @@ public:
 	}
 	}
 
 
 	/// Dependency to the whole texture.
 	/// Dependency to the whole texture.
-	RenderPassDependency(
-		RenderTargetHandle handle, TextureUsageBit usage, DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE)
+	RenderPassDependency(RenderTargetHandle handle, TextureUsageBit usage,
+						 DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE)
 		: m_texture({handle, usage, TextureSubresourceInfo()})
 		: m_texture({handle, usage, TextureSubresourceInfo()})
 		, m_isTexture(true)
 		, m_isTexture(true)
 	{
 	{
@@ -404,20 +399,14 @@ class GraphicsRenderPassDescription : public RenderPassDescriptionBase
 
 
 public:
 public:
 	void setFramebufferInfo(const FramebufferDescription& fbInfo,
 	void setFramebufferInfo(const FramebufferDescription& fbInfo,
-		ConstWeakArray<RenderTargetHandle> colorRenderTargetHandles,
-		RenderTargetHandle depthStencilRenderTargetHandle,
-		U32 minx = 0,
-		U32 miny = 0,
-		U32 maxx = MAX_U32,
-		U32 maxy = MAX_U32);
+							ConstWeakArray<RenderTargetHandle> colorRenderTargetHandles,
+							RenderTargetHandle depthStencilRenderTargetHandle, U32 minx = 0, U32 miny = 0,
+							U32 maxx = MAX_U32, U32 maxy = MAX_U32);
 
 
 	void setFramebufferInfo(const FramebufferDescription& fbInfo,
 	void setFramebufferInfo(const FramebufferDescription& fbInfo,
-		std::initializer_list<RenderTargetHandle> colorRenderTargetHandles,
-		RenderTargetHandle depthStencilRenderTargetHandle,
-		U32 minx = 0,
-		U32 miny = 0,
-		U32 maxx = MAX_U32,
-		U32 maxy = MAX_U32);
+							std::initializer_list<RenderTargetHandle> colorRenderTargetHandles,
+							RenderTargetHandle depthStencilRenderTargetHandle, U32 minx = 0, U32 miny = 0,
+							U32 maxx = MAX_U32, U32 maxy = MAX_U32);
 
 
 private:
 private:
 	Array<RenderTargetHandle, MAX_COLOR_ATTACHMENTS + 1> m_rtHandles;
 	Array<RenderTargetHandle, MAX_COLOR_ATTACHMENTS + 1> m_rtHandles;
@@ -648,10 +637,8 @@ private:
 	void setBatchBarriers(const RenderGraphDescription& descr);
 	void setBatchBarriers(const RenderGraphDescription& descr);
 
 
 	TexturePtr getOrCreateRenderTarget(const TextureInitInfo& initInf, U64 hash);
 	TexturePtr getOrCreateRenderTarget(const TextureInitInfo& initInf, U64 hash);
-	FramebufferPtr getOrCreateFramebuffer(const FramebufferDescription& fbDescr,
-		const RenderTargetHandle* rtHandles,
-		CString name,
-		Bool& drawsToPresentableTex);
+	FramebufferPtr getOrCreateFramebuffer(const FramebufferDescription& fbDescr, const RenderTargetHandle* rtHandles,
+										  CString name, Bool& drawsToPresentableTex);
 
 
 	/// Every N number of frames clean unused cached items.
 	/// Every N number of frames clean unused cached items.
 	void periodicCleanup();
 	void periodicCleanup();
@@ -667,15 +654,13 @@ private:
 	template<typename TFunc>
 	template<typename TFunc>
 	static void iterateSurfsOrVolumes(const TexturePtr& tex, const TextureSubresourceInfo& subresource, TFunc func);
 	static void iterateSurfsOrVolumes(const TexturePtr& tex, const TextureSubresourceInfo& subresource, TFunc func);
 
 
-	void getCrntUsage(RenderTargetHandle handle,
-		U32 batchIdx,
-		const TextureSubresourceInfo& subresource,
-		TextureUsageBit& usage) const;
+	void getCrntUsage(RenderTargetHandle handle, U32 batchIdx, const TextureSubresourceInfo& subresource,
+					  TextureUsageBit& usage) const;
 
 
 	/// @name Dump the dependency graph into a file.
 	/// @name Dump the dependency graph into a file.
 	/// @{
 	/// @{
-	ANKI_USE_RESULT Error dumpDependencyDotFile(
-		const RenderGraphDescription& descr, const BakeContext& ctx, CString path) const;
+	ANKI_USE_RESULT Error dumpDependencyDotFile(const RenderGraphDescription& descr, const BakeContext& ctx,
+												CString path) const;
 	static StringAuto textureUsageToStr(StackAllocator<U8>& alloc, TextureUsageBit usage);
 	static StringAuto textureUsageToStr(StackAllocator<U8>& alloc, TextureUsageBit usage);
 	static StringAuto bufferUsageToStr(StackAllocator<U8>& alloc, BufferUsageBit usage);
 	static StringAuto bufferUsageToStr(StackAllocator<U8>& alloc, BufferUsageBit usage);
 	/// @}
 	/// @}

+ 11 - 23
src/anki/gr/RenderGraph.inl.h

@@ -13,8 +13,9 @@ inline void RenderPassWorkContext::getBufferState(RenderPassBufferHandle handle,
 	buff = m_rgraph->getBuffer(handle);
 	buff = m_rgraph->getBuffer(handle);
 }
 }
 
 
-inline void RenderPassWorkContext::getRenderTargetState(
-	RenderTargetHandle handle, const TextureSubresourceInfo& subresource, TexturePtr& tex, TextureUsageBit& usage) const
+inline void RenderPassWorkContext::getRenderTargetState(RenderTargetHandle handle,
+														const TextureSubresourceInfo& subresource, TexturePtr& tex,
+														TextureUsageBit& usage) const
 {
 {
 	m_rgraph->getCrntUsage(handle, m_batchIdx, subresource, usage);
 	m_rgraph->getCrntUsage(handle, m_batchIdx, subresource, usage);
 	tex = m_rgraph->getTexture(handle);
 	tex = m_rgraph->getTexture(handle);
@@ -128,13 +129,9 @@ inline void RenderPassDescriptionBase::newDependency(const RenderPassDependency&
 	}
 	}
 }
 }
 
 
-inline void GraphicsRenderPassDescription::setFramebufferInfo(const FramebufferDescription& fbInfo,
-	std::initializer_list<RenderTargetHandle> colorRenderTargetHandles,
-	RenderTargetHandle depthStencilRenderTargetHandle,
-	U32 minx,
-	U32 miny,
-	U32 maxx,
-	U32 maxy)
+inline void GraphicsRenderPassDescription::setFramebufferInfo(
+	const FramebufferDescription& fbInfo, std::initializer_list<RenderTargetHandle> colorRenderTargetHandles,
+	RenderTargetHandle depthStencilRenderTargetHandle, U32 minx, U32 miny, U32 maxx, U32 maxy)
 {
 {
 	Array<RenderTargetHandle, MAX_COLOR_ATTACHMENTS> rts;
 	Array<RenderTargetHandle, MAX_COLOR_ATTACHMENTS> rts;
 	U32 count = 0;
 	U32 count = 0;
@@ -142,22 +139,13 @@ inline void GraphicsRenderPassDescription::setFramebufferInfo(const FramebufferD
 	{
 	{
 		rts[count++] = h;
 		rts[count++] = h;
 	}
 	}
-	setFramebufferInfo(fbInfo,
-		ConstWeakArray<RenderTargetHandle>(&rts[0], count),
-		depthStencilRenderTargetHandle,
-		minx,
-		miny,
-		maxx,
-		maxy);
+	setFramebufferInfo(fbInfo, ConstWeakArray<RenderTargetHandle>(&rts[0], count), depthStencilRenderTargetHandle, minx,
+					   miny, maxx, maxy);
 }
 }
 
 
-inline void GraphicsRenderPassDescription::setFramebufferInfo(const FramebufferDescription& fbInfo,
-	ConstWeakArray<RenderTargetHandle> colorRenderTargetHandles,
-	RenderTargetHandle depthStencilRenderTargetHandle,
-	U32 minx,
-	U32 miny,
-	U32 maxx,
-	U32 maxy)
+inline void GraphicsRenderPassDescription::setFramebufferInfo(
+	const FramebufferDescription& fbInfo, ConstWeakArray<RenderTargetHandle> colorRenderTargetHandles,
+	RenderTargetHandle depthStencilRenderTargetHandle, U32 minx, U32 miny, U32 maxx, U32 maxy)
 {
 {
 #if ANKI_ENABLE_ASSERTS
 #if ANKI_ENABLE_ASSERTS
 	ANKI_ASSERT(fbInfo.isBacked() && "Forgot call GraphicsRenderPassFramebufferInfo::bake");
 	ANKI_ASSERT(fbInfo.isBacked() && "Forgot call GraphicsRenderPassFramebufferInfo::bake");

+ 2 - 4
src/anki/gr/TextureView.h

@@ -40,10 +40,8 @@ public:
 	{
 	{
 	}
 	}
 
 
-	TextureViewInitInfo(TexturePtr tex,
-		const TextureSurfaceInfo& surf,
-		DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE,
-		CString name = {})
+	TextureViewInitInfo(TexturePtr tex, const TextureSurfaceInfo& surf,
+						DepthStencilAspectBit aspect = DepthStencilAspectBit::NONE, CString name = {})
 		: GrBaseInitInfo(name)
 		: GrBaseInitInfo(name)
 		, m_texture(tex)
 		, m_texture(tex)
 	{
 	{

+ 55 - 74
src/anki/gr/gl/CommandBuffer.cpp

@@ -51,8 +51,8 @@ void CommandBuffer::flush(FencePtr* fence)
 	}
 	}
 }
 }
 
 
-void CommandBuffer::bindVertexBuffer(
-	U32 binding, BufferPtr buff, PtrSize offset, PtrSize stride, VertexStepRate stepRate)
+void CommandBuffer::bindVertexBuffer(U32 binding, BufferPtr buff, PtrSize offset, PtrSize stride,
+									 VertexStepRate stepRate)
 {
 {
 	class Cmd final : public GlCommand
 	class Cmd final : public GlCommand
 	{
 	{
@@ -240,7 +240,7 @@ void CommandBuffer::setScissor(U32 minx, U32 miny, U32 width, U32 height)
 		Error operator()(GlState& state)
 		Error operator()(GlState& state)
 		{
 		{
 			if(state.m_scissor[0] != m_value[0] || state.m_scissor[1] != m_value[1] || state.m_scissor[2] != m_value[2]
 			if(state.m_scissor[0] != m_value[0] || state.m_scissor[1] != m_value[1] || state.m_scissor[2] != m_value[2]
-				|| state.m_scissor[3] != m_value[3])
+			   || state.m_scissor[3] != m_value[3])
 			{
 			{
 				state.m_scissor = m_value;
 				state.m_scissor = m_value;
 				glScissor(m_value[0], m_value[1], m_value[2], m_value[3]);
 				glScissor(m_value[0], m_value[1], m_value[2], m_value[3]);
@@ -351,10 +351,8 @@ void CommandBuffer::setPolygonOffset(F32 factor, F32 units)
 	}
 	}
 }
 }
 
 
-void CommandBuffer::setStencilOperations(FaceSelectionBit face,
-	StencilOperation stencilFail,
-	StencilOperation stencilPassDepthFail,
-	StencilOperation stencilPassDepthPass)
+void CommandBuffer::setStencilOperations(FaceSelectionBit face, StencilOperation stencilFail,
+										 StencilOperation stencilPassDepthFail, StencilOperation stencilPassDepthPass)
 {
 {
 	class Cmd final : public GlCommand
 	class Cmd final : public GlCommand
 	{
 	{
@@ -382,10 +380,9 @@ void CommandBuffer::setStencilOperations(FaceSelectionBit face,
 	ANKI_GL_SELF(CommandBufferImpl);
 	ANKI_GL_SELF(CommandBufferImpl);
 	if(self.m_state.setStencilOperations(face, stencilFail, stencilPassDepthFail, stencilPassDepthPass))
 	if(self.m_state.setStencilOperations(face, stencilFail, stencilPassDepthFail, stencilPassDepthPass))
 	{
 	{
-		self.pushBackNewCommand<Cmd>(convertFaceMode(face),
-			convertStencilOperation(stencilFail),
-			convertStencilOperation(stencilPassDepthFail),
-			convertStencilOperation(stencilPassDepthPass));
+		self.pushBackNewCommand<Cmd>(convertFaceMode(face), convertStencilOperation(stencilFail),
+									 convertStencilOperation(stencilPassDepthFail),
+									 convertStencilOperation(stencilPassDepthPass));
 	}
 	}
 }
 }
 
 
@@ -544,8 +541,8 @@ void CommandBuffer::setColorChannelWriteMask(U32 attachment, ColorBit mask)
 	}
 	}
 }
 }
 
 
-void CommandBuffer::setBlendFactors(
-	U32 attachment, BlendFactor srcRgb, BlendFactor dstRgb, BlendFactor srcA, BlendFactor dstA)
+void CommandBuffer::setBlendFactors(U32 attachment, BlendFactor srcRgb, BlendFactor dstRgb, BlendFactor srcA,
+									BlendFactor dstA)
 {
 {
 	class Cmd final : public GlCommand
 	class Cmd final : public GlCommand
 	{
 	{
@@ -575,11 +572,8 @@ void CommandBuffer::setBlendFactors(
 	ANKI_GL_SELF(CommandBufferImpl);
 	ANKI_GL_SELF(CommandBufferImpl);
 	if(self.m_state.setBlendFactors(attachment, srcRgb, dstRgb, srcA, dstA))
 	if(self.m_state.setBlendFactors(attachment, srcRgb, dstRgb, srcA, dstA))
 	{
 	{
-		self.pushBackNewCommand<Cmd>(attachment,
-			convertBlendFactor(srcRgb),
-			convertBlendFactor(dstRgb),
-			convertBlendFactor(srcA),
-			convertBlendFactor(dstA));
+		self.pushBackNewCommand<Cmd>(attachment, convertBlendFactor(srcRgb), convertBlendFactor(dstRgb),
+									 convertBlendFactor(srcA), convertBlendFactor(dstA));
 	}
 	}
 }
 }
 
 
@@ -613,8 +607,8 @@ void CommandBuffer::setBlendOperation(U32 attachment, BlendOperation funcRgb, Bl
 	}
 	}
 }
 }
 
 
-void CommandBuffer::bindTextureAndSampler(
-	U32 set, U32 binding, TextureViewPtr texView, SamplerPtr sampler, TextureUsageBit usage)
+void CommandBuffer::bindTextureAndSampler(U32 set, U32 binding, TextureViewPtr texView, SamplerPtr sampler,
+										  TextureUsageBit usage)
 {
 {
 	class Cmd final : public GlCommand
 	class Cmd final : public GlCommand
 	{
 	{
@@ -739,13 +733,8 @@ void CommandBuffer::bindImage(U32 set, U32 binding, TextureViewPtr img)
 		{
 		{
 			const TextureViewImpl& view = static_cast<const TextureViewImpl&>(*m_img);
 			const TextureViewImpl& view = static_cast<const TextureViewImpl&>(*m_img);
 
 
-			glBindImageTexture(m_unit,
-				view.m_view.m_glName,
-				0,
-				GL_TRUE,
-				0,
-				GL_READ_WRITE,
-				static_cast<const TextureImpl&>(*view.m_tex).m_internalFormat);
+			glBindImageTexture(m_unit, view.m_view.m_glName, 0, GL_TRUE, 0, GL_READ_WRITE,
+							   static_cast<const TextureImpl&>(*view.m_tex).m_internalFormat);
 			return Error::NONE;
 			return Error::NONE;
 		}
 		}
 	};
 	};
@@ -844,12 +833,9 @@ void CommandBuffer::bindShaderProgram(ShaderProgramPtr prog)
 }
 }
 
 
 void CommandBuffer::beginRenderPass(FramebufferPtr fb,
 void CommandBuffer::beginRenderPass(FramebufferPtr fb,
-	const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
-	TextureUsageBit depthStencilAttachmentUsage,
-	U32 minx,
-	U32 miny,
-	U32 width,
-	U32 height)
+									const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
+									TextureUsageBit depthStencilAttachmentUsage, U32 minx, U32 miny, U32 width,
+									U32 height)
 {
 {
 	class BindFramebufferCommand final : public GlCommand
 	class BindFramebufferCommand final : public GlCommand
 	{
 	{
@@ -865,8 +851,8 @@ void CommandBuffer::beginRenderPass(FramebufferPtr fb,
 
 
 		Error operator()(GlState& state)
 		Error operator()(GlState& state)
 		{
 		{
-			static_cast<const FramebufferImpl&>(*m_fb).bind(
-				state, m_renderArea[0], m_renderArea[1], m_renderArea[2], m_renderArea[3]);
+			static_cast<const FramebufferImpl&>(*m_fb).bind(state, m_renderArea[0], m_renderArea[1], m_renderArea[2],
+															m_renderArea[3]);
 			return Error::NONE;
 			return Error::NONE;
 		}
 		}
 	};
 	};
@@ -903,8 +889,8 @@ void CommandBuffer::endRenderPass()
 	self.m_state.endRenderPass();
 	self.m_state.endRenderPass();
 }
 }
 
 
-void CommandBuffer::drawElements(
-	PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex, U32 baseVertex, U32 baseInstance)
+void CommandBuffer::drawElements(PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex,
+								 U32 baseVertex, U32 baseInstance)
 {
 {
 	class Cmd final : public GlCommand
 	class Cmd final : public GlCommand
 	{
 	{
@@ -922,13 +908,9 @@ void CommandBuffer::drawElements(
 
 
 		Error operator()(GlState&)
 		Error operator()(GlState&)
 		{
 		{
-			glDrawElementsInstancedBaseVertexBaseInstance(m_topology,
-				m_info.m_count,
-				m_indexType,
-				numberToPtr<void*>(m_info.m_firstIndex),
-				m_info.m_instanceCount,
-				m_info.m_baseVertex,
-				m_info.m_baseInstance);
+			glDrawElementsInstancedBaseVertexBaseInstance(
+				m_topology, m_info.m_count, m_indexType, numberToPtr<void*>(m_info.m_firstIndex),
+				m_info.m_instanceCount, m_info.m_baseVertex, m_info.m_baseInstance);
 
 
 			ANKI_TRACE_INC_COUNTER(GR_DRAWCALLS, 1);
 			ANKI_TRACE_INC_COUNTER(GR_DRAWCALLS, 1);
 			ANKI_TRACE_INC_COUNTER(GR_VERTICES, m_info.m_instanceCount * m_info.m_count);
 			ANKI_TRACE_INC_COUNTER(GR_VERTICES, m_info.m_instanceCount * m_info.m_count);
@@ -974,8 +956,8 @@ void CommandBuffer::drawArrays(PrimitiveTopology topology, U32 count, U32 instan
 
 
 		Error operator()(GlState& state)
 		Error operator()(GlState& state)
 		{
 		{
-			glDrawArraysInstancedBaseInstance(
-				m_topology, m_info.m_first, m_info.m_count, m_info.m_instanceCount, m_info.m_baseInstance);
+			glDrawArraysInstancedBaseInstance(m_topology, m_info.m_first, m_info.m_count, m_info.m_instanceCount,
+											  m_info.m_baseInstance);
 
 
 			ANKI_TRACE_INC_COUNTER(GR_DRAWCALLS, 1);
 			ANKI_TRACE_INC_COUNTER(GR_DRAWCALLS, 1);
 			ANKI_TRACE_INC_COUNTER(GR_VERTICES, m_info.m_instanceCount * m_info.m_count);
 			ANKI_TRACE_INC_COUNTER(GR_VERTICES, m_info.m_instanceCount * m_info.m_count);
@@ -992,8 +974,8 @@ void CommandBuffer::drawArrays(PrimitiveTopology topology, U32 count, U32 instan
 	self.pushBackNewCommand<DrawArraysCommand>(convertPrimitiveTopology(topology), info);
 	self.pushBackNewCommand<DrawArraysCommand>(convertPrimitiveTopology(topology), info);
 }
 }
 
 
-void CommandBuffer::drawElementsIndirect(
-	PrimitiveTopology topology, U32 drawCount, PtrSize offset, BufferPtr indirectBuff)
+void CommandBuffer::drawElementsIndirect(PrimitiveTopology topology, U32 drawCount, PtrSize offset,
+										 BufferPtr indirectBuff)
 {
 {
 	class DrawElementsIndirectCommand final : public GlCommand
 	class DrawElementsIndirectCommand final : public GlCommand
 	{
 	{
@@ -1023,8 +1005,8 @@ void CommandBuffer::drawElementsIndirect(
 
 
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buff.getGlName());
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buff.getGlName());
 
 
-			glMultiDrawElementsIndirect(
-				m_topology, m_indexType, numberToPtr<void*>(m_offset), m_drawCount, sizeof(DrawElementsIndirectInfo));
+			glMultiDrawElementsIndirect(m_topology, m_indexType, numberToPtr<void*>(m_offset), m_drawCount,
+										sizeof(DrawElementsIndirectInfo));
 
 
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
 			return Error::NONE;
 			return Error::NONE;
@@ -1039,8 +1021,8 @@ void CommandBuffer::drawElementsIndirect(
 		convertPrimitiveTopology(topology), self.m_state.m_idx.m_indexType, drawCount, offset, indirectBuff);
 		convertPrimitiveTopology(topology), self.m_state.m_idx.m_indexType, drawCount, offset, indirectBuff);
 }
 }
 
 
-void CommandBuffer::drawArraysIndirect(
-	PrimitiveTopology topology, U32 drawCount, PtrSize offset, BufferPtr indirectBuff)
+void CommandBuffer::drawArraysIndirect(PrimitiveTopology topology, U32 drawCount, PtrSize offset,
+									   BufferPtr indirectBuff)
 {
 {
 	class DrawArraysIndirectCommand final : public GlCommand
 	class DrawArraysIndirectCommand final : public GlCommand
 	{
 	{
@@ -1068,8 +1050,8 @@ void CommandBuffer::drawArraysIndirect(
 
 
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buff.getGlName());
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buff.getGlName());
 
 
-			glMultiDrawArraysIndirect(
-				m_topology, numberToPtr<void*>(m_offset), m_drawCount, sizeof(DrawArraysIndirectInfo));
+			glMultiDrawArraysIndirect(m_topology, numberToPtr<void*>(m_offset), m_drawCount,
+									  sizeof(DrawArraysIndirectInfo));
 
 
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
 			glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
 			return Error::NONE;
 			return Error::NONE;
@@ -1079,8 +1061,8 @@ void CommandBuffer::drawArraysIndirect(
 	ANKI_GL_SELF(CommandBufferImpl);
 	ANKI_GL_SELF(CommandBufferImpl);
 	self.m_state.checkNonIndexedDrawcall();
 	self.m_state.checkNonIndexedDrawcall();
 	self.flushDrawcall(*this);
 	self.flushDrawcall(*this);
-	self.pushBackNewCommand<DrawArraysIndirectCommand>(
-		convertPrimitiveTopology(topology), drawCount, offset, indirectBuff);
+	self.pushBackNewCommand<DrawArraysIndirectCommand>(convertPrimitiveTopology(topology), drawCount, offset,
+													   indirectBuff);
 }
 }
 
 
 void CommandBuffer::dispatchCompute(U32 groupCountX, U32 groupCountY, U32 groupCountZ)
 void CommandBuffer::dispatchCompute(U32 groupCountX, U32 groupCountY, U32 groupCountZ)
@@ -1183,8 +1165,8 @@ void CommandBuffer::copyBufferToTextureView(BufferPtr buff, PtrSize offset, PtrS
 			const TextureViewImpl& viewImpl = static_cast<TextureViewImpl&>(*m_texView);
 			const TextureViewImpl& viewImpl = static_cast<TextureViewImpl&>(*m_texView);
 			const TextureImpl& texImpl = static_cast<TextureImpl&>(*viewImpl.m_tex);
 			const TextureImpl& texImpl = static_cast<TextureImpl&>(*viewImpl.m_tex);
 
 
-			texImpl.copyFromBuffer(
-				viewImpl.getSubresource(), static_cast<const BufferImpl&>(*m_buff).getGlName(), m_offset, m_range);
+			texImpl.copyFromBuffer(viewImpl.getSubresource(), static_cast<const BufferImpl&>(*m_buff).getGlName(),
+								   m_offset, m_range);
 			return Error::NONE;
 			return Error::NONE;
 		}
 		}
 	};
 	};
@@ -1198,8 +1180,8 @@ void CommandBuffer::copyBufferToTextureView(BufferPtr buff, PtrSize offset, PtrS
 	self.pushBackNewCommand<TexSurfUploadCommand>(buff, offset, range, texView);
 	self.pushBackNewCommand<TexSurfUploadCommand>(buff, offset, range, texView);
 }
 }
 
 
-void CommandBuffer::copyBufferToBuffer(
-	BufferPtr src, PtrSize srcOffset, BufferPtr dst, PtrSize dstOffset, PtrSize range)
+void CommandBuffer::copyBufferToBuffer(BufferPtr src, PtrSize srcOffset, BufferPtr dst, PtrSize dstOffset,
+									   PtrSize range)
 {
 {
 	class Cmd final : public GlCommand
 	class Cmd final : public GlCommand
 	{
 	{
@@ -1221,8 +1203,8 @@ void CommandBuffer::copyBufferToBuffer(
 
 
 		Error operator()(GlState& state)
 		Error operator()(GlState& state)
 		{
 		{
-			static_cast<BufferImpl&>(*m_dst).write(
-				static_cast<const BufferImpl&>(*m_src).getGlName(), m_srcOffset, m_dstOffset, m_range);
+			static_cast<BufferImpl&>(*m_dst).write(static_cast<const BufferImpl&>(*m_src).getGlName(), m_srcOffset,
+												   m_dstOffset, m_range);
 			return Error::NONE;
 			return Error::NONE;
 		}
 		}
 	};
 	};
@@ -1303,8 +1285,8 @@ void CommandBuffer::blitTextureViews(TextureViewPtr srcView, TextureViewPtr dest
 	ANKI_ASSERT(!"TODO");
 	ANKI_ASSERT(!"TODO");
 }
 }
 
 
-void CommandBuffer::setBufferBarrier(
-	BufferPtr buff, BufferUsageBit prevUsage, BufferUsageBit nextUsage, PtrSize offset, PtrSize size)
+void CommandBuffer::setBufferBarrier(BufferPtr buff, BufferUsageBit prevUsage, BufferUsageBit nextUsage, PtrSize offset,
+									 PtrSize size)
 {
 {
 	class SetBufferMemBarrierCommand final : public GlCommand
 	class SetBufferMemBarrierCommand final : public GlCommand
 	{
 	{
@@ -1352,7 +1334,7 @@ void CommandBuffer::setBufferBarrier(
 	}
 	}
 
 
 	if(!!(all
 	if(!!(all
-		   & (BufferUsageBit::FILL | BufferUsageBit::BUFFER_UPLOAD_SOURCE | BufferUsageBit::BUFFER_UPLOAD_DESTINATION)))
+		  & (BufferUsageBit::FILL | BufferUsageBit::BUFFER_UPLOAD_SOURCE | BufferUsageBit::BUFFER_UPLOAD_DESTINATION)))
 	{
 	{
 		d |= GL_BUFFER_UPDATE_BARRIER_BIT;
 		d |= GL_BUFFER_UPDATE_BARRIER_BIT;
 	}
 	}
@@ -1367,22 +1349,22 @@ void CommandBuffer::setBufferBarrier(
 	self.pushBackNewCommand<SetBufferMemBarrierCommand>(d);
 	self.pushBackNewCommand<SetBufferMemBarrierCommand>(d);
 }
 }
 
 
-void CommandBuffer::setTextureSurfaceBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSurfaceInfo& surf)
+void CommandBuffer::setTextureSurfaceBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+											 const TextureSurfaceInfo& surf)
 {
 {
 	TextureSubresourceInfo subresource;
 	TextureSubresourceInfo subresource;
 	setTextureBarrier(tex, prevUsage, nextUsage, subresource);
 	setTextureBarrier(tex, prevUsage, nextUsage, subresource);
 }
 }
 
 
-void CommandBuffer::setTextureVolumeBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureVolumeInfo& vol)
+void CommandBuffer::setTextureVolumeBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+											const TextureVolumeInfo& vol)
 {
 {
 	TextureSubresourceInfo subresource;
 	TextureSubresourceInfo subresource;
 	setTextureBarrier(tex, prevUsage, nextUsage, subresource);
 	setTextureBarrier(tex, prevUsage, nextUsage, subresource);
 }
 }
 
 
-void CommandBuffer::setTextureBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSubresourceInfo& subresource)
+void CommandBuffer::setTextureBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+									  const TextureSubresourceInfo& subresource)
 {
 {
 	class Cmd final : public GlCommand
 	class Cmd final : public GlCommand
 	{
 	{
@@ -1524,9 +1506,8 @@ void CommandBuffer::writeOcclusionQueryResultToBuffer(OcclusionQueryPtr query, P
 			ANKI_ASSERT(m_offset + 4 <= buff.getSize());
 			ANKI_ASSERT(m_offset + 4 <= buff.getSize());
 
 
 			glBindBuffer(GL_QUERY_BUFFER, buff.getGlName());
 			glBindBuffer(GL_QUERY_BUFFER, buff.getGlName());
-			glGetQueryObjectuiv(static_cast<const OcclusionQueryImpl&>(*m_query).getGlName(),
-				GL_QUERY_RESULT,
-				numberToPtr<GLuint*>(m_offset));
+			glGetQueryObjectuiv(static_cast<const OcclusionQueryImpl&>(*m_query).getGlName(), GL_QUERY_RESULT,
+								numberToPtr<GLuint*>(m_offset));
 			glBindBuffer(GL_QUERY_BUFFER, 0);
 			glBindBuffer(GL_QUERY_BUFFER, 0);
 
 
 			return Error::NONE;
 			return Error::NONE;

+ 4 - 6
src/anki/gr/gl/CommandBufferImpl.cpp

@@ -25,8 +25,8 @@ void CommandBufferImpl::init(const CommandBufferInitInfo& init)
 {
 {
 	auto& pool = getManager().getAllocator().getMemoryPool();
 	auto& pool = getManager().getAllocator().getMemoryPool();
 
 
-	m_alloc = CommandBufferAllocator<GlCommand*>(
-		pool.getAllocationCallback(), pool.getAllocationCallbackUserData(), init.m_hints.m_chunkSize, 1.0, 0, false);
+	m_alloc = CommandBufferAllocator<GlCommand*>(pool.getAllocationCallback(), pool.getAllocationCallbackUserData(),
+												 init.m_hints.m_chunkSize, 1.0, 0, false);
 
 
 	m_flags = init.m_flags;
 	m_flags = init.m_flags;
 
 
@@ -216,10 +216,8 @@ void CommandBufferImpl::flushDrawcall(CommandBuffer& cmdb)
 	{
 	{
 		if(m_state.m_glStencilFuncSeparateDirty[i])
 		if(m_state.m_glStencilFuncSeparateDirty[i])
 		{
 		{
-			pushBackNewCommand<StencilCmd>(GL_FRONT + i,
-				convertCompareOperation(m_state.m_stencilCompare[i]),
-				m_state.m_stencilRef[i],
-				m_state.m_stencilCompareMask[i]);
+			pushBackNewCommand<StencilCmd>(GL_FRONT + i, convertCompareOperation(m_state.m_stencilCompare[i]),
+										   m_state.m_stencilRef[i], m_state.m_stencilCompareMask[i]);
 
 
 			m_state.m_glStencilFuncSeparateDirty[i] = false;
 			m_state.m_glStencilFuncSeparateDirty[i] = false;
 		}
 		}

+ 2 - 2
src/anki/gr/gl/Common.cpp

@@ -271,8 +271,8 @@ GLenum convertBlendFactor(BlendFactor in)
 	return out;
 	return out;
 }
 }
 
 
-void convertTextureInformation(
-	Format pf, Bool& compressed, GLenum& format, GLenum& internalFormat, GLenum& type, DepthStencilAspectBit& dsAspect)
+void convertTextureInformation(Format pf, Bool& compressed, GLenum& format, GLenum& internalFormat, GLenum& type,
+							   DepthStencilAspectBit& dsAspect)
 {
 {
 	compressed = formatIsCompressed(pf);
 	compressed = formatIsCompressed(pf);
 	dsAspect = computeFormatAspect(pf);
 	dsAspect = computeFormatAspect(pf);

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

@@ -178,8 +178,8 @@ inline GLenum convertPrimitiveTopology(PrimitiveTopology ak)
 	return out;
 	return out;
 }
 }
 
 
-void convertTextureInformation(
-	Format pf, Bool& compressed, GLenum& format, GLenum& internalFormat, GLenum& type, DepthStencilAspectBit& dsAspect);
+void convertTextureInformation(Format pf, Bool& compressed, GLenum& format, GLenum& internalFormat, GLenum& type,
+							   DepthStencilAspectBit& dsAspect);
 /// @}
 /// @}
 
 
 } // end namespace anki
 } // end namespace anki

+ 1 - 1
src/anki/gr/gl/Error.cpp

@@ -48,4 +48,4 @@ void glConditionalCheckError(const char* file, int line, const char* func)
 	ANKI_GL_LOGF("GL error: %s (%s:%d %s)", errStr, file, line, func);
 	ANKI_GL_LOGF("GL error: %s (%s:%d %s)", errStr, file, line, func);
 }
 }
 
 
-} // end namespace
+} // namespace anki

+ 4 - 4
src/anki/gr/gl/Fence.cpp

@@ -83,8 +83,8 @@ Bool Fence::clientWait(Second seconds)
 	{
 	{
 		// Send a cmd that will update the fence's status in case someone calls clientWait with seconds==0.0 all the
 		// Send a cmd that will update the fence's status in case someone calls clientWait with seconds==0.0 all the
 		// time
 		// time
-		static_cast<CommandBufferImpl&>(*cmdb).pushBackNewCommand<CheckFenceCommand>(
-			FencePtr(this), seconds, 0.0, nullptr);
+		static_cast<CommandBufferImpl&>(*cmdb).pushBackNewCommand<CheckFenceCommand>(FencePtr(this), seconds, 0.0,
+																					 nullptr);
 		static_cast<CommandBufferImpl&>(*cmdb).flush();
 		static_cast<CommandBufferImpl&>(*cmdb).flush();
 
 
 		return false;
 		return false;
@@ -95,8 +95,8 @@ Bool Fence::clientWait(Second seconds)
 
 
 		Second flushTime = HighRezTimer::getCurrentTime();
 		Second flushTime = HighRezTimer::getCurrentTime();
 
 
-		static_cast<CommandBufferImpl&>(*cmdb).pushBackNewCommand<CheckFenceCommand>(
-			FencePtr(this), seconds, flushTime, &barrier);
+		static_cast<CommandBufferImpl&>(*cmdb).pushBackNewCommand<CheckFenceCommand>(FencePtr(this), seconds, flushTime,
+																					 &barrier);
 		static_cast<CommandBufferImpl&>(*cmdb).flush();
 		static_cast<CommandBufferImpl&>(*cmdb).flush();
 
 
 		barrier.wait();
 		barrier.wait();

+ 13 - 25
src/anki/gr/gl/FramebufferImpl.cpp

@@ -115,8 +115,8 @@ Error FramebufferImpl::init(const FramebufferInitInfo& init)
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-void FramebufferImpl::attachTextureInternal(
-	GLenum attachment, const TextureViewImpl& view, const FramebufferAttachmentInfo& info)
+void FramebufferImpl::attachTextureInternal(GLenum attachment, const TextureViewImpl& view,
+											const FramebufferAttachmentInfo& info)
 {
 {
 	const GLenum target = GL_FRAMEBUFFER;
 	const GLenum target = GL_FRAMEBUFFER;
 	const TextureImpl& tex = static_cast<const TextureImpl&>(*view.m_tex);
 	const TextureImpl& tex = static_cast<const TextureImpl&>(*view.m_tex);
@@ -130,28 +130,19 @@ void FramebufferImpl::attachTextureInternal(
 		glFramebufferTexture2D(target, attachment, tex.m_target, tex.getGlName(), view.getSubresource().m_firstMipmap);
 		glFramebufferTexture2D(target, attachment, tex.m_target, tex.getGlName(), view.getSubresource().m_firstMipmap);
 		break;
 		break;
 	case GL_TEXTURE_CUBE_MAP:
 	case GL_TEXTURE_CUBE_MAP:
-		glFramebufferTexture2D(target,
-			attachment,
-			GL_TEXTURE_CUBE_MAP_POSITIVE_X + view.getSubresource().m_firstFace,
-			tex.getGlName(),
-			view.getSubresource().m_firstMipmap);
+		glFramebufferTexture2D(target, attachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + view.getSubresource().m_firstFace,
+							   tex.getGlName(), view.getSubresource().m_firstMipmap);
 		break;
 		break;
 	case GL_TEXTURE_2D_ARRAY:
 	case GL_TEXTURE_2D_ARRAY:
-		glFramebufferTextureLayer(target,
-			attachment,
-			tex.getGlName(),
-			view.getSubresource().m_firstMipmap,
-			view.getSubresource().m_firstLayer);
+		glFramebufferTextureLayer(target, attachment, tex.getGlName(), view.getSubresource().m_firstMipmap,
+								  view.getSubresource().m_firstLayer);
 		break;
 		break;
 	case GL_TEXTURE_3D:
 	case GL_TEXTURE_3D:
 		ANKI_ASSERT(!"TODO");
 		ANKI_ASSERT(!"TODO");
 		break;
 		break;
 	case GL_TEXTURE_CUBE_MAP_ARRAY:
 	case GL_TEXTURE_CUBE_MAP_ARRAY:
-		glFramebufferTextureLayer(target,
-			attachment,
-			tex.getGlName(),
-			view.getSubresource().m_firstMipmap,
-			view.getSubresource().m_firstLayer * 6 + view.getSubresource().m_firstFace);
+		glFramebufferTextureLayer(target, attachment, tex.getGlName(), view.getSubresource().m_firstMipmap,
+								  view.getSubresource().m_firstLayer * 6 + view.getSubresource().m_firstFace);
 		break;
 		break;
 	default:
 	default:
 		ANKI_ASSERT(0);
 		ANKI_ASSERT(0);
@@ -188,8 +179,8 @@ void FramebufferImpl::bind(const GlState& state, U32 minx, U32 miny, U32 width,
 	// Invalidate
 	// Invalidate
 	if(m_invalidateBuffersCount)
 	if(m_invalidateBuffersCount)
 	{
 	{
-		glInvalidateSubFramebuffer(
-			GL_FRAMEBUFFER, m_invalidateBuffersCount, &m_invalidateBuffers[0], minx, miny, width, height);
+		glInvalidateSubFramebuffer(GL_FRAMEBUFFER, m_invalidateBuffersCount, &m_invalidateBuffers[0], minx, miny, width,
+								   height);
 	}
 	}
 
 
 	// Clear buffers
 	// Clear buffers
@@ -202,7 +193,7 @@ void FramebufferImpl::bind(const GlState& state, U32 minx, U32 miny, U32 width,
 			// Enable write mask in case a pipeline changed it (else no clear will happen) and then restore state
 			// Enable write mask in case a pipeline changed it (else no clear will happen) and then restore state
 			Bool restore = false;
 			Bool restore = false;
 			if(state.m_colorWriteMasks[i][0] != true || state.m_colorWriteMasks[i][1] != true
 			if(state.m_colorWriteMasks[i][0] != true || state.m_colorWriteMasks[i][1] != true
-				|| state.m_colorWriteMasks[i][2] != true || state.m_colorWriteMasks[i][3] != true)
+			   || state.m_colorWriteMasks[i][2] != true || state.m_colorWriteMasks[i][3] != true)
 			{
 			{
 				glColorMaski(i, true, true, true, true);
 				glColorMaski(i, true, true, true, true);
 				restore = true;
 				restore = true;
@@ -212,11 +203,8 @@ void FramebufferImpl::bind(const GlState& state, U32 minx, U32 miny, U32 width,
 
 
 			if(restore)
 			if(restore)
 			{
 			{
-				glColorMaski(i,
-					state.m_colorWriteMasks[i][0],
-					state.m_colorWriteMasks[i][1],
-					state.m_colorWriteMasks[i][2],
-					state.m_colorWriteMasks[i][3]);
+				glColorMaski(i, state.m_colorWriteMasks[i][0], state.m_colorWriteMasks[i][1],
+							 state.m_colorWriteMasks[i][2], state.m_colorWriteMasks[i][3]);
 			}
 			}
 		}
 		}
 	}
 	}

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

@@ -53,8 +53,8 @@ private:
 	Bool m_clearStencil = false;
 	Bool m_clearStencil = false;
 
 
 	/// Attach a texture
 	/// Attach a texture
-	static void attachTextureInternal(
-		GLenum attachment, const TextureViewImpl& view, const FramebufferAttachmentInfo& info);
+	static void attachTextureInternal(GLenum attachment, const TextureViewImpl& view,
+									  const FramebufferAttachmentInfo& info);
 
 
 	/// Create the FBO
 	/// Create the FBO
 	ANKI_USE_RESULT Error createFbo(const Array<U, MAX_COLOR_ATTACHMENTS + 1>& layers, GLenum depthStencilBindingPoint);
 	ANKI_USE_RESULT Error createFbo(const Array<U, MAX_COLOR_ATTACHMENTS + 1>& layers, GLenum depthStencilBindingPoint);

+ 16 - 21
src/anki/gr/gl/GlState.cpp

@@ -23,34 +23,29 @@ struct GlDbg
 };
 };
 
 
 static const GlDbg gldbgsource[] = {{GL_DEBUG_SOURCE_API, "GL_DEBUG_SOURCE_API"},
 static const GlDbg gldbgsource[] = {{GL_DEBUG_SOURCE_API, "GL_DEBUG_SOURCE_API"},
-	{GL_DEBUG_SOURCE_WINDOW_SYSTEM, "GL_DEBUG_SOURCE_WINDOW_SYSTEM"},
-	{GL_DEBUG_SOURCE_SHADER_COMPILER, "GL_DEBUG_SOURCE_SHADER_COMPILER"},
-	{GL_DEBUG_SOURCE_THIRD_PARTY, "GL_DEBUG_SOURCE_THIRD_PARTY"},
-	{GL_DEBUG_SOURCE_APPLICATION, "GL_DEBUG_SOURCE_APPLICATION"},
-	{GL_DEBUG_SOURCE_OTHER, "GL_DEBUG_SOURCE_OTHER"}};
+									{GL_DEBUG_SOURCE_WINDOW_SYSTEM, "GL_DEBUG_SOURCE_WINDOW_SYSTEM"},
+									{GL_DEBUG_SOURCE_SHADER_COMPILER, "GL_DEBUG_SOURCE_SHADER_COMPILER"},
+									{GL_DEBUG_SOURCE_THIRD_PARTY, "GL_DEBUG_SOURCE_THIRD_PARTY"},
+									{GL_DEBUG_SOURCE_APPLICATION, "GL_DEBUG_SOURCE_APPLICATION"},
+									{GL_DEBUG_SOURCE_OTHER, "GL_DEBUG_SOURCE_OTHER"}};
 
 
 static const GlDbg gldbgtype[] = {{GL_DEBUG_TYPE_ERROR, "GL_DEBUG_TYPE_ERROR"},
 static const GlDbg gldbgtype[] = {{GL_DEBUG_TYPE_ERROR, "GL_DEBUG_TYPE_ERROR"},
-	{GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR, "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"},
-	{GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"},
-	{GL_DEBUG_TYPE_PORTABILITY, "GL_DEBUG_TYPE_PORTABILITY"},
-	{GL_DEBUG_TYPE_PERFORMANCE, "GL_DEBUG_TYPE_PERFORMANCE"},
-	{GL_DEBUG_TYPE_OTHER, "GL_DEBUG_TYPE_OTHER"}};
+								  {GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR, "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"},
+								  {GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"},
+								  {GL_DEBUG_TYPE_PORTABILITY, "GL_DEBUG_TYPE_PORTABILITY"},
+								  {GL_DEBUG_TYPE_PERFORMANCE, "GL_DEBUG_TYPE_PERFORMANCE"},
+								  {GL_DEBUG_TYPE_OTHER, "GL_DEBUG_TYPE_OTHER"}};
 
 
 static const GlDbg gldbgseverity[] = {{GL_DEBUG_SEVERITY_LOW, "GL_DEBUG_SEVERITY_LOW"},
 static const GlDbg gldbgseverity[] = {{GL_DEBUG_SEVERITY_LOW, "GL_DEBUG_SEVERITY_LOW"},
-	{GL_DEBUG_SEVERITY_MEDIUM, "GL_DEBUG_SEVERITY_MEDIUM"},
-	{GL_DEBUG_SEVERITY_HIGH, "GL_DEBUG_SEVERITY_HIGH"}};
+									  {GL_DEBUG_SEVERITY_MEDIUM, "GL_DEBUG_SEVERITY_MEDIUM"},
+									  {GL_DEBUG_SEVERITY_HIGH, "GL_DEBUG_SEVERITY_HIGH"}};
 
 
 #	if ANKI_OS == ANKI_OS_WINDOWS && ANKI_COMPILER != ANKI_COMPILER_MSVC
 #	if ANKI_OS == ANKI_OS_WINDOWS && ANKI_COMPILER != ANKI_COMPILER_MSVC
 __stdcall
 __stdcall
 #	endif
 #	endif
 	void
 	void
-	oglMessagesCallback(GLenum source,
-		GLenum type,
-		GLuint id,
-		GLenum severity,
-		GLsizei length,
-		const char* message,
-		const GLvoid* userParam)
+	oglMessagesCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* message,
+						const GLvoid* userParam)
 {
 {
 	using namespace anki;
 	using namespace anki;
 
 
@@ -128,8 +123,8 @@ void GlState::initRenderThread()
 			{
 			{
 				for(U sv = 0; sv < sizeof(gldbgseverity) / sizeof(GlDbg); sv++)
 				for(U sv = 0; sv < sizeof(gldbgseverity) / sizeof(GlDbg); sv++)
 				{
 				{
-					glDebugMessageControl(
-						gldbgsource[s].token, gldbgtype[t].token, gldbgseverity[sv].token, 0, nullptr, GL_TRUE);
+					glDebugMessageControl(gldbgsource[s].token, gldbgtype[t].token, gldbgseverity[sv].token, 0, nullptr,
+										  GL_TRUE);
 				}
 				}
 			}
 			}
 		}
 		}

+ 3 - 3
src/anki/gr/gl/GlState.h

@@ -44,9 +44,9 @@ public:
 	/// @name FB
 	/// @name FB
 	/// @{
 	/// @{
 	Array2d<Bool, MAX_COLOR_ATTACHMENTS, 4> m_colorWriteMasks = {{{{true, true, true, true}},
 	Array2d<Bool, MAX_COLOR_ATTACHMENTS, 4> m_colorWriteMasks = {{{{true, true, true, true}},
-		{{true, true, true, true}},
-		{{true, true, true, true}},
-		{{true, true, true, true}}}};
+																  {{true, true, true, true}},
+																  {{true, true, true, true}},
+																  {{true, true, true, true}}}};
 
 
 	Bool m_depthWriteMask = true;
 	Bool m_depthWriteMask = true;
 
 

+ 4 - 5
src/anki/gr/gl/GrManagerImplSdl.cpp

@@ -35,9 +35,8 @@ public:
 	{
 	{
 		m_window = init.m_window->getNative().m_window;
 		m_window = init.m_window->getNative().m_window;
 
 
-		ANKI_GL_LOGI("Creating GL %u.%u context...",
-			U(init.m_config->getNumber("gr.glmajor")),
-			U(init.m_config->getNumber("gr.glminor")));
+		ANKI_GL_LOGI("Creating GL %u.%u context...", U(init.m_config->getNumber("gr.glmajor")),
+					 U(init.m_config->getNumber("gr.glminor")));
 
 
 		if(init.m_config->getNumber("gr_debugContext"))
 		if(init.m_config->getNumber("gr_debugContext"))
 		{
 		{
@@ -49,8 +48,8 @@ public:
 		}
 		}
 
 
 		if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, init.m_config->getNumber("gr.glmajor"))
 		if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, init.m_config->getNumber("gr.glmajor"))
-			|| SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, init.m_config->getNumber("gr.glminor"))
-			|| SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE))
+		   || SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, init.m_config->getNumber("gr.glminor"))
+		   || SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE))
 		{
 		{
 			ANKI_GL_LOGE("SDL_GL_SetAttribute() failed");
 			ANKI_GL_LOGE("SDL_GL_SetAttribute() failed");
 			return Error::FUNCTION_FAILED;
 			return Error::FUNCTION_FAILED;

+ 4 - 4
src/anki/gr/gl/RenderingThread.cpp

@@ -56,8 +56,8 @@ public:
 		const FramebufferImpl& fb = static_cast<FramebufferImpl&>(*gr.m_fakeDefaultFb);
 		const FramebufferImpl& fb = static_cast<FramebufferImpl&>(*gr.m_fakeDefaultFb);
 		const U width = gr.m_fakeFbTex->getWidth();
 		const U width = gr.m_fakeFbTex->getWidth();
 		const U height = gr.m_fakeFbTex->getHeight();
 		const U height = gr.m_fakeFbTex->getHeight();
-		glBlitNamedFramebuffer(
-			fb.getGlName(), 0, 0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
+		glBlitNamedFramebuffer(fb.getGlName(), 0, 0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT,
+							   GL_NEAREST);
 
 
 		// Swap buffers
 		// Swap buffers
 		m_renderingThread->swapBuffersInternal();
 		m_renderingThread->swapBuffersInternal();
@@ -186,8 +186,8 @@ void RenderingThread::prepare()
 	glGetError();
 	glGetError();
 
 
 	ANKI_GL_LOGI("OpenGL async thread started: OpenGL version \"%s\", GLSL version \"%s\"",
 	ANKI_GL_LOGI("OpenGL async thread started: OpenGL version \"%s\", GLSL version \"%s\"",
-		reinterpret_cast<const char*>(glGetString(GL_VERSION)),
-		reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
+				 reinterpret_cast<const char*>(glGetString(GL_VERSION)),
+				 reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
 
 
 	// Get thread id
 	// Get thread id
 	m_serverThreadId = Thread::getCurrentThreadId();
 	m_serverThreadId = Thread::getCurrentThreadId();

+ 3 - 4
src/anki/gr/gl/Shader.cpp

@@ -20,10 +20,9 @@ Shader* Shader::newInstance(GrManager* manager, const ShaderInitInfo& init)
 		StringAuto m_source;
 		StringAuto m_source;
 		DynamicArrayAuto<ShaderSpecializationConstValue> m_constValues;
 		DynamicArrayAuto<ShaderSpecializationConstValue> m_constValues;
 
 
-		ShaderCreateCommand(Shader* shader,
-			ConstWeakArray<U8> bin,
-			ConstWeakArray<ShaderSpecializationConstValue> constValues,
-			const CommandBufferAllocator<U8>& alloc)
+		ShaderCreateCommand(Shader* shader, ConstWeakArray<U8> bin,
+							ConstWeakArray<ShaderSpecializationConstValue> constValues,
+							const CommandBufferAllocator<U8>& alloc)
 			: m_shader(shader)
 			: m_shader(shader)
 			, m_source(alloc)
 			, m_source(alloc)
 			, m_constValues(alloc)
 			, m_constValues(alloc)

+ 2 - 6
src/anki/gr/gl/ShaderImpl.cpp

@@ -38,12 +38,8 @@ Error ShaderImpl::init(CString source, ConstWeakArray<ShaderSpecializationConstV
 	ANKI_ASSERT(source);
 	ANKI_ASSERT(source);
 	ANKI_ASSERT(!isCreated());
 	ANKI_ASSERT(!isCreated());
 
 
-	static const Array<GLenum, 6> gltype = {{GL_VERTEX_SHADER,
-		GL_TESS_CONTROL_SHADER,
-		GL_TESS_EVALUATION_SHADER,
-		GL_GEOMETRY_SHADER,
-		GL_FRAGMENT_SHADER,
-		GL_COMPUTE_SHADER}};
+	static const Array<GLenum, 6> gltype = {{GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER,
+											 GL_GEOMETRY_SHADER, GL_FRAGMENT_SHADER, GL_COMPUTE_SHADER}};
 
 
 	m_glType = gltype[U(m_shaderType)];
 	m_glType = gltype[U(m_shaderType)];
 
 

+ 6 - 14
src/anki/gr/gl/ShaderProgram.cpp

@@ -25,13 +25,8 @@ ShaderProgram* ShaderProgram::newInstance(GrManager* manager, const ShaderProgra
 		ShaderPtr m_frag;
 		ShaderPtr m_frag;
 		ShaderPtr m_comp;
 		ShaderPtr m_comp;
 
 
-		CreateCommand(ShaderProgram* prog,
-			ShaderPtr vert,
-			ShaderPtr tessc,
-			ShaderPtr tesse,
-			ShaderPtr geom,
-			ShaderPtr frag,
-			ShaderPtr comp)
+		CreateCommand(ShaderProgram* prog, ShaderPtr vert, ShaderPtr tessc, ShaderPtr tesse, ShaderPtr geom,
+					  ShaderPtr frag, ShaderPtr comp)
 			: m_prog(prog)
 			: m_prog(prog)
 			, m_vert(vert)
 			, m_vert(vert)
 			, m_tessc(tessc)
 			, m_tessc(tessc)
@@ -61,13 +56,10 @@ ShaderProgram* ShaderProgram::newInstance(GrManager* manager, const ShaderProgra
 	impl->getRefcount().fetchAdd(1); // Hold a reference in case the command finishes and deletes quickly
 	impl->getRefcount().fetchAdd(1); // Hold a reference in case the command finishes and deletes quickly
 
 
 	CommandBufferPtr cmdb = manager->newCommandBuffer(CommandBufferInitInfo());
 	CommandBufferPtr cmdb = manager->newCommandBuffer(CommandBufferInitInfo());
-	static_cast<CommandBufferImpl&>(*cmdb).pushBackNewCommand<CreateCommand>(impl,
-		init.m_shaders[ShaderType::VERTEX],
-		init.m_shaders[ShaderType::TESSELLATION_CONTROL],
-		init.m_shaders[ShaderType::TESSELLATION_EVALUATION],
-		init.m_shaders[ShaderType::GEOMETRY],
-		init.m_shaders[ShaderType::FRAGMENT],
-		init.m_shaders[ShaderType::COMPUTE]);
+	static_cast<CommandBufferImpl&>(*cmdb).pushBackNewCommand<CreateCommand>(
+		impl, init.m_shaders[ShaderType::VERTEX], init.m_shaders[ShaderType::TESSELLATION_CONTROL],
+		init.m_shaders[ShaderType::TESSELLATION_EVALUATION], init.m_shaders[ShaderType::GEOMETRY],
+		init.m_shaders[ShaderType::FRAGMENT], init.m_shaders[ShaderType::COMPUTE]);
 	static_cast<CommandBufferImpl&>(*cmdb).flush();
 	static_cast<CommandBufferImpl&>(*cmdb).flush();
 
 
 	return impl;
 	return impl;

+ 4 - 5
src/anki/gr/gl/ShaderProgramImpl.cpp

@@ -163,11 +163,10 @@ const ShaderProgramImplReflection& ShaderProgramImpl::getReflection()
 		}
 		}
 
 
 		// Sort the uniforms
 		// Sort the uniforms
-		std::sort(m_refl.m_uniforms.getBegin(),
-			m_refl.m_uniforms.getEnd(),
-			[](const ShaderProgramImplReflection::Uniform& a, const ShaderProgramImplReflection::Uniform& b) {
-				return a.m_location < b.m_location;
-			});
+		std::sort(m_refl.m_uniforms.getBegin(), m_refl.m_uniforms.getEnd(),
+				  [](const ShaderProgramImplReflection::Uniform& a, const ShaderProgramImplReflection::Uniform& b) {
+					  return a.m_location < b.m_location;
+				  });
 
 
 		// Now calculate the offset inside the push constant buffer
 		// Now calculate the offset inside the push constant buffer
 		m_refl.m_uniformDataSize = 0;
 		m_refl.m_uniformDataSize = 0;

+ 2 - 2
src/anki/gr/gl/ShaderProgramImpl.h

@@ -40,8 +40,8 @@ public:
 
 
 	~ShaderProgramImpl();
 	~ShaderProgramImpl();
 
 
-	ANKI_USE_RESULT Error initGraphics(
-		ShaderPtr vert, ShaderPtr tessc, ShaderPtr tesse, ShaderPtr geom, ShaderPtr frag);
+	ANKI_USE_RESULT Error initGraphics(ShaderPtr vert, ShaderPtr tessc, ShaderPtr tesse, ShaderPtr geom,
+									   ShaderPtr frag);
 	ANKI_USE_RESULT Error initCompute(ShaderPtr comp);
 	ANKI_USE_RESULT Error initCompute(ShaderPtr comp);
 
 
 	// Do that only when is needed to avoid serializing the thread the driver is using for compilation.
 	// Do that only when is needed to avoid serializing the thread the driver is using for compilation.

+ 14 - 20
src/anki/gr/gl/StateTracker.h

@@ -141,7 +141,7 @@ public:
 	Bool setScissor(GLsizei minx, GLsizei miny, GLsizei width, GLsizei height)
 	Bool setScissor(GLsizei minx, GLsizei miny, GLsizei width, GLsizei height)
 	{
 	{
 		if(!m_scissorSet
 		if(!m_scissorSet
-			|| (m_scissor[0] != minx || m_scissor[1] != miny || m_scissor[2] != width || m_scissor[3] != height))
+		   || (m_scissor[0] != minx || m_scissor[1] != miny || m_scissor[2] != width || m_scissor[3] != height))
 		{
 		{
 			m_scissor = {{minx, miny, width, height}};
 			m_scissor = {{minx, miny, width, height}};
 			m_scissorSet = true;
 			m_scissorSet = true;
@@ -198,11 +198,11 @@ public:
 
 
 	Bool maybeEnableStencilTest()
 	Bool maybeEnableStencilTest()
 	{
 	{
-		Bool enable = !stencilTestDisabled(
-			m_stencilFail[0], m_stencilPassDepthFail[0], m_stencilPassDepthPass[0], m_stencilCompare[0]);
+		Bool enable = !stencilTestDisabled(m_stencilFail[0], m_stencilPassDepthFail[0], m_stencilPassDepthPass[0],
+										   m_stencilCompare[0]);
 		enable = enable
 		enable = enable
-				 || !stencilTestDisabled(
-						m_stencilFail[1], m_stencilPassDepthFail[1], m_stencilPassDepthPass[1], m_stencilCompare[1]);
+				 || !stencilTestDisabled(m_stencilFail[1], m_stencilPassDepthFail[1], m_stencilPassDepthPass[1],
+										 m_stencilCompare[1]);
 
 
 		if(enable != m_stencilTestEnabled)
 		if(enable != m_stencilTestEnabled)
 		{
 		{
@@ -216,15 +216,13 @@ public:
 	Array<StencilOperation, 2> m_stencilPassDepthFail = {{StencilOperation::COUNT, StencilOperation::COUNT}};
 	Array<StencilOperation, 2> m_stencilPassDepthFail = {{StencilOperation::COUNT, StencilOperation::COUNT}};
 	Array<StencilOperation, 2> m_stencilPassDepthPass = {{StencilOperation::COUNT, StencilOperation::COUNT}};
 	Array<StencilOperation, 2> m_stencilPassDepthPass = {{StencilOperation::COUNT, StencilOperation::COUNT}};
 
 
-	Bool setStencilOperations(FaceSelectionBit face,
-		StencilOperation stencilFail,
-		StencilOperation stencilPassDepthFail,
-		StencilOperation stencilPassDepthPass)
+	Bool setStencilOperations(FaceSelectionBit face, StencilOperation stencilFail,
+							  StencilOperation stencilPassDepthFail, StencilOperation stencilPassDepthPass)
 	{
 	{
 		Bool changed = false;
 		Bool changed = false;
 		if(!!(face & FaceSelectionBit::FRONT)
 		if(!!(face & FaceSelectionBit::FRONT)
-			&& (m_stencilFail[0] != stencilFail || m_stencilPassDepthFail[0] != stencilPassDepthFail
-				   || m_stencilPassDepthPass[0] != stencilPassDepthPass))
+		   && (m_stencilFail[0] != stencilFail || m_stencilPassDepthFail[0] != stencilPassDepthFail
+			   || m_stencilPassDepthPass[0] != stencilPassDepthPass))
 		{
 		{
 			m_stencilFail[0] = stencilFail;
 			m_stencilFail[0] = stencilFail;
 			m_stencilPassDepthFail[0] = stencilPassDepthFail;
 			m_stencilPassDepthFail[0] = stencilPassDepthFail;
@@ -233,8 +231,8 @@ public:
 		}
 		}
 
 
 		if(!!(face & FaceSelectionBit::BACK)
 		if(!!(face & FaceSelectionBit::BACK)
-			&& (m_stencilFail[1] != stencilFail || m_stencilPassDepthFail[1] != stencilPassDepthFail
-				   || m_stencilPassDepthPass[1] != stencilPassDepthPass))
+		   && (m_stencilFail[1] != stencilFail || m_stencilPassDepthFail[1] != stencilPassDepthFail
+			   || m_stencilPassDepthPass[1] != stencilPassDepthPass))
 		{
 		{
 			m_stencilFail[1] = stencilFail;
 			m_stencilFail[1] = stencilFail;
 			m_stencilPassDepthFail[1] = stencilPassDepthFail;
 			m_stencilPassDepthFail[1] = stencilPassDepthFail;
@@ -398,12 +396,8 @@ public:
 	Bool maybeEnableBlend(U attidx)
 	Bool maybeEnableBlend(U attidx)
 	{
 	{
 		ColorAttachment& att = m_colorAtt[attidx];
 		ColorAttachment& att = m_colorAtt[attidx];
-		Bool wantBlend = !blendingDisabled(att.m_blendSrcFactorRgb,
-			att.m_blendDstFactorRgb,
-			att.m_blendSrcFactorA,
-			att.m_blendDstFactorA,
-			att.m_blendOpRgb,
-			att.m_blendOpA);
+		Bool wantBlend = !blendingDisabled(att.m_blendSrcFactorRgb, att.m_blendDstFactorRgb, att.m_blendSrcFactorA,
+										   att.m_blendDstFactorA, att.m_blendOpRgb, att.m_blendOpA);
 
 
 		if(wantBlend != att.m_enableBlend)
 		if(wantBlend != att.m_enableBlend)
 		{
 		{
@@ -417,7 +411,7 @@ public:
 	{
 	{
 		auto& att = m_colorAtt[attachment];
 		auto& att = m_colorAtt[attachment];
 		if(att.m_blendSrcFactorRgb != srcRgb || att.m_blendDstFactorRgb != dstRgb || att.m_blendSrcFactorA != srcA
 		if(att.m_blendSrcFactorRgb != srcRgb || att.m_blendDstFactorRgb != dstRgb || att.m_blendSrcFactorA != srcA
-			|| att.m_blendDstFactorA != dstA)
+		   || att.m_blendDstFactorA != dstA)
 		{
 		{
 			att.m_blendSrcFactorRgb = srcRgb;
 			att.m_blendSrcFactorRgb = srcRgb;
 			att.m_blendDstFactorRgb = dstRgb;
 			att.m_blendDstFactorRgb = dstRgb;

+ 15 - 22
src/anki/gr/gl/TextureImpl.cpp

@@ -94,8 +94,8 @@ TextureImpl::~TextureImpl()
 		CommandBufferPtr commands;
 		CommandBufferPtr commands;
 
 
 		commands = manager.newCommandBuffer(CommandBufferInitInfo());
 		commands = manager.newCommandBuffer(CommandBufferInitInfo());
-		static_cast<CommandBufferImpl&>(*commands).pushBackNewCommand<DeleteTextureCommand>(
-			m_glName, m_viewsMap, getAllocator());
+		static_cast<CommandBufferImpl&>(*commands).pushBackNewCommand<DeleteTextureCommand>(m_glName, m_viewsMap,
+																							getAllocator());
 		static_cast<CommandBufferImpl&>(*commands).flush();
 		static_cast<CommandBufferImpl&>(*commands).flush();
 	}
 	}
 	else
 	else
@@ -209,8 +209,8 @@ void TextureImpl::init(const TextureInitInfo& init)
 	ANKI_CHECK_GL_ERROR();
 	ANKI_CHECK_GL_ERROR();
 }
 }
 
 
-void TextureImpl::copyFromBuffer(
-	const TextureSubresourceInfo& subresource, GLuint pbo, PtrSize offset, PtrSize dataSize) const
+void TextureImpl::copyFromBuffer(const TextureSubresourceInfo& subresource, GLuint pbo, PtrSize offset,
+								 PtrSize dataSize) const
 {
 {
 	ANKI_ASSERT(isSubresourceGoodForCopyFromBuffer(subresource));
 	ANKI_ASSERT(isSubresourceGoodForCopyFromBuffer(subresource));
 	ANKI_ASSERT(dataSize > 0);
 	ANKI_ASSERT(dataSize > 0);
@@ -243,13 +243,13 @@ void TextureImpl::copyFromBuffer(
 		const U surfIdx = computeSurfaceIdx(TextureSurfaceInfo(mipmap, 0, subresource.m_firstFace, 0));
 		const U surfIdx = computeSurfaceIdx(TextureSurfaceInfo(mipmap, 0, subresource.m_firstFace, 0));
 		if(!m_compressed)
 		if(!m_compressed)
 		{
 		{
-			glTexSubImage2D(
-				GL_TEXTURE_CUBE_MAP_POSITIVE_X + surfIdx, mipmap, 0, 0, w, h, m_glFormat, m_glType, ptrOffset);
+			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + surfIdx, mipmap, 0, 0, w, h, m_glFormat, m_glType,
+							ptrOffset);
 		}
 		}
 		else
 		else
 		{
 		{
-			glCompressedTexSubImage2D(
-				GL_TEXTURE_CUBE_MAP_POSITIVE_X + surfIdx, mipmap, 0, 0, w, h, m_glFormat, dataSize, ptrOffset);
+			glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + surfIdx, mipmap, 0, 0, w, h, m_glFormat,
+									  dataSize, ptrOffset);
 		}
 		}
 		break;
 		break;
 	}
 	}
@@ -341,8 +341,8 @@ void TextureImpl::clear(const TextureSubresourceInfo& subresource, const ClearVa
 				const U width = m_width >> mip;
 				const U width = m_width >> mip;
 				const U height = m_height >> mip;
 				const U height = m_height >> mip;
 
 
-				glClearTexSubImage(
-					m_glName, mip, 0, 0, surfaceIdx, width, height, 1, format, GL_FLOAT, &clearValue.m_colorf[0]);
+				glClearTexSubImage(m_glName, mip, 0, 0, surfaceIdx, width, height, 1, format, GL_FLOAT,
+								   &clearValue.m_colorf[0]);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -405,24 +405,17 @@ MicroTextureView TextureImpl::getOrCreateView(const TextureSubresourceInfo& subr
 
 
 		const U firstSurf = computeSurfaceIdx(
 		const U firstSurf = computeSurfaceIdx(
 			TextureSurfaceInfo(subresource.m_firstMipmap, 0, subresource.m_firstFace, subresource.m_firstLayer));
 			TextureSurfaceInfo(subresource.m_firstMipmap, 0, subresource.m_firstFace, subresource.m_firstLayer));
-		const U lastSurf = computeSurfaceIdx(TextureSurfaceInfo(subresource.m_firstMipmap,
-			0,
-			subresource.m_firstFace + subresource.m_faceCount - 1,
-			subresource.m_firstLayer + subresource.m_layerCount - 1));
+		const U lastSurf = computeSurfaceIdx(
+			TextureSurfaceInfo(subresource.m_firstMipmap, 0, subresource.m_firstFace + subresource.m_faceCount - 1,
+							   subresource.m_firstLayer + subresource.m_layerCount - 1));
 		ANKI_ASSERT(firstSurf <= lastSurf);
 		ANKI_ASSERT(firstSurf <= lastSurf);
 
 
 		MicroTextureView view;
 		MicroTextureView view;
 		view.m_aspect = subresource.m_depthStencilAspect;
 		view.m_aspect = subresource.m_depthStencilAspect;
 
 
 		glGenTextures(1, &view.m_glName);
 		glGenTextures(1, &view.m_glName);
-		glTextureView(view.m_glName,
-			glTarget,
-			m_glName,
-			m_internalFormat,
-			subresource.m_firstMipmap,
-			subresource.m_mipmapCount,
-			firstSurf,
-			lastSurf - firstSurf + 1);
+		glTextureView(view.m_glName, glTarget, m_glName, m_internalFormat, subresource.m_firstMipmap,
+					  subresource.m_mipmapCount, firstSurf, lastSurf - firstSurf + 1);
 
 
 		m_viewsMap.emplace(getAllocator(), subresource, view);
 		m_viewsMap.emplace(getAllocator(), subresource, view);
 
 

+ 8 - 21
src/anki/gr/utils/Functions.cpp

@@ -9,11 +9,8 @@ namespace anki
 {
 {
 
 
 template<typename T>
 template<typename T>
-static void writeShaderBlockMemorySanityChecks(const ShaderVariableBlockInfo& varBlkInfo,
-	const void* elements,
-	U32 elementsCount,
-	void* buffBegin,
-	const void* buffEnd)
+static void writeShaderBlockMemorySanityChecks(const ShaderVariableBlockInfo& varBlkInfo, const void* elements,
+											   U32 elementsCount, void* buffBegin, const void* buffEnd)
 {
 {
 	// Check args
 	// Check args
 	ANKI_ASSERT(elements != nullptr);
 	ANKI_ASSERT(elements != nullptr);
@@ -36,11 +33,8 @@ static void writeShaderBlockMemorySanityChecks(const ShaderVariableBlockInfo& va
 }
 }
 
 
 template<typename T>
 template<typename T>
-static void writeShaderBlockMemorySimple(const ShaderVariableBlockInfo& varBlkInfo,
-	const void* elements,
-	U32 elementsCount,
-	void* buffBegin,
-	const void* buffEnd)
+static void writeShaderBlockMemorySimple(const ShaderVariableBlockInfo& varBlkInfo, const void* elements,
+										 U32 elementsCount, void* buffBegin, const void* buffEnd)
 {
 {
 	writeShaderBlockMemorySanityChecks<T>(varBlkInfo, elements, elementsCount, buffBegin, buffEnd);
 	writeShaderBlockMemorySanityChecks<T>(varBlkInfo, elements, elementsCount, buffBegin, buffEnd);
 
 
@@ -58,11 +52,8 @@ static void writeShaderBlockMemorySimple(const ShaderVariableBlockInfo& varBlkIn
 }
 }
 
 
 template<typename T, typename Vec>
 template<typename T, typename Vec>
-static void writeShaderBlockMemoryMatrix(const ShaderVariableBlockInfo& varBlkInfo,
-	const void* elements,
-	U32 elementsCount,
-	void* buffBegin,
-	const void* buffEnd)
+static void writeShaderBlockMemoryMatrix(const ShaderVariableBlockInfo& varBlkInfo, const void* elements,
+										 U32 elementsCount, void* buffBegin, const void* buffEnd)
 {
 {
 	writeShaderBlockMemorySanityChecks<T>(varBlkInfo, elements, elementsCount, buffBegin, buffEnd);
 	writeShaderBlockMemorySanityChecks<T>(varBlkInfo, elements, elementsCount, buffBegin, buffEnd);
 	ANKI_ASSERT(varBlkInfo.m_matrixStride > 0);
 	ANKI_ASSERT(varBlkInfo.m_matrixStride > 0);
@@ -85,12 +76,8 @@ static void writeShaderBlockMemoryMatrix(const ShaderVariableBlockInfo& varBlkIn
 	}
 	}
 }
 }
 
 
-void writeShaderBlockMemory(ShaderVariableDataType type,
-	const ShaderVariableBlockInfo& varBlkInfo,
-	const void* elements,
-	U32 elementsCount,
-	void* buffBegin,
-	const void* buffEnd)
+void writeShaderBlockMemory(ShaderVariableDataType type, const ShaderVariableBlockInfo& varBlkInfo,
+							const void* elements, U32 elementsCount, void* buffBegin, const void* buffEnd)
 {
 {
 	switch(type)
 	switch(type)
 	{
 	{

+ 6 - 16
src/anki/gr/utils/Functions.h

@@ -11,21 +11,15 @@
 namespace anki
 namespace anki
 {
 {
 
 
-inline Bool stencilTestDisabled(StencilOperation stencilFail,
-	StencilOperation stencilPassDepthFail,
-	StencilOperation stencilPassDepthPass,
-	CompareOperation compare)
+inline Bool stencilTestDisabled(StencilOperation stencilFail, StencilOperation stencilPassDepthFail,
+								StencilOperation stencilPassDepthPass, CompareOperation compare)
 {
 {
 	return stencilFail == StencilOperation::KEEP && stencilPassDepthFail == StencilOperation::KEEP
 	return stencilFail == StencilOperation::KEEP && stencilPassDepthFail == StencilOperation::KEEP
 		   && stencilPassDepthPass == StencilOperation::KEEP && compare == CompareOperation::ALWAYS;
 		   && stencilPassDepthPass == StencilOperation::KEEP && compare == CompareOperation::ALWAYS;
 }
 }
 
 
-inline Bool blendingDisabled(BlendFactor srcFactorRgb,
-	BlendFactor dstFactorRgb,
-	BlendFactor srcFactorA,
-	BlendFactor dstFactorA,
-	BlendOperation opRgb,
-	BlendOperation opA)
+inline Bool blendingDisabled(BlendFactor srcFactorRgb, BlendFactor dstFactorRgb, BlendFactor srcFactorA,
+							 BlendFactor dstFactorA, BlendOperation opRgb, BlendOperation opA)
 {
 {
 	Bool dontWantBlend = srcFactorRgb == BlendFactor::ONE && dstFactorRgb == BlendFactor::ZERO
 	Bool dontWantBlend = srcFactorRgb == BlendFactor::ONE && dstFactorRgb == BlendFactor::ZERO
 						 && srcFactorA == BlendFactor::ONE && dstFactorA == BlendFactor::ZERO
 						 && srcFactorA == BlendFactor::ONE && dstFactorA == BlendFactor::ZERO
@@ -49,12 +43,8 @@ ShaderVariableDataType getShaderVariableTypeFromTypename();
 #undef ANKI_SVDT_MACRO
 #undef ANKI_SVDT_MACRO
 
 
 /// Populate the memory of a variable that is inside a shader block.
 /// Populate the memory of a variable that is inside a shader block.
-void writeShaderBlockMemory(ShaderVariableDataType type,
-	const ShaderVariableBlockInfo& varBlkInfo,
-	const void* elements,
-	U32 elementsCount,
-	void* buffBegin,
-	const void* buffEnd);
+void writeShaderBlockMemory(ShaderVariableDataType type, const ShaderVariableBlockInfo& varBlkInfo,
+							const void* elements, U32 elementsCount, void* buffBegin, const void* buffEnd);
 
 
 /// Convert a ShaderVariableDataType to string.
 /// Convert a ShaderVariableDataType to string.
 const CString shaderVariableDataTypeToString(ShaderVariableDataType t);
 const CString shaderVariableDataTypeToString(ShaderVariableDataType t);

+ 9 - 11
src/anki/gr/vulkan/AccelerationStructureImpl.cpp

@@ -71,8 +71,8 @@ Error AccelerationStructureImpl::init(const AccelerationStructureInitInfo& inf)
 		ci.pGeometryInfos = &geom;
 		ci.pGeometryInfos = &geom;
 
 
 		ANKI_VK_CHECK(vkCreateAccelerationStructureKHR(getDevice(), &ci, nullptr, &m_handle));
 		ANKI_VK_CHECK(vkCreateAccelerationStructureKHR(getDevice(), &ci, nullptr, &m_handle));
-		getGrManagerImpl().trySetVulkanHandleName(
-			inf.getName(), VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR_EXT, m_handle);
+		getGrManagerImpl().trySetVulkanHandleName(inf.getName(),
+												  VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR_EXT, m_handle);
 	}
 	}
 
 
 	// Allocate memory
 	// Allocate memory
@@ -91,14 +91,14 @@ Error AccelerationStructureImpl::init(const AccelerationStructureInitInfo& inf)
 
 
 		// Find mem IDX
 		// Find mem IDX
 		U32 memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryRequirements.memoryTypeBits,
 		U32 memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryRequirements.memoryTypeBits,
-			VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
-			VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
+																			 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+																			 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
 
 
 		// Fallback
 		// Fallback
 		if(memIdx == MAX_U32)
 		if(memIdx == MAX_U32)
 		{
 		{
-			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
-				req.memoryRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0);
+			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryRequirements.memoryTypeBits,
+																			 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0);
 		}
 		}
 
 
 		ANKI_ASSERT(memIdx != MAX_U32);
 		ANKI_ASSERT(memIdx != MAX_U32);
@@ -231,11 +231,9 @@ void AccelerationStructureImpl::initBuildInfo()
 }
 }
 
 
 void AccelerationStructureImpl::computeBarrierInfo(AccelerationStructureUsageBit before,
 void AccelerationStructureImpl::computeBarrierInfo(AccelerationStructureUsageBit before,
-	AccelerationStructureUsageBit after,
-	VkPipelineStageFlags& srcStages,
-	VkAccessFlags& srcAccesses,
-	VkPipelineStageFlags& dstStages,
-	VkAccessFlags& dstAccesses)
+												   AccelerationStructureUsageBit after, VkPipelineStageFlags& srcStages,
+												   VkAccessFlags& srcAccesses, VkPipelineStageFlags& dstStages,
+												   VkAccessFlags& dstAccesses)
 {
 {
 	// Before
 	// Before
 	srcStages = 0;
 	srcStages = 0;

+ 8 - 11
src/anki/gr/vulkan/AccelerationStructureImpl.h

@@ -16,8 +16,9 @@ namespace anki
 /// @{
 /// @{
 
 
 /// AccelerationStructure implementation.
 /// AccelerationStructure implementation.
-class AccelerationStructureImpl final : public AccelerationStructure,
-										public VulkanObject<AccelerationStructure, AccelerationStructureImpl>
+class AccelerationStructureImpl final :
+	public AccelerationStructure,
+	public VulkanObject<AccelerationStructure, AccelerationStructureImpl>
 {
 {
 public:
 public:
 	AccelerationStructureImpl(GrManager* manager, CString name)
 	AccelerationStructureImpl(GrManager* manager, CString name)
@@ -41,21 +42,17 @@ public:
 		return m_scratchBufferSize;
 		return m_scratchBufferSize;
 	}
 	}
 
 
-	void generateBuildInfo(U64 scratchBufferAddress,
-		VkAccelerationStructureBuildGeometryInfoKHR& info,
-		VkAccelerationStructureBuildOffsetInfoKHR& offsetInfo) const
+	void generateBuildInfo(U64 scratchBufferAddress, VkAccelerationStructureBuildGeometryInfoKHR& info,
+						   VkAccelerationStructureBuildOffsetInfoKHR& offsetInfo) const
 	{
 	{
 		info = m_buildInfo;
 		info = m_buildInfo;
 		info.scratchData.deviceAddress = scratchBufferAddress;
 		info.scratchData.deviceAddress = scratchBufferAddress;
 		offsetInfo = m_offsetInfo;
 		offsetInfo = m_offsetInfo;
 	}
 	}
 
 
-	static void computeBarrierInfo(AccelerationStructureUsageBit before,
-		AccelerationStructureUsageBit after,
-		VkPipelineStageFlags& srcStages,
-		VkAccessFlags& srcAccesses,
-		VkPipelineStageFlags& dstStages,
-		VkAccessFlags& dstAccesses);
+	static void computeBarrierInfo(AccelerationStructureUsageBit before, AccelerationStructureUsageBit after,
+								   VkPipelineStageFlags& srcStages, VkAccessFlags& srcAccesses,
+								   VkPipelineStageFlags& dstStages, VkAccessFlags& dstAccesses);
 
 
 private:
 private:
 	class ASBottomLevelInfo : public BottomLevelAccelerationStructureInitInfo
 	class ASBottomLevelInfo : public BottomLevelAccelerationStructureInitInfo

+ 19 - 20
src/anki/gr/vulkan/BufferImpl.cpp

@@ -79,15 +79,16 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 		}
 		}
 
 
 		// Device & host & coherent but not cached
 		// Device & host & coherent but not cached
-		memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryTypeBits,
+		memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
+			req.memoryTypeBits,
 			VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | preferDeviceLocal,
 			VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | preferDeviceLocal,
 			VK_MEMORY_PROPERTY_HOST_CACHED_BIT | avoidDeviceLocal);
 			VK_MEMORY_PROPERTY_HOST_CACHED_BIT | avoidDeviceLocal);
 
 
 		// Fallback: host & coherent and not cached
 		// Fallback: host & coherent and not cached
 		if(memIdx == MAX_U32)
 		if(memIdx == MAX_U32)
 		{
 		{
-			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryTypeBits,
-				VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
+				req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
 				VK_MEMORY_PROPERTY_HOST_CACHED_BIT | avoidDeviceLocal);
 				VK_MEMORY_PROPERTY_HOST_CACHED_BIT | avoidDeviceLocal);
 		}
 		}
 
 
@@ -95,8 +96,8 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 		if(memIdx == MAX_U32)
 		if(memIdx == MAX_U32)
 		{
 		{
 			ANKI_VK_LOGW("Using a fallback mode for write-only buffer");
 			ANKI_VK_LOGW("Using a fallback mode for write-only buffer");
-			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
-				req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 0);
+			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryTypeBits,
+																			 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 0);
 		}
 		}
 	}
 	}
 	else if((access & BufferMapAccessBit::READ) != BufferMapAccessBit::NONE)
 	else if((access & BufferMapAccessBit::READ) != BufferMapAccessBit::NONE)
@@ -105,9 +106,10 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 
 
 		// Cached & coherent
 		// Cached & coherent
 		memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryTypeBits,
 		memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryTypeBits,
-			VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT
-				| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
-			0);
+																		 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
+																			 | VK_MEMORY_PROPERTY_HOST_CACHED_BIT
+																			 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+																		 0);
 
 
 		// Fallback: Just cached
 		// Fallback: Just cached
 		if(memIdx == MAX_U32)
 		if(memIdx == MAX_U32)
@@ -120,8 +122,8 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 		if(memIdx == MAX_U32)
 		if(memIdx == MAX_U32)
 		{
 		{
 			ANKI_VK_LOGW("Using a fallback mode for read/write buffer");
 			ANKI_VK_LOGW("Using a fallback mode for read/write buffer");
-			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
-				req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 0);
+			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryTypeBits,
+																			 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 0);
 		}
 		}
 	}
 	}
 	else
 	else
@@ -137,8 +139,8 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 		// Fallback: Device with anything else
 		// Fallback: Device with anything else
 		if(memIdx == MAX_U32)
 		if(memIdx == MAX_U32)
 		{
 		{
-			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
-				req.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0);
+			memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(req.memoryTypeBits,
+																			 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0);
 		}
 		}
 	}
 	}
 
 
@@ -148,8 +150,8 @@ Error BufferImpl::init(const BufferInitInfo& inf)
 	m_memoryFlags = props.memoryTypes[memIdx].propertyFlags;
 	m_memoryFlags = props.memoryTypes[memIdx].propertyFlags;
 
 
 	// Allocate
 	// Allocate
-	getGrManagerImpl().getGpuMemoryManager().allocateMemory(
-		memIdx, req.size, U32(req.alignment), true, inf.m_exposeGpuAddress, m_memHandle);
+	getGrManagerImpl().getGpuMemoryManager().allocateMemory(memIdx, req.size, U32(req.alignment), true,
+															inf.m_exposeGpuAddress, m_memHandle);
 
 
 	// Bind mem to buffer
 	// Bind mem to buffer
 	{
 	{
@@ -322,12 +324,9 @@ VkAccessFlags BufferImpl::computeAccessMask(BufferUsageBit usage)
 	return mask;
 	return mask;
 }
 }
 
 
-void BufferImpl::computeBarrierInfo(BufferUsageBit before,
-	BufferUsageBit after,
-	VkPipelineStageFlags& srcStages,
-	VkAccessFlags& srcAccesses,
-	VkPipelineStageFlags& dstStages,
-	VkAccessFlags& dstAccesses) const
+void BufferImpl::computeBarrierInfo(BufferUsageBit before, BufferUsageBit after, VkPipelineStageFlags& srcStages,
+									VkAccessFlags& srcAccesses, VkPipelineStageFlags& dstStages,
+									VkAccessFlags& dstAccesses) const
 {
 {
 	ANKI_ASSERT(usageValid(before) && usageValid(after));
 	ANKI_ASSERT(usageValid(before) && usageValid(after));
 	ANKI_ASSERT(!!after);
 	ANKI_ASSERT(!!after);

+ 3 - 6
src/anki/gr/vulkan/BufferImpl.h

@@ -60,12 +60,9 @@ public:
 		return m_actualSize;
 		return m_actualSize;
 	}
 	}
 
 
-	void computeBarrierInfo(BufferUsageBit before,
-		BufferUsageBit after,
-		VkPipelineStageFlags& srcStages,
-		VkAccessFlags& srcAccesses,
-		VkPipelineStageFlags& dstStages,
-		VkAccessFlags& dstAccesses) const;
+	void computeBarrierInfo(BufferUsageBit before, BufferUsageBit after, VkPipelineStageFlags& srcStages,
+							VkAccessFlags& srcAccesses, VkPipelineStageFlags& dstStages,
+							VkAccessFlags& dstAccesses) const;
 
 
 private:
 private:
 	VkBuffer m_handle = VK_NULL_HANDLE;
 	VkBuffer m_handle = VK_NULL_HANDLE;

+ 28 - 32
src/anki/gr/vulkan/CommandBuffer.cpp

@@ -38,8 +38,8 @@ void CommandBuffer::flush(FencePtr* fence)
 	}
 	}
 }
 }
 
 
-void CommandBuffer::bindVertexBuffer(
-	U32 binding, BufferPtr buff, PtrSize offset, PtrSize stride, VertexStepRate stepRate)
+void CommandBuffer::bindVertexBuffer(U32 binding, BufferPtr buff, PtrSize offset, PtrSize stride,
+									 VertexStepRate stepRate)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.bindVertexBuffer(binding, buff, offset, stride, stepRate);
 	self.bindVertexBuffer(binding, buff, offset, stride, stepRate);
@@ -93,10 +93,8 @@ void CommandBuffer::setPolygonOffset(F32 factor, F32 units)
 	self.setPolygonOffset(factor, units);
 	self.setPolygonOffset(factor, units);
 }
 }
 
 
-void CommandBuffer::setStencilOperations(FaceSelectionBit face,
-	StencilOperation stencilFail,
-	StencilOperation stencilPassDepthFail,
-	StencilOperation stencilPassDepthPass)
+void CommandBuffer::setStencilOperations(FaceSelectionBit face, StencilOperation stencilFail,
+										 StencilOperation stencilPassDepthFail, StencilOperation stencilPassDepthPass)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.setStencilOperations(face, stencilFail, stencilPassDepthFail, stencilPassDepthPass);
 	self.setStencilOperations(face, stencilFail, stencilPassDepthFail, stencilPassDepthPass);
@@ -150,8 +148,8 @@ void CommandBuffer::setColorChannelWriteMask(U32 attachment, ColorBit mask)
 	self.setColorChannelWriteMask(attachment, mask);
 	self.setColorChannelWriteMask(attachment, mask);
 }
 }
 
 
-void CommandBuffer::setBlendFactors(
-	U32 attachment, BlendFactor srcRgb, BlendFactor dstRgb, BlendFactor srcA, BlendFactor dstA)
+void CommandBuffer::setBlendFactors(U32 attachment, BlendFactor srcRgb, BlendFactor dstRgb, BlendFactor srcA,
+									BlendFactor dstA)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.setBlendFactors(attachment, srcRgb, dstRgb, srcA, dstA);
 	self.setBlendFactors(attachment, srcRgb, dstRgb, srcA, dstA);
@@ -163,8 +161,8 @@ void CommandBuffer::setBlendOperation(U32 attachment, BlendOperation funcRgb, Bl
 	self.setBlendOperation(attachment, funcRgb, funcA);
 	self.setBlendOperation(attachment, funcRgb, funcA);
 }
 }
 
 
-void CommandBuffer::bindTextureAndSampler(
-	U32 set, U32 binding, TextureViewPtr texView, SamplerPtr sampler, TextureUsageBit usage, U32 arrayIdx)
+void CommandBuffer::bindTextureAndSampler(U32 set, U32 binding, TextureViewPtr texView, SamplerPtr sampler,
+										  TextureUsageBit usage, U32 arrayIdx)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.bindTextureAndSamplerInternal(set, binding, texView, sampler, usage, arrayIdx);
 	self.bindTextureAndSamplerInternal(set, binding, texView, sampler, usage, arrayIdx);
@@ -206,8 +204,8 @@ void CommandBuffer::bindAccelerationStructure(U32 set, U32 binding, Acceleration
 	self.bindAccelerationStructureInternal(set, binding, as, arrayIdx);
 	self.bindAccelerationStructureInternal(set, binding, as, arrayIdx);
 }
 }
 
 
-void CommandBuffer::bindTextureBuffer(
-	U32 set, U32 binding, BufferPtr buff, PtrSize offset, PtrSize range, Format fmt, U32 arrayIdx)
+void CommandBuffer::bindTextureBuffer(U32 set, U32 binding, BufferPtr buff, PtrSize offset, PtrSize range, Format fmt,
+									  U32 arrayIdx)
 {
 {
 	ANKI_ASSERT(!"TODO");
 	ANKI_ASSERT(!"TODO");
 }
 }
@@ -237,12 +235,9 @@ void CommandBuffer::bindShaderProgram(ShaderProgramPtr prog)
 }
 }
 
 
 void CommandBuffer::beginRenderPass(FramebufferPtr fb,
 void CommandBuffer::beginRenderPass(FramebufferPtr fb,
-	const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
-	TextureUsageBit depthStencilAttachmentUsage,
-	U32 minx,
-	U32 miny,
-	U32 width,
-	U32 height)
+									const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
+									TextureUsageBit depthStencilAttachmentUsage, U32 minx, U32 miny, U32 width,
+									U32 height)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.beginRenderPass(fb, colorAttachmentUsages, depthStencilAttachmentUsage, minx, miny, width, height);
 	self.beginRenderPass(fb, colorAttachmentUsages, depthStencilAttachmentUsage, minx, miny, width, height);
@@ -254,8 +249,8 @@ void CommandBuffer::endRenderPass()
 	self.endRenderPass();
 	self.endRenderPass();
 }
 }
 
 
-void CommandBuffer::drawElements(
-	PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex, U32 baseVertex, U32 baseInstance)
+void CommandBuffer::drawElements(PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex,
+								 U32 baseVertex, U32 baseInstance)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.drawElements(topology, count, instanceCount, firstIndex, baseVertex, baseInstance);
 	self.drawElements(topology, count, instanceCount, firstIndex, baseVertex, baseInstance);
@@ -325,8 +320,8 @@ void CommandBuffer::writeOcclusionQueryResultToBuffer(OcclusionQueryPtr query, P
 	self.writeOcclusionQueryResultToBuffer(query, offset, buff);
 	self.writeOcclusionQueryResultToBuffer(query, offset, buff);
 }
 }
 
 
-void CommandBuffer::copyBufferToBuffer(
-	BufferPtr src, PtrSize srcOffset, BufferPtr dst, PtrSize dstOffset, PtrSize range)
+void CommandBuffer::copyBufferToBuffer(BufferPtr src, PtrSize srcOffset, BufferPtr dst, PtrSize dstOffset,
+									   PtrSize range)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.copyBufferToBuffer(src, srcOffset, dst, dstOffset, range);
 	self.copyBufferToBuffer(src, srcOffset, dst, dstOffset, range);
@@ -338,36 +333,37 @@ void CommandBuffer::buildAccelerationStructure(AccelerationStructurePtr as)
 	self.buildAccelerationStructureInternal(as);
 	self.buildAccelerationStructureInternal(as);
 }
 }
 
 
-void CommandBuffer::setTextureBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSubresourceInfo& subresource)
+void CommandBuffer::setTextureBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+									  const TextureSubresourceInfo& subresource)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.setTextureBarrier(tex, prevUsage, nextUsage, subresource);
 	self.setTextureBarrier(tex, prevUsage, nextUsage, subresource);
 }
 }
 
 
-void CommandBuffer::setTextureSurfaceBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSurfaceInfo& surf)
+void CommandBuffer::setTextureSurfaceBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+											 const TextureSurfaceInfo& surf)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.setTextureSurfaceBarrier(tex, prevUsage, nextUsage, surf);
 	self.setTextureSurfaceBarrier(tex, prevUsage, nextUsage, surf);
 }
 }
 
 
-void CommandBuffer::setTextureVolumeBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureVolumeInfo& vol)
+void CommandBuffer::setTextureVolumeBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+											const TextureVolumeInfo& vol)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.setTextureVolumeBarrier(tex, prevUsage, nextUsage, vol);
 	self.setTextureVolumeBarrier(tex, prevUsage, nextUsage, vol);
 }
 }
 
 
-void CommandBuffer::setBufferBarrier(
-	BufferPtr buff, BufferUsageBit before, BufferUsageBit after, PtrSize offset, PtrSize size)
+void CommandBuffer::setBufferBarrier(BufferPtr buff, BufferUsageBit before, BufferUsageBit after, PtrSize offset,
+									 PtrSize size)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.setBufferBarrier(buff, before, after, offset, size);
 	self.setBufferBarrier(buff, before, after, offset, size);
 }
 }
 
 
-void CommandBuffer::setAccelerationStructureBarrier(
-	AccelerationStructurePtr as, AccelerationStructureUsageBit prevUsage, AccelerationStructureUsageBit nextUsage)
+void CommandBuffer::setAccelerationStructureBarrier(AccelerationStructurePtr as,
+													AccelerationStructureUsageBit prevUsage,
+													AccelerationStructureUsageBit nextUsage)
 {
 {
 	ANKI_VK_SELF(CommandBufferImpl);
 	ANKI_VK_SELF(CommandBufferImpl);
 	self.setAccelerationStructureBarrierInternal(as, prevUsage, nextUsage);
 	self.setAccelerationStructureBarrierInternal(as, prevUsage, nextUsage);

+ 9 - 11
src/anki/gr/vulkan/CommandBufferFactory.cpp

@@ -86,8 +86,8 @@ void CommandBufferThreadAllocator::destroy()
 	ANKI_ASSERT(m_createdCmdbs.load() == 0 && "Someone still holds references to command buffers");
 	ANKI_ASSERT(m_createdCmdbs.load() == 0 && "Someone still holds references to command buffers");
 }
 }
 
 
-Error CommandBufferThreadAllocator::newCommandBuffer(
-	CommandBufferFlag cmdbFlags, MicroCommandBufferPtr& outPtr, Bool& createdNew)
+Error CommandBufferThreadAllocator::newCommandBuffer(CommandBufferFlag cmdbFlags, MicroCommandBufferPtr& outPtr,
+													 Bool& createdNew)
 {
 {
 	cmdbFlags = cmdbFlags & (CommandBufferFlag::SECOND_LEVEL | CommandBufferFlag::SMALL_BATCH);
 	cmdbFlags = cmdbFlags & (CommandBufferFlag::SECOND_LEVEL | CommandBufferFlag::SMALL_BATCH);
 	createdNew = false;
 	createdNew = false;
@@ -181,10 +181,9 @@ Error CommandBufferThreadAllocator::newCommandBuffer(
 		m_createdCmdbs.fetchAdd(1);
 		m_createdCmdbs.fetchAdd(1);
 #endif
 #endif
 
 
-		newCmdb->m_fastAlloc = StackAllocator<U8>(m_factory->m_alloc.getMemoryPool().getAllocationCallback(),
-			m_factory->m_alloc.getMemoryPool().getAllocationCallbackUserData(),
-			256_KB,
-			2.0f);
+		newCmdb->m_fastAlloc =
+			StackAllocator<U8>(m_factory->m_alloc.getMemoryPool().getAllocationCallback(),
+							   m_factory->m_alloc.getMemoryPool().getAllocationCallbackUserData(), 256_KB, 2.0f);
 
 
 		newCmdb->m_handle = cmdb;
 		newCmdb->m_handle = cmdb;
 		newCmdb->m_flags = cmdbFlags;
 		newCmdb->m_flags = cmdbFlags;
@@ -291,11 +290,10 @@ Error CommandBufferFactory::newCommandBuffer(ThreadId tid, CommandBufferFlag cmd
 				m_threadAllocs[m_threadAllocs.getSize() - 1] = alloc;
 				m_threadAllocs[m_threadAllocs.getSize() - 1] = alloc;
 
 
 				// Sort for fast find
 				// Sort for fast find
-				std::sort(m_threadAllocs.getBegin(),
-					m_threadAllocs.getEnd(),
-					[](const CommandBufferThreadAllocator* a, const CommandBufferThreadAllocator* b) {
-						return a->m_tid < b->m_tid;
-					});
+				std::sort(m_threadAllocs.getBegin(), m_threadAllocs.getEnd(),
+						  [](const CommandBufferThreadAllocator* a, const CommandBufferThreadAllocator* b) {
+							  return a->m_tid < b->m_tid;
+						  });
 
 
 				ANKI_CHECK(alloc->init());
 				ANKI_CHECK(alloc->init());
 			}
 			}

+ 131 - 166
src/anki/gr/vulkan/CommandBufferImpl.cpp

@@ -104,12 +104,9 @@ void CommandBufferImpl::beginRecording()
 }
 }
 
 
 void CommandBufferImpl::beginRenderPass(FramebufferPtr fb,
 void CommandBufferImpl::beginRenderPass(FramebufferPtr fb,
-	const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
-	TextureUsageBit depthStencilAttachmentUsage,
-	U32 minx,
-	U32 miny,
-	U32 width,
-	U32 height)
+										const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
+										TextureUsageBit depthStencilAttachmentUsage, U32 minx, U32 miny, U32 width,
+										U32 height)
 {
 {
 	commandCommon();
 	commandCommon();
 	ANKI_ASSERT(!insideRenderPass());
 	ANKI_ASSERT(!insideRenderPass());
@@ -276,17 +273,13 @@ void CommandBufferImpl::generateMipmaps2d(TextureViewPtr texView)
 		if(i > 0)
 		if(i > 0)
 		{
 		{
 			VkImageSubresourceRange range;
 			VkImageSubresourceRange range;
-			tex.computeVkImageSubresourceRange(
-				TextureSubresourceInfo(TextureSurfaceInfo(i, 0, face, layer), aspect), range);
-
-			setImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
-				VK_ACCESS_TRANSFER_WRITE_BIT,
-				VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
-				VK_PIPELINE_STAGE_TRANSFER_BIT,
-				VK_ACCESS_TRANSFER_READ_BIT,
-				VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
-				tex.m_imageHandle,
-				range);
+			tex.computeVkImageSubresourceRange(TextureSubresourceInfo(TextureSurfaceInfo(i, 0, face, layer), aspect),
+											   range);
+
+			setImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
+							VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT,
+							VK_ACCESS_TRANSFER_READ_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, tex.m_imageHandle,
+							range);
 		}
 		}
 
 
 		// Transition destination
 		// Transition destination
@@ -295,14 +288,9 @@ void CommandBufferImpl::generateMipmaps2d(TextureViewPtr texView)
 			tex.computeVkImageSubresourceRange(
 			tex.computeVkImageSubresourceRange(
 				TextureSubresourceInfo(TextureSurfaceInfo(i + 1, 0, face, layer), aspect), range);
 				TextureSubresourceInfo(TextureSurfaceInfo(i + 1, 0, face, layer), aspect), range);
 
 
-			setImageBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
-				0,
-				VK_IMAGE_LAYOUT_UNDEFINED,
-				VK_PIPELINE_STAGE_TRANSFER_BIT,
-				VK_ACCESS_TRANSFER_WRITE_BIT,
-				VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
-				tex.m_imageHandle,
-				range);
+			setImageBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, VK_IMAGE_LAYOUT_UNDEFINED,
+							VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
+							VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, tex.m_imageHandle, range);
 		}
 		}
 
 
 		// Setup the blit struct
 		// Setup the blit struct
@@ -346,15 +334,10 @@ void CommandBufferImpl::generateMipmaps2d(TextureViewPtr texView)
 		blit.dstOffsets[0] = {0, 0, 0};
 		blit.dstOffsets[0] = {0, 0, 0};
 		blit.dstOffsets[1] = {dstWidth, dstHeight, 1};
 		blit.dstOffsets[1] = {dstWidth, dstHeight, 1};
 
 
-		ANKI_CMD(vkCmdBlitImage(m_handle,
-					 tex.m_imageHandle,
-					 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
-					 tex.m_imageHandle,
-					 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
-					 1,
-					 &blit,
-					 (!!aspect) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR),
-			ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdBlitImage(m_handle, tex.m_imageHandle, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, tex.m_imageHandle,
+								VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit,
+								(!!aspect) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 
 
 	// Hold the reference
 	// Hold the reference
@@ -373,41 +356,40 @@ void CommandBufferImpl::flushBarriers()
 
 
 	if(m_imgBarrierCount > 0)
 	if(m_imgBarrierCount > 0)
 	{
 	{
-		std::sort(&m_imgBarriers[0],
-			&m_imgBarriers[0] + m_imgBarrierCount,
-			[](const VkImageMemoryBarrier& a, const VkImageMemoryBarrier& b) -> Bool {
-				if(a.image != b.image)
-				{
-					return a.image < b.image;
-				}
-
-				if(a.subresourceRange.aspectMask != b.subresourceRange.aspectMask)
-				{
-					return a.subresourceRange.aspectMask < b.subresourceRange.aspectMask;
-				}
-
-				if(a.oldLayout != b.oldLayout)
-				{
-					return a.oldLayout < b.oldLayout;
-				}
-
-				if(a.newLayout != b.newLayout)
-				{
-					return a.newLayout < b.newLayout;
-				}
-
-				if(a.subresourceRange.baseArrayLayer != b.subresourceRange.baseArrayLayer)
-				{
-					return a.subresourceRange.baseArrayLayer < b.subresourceRange.baseArrayLayer;
-				}
-
-				if(a.subresourceRange.baseMipLevel != b.subresourceRange.baseMipLevel)
-				{
-					return a.subresourceRange.baseMipLevel < b.subresourceRange.baseMipLevel;
-				}
-
-				return false;
-			});
+		std::sort(&m_imgBarriers[0], &m_imgBarriers[0] + m_imgBarrierCount,
+				  [](const VkImageMemoryBarrier& a, const VkImageMemoryBarrier& b) -> Bool {
+					  if(a.image != b.image)
+					  {
+						  return a.image < b.image;
+					  }
+
+					  if(a.subresourceRange.aspectMask != b.subresourceRange.aspectMask)
+					  {
+						  return a.subresourceRange.aspectMask < b.subresourceRange.aspectMask;
+					  }
+
+					  if(a.oldLayout != b.oldLayout)
+					  {
+						  return a.oldLayout < b.oldLayout;
+					  }
+
+					  if(a.newLayout != b.newLayout)
+					  {
+						  return a.newLayout < b.newLayout;
+					  }
+
+					  if(a.subresourceRange.baseArrayLayer != b.subresourceRange.baseArrayLayer)
+					  {
+						  return a.subresourceRange.baseArrayLayer < b.subresourceRange.baseArrayLayer;
+					  }
+
+					  if(a.subresourceRange.baseMipLevel != b.subresourceRange.baseMipLevel)
+					  {
+						  return a.subresourceRange.baseMipLevel < b.subresourceRange.baseMipLevel;
+					  }
+
+					  return false;
+				  });
 	}
 	}
 
 
 	// Batch
 	// Batch
@@ -429,13 +411,13 @@ void CommandBufferImpl::flushBarriers()
 			const VkImageMemoryBarrier& crnt = m_imgBarriers[i];
 			const VkImageMemoryBarrier& crnt = m_imgBarriers[i];
 
 
 			if(prev && prev->image == crnt.image
 			if(prev && prev->image == crnt.image
-				&& prev->subresourceRange.aspectMask == crnt.subresourceRange.aspectMask
-				&& prev->oldLayout == crnt.oldLayout && prev->newLayout == crnt.newLayout
-				&& prev->srcAccessMask == crnt.srcAccessMask && prev->dstAccessMask == crnt.dstAccessMask
-				&& prev->subresourceRange.baseMipLevel + prev->subresourceRange.levelCount
-					   == crnt.subresourceRange.baseMipLevel
-				&& prev->subresourceRange.baseArrayLayer == crnt.subresourceRange.baseArrayLayer
-				&& prev->subresourceRange.layerCount == crnt.subresourceRange.layerCount)
+			   && prev->subresourceRange.aspectMask == crnt.subresourceRange.aspectMask
+			   && prev->oldLayout == crnt.oldLayout && prev->newLayout == crnt.newLayout
+			   && prev->srcAccessMask == crnt.srcAccessMask && prev->dstAccessMask == crnt.dstAccessMask
+			   && prev->subresourceRange.baseMipLevel + prev->subresourceRange.levelCount
+					  == crnt.subresourceRange.baseMipLevel
+			   && prev->subresourceRange.baseArrayLayer == crnt.subresourceRange.baseArrayLayer
+			   && prev->subresourceRange.layerCount == crnt.subresourceRange.layerCount)
 			{
 			{
 				// Can batch
 				// Can batch
 				squashedBarriers[squashedBarrierCount - 1].subresourceRange.levelCount +=
 				squashedBarriers[squashedBarrierCount - 1].subresourceRange.levelCount +=
@@ -459,13 +441,13 @@ void CommandBufferImpl::flushBarriers()
 			const VkImageMemoryBarrier& crnt = squashedBarriers[i];
 			const VkImageMemoryBarrier& crnt = squashedBarriers[i];
 
 
 			if(prev && prev->image == crnt.image
 			if(prev && prev->image == crnt.image
-				&& prev->subresourceRange.aspectMask == crnt.subresourceRange.aspectMask
-				&& prev->oldLayout == crnt.oldLayout && prev->newLayout == crnt.newLayout
-				&& prev->srcAccessMask == crnt.srcAccessMask && prev->dstAccessMask == crnt.dstAccessMask
-				&& prev->subresourceRange.baseMipLevel == crnt.subresourceRange.baseMipLevel
-				&& prev->subresourceRange.levelCount == crnt.subresourceRange.levelCount
-				&& prev->subresourceRange.baseArrayLayer + prev->subresourceRange.layerCount
-					   == crnt.subresourceRange.baseArrayLayer)
+			   && prev->subresourceRange.aspectMask == crnt.subresourceRange.aspectMask
+			   && prev->oldLayout == crnt.oldLayout && prev->newLayout == crnt.newLayout
+			   && prev->srcAccessMask == crnt.srcAccessMask && prev->dstAccessMask == crnt.dstAccessMask
+			   && prev->subresourceRange.baseMipLevel == crnt.subresourceRange.baseMipLevel
+			   && prev->subresourceRange.levelCount == crnt.subresourceRange.levelCount
+			   && prev->subresourceRange.baseArrayLayer + prev->subresourceRange.layerCount
+					  == crnt.subresourceRange.baseArrayLayer)
 			{
 			{
 				// Can batch
 				// Can batch
 				finalImgBarriers[finalImgBarrierCount - 1].subresourceRange.layerCount +=
 				finalImgBarriers[finalImgBarrierCount - 1].subresourceRange.layerCount +=
@@ -483,16 +465,10 @@ void CommandBufferImpl::flushBarriers()
 
 
 	// Finish the job
 	// Finish the job
 	//
 	//
-	vkCmdPipelineBarrier(m_handle,
-		m_srcStageMask,
-		m_dstStageMask,
-		0,
-		m_memBarrierCount,
-		(m_memBarrierCount) ? &m_memBarriers[0] : nullptr,
-		m_buffBarrierCount,
-		(m_buffBarrierCount) ? &m_buffBarriers[0] : nullptr,
-		finalImgBarrierCount,
-		(finalImgBarrierCount) ? &finalImgBarriers[0] : nullptr);
+	vkCmdPipelineBarrier(m_handle, m_srcStageMask, m_dstStageMask, 0, m_memBarrierCount,
+						 (m_memBarrierCount) ? &m_memBarriers[0] : nullptr, m_buffBarrierCount,
+						 (m_buffBarrierCount) ? &m_buffBarriers[0] : nullptr, finalImgBarrierCount,
+						 (finalImgBarrierCount) ? &finalImgBarriers[0] : nullptr);
 
 
 	ANKI_TRACE_INC_COUNTER(VK_PIPELINE_BARRIERS, 1);
 	ANKI_TRACE_INC_COUNTER(VK_PIPELINE_BARRIERS, 1);
 
 
@@ -510,17 +486,16 @@ void CommandBufferImpl::flushQueryResets()
 		return;
 		return;
 	}
 	}
 
 
-	std::sort(m_queryResetAtoms.getBegin(),
-		m_queryResetAtoms.getEnd(),
-		[](const QueryResetAtom& a, const QueryResetAtom& b) -> Bool {
-			if(a.m_pool != b.m_pool)
-			{
-				return a.m_pool < b.m_pool;
-			}
+	std::sort(m_queryResetAtoms.getBegin(), m_queryResetAtoms.getEnd(),
+			  [](const QueryResetAtom& a, const QueryResetAtom& b) -> Bool {
+				  if(a.m_pool != b.m_pool)
+				  {
+					  return a.m_pool < b.m_pool;
+				  }
 
 
-			ANKI_ASSERT(a.m_queryIdx != b.m_queryIdx && "Tried to reset the same query more than once");
-			return a.m_queryIdx < b.m_queryIdx;
-		});
+				  ANKI_ASSERT(a.m_queryIdx != b.m_queryIdx && "Tried to reset the same query more than once");
+				  return a.m_queryIdx < b.m_queryIdx;
+			  });
 
 
 	U32 firstQuery = m_queryResetAtoms[0].m_queryIdx;
 	U32 firstQuery = m_queryResetAtoms[0].m_queryIdx;
 	U32 queryCount = 1;
 	U32 queryCount = 1;
@@ -559,27 +534,26 @@ void CommandBufferImpl::flushWriteQueryResults()
 		return;
 		return;
 	}
 	}
 
 
-	std::sort(&m_writeQueryAtoms[0],
-		&m_writeQueryAtoms[0] + m_writeQueryAtoms.getSize(),
-		[](const WriteQueryAtom& a, const WriteQueryAtom& b) -> Bool {
-			if(a.m_pool != b.m_pool)
-			{
-				return a.m_pool < b.m_pool;
-			}
+	std::sort(&m_writeQueryAtoms[0], &m_writeQueryAtoms[0] + m_writeQueryAtoms.getSize(),
+			  [](const WriteQueryAtom& a, const WriteQueryAtom& b) -> Bool {
+				  if(a.m_pool != b.m_pool)
+				  {
+					  return a.m_pool < b.m_pool;
+				  }
 
 
-			if(a.m_buffer != b.m_buffer)
-			{
-				return a.m_buffer < b.m_buffer;
-			}
+				  if(a.m_buffer != b.m_buffer)
+				  {
+					  return a.m_buffer < b.m_buffer;
+				  }
 
 
-			if(a.m_offset != b.m_offset)
-			{
-				return a.m_offset < b.m_offset;
-			}
+				  if(a.m_offset != b.m_offset)
+				  {
+					  return a.m_offset < b.m_offset;
+				  }
 
 
-			ANKI_ASSERT(a.m_queryIdx != b.m_queryIdx && "Tried to write the same query more than once");
-			return a.m_queryIdx < b.m_queryIdx;
-		});
+				  ANKI_ASSERT(a.m_queryIdx != b.m_queryIdx && "Tried to write the same query more than once");
+				  return a.m_queryIdx < b.m_queryIdx;
+			  });
 
 
 	U32 firstQuery = m_writeQueryAtoms[0].m_queryIdx;
 	U32 firstQuery = m_writeQueryAtoms[0].m_queryIdx;
 	U32 queryCount = 1;
 	U32 queryCount = 1;
@@ -592,7 +566,7 @@ void CommandBufferImpl::flushWriteQueryResults()
 		const WriteQueryAtom& prev = m_writeQueryAtoms[i - 1];
 		const WriteQueryAtom& prev = m_writeQueryAtoms[i - 1];
 
 
 		if(crnt.m_pool == prev.m_pool && crnt.m_buffer == prev.m_buffer && prev.m_queryIdx + 1 == crnt.m_queryIdx
 		if(crnt.m_pool == prev.m_pool && crnt.m_buffer == prev.m_buffer && prev.m_queryIdx + 1 == crnt.m_queryIdx
-			&& prev.m_offset + sizeof(U32) == crnt.m_offset)
+		   && prev.m_offset + sizeof(U32) == crnt.m_offset)
 		{
 		{
 			// Can batch
 			// Can batch
 			++queryCount;
 			++queryCount;
@@ -600,8 +574,8 @@ void CommandBufferImpl::flushWriteQueryResults()
 		else
 		else
 		{
 		{
 			// Flush batch
 			// Flush batch
-			vkCmdCopyQueryPoolResults(
-				m_handle, pool, firstQuery, queryCount, buff, offset, sizeof(U32), VK_QUERY_RESULT_PARTIAL_BIT);
+			vkCmdCopyQueryPoolResults(m_handle, pool, firstQuery, queryCount, buff, offset, sizeof(U32),
+									  VK_QUERY_RESULT_PARTIAL_BIT);
 
 
 			// New batch
 			// New batch
 			firstQuery = crnt.m_queryIdx;
 			firstQuery = crnt.m_queryIdx;
@@ -611,14 +585,14 @@ void CommandBufferImpl::flushWriteQueryResults()
 		}
 		}
 	}
 	}
 
 
-	vkCmdCopyQueryPoolResults(
-		m_handle, pool, firstQuery, queryCount, buff, offset, sizeof(U32), VK_QUERY_RESULT_PARTIAL_BIT);
+	vkCmdCopyQueryPoolResults(m_handle, pool, firstQuery, queryCount, buff, offset, sizeof(U32),
+							  VK_QUERY_RESULT_PARTIAL_BIT);
 
 
 	m_writeQueryAtoms.resize(m_alloc, 0);
 	m_writeQueryAtoms.resize(m_alloc, 0);
 }
 }
 
 
-void CommandBufferImpl::copyBufferToTextureViewInternal(
-	BufferPtr buff, PtrSize offset, PtrSize range, TextureViewPtr texView)
+void CommandBufferImpl::copyBufferToTextureViewInternal(BufferPtr buff, PtrSize offset, PtrSize range,
+														TextureViewPtr texView)
 {
 {
 	commandCommon();
 	commandCommon();
 
 
@@ -630,8 +604,8 @@ void CommandBufferImpl::copyBufferToTextureViewInternal(
 	const Bool is3D = tex.getTextureType() == TextureType::_3D;
 	const Bool is3D = tex.getTextureType() == TextureType::_3D;
 	const VkImageAspectFlags aspect = convertImageAspect(view.getSubresource().m_depthStencilAspect);
 	const VkImageAspectFlags aspect = convertImageAspect(view.getSubresource().m_depthStencilAspect);
 
 
-	const TextureSurfaceInfo surf(
-		view.getSubresource().m_firstMipmap, view.getSubresource().m_firstFace, 0, view.getSubresource().m_firstLayer);
+	const TextureSurfaceInfo surf(view.getSubresource().m_firstMipmap, view.getSubresource().m_firstFace, 0,
+								  view.getSubresource().m_firstLayer);
 	const TextureVolumeInfo vol(view.getSubresource().m_firstMipmap);
 	const TextureVolumeInfo vol(view.getSubresource().m_firstMipmap);
 
 
 	// Compute the sizes of the mip
 	// Compute the sizes of the mip
@@ -665,10 +639,9 @@ void CommandBufferImpl::copyBufferToTextureViewInternal(
 		region.bufferImageHeight = 0;
 		region.bufferImageHeight = 0;
 		region.bufferRowLength = 0;
 		region.bufferRowLength = 0;
 
 
-		ANKI_CMD(
-			vkCmdCopyBufferToImage(
-				m_handle, static_cast<const BufferImpl&>(*buff).getHandle(), tex.m_imageHandle, layout, 1, &region),
-			ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdCopyBufferToImage(m_handle, static_cast<const BufferImpl&>(*buff).getHandle(), tex.m_imageHandle,
+										layout, 1, &region),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 	else if(!!(tex.m_workarounds & TextureImplWorkaround::R8G8B8_TO_R8G8B8A8))
 	else if(!!(tex.m_workarounds & TextureImplWorkaround::R8G8B8_TO_R8G8B8A8))
 	{
 	{
@@ -719,22 +692,14 @@ void CommandBufferImpl::copyBufferToTextureViewInternal(
 			}
 			}
 
 
 			// Do the copy to the shadow buffer
 			// Do the copy to the shadow buffer
-			ANKI_CMD(vkCmdCopyBuffer(m_handle,
-						 static_cast<const BufferImpl&>(*buff).getHandle(),
-						 shadowHandle,
-						 regions.getSize(),
-						 &regions[0]),
-				ANY_OTHER_COMMAND);
+			ANKI_CMD(vkCmdCopyBuffer(m_handle, static_cast<const BufferImpl&>(*buff).getHandle(), shadowHandle,
+									 regions.getSize(), &regions[0]),
+					 ANY_OTHER_COMMAND);
 		}
 		}
 
 
 		// Set barrier
 		// Set barrier
-		setBufferBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
-			VK_ACCESS_TRANSFER_WRITE_BIT,
-			VK_PIPELINE_STAGE_TRANSFER_BIT,
-			VK_ACCESS_TRANSFER_READ_BIT,
-			0,
-			shadowSize,
-			shadowHandle);
+		setBufferBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
+						 VK_ACCESS_TRANSFER_READ_BIT, 0, shadowSize, shadowHandle);
 
 
 		// Do the copy to the image
 		// Do the copy to the image
 		VkBufferImageCopy region;
 		VkBufferImageCopy region;
@@ -750,8 +715,8 @@ void CommandBufferImpl::copyBufferToTextureViewInternal(
 		region.bufferImageHeight = 0;
 		region.bufferImageHeight = 0;
 		region.bufferRowLength = 0;
 		region.bufferRowLength = 0;
 
 
-		ANKI_CMD(
-			vkCmdCopyBufferToImage(m_handle, shadowHandle, tex.m_imageHandle, layout, 1, &region), ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdCopyBufferToImage(m_handle, shadowHandle, tex.m_imageHandle, layout, 1, &region),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 	else
 	else
 	{
 	{
@@ -772,46 +737,46 @@ void CommandBufferImpl::rebindDynamicState()
 	// Rebind the stencil compare mask
 	// Rebind the stencil compare mask
 	if(m_stencilCompareMasks[0] == m_stencilCompareMasks[1])
 	if(m_stencilCompareMasks[0] == m_stencilCompareMasks[1])
 	{
 	{
-		ANKI_CMD(vkCmdSetStencilCompareMask(
-					 m_handle, VK_STENCIL_FACE_FRONT_BIT | VK_STENCIL_FACE_BACK_BIT, m_stencilCompareMasks[0]),
-			ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdSetStencilCompareMask(m_handle, VK_STENCIL_FACE_FRONT_BIT | VK_STENCIL_FACE_BACK_BIT,
+											m_stencilCompareMasks[0]),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 	else
 	else
 	{
 	{
 		ANKI_CMD(vkCmdSetStencilCompareMask(m_handle, VK_STENCIL_FACE_FRONT_BIT, m_stencilCompareMasks[0]),
 		ANKI_CMD(vkCmdSetStencilCompareMask(m_handle, VK_STENCIL_FACE_FRONT_BIT, m_stencilCompareMasks[0]),
-			ANY_OTHER_COMMAND);
+				 ANY_OTHER_COMMAND);
 		ANKI_CMD(vkCmdSetStencilCompareMask(m_handle, VK_STENCIL_FACE_BACK_BIT, m_stencilCompareMasks[1]),
 		ANKI_CMD(vkCmdSetStencilCompareMask(m_handle, VK_STENCIL_FACE_BACK_BIT, m_stencilCompareMasks[1]),
-			ANY_OTHER_COMMAND);
+				 ANY_OTHER_COMMAND);
 	}
 	}
 
 
 	// Rebind the stencil write mask
 	// Rebind the stencil write mask
 	if(m_stencilWriteMasks[0] == m_stencilWriteMasks[1])
 	if(m_stencilWriteMasks[0] == m_stencilWriteMasks[1])
 	{
 	{
-		ANKI_CMD(vkCmdSetStencilWriteMask(
-					 m_handle, VK_STENCIL_FACE_FRONT_BIT | VK_STENCIL_FACE_BACK_BIT, m_stencilWriteMasks[0]),
-			ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdSetStencilWriteMask(m_handle, VK_STENCIL_FACE_FRONT_BIT | VK_STENCIL_FACE_BACK_BIT,
+										  m_stencilWriteMasks[0]),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 	else
 	else
 	{
 	{
-		ANKI_CMD(
-			vkCmdSetStencilWriteMask(m_handle, VK_STENCIL_FACE_FRONT_BIT, m_stencilWriteMasks[0]), ANY_OTHER_COMMAND);
-		ANKI_CMD(
-			vkCmdSetStencilWriteMask(m_handle, VK_STENCIL_FACE_BACK_BIT, m_stencilWriteMasks[1]), ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdSetStencilWriteMask(m_handle, VK_STENCIL_FACE_FRONT_BIT, m_stencilWriteMasks[0]),
+				 ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdSetStencilWriteMask(m_handle, VK_STENCIL_FACE_BACK_BIT, m_stencilWriteMasks[1]),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 
 
 	// Rebind the stencil reference
 	// Rebind the stencil reference
 	if(m_stencilReferenceMasks[0] == m_stencilReferenceMasks[1])
 	if(m_stencilReferenceMasks[0] == m_stencilReferenceMasks[1])
 	{
 	{
-		ANKI_CMD(vkCmdSetStencilReference(
-					 m_handle, VK_STENCIL_FACE_FRONT_BIT | VK_STENCIL_FACE_BACK_BIT, m_stencilReferenceMasks[0]),
-			ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdSetStencilReference(m_handle, VK_STENCIL_FACE_FRONT_BIT | VK_STENCIL_FACE_BACK_BIT,
+										  m_stencilReferenceMasks[0]),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 	else
 	else
 	{
 	{
 		ANKI_CMD(vkCmdSetStencilReference(m_handle, VK_STENCIL_FACE_FRONT_BIT, m_stencilReferenceMasks[0]),
 		ANKI_CMD(vkCmdSetStencilReference(m_handle, VK_STENCIL_FACE_FRONT_BIT, m_stencilReferenceMasks[0]),
-			ANY_OTHER_COMMAND);
+				 ANY_OTHER_COMMAND);
 		ANKI_CMD(vkCmdSetStencilReference(m_handle, VK_STENCIL_FACE_BACK_BIT, m_stencilReferenceMasks[1]),
 		ANKI_CMD(vkCmdSetStencilReference(m_handle, VK_STENCIL_FACE_BACK_BIT, m_stencilReferenceMasks[1]),
-			ANY_OTHER_COMMAND);
+				 ANY_OTHER_COMMAND);
 	}
 	}
 }
 }
 
 

+ 26 - 45
src/anki/gr/vulkan/CommandBufferImpl.h

@@ -101,9 +101,9 @@ public:
 	void bindIndexBuffer(BufferPtr buff, PtrSize offset, IndexType type)
 	void bindIndexBuffer(BufferPtr buff, PtrSize offset, IndexType type)
 	{
 	{
 		commandCommon();
 		commandCommon();
-		ANKI_CMD(vkCmdBindIndexBuffer(
-					 m_handle, static_cast<const BufferImpl&>(*buff).getHandle(), offset, convertIndexType(type)),
-			ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdBindIndexBuffer(m_handle, static_cast<const BufferImpl&>(*buff).getHandle(), offset,
+									  convertIndexType(type)),
+				 ANY_OTHER_COMMAND);
 		m_microCmdb->pushObjectRef(buff);
 		m_microCmdb->pushObjectRef(buff);
 	}
 	}
 
 
@@ -163,10 +163,8 @@ public:
 		m_state.setPolygonOffset(factor, units);
 		m_state.setPolygonOffset(factor, units);
 	}
 	}
 
 
-	void setStencilOperations(FaceSelectionBit face,
-		StencilOperation stencilFail,
-		StencilOperation stencilPassDepthFail,
-		StencilOperation stencilPassDepthPass)
+	void setStencilOperations(FaceSelectionBit face, StencilOperation stencilFail,
+							  StencilOperation stencilPassDepthFail, StencilOperation stencilPassDepthPass)
 	{
 	{
 		commandCommon();
 		commandCommon();
 		m_state.setStencilOperations(face, stencilFail, stencilPassDepthFail, stencilPassDepthPass);
 		m_state.setStencilOperations(face, stencilFail, stencilPassDepthFail, stencilPassDepthPass);
@@ -220,8 +218,8 @@ public:
 		m_state.setBlendOperation(attachment, funcRgb, funcA);
 		m_state.setBlendOperation(attachment, funcRgb, funcA);
 	}
 	}
 
 
-	void bindTextureAndSamplerInternal(
-		U32 set, U32 binding, TextureViewPtr& texView, SamplerPtr sampler, TextureUsageBit usage, U32 arrayIdx)
+	void bindTextureAndSamplerInternal(U32 set, U32 binding, TextureViewPtr& texView, SamplerPtr sampler,
+									   TextureUsageBit usage, U32 arrayIdx)
 	{
 	{
 		commandCommon();
 		commandCommon();
 		const TextureViewImpl& view = static_cast<const TextureViewImpl&>(*texView);
 		const TextureViewImpl& view = static_cast<const TextureViewImpl&>(*texView);
@@ -292,20 +290,15 @@ public:
 		return idx;
 		return idx;
 	}
 	}
 
 
-	void beginRenderPass(FramebufferPtr fb,
-		const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
-		TextureUsageBit depthStencilAttachmentUsage,
-		U32 minx,
-		U32 miny,
-		U32 width,
-		U32 height);
+	void beginRenderPass(FramebufferPtr fb, const Array<TextureUsageBit, MAX_COLOR_ATTACHMENTS>& colorAttachmentUsages,
+						 TextureUsageBit depthStencilAttachmentUsage, U32 minx, U32 miny, U32 width, U32 height);
 
 
 	void endRenderPass();
 	void endRenderPass();
 
 
 	void drawArrays(PrimitiveTopology topology, U32 count, U32 instanceCount, U32 first, U32 baseInstance);
 	void drawArrays(PrimitiveTopology topology, U32 count, U32 instanceCount, U32 first, U32 baseInstance);
 
 
-	void drawElements(
-		PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex, U32 baseVertex, U32 baseInstance);
+	void drawElements(PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex, U32 baseVertex,
+					  U32 baseInstance);
 
 
 	void drawArraysIndirect(PrimitiveTopology topology, U32 drawCount, PtrSize offset, BufferPtr& buff);
 	void drawArraysIndirect(PrimitiveTopology topology, U32 drawCount, PtrSize offset, BufferPtr& buff);
 
 
@@ -331,32 +324,25 @@ public:
 
 
 	void endRecording();
 	void endRecording();
 
 
-	void setTextureBarrier(TexturePtr tex,
-		TextureUsageBit prevUsage,
-		TextureUsageBit nextUsage,
-		const TextureSubresourceInfo& subresource);
+	void setTextureBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+						   const TextureSubresourceInfo& subresource);
 
 
-	void setTextureSurfaceBarrier(
-		TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSurfaceInfo& surf);
+	void setTextureSurfaceBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+								  const TextureSurfaceInfo& surf);
 
 
-	void setTextureVolumeBarrier(
-		TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureVolumeInfo& vol);
+	void setTextureVolumeBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+								 const TextureVolumeInfo& vol);
 
 
-	void setTextureBarrierRange(
-		TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const VkImageSubresourceRange& range);
+	void setTextureBarrierRange(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+								const VkImageSubresourceRange& range);
 
 
-	void setBufferBarrier(VkPipelineStageFlags srcStage,
-		VkAccessFlags srcAccess,
-		VkPipelineStageFlags dstStage,
-		VkAccessFlags dstAccess,
-		PtrSize offset,
-		PtrSize size,
-		VkBuffer buff);
+	void setBufferBarrier(VkPipelineStageFlags srcStage, VkAccessFlags srcAccess, VkPipelineStageFlags dstStage,
+						  VkAccessFlags dstAccess, PtrSize offset, PtrSize size, VkBuffer buff);
 
 
 	void setBufferBarrier(BufferPtr& buff, BufferUsageBit before, BufferUsageBit after, PtrSize offset, PtrSize size);
 	void setBufferBarrier(BufferPtr& buff, BufferUsageBit before, BufferUsageBit after, PtrSize offset, PtrSize size);
 
 
-	void setAccelerationStructureBarrierInternal(
-		AccelerationStructurePtr& as, AccelerationStructureUsageBit prevUsage, AccelerationStructureUsageBit nextUsage);
+	void setAccelerationStructureBarrierInternal(AccelerationStructurePtr& as, AccelerationStructureUsageBit prevUsage,
+												 AccelerationStructureUsageBit nextUsage);
 
 
 	void fillBuffer(BufferPtr buff, PtrSize offset, PtrSize size, U32 value);
 	void fillBuffer(BufferPtr buff, PtrSize offset, PtrSize size, U32 value);
 
 
@@ -516,14 +502,9 @@ private:
 
 
 	void flushWriteQueryResults();
 	void flushWriteQueryResults();
 
 
-	void setImageBarrier(VkPipelineStageFlags srcStage,
-		VkAccessFlags srcAccess,
-		VkImageLayout prevLayout,
-		VkPipelineStageFlags dstStage,
-		VkAccessFlags dstAccess,
-		VkImageLayout newLayout,
-		VkImage img,
-		const VkImageSubresourceRange& range);
+	void setImageBarrier(VkPipelineStageFlags srcStage, VkAccessFlags srcAccess, VkImageLayout prevLayout,
+						 VkPipelineStageFlags dstStage, VkAccessFlags dstAccess, VkImageLayout newLayout, VkImage img,
+						 const VkImageSubresourceRange& range);
 
 
 	void beginRecording();
 	void beginRecording();
 
 

+ 55 - 81
src/anki/gr/vulkan/CommandBufferImpl.inl.h

@@ -86,14 +86,10 @@ inline void CommandBufferImpl::setStencilReference(FaceSelectionBit face, U32 re
 	}
 	}
 }
 }
 
 
-inline void CommandBufferImpl::setImageBarrier(VkPipelineStageFlags srcStage,
-	VkAccessFlags srcAccess,
-	VkImageLayout prevLayout,
-	VkPipelineStageFlags dstStage,
-	VkAccessFlags dstAccess,
-	VkImageLayout newLayout,
-	VkImage img,
-	const VkImageSubresourceRange& range)
+inline void CommandBufferImpl::setImageBarrier(VkPipelineStageFlags srcStage, VkAccessFlags srcAccess,
+											   VkImageLayout prevLayout, VkPipelineStageFlags dstStage,
+											   VkAccessFlags dstAccess, VkImageLayout newLayout, VkImage img,
+											   const VkImageSubresourceRange& range)
 {
 {
 	ANKI_ASSERT(img);
 	ANKI_ASSERT(img);
 	commandCommon();
 	commandCommon();
@@ -127,8 +123,8 @@ inline void CommandBufferImpl::setImageBarrier(VkPipelineStageFlags srcStage,
 #endif
 #endif
 }
 }
 
 
-inline void CommandBufferImpl::setTextureBarrierRange(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const VkImageSubresourceRange& range)
+inline void CommandBufferImpl::setTextureBarrierRange(TexturePtr tex, TextureUsageBit prevUsage,
+													  TextureUsageBit nextUsage, const VkImageSubresourceRange& range)
 {
 {
 	const TextureImpl& impl = static_cast<const TextureImpl&>(*tex);
 	const TextureImpl& impl = static_cast<const TextureImpl&>(*tex);
 	ANKI_ASSERT(impl.usageValid(prevUsage));
 	ANKI_ASSERT(impl.usageValid(prevUsage));
@@ -149,8 +145,8 @@ inline void CommandBufferImpl::setTextureBarrierRange(
 	m_microCmdb->pushObjectRef(tex);
 	m_microCmdb->pushObjectRef(tex);
 }
 }
 
 
-inline void CommandBufferImpl::setTextureBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSubresourceInfo& subresource_)
+inline void CommandBufferImpl::setTextureBarrier(TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage,
+												 const TextureSubresourceInfo& subresource_)
 {
 {
 	TextureSubresourceInfo subresource = subresource_;
 	TextureSubresourceInfo subresource = subresource_;
 	const TextureImpl& impl = static_cast<const TextureImpl&>(*tex);
 	const TextureImpl& impl = static_cast<const TextureImpl&>(*tex);
@@ -172,8 +168,8 @@ inline void CommandBufferImpl::setTextureBarrier(
 	setTextureBarrierRange(tex, prevUsage, nextUsage, range);
 	setTextureBarrierRange(tex, prevUsage, nextUsage, range);
 }
 }
 
 
-inline void CommandBufferImpl::setTextureSurfaceBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureSurfaceInfo& surf)
+inline void CommandBufferImpl::setTextureSurfaceBarrier(TexturePtr tex, TextureUsageBit prevUsage,
+														TextureUsageBit nextUsage, const TextureSurfaceInfo& surf)
 {
 {
 	if(ANKI_UNLIKELY(surf.m_level > 0 && nextUsage == TextureUsageBit::GENERATE_MIPMAPS))
 	if(ANKI_UNLIKELY(surf.m_level > 0 && nextUsage == TextureUsageBit::GENERATE_MIPMAPS))
 	{
 	{
@@ -188,8 +184,8 @@ inline void CommandBufferImpl::setTextureSurfaceBarrier(
 	setTextureBarrierRange(tex, prevUsage, nextUsage, range);
 	setTextureBarrierRange(tex, prevUsage, nextUsage, range);
 }
 }
 
 
-inline void CommandBufferImpl::setTextureVolumeBarrier(
-	TexturePtr tex, TextureUsageBit prevUsage, TextureUsageBit nextUsage, const TextureVolumeInfo& vol)
+inline void CommandBufferImpl::setTextureVolumeBarrier(TexturePtr tex, TextureUsageBit prevUsage,
+													   TextureUsageBit nextUsage, const TextureVolumeInfo& vol)
 {
 {
 	if(vol.m_level > 0)
 	if(vol.m_level > 0)
 	{
 	{
@@ -204,13 +200,9 @@ inline void CommandBufferImpl::setTextureVolumeBarrier(
 	setTextureBarrierRange(tex, prevUsage, nextUsage, range);
 	setTextureBarrierRange(tex, prevUsage, nextUsage, range);
 }
 }
 
 
-inline void CommandBufferImpl::setBufferBarrier(VkPipelineStageFlags srcStage,
-	VkAccessFlags srcAccess,
-	VkPipelineStageFlags dstStage,
-	VkAccessFlags dstAccess,
-	PtrSize offset,
-	PtrSize size,
-	VkBuffer buff)
+inline void CommandBufferImpl::setBufferBarrier(VkPipelineStageFlags srcStage, VkAccessFlags srcAccess,
+												VkPipelineStageFlags dstStage, VkAccessFlags dstAccess, PtrSize offset,
+												PtrSize size, VkBuffer buff)
 {
 {
 	ANKI_ASSERT(buff);
 	ANKI_ASSERT(buff);
 	commandCommon();
 	commandCommon();
@@ -243,8 +235,8 @@ inline void CommandBufferImpl::setBufferBarrier(VkPipelineStageFlags srcStage,
 #endif
 #endif
 }
 }
 
 
-inline void CommandBufferImpl::setBufferBarrier(
-	BufferPtr& buff, BufferUsageBit before, BufferUsageBit after, PtrSize offset, PtrSize size)
+inline void CommandBufferImpl::setBufferBarrier(BufferPtr& buff, BufferUsageBit before, BufferUsageBit after,
+												PtrSize offset, PtrSize size)
 {
 {
 	const BufferImpl& impl = static_cast<const BufferImpl&>(*buff);
 	const BufferImpl& impl = static_cast<const BufferImpl&>(*buff);
 
 
@@ -259,8 +251,9 @@ inline void CommandBufferImpl::setBufferBarrier(
 	m_microCmdb->pushObjectRef(buff);
 	m_microCmdb->pushObjectRef(buff);
 }
 }
 
 
-inline void CommandBufferImpl::setAccelerationStructureBarrierInternal(
-	AccelerationStructurePtr& as, AccelerationStructureUsageBit prevUsage, AccelerationStructureUsageBit nextUsage)
+inline void CommandBufferImpl::setAccelerationStructureBarrierInternal(AccelerationStructurePtr& as,
+																	   AccelerationStructureUsageBit prevUsage,
+																	   AccelerationStructureUsageBit nextUsage)
 {
 {
 	commandCommon();
 	commandCommon();
 
 
@@ -292,24 +285,24 @@ inline void CommandBufferImpl::setAccelerationStructureBarrierInternal(
 #endif
 #endif
 }
 }
 
 
-inline void CommandBufferImpl::drawArrays(
-	PrimitiveTopology topology, U32 count, U32 instanceCount, U32 first, U32 baseInstance)
+inline void CommandBufferImpl::drawArrays(PrimitiveTopology topology, U32 count, U32 instanceCount, U32 first,
+										  U32 baseInstance)
 {
 {
 	m_state.setPrimitiveTopology(topology);
 	m_state.setPrimitiveTopology(topology);
 	drawcallCommon();
 	drawcallCommon();
 	ANKI_CMD(vkCmdDraw(m_handle, count, instanceCount, first, baseInstance), ANY_OTHER_COMMAND);
 	ANKI_CMD(vkCmdDraw(m_handle, count, instanceCount, first, baseInstance), ANY_OTHER_COMMAND);
 }
 }
 
 
-inline void CommandBufferImpl::drawElements(
-	PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex, U32 baseVertex, U32 baseInstance)
+inline void CommandBufferImpl::drawElements(PrimitiveTopology topology, U32 count, U32 instanceCount, U32 firstIndex,
+											U32 baseVertex, U32 baseInstance)
 {
 {
 	m_state.setPrimitiveTopology(topology);
 	m_state.setPrimitiveTopology(topology);
 	drawcallCommon();
 	drawcallCommon();
 	ANKI_CMD(vkCmdDrawIndexed(m_handle, count, instanceCount, firstIndex, baseVertex, baseInstance), ANY_OTHER_COMMAND);
 	ANKI_CMD(vkCmdDrawIndexed(m_handle, count, instanceCount, firstIndex, baseVertex, baseInstance), ANY_OTHER_COMMAND);
 }
 }
 
 
-inline void CommandBufferImpl::drawArraysIndirect(
-	PrimitiveTopology topology, U32 drawCount, PtrSize offset, BufferPtr& buff)
+inline void CommandBufferImpl::drawArraysIndirect(PrimitiveTopology topology, U32 drawCount, PtrSize offset,
+												  BufferPtr& buff)
 {
 {
 	m_state.setPrimitiveTopology(topology);
 	m_state.setPrimitiveTopology(topology);
 	drawcallCommon();
 	drawcallCommon();
@@ -319,11 +312,11 @@ inline void CommandBufferImpl::drawArraysIndirect(
 	ANKI_ASSERT((offset + sizeof(DrawArraysIndirectInfo) * drawCount) <= impl.getSize());
 	ANKI_ASSERT((offset + sizeof(DrawArraysIndirectInfo) * drawCount) <= impl.getSize());
 
 
 	ANKI_CMD(vkCmdDrawIndirect(m_handle, impl.getHandle(), offset, drawCount, sizeof(DrawArraysIndirectInfo)),
 	ANKI_CMD(vkCmdDrawIndirect(m_handle, impl.getHandle(), offset, drawCount, sizeof(DrawArraysIndirectInfo)),
-		ANY_OTHER_COMMAND);
+			 ANY_OTHER_COMMAND);
 }
 }
 
 
-inline void CommandBufferImpl::drawElementsIndirect(
-	PrimitiveTopology topology, U32 drawCount, PtrSize offset, BufferPtr& buff)
+inline void CommandBufferImpl::drawElementsIndirect(PrimitiveTopology topology, U32 drawCount, PtrSize offset,
+													BufferPtr& buff)
 {
 {
 	m_state.setPrimitiveTopology(topology);
 	m_state.setPrimitiveTopology(topology);
 	drawcallCommon();
 	drawcallCommon();
@@ -333,7 +326,7 @@ inline void CommandBufferImpl::drawElementsIndirect(
 	ANKI_ASSERT((offset + sizeof(DrawElementsIndirectInfo) * drawCount) <= impl.getSize());
 	ANKI_ASSERT((offset + sizeof(DrawElementsIndirectInfo) * drawCount) <= impl.getSize());
 
 
 	ANKI_CMD(vkCmdDrawIndexedIndirect(m_handle, impl.getHandle(), offset, drawCount, sizeof(DrawElementsIndirectInfo)),
 	ANKI_CMD(vkCmdDrawIndexedIndirect(m_handle, impl.getHandle(), offset, drawCount, sizeof(DrawElementsIndirectInfo)),
-		ANY_OTHER_COMMAND);
+			 ANY_OTHER_COMMAND);
 }
 }
 
 
 inline void CommandBufferImpl::dispatchCompute(U32 groupCountX, U32 groupCountY, U32 groupCountZ)
 inline void CommandBufferImpl::dispatchCompute(U32 groupCountX, U32 groupCountY, U32 groupCountZ)
@@ -371,15 +364,10 @@ inline void CommandBufferImpl::dispatchCompute(U32 groupCountX, U32 groupCountY,
 
 
 				VkDescriptorSet dsHandle = dset.getHandle();
 				VkDescriptorSet dsHandle = dset.getHandle();
 
 
-				ANKI_CMD(vkCmdBindDescriptorSets(m_handle,
-							 VK_PIPELINE_BIND_POINT_COMPUTE,
-							 m_computeProg->getPipelineLayout().getHandle(),
-							 i,
-							 1,
-							 &dsHandle,
-							 dynamicOffsetCount,
-							 &dynamicOffsets[0]),
-					ANY_OTHER_COMMAND);
+				ANKI_CMD(vkCmdBindDescriptorSets(m_handle, VK_PIPELINE_BIND_POINT_COMPUTE,
+												 m_computeProg->getPipelineLayout().getHandle(), i, 1, &dsHandle,
+												 dynamicOffsetCount, &dynamicOffsets[0]),
+						 ANY_OTHER_COMMAND);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -483,9 +471,9 @@ inline void CommandBufferImpl::clearTextureView(TextureViewPtr texView, const Cl
 	if(!view.getSubresource().m_depthStencilAspect)
 	if(!view.getSubresource().m_depthStencilAspect)
 	{
 	{
 		VkImageSubresourceRange vkRange = view.getVkImageSubresourceRange();
 		VkImageSubresourceRange vkRange = view.getVkImageSubresourceRange();
-		ANKI_CMD(vkCmdClearColorImage(
-					 m_handle, tex.m_imageHandle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &vclear, 1, &vkRange),
-			ANY_OTHER_COMMAND);
+		ANKI_CMD(vkCmdClearColorImage(m_handle, tex.m_imageHandle, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &vclear, 1,
+									  &vkRange),
+				 ANY_OTHER_COMMAND);
 	}
 	}
 	else
 	else
 	{
 	{
@@ -521,8 +509,8 @@ inline void CommandBufferImpl::pushSecondLevelCommandBuffer(CommandBufferPtr cmd
 
 
 	m_secondLevelAtoms[m_secondLevelAtomCount++] = static_cast<const CommandBufferImpl&>(*cmdb).m_handle;
 	m_secondLevelAtoms[m_secondLevelAtomCount++] = static_cast<const CommandBufferImpl&>(*cmdb).m_handle;
 #else
 #else
-	ANKI_CMD(
-		vkCmdExecuteCommands(m_handle, 1, &static_cast<const CommandBufferImpl&>(*cmdb).m_handle), ANY_OTHER_COMMAND);
+	ANKI_CMD(vkCmdExecuteCommands(m_handle, 1, &static_cast<const CommandBufferImpl&>(*cmdb).m_handle),
+			 ANY_OTHER_COMMAND);
 #endif
 #endif
 
 
 	++m_rpCommandCount;
 	++m_rpCommandCount;
@@ -584,15 +572,10 @@ inline void CommandBufferImpl::drawcallCommon()
 
 
 				VkDescriptorSet dsHandle = dset.getHandle();
 				VkDescriptorSet dsHandle = dset.getHandle();
 
 
-				ANKI_CMD(vkCmdBindDescriptorSets(m_handle,
-							 VK_PIPELINE_BIND_POINT_GRAPHICS,
-							 m_graphicsProg->getPipelineLayout().getHandle(),
-							 i,
-							 1,
-							 &dsHandle,
-							 dynamicOffsetCount,
-							 &dynamicOffsets[0]),
-					ANY_OTHER_COMMAND);
+				ANKI_CMD(vkCmdBindDescriptorSets(m_handle, VK_PIPELINE_BIND_POINT_GRAPHICS,
+												 m_graphicsProg->getPipelineLayout().getHandle(), i, 1, &dsHandle,
+												 dynamicOffsetCount, &dynamicOffsets[0]),
+						 ANY_OTHER_COMMAND);
 			}
 			}
 		}
 		}
 	}
 	}
@@ -640,7 +623,7 @@ inline void CommandBufferImpl::drawcallCommon()
 	// Some checks
 	// Some checks
 #if ANKI_ENABLE_ASSERTS
 #if ANKI_ENABLE_ASSERTS
 	if(m_state.getPrimitiveTopology() == PrimitiveTopology::LINES
 	if(m_state.getPrimitiveTopology() == PrimitiveTopology::LINES
-		|| m_state.getPrimitiveTopology() == PrimitiveTopology::LINE_STRIP)
+	   || m_state.getPrimitiveTopology() == PrimitiveTopology::LINE_STRIP)
 	{
 	{
 		ANKI_ASSERT(m_lineWidthSet == true);
 		ANKI_ASSERT(m_lineWidthSet == true);
 	}
 	}
@@ -721,8 +704,8 @@ inline void CommandBufferImpl::fillBuffer(BufferPtr buff, PtrSize offset, PtrSiz
 	m_microCmdb->pushObjectRef(buff);
 	m_microCmdb->pushObjectRef(buff);
 }
 }
 
 
-inline void CommandBufferImpl::writeOcclusionQueryResultToBuffer(
-	OcclusionQueryPtr query, PtrSize offset, BufferPtr buff)
+inline void CommandBufferImpl::writeOcclusionQueryResultToBuffer(OcclusionQueryPtr query, PtrSize offset,
+																 BufferPtr buff)
 {
 {
 	commandCommon();
 	commandCommon();
 	ANKI_ASSERT(!insideRenderPass());
 	ANKI_ASSERT(!insideRenderPass());
@@ -745,15 +728,9 @@ inline void CommandBufferImpl::writeOcclusionQueryResultToBuffer(
 
 
 	m_writeQueryAtoms.emplaceBack(m_alloc, atom);
 	m_writeQueryAtoms.emplaceBack(m_alloc, atom);
 #else
 #else
-	ANKI_CMD(vkCmdCopyQueryPoolResults(m_handle,
-				 q.m_handle.m_pool,
-				 q.m_handle.m_queryIndex,
-				 1,
-				 impl.getHandle(),
-				 offset,
-				 sizeof(U32),
-				 VK_QUERY_RESULT_PARTIAL_BIT),
-		ANY_OTHER_COMMAND);
+	ANKI_CMD(vkCmdCopyQueryPoolResults(m_handle, q.m_handle.m_pool, q.m_handle.m_queryIndex, 1, impl.getHandle(),
+									   offset, sizeof(U32), VK_QUERY_RESULT_PARTIAL_BIT),
+			 ANY_OTHER_COMMAND);
 #endif
 #endif
 
 
 	m_microCmdb->pushObjectRef(query);
 	m_microCmdb->pushObjectRef(query);
@@ -779,7 +756,7 @@ inline void CommandBufferImpl::bindShaderProgram(ShaderProgramPtr& prog)
 
 
 		// Bind the pipeline now
 		// Bind the pipeline now
 		ANKI_CMD(vkCmdBindPipeline(m_handle, VK_PIPELINE_BIND_POINT_COMPUTE, impl.getComputePipelineHandle()),
 		ANKI_CMD(vkCmdBindPipeline(m_handle, VK_PIPELINE_BIND_POINT_COMPUTE, impl.getComputePipelineHandle()),
-			ANY_OTHER_COMMAND);
+				 ANY_OTHER_COMMAND);
 	}
 	}
 
 
 	for(U i = 0; i < MAX_DESCRIPTOR_SETS; ++i)
 	for(U i = 0; i < MAX_DESCRIPTOR_SETS; ++i)
@@ -803,8 +780,8 @@ inline void CommandBufferImpl::bindShaderProgram(ShaderProgramPtr& prog)
 #endif
 #endif
 }
 }
 
 
-inline void CommandBufferImpl::copyBufferToBuffer(
-	BufferPtr& src, PtrSize srcOffset, BufferPtr& dst, PtrSize dstOffset, PtrSize range)
+inline void CommandBufferImpl::copyBufferToBuffer(BufferPtr& src, PtrSize srcOffset, BufferPtr& dst, PtrSize dstOffset,
+												  PtrSize range)
 {
 {
 	ANKI_ASSERT(static_cast<const BufferImpl&>(*src).usageValid(BufferUsageBit::TRANSFER_SOURCE));
 	ANKI_ASSERT(static_cast<const BufferImpl&>(*src).usageValid(BufferUsageBit::TRANSFER_SOURCE));
 	ANKI_ASSERT(static_cast<const BufferImpl&>(*dst).usageValid(BufferUsageBit::TRANSFER_DESTINATION));
 	ANKI_ASSERT(static_cast<const BufferImpl&>(*dst).usageValid(BufferUsageBit::TRANSFER_DESTINATION));
@@ -818,12 +795,9 @@ inline void CommandBufferImpl::copyBufferToBuffer(
 	region.dstOffset = dstOffset;
 	region.dstOffset = dstOffset;
 	region.size = range;
 	region.size = range;
 
 
-	ANKI_CMD(vkCmdCopyBuffer(m_handle,
-				 static_cast<const BufferImpl&>(*src).getHandle(),
-				 static_cast<const BufferImpl&>(*dst).getHandle(),
-				 1,
-				 &region),
-		ANY_OTHER_COMMAND);
+	ANKI_CMD(vkCmdCopyBuffer(m_handle, static_cast<const BufferImpl&>(*src).getHandle(),
+							 static_cast<const BufferImpl&>(*dst).getHandle(), 1, &region),
+			 ANY_OTHER_COMMAND);
 
 
 	m_microCmdb->pushObjectRef(src);
 	m_microCmdb->pushObjectRef(src);
 	m_microCmdb->pushObjectRef(dst);
 	m_microCmdb->pushObjectRef(dst);

+ 30 - 48
src/anki/gr/vulkan/DescriptorSet.cpp

@@ -95,8 +95,8 @@ DescriptorSetFactory::BindlessDescriptorSet::~BindlessDescriptorSet()
 	m_freeTexIndices.destroy(m_alloc);
 	m_freeTexIndices.destroy(m_alloc);
 }
 }
 
 
-Error DescriptorSetFactory::BindlessDescriptorSet::init(
-	const GrAllocator<U8>& alloc, VkDevice dev, const BindlessLimits& bindlessLimits)
+Error DescriptorSetFactory::BindlessDescriptorSet::init(const GrAllocator<U8>& alloc, VkDevice dev,
+														const BindlessLimits& bindlessLimits)
 {
 {
 	ANKI_ASSERT(dev);
 	ANKI_ASSERT(dev);
 	ANKI_ASSERT(bindlessLimits.m_bindlessTextureCount <= MAX_U16);
 	ANKI_ASSERT(bindlessLimits.m_bindlessTextureCount <= MAX_U16);
@@ -252,8 +252,8 @@ U32 DescriptorSetFactory::BindlessDescriptorSet::bindImage(const VkImageView vie
 	return idx;
 	return idx;
 }
 }
 
 
-void DescriptorSetFactory::BindlessDescriptorSet::unbindCommon(
-	U32 idx, DynamicArray<U16>& freeIndices, U16& freeIndexCount)
+void DescriptorSetFactory::BindlessDescriptorSet::unbindCommon(U32 idx, DynamicArray<U16>& freeIndices,
+															   U16& freeIndexCount)
 {
 {
 	ANKI_ASSERT(idx < freeIndices.getSize());
 	ANKI_ASSERT(idx < freeIndices.getSize());
 
 
@@ -309,9 +309,8 @@ public:
 	ANKI_USE_RESULT Error createNewPool();
 	ANKI_USE_RESULT Error createNewPool();
 
 
 	ANKI_USE_RESULT Error getOrCreateSet(U64 hash,
 	ANKI_USE_RESULT Error getOrCreateSet(U64 hash,
-		const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
-		StackAllocator<U8>& tmpAlloc,
-		const DS*& out)
+										 const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
+										 StackAllocator<U8>& tmpAlloc, const DS*& out)
 	{
 	{
 		out = tryFindSet(hash);
 		out = tryFindSet(hash);
 		if(out == nullptr)
 		if(out == nullptr)
@@ -324,13 +323,10 @@ public:
 
 
 private:
 private:
 	ANKI_USE_RESULT const DS* tryFindSet(U64 hash);
 	ANKI_USE_RESULT const DS* tryFindSet(U64 hash);
-	ANKI_USE_RESULT Error newSet(U64 hash,
-		const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
-		StackAllocator<U8>& tmpAlloc,
-		const DS*& out);
-	void writeSet(const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
-		const DS& set,
-		StackAllocator<U8>& tmpAlloc);
+	ANKI_USE_RESULT Error newSet(U64 hash, const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
+								 StackAllocator<U8>& tmpAlloc, const DS*& out);
+	void writeSet(const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings, const DS& set,
+				  StackAllocator<U8>& tmpAlloc);
 };
 };
 
 
 /// Cache entry. It's built around a specific descriptor set layout.
 /// Cache entry. It's built around a specific descriptor set layout.
@@ -402,9 +398,8 @@ Error DSThreadAllocator::createNewPool()
 
 
 	// Set the create info
 	// Set the create info
 	Array<VkDescriptorPoolSize, U(DescriptorType::COUNT)> poolSizes;
 	Array<VkDescriptorPoolSize, U(DescriptorType::COUNT)> poolSizes;
-	memcpy(&poolSizes[0],
-		&m_layoutEntry->m_poolSizesCreateInf[0],
-		sizeof(poolSizes[0]) * m_layoutEntry->m_poolCreateInf.poolSizeCount);
+	memcpy(&poolSizes[0], &m_layoutEntry->m_poolSizesCreateInf[0],
+		   sizeof(poolSizes[0]) * m_layoutEntry->m_poolCreateInf.poolSizeCount);
 
 
 	for(U i = 0; i < m_layoutEntry->m_poolCreateInf.poolSizeCount; ++i)
 	for(U i = 0; i < m_layoutEntry->m_poolCreateInf.poolSizeCount; ++i)
 	{
 	{
@@ -450,10 +445,8 @@ const DS* DSThreadAllocator::tryFindSet(U64 hash)
 	}
 	}
 }
 }
 
 
-Error DSThreadAllocator::newSet(U64 hash,
-	const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
-	StackAllocator<U8>& tmpAlloc,
-	const DS*& out_)
+Error DSThreadAllocator::newSet(U64 hash, const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
+								StackAllocator<U8>& tmpAlloc, const DS*& out_)
 {
 {
 	DS* out = nullptr;
 	DS* out = nullptr;
 
 
@@ -525,8 +518,7 @@ Error DSThreadAllocator::newSet(U64 hash,
 }
 }
 
 
 void DSThreadAllocator::writeSet(const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
 void DSThreadAllocator::writeSet(const Array<AnyBindingExtended, MAX_BINDINGS_PER_DESCRIPTOR_SET>& bindings,
-	const DS& set,
-	StackAllocator<U8>& tmpAlloc)
+								 const DS& set, StackAllocator<U8>& tmpAlloc)
 {
 {
 	DynamicArrayAuto<VkWriteDescriptorSet> writeInfos(tmpAlloc);
 	DynamicArrayAuto<VkWriteDescriptorSet> writeInfos(tmpAlloc);
 	DynamicArrayAuto<VkDescriptorImageInfo> texInfos(tmpAlloc);
 	DynamicArrayAuto<VkDescriptorImageInfo> texInfos(tmpAlloc);
@@ -651,11 +643,8 @@ void DSThreadAllocator::writeSet(const Array<AnyBindingExtended, MAX_BINDINGS_PE
 	}
 	}
 
 
 	// Write
 	// Write
-	vkUpdateDescriptorSets(m_layoutEntry->m_factory->m_dev,
-		writeInfos.getSize(),
-		(writeInfos.getSize() > 0) ? &writeInfos[0] : nullptr,
-		0,
-		nullptr);
+	vkUpdateDescriptorSets(m_layoutEntry->m_factory->m_dev, writeInfos.getSize(),
+						   (writeInfos.getSize() > 0) ? &writeInfos[0] : nullptr, 0, nullptr);
 }
 }
 
 
 DSLayoutCacheEntry::~DSLayoutCacheEntry()
 DSLayoutCacheEntry::~DSLayoutCacheEntry()
@@ -795,9 +784,8 @@ Error DSLayoutCacheEntry::getOrCreateThreadAllocator(ThreadId tid, DSThreadAlloc
 			m_threadAllocs[m_threadAllocs.getSize() - 1] = alloc;
 			m_threadAllocs[m_threadAllocs.getSize() - 1] = alloc;
 
 
 			// Sort for fast find
 			// Sort for fast find
-			std::sort(m_threadAllocs.getBegin(),
-				m_threadAllocs.getEnd(),
-				[](const DSThreadAllocator* a, const DSThreadAllocator* b) { return a->m_tid < b->m_tid; });
+			std::sort(m_threadAllocs.getBegin(), m_threadAllocs.getEnd(),
+					  [](const DSThreadAllocator* a, const DSThreadAllocator* b) { return a->m_tid < b->m_tid; });
 		}
 		}
 	}
 	}
 
 
@@ -806,10 +794,8 @@ Error DSLayoutCacheEntry::getOrCreateThreadAllocator(ThreadId tid, DSThreadAlloc
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-void DescriptorSetState::flush(U64& hash,
-	Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-	U32& dynamicOffsetCount,
-	Bool& bindlessDSet)
+void DescriptorSetState::flush(U64& hash, Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
+							   U32& dynamicOffsetCount, Bool& bindlessDSet)
 {
 {
 	// Set some values
 	// Set some values
 	hash = 0;
 	hash = 0;
@@ -893,8 +879,8 @@ void DescriptorSetState::flush(U64& hash,
 						ANKI_ASSERT(anyBinding.m_type == DescriptorType::IMAGE && "Have bound the wrong type");
 						ANKI_ASSERT(anyBinding.m_type == DescriptorType::IMAGE && "Have bound the wrong type");
 						break;
 						break;
 					case DescriptorType::ACCELERATION_STRUCTURE:
 					case DescriptorType::ACCELERATION_STRUCTURE:
-						ANKI_ASSERT(
-							anyBinding.m_type == DescriptorType::ACCELERATION_STRUCTURE && "Have bound the wrong type");
+						ANKI_ASSERT(anyBinding.m_type == DescriptorType::ACCELERATION_STRUCTURE
+									&& "Have bound the wrong type");
 						break;
 						break;
 					default:
 					default:
 						ANKI_ASSERT(0);
 						ANKI_ASSERT(0);
@@ -975,9 +961,8 @@ Error DescriptorSetFactory::newDescriptorSetLayout(const DescriptorSetLayoutInit
 	if(init.m_bindings.getSize() > 0)
 	if(init.m_bindings.getSize() > 0)
 	{
 	{
 		memcpy(bindings.getBegin(), init.m_bindings.getBegin(), init.m_bindings.getSizeInBytes());
 		memcpy(bindings.getBegin(), init.m_bindings.getBegin(), init.m_bindings.getSizeInBytes());
-		std::sort(bindings.getBegin(),
-			bindings.getBegin() + bindingCount,
-			[](const DescriptorBinding& a, const DescriptorBinding& b) { return a.m_binding < b.m_binding; });
+		std::sort(bindings.getBegin(), bindings.getBegin() + bindingCount,
+				  [](const DescriptorBinding& a, const DescriptorBinding& b) { return a.m_binding < b.m_binding; });
 
 
 		hash = computeHash(&bindings[0], init.m_bindings.getSizeInBytes());
 		hash = computeHash(&bindings[0], init.m_bindings.getSizeInBytes());
 		ANKI_ASSERT(hash != 1);
 		ANKI_ASSERT(hash != 1);
@@ -996,7 +981,7 @@ Error DescriptorSetFactory::newDescriptorSetLayout(const DescriptorSetLayoutInit
 		{
 		{
 			const DescriptorBinding& binding = bindings[i];
 			const DescriptorBinding& binding = bindings[i];
 			if(binding.m_binding == 0 && binding.m_type == DescriptorType::TEXTURE
 			if(binding.m_binding == 0 && binding.m_type == DescriptorType::TEXTURE
-				&& binding.m_arraySizeMinusOne == m_bindlessLimits.m_bindlessTextureCount - 1)
+			   && binding.m_arraySizeMinusOne == m_bindlessLimits.m_bindlessTextureCount - 1)
 			{
 			{
 				// All good
 				// All good
 			}
 			}
@@ -1051,13 +1036,10 @@ Error DescriptorSetFactory::newDescriptorSetLayout(const DescriptorSetLayoutInit
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-Error DescriptorSetFactory::newDescriptorSet(ThreadId tid,
-	StackAllocator<U8>& tmpAlloc,
-	DescriptorSetState& state,
-	DescriptorSet& set,
-	Bool& dirty,
-	Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-	U32& dynamicOffsetCount)
+Error DescriptorSetFactory::newDescriptorSet(ThreadId tid, StackAllocator<U8>& tmpAlloc, DescriptorSetState& state,
+											 DescriptorSet& set, Bool& dirty,
+											 Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
+											 U32& dynamicOffsetCount)
 {
 {
 	ANKI_TRACE_SCOPED_EVENT(VK_DESCRIPTOR_SET_GET_OR_CREATE);
 	ANKI_TRACE_SCOPED_EVENT(VK_DESCRIPTOR_SET_GET_OR_CREATE);
 
 

+ 8 - 13
src/anki/gr/vulkan/DescriptorSet.h

@@ -188,8 +188,8 @@ public:
 		m_layout = layout;
 		m_layout = layout;
 	}
 	}
 
 
-	void bindTextureAndSampler(
-		U32 binding, U32 arrayIdx, const TextureView* texView, const Sampler* sampler, VkImageLayout layout)
+	void bindTextureAndSampler(U32 binding, U32 arrayIdx, const TextureView* texView, const Sampler* sampler,
+							   VkImageLayout layout)
 	{
 	{
 		const TextureViewImpl& viewImpl = static_cast<const TextureViewImpl&>(*texView);
 		const TextureViewImpl& viewImpl = static_cast<const TextureViewImpl&>(*texView);
 		ANKI_ASSERT(viewImpl.getTextureImpl().isSubresourceGoodForSampling(viewImpl.getSubresource()));
 		ANKI_ASSERT(viewImpl.getTextureImpl().isSubresourceGoodForSampling(viewImpl.getSubresource()));
@@ -320,10 +320,8 @@ private:
 
 
 	/// Only DescriptorSetFactory should call this.
 	/// Only DescriptorSetFactory should call this.
 	/// @param hash If hash is zero then the DS doesn't need rebind.
 	/// @param hash If hash is zero then the DS doesn't need rebind.
-	void flush(U64& hash,
-		Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-		U32& dynamicOffsetCount,
-		Bool& bindlessDSet);
+	void flush(U64& hash, Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets, U32& dynamicOffsetCount,
+			   Bool& bindlessDSet);
 
 
 	void unbindBindlessDSet()
 	void unbindBindlessDSet()
 	{
 	{
@@ -399,13 +397,10 @@ public:
 	ANKI_USE_RESULT Error newDescriptorSetLayout(const DescriptorSetLayoutInitInfo& init, DescriptorSetLayout& layout);
 	ANKI_USE_RESULT Error newDescriptorSetLayout(const DescriptorSetLayoutInitInfo& init, DescriptorSetLayout& layout);
 
 
 	/// @note It's thread-safe.
 	/// @note It's thread-safe.
-	ANKI_USE_RESULT Error newDescriptorSet(ThreadId tid,
-		StackAllocator<U8>& tmpAlloc,
-		DescriptorSetState& state,
-		DescriptorSet& set,
-		Bool& dirty,
-		Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
-		U32& dynamicOffsetCount);
+	ANKI_USE_RESULT Error newDescriptorSet(ThreadId tid, StackAllocator<U8>& tmpAlloc, DescriptorSetState& state,
+										   DescriptorSet& set, Bool& dirty,
+										   Array<PtrSize, MAX_BINDINGS_PER_DESCRIPTOR_SET>& dynamicOffsets,
+										   U32& dynamicOffsetCount);
 
 
 	void endFrame()
 	void endFrame()
 	{
 	{

+ 11 - 12
src/anki/gr/vulkan/FramebufferImpl.cpp

@@ -54,8 +54,8 @@ Error FramebufferImpl::init(const FramebufferInitInfo& init)
 	// Create a renderpass.
 	// Create a renderpass.
 	initRpassCreateInfo(init);
 	initRpassCreateInfo(init);
 	ANKI_VK_CHECK(vkCreateRenderPass(getDevice(), &m_rpassCi, nullptr, &m_compatibleRpass));
 	ANKI_VK_CHECK(vkCreateRenderPass(getDevice(), &m_rpassCi, nullptr, &m_compatibleRpass));
-	getGrManagerImpl().trySetVulkanHandleName(
-		init.getName(), VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, m_compatibleRpass);
+	getGrManagerImpl().trySetVulkanHandleName(init.getName(), VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT,
+											  m_compatibleRpass);
 
 
 	// Create the FB
 	// Create the FB
 	ANKI_CHECK(initFbs(init));
 	ANKI_CHECK(initFbs(init));
@@ -84,7 +84,7 @@ void FramebufferImpl::initClearValues(const FramebufferInitInfo& init)
 	if(hasDepthStencil())
 	if(hasDepthStencil())
 	{
 	{
 		if(init.m_depthStencilAttachment.m_loadOperation == AttachmentLoadOperation::CLEAR
 		if(init.m_depthStencilAttachment.m_loadOperation == AttachmentLoadOperation::CLEAR
-			|| init.m_depthStencilAttachment.m_stencilLoadOperation == AttachmentLoadOperation::CLEAR)
+		   || init.m_depthStencilAttachment.m_stencilLoadOperation == AttachmentLoadOperation::CLEAR)
 		{
 		{
 			m_clearVals[m_colorAttCount].depthStencil.depth =
 			m_clearVals[m_colorAttCount].depthStencil.depth =
 				init.m_depthStencilAttachment.m_clearValue.m_depthStencil.m_depth;
 				init.m_depthStencilAttachment.m_clearValue.m_depthStencil.m_depth;
@@ -163,8 +163,8 @@ Error FramebufferImpl::initFbs(const FramebufferInitInfo& init)
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-void FramebufferImpl::setupAttachmentDescriptor(
-	const FramebufferAttachmentInfo& att, VkAttachmentDescription& desc, VkImageLayout layout) const
+void FramebufferImpl::setupAttachmentDescriptor(const FramebufferAttachmentInfo& att, VkAttachmentDescription& desc,
+												VkImageLayout layout) const
 {
 {
 	desc = {};
 	desc = {};
 	desc.format = convertFormat(static_cast<const TextureViewImpl&>(*att.m_textureView).getTextureImpl().getFormat());
 	desc.format = convertFormat(static_cast<const TextureViewImpl&>(*att.m_textureView).getTextureImpl().getFormat());
@@ -182,8 +182,8 @@ void FramebufferImpl::initRpassCreateInfo(const FramebufferInitInfo& init)
 	// Setup attachments and references
 	// Setup attachments and references
 	for(U32 i = 0; i < init.m_colorAttachmentCount; ++i)
 	for(U32 i = 0; i < init.m_colorAttachmentCount; ++i)
 	{
 	{
-		setupAttachmentDescriptor(
-			init.m_colorAttachments[i], m_attachmentDescriptions[i], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
+		setupAttachmentDescriptor(init.m_colorAttachments[i], m_attachmentDescriptions[i],
+								  VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
 
 
 		m_references[i].attachment = i;
 		m_references[i].attachment = i;
 		m_references[i].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
 		m_references[i].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
@@ -191,9 +191,8 @@ void FramebufferImpl::initRpassCreateInfo(const FramebufferInitInfo& init)
 
 
 	if(hasDepthStencil())
 	if(hasDepthStencil())
 	{
 	{
-		setupAttachmentDescriptor(init.m_depthStencilAttachment,
-			m_attachmentDescriptions[init.m_colorAttachmentCount],
-			VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
+		setupAttachmentDescriptor(init.m_depthStencilAttachment, m_attachmentDescriptions[init.m_colorAttachmentCount],
+								  VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
 
 
 		VkAttachmentReference& dsReference = m_references[init.m_colorAttachmentCount];
 		VkAttachmentReference& dsReference = m_references[init.m_colorAttachmentCount];
 		dsReference.attachment = init.m_colorAttachmentCount;
 		dsReference.attachment = init.m_colorAttachmentCount;
@@ -215,8 +214,8 @@ void FramebufferImpl::initRpassCreateInfo(const FramebufferInitInfo& init)
 	m_rpassCi.pSubpasses = &m_subpassDescr;
 	m_rpassCi.pSubpasses = &m_subpassDescr;
 }
 }
 
 
-VkRenderPass FramebufferImpl::getRenderPassHandle(
-	const Array<VkImageLayout, MAX_COLOR_ATTACHMENTS>& colorLayouts, VkImageLayout dsLayout)
+VkRenderPass FramebufferImpl::getRenderPassHandle(const Array<VkImageLayout, MAX_COLOR_ATTACHMENTS>& colorLayouts,
+												  VkImageLayout dsLayout)
 {
 {
 	VkRenderPass out = {};
 	VkRenderPass out = {};
 
 

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

@@ -41,8 +41,8 @@ public:
 	}
 	}
 
 
 	/// Use it for binding. It's thread-safe
 	/// Use it for binding. It's thread-safe
-	VkRenderPass getRenderPassHandle(
-		const Array<VkImageLayout, MAX_COLOR_ATTACHMENTS>& colorLayouts, VkImageLayout dsLayout);
+	VkRenderPass getRenderPassHandle(const Array<VkImageLayout, MAX_COLOR_ATTACHMENTS>& colorLayouts,
+									 VkImageLayout dsLayout);
 
 
 	VkFramebuffer getFramebufferHandle() const
 	VkFramebuffer getFramebufferHandle() const
 	{
 	{
@@ -130,8 +130,8 @@ private:
 	ANKI_USE_RESULT Error initFbs(const FramebufferInitInfo& init);
 	ANKI_USE_RESULT Error initFbs(const FramebufferInitInfo& init);
 	void initRpassCreateInfo(const FramebufferInitInfo& init);
 	void initRpassCreateInfo(const FramebufferInitInfo& init);
 	void initClearValues(const FramebufferInitInfo& init);
 	void initClearValues(const FramebufferInitInfo& init);
-	void setupAttachmentDescriptor(
-		const FramebufferAttachmentInfo& att, VkAttachmentDescription& desc, VkImageLayout layout) const;
+	void setupAttachmentDescriptor(const FramebufferAttachmentInfo& att, VkAttachmentDescription& desc,
+								   VkImageLayout layout) const;
 };
 };
 /// @}
 /// @}
 
 

+ 18 - 23
src/anki/gr/vulkan/GpuMemoryManager.cpp

@@ -19,15 +19,16 @@ public:
 };
 };
 
 
 static const Array<ClassInf, CLASS_COUNT> CLASSES{{{256_B, 16_KB},
 static const Array<ClassInf, CLASS_COUNT> CLASSES{{{256_B, 16_KB},
-	{4_KB, 256_KB},
-	{128_KB, 8_MB},
-	{1_MB, 64_MB},
-	{16_MB, 128_MB},
-	{64_MB, 256_MB},
-	{128_MB, 256_MB}}};
-
-class GpuMemoryManager::Memory final : public ClassGpuAllocatorMemory,
-									   public IntrusiveListEnabled<GpuMemoryManager::Memory>
+												   {4_KB, 256_KB},
+												   {128_KB, 8_MB},
+												   {1_MB, 64_MB},
+												   {16_MB, 128_MB},
+												   {64_MB, 256_MB},
+												   {128_MB, 256_MB}}};
+
+class GpuMemoryManager::Memory final :
+	public ClassGpuAllocatorMemory,
+	public IntrusiveListEnabled<GpuMemoryManager::Memory>
 {
 {
 public:
 public:
 	VkDeviceMemory m_handle = VK_NULL_HANDLE;
 	VkDeviceMemory m_handle = VK_NULL_HANDLE;
@@ -200,10 +201,8 @@ void GpuMemoryManager::init(VkPhysicalDevice pdev, VkDevice dev, GrAllocator<U8>
 	ANKI_VK_LOGI("Initializing memory manager");
 	ANKI_VK_LOGI("Initializing memory manager");
 	for(const ClassInf& c : CLASSES)
 	for(const ClassInf& c : CLASSES)
 	{
 	{
-		ANKI_VK_LOGI("\tGPU mem class. Chunk size: %lu, slotSize: %lu, allocsPerChunk %lu",
-			c.m_chunkSize,
-			c.m_slotSize,
-			c.m_chunkSize / c.m_slotSize);
+		ANKI_VK_LOGI("\tGPU mem class. Chunk size: %lu, slotSize: %lu, allocsPerChunk %lu", c.m_chunkSize, c.m_slotSize,
+					 c.m_chunkSize / c.m_slotSize);
 	}
 	}
 
 
 	vkGetPhysicalDeviceMemoryProperties(pdev, &m_memoryProperties);
 	vkGetPhysicalDeviceMemoryProperties(pdev, &m_memoryProperties);
@@ -229,8 +228,8 @@ void GpuMemoryManager::init(VkPhysicalDevice pdev, VkDevice dev, GrAllocator<U8>
 		for(U32 type = 0; type < 3; ++type)
 		for(U32 type = 0; type < 3; ++type)
 		{
 		{
 			const Bool exposesBufferGpuAddress = (type == 2);
 			const Bool exposesBufferGpuAddress = (type == 2);
-			ANKI_ASSERT(
-				m_ifaces[memTypeIdx][exposesBufferGpuAddress].m_exposesBufferGpuAddress == exposesBufferGpuAddress);
+			ANKI_ASSERT(m_ifaces[memTypeIdx][exposesBufferGpuAddress].m_exposesBufferGpuAddress
+						== exposesBufferGpuAddress);
 			m_callocs[memTypeIdx][type].init(m_alloc, &m_ifaces[memTypeIdx][exposesBufferGpuAddress]);
 			m_callocs[memTypeIdx][type].init(m_alloc, &m_ifaces[memTypeIdx][exposesBufferGpuAddress]);
 
 
 			const U32 heapIdx = m_memoryProperties.memoryTypes[memTypeIdx].heapIndex;
 			const U32 heapIdx = m_memoryProperties.memoryTypes[memTypeIdx].heapIndex;
@@ -240,12 +239,8 @@ void GpuMemoryManager::init(VkPhysicalDevice pdev, VkDevice dev, GrAllocator<U8>
 	}
 	}
 }
 }
 
 
-void GpuMemoryManager::allocateMemory(U32 memTypeIdx,
-	PtrSize size,
-	U32 alignment,
-	Bool linearResource,
-	Bool exposesBufferGpuAddress,
-	GpuMemoryHandle& handle)
+void GpuMemoryManager::allocateMemory(U32 memTypeIdx, PtrSize size, U32 alignment, Bool linearResource,
+									  Bool exposesBufferGpuAddress, GpuMemoryHandle& handle)
 {
 {
 	U32 type;
 	U32 type;
 	if(!linearResource)
 	if(!linearResource)
@@ -307,8 +302,8 @@ void* GpuMemoryManager::getMappedAddress(GpuMemoryHandle& handle)
 	return static_cast<void*>(out + handle.m_offset);
 	return static_cast<void*>(out + handle.m_offset);
 }
 }
 
 
-U32 GpuMemoryManager::findMemoryType(
-	U32 resourceMemTypeBits, VkMemoryPropertyFlags preferFlags, VkMemoryPropertyFlags avoidFlags) const
+U32 GpuMemoryManager::findMemoryType(U32 resourceMemTypeBits, VkMemoryPropertyFlags preferFlags,
+									 VkMemoryPropertyFlags avoidFlags) const
 {
 {
 	U32 prefered = MAX_U32;
 	U32 prefered = MAX_U32;
 
 

+ 4 - 8
src/anki/gr/vulkan/GpuMemoryManager.h

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

+ 34 - 63
src/anki/gr/vulkan/GrManagerImpl.cpp

@@ -133,13 +133,9 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 	// Set m_r8g8b8ImagesSupported
 	// Set m_r8g8b8ImagesSupported
 	{
 	{
 		VkImageFormatProperties props = {};
 		VkImageFormatProperties props = {};
-		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
-			VK_FORMAT_R8G8B8_UNORM,
-			VK_IMAGE_TYPE_2D,
-			VK_IMAGE_TILING_OPTIMAL,
-			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
-			0,
-			&props);
+		VkResult res = vkGetPhysicalDeviceImageFormatProperties(
+			m_physicalDevice, VK_FORMAT_R8G8B8_UNORM, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL,
+			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &props);
 
 
 		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 		{
 		{
@@ -157,13 +153,9 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 	// Set m_s8ImagesSupported
 	// Set m_s8ImagesSupported
 	{
 	{
 		VkImageFormatProperties props = {};
 		VkImageFormatProperties props = {};
-		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
-			VK_FORMAT_S8_UINT,
-			VK_IMAGE_TYPE_2D,
-			VK_IMAGE_TILING_OPTIMAL,
-			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
-			0,
-			&props);
+		VkResult res = vkGetPhysicalDeviceImageFormatProperties(
+			m_physicalDevice, VK_FORMAT_S8_UINT, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL,
+			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, 0, &props);
 
 
 		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 		{
 		{
@@ -181,13 +173,9 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 	// Set m_d24S8ImagesSupported
 	// Set m_d24S8ImagesSupported
 	{
 	{
 		VkImageFormatProperties props = {};
 		VkImageFormatProperties props = {};
-		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
-			VK_FORMAT_D24_UNORM_S8_UINT,
-			VK_IMAGE_TYPE_2D,
-			VK_IMAGE_TILING_OPTIMAL,
-			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
-			0,
-			&props);
+		VkResult res = vkGetPhysicalDeviceImageFormatProperties(
+			m_physicalDevice, VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL,
+			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, 0, &props);
 
 
 		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 		{
 		{
@@ -413,8 +401,8 @@ Error GrManagerImpl::initInstance(const GrManagerInitInfo& init)
 	default:
 	default:
 		m_capabilities.m_gpuVendor = GpuVendor::UNKNOWN;
 		m_capabilities.m_gpuVendor = GpuVendor::UNKNOWN;
 	}
 	}
-	ANKI_VK_LOGI(
-		"GPU is %s. Vendor identified as %s", m_devProps.deviceName, &GPU_VENDOR_STR[m_capabilities.m_gpuVendor][0]);
+	ANKI_VK_LOGI("GPU is %s. Vendor identified as %s", m_devProps.deviceName,
+				 &GPU_VENDOR_STR[m_capabilities.m_gpuVendor][0]);
 
 
 	vkGetPhysicalDeviceFeatures(m_physicalDevice, &m_devFeatures);
 	vkGetPhysicalDeviceFeatures(m_physicalDevice, &m_devFeatures);
 	m_devFeatures.robustBufferAccess =
 	m_devFeatures.robustBufferAccess =
@@ -551,14 +539,14 @@ Error GrManagerImpl::initDevice(const GrManagerInitInfo& init)
 			vkGetPhysicalDeviceFeatures2(m_physicalDevice, &features);
 			vkGetPhysicalDeviceFeatures2(m_physicalDevice, &features);
 
 
 			if(!m_descriptorIndexingFeatures.shaderSampledImageArrayNonUniformIndexing
 			if(!m_descriptorIndexingFeatures.shaderSampledImageArrayNonUniformIndexing
-				|| !m_descriptorIndexingFeatures.shaderStorageImageArrayNonUniformIndexing)
+			   || !m_descriptorIndexingFeatures.shaderStorageImageArrayNonUniformIndexing)
 			{
 			{
 				ANKI_VK_LOGE("Non uniform indexing is not supported by the device");
 				ANKI_VK_LOGE("Non uniform indexing is not supported by the device");
 				return Error::FUNCTION_FAILED;
 				return Error::FUNCTION_FAILED;
 			}
 			}
 
 
 			if(!m_descriptorIndexingFeatures.descriptorBindingSampledImageUpdateAfterBind
 			if(!m_descriptorIndexingFeatures.descriptorBindingSampledImageUpdateAfterBind
-				|| !m_descriptorIndexingFeatures.descriptorBindingStorageImageUpdateAfterBind)
+			   || !m_descriptorIndexingFeatures.descriptorBindingStorageImageUpdateAfterBind)
 			{
 			{
 				ANKI_VK_LOGE("Update descriptors after bind is not supported by the device");
 				ANKI_VK_LOGE("Update descriptors after bind is not supported by the device");
 				return Error::FUNCTION_FAILED;
 				return Error::FUNCTION_FAILED;
@@ -684,10 +672,9 @@ Error GrManagerImpl::initMemory(const ConfigSet& cfg)
 	}
 	}
 	for(U32 i = 0; i < m_memoryProperties.memoryTypeCount; ++i)
 	for(U32 i = 0; i < m_memoryProperties.memoryTypeCount; ++i)
 	{
 	{
-		ANKI_VK_LOGI("\tMem type %u points to heap %u, flags %" ANKI_PRIb32,
-			i,
-			m_memoryProperties.memoryTypes[i].heapIndex,
-			ANKI_FORMAT_U32(m_memoryProperties.memoryTypes[i].propertyFlags));
+		ANKI_VK_LOGI("\tMem type %u points to heap %u, flags %" ANKI_PRIb32, i,
+					 m_memoryProperties.memoryTypes[i].heapIndex,
+					 ANKI_FORMAT_U32(m_memoryProperties.memoryTypes[i].propertyFlags));
 	}
 	}
 
 
 	m_gpuMemManager.init(m_physicalDevice, m_device, getAllocator());
 	m_gpuMemManager.init(m_physicalDevice, m_device, getAllocator());
@@ -696,8 +683,8 @@ Error GrManagerImpl::initMemory(const ConfigSet& cfg)
 }
 }
 
 
 #if ANKI_GR_MANAGER_DEBUG_MEMMORY
 #if ANKI_GR_MANAGER_DEBUG_MEMMORY
-void* GrManagerImpl::allocateCallback(
-	void* userData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope)
+void* GrManagerImpl::allocateCallback(void* userData, size_t size, size_t alignment,
+									  VkSystemAllocationScope allocationScope)
 {
 {
 	if(ANKI_UNLIKELY(size == 0))
 	if(ANKI_UNLIKELY(size == 0))
 	{
 	{
@@ -720,8 +707,8 @@ void* GrManagerImpl::allocateCallback(
 	return static_cast<AllocHeader*>(header);
 	return static_cast<AllocHeader*>(header);
 }
 }
 
 
-void* GrManagerImpl::reallocateCallback(
-	void* userData, void* original, size_t size, size_t alignment, VkSystemAllocationScope allocationScope)
+void* GrManagerImpl::reallocateCallback(void* userData, void* original, size_t size, size_t alignment,
+										VkSystemAllocationScope allocationScope)
 {
 {
 	if(original && size == 0)
 	if(original && size == 0)
 	{
 	{
@@ -773,12 +760,8 @@ TexturePtr GrManagerImpl::acquireNextPresentableTexture()
 	// Get new image
 	// Get new image
 	uint32_t imageIdx;
 	uint32_t imageIdx;
 
 
-	VkResult res = vkAcquireNextImageKHR(m_device,
-		m_crntSwapchain->m_swapchain,
-		UINT64_MAX,
-		frame.m_acquireSemaphore->getHandle(),
-		fence->getHandle(),
-		&imageIdx);
+	VkResult res = vkAcquireNextImageKHR(m_device, m_crntSwapchain->m_swapchain, UINT64_MAX,
+										 frame.m_acquireSemaphore->getHandle(), fence->getHandle(), &imageIdx);
 
 
 	if(res == VK_ERROR_OUT_OF_DATE_KHR)
 	if(res == VK_ERROR_OUT_OF_DATE_KHR)
 	{
 	{
@@ -787,12 +770,8 @@ TexturePtr GrManagerImpl::acquireNextPresentableTexture()
 		m_crntSwapchain = m_swapchainFactory.newInstance();
 		m_crntSwapchain = m_swapchainFactory.newInstance();
 
 
 		// Can't fail a second time
 		// Can't fail a second time
-		ANKI_VK_CHECKF(vkAcquireNextImageKHR(m_device,
-			m_crntSwapchain->m_swapchain,
-			UINT64_MAX,
-			frame.m_acquireSemaphore->getHandle(),
-			fence->getHandle(),
-			&imageIdx));
+		ANKI_VK_CHECKF(vkAcquireNextImageKHR(m_device, m_crntSwapchain->m_swapchain, UINT64_MAX,
+											 frame.m_acquireSemaphore->getHandle(), fence->getHandle(), &imageIdx));
 	}
 	}
 	else
 	else
 	{
 	{
@@ -975,14 +954,9 @@ StringAuto GrManagerImpl::tryGetVulkanHandleName(U64 handle) const
 	return out;
 	return out;
 }
 }
 
 
-VkBool32 GrManagerImpl::debugReportCallbackEXT(VkDebugReportFlagsEXT flags,
-	VkDebugReportObjectTypeEXT objectType,
-	uint64_t object,
-	size_t location,
-	int32_t messageCode,
-	const char* pLayerPrefix,
-	const char* pMessage,
-	void* pUserData)
+VkBool32 GrManagerImpl::debugReportCallbackEXT(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType,
+											   uint64_t object, size_t location, int32_t messageCode,
+											   const char* pLayerPrefix, const char* pMessage, void* pUserData)
 {
 {
 	// Get the object name
 	// Get the object name
 	GrManagerImpl* self = static_cast<GrManagerImpl*>(pUserData);
 	GrManagerImpl* self = static_cast<GrManagerImpl*>(pUserData);
@@ -1013,8 +987,8 @@ void GrManagerImpl::printPipelineShaderInfo(VkPipeline ppline, CString name, Sha
 	}
 	}
 }
 }
 
 
-Error GrManagerImpl::printPipelineShaderInfoInternal(
-	VkPipeline ppline, CString name, ShaderTypeBit stages, U64 hash) const
+Error GrManagerImpl::printPipelineShaderInfoInternal(VkPipeline ppline, CString name, ShaderTypeBit stages,
+													 U64 hash) const
 {
 {
 	if(m_pfnGetShaderInfoAMD)
 	if(m_pfnGetShaderInfoAMD)
 	{
 	{
@@ -1052,18 +1026,15 @@ Error GrManagerImpl::printPipelineShaderInfoInternal(
 			}
 			}
 
 
 			size_t size = sizeof(stats);
 			size_t size = sizeof(stats);
-			ANKI_VK_CHECK(m_pfnGetShaderInfoAMD(
-				m_device, ppline, convertShaderTypeBit(stage), VK_SHADER_INFO_TYPE_STATISTICS_AMD, &size, &stats));
+			ANKI_VK_CHECK(m_pfnGetShaderInfoAMD(m_device, ppline, convertShaderTypeBit(stage),
+												VK_SHADER_INFO_TYPE_STATISTICS_AMD, &size, &stats));
 
 
 			str.append(StringAuto(getAllocator())
 			str.append(StringAuto(getAllocator())
-						   .sprintf("Stage %u: VGRPS %02u, SGRPS %02u ",
-							   U32(type),
-							   stats.resourceUsage.numUsedVgprs,
-							   stats.resourceUsage.numUsedSgprs));
+						   .sprintf("Stage %u: VGRPS %02u, SGRPS %02u ", U32(type), stats.resourceUsage.numUsedVgprs,
+									stats.resourceUsage.numUsedSgprs));
 
 
 			ANKI_CHECK(m_shaderStatsFile.writeText((type != ShaderType::LAST) ? "%u,%u," : "%u,%u\n",
 			ANKI_CHECK(m_shaderStatsFile.writeText((type != ShaderType::LAST) ? "%u,%u," : "%u,%u\n",
-				stats.resourceUsage.numUsedVgprs,
-				stats.resourceUsage.numUsedSgprs));
+												   stats.resourceUsage.numUsedVgprs, stats.resourceUsage.numUsedSgprs));
 		}
 		}
 
 
 		ANKI_VK_LOGI("Pipeline \"%s\" (0x%016" PRIx64 ") stats: %s", name.cstr(), hash, str.cstr());
 		ANKI_VK_LOGI("Pipeline \"%s\" (0x%016" PRIx64 ") stats: %s", name.cstr(), hash, str.cstr());

+ 10 - 15
src/anki/gr/vulkan/GrManagerImpl.h

@@ -320,28 +320,23 @@ private:
 	ANKI_USE_RESULT Error initMemory(const ConfigSet& cfg);
 	ANKI_USE_RESULT Error initMemory(const ConfigSet& cfg);
 
 
 #if ANKI_GR_MANAGER_DEBUG_MEMMORY
 #if ANKI_GR_MANAGER_DEBUG_MEMMORY
-	static void* allocateCallback(
-		void* userData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
+	static void* allocateCallback(void* userData, size_t size, size_t alignment,
+								  VkSystemAllocationScope allocationScope);
 
 
-	static void* reallocateCallback(
-		void* userData, void* original, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
+	static void* reallocateCallback(void* userData, void* original, size_t size, size_t alignment,
+									VkSystemAllocationScope allocationScope);
 
 
 	static void freeCallback(void* userData, void* ptr);
 	static void freeCallback(void* userData, void* ptr);
 #endif
 #endif
 
 
 	void resetFrame(PerFrame& frame);
 	void resetFrame(PerFrame& frame);
 
 
-	static VkBool32 debugReportCallbackEXT(VkDebugReportFlagsEXT flags,
-		VkDebugReportObjectTypeEXT objectType,
-		uint64_t object,
-		size_t location,
-		int32_t messageCode,
-		const char* pLayerPrefix,
-		const char* pMessage,
-		void* pUserData);
-
-	ANKI_USE_RESULT Error printPipelineShaderInfoInternal(
-		VkPipeline ppline, CString name, ShaderTypeBit stages, U64 hash) const;
+	static VkBool32 debugReportCallbackEXT(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType,
+										   uint64_t object, size_t location, int32_t messageCode,
+										   const char* pLayerPrefix, const char* pMessage, void* pUserData);
+
+	ANKI_USE_RESULT Error printPipelineShaderInfoInternal(VkPipeline ppline, CString name, ShaderTypeBit stages,
+														  U64 hash) const;
 };
 };
 /// @}
 /// @}
 
 

+ 4 - 8
src/anki/gr/vulkan/OcclusionQueryImpl.cpp

@@ -29,14 +29,10 @@ OcclusionQueryResult OcclusionQueryImpl::getResultInternal() const
 	U64 out = 0;
 	U64 out = 0;
 
 
 	VkResult res;
 	VkResult res;
-	ANKI_VK_CHECKF(res = vkGetQueryPoolResults(getDevice(),
-					   m_handle.getQueryPool(),
-					   m_handle.getQueryIndex(),
-					   1,
-					   sizeof(out),
-					   &out,
-					   sizeof(out),
-					   VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT | VK_QUERY_RESULT_PARTIAL_BIT));
+	ANKI_VK_CHECKF(res = vkGetQueryPoolResults(getDevice(), m_handle.getQueryPool(), m_handle.getQueryIndex(), 1,
+											   sizeof(out), &out, sizeof(out),
+											   VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT
+												   | VK_QUERY_RESULT_PARTIAL_BIT));
 
 
 	OcclusionQueryResult qout = OcclusionQueryResult::NOT_AVAILABLE;
 	OcclusionQueryResult qout = OcclusionQueryResult::NOT_AVAILABLE;
 	if(res == VK_SUCCESS)
 	if(res == VK_SUCCESS)

+ 20 - 27
src/anki/gr/vulkan/Pipeline.cpp

@@ -66,9 +66,9 @@ Bool PipelineStateTracker::updateHashes()
 				{
 				{
 					m_hashes.m_vertexAttribs[i] =
 					m_hashes.m_vertexAttribs[i] =
 						computeHash(&m_state.m_vertex.m_attributes[i], sizeof(m_state.m_vertex.m_attributes[i]));
 						computeHash(&m_state.m_vertex.m_attributes[i], sizeof(m_state.m_vertex.m_attributes[i]));
-					m_hashes.m_vertexAttribs[i] = appendHash(&m_state.m_vertex.m_bindings[i],
-						sizeof(m_state.m_vertex.m_bindings[i]),
-						m_hashes.m_vertexAttribs[i]);
+					m_hashes.m_vertexAttribs[i] =
+						appendHash(&m_state.m_vertex.m_bindings[i], sizeof(m_state.m_vertex.m_bindings[i]),
+								   m_hashes.m_vertexAttribs[i]);
 
 
 					stateDirty = true;
 					stateDirty = true;
 				}
 				}
@@ -307,14 +307,15 @@ const VkGraphicsPipelineCreateInfo& PipelineStateTracker::updatePipelineCreateIn
 
 
 		if(m_fbStencil)
 		if(m_fbStencil)
 		{
 		{
-			dsCi.stencilTestEnable = !stencilTestDisabled(m_state.m_stencil.m_face[0].m_stencilFailOperation,
-										 m_state.m_stencil.m_face[0].m_stencilPassDepthFailOperation,
-										 m_state.m_stencil.m_face[0].m_stencilPassDepthPassOperation,
-										 m_state.m_stencil.m_face[0].m_compareFunction)
-									 || !stencilTestDisabled(m_state.m_stencil.m_face[1].m_stencilFailOperation,
-											m_state.m_stencil.m_face[1].m_stencilPassDepthFailOperation,
-											m_state.m_stencil.m_face[1].m_stencilPassDepthPassOperation,
-											m_state.m_stencil.m_face[1].m_compareFunction);
+			dsCi.stencilTestEnable =
+				!stencilTestDisabled(m_state.m_stencil.m_face[0].m_stencilFailOperation,
+									 m_state.m_stencil.m_face[0].m_stencilPassDepthFailOperation,
+									 m_state.m_stencil.m_face[0].m_stencilPassDepthPassOperation,
+									 m_state.m_stencil.m_face[0].m_compareFunction)
+				|| !stencilTestDisabled(m_state.m_stencil.m_face[1].m_stencilFailOperation,
+										m_state.m_stencil.m_face[1].m_stencilPassDepthFailOperation,
+										m_state.m_stencil.m_face[1].m_stencilPassDepthPassOperation,
+										m_state.m_stencil.m_face[1].m_compareFunction);
 
 
 			dsCi.front.failOp = convertStencilOp(m_state.m_stencil.m_face[0].m_stencilFailOperation);
 			dsCi.front.failOp = convertStencilOp(m_state.m_stencil.m_face[0].m_stencilFailOperation);
 			dsCi.front.passOp = convertStencilOp(m_state.m_stencil.m_face[0].m_stencilPassDepthPassOperation);
 			dsCi.front.passOp = convertStencilOp(m_state.m_stencil.m_face[0].m_stencilPassDepthPassOperation);
@@ -344,12 +345,8 @@ const VkGraphicsPipelineCreateInfo& PipelineStateTracker::updatePipelineCreateIn
 			VkPipelineColorBlendAttachmentState& out = m_ci.m_colAttachments[i];
 			VkPipelineColorBlendAttachmentState& out = m_ci.m_colAttachments[i];
 			const PPColorAttachmentStateInfo& in = m_state.m_color.m_attachments[i];
 			const PPColorAttachmentStateInfo& in = m_state.m_color.m_attachments[i];
 
 
-			out.blendEnable = !blendingDisabled(in.m_srcBlendFactorRgb,
-				in.m_dstBlendFactorRgb,
-				in.m_srcBlendFactorA,
-				in.m_dstBlendFactorA,
-				in.m_blendFunctionRgb,
-				in.m_blendFunctionA);
+			out.blendEnable = !blendingDisabled(in.m_srcBlendFactorRgb, in.m_dstBlendFactorRgb, in.m_srcBlendFactorA,
+												in.m_dstBlendFactorA, in.m_blendFunctionRgb, in.m_blendFunctionA);
 			out.srcColorBlendFactor = convertBlendFactor(in.m_srcBlendFactorRgb);
 			out.srcColorBlendFactor = convertBlendFactor(in.m_srcBlendFactorRgb);
 			out.dstColorBlendFactor = convertBlendFactor(in.m_dstBlendFactorRgb);
 			out.dstColorBlendFactor = convertBlendFactor(in.m_dstBlendFactorRgb);
 			out.srcAlphaBlendFactor = convertBlendFactor(in.m_srcBlendFactorA);
 			out.srcAlphaBlendFactor = convertBlendFactor(in.m_srcBlendFactorA);
@@ -369,14 +366,10 @@ const VkGraphicsPipelineCreateInfo& PipelineStateTracker::updatePipelineCreateIn
 	dynCi.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
 	dynCi.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
 
 
 	// Almost all state is dynamic. Depth bias is static
 	// Almost all state is dynamic. Depth bias is static
-	static const Array<VkDynamicState, 8> DYN = {{VK_DYNAMIC_STATE_VIEWPORT,
-		VK_DYNAMIC_STATE_SCISSOR,
-		VK_DYNAMIC_STATE_BLEND_CONSTANTS,
-		VK_DYNAMIC_STATE_DEPTH_BOUNDS,
-		VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
-		VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
-		VK_DYNAMIC_STATE_STENCIL_REFERENCE,
-		VK_DYNAMIC_STATE_LINE_WIDTH}};
+	static const Array<VkDynamicState, 8> DYN = {
+		{VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, VK_DYNAMIC_STATE_BLEND_CONSTANTS,
+		 VK_DYNAMIC_STATE_DEPTH_BOUNDS, VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK, VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
+		 VK_DYNAMIC_STATE_STENCIL_REFERENCE, VK_DYNAMIC_STATE_LINE_WIDTH}};
 
 
 	dynCi.dynamicStateCount = DYN.getSize();
 	dynCi.dynamicStateCount = DYN.getSize();
 	dynCi.pDynamicStates = &DYN[0];
 	dynCi.pDynamicStates = &DYN[0];
@@ -459,8 +452,8 @@ void PipelineFactory::newPipeline(PipelineStateTracker& state, Pipeline& ppline,
 
 
 		// Print shader info
 		// Print shader info
 		const ShaderProgramImpl& shaderImpl = static_cast<const ShaderProgramImpl&>(*state.m_state.m_prog);
 		const ShaderProgramImpl& shaderImpl = static_cast<const ShaderProgramImpl&>(*state.m_state.m_prog);
-		shaderImpl.getGrManagerImpl().printPipelineShaderInfo(
-			pp.m_handle, shaderImpl.getName(), shaderImpl.getStages(), hash);
+		shaderImpl.getGrManagerImpl().printPipelineShaderInfo(pp.m_handle, shaderImpl.getName(), shaderImpl.getStages(),
+															  hash);
 	}
 	}
 }
 }
 
 

+ 10 - 12
src/anki/gr/vulkan/Pipeline.h

@@ -243,7 +243,7 @@ public:
 	void setPolygonOffset(F32 factor, F32 units)
 	void setPolygonOffset(F32 factor, F32 units)
 	{
 	{
 		if(m_state.m_rasterizer.m_depthBiasConstantFactor != factor
 		if(m_state.m_rasterizer.m_depthBiasConstantFactor != factor
-			|| m_state.m_rasterizer.m_depthBiasSlopeFactor != units)
+		   || m_state.m_rasterizer.m_depthBiasSlopeFactor != units)
 		{
 		{
 			m_state.m_rasterizer.m_depthBiasConstantFactor = factor;
 			m_state.m_rasterizer.m_depthBiasConstantFactor = factor;
 			m_state.m_rasterizer.m_depthBiasSlopeFactor = units;
 			m_state.m_rasterizer.m_depthBiasSlopeFactor = units;
@@ -260,15 +260,13 @@ public:
 		}
 		}
 	}
 	}
 
 
-	void setStencilOperations(FaceSelectionBit face,
-		StencilOperation stencilFail,
-		StencilOperation stencilPassDepthFail,
-		StencilOperation stencilPassDepthPass)
+	void setStencilOperations(FaceSelectionBit face, StencilOperation stencilFail,
+							  StencilOperation stencilPassDepthFail, StencilOperation stencilPassDepthPass)
 	{
 	{
 		if(!!(face & FaceSelectionBit::FRONT)
 		if(!!(face & FaceSelectionBit::FRONT)
-			&& (m_state.m_stencil.m_face[0].m_stencilFailOperation != stencilFail
-				   || m_state.m_stencil.m_face[0].m_stencilPassDepthFailOperation != stencilPassDepthFail
-				   || m_state.m_stencil.m_face[0].m_stencilPassDepthPassOperation != stencilPassDepthPass))
+		   && (m_state.m_stencil.m_face[0].m_stencilFailOperation != stencilFail
+			   || m_state.m_stencil.m_face[0].m_stencilPassDepthFailOperation != stencilPassDepthFail
+			   || m_state.m_stencil.m_face[0].m_stencilPassDepthPassOperation != stencilPassDepthPass))
 		{
 		{
 			m_state.m_stencil.m_face[0].m_stencilFailOperation = stencilFail;
 			m_state.m_stencil.m_face[0].m_stencilFailOperation = stencilFail;
 			m_state.m_stencil.m_face[0].m_stencilPassDepthFailOperation = stencilPassDepthFail;
 			m_state.m_stencil.m_face[0].m_stencilPassDepthFailOperation = stencilPassDepthFail;
@@ -277,9 +275,9 @@ public:
 		}
 		}
 
 
 		if(!!(face & FaceSelectionBit::BACK)
 		if(!!(face & FaceSelectionBit::BACK)
-			&& (m_state.m_stencil.m_face[1].m_stencilFailOperation != stencilFail
-				   || m_state.m_stencil.m_face[1].m_stencilPassDepthFailOperation != stencilPassDepthFail
-				   || m_state.m_stencil.m_face[1].m_stencilPassDepthPassOperation != stencilPassDepthPass))
+		   && (m_state.m_stencil.m_face[1].m_stencilFailOperation != stencilFail
+			   || m_state.m_stencil.m_face[1].m_stencilPassDepthFailOperation != stencilPassDepthFail
+			   || m_state.m_stencil.m_face[1].m_stencilPassDepthPassOperation != stencilPassDepthPass))
 		{
 		{
 			m_state.m_stencil.m_face[1].m_stencilFailOperation = stencilFail;
 			m_state.m_stencil.m_face[1].m_stencilFailOperation = stencilFail;
 			m_state.m_stencil.m_face[1].m_stencilPassDepthFailOperation = stencilPassDepthFail;
 			m_state.m_stencil.m_face[1].m_stencilPassDepthFailOperation = stencilPassDepthFail;
@@ -343,7 +341,7 @@ public:
 	{
 	{
 		PPColorAttachmentStateInfo& c = m_state.m_color.m_attachments[attachment];
 		PPColorAttachmentStateInfo& c = m_state.m_color.m_attachments[attachment];
 		if(c.m_srcBlendFactorRgb != srcRgb || c.m_dstBlendFactorRgb != dstRgb || c.m_srcBlendFactorA != srcA
 		if(c.m_srcBlendFactorRgb != srcRgb || c.m_dstBlendFactorRgb != dstRgb || c.m_srcBlendFactorA != srcA
-			|| c.m_dstBlendFactorA != dstA)
+		   || c.m_dstBlendFactorA != dstA)
 		{
 		{
 			c.m_srcBlendFactorRgb = srcRgb;
 			c.m_srcBlendFactorRgb = srcRgb;
 			c.m_dstBlendFactorRgb = dstRgb;
 			c.m_dstBlendFactorRgb = dstRgb;

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

@@ -11,8 +11,8 @@
 namespace anki
 namespace anki
 {
 {
 
 
-Error PipelineCache::init(
-	VkDevice dev, VkPhysicalDevice pdev, CString cacheDir, const ConfigSet& cfg, GrAllocator<U8> alloc)
+Error PipelineCache::init(VkDevice dev, VkPhysicalDevice pdev, CString cacheDir, const ConfigSet& cfg,
+						  GrAllocator<U8> alloc)
 {
 {
 	ANKI_ASSERT(cacheDir && dev && pdev);
 	ANKI_ASSERT(cacheDir && dev && pdev);
 	m_dumpSize = cfg.getNumberU32("gr_diskShaderCacheMaxSize");
 	m_dumpSize = cfg.getNumberU32("gr_diskShaderCacheMaxSize");

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

@@ -22,8 +22,8 @@ class PipelineCache
 public:
 public:
 	VkPipelineCache m_cacheHandle = VK_NULL_HANDLE;
 	VkPipelineCache m_cacheHandle = VK_NULL_HANDLE;
 
 
-	ANKI_USE_RESULT Error init(
-		VkDevice dev, VkPhysicalDevice pdev, CString cacheDir, const ConfigSet& cfg, GrAllocator<U8> alloc);
+	ANKI_USE_RESULT Error init(VkDevice dev, VkPhysicalDevice pdev, CString cacheDir, const ConfigSet& cfg,
+							   GrAllocator<U8> alloc);
 
 
 	void destroy(VkDevice dev, VkPhysicalDevice pdev, GrAllocator<U8> alloc);
 	void destroy(VkDevice dev, VkPhysicalDevice pdev, GrAllocator<U8> alloc);
 
 

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

@@ -20,8 +20,8 @@ void PipelineLayoutFactory::destroy()
 	}
 	}
 }
 }
 
 
-Error PipelineLayoutFactory::newPipelineLayout(
-	const WeakArray<DescriptorSetLayout>& dsetLayouts, U32 pushConstantsSize, PipelineLayout& layout)
+Error PipelineLayoutFactory::newPipelineLayout(const WeakArray<DescriptorSetLayout>& dsetLayouts, U32 pushConstantsSize,
+											   PipelineLayout& layout)
 {
 {
 	U64 hash = computeHash(&pushConstantsSize, sizeof(pushConstantsSize));
 	U64 hash = computeHash(&pushConstantsSize, sizeof(pushConstantsSize));
 	Array<VkDescriptorSetLayout, MAX_DESCRIPTOR_SETS> vkDsetLayouts;
 	Array<VkDescriptorSetLayout, MAX_DESCRIPTOR_SETS> vkDsetLayouts;

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

@@ -45,8 +45,8 @@ public:
 	void destroy();
 	void destroy();
 
 
 	/// @note It's thread-safe.
 	/// @note It's thread-safe.
-	ANKI_USE_RESULT Error newPipelineLayout(
-		const WeakArray<DescriptorSetLayout>& dsetLayouts, U32 pushConstantsSize, PipelineLayout& layout);
+	ANKI_USE_RESULT Error newPipelineLayout(const WeakArray<DescriptorSetLayout>& dsetLayouts, U32 pushConstantsSize,
+											PipelineLayout& layout);
 
 
 private:
 private:
 	GrAllocator<U8> m_alloc;
 	GrAllocator<U8> m_alloc;

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

@@ -38,14 +38,14 @@ ShaderImpl::~ShaderImpl()
 
 
 	if(m_specConstInfo.pMapEntries)
 	if(m_specConstInfo.pMapEntries)
 	{
 	{
-		getAllocator().deleteArray(
-			const_cast<VkSpecializationMapEntry*>(m_specConstInfo.pMapEntries), m_specConstInfo.mapEntryCount);
+		getAllocator().deleteArray(const_cast<VkSpecializationMapEntry*>(m_specConstInfo.pMapEntries),
+								   m_specConstInfo.mapEntryCount);
 	}
 	}
 
 
 	if(m_specConstInfo.pData)
 	if(m_specConstInfo.pData)
 	{
 	{
-		getAllocator().deleteArray(
-			static_cast<I32*>(const_cast<void*>(m_specConstInfo.pData)), m_specConstInfo.dataSize / sizeof(I32));
+		getAllocator().deleteArray(static_cast<I32*>(const_cast<void*>(m_specConstInfo.pData)),
+								   m_specConstInfo.dataSize / sizeof(I32));
 	}
 	}
 }
 }
 
 
@@ -66,11 +66,8 @@ Error ShaderImpl::init(const ShaderInitInfo& inf)
 	}
 	}
 #endif
 #endif
 
 
-	VkShaderModuleCreateInfo ci = {VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
-		nullptr,
-		0,
-		inf.m_binary.getSize(),
-		reinterpret_cast<const uint32_t*>(&inf.m_binary[0])};
+	VkShaderModuleCreateInfo ci = {VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, nullptr, 0, inf.m_binary.getSize(),
+								   reinterpret_cast<const uint32_t*>(&inf.m_binary[0])};
 
 
 	ANKI_VK_CHECK(vkCreateShaderModule(getDevice(), &ci, nullptr, &m_handle));
 	ANKI_VK_CHECK(vkCreateShaderModule(getDevice(), &ci, nullptr, &m_handle));
 
 

+ 8 - 8
src/anki/gr/vulkan/ShaderProgramImpl.cpp

@@ -111,10 +111,10 @@ Error ShaderProgramImpl::init(const ShaderProgramInitInfo& inf)
 
 
 	// Create the ppline layout
 	// Create the ppline layout
 	//
 	//
-	WeakArray<DescriptorSetLayout> dsetLayouts(
-		(descriptorSetCount) ? &m_descriptorSetLayouts[0] : nullptr, descriptorSetCount);
-	ANKI_CHECK(getGrManagerImpl().getPipelineLayoutFactory().newPipelineLayout(
-		dsetLayouts, m_refl.m_pushConstantsSize, m_pplineLayout));
+	WeakArray<DescriptorSetLayout> dsetLayouts((descriptorSetCount) ? &m_descriptorSetLayouts[0] : nullptr,
+											   descriptorSetCount);
+	ANKI_CHECK(getGrManagerImpl().getPipelineLayoutFactory().newPipelineLayout(dsetLayouts, m_refl.m_pushConstantsSize,
+																			   m_pplineLayout));
 
 
 	// Get some masks
 	// Get some masks
 	//
 	//
@@ -160,8 +160,8 @@ Error ShaderProgramImpl::init(const ShaderProgramInitInfo& inf)
 	if(graphicsProg)
 	if(graphicsProg)
 	{
 	{
 		m_pplineFactory = getAllocator().newInstance<PipelineFactory>();
 		m_pplineFactory = getAllocator().newInstance<PipelineFactory>();
-		m_pplineFactory->init(
-			getGrManagerImpl().getAllocator(), getGrManagerImpl().getDevice(), getGrManagerImpl().getPipelineCache());
+		m_pplineFactory->init(getGrManagerImpl().getAllocator(), getGrManagerImpl().getDevice(),
+							  getGrManagerImpl().getPipelineCache());
 	}
 	}
 
 
 	// Create the pipeline if compute
 	// Create the pipeline if compute
@@ -180,8 +180,8 @@ Error ShaderProgramImpl::init(const ShaderProgramInitInfo& inf)
 		ci.stage.module = shaderImpl.m_handle;
 		ci.stage.module = shaderImpl.m_handle;
 		ci.stage.pSpecializationInfo = shaderImpl.getSpecConstInfo();
 		ci.stage.pSpecializationInfo = shaderImpl.getSpecConstInfo();
 
 
-		ANKI_VK_CHECK(vkCreateComputePipelines(
-			getDevice(), getGrManagerImpl().getPipelineCache(), 1, &ci, nullptr, &m_computePpline));
+		ANKI_VK_CHECK(vkCreateComputePipelines(getDevice(), getGrManagerImpl().getPipelineCache(), 1, &ci, nullptr,
+											   &m_computePpline));
 		getGrManagerImpl().printPipelineShaderInfo(m_computePpline, getName(), ShaderTypeBit::COMPUTE);
 		getGrManagerImpl().printPipelineShaderInfo(m_computePpline, getName(), ShaderTypeBit::COMPUTE);
 	}
 	}
 
 

+ 12 - 16
src/anki/gr/vulkan/SwapchainFactory.cpp

@@ -44,8 +44,8 @@ Error MicroSwapchain::initInternal()
 	VkSurfaceCapabilitiesKHR surfaceProperties;
 	VkSurfaceCapabilitiesKHR surfaceProperties;
 	U32 surfaceWidth = 0, surfaceHeight = 0;
 	U32 surfaceWidth = 0, surfaceHeight = 0;
 	{
 	{
-		ANKI_VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
-			m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(), &surfaceProperties));
+		ANKI_VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(m_factory->m_gr->getPhysicalDevice(),
+																m_factory->m_gr->getSurface(), &surfaceProperties));
 
 
 		if(surfaceProperties.currentExtent.width == MAX_U32 || surfaceProperties.currentExtent.height == MAX_U32)
 		if(surfaceProperties.currentExtent.width == MAX_U32 || surfaceProperties.currentExtent.height == MAX_U32)
 		{
 		{
@@ -61,13 +61,13 @@ Error MicroSwapchain::initInternal()
 	VkColorSpaceKHR colorspace = VK_COLOR_SPACE_MAX_ENUM_KHR;
 	VkColorSpaceKHR colorspace = VK_COLOR_SPACE_MAX_ENUM_KHR;
 	{
 	{
 		uint32_t formatCount;
 		uint32_t formatCount;
-		ANKI_VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(
-			m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(), &formatCount, nullptr));
+		ANKI_VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(m_factory->m_gr->getPhysicalDevice(),
+														   m_factory->m_gr->getSurface(), &formatCount, nullptr));
 
 
 		DynamicArrayAuto<VkSurfaceFormatKHR> formats(getAllocator());
 		DynamicArrayAuto<VkSurfaceFormatKHR> formats(getAllocator());
 		formats.create(formatCount);
 		formats.create(formatCount);
-		ANKI_VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(
-			m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(), &formatCount, &formats[0]));
+		ANKI_VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(m_factory->m_gr->getPhysicalDevice(),
+														   m_factory->m_gr->getSurface(), &formatCount, &formats[0]));
 
 
 		while(formatCount--)
 		while(formatCount--)
 		{
 		{
@@ -91,12 +91,12 @@ Error MicroSwapchain::initInternal()
 	VkPresentModeKHR presentModeSecondChoice = VK_PRESENT_MODE_MAX_ENUM_KHR;
 	VkPresentModeKHR presentModeSecondChoice = VK_PRESENT_MODE_MAX_ENUM_KHR;
 	{
 	{
 		uint32_t presentModeCount;
 		uint32_t presentModeCount;
-		vkGetPhysicalDeviceSurfacePresentModesKHR(
-			m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(), &presentModeCount, nullptr);
+		vkGetPhysicalDeviceSurfacePresentModesKHR(m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(),
+												  &presentModeCount, nullptr);
 		presentModeCount = min(presentModeCount, 4u);
 		presentModeCount = min(presentModeCount, 4u);
 		Array<VkPresentModeKHR, 4> presentModes;
 		Array<VkPresentModeKHR, 4> presentModes;
-		vkGetPhysicalDeviceSurfacePresentModesKHR(
-			m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(), &presentModeCount, &presentModes[0]);
+		vkGetPhysicalDeviceSurfacePresentModesKHR(m_factory->m_gr->getPhysicalDevice(), m_factory->m_gr->getSurface(),
+												  &presentModeCount, &presentModes[0]);
 
 
 		if(m_factory->m_vsync)
 		if(m_factory->m_vsync)
 		{
 		{
@@ -169,12 +169,8 @@ Error MicroSwapchain::initInternal()
 			return Error::FUNCTION_FAILED;
 			return Error::FUNCTION_FAILED;
 		}
 		}
 
 
-		ANKI_VK_LOGI("Created a swapchain. Image count: %u, present mode: %u, size: %ux%u, vsync: %u",
-			count,
-			presentMode,
-			surfaceWidth,
-			surfaceHeight,
-			U32(m_factory->m_vsync));
+		ANKI_VK_LOGI("Created a swapchain. Image count: %u, present mode: %u, size: %ux%u, vsync: %u", count,
+					 presentMode, surfaceWidth, surfaceHeight, U32(m_factory->m_vsync));
 
 
 		Array<VkImage, MAX_FRAMES_IN_FLIGHT> images;
 		Array<VkImage, MAX_FRAMES_IN_FLIGHT> images;
 		ANKI_VK_CHECK(vkGetSwapchainImagesKHR(dev, m_swapchain, &count, &images[0]));
 		ANKI_VK_CHECK(vkGetSwapchainImagesKHR(dev, m_swapchain, &count, &images[0]));

+ 23 - 34
src/anki/gr/vulkan/TextureImpl.cpp

@@ -141,8 +141,8 @@ Error TextureImpl::initInternal(VkImage externalImage, const TextureInitInfo& in
 		range.layerCount = m_layerCount;
 		range.layerCount = m_layerCount;
 		range.levelCount = m_mipCount;
 		range.levelCount = m_mipCount;
 
 
-		static_cast<CommandBufferImpl&>(*cmdb).setTextureBarrierRange(
-			TexturePtr(this), TextureUsageBit::NONE, init.m_initialUsage, range);
+		static_cast<CommandBufferImpl&>(*cmdb).setTextureBarrierRange(TexturePtr(this), TextureUsageBit::NONE,
+																	  init.m_initialUsage, range);
 
 
 		static_cast<CommandBufferImpl&>(*cmdb).endRecording();
 		static_cast<CommandBufferImpl&>(*cmdb).endRecording();
 		getGrManagerImpl().flushCommandBuffer(cmdb, nullptr);
 		getGrManagerImpl().flushCommandBuffer(cmdb, nullptr);
@@ -197,13 +197,9 @@ Bool TextureImpl::imageSupported(const TextureInitInfo& init)
 {
 {
 	VkImageFormatProperties props = {};
 	VkImageFormatProperties props = {};
 
 
-	VkResult res = vkGetPhysicalDeviceImageFormatProperties(getGrManagerImpl().getPhysicalDevice(),
-		m_vkFormat,
-		convertTextureType(init.m_type),
-		VK_IMAGE_TILING_OPTIMAL,
-		convertTextureUsage(init.m_usage, init.m_format),
-		calcCreateFlags(init),
-		&props);
+	VkResult res = vkGetPhysicalDeviceImageFormatProperties(
+		getGrManagerImpl().getPhysicalDevice(), m_vkFormat, convertTextureType(init.m_type), VK_IMAGE_TILING_OPTIMAL,
+		convertTextureUsage(init.m_usage, init.m_format), calcCreateFlags(init), &props);
 
 
 	if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 	if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
 	{
 	{
@@ -237,8 +233,8 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 		}
 		}
 		else if(init.m_format == Format::S8_UINT)
 		else if(init.m_format == Format::S8_UINT)
 		{
 		{
-			ANKI_ASSERT(
-				!(init.m_usage & (TextureUsageBit::IMAGE_ALL | TextureUsageBit::TRANSFER_ALL)) && "Can't do that ATM");
+			ANKI_ASSERT(!(init.m_usage & (TextureUsageBit::IMAGE_ALL | TextureUsageBit::TRANSFER_ALL))
+						&& "Can't do that ATM");
 			init.m_format = Format::D24_UNORM_S8_UINT;
 			init.m_format = Format::D24_UNORM_S8_UINT;
 			m_format = init.m_format;
 			m_format = init.m_format;
 			m_vkFormat = convertFormat(m_format);
 			m_vkFormat = convertFormat(m_format);
@@ -246,8 +242,8 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 		}
 		}
 		else if(init.m_format == Format::D24_UNORM_S8_UINT)
 		else if(init.m_format == Format::D24_UNORM_S8_UINT)
 		{
 		{
-			ANKI_ASSERT(
-				!(init.m_usage & (TextureUsageBit::IMAGE_ALL | TextureUsageBit::TRANSFER_ALL)) && "Can't do that ATM");
+			ANKI_ASSERT(!(init.m_usage & (TextureUsageBit::IMAGE_ALL | TextureUsageBit::TRANSFER_ALL))
+						&& "Can't do that ATM");
 			init.m_format = Format::D32_SFLOAT_S8_UINT;
 			init.m_format = Format::D32_SFLOAT_S8_UINT;
 			m_format = init.m_format;
 			m_format = init.m_format;
 			m_vkFormat = convertFormat(m_format);
 			m_vkFormat = convertFormat(m_format);
@@ -336,14 +332,14 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 	vkGetImageMemoryRequirements2(getDevice(), &imageRequirementsInfo, &requirements);
 	vkGetImageMemoryRequirements2(getDevice(), &imageRequirementsInfo, &requirements);
 
 
 	U32 memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(requirements.memoryRequirements.memoryTypeBits,
 	U32 memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(requirements.memoryRequirements.memoryTypeBits,
-		VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
-		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
+																		 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+																		 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
 
 
 	// Fallback
 	// Fallback
 	if(memIdx == MAX_U32)
 	if(memIdx == MAX_U32)
 	{
 	{
-		memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(
-			requirements.memoryRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0);
+		memIdx = getGrManagerImpl().getGpuMemoryManager().findMemoryType(requirements.memoryRequirements.memoryTypeBits,
+																		 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0);
 	}
 	}
 
 
 	ANKI_ASSERT(memIdx != MAX_U32);
 	ANKI_ASSERT(memIdx != MAX_U32);
@@ -351,12 +347,9 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 	if(!dedicatedRequirements.prefersDedicatedAllocation)
 	if(!dedicatedRequirements.prefersDedicatedAllocation)
 	{
 	{
 		// Allocate
 		// Allocate
-		getGrManagerImpl().getGpuMemoryManager().allocateMemory(memIdx,
-			requirements.memoryRequirements.size,
-			U32(requirements.memoryRequirements.alignment),
-			false,
-			false,
-			m_memHandle);
+		getGrManagerImpl().getGpuMemoryManager().allocateMemory(memIdx, requirements.memoryRequirements.size,
+																U32(requirements.memoryRequirements.alignment), false,
+																false, m_memHandle);
 
 
 		// Bind mem to image
 		// Bind mem to image
 		ANKI_TRACE_SCOPED_EVENT(VK_BIND_OBJECT);
 		ANKI_TRACE_SCOPED_EVENT(VK_BIND_OBJECT);
@@ -375,8 +368,8 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 		memoryAllocateInfo.memoryTypeIndex = memIdx;
 		memoryAllocateInfo.memoryTypeIndex = memIdx;
 
 
 		ANKI_VK_CHECK(vkAllocateMemory(getDevice(), &memoryAllocateInfo, nullptr, &m_dedicatedMem));
 		ANKI_VK_CHECK(vkAllocateMemory(getDevice(), &memoryAllocateInfo, nullptr, &m_dedicatedMem));
-		getGrManagerImpl().trySetVulkanHandleName(
-			init.getName(), VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, ptrToNumber(m_dedicatedMem));
+		getGrManagerImpl().trySetVulkanHandleName(init.getName(), VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT,
+												  ptrToNumber(m_dedicatedMem));
 
 
 		ANKI_TRACE_SCOPED_EVENT(VK_BIND_OBJECT);
 		ANKI_TRACE_SCOPED_EVENT(VK_BIND_OBJECT);
 		ANKI_VK_CHECK(vkBindImageMemory(getDevice(), m_imageHandle, m_dedicatedMem, 0));
 		ANKI_VK_CHECK(vkBindImageMemory(getDevice(), m_imageHandle, m_dedicatedMem, 0));
@@ -385,13 +378,9 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-void TextureImpl::computeBarrierInfo(TextureUsageBit before,
-	TextureUsageBit after,
-	U level,
-	VkPipelineStageFlags& srcStages,
-	VkAccessFlags& srcAccesses,
-	VkPipelineStageFlags& dstStages,
-	VkAccessFlags& dstAccesses) const
+void TextureImpl::computeBarrierInfo(TextureUsageBit before, TextureUsageBit after, U level,
+									 VkPipelineStageFlags& srcStages, VkAccessFlags& srcAccesses,
+									 VkPipelineStageFlags& dstStages, VkAccessFlags& dstAccesses) const
 {
 {
 	ANKI_ASSERT(level < m_mipCount);
 	ANKI_ASSERT(level < m_mipCount);
 	ANKI_ASSERT(usageValid(before) && usageValid(after));
 	ANKI_ASSERT(usageValid(before) && usageValid(after));
@@ -713,8 +702,8 @@ const MicroImageView& TextureImpl::getOrCreateView(const TextureSubresourceInfo&
 		ANKI_ASSERT(viewTexType != TextureType::COUNT);
 		ANKI_ASSERT(viewTexType != TextureType::COUNT);
 
 
 		ANKI_VK_CHECKF(vkCreateImageView(getDevice(), &viewCi, nullptr, &handle));
 		ANKI_VK_CHECKF(vkCreateImageView(getDevice(), &viewCi, nullptr, &handle));
-		getGrManagerImpl().trySetVulkanHandleName(
-			getName(), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT, ptrToNumber(handle));
+		getGrManagerImpl().trySetVulkanHandleName(getName(), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT,
+												  ptrToNumber(handle));
 
 
 		it = m_viewsMap.emplace(getAllocator(), subresource);
 		it = m_viewsMap.emplace(getAllocator(), subresource);
 		it->m_handle = handle;
 		it->m_handle = handle;

+ 7 - 11
src/anki/gr/vulkan/TextureImpl.h

@@ -147,13 +147,9 @@ public:
 	}
 	}
 
 
 	/// By knowing the previous and new texture usage calculate the relavant info for a ppline barrier.
 	/// By knowing the previous and new texture usage calculate the relavant info for a ppline barrier.
-	void computeBarrierInfo(TextureUsageBit before,
-		TextureUsageBit after,
-		U level,
-		VkPipelineStageFlags& srcStages,
-		VkAccessFlags& srcAccesses,
-		VkPipelineStageFlags& dstStages,
-		VkAccessFlags& dstAccesses) const;
+	void computeBarrierInfo(TextureUsageBit before, TextureUsageBit after, U level, VkPipelineStageFlags& srcStages,
+							VkAccessFlags& srcAccesses, VkPipelineStageFlags& dstStages,
+							VkAccessFlags& dstAccesses) const;
 
 
 	/// Predict the image layout.
 	/// Predict the image layout.
 	VkImageLayout computeLayout(TextureUsageBit usage, U level) const;
 	VkImageLayout computeLayout(TextureUsageBit usage, U level) const;
@@ -171,8 +167,8 @@ public:
 		range.layerCount = in.m_layerCount * in.m_faceCount;
 		range.layerCount = in.m_layerCount * in.m_faceCount;
 	}
 	}
 
 
-	void computeVkImageViewCreateInfo(
-		const TextureSubresourceInfo& subresource, VkImageViewCreateInfo& viewCi, TextureType& newTextureType) const
+	void computeVkImageViewCreateInfo(const TextureSubresourceInfo& subresource, VkImageViewCreateInfo& viewCi,
+									  TextureType& newTextureType) const
 	{
 	{
 		ANKI_ASSERT(isSubresourceValid(subresource));
 		ANKI_ASSERT(isSubresourceValid(subresource));
 
 
@@ -206,8 +202,8 @@ private:
 	ANKI_USE_RESULT Error initImage(const TextureInitInfo& init);
 	ANKI_USE_RESULT Error initImage(const TextureInitInfo& init);
 
 
 	template<typename TextureInfo>
 	template<typename TextureInfo>
-	void updateUsageState(
-		const TextureInfo& surfOrVol, TextureUsageBit usage, StackAllocator<U8>& alloc, TextureUsageState& state) const;
+	void updateUsageState(const TextureInfo& surfOrVol, TextureUsageBit usage, StackAllocator<U8>& alloc,
+						  TextureUsageState& state) const;
 
 
 	void updateUsageState(TextureUsageBit usage, StackAllocator<U8>& alloc, TextureUsageState& state) const;
 	void updateUsageState(TextureUsageBit usage, StackAllocator<U8>& alloc, TextureUsageState& state) const;
 
 

+ 2 - 8
src/anki/gr/vulkan/TimestampQueryImpl.cpp

@@ -33,14 +33,8 @@ TimestampQueryResult TimestampQueryImpl::getResultInternal(Second& timestamp) co
 
 
 	VkResult res;
 	VkResult res;
 	U64 value;
 	U64 value;
-	ANKI_VK_CHECKF(res = vkGetQueryPoolResults(getDevice(),
-					   m_handle.getQueryPool(),
-					   m_handle.getQueryIndex(),
-					   1,
-					   sizeof(value),
-					   &value,
-					   sizeof(value),
-					   VK_QUERY_RESULT_64_BIT));
+	ANKI_VK_CHECKF(res = vkGetQueryPoolResults(getDevice(), m_handle.getQueryPool(), m_handle.getQueryIndex(), 1,
+											   sizeof(value), &value, sizeof(value), VK_QUERY_RESULT_64_BIT));
 
 
 	TimestampQueryResult qout = TimestampQueryResult::NOT_AVAILABLE;
 	TimestampQueryResult qout = TimestampQueryResult::NOT_AVAILABLE;
 	if(res == VK_SUCCESS)
 	if(res == VK_SUCCESS)

+ 51 - 99
src/anki/importer/GltfImporter.cpp

@@ -154,16 +154,8 @@ GltfImporter::~GltfImporter()
 	m_alloc.deleteInstance(m_hive);
 	m_alloc.deleteInstance(m_hive);
 }
 }
 
 
-Error GltfImporter::init(CString inputFname,
-	CString outDir,
-	CString rpath,
-	CString texrpath,
-	Bool optimizeMeshes,
-	F32 lodFactor,
-	U32 lodCount,
-	F32 lightIntensityScale,
-	U32 threadCount,
-	CString comment)
+Error GltfImporter::init(CString inputFname, CString outDir, CString rpath, CString texrpath, Bool optimizeMeshes,
+						 F32 lodFactor, U32 lodCount, F32 lightIntensityScale, U32 threadCount, CString comment)
 {
 {
 	m_inputFname.create(inputFname);
 	m_inputFname.create(inputFname);
 	m_outDir.create(outDir);
 	m_outDir.create(outDir);
@@ -397,15 +389,15 @@ Error GltfImporter::parseArrayOfNumbers(CString str, DynamicArrayAuto<F64>& out,
 
 
 	if(expectedArraySize && *expectedArraySize != out.getSize())
 	if(expectedArraySize && *expectedArraySize != out.getSize())
 	{
 	{
-		ANKI_GLTF_LOGE(
-			"Failed to parse floats. Expecting %u floats got %u: %s", *expectedArraySize, out.getSize(), str.cstr());
+		ANKI_GLTF_LOGE("Failed to parse floats. Expecting %u floats got %u: %s", *expectedArraySize, out.getSize(),
+					   str.cstr());
 	}
 	}
 
 
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-Error GltfImporter::visitNode(
-	const cgltf_node& node, const Transform& parentTrf, const HashMapAuto<CString, StringAuto>& parentExtras)
+Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf,
+							  const HashMapAuto<CString, StringAuto>& parentExtras)
 {
 {
 	// Check error from a thread
 	// Check error from a thread
 	const Error threadErr = m_errorInThread.load();
 	const Error threadErr = m_errorInThread.load();
@@ -452,9 +444,7 @@ Error GltfImporter::visitNode(
 			}
 			}
 
 
 			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:new%sParticleEmitterNode(\"%s\", \"%s\")\n",
 			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:new%sParticleEmitterNode(\"%s\", \"%s\")\n",
-				(gpuParticles) ? "Gpu" : "",
-				getNodeName(node).cstr(),
-				fname.cstr()));
+											 (gpuParticles) ? "Gpu" : "", getNodeName(node).cstr(), fname.cstr()));
 
 
 			Transform localTrf;
 			Transform localTrf;
 			ANKI_CHECK(getNodeTransform(node, localTrf));
 			ANKI_CHECK(getNodeTransform(node, localTrf));
@@ -471,14 +461,11 @@ Error GltfImporter::visitNode(
 
 
 				ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>%s%s.ankimesh"
 				ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>%s%s.ankimesh"
 										  "</value>\n</collisionShape>\n",
 										  "</value>\n</collisionShape>\n",
-					m_rpath.cstr(),
-					node.mesh->name));
+										  m_rpath.cstr(), node.mesh->name));
 			}
 			}
 
 
 			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newStaticCollisionNode(\"%s\", \"%s%s.ankicl\")\n",
 			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newStaticCollisionNode(\"%s\", \"%s%s.ankicl\")\n",
-				getNodeName(node).cstr(),
-				m_rpath.cstr(),
-				node.mesh->name));
+											 getNodeName(node).cstr(), m_rpath.cstr(), node.mesh->name));
 
 
 			Transform localTrf;
 			Transform localTrf;
 			ANKI_CHECK(getNodeTransform(node, localTrf));
 			ANKI_CHECK(getNodeTransform(node, localTrf));
@@ -497,12 +484,7 @@ Error GltfImporter::visitNode(
 
 
 			ANKI_CHECK(m_sceneFile.writeText(
 			ANKI_CHECK(m_sceneFile.writeText(
 				"\nnode = scene:newReflectionProbeNode(\"%s\", Vec4.new(%f, %f, %f, 0), Vec4.new(%f, %f, %f, 0))\n",
 				"\nnode = scene:newReflectionProbeNode(\"%s\", Vec4.new(%f, %f, %f, 0), Vec4.new(%f, %f, %f, 0))\n",
-				getNodeName(node).cstr(),
-				aabbMin.x(),
-				aabbMin.y(),
-				aabbMin.z(),
-				aabbMax.x(),
-				aabbMax.y(),
+				getNodeName(node).cstr(), aabbMin.x(), aabbMin.y(), aabbMin.z(), aabbMax.x(), aabbMax.y(),
 				aabbMax.z()));
 				aabbMax.z()));
 
 
 			Transform localTrf = Transform(tsl.xyz0(), Mat3x4(rot), 1.0f);
 			Transform localTrf = Transform(tsl.xyz0(), Mat3x4(rot), 1.0f);
@@ -531,17 +513,13 @@ Error GltfImporter::visitNode(
 				ANKI_CHECK(it->toNumber(cellSize));
 				ANKI_CHECK(it->toNumber(cellSize));
 			}
 			}
 
 
-			ANKI_CHECK(m_sceneFile.writeText(
-				"\nnode = scene:newGlobalIlluminationProbeNode(\"%s\")\n", getNodeName(node).cstr()));
+			ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newGlobalIlluminationProbeNode(\"%s\")\n",
+											 getNodeName(node).cstr()));
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getGlobalIlluminationProbeComponent()\n"));
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getGlobalIlluminationProbeComponent()\n"));
 
 
 			ANKI_CHECK(m_sceneFile.writeText("comp:setBoundingBox(Vec4.new(%f, %f, %f, 0), Vec4.new(%f, %f, %f, 0))\n",
 			ANKI_CHECK(m_sceneFile.writeText("comp:setBoundingBox(Vec4.new(%f, %f, %f, 0), Vec4.new(%f, %f, %f, 0))\n",
-				aabbMin.x(),
-				aabbMin.y(),
-				aabbMin.z(),
-				aabbMax.x(),
-				aabbMax.y(),
-				aabbMax.z()));
+											 aabbMin.x(), aabbMin.y(), aabbMin.z(), aabbMax.x(), aabbMax.y(),
+											 aabbMax.z()));
 
 
 			if(fadeDistance > 0.0f)
 			if(fadeDistance > 0.0f)
 			{
 			{
@@ -598,18 +576,15 @@ Error GltfImporter::visitNode(
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getDecalComponent()\n"));
 			ANKI_CHECK(m_sceneFile.writeText("comp = node:getSceneNodeBase():getDecalComponent()\n"));
 			if(diffuseAtlas)
 			if(diffuseAtlas)
 			{
 			{
-				ANKI_CHECK(m_sceneFile.writeText("comp:setDiffuseDecal(\"%s\", \"%s\", %f)\n",
-					diffuseAtlas.cstr(),
-					diffuseSubtexture.cstr(),
-					diffuseFactor));
+				ANKI_CHECK(m_sceneFile.writeText("comp:setDiffuseDecal(\"%s\", \"%s\", %f)\n", diffuseAtlas.cstr(),
+												 diffuseSubtexture.cstr(), diffuseFactor));
 			}
 			}
 
 
 			if(specularRougnessMetallicAtlas)
 			if(specularRougnessMetallicAtlas)
 			{
 			{
-				ANKI_CHECK(m_sceneFile.writeText("comp:setSpecularRoughnessDecal(\"%s\", \"%s\", %f)\n",
-					specularRougnessMetallicAtlas.cstr(),
-					specularRougnessMetallicSubtexture.cstr(),
-					specularRougnessMetallicFactor));
+				ANKI_CHECK(m_sceneFile.writeText(
+					"comp:setSpecularRoughnessDecal(\"%s\", \"%s\", %f)\n", specularRougnessMetallicAtlas.cstr(),
+					specularRougnessMetallicSubtexture.cstr(), specularRougnessMetallicFactor));
 			}
 			}
 
 
 			Vec3 tsl;
 			Vec3 tsl;
@@ -719,9 +694,7 @@ Error GltfImporter::visitNode(
 			{
 			{
 				ANKI_CHECK(
 				ANKI_CHECK(
 					m_sceneFile.writeText("node2 = scene:newStaticCollisionNode(\"%s_cl\", \"%s%s.ankicl\", trf)\n",
 					m_sceneFile.writeText("node2 = scene:newStaticCollisionNode(\"%s_cl\", \"%s%s.ankicl\", trf)\n",
-						getNodeName(node).cstr(),
-						m_rpath.cstr(),
-						node.mesh->name));
+										  getNodeName(node).cstr(), m_rpath.cstr(), node.mesh->name));
 			}
 			}
 		}
 		}
 	}
 	}
@@ -751,8 +724,8 @@ Error GltfImporter::visitNode(
 Error GltfImporter::writeTransform(const Transform& trf)
 Error GltfImporter::writeTransform(const Transform& trf)
 {
 {
 	ANKI_CHECK(m_sceneFile.writeText("trf = Transform.new()\n"));
 	ANKI_CHECK(m_sceneFile.writeText("trf = Transform.new()\n"));
-	ANKI_CHECK(m_sceneFile.writeText(
-		"trf:setOrigin(Vec4.new(%f, %f, %f, 0))\n", trf.getOrigin().x(), trf.getOrigin().y(), trf.getOrigin().z()));
+	ANKI_CHECK(m_sceneFile.writeText("trf:setOrigin(Vec4.new(%f, %f, %f, 0))\n", trf.getOrigin().x(),
+									 trf.getOrigin().y(), trf.getOrigin().z()));
 
 
 	ANKI_CHECK(m_sceneFile.writeText("rot = Mat3x4.new()\n"));
 	ANKI_CHECK(m_sceneFile.writeText("rot = Mat3x4.new()\n"));
 	ANKI_CHECK(m_sceneFile.writeText("rot:setAll("));
 	ANKI_CHECK(m_sceneFile.writeText("rot:setAll("));
@@ -817,8 +790,8 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh, CString skinName)
 	}
 	}
 	else
 	else
 	{
 	{
-		ANKI_CHECK(file.writeText(
-			"\t\t\t<material>%s%s.ankimtl</material>\n", m_rpath.cstr(), mesh.primitives[0].material->name));
+		ANKI_CHECK(file.writeText("\t\t\t<material>%s%s.ankimtl</material>\n", m_rpath.cstr(),
+								  mesh.primitives[0].material->name));
 	}
 	}
 
 
 	ANKI_CHECK(file.writeText("\t\t</modelPatch>\n"));
 	ANKI_CHECK(file.writeText("\t\t</modelPatch>\n"));
@@ -862,8 +835,8 @@ public:
 
 
 /// Optimize out same animation keys.
 /// Optimize out same animation keys.
 template<typename T, typename TZeroFunc, typename TLerpFunc>
 template<typename T, typename TZeroFunc, typename TLerpFunc>
-static void optimizeChannel(
-	DynamicArrayAuto<GltfAnimKey<T>>& arr, const T& identity, TZeroFunc isZeroFunc, TLerpFunc lerpFunc)
+static void optimizeChannel(DynamicArrayAuto<GltfAnimKey<T>>& arr, const T& identity, TZeroFunc isZeroFunc,
+							TLerpFunc lerpFunc)
 {
 {
 	if(arr.getSize() < 3)
 	if(arr.getSize() < 3)
 	{
 	{
@@ -902,7 +875,7 @@ static void optimizeChannel(
 
 
 	// Check if identity
 	// Check if identity
 	if(newArr.getSize() == 2 && isZeroFunc(newArr[0].m_value - newArr[1].m_value)
 	if(newArr.getSize() == 2 && isZeroFunc(newArr[0].m_value - newArr[1].m_value)
-		&& isZeroFunc(newArr[0].m_value - identity))
+	   && isZeroFunc(newArr[0].m_value - identity))
 	{
 	{
 		newArr.destroy();
 		newArr.destroy();
 	}
 	}
@@ -1034,7 +1007,7 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 			{
 			{
 				const F32 scaleEpsilon = 0.0001f;
 				const F32 scaleEpsilon = 0.0001f;
 				if(absolute(scales[i][0] - scales[i][1]) > scaleEpsilon
 				if(absolute(scales[i][0] - scales[i][1]) > scaleEpsilon
-					|| absolute(scales[i][0] - scales[i][2]) > scaleEpsilon)
+				   || absolute(scales[i][0] - scales[i][2]) > scaleEpsilon)
 				{
 				{
 					ANKI_GLTF_LOGE("Expecting uniform scale");
 					ANKI_GLTF_LOGE("Expecting uniform scale");
 					return Error::USER_DATA;
 					return Error::USER_DATA;
@@ -1060,17 +1033,15 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 	constexpr F32 KILL_EPSILON = 0.001f; // 1 millimiter
 	constexpr F32 KILL_EPSILON = 0.001f; // 1 millimiter
 	for(GltfAnimChannel& channel : tempChannels)
 	for(GltfAnimChannel& channel : tempChannels)
 	{
 	{
-		optimizeChannel(channel.m_positions,
-			Vec3(0.0f),
-			[&](const Vec3& a) -> Bool { return a.abs() < KILL_EPSILON; },
+		optimizeChannel(
+			channel.m_positions, Vec3(0.0f), [&](const Vec3& a) -> Bool { return a.abs() < KILL_EPSILON; },
 			[&](const Vec3& a, const Vec3& b, F32 u) -> Vec3 { return linearInterpolate(a, b, u); });
 			[&](const Vec3& a, const Vec3& b, F32 u) -> Vec3 { return linearInterpolate(a, b, u); });
-		optimizeChannel(channel.m_rotations,
-			Quat::getIdentity(),
+		optimizeChannel(
+			channel.m_rotations, Quat::getIdentity(),
 			[&](const Quat& a) -> Bool { return a.abs() < Quat(EPSILON * 20.0f); },
 			[&](const Quat& a) -> Bool { return a.abs() < Quat(EPSILON * 20.0f); },
 			[&](const Quat& a, const Quat& b, F32 u) -> Quat { return a.slerp(b, u); });
 			[&](const Quat& a, const Quat& b, F32 u) -> Quat { return a.slerp(b, u); });
-		optimizeChannel(channel.m_scales,
-			1.0f,
-			[&](const F32& a) -> Bool { return absolute(a) < KILL_EPSILON; },
+		optimizeChannel(
+			channel.m_scales, 1.0f, [&](const F32& a) -> Bool { return absolute(a) < KILL_EPSILON; },
 			[&](const F32& a, const F32& b, F32 u) -> F32 { return linearInterpolate(a, b, u); });
 			[&](const F32& a, const F32& b, F32 u) -> F32 { return linearInterpolate(a, b, u); });
 	}
 	}
 
 
@@ -1091,11 +1062,8 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 			ANKI_CHECK(file.writeText("\t\t\t<positionKeys>\n"));
 			ANKI_CHECK(file.writeText("\t\t\t<positionKeys>\n"));
 			for(const GltfAnimKey<Vec3>& key : channel.m_positions)
 			for(const GltfAnimKey<Vec3>& key : channel.m_positions)
 			{
 			{
-				ANKI_CHECK(file.writeText("\t\t\t\t<key time=\"%f\">%f %f %f</key>\n",
-					key.m_time,
-					key.m_value.x(),
-					key.m_value.y(),
-					key.m_value.z()));
+				ANKI_CHECK(file.writeText("\t\t\t\t<key time=\"%f\">%f %f %f</key>\n", key.m_time, key.m_value.x(),
+										  key.m_value.y(), key.m_value.z()));
 			}
 			}
 			ANKI_CHECK(file.writeText("\t\t\t</positionKeys>\n"));
 			ANKI_CHECK(file.writeText("\t\t\t</positionKeys>\n"));
 		}
 		}
@@ -1106,12 +1074,8 @@ Error GltfImporter::writeAnimation(const cgltf_animation& anim)
 			ANKI_CHECK(file.writeText("\t\t\t<rotationKeys>\n"));
 			ANKI_CHECK(file.writeText("\t\t\t<rotationKeys>\n"));
 			for(const GltfAnimKey<Quat>& key : channel.m_rotations)
 			for(const GltfAnimKey<Quat>& key : channel.m_rotations)
 			{
 			{
-				ANKI_CHECK(file.writeText("\t\t\t\t<key time=\"%f\">%f %f %f %f</key>\n",
-					key.m_time,
-					key.m_value.x(),
-					key.m_value.y(),
-					key.m_value.z(),
-					key.m_value.w()));
+				ANKI_CHECK(file.writeText("\t\t\t\t<key time=\"%f\">%f %f %f %f</key>\n", key.m_time, key.m_value.x(),
+										  key.m_value.y(), key.m_value.z(), key.m_value.w()));
 			}
 			}
 			ANKI_CHECK(file.writeText("\t\t\t</rotationKeys>\n"));
 			ANKI_CHECK(file.writeText("\t\t\t</rotationKeys>\n"));
 		}
 		}
@@ -1217,16 +1181,13 @@ Error GltfImporter::writeCollisionMesh(const cgltf_mesh& mesh, U32 maxLod)
 	{
 	{
 		ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>"
 		ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>"
 								  "%s%s.ankimesh</value>\n</collisionShape>\n",
 								  "%s%s.ankimesh</value>\n</collisionShape>\n",
-			m_rpath.cstr(),
-			mesh.name));
+								  m_rpath.cstr(), mesh.name));
 	}
 	}
 	else
 	else
 	{
 	{
 		ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>"
 		ANKI_CHECK(file.writeText("<collisionShape>\n\t<type>staticMesh</type>\n\t<value>"
 								  "%s%s_lod%u.ankimesh</value>\n</collisionShape>\n",
 								  "%s%s_lod%u.ankimesh</value>\n</collisionShape>\n",
-			m_rpath.cstr(),
-			mesh.name,
-			maxLod));
+								  m_rpath.cstr(), mesh.name, maxLod));
 	}
 	}
 
 
 	return Error::NONE;
 	return Error::NONE;
@@ -1282,13 +1243,13 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 
 
 	if(light.type == cgltf_light_type_point)
 	if(light.type == cgltf_light_type_point)
 	{
 	{
-		ANKI_CHECK(m_sceneFile.writeText(
-			"lcomp:setRadius(%f)\n", (light.range > 0.0f) ? light.range : computeLightRadius(color)));
+		ANKI_CHECK(m_sceneFile.writeText("lcomp:setRadius(%f)\n",
+										 (light.range > 0.0f) ? light.range : computeLightRadius(color)));
 	}
 	}
 	else if(light.type == cgltf_light_type_spot)
 	else if(light.type == cgltf_light_type_spot)
 	{
 	{
-		ANKI_CHECK(m_sceneFile.writeText(
-			"lcomp:setDistance(%f)\n", (light.range > 0.0f) ? light.range : computeLightRadius(color)));
+		ANKI_CHECK(m_sceneFile.writeText("lcomp:setDistance(%f)\n",
+										 (light.range > 0.0f) ? light.range : computeLightRadius(color)));
 
 
 		const F32 outer = light.spot_outer_cone_angle * 2.0f;
 		const F32 outer = light.spot_outer_cone_angle * 2.0f;
 		ANKI_CHECK(m_sceneFile.writeText("lcomp:setOuterAngle(%f)\n", outer));
 		ANKI_CHECK(m_sceneFile.writeText("lcomp:setOuterAngle(%f)\n", outer));
@@ -1342,11 +1303,8 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 			const U32 count = 4;
 			const U32 count = 4;
 			ANKI_CHECK(parseArrayOfNumbers(lsColor->toCString(), numbers, &count));
 			ANKI_CHECK(parseArrayOfNumbers(lsColor->toCString(), numbers, &count));
 
 
-			ANKI_CHECK(m_sceneFile.writeText("lfcomp:setColorMultiplier(Vec4.new(%f, %f, %f, %f))\n",
-				numbers[0],
-				numbers[1],
-				numbers[2],
-				numbers[3]));
+			ANKI_CHECK(m_sceneFile.writeText("lfcomp:setColorMultiplier(Vec4.new(%f, %f, %f, %f))\n", numbers[0],
+											 numbers[1], numbers[2], numbers[3]));
 		}
 		}
 	}
 	}
 
 
@@ -1361,11 +1319,8 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			DynamicArrayAuto<F64> numbers(m_alloc);
 			const U32 count = 4;
 			const U32 count = 4;
 			ANKI_CHECK(parseArrayOfNumbers(lightEventIntensity->toCString(), numbers, &count));
 			ANKI_CHECK(parseArrayOfNumbers(lightEventIntensity->toCString(), numbers, &count));
-			ANKI_CHECK(m_sceneFile.writeText("event:setIntensityMultiplier(Vec4.new(%f, %f, %f, %f))\n",
-				numbers[0],
-				numbers[1],
-				numbers[2],
-				numbers[3]));
+			ANKI_CHECK(m_sceneFile.writeText("event:setIntensityMultiplier(Vec4.new(%f, %f, %f, %f))\n", numbers[0],
+											 numbers[1], numbers[2], numbers[3]));
 		}
 		}
 
 
 		if(lightEventFrequency != extras.getEnd())
 		if(lightEventFrequency != extras.getEnd())
@@ -1396,10 +1351,7 @@ Error GltfImporter::writeCamera(const cgltf_node& node, const HashMapAuto<CStrin
 	ANKI_CHECK(m_sceneFile.writeText("frustumc = node:getSceneNodeBase():getFrustumComponent()\n"));
 	ANKI_CHECK(m_sceneFile.writeText("frustumc = node:getSceneNodeBase():getFrustumComponent()\n"));
 
 
 	ANKI_CHECK(m_sceneFile.writeText("frustumc:setPerspective(%f, %f, getMainRenderer():getAspectRatio() * %f, %f)\n",
 	ANKI_CHECK(m_sceneFile.writeText("frustumc:setPerspective(%f, %f, getMainRenderer():getAspectRatio() * %f, %f)\n",
-		cam.znear,
-		cam.zfar,
-		cam.yfov,
-		cam.yfov));
+									 cam.znear, cam.zfar, cam.yfov, cam.yfov));
 
 
 	return Error::NONE;
 	return Error::NONE;
 }
 }
@@ -1414,8 +1366,8 @@ Error GltfImporter::writeModelNode(const cgltf_node& node, const HashMapAuto<CSt
 	StringAuto modelFname(m_alloc);
 	StringAuto modelFname(m_alloc);
 	modelFname.sprintf("%s%s_%s.ankimdl", m_rpath.cstr(), node.mesh->name, node.mesh->primitives[0].material->name);
 	modelFname.sprintf("%s%s_%s.ankimdl", m_rpath.cstr(), node.mesh->name, node.mesh->primitives[0].material->name);
 
 
-	ANKI_CHECK(m_sceneFile.writeText(
-		"\nnode = scene:newModelNode(\"%s\", \"%s\")\n", getNodeName(node).cstr(), modelFname.cstr()));
+	ANKI_CHECK(m_sceneFile.writeText("\nnode = scene:newModelNode(\"%s\", \"%s\")\n", getNodeName(node).cstr(),
+									 modelFname.cstr()));
 
 
 	return Error::NONE;
 	return Error::NONE;
 }
 }

+ 6 - 14
src/anki/importer/GltfImporter.h

@@ -30,16 +30,8 @@ public:
 
 
 	~GltfImporter();
 	~GltfImporter();
 
 
-	ANKI_USE_RESULT Error init(CString inputFname,
-		CString outDir,
-		CString rpath,
-		CString texrpath,
-		Bool optimizeMeshes,
-		F32 lodFactor,
-		U32 lodCount,
-		F32 lightIntensityScale,
-		U32 threadCount,
-		CString comment);
+	ANKI_USE_RESULT Error init(CString inputFname, CString outDir, CString rpath, CString texrpath, Bool optimizeMeshes,
+							   F32 lodFactor, U32 lodCount, F32 lightIntensityScale, U32 threadCount, CString comment);
 
 
 	ANKI_USE_RESULT Error writeAll();
 	ANKI_USE_RESULT Error writeAll();
 
 
@@ -83,8 +75,8 @@ private:
 
 
 	// Misc
 	// Misc
 	ANKI_USE_RESULT Error getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringAuto>& out);
 	ANKI_USE_RESULT Error getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringAuto>& out);
-	ANKI_USE_RESULT Error parseArrayOfNumbers(
-		CString str, DynamicArrayAuto<F64>& out, const U32* expectedArraySize = nullptr);
+	ANKI_USE_RESULT Error parseArrayOfNumbers(CString str, DynamicArrayAuto<F64>& out,
+											  const U32* expectedArraySize = nullptr);
 	void populateNodePtrToIdx();
 	void populateNodePtrToIdx();
 	void populateNodePtrToIdxInternal(const cgltf_node& node, U32& idx);
 	void populateNodePtrToIdxInternal(const cgltf_node& node, U32& idx);
 	StringAuto getNodeName(const cgltf_node& node);
 	StringAuto getNodeName(const cgltf_node& node);
@@ -116,8 +108,8 @@ private:
 
 
 	// Scene
 	// Scene
 	ANKI_USE_RESULT Error writeTransform(const Transform& trf);
 	ANKI_USE_RESULT Error writeTransform(const Transform& trf);
-	ANKI_USE_RESULT Error visitNode(
-		const cgltf_node& node, const Transform& parentTrf, const HashMapAuto<CString, StringAuto>& parentExtras);
+	ANKI_USE_RESULT Error visitNode(const cgltf_node& node, const Transform& parentTrf,
+									const HashMapAuto<CString, StringAuto>& parentExtras);
 	ANKI_USE_RESULT Error writeLight(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras);
 	ANKI_USE_RESULT Error writeLight(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras);
 	ANKI_USE_RESULT Error writeCamera(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras);
 	ANKI_USE_RESULT Error writeCamera(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras);
 	ANKI_USE_RESULT Error writeModelNode(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras);
 	ANKI_USE_RESULT Error writeModelNode(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras);

+ 29 - 34
src/anki/importer/GltfImporterMaterial.cpp

@@ -45,8 +45,8 @@ static CString getTextureUri(const cgltf_texture_view& view)
 }
 }
 
 
 /// Read the texture and find out if
 /// Read the texture and find out if
-static Error identifyMetallicRoughnessTexture(
-	CString fname, F32& constantMetalines, F32& constantRoughness, GenericMemoryPoolAllocator<U8>& alloc)
+static Error identifyMetallicRoughnessTexture(CString fname, F32& constantMetalines, F32& constantRoughness,
+											  GenericMemoryPoolAllocator<U8>& alloc)
 {
 {
 	ImageLoader iloader(alloc);
 	ImageLoader iloader(alloc);
 	ANKI_CHECK(iloader.load(fname));
 	ANKI_CHECK(iloader.load(fname));
@@ -114,17 +114,16 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		StringAuto uri(m_alloc);
 		StringAuto uri(m_alloc);
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.base_color_texture).cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.base_color_texture).cstr());
 
 
-		xml.replaceAll(
-			"%diff%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_diffTex\" value=\"%s\"/>", uri.cstr()));
+		xml.replaceAll("%diff%",
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_diffTex\" value=\"%s\"/>", uri.cstr()));
 		xml.replaceAll("%diffTexMutator%", "1");
 		xml.replaceAll("%diffTexMutator%", "1");
 	}
 	}
 	else
 	else
 	{
 	{
 		const F32* diffCol = &mtl.pbr_metallic_roughness.base_color_factor[0];
 		const F32* diffCol = &mtl.pbr_metallic_roughness.base_color_factor[0];
 
 
-		xml.replaceAll("%diff%",
-			StringAuto{m_alloc}.sprintf(
-				"<input shaderVar=\"m_diffColor\" value=\"%f %f %f\"/>", diffCol[0], diffCol[1], diffCol[2]));
+		xml.replaceAll("%diff%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_diffColor\" value=\"%f %f %f\"/>",
+															 diffCol[0], diffCol[1], diffCol[2]));
 
 
 		xml.replaceAll("%diffTexMutator%", "0");
 		xml.replaceAll("%diffTexMutator%", "0");
 	}
 	}
@@ -155,9 +154,8 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 			specular = Vec3(0.04f);
 			specular = Vec3(0.04f);
 		}
 		}
 
 
-		xml.replaceAll("%spec%",
-			StringAuto{m_alloc}.sprintf(
-				"<input shaderVar=\"m_specColor\" value=\"%f %f %f\"/>", specular.x(), specular.y(), specular.z()));
+		xml.replaceAll("%spec%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_specColor\" value=\"%f %f %f\"/>",
+															 specular.x(), specular.y(), specular.z()));
 
 
 		xml.replaceAll("%specTexMutator%", "0");
 		xml.replaceAll("%specTexMutator%", "0");
 	}
 	}
@@ -175,11 +173,11 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 	if(mtl.pbr_metallic_roughness.metallic_roughness_texture.texture && constantRoughness < 0.0f)
 	if(mtl.pbr_metallic_roughness.metallic_roughness_texture.texture && constantRoughness < 0.0f)
 	{
 	{
 		StringAuto uri(m_alloc);
 		StringAuto uri(m_alloc);
-		uri.sprintf(
-			"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
+		uri.sprintf("%s%s", m_texrpath.cstr(),
+					getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
 
 
 		xml.replaceAll("%roughness%",
 		xml.replaceAll("%roughness%",
-			StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_roughnessTex\" value=\"%s\"/>", uri.cstr()));
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_roughnessTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%roughnessTexMutator%", "1");
 		xml.replaceAll("%roughnessTexMutator%", "1");
 	}
 	}
@@ -189,8 +187,8 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 								  ? constantRoughness * mtl.pbr_metallic_roughness.roughness_factor
 								  ? constantRoughness * mtl.pbr_metallic_roughness.roughness_factor
 								  : mtl.pbr_metallic_roughness.roughness_factor;
 								  : mtl.pbr_metallic_roughness.roughness_factor;
 
 
-		xml.replaceAll(
-			"%roughness%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_roughness\" value=\"%f\"/>", roughness));
+		xml.replaceAll("%roughness%",
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_roughness\" value=\"%f\"/>", roughness));
 
 
 		xml.replaceAll("%roughnessTexMutator%", "0");
 		xml.replaceAll("%roughnessTexMutator%", "0");
 	}
 	}
@@ -199,11 +197,11 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 	if(mtl.pbr_metallic_roughness.metallic_roughness_texture.texture && constantMetaliness < 0.0f)
 	if(mtl.pbr_metallic_roughness.metallic_roughness_texture.texture && constantMetaliness < 0.0f)
 	{
 	{
 		StringAuto uri(m_alloc);
 		StringAuto uri(m_alloc);
-		uri.sprintf(
-			"%s%s", m_texrpath.cstr(), getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
+		uri.sprintf("%s%s", m_texrpath.cstr(),
+					getTextureUri(mtl.pbr_metallic_roughness.metallic_roughness_texture).cstr());
 
 
-		xml.replaceAll(
-			"%metallic%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_metallicTex\" value=\"%s\"/>", uri.cstr()));
+		xml.replaceAll("%metallic%",
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_metallicTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%metalTexMutator%", "1");
 		xml.replaceAll("%metalTexMutator%", "1");
 	}
 	}
@@ -213,8 +211,8 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 								  ? constantMetaliness * mtl.pbr_metallic_roughness.metallic_factor
 								  ? constantMetaliness * mtl.pbr_metallic_roughness.metallic_factor
 								  : mtl.pbr_metallic_roughness.metallic_factor;
 								  : mtl.pbr_metallic_roughness.metallic_factor;
 
 
-		xml.replaceAll(
-			"%metallic%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_metallic\" value=\"%f\"/>", metalines));
+		xml.replaceAll("%metallic%",
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_metallic\" value=\"%f\"/>", metalines));
 
 
 		xml.replaceAll("%metalTexMutator%", "0");
 		xml.replaceAll("%metalTexMutator%", "0");
 	}
 	}
@@ -225,8 +223,8 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		StringAuto uri(m_alloc);
 		StringAuto uri(m_alloc);
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.normal_texture).cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.normal_texture).cstr());
 
 
-		xml.replaceAll(
-			"%normal%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_normalTex\" value=\"%s\"/>", uri.cstr()));
+		xml.replaceAll("%normal%",
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_normalTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%normalTexMutator%", "1");
 		xml.replaceAll("%normalTexMutator%", "1");
 	}
 	}
@@ -242,8 +240,8 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		StringAuto uri(m_alloc);
 		StringAuto uri(m_alloc);
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.emissive_texture).cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), getTextureUri(mtl.emissive_texture).cstr());
 
 
-		xml.replaceAll(
-			"%emission%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_emissiveTex\" value=\"%s\"/>", uri.cstr()));
+		xml.replaceAll("%emission%",
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_emissiveTex\" value=\"%s\"/>", uri.cstr()));
 
 
 		xml.replaceAll("%emissiveTexMutator%", "1");
 		xml.replaceAll("%emissiveTexMutator%", "1");
 	}
 	}
@@ -251,11 +249,8 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 	{
 	{
 		const F32* emissionCol = &mtl.emissive_factor[0];
 		const F32* emissionCol = &mtl.emissive_factor[0];
 
 
-		xml.replaceAll("%emission%",
-			StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_emission\" value=\"%f %f %f\"/>",
-				emissionCol[0],
-				emissionCol[1],
-				emissionCol[2]));
+		xml.replaceAll("%emission%", StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_emission\" value=\"%f %f %f\"/>",
+																 emissionCol[0], emissionCol[1], emissionCol[2]));
 
 
 		xml.replaceAll("%emissiveTexMutator%", "0");
 		xml.replaceAll("%emissiveTexMutator%", "0");
 	}
 	}
@@ -274,7 +269,7 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		}
 		}
 
 
 		xml.replaceAll("%subsurface%",
 		xml.replaceAll("%subsurface%",
-			StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_subsurface\" value=\"%f\"/>", subsurface));
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"m_subsurface\" value=\"%f\"/>", subsurface));
 	}
 	}
 
 
 	// Height texture
 	// Height texture
@@ -285,9 +280,9 @@ Error GltfImporter::writeMaterial(const cgltf_material& mtl)
 		uri.sprintf("%s%s", m_texrpath.cstr(), it->cstr());
 		uri.sprintf("%s%s", m_texrpath.cstr(), it->cstr());
 
 
 		xml.replaceAll("%height%",
 		xml.replaceAll("%height%",
-			StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_heightTex\" value=\"%s\" \"/>\n"
-										"\t\t<input shaderVar=\"m_heightmapScale\" value=\"0.05\"/>",
-				uri.cstr()));
+					   StringAuto{m_alloc}.sprintf("<input shaderVar=\"u_heightTex\" value=\"%s\" \"/>\n"
+												   "\t\t<input shaderVar=\"m_heightmapScale\" value=\"0.05\"/>",
+												   uri.cstr()));
 
 
 		xml.replaceAll("%parallaxMutator%", "1");
 		xml.replaceAll("%parallaxMutator%", "1");
 	}
 	}

+ 24 - 46
src/anki/importer/GltfImporterMesh.cpp

@@ -141,12 +141,8 @@ static void reindexSubmesh(SubMesh& submesh, GenericMemoryPoolAllocator<U8> allo
 	DynamicArrayAuto<U32> remap(alloc);
 	DynamicArrayAuto<U32> remap(alloc);
 	remap.create(submesh.m_verts.getSize(), 0);
 	remap.create(submesh.m_verts.getSize(), 0);
 
 
-	const U32 vertCount = U32(meshopt_generateVertexRemap(&remap[0],
-		&submesh.m_indices[0],
-		submesh.m_indices.getSize(),
-		&submesh.m_verts[0],
-		submesh.m_verts.getSize(),
-		vertSize));
+	const U32 vertCount = U32(meshopt_generateVertexRemap(&remap[0], &submesh.m_indices[0], submesh.m_indices.getSize(),
+														  &submesh.m_verts[0], submesh.m_verts.getSize(), vertSize));
 
 
 	DynamicArrayAuto<U32> newIdxArray(alloc);
 	DynamicArrayAuto<U32> newIdxArray(alloc);
 	newIdxArray.create(submesh.m_indices.getSize(), 0);
 	newIdxArray.create(submesh.m_indices.getSize(), 0);
@@ -170,8 +166,8 @@ static void optimizeSubmesh(SubMesh& submesh, GenericMemoryPoolAllocator<U8> all
 		DynamicArrayAuto<U32> newIdxArray(alloc);
 		DynamicArrayAuto<U32> newIdxArray(alloc);
 		newIdxArray.create(submesh.m_indices.getSize(), 0);
 		newIdxArray.create(submesh.m_indices.getSize(), 0);
 
 
-		meshopt_optimizeVertexCache(
-			&newIdxArray[0], &submesh.m_indices[0], submesh.m_indices.getSize(), submesh.m_verts.getSize());
+		meshopt_optimizeVertexCache(&newIdxArray[0], &submesh.m_indices[0], submesh.m_indices.getSize(),
+									submesh.m_verts.getSize());
 
 
 		submesh.m_indices = std::move(newIdxArray);
 		submesh.m_indices = std::move(newIdxArray);
 	}
 	}
@@ -181,13 +177,8 @@ static void optimizeSubmesh(SubMesh& submesh, GenericMemoryPoolAllocator<U8> all
 		DynamicArrayAuto<U32> newIdxArray(alloc);
 		DynamicArrayAuto<U32> newIdxArray(alloc);
 		newIdxArray.create(submesh.m_indices.getSize(), 0);
 		newIdxArray.create(submesh.m_indices.getSize(), 0);
 
 
-		meshopt_optimizeOverdraw(&newIdxArray[0],
-			&submesh.m_indices[0],
-			submesh.m_indices.getSize(),
-			&submesh.m_verts[0].m_position.x(),
-			submesh.m_verts.getSize(),
-			vertSize,
-			1.05f);
+		meshopt_optimizeOverdraw(&newIdxArray[0], &submesh.m_indices[0], submesh.m_indices.getSize(),
+								 &submesh.m_verts[0].m_position.x(), submesh.m_verts.getSize(), vertSize, 1.05f);
 
 
 		submesh.m_indices = std::move(newIdxArray);
 		submesh.m_indices = std::move(newIdxArray);
 	}
 	}
@@ -198,11 +189,9 @@ static void optimizeSubmesh(SubMesh& submesh, GenericMemoryPoolAllocator<U8> all
 		newVertArray.create(submesh.m_verts.getSize());
 		newVertArray.create(submesh.m_verts.getSize());
 
 
 		const U32 newVertCount = U32(meshopt_optimizeVertexFetch(&newVertArray[0],
 		const U32 newVertCount = U32(meshopt_optimizeVertexFetch(&newVertArray[0],
-			&submesh.m_indices[0], // Inplace
-			submesh.m_indices.getSize(),
-			&submesh.m_verts[0],
-			submesh.m_verts.getSize(),
-			vertSize));
+																 &submesh.m_indices[0], // Inplace
+																 submesh.m_indices.getSize(), &submesh.m_verts[0],
+																 submesh.m_verts.getSize(), vertSize));
 
 
 		if(newVertCount != submesh.m_verts.getSize())
 		if(newVertCount != submesh.m_verts.getSize())
 		{
 		{
@@ -226,14 +215,9 @@ static void decimateSubmesh(F32 factor, SubMesh& submesh, GenericMemoryPoolAlloc
 
 
 	// Decimate
 	// Decimate
 	DynamicArrayAuto<U32> newIndices(alloc, submesh.m_indices.getSize());
 	DynamicArrayAuto<U32> newIndices(alloc, submesh.m_indices.getSize());
-	newIndices.resize(U32(meshopt_simplify(&newIndices[0],
-		&submesh.m_indices[0],
-		submesh.m_indices.getSize(),
-		&submesh.m_verts[0].m_position.x(),
-		submesh.m_verts.getSize(),
-		sizeof(TempVertex),
-		targetIndexCount,
-		1e-2f)));
+	newIndices.resize(U32(meshopt_simplify(&newIndices[0], &submesh.m_indices[0], submesh.m_indices.getSize(),
+										   &submesh.m_verts[0].m_position.x(), submesh.m_verts.getSize(),
+										   sizeof(TempVertex), targetIndexCount, 1e-2f)));
 
 
 	// Re-pack
 	// Re-pack
 	DynamicArrayAuto<U32> reindexedIndices(alloc);
 	DynamicArrayAuto<U32> reindexedIndices(alloc);
@@ -269,10 +253,8 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 {
 {
 	StringAuto fname(m_alloc);
 	StringAuto fname(m_alloc);
 	fname.sprintf("%s%s.ankimesh", m_outDir.cstr(), (nameOverride.isEmpty()) ? mesh.name : nameOverride.cstr());
 	fname.sprintf("%s%s.ankimesh", m_outDir.cstr(), (nameOverride.isEmpty()) ? mesh.name : nameOverride.cstr());
-	ANKI_GLTF_LOGI("Importing mesh (%s, decimate factor %f): %s",
-		(m_optimizeMeshes) ? "optimze" : "WON'T optimize",
-		decimateFactor,
-		fname.cstr());
+	ANKI_GLTF_LOGI("Importing mesh (%s, decimate factor %f): %s", (m_optimizeMeshes) ? "optimze" : "WON'T optimize",
+				   decimateFactor, fname.cstr());
 
 
 	ListAuto<SubMesh> submeshes(m_alloc);
 	ListAuto<SubMesh> submeshes(m_alloc);
 	U32 totalIndexCount = 0;
 	U32 totalIndexCount = 0;
@@ -298,8 +280,7 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 		U minVertCount = MAX_U;
 		U minVertCount = MAX_U;
 		U maxVertCount = MIN_U;
 		U maxVertCount = MIN_U;
 		for(const cgltf_attribute* attrib = primitive->attributes;
 		for(const cgltf_attribute* attrib = primitive->attributes;
-			attrib < primitive->attributes + primitive->attributes_count;
-			++attrib)
+			attrib < primitive->attributes + primitive->attributes_count; ++attrib)
 		{
 		{
 			minVertCount = min(minVertCount, U(attrib->data->count));
 			minVertCount = min(minVertCount, U(attrib->data->count));
 			maxVertCount = max(maxVertCount, U(attrib->data->count));
 			maxVertCount = max(maxVertCount, U(attrib->data->count));
@@ -318,8 +299,7 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 		// Gather positions + normals + UVs
 		// Gather positions + normals + UVs
 		//
 		//
 		for(const cgltf_attribute* attrib = primitive->attributes;
 		for(const cgltf_attribute* attrib = primitive->attributes;
-			attrib < primitive->attributes + primitive->attributes_count;
-			++attrib)
+			attrib < primitive->attributes + primitive->attributes_count; ++attrib)
 		{
 		{
 			if(attrib->type == cgltf_attribute_type_position)
 			if(attrib->type == cgltf_attribute_type_position)
 			{
 			{
@@ -335,8 +315,8 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 			{
 			{
 				U32 count = 0;
 				U32 count = 0;
 				ANKI_CHECK(checkAttribute<Vec3>(*attrib));
 				ANKI_CHECK(checkAttribute<Vec3>(*attrib));
-				visitAccessor<Vec3>(
-					*attrib->data, [&](const Vec3& normal) { submesh.m_verts[count++].m_normal = normal; });
+				visitAccessor<Vec3>(*attrib->data,
+									[&](const Vec3& normal) { submesh.m_verts[count++].m_normal = normal; });
 			}
 			}
 			else if(attrib->type == cgltf_attribute_type_texcoord && CString(attrib->name) == "TEXCOORD_0")
 			else if(attrib->type == cgltf_attribute_type_texcoord && CString(attrib->name) == "TEXCOORD_0")
 			{
 			{
@@ -352,16 +332,16 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 			{
 			{
 				U32 count = 0;
 				U32 count = 0;
 				ANKI_CHECK(checkAttribute<U16Vec4>(*attrib));
 				ANKI_CHECK(checkAttribute<U16Vec4>(*attrib));
-				visitAccessor<U16Vec4>(
-					*attrib->data, [&](const U16Vec4& x) { submesh.m_verts[count++].m_boneIds = x; });
+				visitAccessor<U16Vec4>(*attrib->data,
+									   [&](const U16Vec4& x) { submesh.m_verts[count++].m_boneIds = x; });
 				hasBoneWeights = true;
 				hasBoneWeights = true;
 			}
 			}
 			else if(attrib->type == cgltf_attribute_type_weights)
 			else if(attrib->type == cgltf_attribute_type_weights)
 			{
 			{
 				U32 count = 0;
 				U32 count = 0;
 				ANKI_CHECK(checkAttribute<Vec4>(*attrib));
 				ANKI_CHECK(checkAttribute<Vec4>(*attrib));
-				visitAccessor<Vec4>(
-					*attrib->data, [&](const Vec4& bw) { submesh.m_verts[count++].m_boneWeights = bw; });
+				visitAccessor<Vec4>(*attrib->data,
+									[&](const Vec4& bw) { submesh.m_verts[count++].m_boneWeights = bw; });
 			}
 			}
 			else
 			else
 			{
 			{
@@ -781,10 +761,8 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 
 
 			for(U32 v = 0; v < submesh.m_verts.getSize(); ++v)
 			for(U32 v = 0; v < submesh.m_verts.getSize(); ++v)
 			{
 			{
-				pos16[v] = HVec4(F16(submesh.m_verts[v].m_position.x()),
-					F16(submesh.m_verts[v].m_position.y()),
-					F16(submesh.m_verts[v].m_position.z()),
-					F16(0.0f));
+				pos16[v] = HVec4(F16(submesh.m_verts[v].m_position.x()), F16(submesh.m_verts[v].m_position.y()),
+								 F16(submesh.m_verts[v].m_position.z()), F16(0.0f));
 			}
 			}
 
 
 			ANKI_CHECK(file.write(&pos16[0], pos16.getSizeInBytes()));
 			ANKI_CHECK(file.write(&pos16[0], pos16.getSizeInBytes()));

+ 2 - 5
src/anki/input/InputSdl.h

@@ -16,11 +16,8 @@ namespace anki
 class InputImpl
 class InputImpl
 {
 {
 public:
 public:
-	std::unordered_map<SDL_Keycode,
-		KeyCode,
-		std::hash<SDL_Keycode>,
-		std::equal_to<SDL_Keycode>,
-		HeapAllocator<std::pair<const SDL_Keycode, KeyCode>>>
+	std::unordered_map<SDL_Keycode, KeyCode, std::hash<SDL_Keycode>, std::equal_to<SDL_Keycode>,
+					   HeapAllocator<std::pair<const SDL_Keycode, KeyCode>>>
 		m_sdlToAnki;
 		m_sdlToAnki;
 
 
 	InputImpl(HeapAllocator<std::pair<const SDL_Keycode, KeyCode>>& alloc)
 	InputImpl(HeapAllocator<std::pair<const SDL_Keycode, KeyCode>>& alloc)

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

@@ -57,7 +57,7 @@ public:
 		{
 		{
 
 
 			if((absolute<T>(m3(0, 1) + m3(1, 0)) < 0.1) && (absolute<T>(m3(0, 2) + m3(2, 0)) < 0.1)
 			if((absolute<T>(m3(0, 1) + m3(1, 0)) < 0.1) && (absolute<T>(m3(0, 2) + m3(2, 0)) < 0.1)
-				&& (absolute<T>(m3(1, 2) + m3(2, 1)) < 0.1) && (absolute<T>(m3(0, 0) + m3(1, 1) + m3(2, 2)) - 3) < 0.1)
+			   && (absolute<T>(m3(1, 2) + m3(2, 1)) < 0.1) && (absolute<T>(m3(0, 0) + m3(1, 1) + m3(2, 2)) - 3) < 0.1)
 			{
 			{
 				m_axis = TVec<T, 3>(1.0, 0.0, 0.0);
 				m_axis = TVec<T, 3>(1.0, 0.0, 0.0);
 				m_ang = 0.0;
 				m_ang = 0.0;

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

@@ -107,7 +107,7 @@ inline T modf(T x, T& intPart)
 
 
 /// The same as abs/fabs. For ints and floats.
 /// The same as abs/fabs. For ints and floats.
 template<typename T,
 template<typename T,
-	ANKI_ENABLE(std::is_floating_point<T>::value || (std::is_integral<T>::value && std::is_signed<T>::value))>
+		 ANKI_ENABLE(std::is_floating_point<T>::value || (std::is_integral<T>::value && std::is_signed<T>::value))>
 inline T absolute(const T f)
 inline T absolute(const T f)
 {
 {
 	return (f < T(0)) ? -f : f;
 	return (f < T(0)) ? -f : f;

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

@@ -1485,8 +1485,8 @@ public:
 	{
 	{
 		const auto& m = *this;
 		const auto& m = *this;
 		return TVec<T, 3>(m(0, 0) * v.x() + m(0, 1) * v.y() + m(0, 2) * v.z() + m(0, 3),
 		return TVec<T, 3>(m(0, 0) * v.x() + m(0, 1) * v.y() + m(0, 2) * v.z() + m(0, 3),
-			m(1, 0) * v.x() + m(1, 1) * v.y() + m(1, 2) * v.z() + m(1, 3),
-			m(2, 0) * v.x() + m(2, 1) * v.y() + m(2, 2) * v.z() + m(2, 3));
+						  m(1, 0) * v.x() + m(1, 1) * v.y() + m(1, 2) * v.z() + m(1, 3),
+						  m(2, 0) * v.x() + m(2, 1) * v.y() + m(2, 2) * v.z() + m(2, 3));
 	}
 	}
 
 
 	TMat lerp(const TMat& b, T t) const
 	TMat lerp(const TMat& b, T t) const

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

@@ -41,8 +41,8 @@ public:
 		const TVec<T, 3> scales(s0.getLength(), s1.getLength(), s2.getLength());
 		const TVec<T, 3> scales(s0.getLength(), s1.getLength(), s2.getLength());
 		const T E = T(0.001);
 		const T E = T(0.001);
 		(void)E;
 		(void)E;
-		ANKI_ASSERT(
-			isZero(scales.x() - scales.y(), E) && isZero(scales.y() - scales.z(), E) && "Expecting uniform scale");
+		ANKI_ASSERT(isZero(scales.x() - scales.y(), E) && isZero(scales.y() - scales.z(), E)
+					&& "Expecting uniform scale");
 
 
 		m_rotation.setColumns(s0 / scales.x(), s1 / scales.x(), s2 / scales.x(), TVec<T, 3>(0.0));
 		m_rotation.setColumns(s0 / scales.x(), s1 / scales.x(), s2 / scales.x(), TVec<T, 3>(0.0));
 		m_origin = m4.getTranslationPart().xyz0();
 		m_origin = m4.getTranslationPart().xyz0();

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