-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
145 lines (85 loc) · 5.07 KB
/
Copy pathSource.cpp
File metadata and controls
145 lines (85 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Dot Engine : Technical Master Plan
Architecture Type : Data - Oriented Hybrid.Primary Languages : C++20 (Core), C# (Scripting), HLSL / GLSL(Shaders).Target Platforms : Windows, Linux, MacOS(Phase 1); Consoles / Mobile(Phase 2).
Stage 1: The Core "Kernel" (The Bedrock)
Before drawing a single pixel, you need a safe environment for code to run.
1.1 Memory Management System
Standard new / delete is too slow for 60fps.You need a custom memory manager.
Linear / Stack Allocators : For per - frame temporary data(cleared instantly at end of frame).
Pool Allocators : For game objects(keeps data contiguous in RAM for CPU cache efficiency).
Memory Tracking : A debug layer to track every byte allocated and detect leaks instantly.
1.2 The Job System(Multithreading)
Do not use std::thread directly.
Fiber - Based Task Graph : Similar to Naughty Dog’s engine.You create small "Jobs" (e.g., "Calculate Physics", "Update Animation").
Worker Threads : One thread per CPU core.They steal jobs from a queue.
Lock - Free Queues : Use atomic operations to prevent threads from waiting on each other.
1.3 SIMD Math Library
Implement a math library(Vectors, Matrices, Quaternions) that utilizes SSE / AVX intrinsics.This allows the CPU to calculate 4 to 8 math operations in a single cycle.
Stage 2 : The Architecture(The "Godot + Unreal" Hybrid)
This is where we merge the two philosophies.
2.1 The Hybrid ECS
Backend(The "Unreal" Power) :
Data is stored in Archetypes(tightly packed arrays of integers / floats).
Systems iterate over these arrays linearly(extremely fast).
Frontend(The "Godot" Ease) :
The "Node" Wrapper : A C++ class that acts as a handle to the ECS data.
When the user types player.move(), the Node translates that into an ECS command.
Scene Tree : A Directed Acyclic Graph(DAG) that manages parent / child transforms, strictly for logical organization, not memory storage.
2.2 Reflection System
You need to build a custom Reflection System(like Unreal's UPROPERTY).
Use macros or a pre - build tool(parser) to analyze your C++ code and generate metadata.
Why ? This allows the Editor to automatically see your variables(float speed) and create UI sliders for them without you writing UI code.
Stage 3 : The Renderer(The "Visuals")
We are building a Render Graph architecture, not a linear pipeline.
3.1 The RHI(Render Hardware Interface)
Abstraction Layer : RHI_CommandList, RHI_Texture, RHI_Buffer.
Backends :
Vulkan : Primary backend(cross - platform, high performance).
DirectX 12 : For Windows optimization.
Metal : For MacOS support.
3.2 The Frame Graph
Instead of hardcoding passes, the engine builds a dependency graph every frame.
Pass A : "I need the Depth Buffer."
Pass B : "I produce the Depth Buffer."
Engine : "Okay, run B, then A. I will handle the memory barriers."
3.3 Rendering Techniques(The "Cool Stuff")
Bindless Rendering : Use "Bindless Descriptors" so you can access all textures in a single shader(removes draw - call overhead).
Cluster - Based Mesh Shading(Nanite - lite) :
Pre - process meshes into "Meshlets" (small groups of triangles).
Use Task Shaders & Mesh Shaders on the GPU to cull invisible geometry before the pixel shader runs.
Hybrid Ray - Tracing:
Use Software Ray Tracing(SDFs) for Global Illumination(Lumen style).
Use Hardware Ray Tracing(DXR / Vulkan RT) for precise reflections if the GPU supports it.
Stage 4: The Asset Pipeline
Data management is 50 % of an engine.
4.1 The Virtual File System(VFS)
Abstract the file system so Res ://textures/grass.png works even if the data is inside a compressed .pak file or streamed from a server.
4.2 Asset Processor
Hot - Reloading : Watch files for changes.
Importer :
Images ->.tex(custom GPU - ready compression like BC7).
Models ->.mesh(custom binary format with pre - calculated bounding boxes and LODs).
Scripts->DLL hot - swap.
Stage 5: Physics & Simulation
5.1 Physics Integration
Library : Jolt Physics(MIT license, faster than PhysX).
Layer : Wrap Jolt in an ECS System.
System : PhysicsSystem reads TransformComponent->updates Jolt Body->Jolt simulates->writes back to TransformComponent.
5.2 Audio Engine
Library : Miniaudio(Simple, raw) or FMOD(Professional).
Features : Spatial audio, reverb zones, Doppler effect.
Stage 6 : The Editor(The Interface)
6.1 UI Framework
Immediate Mode(ImGui) : Use this for the initial version.It is fast and stateless.
Docking System : Allow users to drag windows(Scene, Inspector, Console) anywhere.
6.2 The Viewport
This is a "Game Window" running inside the Editor UI.
Implement Gizmos(Translation / Rotation / Scale tools) using Ray - AABB intersection tests.
Stage 7: Scripting(The User Layer)
7.1 C# Mono Integration
Embed the Mono Runtime or CoreCLR.
Generate C# bindings automatically from your C++ Reflection system.
This gives users the safety of C# with the speed of the C++ engine.
7.2 Visual Scripting
A Graph Editor that serializes connections to a JSON / Binary format.
Interpreter: The C++ backend reads the graph and executes nodes(slower).
Compiler : Later, compile the graph into C# code(faster).