Browse Source

Merge pull request #117 from godlikepanos/gpuscene_v2

GPU scene
Panagiotis Christopoulos Charitos 2 years ago
parent
commit
fd12a5f960
100 changed files with 1104 additions and 1227 deletions
  1. 27 7
      .clang-format
  2. 186 0
      .clang-format-hlsl
  3. 2 1
      .gitattributes
  4. 7 5
      .github/workflows/Android.yml
  5. 6 7
      .github/workflows/Linux.yml
  6. 3 3
      .github/workflows/Windows.yml
  7. 2 2
      AnKi/AnKi.h
  8. 1 1
      AnKi/CMakeLists.txt
  9. 1 1
      AnKi/Collision.h
  10. 1 1
      AnKi/Collision/Aabb.cpp
  11. 2 2
      AnKi/Collision/Aabb.h
  12. 3 3
      AnKi/Collision/Common.h
  13. 1 1
      AnKi/Collision/Cone.h
  14. 1 1
      AnKi/Collision/ConvexHullShape.cpp
  15. 1 1
      AnKi/Collision/ConvexHullShape.h
  16. 1 1
      AnKi/Collision/Forward.h
  17. 1 1
      AnKi/Collision/Functions.h
  18. 1 1
      AnKi/Collision/FunctionsComputeAabb.cpp
  19. 1 1
      AnKi/Collision/FunctionsMisc.cpp
  20. 1 1
      AnKi/Collision/FunctionsTestCollision.cpp
  21. 1 1
      AnKi/Collision/FunctionsTestPlane.cpp
  22. 1 1
      AnKi/Collision/GjkEpa.cpp
  23. 1 1
      AnKi/Collision/GjkEpa.h
  24. 1 1
      AnKi/Collision/LineSegment.h
  25. 1 1
      AnKi/Collision/Obb.cpp
  26. 2 2
      AnKi/Collision/Obb.h
  27. 1 1
      AnKi/Collision/Plane.cpp
  28. 1 1
      AnKi/Collision/Plane.h
  29. 1 1
      AnKi/Collision/Ray.h
  30. 1 1
      AnKi/Collision/Sphere.cpp
  31. 1 1
      AnKi/Collision/Sphere.h
  32. 40 11
      AnKi/Config.h.cmake
  33. 1 2
      AnKi/Core.h
  34. 1 1
      AnKi/Core/AllConfigVars.defs.h
  35. 225 188
      AnKi/Core/App.cpp
  36. 13 112
      AnKi/Core/App.h
  37. 2 16
      AnKi/Core/CMakeLists.txt
  38. 38 1
      AnKi/Core/Common.h
  39. 4 4
      AnKi/Core/ConfigSet.cpp
  40. 15 16
      AnKi/Core/ConfigSet.h
  41. 7 6
      AnKi/Core/ConfigVars.defs.h
  42. 22 43
      AnKi/Core/CoreTracer.cpp
  43. 11 10
      AnKi/Core/CoreTracer.h
  44. 11 15
      AnKi/Core/DeveloperConsole.cpp
  45. 5 8
      AnKi/Core/DeveloperConsole.h
  46. 181 79
      AnKi/Core/GpuMemoryPools.cpp
  47. 139 54
      AnKi/Core/GpuMemoryPools.h
  48. 8 8
      AnKi/Core/MaliHwCounters.cpp
  49. 9 7
      AnKi/Core/MaliHwCounters.h
  50. 0 76
      AnKi/Core/NativeWindow.h
  51. 0 104
      AnKi/Core/NativeWindowAndroid.cpp
  52. 0 24
      AnKi/Core/NativeWindowAndroid.h
  53. 0 41
      AnKi/Core/NativeWindowHeadless.cpp
  54. 0 18
      AnKi/Core/NativeWindowHeadless.h
  55. 0 149
      AnKi/Core/NativeWindowSdl.cpp
  56. 0 28
      AnKi/Core/NativeWindowSdl.h
  57. 3 3
      AnKi/Core/StatsUi.cpp
  58. 5 1
      AnKi/Core/StatsUi.defs.h
  59. 2 5
      AnKi/Core/StatsUi.h
  60. 1 1
      AnKi/Core/StdinListener.cpp
  61. 1 1
      AnKi/Core/StdinListener.h
  62. 2 2
      AnKi/Gr.h
  63. 4 5
      AnKi/Gr/AccelerationStructure.h
  64. 4 4
      AnKi/Gr/Buffer.h
  65. 9 13
      AnKi/Gr/CMakeLists.txt
  66. 5 5
      AnKi/Gr/CommandBuffer.h
  67. 7 1
      AnKi/Gr/Common.cpp
  68. 25 70
      AnKi/Gr/Common.h
  69. 2 1
      AnKi/Gr/ConfigVars.defs.h
  70. 4 4
      AnKi/Gr/Fence.h
  71. 1 1
      AnKi/Gr/Format.defs.h
  72. 4 4
      AnKi/Gr/Framebuffer.h
  73. 1 1
      AnKi/Gr/Gl/Buffer.cpp
  74. 1 1
      AnKi/Gr/Gl/BufferImpl.cpp
  75. 1 1
      AnKi/Gr/Gl/BufferImpl.h
  76. 1 1
      AnKi/Gr/Gl/CommandBuffer.cpp
  77. 2 2
      AnKi/Gr/Gl/CommandBufferImpl.cpp
  78. 1 1
      AnKi/Gr/Gl/CommandBufferImpl.h
  79. 1 1
      AnKi/Gr/Gl/Common.cpp
  80. 1 1
      AnKi/Gr/Gl/Common.h
  81. 1 1
      AnKi/Gr/Gl/Error.cpp
  82. 1 1
      AnKi/Gr/Gl/Error.h
  83. 1 1
      AnKi/Gr/Gl/Fence.cpp
  84. 1 1
      AnKi/Gr/Gl/FenceImpl.cpp
  85. 1 1
      AnKi/Gr/Gl/FenceImpl.h
  86. 1 1
      AnKi/Gr/Gl/Framebuffer.cpp
  87. 1 1
      AnKi/Gr/Gl/FramebufferImpl.cpp
  88. 1 1
      AnKi/Gr/Gl/FramebufferImpl.h
  89. 1 1
      AnKi/Gr/Gl/GlObject.cpp
  90. 1 1
      AnKi/Gr/Gl/GlObject.h
  91. 1 1
      AnKi/Gr/Gl/GlState.cpp
  92. 1 1
      AnKi/Gr/Gl/GlState.h
  93. 1 1
      AnKi/Gr/Gl/GrManager.cpp
  94. 2 2
      AnKi/Gr/Gl/GrManagerImpl.cpp
  95. 1 1
      AnKi/Gr/Gl/GrManagerImpl.h
  96. 3 3
      AnKi/Gr/Gl/GrManagerImplSdl.cpp
  97. 1 1
      AnKi/Gr/Gl/OcclusionQuery.cpp
  98. 1 1
      AnKi/Gr/Gl/OcclusionQueryImpl.cpp
  99. 1 1
      AnKi/Gr/Gl/OcclusionQueryImpl.h
  100. 1 1
      AnKi/Gr/Gl/RenderingThread.cpp

+ 27 - 7
.clang-format

@@ -1,8 +1,9 @@
 ---
 ---
 Language:        Cpp
 Language:        Cpp
-# BasedOnStyle:  LLVM
+BasedOnStyle:  LLVM
 AccessModifierOffset: -4
 AccessModifierOffset: -4
 AlignAfterOpenBracket: Align
 AlignAfterOpenBracket: Align
+AlignArrayOfStructures: None
 AlignConsecutiveMacros: None
 AlignConsecutiveMacros: None
 AlignConsecutiveAssignments: None
 AlignConsecutiveAssignments: None
 AlignConsecutiveBitFields: None
 AlignConsecutiveBitFields: None
@@ -11,7 +12,6 @@ AlignEscapedNewlines: DontAlign
 AlignOperands:   Align
 AlignOperands:   Align
 AlignTrailingComments: false
 AlignTrailingComments: false
 AllowAllArgumentsOnNextLine: false
 AllowAllArgumentsOnNextLine: false
-AllowAllConstructorInitializersOnNextLine: true
 AllowAllParametersOfDeclarationOnNextLine: true
 AllowAllParametersOfDeclarationOnNextLine: true
 AllowShortEnumsOnASingleLine: false
 AllowShortEnumsOnASingleLine: false
 AllowShortBlocksOnASingleLine: Never
 AllowShortBlocksOnASingleLine: Never
@@ -59,23 +59,27 @@ BreakAfterJavaFieldAnnotations: false
 BreakStringLiterals: true
 BreakStringLiterals: true
 ColumnLimit:     120
 ColumnLimit:     120
 CommentPragmas:  '^ IWYU pragma:'
 CommentPragmas:  '^ IWYU pragma:'
+QualifierAlignment: Leave
 CompactNamespaces: false
 CompactNamespaces: false
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
 ConstructorInitializerIndentWidth: 4
 ConstructorInitializerIndentWidth: 4
 ContinuationIndentWidth: 4
 ContinuationIndentWidth: 4
 Cpp11BracedListStyle: true
 Cpp11BracedListStyle: true
 DeriveLineEnding: true
 DeriveLineEnding: true
 DerivePointerAlignment: false
 DerivePointerAlignment: false
 DisableFormat:   false
 DisableFormat:   false
+EmptyLineAfterAccessModifier: Never
 EmptyLineBeforeAccessModifier: LogicalBlock
 EmptyLineBeforeAccessModifier: LogicalBlock
 ExperimentalAutoDetectBinPacking: false
 ExperimentalAutoDetectBinPacking: false
+PackConstructorInitializers: BinPack
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+AllowAllConstructorInitializersOnNextLine: false
 FixNamespaceComments: true
 FixNamespaceComments: true
 ForEachMacros:
 ForEachMacros:
   - foreach
   - foreach
   - Q_FOREACH
   - Q_FOREACH
   - BOOST_FOREACH
   - BOOST_FOREACH
-StatementAttributeLikeMacros:
-  - Q_EMIT
+IfMacros:
+  - KJ_IF_MAYBE
 IncludeBlocks:   Preserve
 IncludeBlocks:   Preserve
 IncludeCategories:
 IncludeCategories:
   - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
   - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
@@ -92,6 +96,7 @@ IncludeCategories:
     CaseSensitive:   false
     CaseSensitive:   false
 IncludeIsMainRegex: '(Test)?$'
 IncludeIsMainRegex: '(Test)?$'
 IncludeIsMainSourceRegex: ''
 IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
 IndentCaseLabels: false
 IndentCaseLabels: false
 IndentCaseBlocks: false
 IndentCaseBlocks: false
 IndentGotoLabels: true
 IndentGotoLabels: true
@@ -104,6 +109,7 @@ InsertTrailingCommas: None
 JavaScriptQuotes: Leave
 JavaScriptQuotes: Leave
 JavaScriptWrapImports: true
 JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: true
 KeepEmptyLinesAtTheStartOfBlocks: true
+LambdaBodyIndentation: Signature
 MacroBlockBegin: ''
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
 MacroBlockEnd:   ''
 MaxEmptyLinesToKeep: 1
 MaxEmptyLinesToKeep: 1
@@ -117,14 +123,20 @@ PenaltyBreakAssignment: 2
 PenaltyBreakBeforeFirstCallParameter: 19
 PenaltyBreakBeforeFirstCallParameter: 19
 PenaltyBreakComment: 300
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakFirstLessLess: 120
+PenaltyBreakOpenParenthesis: 0
 PenaltyBreakString: 1000
 PenaltyBreakString: 1000
 PenaltyBreakTemplateDeclaration: 10
 PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
 PenaltyReturnTypeOnItsOwnLine: 60
 PenaltyIndentedWhitespace: 0
 PenaltyIndentedWhitespace: 0
 PointerAlignment: Left
 PointerAlignment: Left
+PPIndentWidth:   -1
+ReferenceAlignment: Pointer
 ReflowComments:  true
 ReflowComments:  true
-SortIncludes:    false
+RemoveBracesLLVM: false
+SeparateDefinitionBlocks: Leave
+ShortNamespaceLines: 1
+SortIncludes:    Never
 SortJavaStaticImport: Before
 SortJavaStaticImport: Before
 SortUsingDeclarations: false
 SortUsingDeclarations: false
 SpaceAfterCStyleCast: false
 SpaceAfterCStyleCast: false
@@ -141,15 +153,20 @@ SpaceBeforeRangeBasedForLoopColon: true
 SpaceInEmptyBlock: false
 SpaceInEmptyBlock: false
 SpaceInEmptyParentheses: false
 SpaceInEmptyParentheses: false
 SpacesBeforeTrailingComments: 1
 SpacesBeforeTrailingComments: 1
-SpacesInAngles:  false
+SpacesInAngles:  Never
 SpacesInConditionalStatement: false
 SpacesInConditionalStatement: false
 SpacesInContainerLiterals: true
 SpacesInContainerLiterals: true
 SpacesInCStyleCastParentheses: false
 SpacesInCStyleCastParentheses: false
+SpacesInLineCommentPrefix:
+  Minimum:         1
+  Maximum:         -1
 SpacesInParentheses: false
 SpacesInParentheses: false
 SpacesInSquareBrackets: false
 SpacesInSquareBrackets: false
 SpaceBeforeSquareBrackets: false
 SpaceBeforeSquareBrackets: false
 BitFieldColonSpacing: Both
 BitFieldColonSpacing: Both
 Standard:        Latest
 Standard:        Latest
+StatementAttributeLikeMacros:
+  - Q_EMIT
 StatementMacros:
 StatementMacros:
   - Q_UNUSED
   - Q_UNUSED
   - QT_REQUIRE_VERSION
   - QT_REQUIRE_VERSION
@@ -162,5 +179,8 @@ WhitespaceSensitiveMacros:
   - BOOST_PP_STRINGIZE
   - BOOST_PP_STRINGIZE
   - NS_SWIFT_NAME
   - NS_SWIFT_NAME
   - CF_SWIFT_NAME
   - CF_SWIFT_NAME
+---
+Language: ObjC
+BasedOnStyle: Microsoft
 ...
 ...
 
 

+ 186 - 0
.clang-format-hlsl

@@ -0,0 +1,186 @@
+---
+Language:        Cpp
+BasedOnStyle:  LLVM
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignArrayOfStructures: None
+AlignConsecutiveMacros: None
+AlignConsecutiveAssignments: None
+AlignConsecutiveBitFields: None
+AlignConsecutiveDeclarations: None
+AlignEscapedNewlines: DontAlign
+AlignOperands:   Align
+AlignTrailingComments: false
+AllowAllArgumentsOnNextLine: false
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortEnumsOnASingleLine: false
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortLambdasOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: Yes
+AttributeMacros:
+  - __capability
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterCaseLabel:  true
+  AfterClass:      true
+  AfterControlStatement: true
+  AfterEnum:       true
+  AfterFunction:   true
+  AfterNamespace:  false
+  AfterObjCDeclaration: true
+  AfterStruct:     true
+  AfterUnion:      true
+  AfterExternBlock: false
+  BeforeCatch:     true
+  BeforeElse:      true
+  BeforeLambdaBody: true
+  BeforeWhile:     false
+  IndentBraces:    false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeConceptDeclarations: true
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakInheritanceList: AfterColon
+BreakBeforeTernaryOperators: true
+#BreakConstructorInitializersBeforeComma: true
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit:     120
+CommentPragmas:  '^ IWYU pragma:'
+QualifierAlignment: Leave
+CompactNamespaces: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DeriveLineEnding: true
+DerivePointerAlignment: false
+DisableFormat:   false
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
+ExperimentalAutoDetectBinPacking: false
+PackConstructorInitializers: BinPack
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+AllowAllConstructorInitializersOnNextLine: false
+FixNamespaceComments: true
+ForEachMacros:
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+IfMacros:
+  - KJ_IF_MAYBE
+IncludeBlocks:   Preserve
+IncludeCategories:
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
+    Priority:        2
+    SortPriority:    0
+    CaseSensitive:   false
+  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
+    Priority:        3
+    SortPriority:    0
+    CaseSensitive:   false
+  - Regex:           '.*'
+    Priority:        1
+    SortPriority:    0
+    CaseSensitive:   false
+IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
+IndentCaseLabels: false
+IndentCaseBlocks: false
+IndentGotoLabels: true
+IndentPPDirectives: AfterHash
+IndentExternBlock: NoIndent
+IndentRequires:  false
+IndentWidth:     4
+IndentWrappedFunctionNames: false
+InsertTrailingCommas: None
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+LambdaBodyIndentation: Signature
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 2
+ObjCBreakBeforeNestedBlockParam: true
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakOpenParenthesis: 0
+PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
+PointerAlignment: Left
+PPIndentWidth:   -1
+ReferenceAlignment: Pointer
+ReflowComments:  true
+RemoveBracesLLVM: false
+SeparateDefinitionBlocks: Leave
+ShortNamespaceLines: 1
+SortIncludes:    Never
+SortJavaStaticImport: Before
+SortUsingDeclarations: false
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCaseColon: false
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: false
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: Never
+SpaceAroundPointerQualifiers: Default
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  Never
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInLineCommentPrefix:
+  Minimum:         1
+  Maximum:         -1
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+SpaceBeforeSquareBrackets: false
+BitFieldColonSpacing: Both
+Standard:        Latest
+StatementAttributeLikeMacros:
+  - Q_EMIT
+StatementMacros:
+  - Q_UNUSED
+  - QT_REQUIRE_VERSION
+TabWidth:        4
+UseCRLF:         false
+UseTab:          ForContinuationAndIndentation
+WhitespaceSensitiveMacros:
+  - STRINGIZE
+  - PP_STRINGIZE
+  - BOOST_PP_STRINGIZE
+  - NS_SWIFT_NAME
+  - CF_SWIFT_NAME
+---
+Language: ObjC
+BasedOnStyle: Microsoft
+...
+

+ 2 - 1
.gitattributes

@@ -3,6 +3,7 @@
 *.h text eol=lf
 *.h text eol=lf
 *.hpp text eol=lf
 *.hpp text eol=lf
 *.glsl text eol=lf
 *.glsl text eol=lf
+*.hlsl text eol=lf
 *.lua text eol=lf
 *.lua text eol=lf
 *.py text eol=lf
 *.py text eol=lf
 *.cmake text eol=lf
 *.cmake text eol=lf
