Adds docs/ — a navigation layer on top of AGENTS.md for future coding agents working on the Seele engine and the MeshShadingDemo harness. - docs/README.md: index + 30-second orientation + how-to-use workflow. - docs/cross-repo.md: the engine<->demo contract (2-symbol ABI, the ComponentSystem<...> demo pattern with the FlyCamSystem example, the CMake in-tree vs install(EXPORT) split, a where-to-look task map). - docs/subsystems/*.md: 16 per-subsystem deep-dives (scene/ECS, systems, game-interface, window, graphics backends, render graph, materials, physics, UI, assets, platform, core utils). Each maps public types to their defining headers and gives file:line pointers + gotchas. All cross-links verified resolving. This is documentation only — no source changes.
9.2 KiB
GPU Resources (Buffers, Textures, Shaders, Pipelines, Descriptors)
GPU resource types, VertexData self-registration, the descriptor/parameter layer, and the shader compilation flow.
This is a navigation doc: it tells you where things live, how data actually flows, and the sharp edges — so you can orient in minutes instead of hours. It complements the repository's AGENTS.md (map + rules) and the cross-repo guide (engine ↔ demo contract). Everything below is grounded in the checked-out source at commit d3ed573.
Key types & where they live
| Type | Defined in |
|---|---|
Gfx::Buffer (abstract) |
git grep in src/ |
Gfx::ShaderBuffer |
git grep in src/ |
Gfx::UniformBuffer |
git grep in src/ |
Gfx::VertexBuffer |
git grep in src/ |
Gfx::IndexBuffer |
git grep in src/ |
Gfx::Texture |
src/Engine/Graphics/Metal/Texture.h |
Gfx::Texture2D |
git grep in src/ |
Gfx::Texture2DArray |
git grep in src/ |
Gfx::Texture3D |
git grep in src/ |
Gfx::TextureCube |
git grep in src/ |
Gfx::TextureView |
git grep in src/ |
Gfx::Sampler |
git grep in src/ |
Gfx::Shader (abstract) |
git grep in src/ |
Gfx::VertexShader |
git grep in src/ |
Gfx::FragmentShader |
git grep in src/ |
Gfx::ComputeShader |
git grep in src/ |
Gfx::TaskShader |
git grep in src/ |
Gfx::MeshShader |
git grep in src/ |
Gfx::ShaderCompiler |
git grep in src/ |
Gfx::DescriptorLayout |
git grep in src/ |
Gfx::DescriptorSet |
git grep in src/ |
Gfx::PipelineLayout |
git grep in src/ |
Gfx::GraphicsPipeline |
git grep in src/ |
Gfx::ComputePipeline |
git grep in src/ |
Gfx::RayTracingPipeline |
git grep in src/ |
Gfx::RenderTarget |
src/Engine/Graphics/RenderTarget.h |
Gfx::RenderTargetAttachment |
git grep in src/ |
Gfx::VertexInput |
git grep in src/ |
Gfx::RenderCommand |
git grep in src/ |
Gfx::ComputeCommand |
git grep in src/ |
Gfx::Meshlet |
src/Engine/Graphics/Meshlet.h |
Gfx::Mesh |
src/Engine/Component/Mesh.h |
VertexData |
src/Engine/Graphics/VertexData.h |
StaticMeshVertexData |
src/Engine/Graphics/StaticMeshVertexData.h |
Paths above are resolved against the actual source tree (namespace ≈ directory in this codebase). A (search) marker means the file contains the name but may also define others — open it and grep. git grep is always a fallback. The full per-file map is in Where to look below.
Data flow / lifecycle
All GPU resources are created through Gfx::Graphics factory methods (see Gfx Abstract Backend). Resource classes are thin wrappers around backend handles: Buffer.h (abstract base, 3.7KB) -> ShaderBuffer/UniformBuffer/VertexBuffer/IndexBuffer (each with a createInfo struct in Initializer.h). Texture.h (7KB) defines Texture base + Texture2D/2DArray/3D/Cube + TextureView + Sampler. Each has a TextureCreateInfo / SamplerCreateInfo in Initializer.h. Shader.h (5.9KB) defines Shader base (with ShaderStage enum) + VertexShader/FragmentShader/ComputeShader/TaskShader/MeshShader + ShaderCompiler (line 178). Shader compilation is two-phase: Graphics::beginShaderCompilation(ShaderCompilationInfo) then createXxxShader(ShaderCreateInfo) — the ShaderCompiler (held as OShaderCompiler member of Graphics) does the actual Slang->SPIR-V/Metal translation (see slang-compile.h/.cpp, 9KB). Descriptor.h (4.4KB) defines DescriptorLayout (with DescriptorBinding struct: binding index, stage flags, resource type), DescriptorSet (binds resources to a layout), PipelineLayout (composes descriptor layouts + push constant ranges). RenderTarget.h (4.7KB) defines RenderTarget (wraps Gfx::ORenderPass + framebuffers), RenderTargetAttachment (texture + load/store op + initial layout + final layout), SubPassDependency. Pipeline.h (904B) defines LegacyPipelineCreateInfo (vertex/fragment shader stages, vertex input state, render pass, multisample state, depth/stencil state, blend state, rasterization state) and MeshPipelineCreateInfo (task/mesh/fragment shaders, vertex output state, same fixed-function state). ComputePipelineCreateInfo and RayTracingPipelineCreateInfo are also here. Meshlet.h (442B) + Meshlet.cpp (6.2KB) define the meshlet data structure (submesh with bounding sphere, transform, index range) used by the GPU culling pipeline. Mesh.h (895B) + Mesh.cpp (1.5KB) define the GPU mesh asset (vertex buffer + index buffer + meshlets). VertexData (6.5KB header + 27.5KB impl) is the CPU-side mesh data object that owns the source vertex/index arrays, builds meshlets (Meshlet.cpp), and uploads to GPU (createDescriptors()). StaticMeshVertexData (2.3KB header + 7.9KB impl) is the concrete implementation for static meshes. VertexData has a STATIC global registry (getList()) that GameView::update() iterates. Slang shaders are compiled by slang-compile.cpp (9KB) which invokes the Slang compiler frontend and produces SPIR-V (Vulkan) or Metal SL (Metal). The ShaderCompiler class in Shader.h orchestrates this.
Where to look
| Path | What's there |
|---|---|
src/Engine/Graphics/Buffer.h + .cpp |
abstract buffer base + create-info structs |
src/Engine/Graphics/Texture.h + .cpp |
texture hierarchy, 7KB header |
src/Engine/Graphics/Shader.h |
Shader base + all shader types + ShaderCompiler at line 178 |
src/Engine/Graphics/Shader.cpp |
7.3KB — shader compilation orchestration |
src/Engine/Graphics/slang-compile.h + .cpp |
Slang frontend invocation, 9KB |
src/Engine/Graphics/Descriptor.h + .cpp |
descriptor layout/set/pipeline layout |
src/Engine/Graphics/Pipeline.h + .cpp |
pipeline create-info structs |
src/Engine/Graphics/RenderTarget.h + .cpp |
render target + attachments + subpass dependencies |
src/Engine/Graphics/Command.h + .cpp |
RenderCommand/ComputeCommand — command buffer wrappers |
src/Engine/Graphics/Meshlet.h + .cpp |
meshlet data structure for GPU culling |
src/Engine/Graphics/Mesh.h + .cpp |
GPU mesh asset |
src/Engine/Graphics/VertexData.h + .cpp |
CPU mesh data, meshlet builder, GPU upload — 27.5KB impl |
src/Engine/Graphics/StaticMeshVertexData.h + .cpp |
static mesh implementation |
src/Engine/Graphics/Initializer.h |
ALL create-info structs: GraphicsInitializer, WindowCreateInfo, ViewportCreateInfo, TextureCreateInfo, BufferCreateInfo, ShaderCreateInfo, PipelineCreateInfo variants, SamplerCreateInfo, etc. — 8.5KB |
src/Engine/Graphics/Enums.h |
81KB — all Vulkan/Metal enums, flags, and mapping tables |
Gotchas & sharp edges
- VertexData is NOT an entt component — it is a standalone object that self-registers into a static global list. GameView::update() calls VertexData::getList() to iterate all registered instances. If you create a VertexData and never add it to a scene entity, it still appears in the global list.
- StaticMeshVertexData is the only concrete VertexData implementation in the codebase. There is no 'dynamic mesh' or 'animated mesh' VertexData variant.
- The Slang compiler is invoked at RUNTIME via slang-compile.cpp — shaders are NOT pre-compiled at build time. This means first-frame startup time includes Slang compilation. The PipelineCache (Vulkan/PipelineCache.cpp, 36.8KB / Metal/PipelineCache.mm, 12.8KB) caches compiled pipeline binaries to disk to avoid re-compilation on subsequent launches.
- DescriptorSet and DescriptorLayout are GPU resources — they are created via Graphics::createDescriptorLayout / the backend. You cannot create them directly; you must go through the Graphics factory.
- The MeshPipelineCreateInfo (for mesh shading) is a SEPARATE struct from LegacyPipelineCreateInfo. Graphics::createGraphicsPipeline has two overloads — one takes each. Passing the wrong one is a compile error (no implicit conversion).
- ShaderCompiler is a member of Graphics (OShaderCompiler shaderCompiler) and is accessed via Graphics::getShaderCompiler(). It is NOT a standalone service — it dies when the Graphics instance is destroyed.
- RenderTargetAttachment holds a Gfx::PTexture (the actual texture) + load/store ops + initial/final layouts. The RenderTarget class wraps the GPU render pass + framebuffers. createRenderPass on Graphics takes a RenderTargetLayout (array of attachments) + SubPassDependency array + render area + optional viewMasks/correlationMasks (for multi-view/SPIRV workarounds).
- Buffer.h defines the abstract Buffer base with a BufferUsageFlags enum. ShaderBuffer is for generic GPU-usable buffers (uniform/vertex/index data). UniformBuffer is specifically for uniform buffers (has a dedicated createUniformBuffer factory). VertexBuffer and IndexBuffer are for vertex/index data (have dedicated factories).
- The 81KB Enums.h file contains ALL Vulkan enums + Metal enum mappings. It is auto-generated or hand-maintained. Modifying it is fragile.
- PipelineCache (Vulkan) serializes VkPipelineCacheData to disk. Metal's PipelineCache.mm uses MTLBinaryArchive. Both are keyed by a hash of the pipeline create-info + shader code.
Generated from a full read of the checked-out source at commit d3ed573. If a path has moved, git grep for the type name — the engine is small enough to find anything in seconds.