@@ -19,4 +20,4 @@
 
 
 # Github stats
 # Github stats
 ThirdParty/** linguist-vendored
 ThirdParty/** linguist-vendored
-*.ankiprog linguist-language=GLSL
+*.ankiprog linguist-language=HLSL

+ 7 - 5
.github/workflows/Android.yml

@@ -15,20 +15,22 @@ jobs:
     steps:
     steps:
     - name: Install dependencies
     - name: Install dependencies
       run: |
       run: |
-        apt-get update
-        apt install ninja-build
+        add-apt-repository -y ppa:ubuntu-toolchain-r/test
+        apt update
+        apt update -y
+        apt install -y ninja-build gcc-11 g++-11
 
 
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake for Linux
     - name: Configure CMake for Linux
-      run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF
+      run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11
 
 
     - name: Build Linux ShaderCompiler
     - name: Build Linux ShaderCompiler
       run: cmake --build ${{github.workspace}}/build --config Release --target ShaderCompiler
       run: cmake --build ${{github.workspace}}/build --config Release --target ShaderCompiler
 
 
     - name: Generate project
     - name: Generate project
-      run: ./Samples/Sponza/GenerateAndroidProject.sh ${{github.workspace}}/build/Bin/ShaderCompiler
+      run: ./Samples/Sponza/GenerateAndroidProject.sh ${{github.workspace}}/build/Binaries/ShaderCompiler
 
 
     - name: local.properties
     - name: local.properties
       run: |
       run: |

+ 6 - 7
.github/workflows/Linux.yml

@@ -16,7 +16,7 @@ jobs:
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
 
 
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Debug -DANKI_EXTRA_CHECKS=ON
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Debug -DANKI_EXTRA_CHECKS=ON
@@ -33,7 +33,7 @@ jobs:
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
 
 
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF
@@ -41,7 +41,6 @@ jobs:
     - name: Build
     - name: Build
       run: cmake --build ${{github.workspace}}/build --config Release
       run: cmake --build ${{github.workspace}}/build --config Release
 
 
-
   Debug_Clang:
   Debug_Clang:
     name: "Clang Debug"
     name: "Clang Debug"
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
@@ -51,7 +50,7 @@ jobs:
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
 
 
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Debug -DANKI_EXTRA_CHECKS=ON
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Debug -DANKI_EXTRA_CHECKS=ON
@@ -68,7 +67,7 @@ jobs:
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
 
 
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF
@@ -85,7 +84,7 @@ jobs:
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
 
 
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=ON -DANKI_HEADLESS=ON
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=ON -DANKI_HEADLESS=ON
@@ -102,7 +101,7 @@ jobs:
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
       run: sudo apt install libx11-dev libx11-xcb-dev clang gcc
 
 
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=ON -DANKI_DLSS=ON
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=ON -DANKI_DLSS=ON

+ 3 - 3
.github/workflows/Windows.yml

@@ -13,7 +13,7 @@ jobs:
 
 
     steps:
     steps:
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DANKI_EXTRA_CHECKS=ON
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DANKI_EXTRA_CHECKS=ON
@@ -27,7 +27,7 @@ jobs:
 
 
     steps:
     steps:
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF
@@ -41,7 +41,7 @@ jobs:
 
 
     steps:
     steps:
     - name: Clone
     - name: Clone
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
 
     - name: Configure CMake
     - name: Configure CMake
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF -DANKI_DLSS=ON
       run: cmake -B ${{github.workspace}}/build -DANKI_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DANKI_EXTRA_CHECKS=OFF -DANKI_DLSS=ON

+ 2 - 2
AnKi/AnKi.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -11,7 +11,7 @@
 #include <AnKi/Scene.h>
 #include <AnKi/Scene.h>
 #include <AnKi/Renderer.h>
 #include <AnKi/Renderer.h>
 #include <AnKi/Script.h>
 #include <AnKi/Script.h>
-#include <AnKi/Input.h>
+#include <AnKi/Window.h>
 #include <AnKi/Resource.h>
 #include <AnKi/Resource.h>
 #include <AnKi/Physics.h>
 #include <AnKi/Physics.h>
 #include <AnKi/Gr.h>
 #include <AnKi/Gr.h>

+ 1 - 1
AnKi/CMakeLists.txt

@@ -1,4 +1,4 @@
-set(ANKI_SUB_DIRS Importer Core Script Renderer Scene Ui Input Physics Resource Gr Collision Math Util ShaderCompiler
+set(ANKI_SUB_DIRS Importer Core Script Renderer Scene Ui Window Physics Resource Gr Collision Math Util ShaderCompiler
 	Shaders)
 	Shaders)
 foreach(TMP ${ANKI_SUB_DIRS})
 foreach(TMP ${ANKI_SUB_DIRS})
 	add_subdirectory(${TMP})
 	add_subdirectory(${TMP})

+ 1 - 1
AnKi/Collision.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Aabb.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 2 - 2
AnKi/Collision/Aabb.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -16,7 +16,7 @@ namespace anki {
 class Aabb
 class Aabb
 {
 {
 public:
 public:
-	static constexpr CollisionShapeType kClassType = CollisionShapeType::kAABB;
+	static constexpr CollisionShapeType kClassType = CollisionShapeType::kAabb;
 
 
 	/// Will not initialize any memory, nothing.
 	/// Will not initialize any memory, nothing.
 	Aabb()
 	Aabb()

+ 3 - 3
AnKi/Collision/Common.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -35,9 +35,9 @@ enum class CollisionShapeType : U8
 	kPlane,
 	kPlane,
 	kLineSegment,
 	kLineSegment,
 	kRay,
 	kRay,
-	kAABB,
+	kAabb,
 	kSphere,
 	kSphere,
-	kOBB,
+	kObb,
 	kConvexHull,
 	kConvexHull,
 	kCone,
 	kCone,
 
 

+ 1 - 1
AnKi/Collision/Cone.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/ConvexHullShape.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/ConvexHullShape.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Forward.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Functions.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/FunctionsComputeAabb.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/FunctionsMisc.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/FunctionsTestCollision.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/FunctionsTestPlane.cpp

@@ -126,7 +126,7 @@ F32 testPlane(const Plane& plane, const ConvexHullShape& hull)
 	for(const Vec4& point : points)
 	for(const Vec4& point : points)
 	{
 	{
 		const F32 test = testPlane(pa, point);
 		const F32 test = testPlane(pa, point);
-		if(ANKI_UNLIKELY(test == 0.0f))
+		if(test == 0.0f) [[unlikely]]
 		{
 		{
 			// Early exit
 			// Early exit
 			return 0.0f;
 			return 0.0f;

+ 1 - 1
AnKi/Collision/GjkEpa.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/GjkEpa.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/LineSegment.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Obb.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 2 - 2
AnKi/Collision/Obb.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -18,7 +18,7 @@ namespace anki {
 class Obb
 class Obb
 {
 {
 public:
 public:
-	static constexpr CollisionShapeType kClassType = CollisionShapeType::kOBB;
+	static constexpr CollisionShapeType kClassType = CollisionShapeType::kObb;
 
 
 	/// Will not initialize any memory, nothing.
 	/// Will not initialize any memory, nothing.
 	Obb()
 	Obb()

+ 1 - 1
AnKi/Collision/Plane.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Plane.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Ray.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Sphere.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Collision/Sphere.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 40 - 11
AnKi/Config.h.cmake

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -165,8 +165,6 @@
 
 
 // Some compiler attributes
 // Some compiler attributes
 #if ANKI_COMPILER_GCC_COMPATIBLE
 #if ANKI_COMPILER_GCC_COMPATIBLE
-#	define ANKI_LIKELY(x) __builtin_expect(!!(x), 1)
-#	define ANKI_UNLIKELY(x) __builtin_expect(!!(x), 0)
 #	define ANKI_RESTRICT __restrict
 #	define ANKI_RESTRICT __restrict
 #	define ANKI_FORCE_INLINE __attribute__((always_inline))
 #	define ANKI_FORCE_INLINE __attribute__((always_inline))
 #	define ANKI_DONT_INLINE __attribute__((noinline))
 #	define ANKI_DONT_INLINE __attribute__((noinline))
@@ -177,11 +175,9 @@
 #	define ANKI_PREFETCH_MEMORY(addr) __builtin_prefetch(addr)
 #	define ANKI_PREFETCH_MEMORY(addr) __builtin_prefetch(addr)
 #	define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx) __attribute__((format(printf, fmtArgIdx + 1, firstArgIdx + 1))) // On methods you need to include "this"
 #	define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx) __attribute__((format(printf, fmtArgIdx + 1, firstArgIdx + 1))) // On methods you need to include "this"
 #	define ANKI_PURE __attribute__((pure))
 #	define ANKI_PURE __attribute__((pure))
-#else
-#	define ANKI_LIKELY(x) (x)
-#	define ANKI_UNLIKELY(x) (x)
+#elif ANKI_COMPILER_MSVC
 #	define ANKI_RESTRICT
 #	define ANKI_RESTRICT
-#	define ANKI_FORCE_INLINE
+#	define ANKI_FORCE_INLINE __forceinline
 #	define ANKI_DONT_INLINE
 #	define ANKI_DONT_INLINE
 #	define ANKI_UNUSED
 #	define ANKI_UNUSED
 #	define ANKI_COLD
 #	define ANKI_COLD
@@ -190,6 +186,17 @@
 #	define ANKI_PREFETCH_MEMORY(addr) (void)(addr)
 #	define ANKI_PREFETCH_MEMORY(addr) (void)(addr)
 #	define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx)
 #	define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx)
 #	define ANKI_PURE
 #	define ANKI_PURE
+#else
+#	define ANKI_RESTRICT
+#	define ANKI_FORCE_INLINE 
+#	define ANKI_DONT_INLINE
+#	define ANKI_UNUSED
+#	define ANKI_COLD
+#	define ANKI_HOT
+#	define ANKI_UNREACHABLE() 
+#	define ANKI_PREFETCH_MEMORY(addr) (void)(addr)
+#	define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx)
+#	define ANKI_PURE
 #endif
 #endif
 
 
 // Pack structs
 // Pack structs
@@ -232,9 +239,28 @@ inline int __builtin_ctzll(unsigned long long x)
 #	define ANKI_INTERNAL [[deprecated("This is an AnKi internal interface. Don't use it")]]
 #	define ANKI_INTERNAL [[deprecated("This is an AnKi internal interface. Don't use it")]]
 #endif
 #endif
 
 
+// Macro that temporarily disable the ANKI_INTERNAL. It's needed in some cases where an ANKI_INTERNAL is called in a
+// header
+#if ANKI_COMPILER_MSVC
+#	define ANKI_CALL_INTERNAL(...) \
+	__pragma(warning(push)) \
+	__pragma(warning(disable:4996)) \
+	__VA_ARGS__ \
+	__pragma(warning(pop))
+#elif ANKI_COMPILER_GCC_COMPATIBLE
+#	define ANKI_CALL_INTERNAL(...) \
+	_Pragma("GCC diagnostic push") \
+	_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
+	__VA_ARGS__ \
+	_Pragma("GCC diagnostic pop")
+#else
+#	define ANKI_CALL_INTERNAL(...)
+#endif
+
 // Define the main() function.
 // Define the main() function.
 namespace anki {
 namespace anki {
-void preMainInit();
+void preMain();
+void postMain();
 }
 }
 #if ANKI_OS_ANDROID
 #if ANKI_OS_ANDROID
 extern "C" {
 extern "C" {
@@ -253,20 +279,23 @@ void cleanupGetAndroidCommandLineArguments(void* ptr);
 	extern "C" void android_main(android_app* app) \
 	extern "C" void android_main(android_app* app) \
 	{ \
 	{ \
 		anki::g_androidApp = app; \
 		anki::g_androidApp = app; \
-		preMainInit(); \
+		preMain(); \
 		char** argv; \
 		char** argv; \
 		int argc; \
 		int argc; \
 		void* cleanupToken = anki::getAndroidCommandLineArguments(argc, argv); \
 		void* cleanupToken = anki::getAndroidCommandLineArguments(argc, argv); \
 		myMain(argc, argv); \
 		myMain(argc, argv); \
 		anki::cleanupGetAndroidCommandLineArguments(cleanupToken); \
 		anki::cleanupGetAndroidCommandLineArguments(cleanupToken); \
+		postMain(); \
 	}
 	}
 #else
 #else
 #	define ANKI_MAIN_FUNCTION(myMain) \
 #	define ANKI_MAIN_FUNCTION(myMain) \
 	int myMain(int argc, char* argv[]); \
 	int myMain(int argc, char* argv[]); \
 	int main(int argc, char* argv[]) \
 	int main(int argc, char* argv[]) \
 	{ \
 	{ \
-		preMainInit(); \
-		return myMain(argc, argv); \
+		preMain(); \
+		const int exitCode = myMain(argc, argv); \
+		postMain(); \
+		return exitCode; \
 	}
 	}
 #endif
 #endif
 /// @}
 /// @}

+ 1 - 2
AnKi/Core.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -7,5 +7,4 @@
 
 
 #include <AnKi/Core/App.h>
 #include <AnKi/Core/App.h>
 #include <AnKi/Core/ConfigSet.h>
 #include <AnKi/Core/ConfigSet.h>
-#include <AnKi/Core/NativeWindow.h>
 #include <AnKi/Core/CoreTracer.h>
 #include <AnKi/Core/CoreTracer.h>

+ 1 - 1
AnKi/Core/AllConfigVars.defs.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 225 - 188
AnKi/Core/App.cpp

@@ -1,5 +1,5 @@
 
 
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -16,9 +16,9 @@
 #include <AnKi/Core/CoreTracer.h>
 #include <AnKi/Core/CoreTracer.h>
 #include <AnKi/Core/DeveloperConsole.h>
 #include <AnKi/Core/DeveloperConsole.h>
 #include <AnKi/Core/StatsUi.h>
 #include <AnKi/Core/StatsUi.h>
-#include <AnKi/Core/NativeWindow.h>
+#include <AnKi/Window/NativeWindow.h>
 #include <AnKi/Core/MaliHwCounters.h>
 #include <AnKi/Core/MaliHwCounters.h>
-#include <AnKi/Input/Input.h>
+#include <AnKi/Window/Input.h>
 #include <AnKi/Scene/SceneGraph.h>
 #include <AnKi/Scene/SceneGraph.h>
 #include <AnKi/Renderer/RenderQueue.h>
 #include <AnKi/Renderer/RenderQueue.h>
 #include <AnKi/Resource/ResourceManager.h>
 #include <AnKi/Resource/ResourceManager.h>
@@ -69,40 +69,45 @@ void* App::MemStats::allocCallback(void* userData, void* ptr, PtrSize size, [[ma
 		const PtrSize newSize = sizeof(Header) + size;
 		const PtrSize newSize = sizeof(Header) + size;
 
 
 		// Allocate
 		// Allocate
-		MemStats* self = static_cast<MemStats*>(userData);
+		App* self = static_cast<App*>(userData);
 		Header* allocation = static_cast<Header*>(
 		Header* allocation = static_cast<Header*>(
-			self->m_originalAllocCallback(self->m_originalUserData, nullptr, newSize, newAlignment));
+			self->m_originalAllocCallback(self->m_originalAllocUserData, nullptr, newSize, newAlignment));
 		allocation->m_allocatedSize = size;
 		allocation->m_allocatedSize = size;
 		++allocation;
 		++allocation;
 		out = static_cast<void*>(allocation);
 		out = static_cast<void*>(allocation);
 
 
 		// Update stats
 		// Update stats
-		self->m_allocatedMem.fetchAdd(size);
-		self->m_allocCount.fetchAdd(1);
+		self->m_memStats.m_allocatedMem.fetchAdd(size);
+		self->m_memStats.m_allocCount.fetchAdd(1);
 	}
 	}
 	else
 	else
 	{
 	{
 		// Need to free
 		// Need to free
 
 
-		MemStats* self = static_cast<MemStats*>(userData);
+		App* self = static_cast<App*>(userData);
 
 
 		Header* allocation = static_cast<Header*>(ptr);
 		Header* allocation = static_cast<Header*>(ptr);
 		--allocation;
 		--allocation;
 		ANKI_ASSERT(allocation->m_allocatedSize > 0);
 		ANKI_ASSERT(allocation->m_allocatedSize > 0);
 
 
 		// Update stats
 		// Update stats
-		self->m_freeCount.fetchAdd(1);
-		self->m_allocatedMem.fetchSub(allocation->m_allocatedSize);
+		self->m_memStats.m_freeCount.fetchAdd(1);
+		self->m_memStats.m_allocatedMem.fetchSub(allocation->m_allocatedSize);
 
 
 		// Free
 		// Free
-		self->m_originalAllocCallback(self->m_originalUserData, allocation, 0, 0);
+		self->m_originalAllocCallback(self->m_originalAllocUserData, allocation, 0, 0);
 	}
 	}
 
 
 	return out;
 	return out;
 }
 }
 
 
-App::App()
+App::App(AllocAlignedCallback allocCb, void* allocCbUserData)
 {
 {
+	m_originalAllocCallback = allocCb;
+	m_originalAllocUserData = allocCbUserData;
+
+	// Config set is a bit special so init it ASAP
+	ConfigSet::allocateSingleton(allocCb, allocCbUserData);
 }
 }
 
 
 App::~App()
 App::~App()
@@ -116,49 +121,39 @@ void App::cleanup()
 	m_statsUi.reset(nullptr);
 	m_statsUi.reset(nullptr);
 	m_console.reset(nullptr);
 	m_console.reset(nullptr);
 
 
-	deleteInstance(m_mainPool, m_scene);
-	m_scene = nullptr;
-	deleteInstance(m_mainPool, m_script);
-	m_script = nullptr;
-	deleteInstance(m_mainPool, m_renderer);
-	m_renderer = nullptr;
-	deleteInstance(m_mainPool, m_ui);
-	m_ui = nullptr;
-	deleteInstance(m_mainPool, m_resources);
-	m_resources = nullptr;
-	deleteInstance(m_mainPool, m_resourceFs);
-	m_resourceFs = nullptr;
-	deleteInstance(m_mainPool, m_physics);
-	m_physics = nullptr;
-	deleteInstance(m_mainPool, m_stagingMem);
-	m_stagingMem = nullptr;
-	deleteInstance(m_mainPool, m_unifiedGometryMemPool);
-	m_unifiedGometryMemPool = nullptr;
-	deleteInstance(m_mainPool, m_threadHive);
-	m_threadHive = nullptr;
-	deleteInstance(m_mainPool, m_maliHwCounters);
-	m_maliHwCounters = nullptr;
-	GrManager::deleteInstance(m_gr);
-	m_gr = nullptr;
-	Input::deleteInstance(m_input);
-	m_input = nullptr;
-	NativeWindow::deleteInstance(m_window);
-	m_window = nullptr;
+	SceneGraph::freeSingleton();
+	ScriptManager::freeSingleton();
+	MainRenderer::freeSingleton();
+	UiManager::freeSingleton();
+	GpuSceneMicroPatcher::freeSingleton();
+	ResourceManager::freeSingleton();
+	PhysicsWorld::freeSingleton();
+	RebarStagingGpuMemoryPool::freeSingleton();
+	UnifiedGeometryMemoryPool::freeSingleton();
+	GpuSceneMemoryPool::freeSingleton();
+	CoreThreadHive::freeSingleton();
+	MaliHwCounters::freeSingleton();
+	GrManager::freeSingleton();
+	Input::freeSingleton();
+	NativeWindow::freeSingleton();
 
 
 #if ANKI_ENABLE_TRACE
 #if ANKI_ENABLE_TRACE
-	m_heapAlloc.deleteInstance(m_coreTracer);
-	m_coreTracer = nullptr;
+	CoreTracer::freeSingleton();
 #endif
 #endif
 
 
-	m_settingsDir.destroy(m_mainPool);
-	m_cacheDir.destroy(m_mainPool);
+	GlobalFrameIndex::freeSingleton();
+	ConfigSet::freeSingleton();
+
+	m_settingsDir.destroy();
+	m_cacheDir.destroy();
+
+	CoreMemoryPool::freeSingleton();
+	DefaultMemoryPool::freeSingleton();
 }
 }
 
 
-Error App::init(ConfigSet* config, AllocAlignedCallback allocCb, void* allocCbUserData)
+Error App::init()
 {
 {
-	ANKI_ASSERT(config);
-	m_config = config;
-	const Error err = initInternal(allocCb, allocCbUserData);
+	const Error err = initInternal();
 	if(err)
 	if(err)
 	{
 	{
 		ANKI_CORE_LOGE("App initialization failed. Shutting down");
 		ANKI_CORE_LOGE("App initialization failed. Shutting down");
@@ -168,14 +163,18 @@ Error App::init(ConfigSet* config, AllocAlignedCallback allocCb, void* allocCbUs
 	return err;
 	return err;
 }
 }
 
 
-Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
+Error App::initInternal()
 {
 {
-	LoggerSingleton::get().enableVerbosity(m_config->getCoreVerboseLog());
+	Logger::getSingleton().enableVerbosity(ConfigSet::getSingleton().getCoreVerboseLog());
 
 
 	setSignalHandlers();
 	setSignalHandlers();
 
 
+	AllocAlignedCallback allocCb = m_originalAllocCallback;
+	void* allocCbUserData = m_originalAllocUserData;
 	initMemoryCallbacks(allocCb, allocCbUserData);
 	initMemoryCallbacks(allocCb, allocCbUserData);
-	m_mainPool.init(allocCb, allocCbUserData, "Core");
+
+	DefaultMemoryPool::allocateSingleton(allocCb, allocCbUserData);
+	CoreMemoryPool::allocateSingleton(allocCb, allocCbUserData);
 
 
 	ANKI_CHECK(initDirs());
 	ANKI_CHECK(initDirs());
 
 
@@ -219,158 +218,132 @@ Error App::initInternal(AllocAlignedCallback allocCb, void* allocCbUserData)
 	}
 	}
 #endif
 #endif
 
 
-	ANKI_CORE_LOGI("Number of job threads: %u", m_config->getCoreJobThreadCount());
+	ANKI_CORE_LOGI("Number of job threads: %u", ConfigSet::getSingleton().getCoreJobThreadCount());
+
+	if(ConfigSet::getSingleton().getCoreBenchmarkMode() && ConfigSet::getSingleton().getGrVsync())
+	{
+		ANKI_CORE_LOGW("Vsync is enabled and benchmark mode as well. Will turn vsync off");
+		ConfigSet::getSingleton().setGrVsync(false);
+	}
+
+	GlobalFrameIndex::allocateSingleton();
 
 
 	//
 	//
 	// Core tracer
 	// Core tracer
 	//
 	//
 #if ANKI_ENABLE_TRACE
 #if ANKI_ENABLE_TRACE
-	m_coreTracer = m_heapAlloc.newInstance<CoreTracer>();
-	ANKI_CHECK(m_coreTracer->init(m_heapAlloc, m_settingsDir));
+	ANKI_CHECK(CoreTracer::allocateSingleton().init(m_settingsDir));
 #endif
 #endif
 
 
 	//
 	//
 	// Window
 	// Window
 	//
 	//
 	NativeWindowInitInfo nwinit;
 	NativeWindowInitInfo nwinit;
-	nwinit.m_allocCallback = m_mainPool.getAllocationCallback();
-	nwinit.m_allocCallbackUserData = m_mainPool.getAllocationCallbackUserData();
-	nwinit.m_width = m_config->getWidth();
-	nwinit.m_height = m_config->getHeight();
+	nwinit.m_width = ConfigSet::getSingleton().getWidth();
+	nwinit.m_height = ConfigSet::getSingleton().getHeight();
 	nwinit.m_depthBits = 0;
 	nwinit.m_depthBits = 0;
 	nwinit.m_stencilBits = 0;
 	nwinit.m_stencilBits = 0;
-	nwinit.m_fullscreenDesktopRez = m_config->getWindowFullscreen() > 0;
-	nwinit.m_exclusiveFullscreen = m_config->getWindowFullscreen() == 2;
-	ANKI_CHECK(NativeWindow::newInstance(nwinit, m_window));
+	nwinit.m_fullscreenDesktopRez = ConfigSet::getSingleton().getWindowFullscreen() > 0;
+	nwinit.m_exclusiveFullscreen = ConfigSet::getSingleton().getWindowFullscreen() == 2;
+	nwinit.m_targetFps = ConfigSet::getSingleton().getCoreTargetFps();
+	NativeWindow::allocateSingleton();
+	ANKI_CHECK(NativeWindow::getSingleton().init(nwinit));
 
 
 	//
 	//
 	// Input
 	// Input
 	//
 	//
-	ANKI_CHECK(Input::newInstance(m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData(),
-								  m_window, m_input));
+	Input::allocateSingleton();
+	ANKI_CHECK(Input::getSingleton().init());
 
 
 	//
 	//
 	// ThreadPool
 	// ThreadPool
 	//
 	//
-	m_threadHive = newInstance<ThreadHive>(m_mainPool, m_config->getCoreJobThreadCount(), &m_mainPool, true);
+	const Bool pinThreads = !ANKI_OS_ANDROID;
+	CoreThreadHive::allocateSingleton(ConfigSet::getSingleton().getCoreJobThreadCount(), pinThreads);
 
 
 	//
 	//
 	// Graphics API
 	// Graphics API
 	//
 	//
 	GrManagerInitInfo grInit;
 	GrManagerInitInfo grInit;
-	grInit.m_allocCallback = m_mainPool.getAllocationCallback();
-	grInit.m_allocCallbackUserData = m_mainPool.getAllocationCallbackUserData();
+	grInit.m_allocCallback = allocCb;
+	grInit.m_allocCallbackUserData = allocCbUserData;
 	grInit.m_cacheDirectory = m_cacheDir.toCString();
 	grInit.m_cacheDirectory = m_cacheDir.toCString();
-	grInit.m_config = m_config;
-	grInit.m_window = m_window;
-
-	ANKI_CHECK(GrManager::newInstance(grInit, m_gr));
+	ANKI_CHECK(GrManager::allocateSingleton().init(grInit));
 
 
 	//
 	//
 	// Mali HW counters
 	// Mali HW counters
 	//
 	//
-	if(m_gr->getDeviceCapabilities().m_gpuVendor == GpuVendor::kArm && m_config->getCoreMaliHwCounters())
+	if(GrManager::getSingleton().getDeviceCapabilities().m_gpuVendor == GpuVendor::kArm
+	   && ConfigSet::getSingleton().getCoreMaliHwCounters())
 	{
 	{
-		m_maliHwCounters = newInstance<MaliHwCounters>(m_mainPool, &m_mainPool);
+		MaliHwCounters::allocateSingleton();
 	}
 	}
 
 
 	//
 	//
 	// GPU mem
 	// GPU mem
 	//
 	//
-	m_unifiedGometryMemPool = newInstance<UnifiedGeometryMemoryPool>(m_mainPool);
-	m_unifiedGometryMemPool->init(&m_mainPool, m_gr, *m_config);
-
-	m_stagingMem = newInstance<StagingGpuMemoryPool>(m_mainPool);
-	ANKI_CHECK(m_stagingMem->init(m_gr, *m_config));
+	UnifiedGeometryMemoryPool::allocateSingleton().init();
+	GpuSceneMemoryPool::allocateSingleton().init();
+	RebarStagingGpuMemoryPool::allocateSingleton().init();
 
 
 	//
 	//
 	// Physics
 	// Physics
 	//
 	//
-	m_physics = newInstance<PhysicsWorld>(m_mainPool);
-	ANKI_CHECK(m_physics->init(m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData()));
+	PhysicsWorld::allocateSingleton();
+	ANKI_CHECK(PhysicsWorld::getSingleton().init(allocCb, allocCbUserData));
 
 
 	//
 	//
-	// Resource FS
+	// Resources
 	//
 	//
 #if !ANKI_OS_ANDROID
 #if !ANKI_OS_ANDROID
 	// Add the location of the executable where the shaders are supposed to be
 	// Add the location of the executable where the shaders are supposed to be
-	StringRaii executableFname(&m_mainPool);
+	String executableFname;
 	ANKI_CHECK(getApplicationPath(executableFname));
 	ANKI_CHECK(getApplicationPath(executableFname));
 	ANKI_CORE_LOGI("Executable path is: %s", executableFname.cstr());
 	ANKI_CORE_LOGI("Executable path is: %s", executableFname.cstr());
-	StringRaii shadersPath(&m_mainPool);
+	String shadersPath;
 	getParentFilepath(executableFname, shadersPath);
 	getParentFilepath(executableFname, shadersPath);
-	shadersPath.append(":");
-	shadersPath.append(m_config->getRsrcDataPaths());
-	m_config->setRsrcDataPaths(shadersPath);
+	shadersPath += ":";
+	shadersPath += ConfigSet::getSingleton().getRsrcDataPaths();
+	ConfigSet::getSingleton().setRsrcDataPaths(shadersPath);
 #endif
 #endif
 
 
-	m_resourceFs = newInstance<ResourceFilesystem>(m_mainPool);
-	ANKI_CHECK(
-		m_resourceFs->init(*m_config, m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData()));
+	ANKI_CHECK(ResourceManager::allocateSingleton().init(allocCb, allocCbUserData));
 
 
 	//
 	//
-	// Resources
+	// UI
 	//
 	//
-	ResourceManagerInitInfo rinit;
-	rinit.m_gr = m_gr;
-	rinit.m_physics = m_physics;
-	rinit.m_resourceFs = m_resourceFs;
-	rinit.m_unifiedGometryMemoryPool = m_unifiedGometryMemPool;
-	rinit.m_config = m_config;
-	rinit.m_allocCallback = m_mainPool.getAllocationCallback();
-	rinit.m_allocCallbackData = m_mainPool.getAllocationCallbackUserData();
-	m_resources = newInstance<ResourceManager>(m_mainPool);
-
-	ANKI_CHECK(m_resources->init(rinit));
+	ANKI_CHECK(UiManager::allocateSingleton().init(allocCb, allocCbUserData));
 
 
 	//
 	//
-	// UI
+	// GPU scene
 	//
 	//
-	m_ui = newInstance<UiManager>(m_mainPool);
-	ANKI_CHECK(m_ui->init(m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData(), m_resources,
-						  m_gr, m_stagingMem, m_input));
+	ANKI_CHECK(GpuSceneMicroPatcher::allocateSingleton().init());
 
 
 	//
 	//
 	// Renderer
 	// Renderer
 	//
 	//
 	MainRendererInitInfo renderInit;
 	MainRendererInitInfo renderInit;
-	renderInit.m_swapchainSize = UVec2(m_window->getWidth(), m_window->getHeight());
-	renderInit.m_allocCallback = m_mainPool.getAllocationCallback();
-	renderInit.m_allocCallbackUserData = m_mainPool.getAllocationCallbackUserData();
-	renderInit.m_threadHive = m_threadHive;
-	renderInit.m_resourceManager = m_resources;
-	renderInit.m_gr = m_gr;
-	renderInit.m_stagingMemory = m_stagingMem;
-	renderInit.m_ui = m_ui;
-	renderInit.m_config = m_config;
-	renderInit.m_globTimestamp = &m_globalTimestamp;
-	m_renderer = newInstance<MainRenderer>(m_mainPool);
-	ANKI_CHECK(m_renderer->init(renderInit));
+	renderInit.m_swapchainSize =
+		UVec2(NativeWindow::getSingleton().getWidth(), NativeWindow::getSingleton().getHeight());
+	renderInit.m_allocCallback = allocCb;
+	renderInit.m_allocCallbackUserData = allocCbUserData;
+	ANKI_CHECK(MainRenderer::allocateSingleton().init(renderInit));
 
 
 	//
 	//
 	// Script
 	// Script
 	//
 	//
-	m_script = newInstance<ScriptManager>(m_mainPool);
-	ANKI_CHECK(m_script->init(m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData()));
+	ScriptManager::allocateSingleton(allocCb, allocCbUserData);
 
 
 	//
 	//
 	// Scene
 	// Scene
 	//
 	//
-	m_scene = newInstance<SceneGraph>(m_mainPool);
-
-	ANKI_CHECK(m_scene->init(m_mainPool.getAllocationCallback(), m_mainPool.getAllocationCallbackUserData(),
-							 m_threadHive, m_resources, m_input, m_script, m_ui, m_config, &m_globalTimestamp,
-							 m_unifiedGometryMemPool));
-
-	// Inform the script engine about some subsystems
-	m_script->setRenderer(m_renderer);
-	m_script->setSceneGraph(m_scene);
+	ANKI_CHECK(SceneGraph::allocateSingleton().init(allocCb, allocCbUserData));
 
 
 	//
 	//
 	// Misc
 	// Misc
 	//
 	//
-	ANKI_CHECK(m_ui->newInstance<StatsUi>(m_statsUi));
-	ANKI_CHECK(m_ui->newInstance<DeveloperConsole>(m_console, m_script));
+	ANKI_CHECK(UiManager::getSingleton().newInstance<StatsUi>(m_statsUi));
+	ANKI_CHECK(UiManager::getSingleton().newInstance<DeveloperConsole>(m_console));
 
 
 	ANKI_CORE_LOGI("Application initialized");
 	ANKI_CORE_LOGI("Application initialized");
 
 
@@ -381,12 +354,12 @@ Error App::initDirs()
 {
 {
 	// Settings path
 	// Settings path
 #if !ANKI_OS_ANDROID
 #if !ANKI_OS_ANDROID
-	StringRaii home(&m_mainPool);
+	String home;
 	ANKI_CHECK(getHomeDirectory(home));
 	ANKI_CHECK(getHomeDirectory(home));
 
 
-	m_settingsDir.sprintf(m_mainPool, "%s/.anki", &home[0]);
+	m_settingsDir.sprintf("%s/.anki", &home[0]);
 #else
 #else
-	m_settingsDir.sprintf(m_mainPool, "%s/.anki", g_androidApp->activity->internalDataPath);
+	m_settingsDir.sprintf("%s/.anki", g_androidApp->activity->internalDataPath);
 #endif
 #endif
 
 
 	if(!directoryExists(m_settingsDir.toCString()))
 	if(!directoryExists(m_settingsDir.toCString()))
@@ -400,18 +373,18 @@ Error App::initDirs()
 	}
 	}
 
 
 	// Cache
 	// Cache
-	m_cacheDir.sprintf(m_mainPool, "%s/cache", &m_settingsDir[0]);
+	m_cacheDir.sprintf("%s/cache", &m_settingsDir[0]);
 
 
 	const Bool cacheDirExists = directoryExists(m_cacheDir.toCString());
 	const Bool cacheDirExists = directoryExists(m_cacheDir.toCString());
-	if(m_config->getCoreClearCaches() && cacheDirExists)
+	if(ConfigSet::getSingleton().getCoreClearCaches() && cacheDirExists)
 	{
 	{
-		ANKI_CORE_LOGI("Will delete the cache dir and start fresh: %s", &m_cacheDir[0]);
-		ANKI_CHECK(removeDirectory(m_cacheDir.toCString(), m_mainPool));
+		ANKI_CORE_LOGI("Will delete the cache dir and start fresh: %s", m_cacheDir.cstr());
+		ANKI_CHECK(removeDirectory(m_cacheDir.toCString()));
 		ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
 		ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
 	}
 	}
 	else if(!cacheDirExists)
 	else if(!cacheDirExists)
 	{
 	{
-		ANKI_CORE_LOGI("Will create cache dir: %s", &m_cacheDir[0]);
+		ANKI_CORE_LOGI("Will create cache dir: %s", m_cacheDir.cstr());
 		ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
 		ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
 	}
 	}
 
 
@@ -426,80 +399,131 @@ Error App::mainLoop()
 	Second prevUpdateTime = HighRezTimer::getCurrentTime();
 	Second prevUpdateTime = HighRezTimer::getCurrentTime();
 	Second crntTime = prevUpdateTime;
 	Second crntTime = prevUpdateTime;
 
 
+	// Benchmark mode stuff:
+	const Bool benchmarkMode = ConfigSet::getSingleton().getCoreBenchmarkMode();
+	Second aggregatedCpuTime = 0.0;
+	Second aggregatedGpuTime = 0.0;
+	constexpr U32 kBenchmarkFramesToGatherBeforeFlush = 60;
+	U32 benchmarkFramesGathered = 0;
+	File benchmarkCsvFile;
+	CoreString benchmarkCsvFileFilename;
+	if(benchmarkMode)
+	{
+		benchmarkCsvFileFilename.sprintf("%s/Benchmark.csv", m_settingsDir.cstr());
+		ANKI_CHECK(benchmarkCsvFile.open(benchmarkCsvFileFilename, FileOpenFlag::kWrite));
+		ANKI_CHECK(benchmarkCsvFile.writeText("CPU, GPU\n"));
+	}
+
 	while(!quit)
 	while(!quit)
 	{
 	{
 		{
 		{
-			ANKI_TRACE_SCOPED_EVENT(FRAME);
+			ANKI_TRACE_SCOPED_EVENT(Frame);
 			const Second startTime = HighRezTimer::getCurrentTime();
 			const Second startTime = HighRezTimer::getCurrentTime();
 
 
 			prevUpdateTime = crntTime;
 			prevUpdateTime = crntTime;
-			crntTime = HighRezTimer::getCurrentTime();
+			crntTime = (!benchmarkMode) ? HighRezTimer::getCurrentTime() : (prevUpdateTime + 1.0_sec / 60.0_sec);
 
 
 			// Update
 			// Update
-			ANKI_CHECK(m_input->handleEvents());
+			ANKI_CHECK(Input::getSingleton().handleEvents());
 
 
 			// User update
 			// User update
 			ANKI_CHECK(userMainLoop(quit, crntTime - prevUpdateTime));
 			ANKI_CHECK(userMainLoop(quit, crntTime - prevUpdateTime));
 
 
-			ANKI_CHECK(m_scene->update(prevUpdateTime, crntTime));
+			ANKI_CHECK(SceneGraph::getSingleton().update(prevUpdateTime, crntTime));
 
 
 			RenderQueue rqueue;
 			RenderQueue rqueue;
-			m_scene->doVisibilityTests(rqueue);
+			SceneGraph::getSingleton().doVisibilityTests(rqueue);
 
 
 			// Inject stats UI
 			// Inject stats UI
-			DynamicArrayRaii<UiQueueElement> newUiElementArr(&m_mainPool);
+			CoreDynamicArray<UiQueueElement> newUiElementArr;
 			injectUiElements(newUiElementArr, rqueue);
 			injectUiElements(newUiElementArr, rqueue);
 
 
 			// Render
 			// Render
-			TexturePtr presentableTex = m_gr->acquireNextPresentableTexture();
-			m_renderer->setStatsEnabled(m_config->getCoreDisplayStats() > 0
+			TexturePtr presentableTex = GrManager::getSingleton().acquireNextPresentableTexture();
+			MainRenderer::getSingleton().setStatsEnabled(ConfigSet::getSingleton().getCoreDisplayStats() > 0
+														 || benchmarkMode
 #if ANKI_ENABLE_TRACE
 #if ANKI_ENABLE_TRACE
-										|| TracerSingleton::get().getEnabled()
+														 || Tracer::getSingleton().getEnabled()
 #endif
 #endif
 			);
 			);
-			ANKI_CHECK(m_renderer->render(rqueue, presentableTex));
+			ANKI_CHECK(MainRenderer::getSingleton().render(rqueue, presentableTex));
 
 
 			// Pause and sync async loader. That will force all tasks before the pause to finish in this frame.
 			// Pause and sync async loader. That will force all tasks before the pause to finish in this frame.
-			m_resources->getAsyncLoader().pause();
+			ResourceManager::getSingleton().getAsyncLoader().pause();
+
+			// If we get stats exclude the time of GR because it forces some GPU-CPU serialization. We don't want to
+			// count that
+			Second grTime = 0.0;
+			if(benchmarkMode || ConfigSet::getSingleton().getCoreDisplayStats() > 0) [[unlikely]]
+			{
+				grTime = HighRezTimer::getCurrentTime();
+			}
 
 
-			m_gr->swapBuffers();
-			m_stagingMem->endFrame();
-			m_unifiedGometryMemPool->endFrame();
+			GrManager::getSingleton().swapBuffers();
+
+			if(benchmarkMode || ConfigSet::getSingleton().getCoreDisplayStats() > 0) [[unlikely]]
+			{
+				grTime = HighRezTimer::getCurrentTime() - grTime;
+			}
+
+			const PtrSize rebarMemUsed = RebarStagingGpuMemoryPool::getSingleton().endFrame();
+			UnifiedGeometryMemoryPool::getSingleton().endFrame();
+			GpuSceneMemoryPool::getSingleton().endFrame();
 
 
 			// Update the trace info with some async loader stats
 			// Update the trace info with some async loader stats
-			U64 asyncTaskCount = m_resources->getAsyncLoader().getCompletedTaskCount();
-			ANKI_TRACE_INC_COUNTER(RESOURCE_ASYNC_TASKS, asyncTaskCount - m_resourceCompletedAsyncTaskCount);
+			U64 asyncTaskCount = ResourceManager::getSingleton().getAsyncLoader().getCompletedTaskCount();
+			ANKI_TRACE_INC_COUNTER(RsrcAsyncTasks, asyncTaskCount - m_resourceCompletedAsyncTaskCount);
 			m_resourceCompletedAsyncTaskCount = asyncTaskCount;
 			m_resourceCompletedAsyncTaskCount = asyncTaskCount;
 
 
 			// Now resume the loader
 			// Now resume the loader
-			m_resources->getAsyncLoader().resume();
+			ResourceManager::getSingleton().getAsyncLoader().resume();
 
 
 			// Sleep
 			// Sleep
 			const Second endTime = HighRezTimer::getCurrentTime();
 			const Second endTime = HighRezTimer::getCurrentTime();
 			const Second frameTime = endTime - startTime;
 			const Second frameTime = endTime - startTime;
-			const Second timerTick = 1.0 / Second(m_config->getCoreTargetFps());
-			if(frameTime < timerTick)
+			if(!benchmarkMode) [[likely]]
 			{
 			{
-				ANKI_TRACE_SCOPED_EVENT(TIMER_TICK_SLEEP);
-				HighRezTimer::sleep(timerTick - frameTime);
+				const Second timerTick = 1.0_sec / Second(ConfigSet::getSingleton().getCoreTargetFps());
+				if(frameTime < timerTick)
+				{
+					ANKI_TRACE_SCOPED_EVENT(TimerTickSleep);
+					HighRezTimer::sleep(timerTick - frameTime);
+				}
+			}
+			// Benchmark stats
+			else
+			{
+				aggregatedCpuTime += frameTime - grTime;
+				aggregatedGpuTime += MainRenderer::getSingleton().getStats().m_renderingGpuTime;
+				++benchmarkFramesGathered;
+				if(benchmarkFramesGathered >= kBenchmarkFramesToGatherBeforeFlush)
+				{
+					aggregatedCpuTime = aggregatedCpuTime / Second(kBenchmarkFramesToGatherBeforeFlush) * 1000.0;
+					aggregatedGpuTime = aggregatedGpuTime / Second(kBenchmarkFramesToGatherBeforeFlush) * 1000.0;
+					ANKI_CHECK(benchmarkCsvFile.writeTextf("%f,%f\n", aggregatedCpuTime, aggregatedGpuTime));
+
+					benchmarkFramesGathered = 0;
+					aggregatedCpuTime = 0.0;
+					aggregatedGpuTime = 0.0;
+				}
 			}
 			}
 
 
 			// Stats
 			// Stats
-			if(m_config->getCoreDisplayStats() > 0)
+			if(ConfigSet::getSingleton().getCoreDisplayStats() > 0)
 			{
 			{
 				StatsUiInput in;
 				StatsUiInput in;
-				in.m_cpuFrameTime = frameTime;
-				in.m_rendererTime = m_renderer->getStats().m_renderingCpuTime;
-				in.m_sceneUpdateTime = m_scene->getStats().m_updateTime;
-				in.m_visibilityTestsTime = m_scene->getStats().m_visibilityTestsTime;
-				in.m_physicsTime = m_scene->getStats().m_physicsUpdate;
+				in.m_cpuFrameTime = frameTime - grTime;
+				in.m_rendererTime = MainRenderer::getSingleton().getStats().m_renderingCpuTime;
+				in.m_sceneUpdateTime = SceneGraph::getSingleton().getStats().m_updateTime;
+				in.m_visibilityTestsTime = SceneGraph::getSingleton().getStats().m_visibilityTestsTime;
+				in.m_physicsTime = SceneGraph::getSingleton().getStats().m_physicsUpdate;
 
 
-				in.m_gpuFrameTime = m_renderer->getStats().m_renderingGpuTime;
+				in.m_gpuFrameTime = MainRenderer::getSingleton().getStats().m_renderingGpuTime;
 
 
-				if(m_maliHwCounters)
+				if(MaliHwCounters::isAllocated())
 				{
 				{
 					MaliHwCountersOut out;
 					MaliHwCountersOut out;
-					m_maliHwCounters->sample(out);
+					MaliHwCounters::getSingleton().sample(out);
 					in.m_gpuActiveCycles = out.m_gpuActive;
 					in.m_gpuActiveCycles = out.m_gpuActive;
 					in.m_gpuReadBandwidth = out.m_readBandwidth;
 					in.m_gpuReadBandwidth = out.m_readBandwidth;
 					in.m_gpuWriteBandwidth = out.m_writeBandwidth;
 					in.m_gpuWriteBandwidth = out.m_writeBandwidth;
@@ -509,49 +533,66 @@ Error App::mainLoop()
 				in.m_cpuAllocationCount = m_memStats.m_allocCount.load();
 				in.m_cpuAllocationCount = m_memStats.m_allocCount.load();
 				in.m_cpuFreeCount = m_memStats.m_freeCount.load();
 				in.m_cpuFreeCount = m_memStats.m_freeCount.load();
 
 
-				const GrManagerStats grStats = m_gr->getStats();
-				m_unifiedGometryMemPool->getStats(in.m_unifiedGometryExternalFragmentation,
-												  in.m_unifiedGeometryAllocated, in.m_unifiedGeometryTotal);
-
+				const GrManagerStats grStats = GrManager::getSingleton().getStats();
+				UnifiedGeometryMemoryPool::getSingleton().getStats(
+					in.m_unifiedGometryExternalFragmentation, in.m_unifiedGeometryAllocated, in.m_unifiedGeometryTotal);
+				GpuSceneMemoryPool::getSingleton().getStats(in.m_gpuSceneExternalFragmentation, in.m_gpuSceneAllocated,
+															in.m_gpuSceneTotal);
 				in.m_gpuDeviceMemoryAllocated = grStats.m_deviceMemoryAllocated;
 				in.m_gpuDeviceMemoryAllocated = grStats.m_deviceMemoryAllocated;
 				in.m_gpuDeviceMemoryInUse = grStats.m_deviceMemoryInUse;
 				in.m_gpuDeviceMemoryInUse = grStats.m_deviceMemoryInUse;
+				in.m_reBar = rebarMemUsed;
 
 
 				in.m_drawableCount = rqueue.countAllRenderables();
 				in.m_drawableCount = rqueue.countAllRenderables();
 				in.m_vkCommandBufferCount = grStats.m_commandBufferCount;
 				in.m_vkCommandBufferCount = grStats.m_commandBufferCount;
 
 
 				StatsUi& statsUi = *static_cast<StatsUi*>(m_statsUi.get());
 				StatsUi& statsUi = *static_cast<StatsUi*>(m_statsUi.get());
-				const StatsUiDetail detail =
-					(m_config->getCoreDisplayStats() == 1) ? StatsUiDetail::kFpsOnly : StatsUiDetail::kDetailed;
+				const StatsUiDetail detail = (ConfigSet::getSingleton().getCoreDisplayStats() == 1)
+												 ? StatsUiDetail::kFpsOnly
+												 : StatsUiDetail::kDetailed;
 				statsUi.setStats(in, detail);
 				statsUi.setStats(in, detail);
 			}
 			}
 
 
 #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,
+				ANKI_TRACE_CUSTOM_EVENT(Gpu, m_renderer->getStats().m_renderingGpuSubmitTimestamp,
 										m_renderer->getStats().m_renderingGpuTime);
 										m_renderer->getStats().m_renderingGpuTime);
 			}
 			}
 #endif
 #endif
 
 
-			++m_globalTimestamp;
+			++GlobalFrameIndex::getSingleton().m_value;
+
+			if(benchmarkMode) [[unlikely]]
+			{
+				if(GlobalFrameIndex::getSingleton().m_value
+				   >= ConfigSet::getSingleton().getCoreBenchmarkModeFrameCount())
+				{
+					quit = true;
+				}
+			}
 		}
 		}
 
 
 #if ANKI_ENABLE_TRACE
 #if ANKI_ENABLE_TRACE
 		static U64 frame = 1;
 		static U64 frame = 1;
-		m_coreTracer->flushFrame(frame++);
+		CoreTracer::getSingleton().flushFrame(frame++);
 #endif
 #endif
 	}
 	}
 
 
+	if(benchmarkMode) [[unlikely]]
+	{
+		ANKI_CORE_LOGI("Benchmark file saved in: %s", benchmarkCsvFileFilename.cstr());
+	}
+
 	return Error::kNone;
 	return Error::kNone;
 }
 }
 
 
-void App::injectUiElements(DynamicArrayRaii<UiQueueElement>& newUiElementArr, RenderQueue& rqueue)
+void App::injectUiElements(CoreDynamicArray<UiQueueElement>& newUiElementArr, RenderQueue& rqueue)
 {
 {
 	const U32 originalCount = rqueue.m_uis.getSize();
 	const U32 originalCount = rqueue.m_uis.getSize();
-	if(m_config->getCoreDisplayStats() > 0 || m_consoleEnabled)
+	if(ConfigSet::getSingleton().getCoreDisplayStats() > 0 || m_consoleEnabled)
 	{
 	{
-		const U32 extraElements = (m_config->getCoreDisplayStats() > 0) + (m_consoleEnabled != 0);
-		newUiElementArr.create(originalCount + extraElements);
+		const U32 extraElements = (ConfigSet::getSingleton().getCoreDisplayStats() > 0) + (m_consoleEnabled != 0);
+		newUiElementArr.resize(originalCount + extraElements);
 
 
 		if(originalCount > 0)
 		if(originalCount > 0)
 		{
 		{
@@ -562,7 +603,7 @@ void App::injectUiElements(DynamicArrayRaii<UiQueueElement>& newUiElementArr, Re
 	}
 	}
 
 
 	U32 count = originalCount;
 	U32 count = originalCount;
-	if(m_config->getCoreDisplayStats() > 0)
+	if(ConfigSet::getSingleton().getCoreDisplayStats() > 0)
 	{
 	{
 		newUiElementArr[count].m_userData = m_statsUi.get();
 		newUiElementArr[count].m_userData = m_statsUi.get();
 		newUiElementArr[count].m_drawCallback = [](CanvasPtr& canvas, void* userData) -> void {
 		newUiElementArr[count].m_drawCallback = [](CanvasPtr& canvas, void* userData) -> void {
@@ -583,13 +624,10 @@ void App::injectUiElements(DynamicArrayRaii<UiQueueElement>& newUiElementArr, Re
 
 
 void App::initMemoryCallbacks(AllocAlignedCallback& allocCb, void*& allocCbUserData)
 void App::initMemoryCallbacks(AllocAlignedCallback& allocCb, void*& allocCbUserData)
 {
 {
-	if(m_config->getCoreDisplayStats() > 1)
+	if(ConfigSet::getSingleton().getCoreDisplayStats() > 1)
 	{
 	{
-		m_memStats.m_originalAllocCallback = allocCb;
-		m_memStats.m_originalUserData = allocCbUserData;
-
 		allocCb = MemStats::allocCallback;
 		allocCb = MemStats::allocCallback;
-		allocCbUserData = &m_memStats;
+		allocCbUserData = this;
 	}
 	}
 	else
 	else
 	{
 	{
@@ -629,8 +667,7 @@ void App::setSignalHandlers()
 
 
 		U32 count = 0;
 		U32 count = 0;
 		printf("Backtrace:\n");
 		printf("Backtrace:\n");
-		HeapMemoryPool pool(allocAligned, nullptr);
-		backtrace(pool, [&count](CString symbol) {
+		backtrace([&count](CString symbol) {
 			printf("%.2u: %s\n", count++, symbol.cstr());
 			printf("%.2u: %s\n", count++, symbol.cstr());
 		});
 		});
 
 

+ 13 - 112
AnKi/Core/App.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -13,61 +13,30 @@
 namespace anki {
 namespace anki {
 
 
 // Forward
 // Forward
-class CoreTracer;
-class ConfigSet;
-class ThreadHive;
-class NativeWindow;
-class Input;
-class GrManager;
-class MainRenderer;
-class PhysicsWorld;
-class SceneGraph;
-class ScriptManager;
-class ResourceManager;
-class ResourceFilesystem;
-class StagingGpuMemoryPool;
-class UnifiedGeometryMemoryPool;
-class UiManager;
 class UiQueueElement;
 class UiQueueElement;
 class RenderQueue;
 class RenderQueue;
-class MaliHwCounters;
 
 
 /// The core class of the engine.
 /// The core class of the engine.
 class App
 class App
 {
 {
 public:
 public:
-	App();
+	App(AllocAlignedCallback allocCb = allocAligned, void* allocCbUserData = nullptr);
+
 	virtual ~App();
 	virtual ~App();
 
 
 	/// Initialize the application.
 	/// Initialize the application.
-	/// @param[in,out] config The config. Needs to be alive as long as the app is alive.
-	Error init(ConfigSet* config, AllocAlignedCallback allocCb, void* allocCbUserData);
+	Error init();
 
 
-	const String& getSettingsDirectory() const
+	CString getSettingsDirectory() const
 	{
 	{
 		return m_settingsDir;
 		return m_settingsDir;
 	}
 	}
 
 
-	const String& getCacheDirectory() const
+	CString getCacheDirectory() const
 	{
 	{
 		return m_cacheDir;
 		return m_cacheDir;
 	}
 	}
 
 
-	ThreadHive& getThreadHive()
-	{
-		return *m_threadHive;
-	}
-
-	HeapMemoryPool& getMemoryPool()
-	{
-		return m_mainPool;
-	}
-
-	Timestamp getGlobalTimestamp() const
-	{
-		return m_globalTimestamp;
-	}
-
 	/// Run the main loop.
 	/// Run the main loop.
 	Error mainLoop();
 	Error mainLoop();
 
 
@@ -78,51 +47,6 @@ public:
 		return Error::kNone;
 		return Error::kNone;
 	}
 	}
 
 
-	const ConfigSet& getConfig() const
-	{
-		return *m_config;
-	}
-
-	ConfigSet& getConfig()
-	{
-		return *m_config;
-	}
-
-	Input& getInput()
-	{
-		return *m_input;
-	}
-
-	SceneGraph& getSceneGraph()
-	{
-		return *m_scene;
-	}
-
-	MainRenderer& getMainRenderer()
-	{
-		return *m_renderer;
-	}
-
-	ResourceManager& getResourceManager()
-	{
-		return *m_resources;
-	}
-
-	ScriptManager& getScriptManager()
-	{
-		return *m_script;
-	}
-
-	PhysicsWorld& getPhysicsWorld()
-	{
-		return *m_physics;
-	}
-
-	NativeWindow& getWindow()
-	{
-		return *m_window;
-	}
-
 	void setDisplayDeveloperConsole(Bool display)
 	void setDisplayDeveloperConsole(Bool display)
 	{
 	{
 		m_consoleEnabled = display;
 		m_consoleEnabled = display;
@@ -134,37 +58,17 @@ public:
 	}
 	}
 
 
 private:
 private:
-	HeapMemoryPool m_mainPool;
-
-	// Sybsystems
-	ConfigSet* m_config = nullptr;
-#if ANKI_ENABLE_TRACE
-	CoreTracer* m_coreTracer = nullptr;
-#endif
-	NativeWindow* m_window = nullptr;
-	Input* m_input = nullptr;
-	ThreadHive* m_threadHive = nullptr;
-	GrManager* m_gr = nullptr;
-	MaliHwCounters* m_maliHwCounters = nullptr;
-	UnifiedGeometryMemoryPool* m_unifiedGometryMemPool = nullptr;
-	StagingGpuMemoryPool* m_stagingMem = nullptr;
-	PhysicsWorld* m_physics = nullptr;
-	ResourceFilesystem* m_resourceFs = nullptr;
-	ResourceManager* m_resources = nullptr;
-	UiManager* m_ui = nullptr;
-	MainRenderer* m_renderer = nullptr;
-	SceneGraph* m_scene = nullptr;
-	ScriptManager* m_script = nullptr;
-
 	// Misc
 	// Misc
 	UiImmediateModeBuilderPtr m_statsUi;
 	UiImmediateModeBuilderPtr m_statsUi;
 	UiImmediateModeBuilderPtr m_console;
 	UiImmediateModeBuilderPtr m_console;
 	Bool m_consoleEnabled = false;
 	Bool m_consoleEnabled = false;
-	Timestamp m_globalTimestamp = 1;
-	String m_settingsDir; ///< The path that holds the configuration
-	String m_cacheDir; ///< This is used as a cache
+	CoreString m_settingsDir; ///< The path that holds the configuration
+	CoreString m_cacheDir; ///< This is used as a cache
 	U64 m_resourceCompletedAsyncTaskCount = 0;
 	U64 m_resourceCompletedAsyncTaskCount = 0;
 
 
+	void* m_originalAllocUserData = nullptr;
+	AllocAlignedCallback m_originalAllocCallback = nullptr;
+
 	class MemStats
 	class MemStats
 	{
 	{
 	public:
 	public:
@@ -172,21 +76,18 @@ private:
 		Atomic<U64> m_allocCount = {0};
 		Atomic<U64> m_allocCount = {0};
 		Atomic<U64> m_freeCount = {0};
 		Atomic<U64> m_freeCount = {0};
 
 
-		void* m_originalUserData = nullptr;
-		AllocAlignedCallback m_originalAllocCallback = nullptr;
-
 		static void* allocCallback(void* userData, void* ptr, PtrSize size, PtrSize alignment);
 		static void* allocCallback(void* userData, void* ptr, PtrSize size, PtrSize alignment);
 	} m_memStats;
 	} m_memStats;
 
 
 	void initMemoryCallbacks(AllocAlignedCallback& allocCb, void*& allocCbUserData);
 	void initMemoryCallbacks(AllocAlignedCallback& allocCb, void*& allocCbUserData);
 
 
-	Error initInternal(AllocAlignedCallback allocCb, void* allocCbUserData);
+	Error initInternal();
 
 
 	Error initDirs();
 	Error initDirs();
 	void cleanup();
 	void cleanup();
 
 
 	/// Inject a new UI element in the render queue for displaying various stuff.
 	/// Inject a new UI element in the render queue for displaying various stuff.
-	void injectUiElements(DynamicArrayRaii<UiQueueElement>& elements, RenderQueue& rqueue);
+	void injectUiElements(CoreDynamicArray<UiQueueElement>& elements, RenderQueue& rqueue);
 
 
 	void setSignalHandlers();
 	void setSignalHandlers();
 };
 };

+ 2 - 16
AnKi/Core/CMakeLists.txt

@@ -17,24 +17,10 @@ set(headers
 	DeveloperConsole.h
 	DeveloperConsole.h
 	GpuMemoryPools.h
 	GpuMemoryPools.h
 	MaliHwCounters.h
 	MaliHwCounters.h
-	NativeWindow.h
 	StatsUi.h
 	StatsUi.h
 	StatsUi.defs.h
 	StatsUi.defs.h
 	StdinListener.h)
 	StdinListener.h)
 
 
-if(ANKI_HEADLESS)
-	set(sources ${sources} NativeWindowHeadless.cpp)
-	set(headers ${headers} NativeWindowHeadless.h)
-elseif(SDL)
-	set(sources ${sources} NativeWindowSdl.cpp)
-	set(headers ${headers} NativeWindowSdl.h)
-elseif(ANDROID)
-	set(sources ${sources} NativeWindowAndroid.cpp)
-	set(headers ${headers} NativeWindowAndroid.h)
-else()
-	message(FATAL_ERROR "Not implemented")
-endif()
-
 add_library(AnKiCore ${sources} ${headers})
 add_library(AnKiCore ${sources} ${headers})
 
 
 if(SDL)
 if(SDL)
@@ -44,10 +30,10 @@ if(SDL)
 
 
 	set(extra_libs ${extra_libs} SDL2-static)
 	set(extra_libs ${extra_libs} SDL2-static)
 elseif(ANDROID)
 elseif(ANDROID)
-	set(extra_libs log android AnKiAndroidNativeGlue AnKiHwcPipe)
+	set(extra_libs log android nativewindow AnKiAndroidNativeGlue AnKiHwcPipe)
 elseif(WINDOWS)
 elseif(WINDOWS)
 	set(extra_libs version Imm32 Winmm DbgHelp)
 	set(extra_libs version Imm32 Winmm DbgHelp)
 endif()
 endif()
 
 
 target_compile_definitions(AnKiCore PRIVATE -DANKI_SOURCE_FILE)
 target_compile_definitions(AnKiCore PRIVATE -DANKI_SOURCE_FILE)
-target_link_libraries(AnKiCore AnKiGr AnKiResource AnKiUi AnKiRenderer AnKiUtil AnKiPhysics AnKiScript AnKiInput ${extra_libs})
+target_link_libraries(AnKiCore AnKiGr AnKiResource AnKiUi AnKiRenderer AnKiUtil AnKiPhysics AnKiScript AnKiWindow ${extra_libs})

+ 38 - 1
AnKi/Core/Common.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -7,6 +7,9 @@
 
 
 #include <AnKi/Config.h>
 #include <AnKi/Config.h>
 #include <AnKi/Util/StdTypes.h>
 #include <AnKi/Util/StdTypes.h>
+#include <AnKi/Util/MemoryPool.h>
+#include <AnKi/Util/DynamicArray.h>
+#include <AnKi/Util/ThreadHive.h>
 
 
 namespace anki {
 namespace anki {
 
 
@@ -15,4 +18,38 @@ namespace anki {
 #define ANKI_CORE_LOGW(...) ANKI_LOG("CORE", kWarning, __VA_ARGS__)
 #define ANKI_CORE_LOGW(...) ANKI_LOG("CORE", kWarning, __VA_ARGS__)
 #define ANKI_CORE_LOGF(...) ANKI_LOG("CORE", kFatal, __VA_ARGS__)
 #define ANKI_CORE_LOGF(...) ANKI_LOG("CORE", kFatal, __VA_ARGS__)
 
 
+class CoreMemoryPool : public HeapMemoryPool, public MakeSingleton<CoreMemoryPool>
+{
+	template<typename>
+	friend class MakeSingleton;
+
+private:
+	CoreMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData)
+		: HeapMemoryPool(allocCb, allocCbUserData, "CoreMemPool")
+	{
+	}
+
+	~CoreMemoryPool() = default;
+};
+
+class CoreThreadHive : public ThreadHive, public MakeSingleton<CoreThreadHive>
+{
+	template<typename>
+	friend class MakeSingleton;
+
+public:
+	CoreThreadHive(U32 threadCount, Bool pinToCores = false)
+		: ThreadHive(threadCount, pinToCores)
+	{
+	}
+};
+
+class GlobalFrameIndex : public MakeSingleton<GlobalFrameIndex>
+{
+public:
+	Timestamp m_value = 1;
+};
+
+ANKI_DEFINE_SUBMODULE_UTIL_CONTAINERS(Core, CoreMemoryPool)
+
 } // end namespace anki
 } // end namespace anki

+ 4 - 4
AnKi/Core/ConfigSet.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -40,7 +40,7 @@ void ConfigSet::init(AllocAlignedCallback allocCb, void* allocCbUserData)
 	m_pool.init(allocCb, allocCbUserData);
 	m_pool.init(allocCb, allocCbUserData);
 
 
 #define ANKI_CONFIG_VAR_NUMERIC(name, defaultValue, minValue, maxValue, description) \
 #define ANKI_CONFIG_VAR_NUMERIC(name, defaultValue, minValue, maxValue, description) \
-	ANKI_ASSERT(minValue <= maxValue && defaultValue >= minValue && defaultValue <= maxValue); \
+	ANKI_ASSERT((minValue) <= (maxValue) && (defaultValue) >= (minValue) && (defaultValue) <= (maxValue)); \
 	m_##name.m_name = #name; \
 	m_##name.m_name = #name; \
 	m_##name.m_description = description; \
 	m_##name.m_description = description; \
 	m_##name.m_value = defaultValue; \
 	m_##name.m_value = defaultValue; \
@@ -106,7 +106,7 @@ Error ConfigSet::loadFromFile(CString filename)
 	ANKI_ASSERT(isInitialized());
 	ANKI_ASSERT(isInitialized());
 
 
 	ANKI_CORE_LOGI("Loading config file %s", filename.cstr());
 	ANKI_CORE_LOGI("Loading config file %s", filename.cstr());
-	XmlDocument xml(&m_pool);
+	CoreXmlDocument xml;
 	ANKI_CHECK(xml.loadFile(filename));
 	ANKI_CHECK(xml.loadFile(filename));
 
 
 	XmlElement rootel;
 	XmlElement rootel;
@@ -170,7 +170,7 @@ Error ConfigSet::saveToFile(CString filename) const
 	File file;
 	File file;
 	ANKI_CHECK(file.open(filename, FileOpenFlag::kWrite));
 	ANKI_CHECK(file.open(filename, FileOpenFlag::kWrite));
 
 
-	ANKI_CHECK(file.writeTextf("%s\n<config>\n", XmlDocument::kXmlHeader.cstr()));
+	ANKI_CHECK(file.writeTextf("%s\n<config>\n", CoreXmlDocument::kXmlHeader.cstr()));
 
 
 #define ANKI_NUMERIC_UINT(name) \
 #define ANKI_NUMERIC_UINT(name) \
 	ANKI_CHECK(file.writeTextf("\t<!-- %s -->\n", m_##name.m_description.cstr())); \
 	ANKI_CHECK(file.writeTextf("\t<!-- %s -->\n", m_##name.m_description.cstr())); \

+ 15 - 16
AnKi/Core/ConfigSet.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -8,6 +8,7 @@
 #include <AnKi/Core/Common.h>
 #include <AnKi/Core/Common.h>
 #include <AnKi/Util/List.h>
 #include <AnKi/Util/List.h>
 #include <AnKi/Util/String.h>
 #include <AnKi/Util/String.h>
+#include <AnKi/Util/Singleton.h>
 #include <AnKi/Math/Functions.h>
 #include <AnKi/Math/Functions.h>
 
 
 namespace anki {
 namespace anki {
@@ -16,27 +17,16 @@ namespace anki {
 /// @{
 /// @{
 
 
 /// A storage of configuration variables.
 /// A storage of configuration variables.
-class ConfigSet
+class ConfigSet : public MakeSingleton<ConfigSet>
 {
 {
-public:
-	/// @note Need to call init() if using this constructor.
-	ConfigSet()
-	{
-	}
-
-	ConfigSet(AllocAlignedCallback allocCb, void* allocCbUserData)
-	{
-		init(allocCb, allocCbUserData);
-	}
+	template<typename>
+	friend class MakeSingleton;
 
 
+public:
 	ConfigSet(const ConfigSet& b) = delete; // Non-copyable
 	ConfigSet(const ConfigSet& b) = delete; // Non-copyable
 
 
-	~ConfigSet();
-
 	ConfigSet& operator=(const ConfigSet& b) = delete; // Non-copyable
 	ConfigSet& operator=(const ConfigSet& b) = delete; // Non-copyable
 
 
-	void init(AllocAlignedCallback allocCb, void* allocCbUserData);
-
 	Error loadFromFile(CString filename);
 	Error loadFromFile(CString filename);
 
 
 	Error saveToFile(CString filename) const;
 	Error saveToFile(CString filename) const;
@@ -144,6 +134,15 @@ private:
 #define ANKI_CONFIG_VAR_STRING(name, defaultValue, description) StringVar m_##name;
 #define ANKI_CONFIG_VAR_STRING(name, defaultValue, description) StringVar m_##name;
 #include <AnKi/Core/AllConfigVars.defs.h>
 #include <AnKi/Core/AllConfigVars.defs.h>
 
 
+	ConfigSet(AllocAlignedCallback allocCb, void* allocCbUserData)
+	{
+		init(allocCb, allocCbUserData);
+	}
+
+	~ConfigSet();
+
+	void init(AllocAlignedCallback allocCb, void* allocCbUserData);
+
 	Bool isInitialized() const
 	Bool isInitialized() const
 	{
 	{
 		return !m_vars.isEmpty();
 		return !m_vars.isEmpty();

+ 7 - 6
AnKi/Core/ConfigVars.defs.h

@@ -1,15 +1,13 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
 ANKI_CONFIG_VAR_GROUP(CORE)
 ANKI_CONFIG_VAR_GROUP(CORE)
 
 
-ANKI_CONFIG_VAR_PTR_SIZE(CoreUniformPerFrameMemorySize, 24_MB, 1_MB, 1_GB, "Uniform staging buffer size")
-ANKI_CONFIG_VAR_PTR_SIZE(CoreStoragePerFrameMemorySize, 24_MB, 1_MB, 1_GB, "Storage staging buffer size")
-ANKI_CONFIG_VAR_PTR_SIZE(CoreVertexPerFrameMemorySize, 12_MB, 1_MB, 1_GB, "Vertex staging buffer size")
-ANKI_CONFIG_VAR_PTR_SIZE(CoreTextureBufferPerFrameMemorySize, 1_MB, 1_MB, 1_GB, "Texture staging buffer size")
+ANKI_CONFIG_VAR_PTR_SIZE(CoreRebarGpuMemorySize, 24_MB, 1_MB, 1_GB, "ReBAR: always mapped GPU memory")
 ANKI_CONFIG_VAR_PTR_SIZE(CoreGlobalVertexMemorySize, 128_MB, 16_MB, 2_GB, "Global index and vertex buffer size")
 ANKI_CONFIG_VAR_PTR_SIZE(CoreGlobalVertexMemorySize, 128_MB, 16_MB, 2_GB, "Global index and vertex buffer size")
+ANKI_CONFIG_VAR_PTR_SIZE(CoreGpuSceneInitialSize, 64_MB, 16_MB, 2_GB, "Global memory for the GPU scene")
 
 
 ANKI_CONFIG_VAR_BOOL(CoreMaliHwCounters, false, "Enable Mali counters")
 ANKI_CONFIG_VAR_BOOL(CoreMaliHwCounters, false, "Enable Mali counters")
 
 
@@ -17,8 +15,11 @@ ANKI_CONFIG_VAR_U32(Width, 1920, 16, 16 * 1024, "Width")
 ANKI_CONFIG_VAR_U32(Height, 1080, 16, 16 * 1024, "Height")
 ANKI_CONFIG_VAR_U32(Height, 1080, 16, 16 * 1024, "Height")
 ANKI_CONFIG_VAR_U32(WindowFullscreen, 1, 0, 2, "0: windowed, 1: borderless fullscreen, 2: exclusive fullscreen")
 ANKI_CONFIG_VAR_U32(WindowFullscreen, 1, 0, 2, "0: windowed, 1: borderless fullscreen, 2: exclusive fullscreen")
 
 
-ANKI_CONFIG_VAR_U32(CoreTargetFps, 60u, 30u, kMaxU32, "Target FPS")
+ANKI_CONFIG_VAR_U32(CoreTargetFps, 60u, 1u, kMaxU32, "Target FPS")
 ANKI_CONFIG_VAR_U32(CoreJobThreadCount, max(2u, getCpuCoresCount() / 2u), 2u, 1024u, "Number of job thread")
 ANKI_CONFIG_VAR_U32(CoreJobThreadCount, max(2u, getCpuCoresCount() / 2u), 2u, 1024u, "Number of job thread")
 ANKI_CONFIG_VAR_U32(CoreDisplayStats, 0, 0, 2, "Display stats, 0: None, 1: Simple, 2: Detailed")
 ANKI_CONFIG_VAR_U32(CoreDisplayStats, 0, 0, 2, "Display stats, 0: None, 1: Simple, 2: Detailed")
 ANKI_CONFIG_VAR_BOOL(CoreClearCaches, false, "Clear all caches")
 ANKI_CONFIG_VAR_BOOL(CoreClearCaches, false, "Clear all caches")
 ANKI_CONFIG_VAR_BOOL(CoreVerboseLog, false, "Verbose logging")
 ANKI_CONFIG_VAR_BOOL(CoreVerboseLog, false, "Verbose logging")
+ANKI_CONFIG_VAR_BOOL(CoreBenchmarkMode, false, "Run in a benchmark mode. Fixed timestep, unlimited target FPS")
+ANKI_CONFIG_VAR_U32(CoreBenchmarkModeFrameCount, 60 * 60 * 2, 1, kMaxU32,
+					"How many frames the benchmark will run before it quits")

+ 22 - 43
AnKi/Core/CoreTracer.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -33,28 +33,17 @@ static void getSpreadsheetColumnName(U32 column, Array<char, 3>& arr)
 class CoreTracer::ThreadWorkItem : public IntrusiveListEnabled<ThreadWorkItem>
 class CoreTracer::ThreadWorkItem : public IntrusiveListEnabled<ThreadWorkItem>
 {
 {
 public:
 public:
-	DynamicArrayRaii<TracerEvent> m_events;
-	DynamicArrayRaii<TracerCounter> m_counters;
+	CoreDynamicArray<TracerEvent> m_events;
+	CoreDynamicArray<TracerCounter> m_counters;
 	ThreadId m_tid;
 	ThreadId m_tid;
 	U64 m_frame;
 	U64 m_frame;
-
-	ThreadWorkItem(HeapMemoryPool* pool)
-		: m_events(pool)
-		, m_counters(pool)
-	{
-	}
 };
 };
 
 
 class CoreTracer::PerFrameCounters : public IntrusiveListEnabled<PerFrameCounters>
 class CoreTracer::PerFrameCounters : public IntrusiveListEnabled<PerFrameCounters>
 {
 {
 public:
 public:
-	DynamicArrayRaii<TracerCounter> m_counters;
+	CoreDynamicArray<TracerCounter> m_counters;
 	U64 m_frame;
 	U64 m_frame;
-
-	PerFrameCounters(HeapMemoryPool* pool)
-		: m_counters(pool)
-	{
-	}
 };
 };
 
 
 CoreTracer::CoreTracer()
 CoreTracer::CoreTracer()
@@ -85,33 +74,24 @@ CoreTracer::~CoreTracer()
 	while(!m_frameCounters.isEmpty())
 	while(!m_frameCounters.isEmpty())
 	{
 	{
 		PerFrameCounters* frame = m_frameCounters.popBack();
 		PerFrameCounters* frame = m_frameCounters.popBack();
-		deleteInstance(*m_pool, frame);
+		deleteInstance(CoreMemoryPool::getSingleton(), frame);
 	}
 	}
 
 
 	while(!m_workItems.isEmpty())
 	while(!m_workItems.isEmpty())
 	{
 	{
 		ThreadWorkItem* item = m_workItems.popBack();
 		ThreadWorkItem* item = m_workItems.popBack();
-		deleteInstance(*m_pool, item);
+		deleteInstance(CoreMemoryPool::getSingleton(), item);
 	}
 	}
 
 
-	for(String& s : m_counterNames)
-	{
-		s.destroy(*m_pool);
-	}
-	m_counterNames.destroy(*m_pool);
-
 	// Destroy the tracer
 	// Destroy the tracer
-	TracerSingleton::destroy();
+	Tracer::freeSingleton();
 }
 }
 
 
-Error CoreTracer::init(HeapMemoryPool* pool, CString directory)
+Error CoreTracer::init(CString directory)
 {
 {
-	ANKI_ASSERT(pool);
-	m_pool = pool;
-
-	TracerSingleton::init(m_pool);
+	Tracer::allocateSingleton();
 	const Bool enableTracer = getenv("ANKI_CORE_TRACER_ENABLED") && getenv("ANKI_CORE_TRACER_ENABLED")[0] == '1';
 	const Bool enableTracer = getenv("ANKI_CORE_TRACER_ENABLED") && getenv("ANKI_CORE_TRACER_ENABLED")[0] == '1';
-	TracerSingleton::get().setEnabled(enableTracer);
+	Tracer::getSingleton().setEnabled(enableTracer);
 	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_thread.start(this, [](ThreadCallbackInfo& info) -> Error {
 	m_thread.start(this, [](ThreadCallbackInfo& info) -> Error {
@@ -119,15 +99,14 @@ Error CoreTracer::init(HeapMemoryPool* pool, CString directory)
 	});
 	});
 
 
 	std::tm tm = getLocalTime();
 	std::tm tm = getLocalTime();
-	StringRaii fname(m_pool);
+	CoreString fname;
 	fname.sprintf("%s/%d%02d%02d-%02d%02d_", directory.cstr(), tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
 	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);
 				  tm.tm_min);
 
 
-	ANKI_CHECK(m_traceJsonFile.open(StringRaii(m_pool).sprintf("%strace.json", fname.cstr()), FileOpenFlag::kWrite));
+	ANKI_CHECK(m_traceJsonFile.open(CoreString().sprintf("%strace.json", fname.cstr()), FileOpenFlag::kWrite));
 	ANKI_CHECK(m_traceJsonFile.writeText("[\n"));
 	ANKI_CHECK(m_traceJsonFile.writeText("[\n"));
 
 
-	ANKI_CHECK(
-		m_countersCsvFile.open(StringRaii(m_pool).sprintf("%scounters.csv", fname.cstr()), FileOpenFlag::kWrite));
+	ANKI_CHECK(m_countersCsvFile.open(CoreString().sprintf("%scounters.csv", fname.cstr()), FileOpenFlag::kWrite));
 
 
 	return Error::kNone;
 	return Error::kNone;
 }
 }
@@ -171,7 +150,7 @@ Error CoreTracer::threadWorker()
 				gatherCounters(*item);
 				gatherCounters(*item);
 			}
 			}
 
 
-			deleteInstance(*m_pool, item);
+			deleteInstance(CoreMemoryPool::getSingleton(), item);
 		}
 		}
 	}
 	}
 
 
@@ -214,7 +193,7 @@ void CoreTracer::gatherCounters(ThreadWorkItem& item)
 	});
 	});
 
 
 	// Merge same
 	// Merge same
-	DynamicArrayRaii<TracerCounter> mergedCounters(m_pool);
+	CoreDynamicArray<TracerCounter> mergedCounters;
 	for(U32 i = 0; i < item.m_counters.getSize(); ++i)
 	for(U32 i = 0; i < item.m_counters.getSize(); ++i)
 	{
 	{
 		if(mergedCounters.getSize() == 0 || mergedCounters.getBack().m_name != item.m_counters[i].m_name)
 		if(mergedCounters.getSize() == 0 || mergedCounters.getBack().m_name != item.m_counters[i].m_name)
@@ -237,7 +216,7 @@ void CoreTracer::gatherCounters(ThreadWorkItem& item)
 		const TracerCounter& counter = mergedCounters[i];
 		const TracerCounter& counter = mergedCounters[i];
 
 
 		Bool found = false;
 		Bool found = false;
-		for(const String& name : m_counterNames)
+		for(const CoreString& name : m_counterNames)
 		{
 		{
 			if(name == counter.m_name)
 			if(name == counter.m_name)
 			{
 			{
@@ -248,7 +227,7 @@ void CoreTracer::gatherCounters(ThreadWorkItem& item)
 
 
 		if(!found)
 		if(!found)
 		{
 		{
-			m_counterNames.emplaceBack(*m_pool, *m_pool, counter.m_name);
+			m_counterNames.emplaceBack(counter.m_name);
 			addedCounterName = true;
 			addedCounterName = true;
 		}
 		}
 	}
 	}
@@ -262,7 +241,7 @@ void CoreTracer::gatherCounters(ThreadWorkItem& item)
 	if(m_frameCounters.isEmpty() || m_frameCounters.getBack().m_frame != item.m_frame)
 	if(m_frameCounters.isEmpty() || m_frameCounters.getBack().m_frame != item.m_frame)
 	{
 	{
 		// Create new frame
 		// Create new frame
-		PerFrameCounters* newPerFrame = newInstance<PerFrameCounters>(*m_pool, m_pool);
+		PerFrameCounters* newPerFrame = newInstance<PerFrameCounters>(CoreMemoryPool::getSingleton());
 		newPerFrame->m_counters = std::move(mergedCounters);
 		newPerFrame->m_counters = std::move(mergedCounters);
 		newPerFrame->m_frame = item.m_frame;
 		newPerFrame->m_frame = item.m_frame;
 		m_frameCounters.pushBack(newPerFrame);
 		m_frameCounters.pushBack(newPerFrame);
@@ -305,24 +284,24 @@ void CoreTracer::flushFrame(U64 frame)
 	ctx.m_frame = frame;
 	ctx.m_frame = frame;
 	ctx.m_self = this;
 	ctx.m_self = this;
 
 
-	TracerSingleton::get().flush(
+	Tracer::getSingleton().flush(
 		[](void* ud, ThreadId tid, ConstWeakArray<TracerEvent> events, ConstWeakArray<TracerCounter> counters) {
 		[](void* ud, ThreadId tid, ConstWeakArray<TracerEvent> events, ConstWeakArray<TracerCounter> counters) {
 			Ctx& ctx = *static_cast<Ctx*>(ud);
 			Ctx& ctx = *static_cast<Ctx*>(ud);
 			CoreTracer& self = *ctx.m_self;
 			CoreTracer& self = *ctx.m_self;
 
 
-			ThreadWorkItem* item = newInstance<ThreadWorkItem>(*self.m_pool, self.m_pool);
+			ThreadWorkItem* item = newInstance<ThreadWorkItem>(CoreMemoryPool::getSingleton());
 			item->m_tid = tid;
 			item->m_tid = tid;
 			item->m_frame = ctx.m_frame;
 			item->m_frame = ctx.m_frame;
 
 
 			if(events.getSize() > 0)
 			if(events.getSize() > 0)
 			{
 			{
-				item->m_events.create(events.getSize());
+				item->m_events.resize(events.getSize());
 				memcpy(&item->m_events[0], &events[0], events.getSizeInBytes());
 				memcpy(&item->m_events[0], &events[0], events.getSizeInBytes());
 			}
 			}
 
 
 			if(counters.getSize() > 0)
 			if(counters.getSize() > 0)
 			{
 			{
-				item->m_counters.create(counters.getSize());
+				item->m_counters.resize(counters.getSize());
 				memcpy(&item->m_counters[0], &counters[0], counters.getSizeInBytes());
 				memcpy(&item->m_counters[0], &counters[0], counters.getSizeInBytes());
 			}
 			}
 
 

+ 11 - 10
AnKi/Core/CoreTracer.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -16,15 +16,14 @@ namespace anki {
 /// @{
 /// @{
 
 
 /// A system that sits on top of the tracer and processes the counters and events.
 /// A system that sits on top of the tracer and processes the counters and events.
-class CoreTracer
+class CoreTracer : public MakeSingleton<CoreTracer>
 {
 {
-public:
-	CoreTracer();
-
-	~CoreTracer();
+	template<typename>
+	friend class MakeSingleton;
 
 
+public:
 	/// @param directory The directory to store the trace and counters.
 	/// @param directory The directory to store the trace and counters.
-	Error init(HeapMemoryPool* pool, CString directory);
+	Error init(CString directory);
 
 
 	/// It will flush everything.
 	/// It will flush everything.
 	void flushFrame(U64 frame);
 	void flushFrame(U64 frame);
@@ -33,13 +32,11 @@ private:
 	class ThreadWorkItem;
 	class ThreadWorkItem;
 	class PerFrameCounters;
 	class PerFrameCounters;
 
 
-	HeapMemoryPool* m_pool = nullptr;
-
 	Thread m_thread;
 	Thread m_thread;
 	ConditionVariable m_cvar;
 	ConditionVariable m_cvar;
 	Mutex m_mtx;
 	Mutex m_mtx;
 
 
-	DynamicArray<String> m_counterNames;
+	CoreDynamicArray<CoreString> m_counterNames;
 	IntrusiveList<PerFrameCounters> m_frameCounters;
 	IntrusiveList<PerFrameCounters> m_frameCounters;
 
 
 	IntrusiveList<ThreadWorkItem> m_workItems; ///< Items for the thread to process.
 	IntrusiveList<ThreadWorkItem> m_workItems; ///< Items for the thread to process.
@@ -47,6 +44,10 @@ private:
 	File m_countersCsvFile;
 	File m_countersCsvFile;
 	Bool m_quit = false;
 	Bool m_quit = false;
 
 
+	CoreTracer();
+
+	~CoreTracer();
+
 	Error threadWorker();
 	Error threadWorker();
 
 
 	Error writeEvents(ThreadWorkItem& item);
 	Error writeEvents(ThreadWorkItem& item);

+ 11 - 15
AnKi/Core/DeveloperConsole.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -9,28 +9,24 @@ namespace anki {
 
 
 DeveloperConsole::~DeveloperConsole()
 DeveloperConsole::~DeveloperConsole()
 {
 {
-	LoggerSingleton::get().removeMessageHandler(this, loggerCallback);
+	Logger::getSingleton().removeMessageHandler(this, loggerCallback);
 
 
 	while(!m_logItems.isEmpty())
 	while(!m_logItems.isEmpty())
 	{
 	{
 		LogItem* item = &m_logItems.getFront();
 		LogItem* item = &m_logItems.getFront();
 		m_logItems.popFront();
 		m_logItems.popFront();
-		item->m_threadName.destroy(getMemoryPool());
-		item->m_msg.destroy(getMemoryPool());
-		deleteInstance(getMemoryPool(), item);
+		deleteInstance(UiMemoryPool::getSingleton(), item);
 	}
 	}
 }
 }
 
 
-Error DeveloperConsole::init(ScriptManager* scriptManager)
+Error DeveloperConsole::init()
 {
 {
 	zeroMemory(m_inputText);
 	zeroMemory(m_inputText);
 
 
-	ANKI_CHECK(m_manager->newInstance(m_font, "EngineAssets/UbuntuMonoRegular.ttf", Array<U32, 1>{16}));
+	ANKI_CHECK(UiManager::getSingleton().newInstance(m_font, "EngineAssets/UbuntuMonoRegular.ttf", Array<U32, 1>{16}));
 
 
 	// Add a new callback to the logger
 	// Add a new callback to the logger
-	LoggerSingleton::get().addMessageHandler(this, loggerCallback);
-
-	ANKI_CHECK(m_scriptEnv.init(scriptManager));
+	Logger::getSingleton().addMessageHandler(this, loggerCallback);
 
 
 	return Error::kNone;
 	return Error::kNone;
 }
 }
@@ -122,8 +118,8 @@ void DeveloperConsole::newLogItem(const LoggerMessageInfo& inf)
 		LogItem* first = &m_logItems.getFront();
 		LogItem* first = &m_logItems.getFront();
 		m_logItems.popFront();
 		m_logItems.popFront();
 
 
-		first->m_msg.destroy(getMemoryPool());
-		first->m_threadName.destroy(getMemoryPool());
+		first->m_msg.destroy();
+		first->m_threadName.destroy();
 
 
 		// Re-use the log item
 		// Re-use the log item
 		newLogItem = first;
 		newLogItem = first;
@@ -131,15 +127,15 @@ void DeveloperConsole::newLogItem(const LoggerMessageInfo& inf)
 	}
 	}
 	else
 	else
 	{
 	{
-		newLogItem = newInstance<LogItem>(getMemoryPool());
+		newLogItem = newInstance<LogItem>(UiMemoryPool::getSingleton());
 	}
 	}
 
 
 	// Create the new item
 	// Create the new item
 	newLogItem->m_file = inf.m_file;
 	newLogItem->m_file = inf.m_file;
 	newLogItem->m_func = inf.m_func;
 	newLogItem->m_func = inf.m_func;
 	newLogItem->m_subsystem = inf.m_subsystem;
 	newLogItem->m_subsystem = inf.m_subsystem;
-	newLogItem->m_threadName.create(getMemoryPool(), inf.m_threadName);
-	newLogItem->m_msg.create(getMemoryPool(), inf.m_msg);
+	newLogItem->m_threadName = inf.m_threadName;
+	newLogItem->m_msg = inf.m_msg;
 	newLogItem->m_line = inf.m_line;
 	newLogItem->m_line = inf.m_line;
 	newLogItem->m_type = inf.m_type;
 	newLogItem->m_type = inf.m_type;
 
 

+ 5 - 8
AnKi/Core/DeveloperConsole.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -19,14 +19,11 @@ namespace anki {
 class DeveloperConsole : public UiImmediateModeBuilder
 class DeveloperConsole : public UiImmediateModeBuilder
 {
 {
 public:
 public:
-	DeveloperConsole(UiManager* ui)
-		: UiImmediateModeBuilder(ui)
-	{
-	}
+	DeveloperConsole() = default;
 
 
 	~DeveloperConsole();
 	~DeveloperConsole();
 
 
-	Error init(ScriptManager* scriptManager);
+	Error init();
 
 
 	void build(CanvasPtr ctx) override;
 	void build(CanvasPtr ctx) override;
 
 
@@ -39,8 +36,8 @@ private:
 		const Char* m_file;
 		const Char* m_file;
 		const Char* m_func;
 		const Char* m_func;
 		const Char* m_subsystem;
 		const Char* m_subsystem;
-		String m_threadName;
-		String m_msg;
+		UiString m_threadName;
+		UiString m_msg;
 		I32 m_line;
 		I32 m_line;
 		LoggerMessageType m_type;
 		LoggerMessageType m_type;
 	};
 	};

+ 181 - 79
AnKi/Core/GpuMemoryPools.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -6,133 +6,235 @@
 #include <AnKi/Core/GpuMemoryPools.h>
 #include <AnKi/Core/GpuMemoryPools.h>
 #include <AnKi/Core/ConfigSet.h>
 #include <AnKi/Core/ConfigSet.h>
 #include <AnKi/Gr/GrManager.h>
 #include <AnKi/Gr/GrManager.h>
+#include <AnKi/Gr/CommandBuffer.h>
 #include <AnKi/Util/Tracer.h>
 #include <AnKi/Util/Tracer.h>
+#include <AnKi/Resource/ResourceManager.h>
 
 
 namespace anki {
 namespace anki {
 
 
-void UnifiedGeometryMemoryPool::init(HeapMemoryPool* pool, GrManager* gr, const ConfigSet& cfg)
+void UnifiedGeometryMemoryPool::init()
 {
 {
-	ANKI_ASSERT(pool && gr);
-
-	const PtrSize poolSize = cfg.getCoreGlobalVertexMemorySize();
+	const PtrSize poolSize = ConfigSet::getSingleton().getCoreGlobalVertexMemorySize();
 
 
 	const Array classes = {1_KB, 8_KB, 32_KB, 128_KB, 512_KB, 4_MB, 8_MB, 16_MB, poolSize};
 	const Array classes = {1_KB, 8_KB, 32_KB, 128_KB, 512_KB, 4_MB, 8_MB, 16_MB, poolSize};
 
 
-	BufferUsageBit buffUsage = BufferUsageBit::kVertex | BufferUsageBit::kIndex | BufferUsageBit::kTransferDestination;
+	BufferUsageBit buffUsage = BufferUsageBit::kVertex | BufferUsageBit::kIndex | BufferUsageBit::kTransferDestination
+							   | (BufferUsageBit::kAllTexture & BufferUsageBit::kAllRead);
 
 
-	if(gr->getDeviceCapabilities().m_rayTracingEnabled)
+	if(GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled)
 	{
 	{
 		buffUsage |= BufferUsageBit::kAccelerationStructureBuild;
 		buffUsage |= BufferUsageBit::kAccelerationStructureBuild;
 	}
 	}
 
 
-	m_alloc.init(gr, pool, buffUsage, classes, poolSize, "UnifiedGeometry", false);
+	m_pool.init(buffUsage, classes, poolSize, "UnifiedGeometry", false);
+
+	// Allocate something dummy to force creating the GPU buffer
+	SegregatedListsGpuMemoryPoolToken token;
+	allocate(16, 4, token);
+	deferredFree(token);
 }
 }
 
 
-StagingGpuMemoryPool::~StagingGpuMemoryPool()
+void GpuSceneMemoryPool::init()
 {
 {
-	m_gr->finish();
+	const PtrSize poolSize = ConfigSet::getSingleton().getCoreGpuSceneInitialSize();
 
 
-	for(auto& it : m_perFrameBuffers)
-	{
-		it.m_buff->unmap();
-		it.m_buff.reset(nullptr);
-	}
+	const Array classes = {32_B, 64_B, 128_B, 256_B, poolSize};
+
+	BufferUsageBit buffUsage = BufferUsageBit::kAllStorage | BufferUsageBit::kTransferDestination;
+
+	m_pool.init(buffUsage, classes, poolSize, "GpuScene", true);
+
+	// Allocate something dummy to force creating the GPU buffer
+	SegregatedListsGpuMemoryPoolToken token;
+	allocate(16, 4, token);
+	deferredFree(token);
 }
 }
 
 
-Error StagingGpuMemoryPool::init(GrManager* gr, const ConfigSet& cfg)
+RebarStagingGpuMemoryPool::~RebarStagingGpuMemoryPool()
 {
 {
-	m_gr = gr;
+	GrManager::getSingleton().finish();
 
 
-	m_perFrameBuffers[StagingGpuMemoryType::kUniform].m_size = cfg.getCoreUniformPerFrameMemorySize();
-	m_perFrameBuffers[StagingGpuMemoryType::kStorage].m_size = cfg.getCoreStoragePerFrameMemorySize();
-	m_perFrameBuffers[StagingGpuMemoryType::kVertex].m_size = cfg.getCoreVertexPerFrameMemorySize();
-	m_perFrameBuffers[StagingGpuMemoryType::kTexture].m_size = cfg.getCoreTextureBufferPerFrameMemorySize();
+	m_buffer->unmap();
+	m_buffer.reset(nullptr);
+}
 
 
-	initBuffer(StagingGpuMemoryType::kUniform, gr->getDeviceCapabilities().m_uniformBufferBindOffsetAlignment,
-			   gr->getDeviceCapabilities().m_uniformBufferMaxRange, BufferUsageBit::kAllUniform, *gr);
+void RebarStagingGpuMemoryPool::init()
+{
+	BufferInitInfo buffInit("ReBar");
+	buffInit.m_mapAccess = BufferMapAccessBit::kWrite;
+	buffInit.m_size = ConfigSet::getSingleton().getCoreRebarGpuMemorySize();
+	buffInit.m_usage = BufferUsageBit::kAllUniform | BufferUsageBit::kAllStorage | BufferUsageBit::kVertex
+					   | BufferUsageBit::kIndex | BufferUsageBit::kShaderBindingTable;
+	m_buffer = GrManager::getSingleton().newBuffer(buffInit);
 
 
-	initBuffer(StagingGpuMemoryType::kStorage,
-			   max(gr->getDeviceCapabilities().m_storageBufferBindOffsetAlignment,
-				   gr->getDeviceCapabilities().m_sbtRecordAlignment),
-			   gr->getDeviceCapabilities().m_storageBufferMaxRange,
-			   BufferUsageBit::kAllStorage | BufferUsageBit::kShaderBindingTable, *gr);
+	m_bufferSize = buffInit.m_size;
 
 
-	initBuffer(StagingGpuMemoryType::kVertex, 16, kMaxU32, BufferUsageBit::kVertex | BufferUsageBit::kIndex, *gr);
+	m_alignment = GrManager::getSingleton().getDeviceCapabilities().m_uniformBufferBindOffsetAlignment;
+	m_alignment =
+		max(m_alignment, GrManager::getSingleton().getDeviceCapabilities().m_storageBufferBindOffsetAlignment);
+	m_alignment = max(m_alignment, GrManager::getSingleton().getDeviceCapabilities().m_sbtRecordAlignment);
 
 
-	initBuffer(StagingGpuMemoryType::kTexture, gr->getDeviceCapabilities().m_textureBufferBindOffsetAlignment,
-			   gr->getDeviceCapabilities().m_textureBufferMaxRange, BufferUsageBit::kAllTexture, *gr);
+	m_mappedMem = static_cast<U8*>(m_buffer->map(0, kMaxPtrSize, BufferMapAccessBit::kWrite));
+}
 
 
-	return Error::kNone;
+void* RebarStagingGpuMemoryPool::allocateFrame(PtrSize size, RebarGpuMemoryToken& token)
+{
+	void* address = tryAllocateFrame(size, token);
+	if(address == nullptr) [[unlikely]]
+	{
+		ANKI_CORE_LOGF("Out of ReBAR GPU memory");
+	}
+
+	return address;
 }
 }
 
 
-void StagingGpuMemoryPool::initBuffer(StagingGpuMemoryType type, U32 alignment, PtrSize maxAllocSize,
-									  BufferUsageBit usage, GrManager& gr)
+void* RebarStagingGpuMemoryPool::tryAllocateFrame(PtrSize origSize, RebarGpuMemoryToken& token)
 {
 {
-	PerFrameBuffer& perframe = m_perFrameBuffers[type];
+	const PtrSize size = getAlignedRoundUp(m_alignment, origSize);
+
+	// Try in a loop because we may end up with an allocation its offset crosses the buffer's end
+	PtrSize offset;
+	Bool done = false;
+	do
+	{
+		offset = m_offset.fetchAdd(size) % m_bufferSize;
+		const PtrSize end = (offset + origSize) % (m_bufferSize + 1);
+
+		done = offset < end;
+	} while(!done);
 
 
-	perframe.m_buff = gr.newBuffer(BufferInitInfo(perframe.m_size, usage, BufferMapAccessBit::kWrite, "Staging"));
-	perframe.m_alloc.init(perframe.m_size, alignment, maxAllocSize);
-	perframe.m_mappedMem = static_cast<U8*>(perframe.m_buff->map(0, perframe.m_size, BufferMapAccessBit::kWrite));
+	void* address = m_mappedMem + offset;
+	token.m_offset = offset;
+	token.m_range = origSize;
+
+	return address;
 }
 }
 
 
-void* StagingGpuMemoryPool::allocateFrame(PtrSize size, StagingGpuMemoryType usage, StagingGpuMemoryToken& token)
+PtrSize RebarStagingGpuMemoryPool::endFrame()
 {
 {
-	PerFrameBuffer& buff = m_perFrameBuffers[usage];
-	const Error err = buff.m_alloc.allocate(size, token.m_offset);
-	if(err)
+	const PtrSize crntOffset = m_offset.getNonAtomically();
+
+	const PtrSize usedMemory = crntOffset - m_previousFrameEndOffset;
+	m_previousFrameEndOffset = crntOffset;
+
+	if(usedMemory >= PtrSize(0.8 * F64(m_bufferSize / kMaxFramesInFlight)))
 	{
 	{
-		ANKI_CORE_LOGF("Out of staging GPU memory. Usage: %u", U32(usage));
+		ANKI_CORE_LOGW("Frame used more that 80%% of its safe limit of ReBAR memory");
 	}
 	}
 
 
-	token.m_buffer = buff.m_buff;
-	token.m_range = size;
-	token.m_type = usage;
+	ANKI_TRACE_INC_COUNTER(ReBarUsedMemory, usedMemory);
+	return usedMemory;
+}
+
+/// It packs the source and destination offsets as well as the size of the patch itself.
+class GpuSceneMicroPatcher::PatchHeader
+{
+public:
+	U32 m_dwordCountAndSrcDwordOffsetPack;
+	U32 m_dstDwordOffset;
+};
+
+GpuSceneMicroPatcher::GpuSceneMicroPatcher()
+{
+}
+
+GpuSceneMicroPatcher::~GpuSceneMicroPatcher()
+{
+	static_assert(sizeof(PatchHeader) == 8);
+}
+
+Error GpuSceneMicroPatcher::init()
+{
+	ANKI_CHECK(ResourceManager::getSingleton().loadResource("ShaderBinaries/GpuSceneMicroPatching.ankiprogbin",
+															m_copyProgram));
+	const ShaderProgramResourceVariant* variant;
+	m_copyProgram->getOrCreateVariant(variant);
+	m_grProgram = variant->getProgram();
 
 
-	return buff.m_mappedMem + token.m_offset;
+	return Error::kNone;
 }
 }
 
 
-void* StagingGpuMemoryPool::tryAllocateFrame(PtrSize size, StagingGpuMemoryType usage, StagingGpuMemoryToken& token)
+void GpuSceneMicroPatcher::newCopy(StackMemoryPool& frameCpuPool, PtrSize gpuSceneDestOffset, PtrSize dataSize,
+								   const void* data)
 {
 {
-	PerFrameBuffer& buff = m_perFrameBuffers[usage];
-	const Error err = buff.m_alloc.allocate(size, token.m_offset);
-	if(!err)
+	ANKI_ASSERT(dataSize > 0 && (dataSize % 4) == 0);
+	ANKI_ASSERT((ptrToNumber(data) % 4) == 0);
+	ANKI_ASSERT((gpuSceneDestOffset % 4) == 0 && gpuSceneDestOffset / 4 < kMaxU32);
+
+	const U32 dataDwords = U32(dataSize / 4);
+	U32 gpuSceneDestDwordOffset = U32(gpuSceneDestOffset / 4);
+
+	const U32* patchIt = static_cast<const U32*>(data);
+	const U32* const patchEnd = patchIt + dataDwords;
+
+	// Break the data into multiple copies
+	LockGuard lock(m_mtx);
+
+	if(m_crntFramePatchHeaders.getSize() == 0)
 	{
 	{
-		token.m_buffer = buff.m_buff;
-		token.m_range = size;
-		token.m_type = usage;
-		return buff.m_mappedMem + token.m_offset;
+		m_crntFramePatchHeaders = DynamicArray<PatchHeader, MemoryPoolPtrWrapper<StackMemoryPool>>(&frameCpuPool);
+		m_crntFramePatchData = DynamicArray<U32, MemoryPoolPtrWrapper<StackMemoryPool>>(&frameCpuPool);
 	}
 	}
-	else
+
+	while(patchIt < patchEnd)
 	{
 	{
-		token = {};
-		return nullptr;
+		const U32 patchDwords = min(kDwordsPerPatch, U32(patchEnd - patchIt));
+
+		PatchHeader& header = *m_crntFramePatchHeaders.emplaceBack();
+		ANKI_ASSERT(((patchDwords - 1) & 0b111111) == (patchDwords - 1));
+		header.m_dwordCountAndSrcDwordOffsetPack = patchDwords - 1;
+		header.m_dwordCountAndSrcDwordOffsetPack <<= 26;
+		ANKI_ASSERT((m_crntFramePatchData.getSize() & 0x3FFFFFF) == m_crntFramePatchData.getSize());
+		header.m_dwordCountAndSrcDwordOffsetPack |= m_crntFramePatchData.getSize();
+		header.m_dstDwordOffset = gpuSceneDestDwordOffset;
+
+		const U32 srcOffset = m_crntFramePatchData.getSize();
+		m_crntFramePatchData.resize(srcOffset + patchDwords);
+		memcpy(&m_crntFramePatchData[srcOffset], patchIt, patchDwords * 4);
+
+		patchIt += patchDwords;
+		gpuSceneDestDwordOffset += patchDwords;
 	}
 	}
 }
 }
 
 
-void StagingGpuMemoryPool::endFrame()
+void GpuSceneMicroPatcher::patchGpuScene(CommandBuffer& cmdb)
 {
 {
-	for(StagingGpuMemoryType usage : EnumIterable<StagingGpuMemoryType>())
+	if(m_crntFramePatchHeaders.getSize() == 0)
 	{
 	{
-		PerFrameBuffer& buff = m_perFrameBuffers[usage];
-
-		if(buff.m_mappedMem)
-		{
-			// Increase the counters
-			switch(usage)
-			{
-			case StagingGpuMemoryType::kUniform:
-				ANKI_TRACE_INC_COUNTER(STAGING_UNIFORMS_SIZE, buff.m_alloc.getUnallocatedMemorySize());
-				break;
-			case StagingGpuMemoryType::kStorage:
-				ANKI_TRACE_INC_COUNTER(STAGING_STORAGE_SIZE, buff.m_alloc.getUnallocatedMemorySize());
-				break;
-			default:
-				break;
-			}
-
-			buff.m_alloc.endFrame();
-		}
+		return;
 	}
 	}
+
+	ANKI_ASSERT(m_crntFramePatchData.getSize() > 0);
+
+	ANKI_TRACE_INC_COUNTER(GpuSceneMicroPatches, m_crntFramePatchHeaders.getSize());
+	ANKI_TRACE_INC_COUNTER(GpuSceneMicroPatchUploadData, m_crntFramePatchData.getSizeInBytes());
+
+	RebarGpuMemoryToken headersToken;
+	void* mapped =
+		RebarStagingGpuMemoryPool::getSingleton().allocateFrame(m_crntFramePatchHeaders.getSizeInBytes(), headersToken);
+	memcpy(mapped, &m_crntFramePatchHeaders[0], m_crntFramePatchHeaders.getSizeInBytes());
+
+	RebarGpuMemoryToken dataToken;
+	mapped = RebarStagingGpuMemoryPool::getSingleton().allocateFrame(m_crntFramePatchData.getSizeInBytes(), dataToken);
+	memcpy(mapped, &m_crntFramePatchData[0], m_crntFramePatchData.getSizeInBytes());
+
+	cmdb.bindStorageBuffer(0, 0, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), headersToken.m_offset,
+						   headersToken.m_range);
+	cmdb.bindStorageBuffer(0, 1, RebarStagingGpuMemoryPool::getSingleton().getBuffer(), dataToken.m_offset,
+						   dataToken.m_range);
+	cmdb.bindStorageBuffer(0, 2, GpuSceneMemoryPool::getSingleton().getBuffer(), 0, kMaxPtrSize);
+
+	cmdb.bindShaderProgram(m_grProgram);
+
+	const U32 workgroupCountX = m_crntFramePatchHeaders.getSize();
+	cmdb.dispatchCompute(workgroupCountX, 1, 1);
+
+	// Cleanup to prepare for the new frame
+	U32* data;
+	U32 size, storage;
+	m_crntFramePatchData.moveAndReset(data, size, storage);
+	PatchHeader* datah;
+	m_crntFramePatchHeaders.moveAndReset(datah, size, storage);
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 139 - 54
AnKi/Core/GpuMemoryPools.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -7,86 +7,121 @@
 
 
 #include <AnKi/Core/Common.h>
 #include <AnKi/Core/Common.h>
 #include <AnKi/Gr/Buffer.h>
 #include <AnKi/Gr/Buffer.h>
-#include <AnKi/Gr/Utils/FrameGpuAllocator.h>
-#include <AnKi/Gr/Utils/SegregatedListsGpuAllocator.h>
+#include <AnKi/Gr/Utils/StackGpuMemoryPool.h>
+#include <AnKi/Gr/Utils/SegregatedListsGpuMemoryPool.h>
+#include <AnKi/Resource/ShaderProgramResource.h>
 
 
 namespace anki {
 namespace anki {
 
 
-// Forward
-class ConfigSet;
-
 /// @addtogroup core
 /// @addtogroup core
 /// @{
 /// @{
 
 
 /// Manages vertex and index memory for the whole application.
 /// Manages vertex and index memory for the whole application.
-class UnifiedGeometryMemoryPool
+class UnifiedGeometryMemoryPool : public MakeSingleton<UnifiedGeometryMemoryPool>
 {
 {
-public:
-	UnifiedGeometryMemoryPool() = default;
+	template<typename>
+	friend class MakeSingleton;
 
 
+public:
 	UnifiedGeometryMemoryPool(const UnifiedGeometryMemoryPool&) = delete; // Non-copyable
 	UnifiedGeometryMemoryPool(const UnifiedGeometryMemoryPool&) = delete; // Non-copyable
 
 
 	UnifiedGeometryMemoryPool& operator=(const UnifiedGeometryMemoryPool&) = delete; // Non-copyable
 	UnifiedGeometryMemoryPool& operator=(const UnifiedGeometryMemoryPool&) = delete; // Non-copyable
 
 
-	void init(HeapMemoryPool* pool, GrManager* gr, const ConfigSet& cfg);
+	void init();
 
 
-	void allocate(PtrSize size, U32 alignment, SegregatedListsGpuAllocatorToken& token)
+	void allocate(PtrSize size, U32 alignment, SegregatedListsGpuMemoryPoolToken& token)
 	{
 	{
-		m_alloc.allocate(size, alignment, token);
+		m_pool.allocate(size, alignment, token);
 	}
 	}
 
 
-	void free(const SegregatedListsGpuAllocatorToken& token)
+	void deferredFree(SegregatedListsGpuMemoryPoolToken& token)
 	{
 	{
-		m_alloc.free(token);
+		m_pool.deferredFree(token);
 	}
 	}
 
 
 	void endFrame()
 	void endFrame()
 	{
 	{
-		m_alloc.endFrame();
+		m_pool.endFrame();
 	}
 	}
 
 
 	const BufferPtr& getBuffer() const
 	const BufferPtr& getBuffer() const
 	{
 	{
-		return m_alloc.getGpuBuffer();
+		return m_pool.getGpuBuffer();
 	}
 	}
 
 
 	void getStats(F32& externalFragmentation, PtrSize& userAllocatedSize, PtrSize& totalSize) const
 	void getStats(F32& externalFragmentation, PtrSize& userAllocatedSize, PtrSize& totalSize) const
 	{
 	{
-		m_alloc.getStats(externalFragmentation, userAllocatedSize, totalSize);
+		m_pool.getStats(externalFragmentation, userAllocatedSize, totalSize);
 	}
 	}
 
 
 private:
 private:
-	SegregatedListsGpuAllocator m_alloc;
+	SegregatedListsGpuMemoryPool m_pool;
+
+	UnifiedGeometryMemoryPool() = default;
+
+	~UnifiedGeometryMemoryPool() = default;
 };
 };
 
 
-enum class StagingGpuMemoryType : U8
+/// Memory pool for the GPU scene.
+class GpuSceneMemoryPool : public MakeSingleton<GpuSceneMemoryPool>
 {
 {
-	kUniform,
-	kStorage,
-	kVertex,
-	kTexture,
+	template<typename>
+	friend class MakeSingleton;
+
+public:
+	GpuSceneMemoryPool(const GpuSceneMemoryPool&) = delete; // Non-copyable
+
+	GpuSceneMemoryPool& operator=(const GpuSceneMemoryPool&) = delete; // Non-copyable
+
+	void init();
+
+	void allocate(PtrSize size, U32 alignment, SegregatedListsGpuMemoryPoolToken& token)
+	{
+		m_pool.allocate(size, alignment, token);
+	}
+
+	void deferredFree(SegregatedListsGpuMemoryPoolToken& token)
+	{
+		m_pool.deferredFree(token);
+	}
+
+	void endFrame()
+	{
+		m_pool.endFrame();
+	}
 
 
-	kCount,
-	kFirst = 0,
+	const BufferPtr& getBuffer() const
+	{
+		return m_pool.getGpuBuffer();
+	}
+
+	void getStats(F32& externalFragmentation, PtrSize& userAllocatedSize, PtrSize& totalSize) const
+	{
+		m_pool.getStats(externalFragmentation, userAllocatedSize, totalSize);
+	}
+
+private:
+	SegregatedListsGpuMemoryPool m_pool;
+
+	GpuSceneMemoryPool() = default;
+
+	~GpuSceneMemoryPool() = default;
 };
 };
-ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(StagingGpuMemoryType)
 
 
 /// Token that gets returned when requesting for memory to write to a resource.
 /// Token that gets returned when requesting for memory to write to a resource.
-class StagingGpuMemoryToken
+class RebarGpuMemoryToken
 {
 {
 public:
 public:
-	BufferPtr m_buffer;
 	PtrSize m_offset = 0;
 	PtrSize m_offset = 0;
 	PtrSize m_range = 0;
 	PtrSize m_range = 0;
-	StagingGpuMemoryType m_type = StagingGpuMemoryType::kCount;
 
 
-	StagingGpuMemoryToken() = default;
+	RebarGpuMemoryToken() = default;
 
 
-	~StagingGpuMemoryToken() = default;
+	~RebarGpuMemoryToken() = default;
 
 
-	Bool operator==(const StagingGpuMemoryToken& b) const
+	Bool operator==(const RebarGpuMemoryToken& b) const
 	{
 	{
-		return m_buffer == b.m_buffer && m_offset == b.m_offset && m_range == b.m_range && m_type == b.m_type;
+		return m_offset == b.m_offset && m_range == b.m_range;
 	}
 	}
 
 
 	void markUnused()
 	void markUnused()
@@ -101,44 +136,94 @@ public:
 };
 };
 
 
 /// Manages staging GPU memory.
 /// Manages staging GPU memory.
-class StagingGpuMemoryPool
+class RebarStagingGpuMemoryPool : public MakeSingleton<RebarStagingGpuMemoryPool>
 {
 {
-public:
-	StagingGpuMemoryPool() = default;
+	template<typename>
+	friend class MakeSingleton;
 
 
-	StagingGpuMemoryPool(const StagingGpuMemoryPool&) = delete; // Non-copyable
+public:
+	RebarStagingGpuMemoryPool(const RebarStagingGpuMemoryPool&) = delete; // Non-copyable
 
 
-	~StagingGpuMemoryPool();
+	~RebarStagingGpuMemoryPool();
 
 
-	StagingGpuMemoryPool& operator=(const StagingGpuMemoryPool&) = delete; // Non-copyable
+	RebarStagingGpuMemoryPool& operator=(const RebarStagingGpuMemoryPool&) = delete; // Non-copyable
 
 
-	Error init(GrManager* gr, const ConfigSet& cfg);
+	void init();
 
 
-	void endFrame();
+	PtrSize endFrame();
 
 
 	/// Allocate staging memory for various operations. The memory will be reclaimed at the begining of the
 	/// Allocate staging memory for various operations. The memory will be reclaimed at the begining of the
 	/// N-(kMaxFramesInFlight-1) frame.
 	/// N-(kMaxFramesInFlight-1) frame.
-	void* allocateFrame(PtrSize size, StagingGpuMemoryType usage, StagingGpuMemoryToken& token);
+	void* allocateFrame(PtrSize size, RebarGpuMemoryToken& token);
 
 
 	/// Allocate staging memory for various operations. The memory will be reclaimed at the begining of the
 	/// Allocate staging memory for various operations. The memory will be reclaimed at the begining of the
 	/// N-(kMaxFramesInFlight-1) frame.
 	/// N-(kMaxFramesInFlight-1) frame.
-	void* tryAllocateFrame(PtrSize size, StagingGpuMemoryType usage, StagingGpuMemoryToken& token);
+	void* tryAllocateFrame(PtrSize size, RebarGpuMemoryToken& token);
+
+	ANKI_PURE const BufferPtr& getBuffer() const
+	{
+		return m_buffer;
+	}
+
+	U8* getBufferMappedAddress()
+	{
+		return m_mappedMem;
+	}
 
 
 private:
 private:
-	class PerFrameBuffer
+	BufferPtr m_buffer;
+	U8* m_mappedMem = nullptr; ///< Cache it.
+	PtrSize m_bufferSize = 0; ///< Cache it.
+	Atomic<PtrSize> m_offset = {0};
+	PtrSize m_previousFrameEndOffset = 0;
+	U32 m_alignment = 0;
+
+	RebarStagingGpuMemoryPool() = default;
+};
+
+/// Creates the copy jobs that will patch the GPU Scene.
+class GpuSceneMicroPatcher : public MakeSingleton<GpuSceneMicroPatcher>
+{
+	template<typename>
+	friend class MakeSingleton;
+
+public:
+	GpuSceneMicroPatcher(const GpuSceneMicroPatcher&) = delete;
+
+	GpuSceneMicroPatcher& operator=(const GpuSceneMicroPatcher&) = delete;
+
+	Error init();
+
+	/// Copy data for the GPU scene to a staging buffer.
+	/// @note It's thread-safe.
+	void newCopy(StackMemoryPool& frameCpuPool, PtrSize gpuSceneDestOffset, PtrSize dataSize, const void* data);
+
+	/// Check if there is a need to call patchGpuScene or if no copies are needed.
+	/// @note Not thread-safe. Nothing else should be happening before calling it.
+	Bool patchingIsNeeded() const
 	{
 	{
-	public:
-		PtrSize m_size = 0;
-		BufferPtr m_buff;
-		U8* m_mappedMem = nullptr; ///< Cache it
-		FrameGpuAllocator m_alloc;
-	};
+		return m_crntFramePatchHeaders.getSize() > 0;
+	}
+
+	/// Copy the data to the GPU scene buffer.
+	/// @note Not thread-safe. Nothing else should be happening before calling it.
+	void patchGpuScene(CommandBuffer& cmdb);
+
+private:
+	static constexpr U32 kDwordsPerPatch = 64;
+
+	class PatchHeader;
+
+	DynamicArray<PatchHeader, MemoryPoolPtrWrapper<StackMemoryPool>> m_crntFramePatchHeaders;
+	DynamicArray<U32, MemoryPoolPtrWrapper<StackMemoryPool>> m_crntFramePatchData;
+	Mutex m_mtx;
+
+	ShaderProgramResourcePtr m_copyProgram;
+	ShaderProgramPtr m_grProgram;
 
 
-	GrManager* m_gr = nullptr;
-	Array<PerFrameBuffer, U(StagingGpuMemoryType::kCount)> m_perFrameBuffers;
+	GpuSceneMicroPatcher();
 
 
-	void initBuffer(StagingGpuMemoryType type, U32 alignment, PtrSize maxAllocSize, BufferUsageBit usage,
-					GrManager& gr);
+	~GpuSceneMicroPatcher();
 };
 };
 /// @}
 /// @}
 
 

+ 8 - 8
AnKi/Core/MaliHwCounters.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -13,14 +13,14 @@
 
 
 namespace anki {
 namespace anki {
 
 
-MaliHwCounters::MaliHwCounters(BaseMemoryPool* pool)
-	: m_pool(pool)
+MaliHwCounters::MaliHwCounters()
 {
 {
-	ANKI_ASSERT(pool);
 #if ANKI_HWCPIPE_ENABLE
 #if ANKI_HWCPIPE_ENABLE
-	hwcpipe::HWCPipe* hwc = newInstance<hwcpipe::HWCPipe>(*m_pool);
-	hwc->set_enabled_gpu_counters({hwcpipe::GpuCounter::GpuCycles, hwcpipe::GpuCounter::ExternalMemoryWriteBytes,
-								   hwcpipe::GpuCounter::ExternalMemoryReadBytes});
+	const hwcpipe::CpuCounterSet cpuCounters;
+	const hwcpipe::GpuCounterSet gpuCounters = {hwcpipe::GpuCounter::GpuCycles,
+												hwcpipe::GpuCounter::ExternalMemoryWriteBytes,
+												hwcpipe::GpuCounter::ExternalMemoryReadBytes};
+	hwcpipe::HWCPipe* hwc = newInstance<hwcpipe::HWCPipe>(CoreMemoryPool::getSingleton(), cpuCounters, gpuCounters);
 
 
 	hwc->run();
 	hwc->run();
 
 
@@ -35,7 +35,7 @@ MaliHwCounters::~MaliHwCounters()
 #if ANKI_HWCPIPE_ENABLE
 #if ANKI_HWCPIPE_ENABLE
 	hwcpipe::HWCPipe* hwc = static_cast<hwcpipe::HWCPipe*>(m_impl);
 	hwcpipe::HWCPipe* hwc = static_cast<hwcpipe::HWCPipe*>(m_impl);
 	hwc->stop();
 	hwc->stop();
-	deleteInstance(*m_pool, hwc);
+	deleteInstance(CoreMemoryPool::getSingleton(), hwc);
 	m_impl = nullptr;
 	m_impl = nullptr;
 #endif
 #endif
 }
 }

+ 9 - 7
AnKi/Core/MaliHwCounters.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -24,22 +24,24 @@ public:
 };
 };
 
 
 /// Sample HW counters for Mali GPUs.
 /// Sample HW counters for Mali GPUs.
-class MaliHwCounters
+class MaliHwCounters : public MakeSingleton<MaliHwCounters>
 {
 {
-public:
-	MaliHwCounters(BaseMemoryPool* pool);
+	template<typename>
+	friend class MakeSingleton;
 
 
+public:
 	MaliHwCounters(const MaliHwCounters&) = delete; // Non-copyable
 	MaliHwCounters(const MaliHwCounters&) = delete; // Non-copyable
 
 
-	~MaliHwCounters();
-
 	MaliHwCounters& operator=(const MaliHwCounters&) = delete; // Non-copyable
 	MaliHwCounters& operator=(const MaliHwCounters&) = delete; // Non-copyable
 
 
 	void sample(MaliHwCountersOut& out);
 	void sample(MaliHwCountersOut& out);
 
 
 private:
 private:
-	BaseMemoryPool* m_pool = nullptr;
 	void* m_impl = nullptr;
 	void* m_impl = nullptr;
+
+	MaliHwCounters();
+
+	~MaliHwCounters();
 };
 };
 /// @}
 /// @}
 
 

+ 0 - 76
AnKi/Core/NativeWindow.h

@@ -1,76 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Core/Common.h>
-#include <AnKi/Util/StdTypes.h>
-#include <AnKi/Util/Array.h>
-#include <AnKi/Util/String.h>
-
-namespace anki {
-
-/// Window initializer
-class NativeWindowInitInfo
-{
-public:
-	AllocAlignedCallback m_allocCallback = nullptr;
-	void* m_allocCallbackUserData = nullptr;
-
-	U32 m_width = 1920;
-	U32 m_height = 1080;
-	Array<U32, 4> m_rgbaBits = {8, 8, 8, 0};
-	U32 m_depthBits = 0;
-	U32 m_stencilBits = 0;
-	U32 m_samplesCount = 0;
-	static constexpr Bool m_doubleBuffer = true;
-	/// Create a fullscreen window with the desktop's resolution
-	Bool m_fullscreenDesktopRez = false;
-	Bool m_exclusiveFullscreen = false;
-
-	CString m_title = "AnKi";
-};
-
-/// Native window.
-class NativeWindow
-{
-public:
-	static Error newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow);
-
-	static void deleteInstance(NativeWindow* nativeWindow);
-
-	U32 getWidth() const
-	{
-		return m_width;
-	}
-
-	U32 getHeight() const
-	{
-		return m_height;
-	}
-
-	F32 getAspectRatio() const
-	{
-		return F32(m_width) / F32(m_height);
-	}
-
-	void setWindowTitle(CString title);
-
-protected:
-	U32 m_width = 0;
-	U32 m_height = 0;
-
-	HeapMemoryPool m_pool;
-
-	NativeWindow()
-	{
-	}
-
-	~NativeWindow()
-	{
-	}
-};
-
-} // end namespace anki

+ 0 - 104
AnKi/Core/NativeWindowAndroid.cpp

@@ -1,104 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Core/NativeWindowAndroid.h>
-
-namespace anki {
-
-Error NativeWindow::newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow)
-{
-	NativeWindowAndroid* andwin = static_cast<NativeWindowAndroid*>(initInfo.m_allocCallback(
-		initInfo.m_allocCallbackUserData, nullptr, sizeof(NativeWindowAndroid), alignof(NativeWindowAndroid)));
-	callConstructor(*andwin);
-
-	const Error err = andwin->init(initInfo);
-	if(err)
-	{
-		callDestructor(*andwin);
-		initInfo.m_allocCallback(initInfo.m_allocCallbackUserData, andwin, 0, 0);
-		nativeWindow = nullptr;
-		return err;
-	}
-	else
-	{
-		nativeWindow = andwin;
-		return Error::kNone;
-	}
-}
-
-void NativeWindow::deleteInstance(NativeWindow* window)
-{
-	if(window)
-	{
-		NativeWindowAndroid* self = static_cast<NativeWindowAndroid*>(window);
-		AllocAlignedCallback callback = self->m_pool.getAllocationCallback();
-		void* userData = self->m_pool.getAllocationCallbackUserData();
-		callDestructor(*self);
-		callback(userData, self, 0, 0);
-	}
-}
-
-void NativeWindow::setWindowTitle([[maybe_unused]] CString title)
-{
-	// Nothing
-}
-
-NativeWindowAndroid::~NativeWindowAndroid()
-{
-	ANKI_CORE_LOGI("Destroying Android window");
-	ANativeActivity_finish(g_androidApp->activity);
-
-	// Loop until destroyRequested is set
-	while(!g_androidApp->destroyRequested)
-	{
-		int ident;
-		int events;
-		android_poll_source* source;
-
-		while((ident = ALooper_pollAll(0, nullptr, &events, reinterpret_cast<void**>(&source))) >= 0)
-		{
-			if(source != nullptr)
-			{
-				source->process(g_androidApp, source);
-			}
-		}
-	}
-
-	m_nativeWindow = nullptr;
-}
-
-Error NativeWindowAndroid::init([[maybe_unused]] const NativeWindowInitInfo& init)
-{
-	ANKI_CORE_LOGI("Initializing Android window");
-
-	m_pool.init(init.m_allocCallback, init.m_allocCallbackUserData);
-
-	// Loop until the window is ready
-	while(g_androidApp->window == nullptr)
-	{
-		int ident;
-		int events;
-		android_poll_source* source;
-
-		const int timeoutMs = 5;
-		while((ident = ALooper_pollAll(timeoutMs, nullptr, &events, reinterpret_cast<void**>(&source))) >= 0)
-		{
-			if(source != nullptr)
-			{
-				source->process(g_androidApp, source);
-			}
-		}
-	}
-
-	m_nativeWindow = g_androidApp->window;
-
-	// Set some stuff
-	m_width = ANativeWindow_getWidth(g_androidApp->window);
-	m_height = ANativeWindow_getHeight(g_androidApp->window);
-
-	return Error::kNone;
-}
-
-} // end namespace anki

+ 0 - 24
AnKi/Core/NativeWindowAndroid.h

@@ -1,24 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Core/NativeWindow.h>
-#include <android_native_app_glue.h>
-
-namespace anki {
-
-/// Native window implementation for Android
-class NativeWindowAndroid : public NativeWindow
-{
-public:
-	ANativeWindow* m_nativeWindow = nullptr;
-
-	~NativeWindowAndroid();
-
-	Error init(const NativeWindowInitInfo& init);
-};
-
-} // end namespace anki

+ 0 - 41
AnKi/Core/NativeWindowHeadless.cpp

@@ -1,41 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Core/NativeWindowHeadless.h>
-
-namespace anki {
-
-Error NativeWindow::newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow)
-{
-	NativeWindowHeadless* hwin = static_cast<NativeWindowHeadless*>(initInfo.m_allocCallback(
-		initInfo.m_allocCallbackUserData, nullptr, sizeof(NativeWindowHeadless), alignof(NativeWindowHeadless)));
-	callConstructor(*hwin);
-
-	hwin->m_pool.init(initInfo.m_allocCallback, initInfo.m_allocCallbackUserData);
-	hwin->m_width = initInfo.m_width;
-	hwin->m_height = initInfo.m_height;
-
-	nativeWindow = hwin;
-	return Error::kNone;
-}
-
-void NativeWindow::deleteInstance(NativeWindow* window)
-{
-	if(window)
-	{
-		NativeWindowHeadless* self = static_cast<NativeWindowHeadless*>(window);
-		AllocAlignedCallback callback = self->m_pool.getAllocationCallback();
-		void* userData = self->m_pool.getAllocationCallbackUserData();
-		callDestructor(*self);
-		callback(userData, self, 0, 0);
-	}
-}
-
-void NativeWindow::setWindowTitle([[maybe_unused]] CString title)
-{
-	// Nothing
-}
-
-} // end namespace anki

+ 0 - 18
AnKi/Core/NativeWindowHeadless.h

@@ -1,18 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Core/NativeWindow.h>
-
-namespace anki {
-
-/// Native window implementation headless surface.
-class NativeWindowHeadless : public NativeWindow
-{
-public:
-};
-
-} // end namespace anki

+ 0 - 149
AnKi/Core/NativeWindowSdl.cpp

@@ -1,149 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#include <AnKi/Core/NativeWindowSdl.h>
-#include <AnKi/Util/Logger.h>
-#if ANKI_GR_BACKEND_VULKAN
-#	include <SDL_vulkan.h>
-#endif
-
-namespace anki {
-
-Error NativeWindow::newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow)
-{
-	NativeWindowSdl* sdlwin = static_cast<NativeWindowSdl*>(initInfo.m_allocCallback(
-		initInfo.m_allocCallbackUserData, nullptr, sizeof(NativeWindowSdl), alignof(NativeWindowSdl)));
-	callConstructor(*sdlwin);
-
-	const Error err = sdlwin->init(initInfo);
-	if(err)
-	{
-		callDestructor(*sdlwin);
-		initInfo.m_allocCallback(initInfo.m_allocCallbackUserData, sdlwin, 0, 0);
-		nativeWindow = nullptr;
-		return err;
-	}
-	else
-	{
-		nativeWindow = sdlwin;
-		return Error::kNone;
-	}
-}
-
-void NativeWindow::deleteInstance(NativeWindow* window)
-{
-	if(window)
-	{
-		NativeWindowSdl* self = static_cast<NativeWindowSdl*>(window);
-		AllocAlignedCallback callback = self->m_pool.getAllocationCallback();
-		void* userData = self->m_pool.getAllocationCallbackUserData();
-		callDestructor(*self);
-		callback(userData, self, 0, 0);
-	}
-}
-
-void NativeWindow::setWindowTitle(CString title)
-{
-	NativeWindowSdl* self = static_cast<NativeWindowSdl*>(this);
-	SDL_SetWindowTitle(self->m_window, title.cstr());
-}
-
-NativeWindowSdl::~NativeWindowSdl()
-{
-	if(m_window)
-	{
-		SDL_DestroyWindow(m_window);
-	}
-
-	SDL_QuitSubSystem(kInitSubsystems);
-	SDL_Quit();
-}
-
-Error NativeWindowSdl::init(const NativeWindowInitInfo& init)
-{
-	m_pool.init(init.m_allocCallback, init.m_allocCallbackUserData);
-
-	if(SDL_Init(kInitSubsystems) != 0)
-	{
-		ANKI_CORE_LOGE("SDL_Init() failed: %s", SDL_GetError());
-		return Error::kFunctionFailed;
-	}
-
-#if ANKI_GR_BACKEND_VULKAN
-	if(SDL_Vulkan_LoadLibrary(nullptr))
-	{
-		ANKI_CORE_LOGE("SDL_Vulkan_LoadLibrary() failed: %s", SDL_GetError());
-		return Error::kFunctionFailed;
-	}
-#endif
-
-	//
-	// Set GL attributes
-	//
-	ANKI_CORE_LOGI("Creating SDL window. SDL version %u.%u", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
-
-	//
-	// Create window
-	//
-	U32 flags = 0;
-
-#if ANKI_GR_BACKEND_GL
-	flags |= SDL_WINDOW_OPENGL;
-#elif ANKI_GR_BACKEND_VULKAN
-	flags |= SDL_WINDOW_VULKAN;
-#endif
-
-	SDL_SetHint(SDL_HINT_ALLOW_TOPMOST, "0");
-	if(init.m_fullscreenDesktopRez)
-	{
-#if ANKI_OS_WINDOWS
-		if(init.m_exclusiveFullscreen)
-		{
-			flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
-		}
-#elif ANKI_OS_LINUX
-		flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
-#else
-#	error See file
-#endif
-
-		// Alter the window size
-		SDL_DisplayMode mode;
-		if(SDL_GetDesktopDisplayMode(0, &mode))
-		{
-			ANKI_CORE_LOGE("SDL_GetDesktopDisplayMode() failed: %s", SDL_GetError());
-			return Error::kFunctionFailed;
-		}
-
-		m_width = mode.w;
-		m_height = mode.h;
-	}
-	else
-	{
-		m_width = init.m_width;
-		m_height = init.m_height;
-	}
-
-	m_window =
-		SDL_CreateWindow(&init.m_title[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_width, m_height, flags);
-
-	if(m_window == nullptr)
-	{
-		ANKI_CORE_LOGE("SDL_CreateWindow() failed");
-		return Error::kFunctionFailed;
-	}
-
-	// Final check
-	{
-		int w, h;
-		SDL_GetWindowSize(m_window, &w, &h);
-		ANKI_ASSERT(m_width == U32(w) && m_height == U32(h));
-	}
-
-	ANKI_CORE_LOGI("SDL window created");
-	return Error::kNone;
-}
-
-} // end namespace anki

+ 0 - 28
AnKi/Core/NativeWindowSdl.h

@@ -1,28 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Core/NativeWindow.h>
-#include <SDL.h>
-
-namespace anki {
-
-/// Native window implementation for SDL
-class NativeWindowSdl : public NativeWindow
-{
-public:
-	SDL_Window* m_window = nullptr;
-
-	~NativeWindowSdl();
-
-	Error init(const NativeWindowInitInfo& init);
-
-private:
-	static constexpr U32 kInitSubsystems =
-		SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER;
-};
-
-} // end namespace anki

+ 3 - 3
AnKi/Core/StatsUi.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -16,7 +16,7 @@ StatsUi::~StatsUi()
 
 
 Error StatsUi::init()
 Error StatsUi::init()
 {
 {
-	ANKI_CHECK(m_manager->newInstance(m_font, "EngineAssets/UbuntuMonoRegular.ttf", Array<U32, 1>{24}));
+	ANKI_CHECK(UiManager::getSingleton().newInstance(m_font, "EngineAssets/UbuntuMonoRegular.ttf", Array<U32, 1>{24}));
 
 
 	return Error::kNone;
 	return Error::kNone;
 }
 }
@@ -36,7 +36,7 @@ void StatsUi::labelBytes(PtrSize val, CString name) const
 
 
 	b = val;
 	b = val;
 
 
-	StringRaii timestamp(&getMemoryPool());
+	UiString timestamp;
 	if(gb)
 	if(gb)
 	{
 	{
 		timestamp.sprintf("%s: %zu,%04zu,%04zu,%04zu", name.cstr(), gb, mb, kb, b);
 		timestamp.sprintf("%s: %zu,%04zu,%04zu,%04zu", name.cstr(), gb, mb, kb, b);

+ 5 - 1
AnKi/Core/StatsUi.defs.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -27,6 +27,10 @@ ANKI_STATS_UI_VALUE(PtrSize, gpuDeviceMemoryInUse, "Used", ValueFlag::kNone | Va
 ANKI_STATS_UI_VALUE(PtrSize, unifiedGeometryAllocated, "Unified geom allocated", ValueFlag::kNone | ValueFlag::kBytes)
 ANKI_STATS_UI_VALUE(PtrSize, unifiedGeometryAllocated, "Unified geom allocated", ValueFlag::kNone | ValueFlag::kBytes)
 ANKI_STATS_UI_VALUE(PtrSize, unifiedGeometryTotal, "Unified geom total", ValueFlag::kNone | ValueFlag::kBytes)
 ANKI_STATS_UI_VALUE(PtrSize, unifiedGeometryTotal, "Unified geom total", ValueFlag::kNone | ValueFlag::kBytes)
 ANKI_STATS_UI_VALUE(F32, unifiedGometryExternalFragmentation, "Unified geom ext fragmentation", ValueFlag::kNone)
 ANKI_STATS_UI_VALUE(F32, unifiedGometryExternalFragmentation, "Unified geom ext fragmentation", ValueFlag::kNone)
+ANKI_STATS_UI_VALUE(PtrSize, gpuSceneAllocated, "GPU scene allocated", ValueFlag::kNone | ValueFlag::kBytes)
+ANKI_STATS_UI_VALUE(PtrSize, gpuSceneTotal, "GPU scene total", ValueFlag::kNone | ValueFlag::kBytes)
+ANKI_STATS_UI_VALUE(F32, gpuSceneExternalFragmentation, "GPU scene ext fragmentation", ValueFlag::kNone)
+ANKI_STATS_UI_VALUE(PtrSize, reBar, "ReBAR", ValueFlag::kBytes)
 
 
 ANKI_STATS_UI_BEGIN_GROUP("Other")
 ANKI_STATS_UI_BEGIN_GROUP("Other")
 ANKI_STATS_UI_VALUE(U32, drawableCount, "Render queue drawbles", ValueFlag::kNone)
 ANKI_STATS_UI_VALUE(U32, drawableCount, "Render queue drawbles", ValueFlag::kNone)

+ 2 - 5
AnKi/Core/StatsUi.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -37,10 +37,7 @@ enum class StatsUiDetail : U8
 class StatsUi : public UiImmediateModeBuilder
 class StatsUi : public UiImmediateModeBuilder
 {
 {
 public:
 public:
-	StatsUi(UiManager* ui)
-		: UiImmediateModeBuilder(ui)
-	{
-	}
+	StatsUi() = default;
 
 
 	~StatsUi();
 	~StatsUi();
 
 

+ 1 - 1
AnKi/Core/StdinListener.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Core/StdinListener.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 2 - 2
AnKi/Gr.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -21,7 +21,7 @@
 #include <AnKi/Gr/RenderGraph.h>
 #include <AnKi/Gr/RenderGraph.h>
 #include <AnKi/Gr/GrUpscaler.h>
 #include <AnKi/Gr/GrUpscaler.h>
 
 
-#include <AnKi/Gr/Utils/FrameGpuAllocator.h>
+#include <AnKi/Gr/Utils/StackGpuMemoryPool.h>
 #include <AnKi/Gr/Utils/Functions.h>
 #include <AnKi/Gr/Utils/Functions.h>
 
 
 /// @defgroup graphics Graphics API abstraction
 /// @defgroup graphics Graphics API abstraction

+ 4 - 5
AnKi/Gr/AccelerationStructure.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -125,8 +125,8 @@ protected:
 	AccelerationStructureType m_type = AccelerationStructureType::kCount;
 	AccelerationStructureType m_type = AccelerationStructureType::kCount;
 
 
 	/// Construct.
 	/// Construct.
-	AccelerationStructure(GrManager* manager, CString name)
-		: GrObject(manager, kClassType, name)
+	AccelerationStructure(CString name)
+		: GrObject(kClassType, name)
 	{
 	{
 	}
 	}
 
 
@@ -137,8 +137,7 @@ protected:
 
 
 private:
 private:
 	/// Allocate and initialize a new instance.
 	/// Allocate and initialize a new instance.
-	[[nodiscard]] static AccelerationStructure* newInstance(GrManager* manager,
-															const AccelerationStructureInitInfo& init);
+	[[nodiscard]] static AccelerationStructure* newInstance(const AccelerationStructureInitInfo& init);
 };
 };
 /// @}
 /// @}
 
 

+ 4 - 4
AnKi/Gr/Buffer.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -113,8 +113,8 @@ protected:
 	U64 m_gpuAddress = 0;
 	U64 m_gpuAddress = 0;
 
 
 	/// Construct.
 	/// Construct.
-	Buffer(GrManager* manager, CString name)
-		: GrObject(manager, kClassType, name)
+	Buffer(CString name)
+		: GrObject(kClassType, name)
 	{
 	{
 	}
 	}
 
 
@@ -125,7 +125,7 @@ protected:
 
 
 private:
 private:
 	/// Allocate and initialize a new instance.
 	/// Allocate and initialize a new instance.
-	[[nodiscard]] static Buffer* newInstance(GrManager* manager, const BufferInitInfo& init);
+	[[nodiscard]] static Buffer* newInstance(const BufferInitInfo& init);
 };
 };
 /// @}
 /// @}
 
 

+ 9 - 13
AnKi/Gr/CMakeLists.txt

@@ -3,9 +3,9 @@ set(common_sources
 	GrObject.cpp
 	GrObject.cpp
 	RenderGraph.cpp
 	RenderGraph.cpp
 	ShaderProgram.cpp
 	ShaderProgram.cpp
-	Utils/FrameGpuAllocator.cpp
+	Utils/StackGpuMemoryPool.cpp
 	Utils/Functions.cpp
 	Utils/Functions.cpp
-	Utils/SegregatedListsGpuAllocator.cpp)
+	Utils/SegregatedListsGpuMemoryPool.cpp)
 
 
 set(common_headers
 set(common_headers
 	AccelerationStructure.h
 	AccelerationStructure.h
@@ -29,10 +29,10 @@ set(common_headers
 	TextureView.h
 	TextureView.h
 	TimestampQuery.h
 	TimestampQuery.h
 	GrUpscaler.h
 	GrUpscaler.h
-	Utils/FrameGpuAllocator.h
+	Utils/StackGpuMemoryPool.h
 	Utils/Functions.h
 	Utils/Functions.h
 	Utils/InstantiationMacros.h
 	Utils/InstantiationMacros.h
-	Utils/SegregatedListsGpuAllocator.h)
+	Utils/SegregatedListsGpuMemoryPool.h)
 
 
 if(VULKAN)
 if(VULKAN)
 	set(backend_sources
 	set(backend_sources
@@ -72,7 +72,6 @@ if(VULKAN)
 		Vulkan/TextureViewImpl.cpp
 		Vulkan/TextureViewImpl.cpp
 		Vulkan/TimestampQuery.cpp
 		Vulkan/TimestampQuery.cpp
 		Vulkan/TimestampQueryImpl.cpp
 		Vulkan/TimestampQueryImpl.cpp
-		Vulkan/VulkanObject.cpp
 		Vulkan/FrameGarbageCollector.cpp
 		Vulkan/FrameGarbageCollector.cpp
 		Vulkan/GrUpscaler.cpp
 		Vulkan/GrUpscaler.cpp
 		Vulkan/GrUpscalerImpl.cpp)
 		Vulkan/GrUpscalerImpl.cpp)
@@ -81,12 +80,10 @@ if(VULKAN)
 		Vulkan/AccelerationStructureImpl.h
 		Vulkan/AccelerationStructureImpl.h
 		Vulkan/BufferImpl.h
 		Vulkan/BufferImpl.h
 		Vulkan/CommandBufferFactory.h
 		Vulkan/CommandBufferFactory.h
-		Vulkan/CommandBufferFactory.inl.h
 		Vulkan/CommandBufferImpl.h
 		Vulkan/CommandBufferImpl.h
 		Vulkan/CommandBufferImpl.inl.h
 		Vulkan/CommandBufferImpl.inl.h
 		Vulkan/Common.h
 		Vulkan/Common.h
 		Vulkan/DeferredBarrierFactory.h
 		Vulkan/DeferredBarrierFactory.h
-		Vulkan/DeferredBarrierFactory.inl.h
 		Vulkan/DescriptorSet.h
 		Vulkan/DescriptorSet.h
 		Vulkan/FenceFactory.h
 		Vulkan/FenceFactory.h
 		Vulkan/FenceFactory.inl.h
 		Vulkan/FenceFactory.inl.h
@@ -112,7 +109,6 @@ if(VULKAN)
 		Vulkan/TextureImpl.h
 		Vulkan/TextureImpl.h
 		Vulkan/TextureViewImpl.h
 		Vulkan/TextureViewImpl.h
 		Vulkan/TimestampQueryImpl.h
 		Vulkan/TimestampQueryImpl.h
-		Vulkan/VulkanObject.h
 		Vulkan/GrUpscalerImpl.h)
 		Vulkan/GrUpscalerImpl.h)
 
 
 	if(ANKI_HEADLESS)
 	if(ANKI_HEADLESS)
@@ -139,15 +135,15 @@ add_library(AnKiGr ${backend_sources} ${backend_headers})
 target_compile_definitions(AnKiGr PRIVATE -DANKI_SOURCE_FILE)
 target_compile_definitions(AnKiGr PRIVATE -DANKI_SOURCE_FILE)
 target_link_libraries(AnKiGr AnKiCore AnKiSpirvCross AnKiGrCommon ${extra_libs})
 target_link_libraries(AnKiGr AnKiCore AnKiSpirvCross AnKiGrCommon ${extra_libs})
 
 
-# Copy DLSS files to Bin
+# Copy DLSS files to Binaries
 if(ANKI_DLSS)
 if(ANKI_DLSS)
 	get_target_property(lib_type AnKiNgx TYPE)
 	get_target_property(lib_type AnKiNgx TYPE)
 	if("${lib_type}" STREQUAL "SHARED_LIBRARY")
 	if("${lib_type}" STREQUAL "SHARED_LIBRARY")
 		get_target_property(ANKINGX_DLL AnKiNgx IMPORTED_LOCATION)
 		get_target_property(ANKINGX_DLL AnKiNgx IMPORTED_LOCATION)
 		add_custom_command(
 		add_custom_command(
 			TARGET AnKiGr
 			TARGET AnKiGr
-			COMMENT "Dependant DLLs copy ${ANKINGX_DLL} ${CMAKE_BINARY_DIR}/Bin"
-			COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ANKINGX_DLL}" "${CMAKE_BINARY_DIR}/Bin")
+			COMMENT "Dependant DLLs copy ${ANKINGX_DLL} ${CMAKE_BINARY_DIR}/Binaries"
+			COMMAND ${CMAKE_COMMAND} -E copy_if_different "${ANKINGX_DLL}" "${CMAKE_BINARY_DIR}/Binaries")
 	else()
 	else()
 		get_property(__NGX_DLLS_LIST TARGET AnKiNgx PROPERTY ANKINGX_EXTRA_DLLS)
 		get_property(__NGX_DLLS_LIST TARGET AnKiNgx PROPERTY ANKINGX_EXTRA_DLLS)
 		foreach(dll_path ${__NGX_DLLS_LIST})
 		foreach(dll_path ${__NGX_DLLS_LIST})
@@ -155,8 +151,8 @@ if(ANKI_DLSS)
 			foreach(dll_file ${dll_files})
 			foreach(dll_file ${dll_files})
 				add_custom_command(
 				add_custom_command(
 				TARGET AnKiGr
 				TARGET AnKiGr
-				COMMENT "NGX DLL copy ${dll_file} ${CMAKE_BINARY_DIR}/Bin\n"
-				COMMAND ${CMAKE_COMMAND} -E copy_if_different "${dll_file}" "${CMAKE_BINARY_DIR}/Bin")
+				COMMENT "NGX DLL copy ${dll_file} ${CMAKE_BINARY_DIR}/Binaries\n"
+				COMMAND ${CMAKE_COMMAND} -E copy_if_different "${dll_file}" "${CMAKE_BINARY_DIR}/Binaries")
 			endforeach()
 			endforeach()
 		endforeach()
 		endforeach()
 	endif()
 	endif()

+ 5 - 5
AnKi/Gr/CommandBuffer.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -376,7 +376,7 @@ public:
 	void copyBufferToBuffer(const BufferPtr& src, PtrSize srcOffset, const BufferPtr& dst, PtrSize dstOffset,
 	void copyBufferToBuffer(const BufferPtr& src, PtrSize srcOffset, const BufferPtr& dst, PtrSize dstOffset,
 							PtrSize range)
 							PtrSize range)
 	{
 	{
-		Array<CopyBufferToBufferInfo, 1> copies = {{srcOffset, dstOffset, range}};
+		Array<CopyBufferToBufferInfo, 1> copies = {{{srcOffset, dstOffset, range}}};
 		copyBufferToBuffer(src, dst, copies);
 		copyBufferToBuffer(src, dst, copies);
 	}
 	}
 
 
@@ -437,8 +437,8 @@ public:
 
 
 protected:
 protected:
 	/// Construct.
 	/// Construct.
-	CommandBuffer(GrManager* manager, CString name)
-		: GrObject(manager, kClassType, name)
+	CommandBuffer(CString name)
+		: GrObject(kClassType, name)
 	{
 	{
 	}
 	}
 
 
@@ -449,7 +449,7 @@ protected:
 
 
 private:
 private:
 	/// Allocate and initialize a new instance.
 	/// Allocate and initialize a new instance.
-	[[nodiscard]] static CommandBuffer* newInstance(GrManager* manager, const CommandBufferInitInfo& init);
+	[[nodiscard]] static CommandBuffer* newInstance(const CommandBufferInitInfo& init);
 };
 };
 /// @}
 /// @}
 
 

+ 7 - 1
AnKi/Gr/Common.cpp

@@ -1,9 +1,10 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
 
 
 #include <AnKi/Gr/Common.h>
 #include <AnKi/Gr/Common.h>
+#include <AnKi/Gr/GrObject.h>
 #include <AnKi/Math.h>
 #include <AnKi/Math.h>
 
 
 namespace anki {
 namespace anki {
@@ -18,6 +19,11 @@ inline constexpr ShaderVariableDataTypeInfo kShaderVariableDataTypeInfos[] = {
 #undef ANKI_SVDT_MACRO_OPAQUE
 #undef ANKI_SVDT_MACRO_OPAQUE
 };
 };
 
 
+void GrObjectDeleter::operator()(GrObject* ptr)
+{
+	deleteInstance(GrMemoryPool::getSingleton(), ptr);
+}
+
 const ShaderVariableDataTypeInfo& getShaderVariableDataTypeInfo(ShaderVariableDataType type)
 const ShaderVariableDataTypeInfo& getShaderVariableDataTypeInfo(ShaderVariableDataType type)
 {
 {
 	ANKI_ASSERT(type > ShaderVariableDataType::kNone && type < ShaderVariableDataType::kCount);
 	ANKI_ASSERT(type > ShaderVariableDataType::kNone && type < ShaderVariableDataType::kCount);

+ 25 - 70
AnKi/Gr/Common.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -9,6 +9,7 @@
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Util/Ptr.h>
 #include <AnKi/Util/String.h>
 #include <AnKi/Util/String.h>
 #include <AnKi/Util/Enum.h>
 #include <AnKi/Util/Enum.h>
+#include <AnKi/Shaders/Include/Common.h>
 
 
 namespace anki {
 namespace anki {
 
 
@@ -38,6 +39,22 @@ class GrUpscalerInitInfo;
 #define ANKI_GR_LOGF(...) ANKI_LOG("GR", kFatal, __VA_ARGS__)
 #define ANKI_GR_LOGF(...) ANKI_LOG("GR", kFatal, __VA_ARGS__)
 #define ANKI_GR_LOGV(...) ANKI_LOG("GR", kVerbose, __VA_ARGS__)
 #define ANKI_GR_LOGV(...) ANKI_LOG("GR", kVerbose, __VA_ARGS__)
 
 
+class GrMemoryPool : public HeapMemoryPool, public MakeSingleton<GrMemoryPool>
+{
+	template<typename>
+	friend class MakeSingleton;
+
+private:
+	GrMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData)
+		: HeapMemoryPool(allocCb, allocCbUserData, "GrMemPool")
+	{
+	}
+
+	~GrMemoryPool() = default;
+};
+
+ANKI_DEFINE_SUBMODULE_UTIL_CONTAINERS(Gr, GrMemoryPool)
+
 // Some constants
 // Some constants
 constexpr U32 kMaxVertexAttributes = 8;
 constexpr U32 kMaxVertexAttributes = 8;
 constexpr U32 kMaxColorRenderTargets = 4;
 constexpr U32 kMaxColorRenderTargets = 4;
@@ -51,9 +68,15 @@ constexpr U32 kMaxBindlessReadonlyTextureBuffers = 512;
 /// The number of commands in a command buffer that make it a small batch command buffer.
 /// The number of commands in a command buffer that make it a small batch command buffer.
 constexpr U32 kCommandBufferSmallBatchMaxCommands = 100;
 constexpr U32 kCommandBufferSmallBatchMaxCommands = 100;
 
 
+class GrObjectDeleter
+{
+public:
+	void operator()(GrObject* ptr);
+};
+
 /// Smart pointer for resources.
 /// Smart pointer for resources.
 template<typename T>
 template<typename T>
-using GrObjectPtrT = IntrusivePtr<T, DefaultPtrDeleter<GrObject>>;
+using GrObjectPtrT = IntrusivePtr<T, GrObjectDeleter>;
 
 
 using GrObjectPtr = GrObjectPtrT<GrObject>;
 using GrObjectPtr = GrObjectPtrT<GrObject>;
 
 
@@ -783,74 +806,6 @@ enum class VrsRate : U8
 };
 };
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VrsRate)
 ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VrsRate)
 
 
-/// The draw indirect structure for index drawing, also the parameters of a regular drawcall
-class DrawElementsIndirectInfo
-{
-public:
-	U32 m_count = kMaxU32;
-	U32 m_instanceCount = 1;
-	U32 m_firstIndex = 0;
-	U32 m_baseVertex = 0;
-	U32 m_baseInstance = 0;
-
-	DrawElementsIndirectInfo() = default;
-
-	DrawElementsIndirectInfo(const DrawElementsIndirectInfo&) = default;
-
-	DrawElementsIndirectInfo(U32 count, U32 instanceCount, U32 firstIndex, U32 baseVertex, U32 baseInstance)
-		: m_count(count)
-		, m_instanceCount(instanceCount)
-		, m_firstIndex(firstIndex)
-		, m_baseVertex(baseVertex)
-		, m_baseInstance(baseInstance)
-	{
-	}
-
-	Bool operator==(const DrawElementsIndirectInfo& b) const
-	{
-		return m_count == b.m_count && m_instanceCount == b.m_instanceCount && m_firstIndex == b.m_firstIndex
-			   && m_baseVertex == b.m_baseVertex && m_baseInstance == b.m_baseInstance;
-	}
-
-	Bool operator!=(const DrawElementsIndirectInfo& b) const
-	{
-		return !(operator==(b));
-	}
-};
-
-/// The draw indirect structure for arrays drawing, also the parameters of a regular drawcall
-class DrawArraysIndirectInfo
-{
-public:
-	U32 m_count = kMaxU32;
-	U32 m_instanceCount = 1;
-	U32 m_first = 0;
-	U32 m_baseInstance = 0;
-
-	DrawArraysIndirectInfo() = default;
-
-	DrawArraysIndirectInfo(const DrawArraysIndirectInfo&) = default;
-
-	DrawArraysIndirectInfo(U32 count, U32 instanceCount, U32 first, U32 baseInstance)
-		: m_count(count)
-		, m_instanceCount(instanceCount)
-		, m_first(first)
-		, m_baseInstance(baseInstance)
-	{
-	}
-
-	Bool operator==(const DrawArraysIndirectInfo& b) const
-	{
-		return m_count == b.m_count && m_instanceCount == b.m_instanceCount && m_first == b.m_first
-			   && m_baseInstance == b.m_baseInstance;
-	}
-
-	Bool operator!=(const DrawArraysIndirectInfo& b) const
-	{
-		return !(operator==(b));
-	}
-};
-
 /// Clear values for textures or attachments.
 /// Clear values for textures or attachments.
 class ClearValue
 class ClearValue
 {
 {

+ 2 - 1
AnKi/Gr/ConfigVars.defs.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -9,6 +9,7 @@ ANKI_CONFIG_VAR_BOOL(GrValidation, false, "Enable or not validation")
 ANKI_CONFIG_VAR_BOOL(GrDebugPrintf, false, "Enable or not debug printf")
 ANKI_CONFIG_VAR_BOOL(GrDebugPrintf, false, "Enable or not debug printf")
 ANKI_CONFIG_VAR_BOOL(GrDebugMarkers, false, "Enable or not debug markers")
 ANKI_CONFIG_VAR_BOOL(GrDebugMarkers, false, "Enable or not debug markers")
 ANKI_CONFIG_VAR_BOOL(GrVsync, false, "Enable or not vsync")
 ANKI_CONFIG_VAR_BOOL(GrVsync, false, "Enable or not vsync")
+ANKI_CONFIG_VAR_U8(GrDevice, 0, 0, 16, "Choose an available device. Devices are sorted by performance")
 
 
 ANKI_CONFIG_VAR_PTR_SIZE(GrDiskShaderCacheMaxSize, 128_MB, 1_MB, 1_GB, "Max size of the pipeline cache file")
 ANKI_CONFIG_VAR_PTR_SIZE(GrDiskShaderCacheMaxSize, 128_MB, 1_MB, 1_GB, "Max size of the pipeline cache file")
 
 

+ 4 - 4
AnKi/Gr/Fence.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -27,8 +27,8 @@ public:
 
 
 protected:
 protected:
 	/// Construct.
 	/// Construct.
-	Fence(GrManager* manager, CString name)
-		: GrObject(manager, kClassType, name)
+	Fence(CString name)
+		: GrObject(kClassType, name)
 	{
 	{
 	}
 	}
 
 
@@ -39,7 +39,7 @@ protected:
 
 
 private:
 private:
 	/// Allocate and initialize a new instance.
 	/// Allocate and initialize a new instance.
-	[[nodiscard]] static Fence* newInstance(GrManager* manager);
+	[[nodiscard]] static Fence* newInstance();
 };
 };
 /// @}
 /// @}
 
 

+ 1 - 1
AnKi/Gr/Format.defs.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 4 - 4
AnKi/Gr/Framebuffer.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -119,8 +119,8 @@ public:
 
 
 protected:
 protected:
 	/// Construct.
 	/// Construct.
-	Framebuffer(GrManager* manager, CString name)
-		: GrObject(manager, kClassType, name)
+	Framebuffer(CString name)
+		: GrObject(kClassType, name)
 	{
 	{
 	}
 	}
 
 
@@ -130,7 +130,7 @@ protected:
 	}
 	}
 
 
 private:
 private:
-	[[nodiscard]] static Framebuffer* newInstance(GrManager* manager, const FramebufferInitInfo& init);
+	[[nodiscard]] static Framebuffer* newInstance(const FramebufferInitInfo& init);
 };
 };
 /// @}
 /// @}
 
 

+ 1 - 1
AnKi/Gr/Gl/Buffer.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/BufferImpl.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/BufferImpl.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/CommandBuffer.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 2 - 2
AnKi/Gr/Gl/CommandBufferImpl.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -96,7 +96,7 @@ void CommandBufferImpl::flushDrawcall(CommandBuffer& cmdb)
 	//
 	//
 	// Set default state
 	// Set default state
 	//
 	//
-	if(ANKI_UNLIKELY(m_state.m_mayContainUnsetState))
+	if(m_state.m_mayContainUnsetState) [[unlikely]]
 	{
 	{
 		m_state.m_mayContainUnsetState = false;
 		m_state.m_mayContainUnsetState = false;
 
 

+ 1 - 1
AnKi/Gr/Gl/CommandBufferImpl.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/Common.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/Common.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/Error.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/Error.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/Fence.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/FenceImpl.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/FenceImpl.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/Framebuffer.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/FramebufferImpl.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/FramebufferImpl.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/GlObject.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/GlObject.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/GlState.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/GlState.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/GrManager.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 2 - 2
AnKi/Gr/Gl/GrManagerImpl.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -8,7 +8,7 @@
 #include <AnKi/Gr/gl/RenderingThread.h>
 #include <AnKi/Gr/gl/RenderingThread.h>
 #include <AnKi/Gr/gl/GlState.h>
 #include <AnKi/Gr/gl/GlState.h>
 #include <AnKi/Core/Config.h>
 #include <AnKi/Core/Config.h>
-#include <AnKi/Core/NativeWindow.h>
+#include <AnKi/Window/NativeWindow.h>
 
 
 namespace anki {
 namespace anki {
 
 

+ 1 - 1
AnKi/Gr/Gl/GrManagerImpl.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 3 - 3
AnKi/Gr/Gl/GrManagerImplSdl.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE
@@ -7,8 +7,8 @@
 
 
 #include <AnKi/Gr/gl/GrManagerImpl.h>
 #include <AnKi/Gr/gl/GrManagerImpl.h>
 #include <AnKi/Gr/GrManager.h>
 #include <AnKi/Gr/GrManager.h>
-#include <AnKi/Core/NativeWindow.h>
-#include <AnKi/Core/NativeWindowSdl.h>
+#include <AnKi/Window/NativeWindow.h>
+#include <AnKi/Window/NativeWindowSdl.h>
 #include <AnKi/Core/Config.h>
 #include <AnKi/Core/Config.h>
 #include <SDL.h>
 #include <SDL.h>
 #include <GL/glew.h>
 #include <GL/glew.h>

+ 1 - 1
AnKi/Gr/Gl/OcclusionQuery.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/OcclusionQueryImpl.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/OcclusionQueryImpl.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

+ 1 - 1
AnKi/Gr/Gl/RenderingThread.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
+// Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
 // All rights reserved.
 // All rights reserved.
 // Code licensed under the BSD License.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE
 // http://www.anki3d.org/LICENSE

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