Documentation
This section provides conceptual documentation to help you understand Zenith.NET's architecture and best practices.
Note
Looking for step-by-step coding guides? Check out the Tutorials section.
Core Concepts
Graphics Context
The GraphicsContext is the central hub of Zenith.NET. It abstracts the underlying graphics API and provides:
- Resource Creation - Create buffers, textures, pipelines, and other GPU resources
- Command Queues - Access to
Graphics,Compute, andCopyqueues - Capabilities - Query device name and feature support via
Capabilities
Backend-specific contexts are created via extension methods:
GraphicsContext.CreateDirectX12(useValidationLayer)- WindowsGraphicsContext.CreateMetal(useValidationLayer)- AppleGraphicsContext.CreateVulkan(useValidationLayer)- Cross-platform
Command Model
Zenith.NET uses an explicit command recording model:
- Get a CommandBuffer - Call
queue.CommandBuffer()to obtain a buffer from the pool - Record Commands - Record draw calls, dispatches, copies, and state changes
- Submit - Call
commandBuffer.Submit()to execute on the GPU - Synchronize - Use
queue.WaitIdle()to wait for all submitted work to complete
Resource Binding
Resources are bound to shaders through two types:
| Type | Purpose |
|---|---|
ResourceLayout |
Declares what resources a shader expects (binding slots, types) |
ResourceTable |
Provides actual resources matching a layout |
Pipelines reference a single ResourceLayout, and you bind a corresponding ResourceTable before draw/dispatch calls.
Features
| Feature | Description |
|---|---|
| Graphics | Traditional rasterization with vertex and pixel shaders |
| Compute | General-purpose GPU compute with compute shaders |
| Ray Tracing | Hardware-accelerated BLAS/TLAS with RayQuery in any shader stage |
| Mesh Shading | Modern GPU-driven geometry with mesh and amplification shaders |
Platform Support
| Platform | DirectX 12 | Metal | Vulkan |
|---|---|---|---|
| Windows | Yes | No | Yes |
| Linux | No | No | Yes |
| Apple | No | Yes | Yes |
| Android | No | No | Yes |
Best Practices
Resource Management
- Dispose resources when no longer needed using
usingstatements orIDisposablepatterns - Create resources upfront rather than per-frame to avoid allocation overhead
- Reuse command buffers - the queue automatically pools and recycles them
Command Recording
- Batch similar operations to reduce pipeline and resource table switches
- Minimize render pass switches by grouping draws with the same targets
- Call
queue.WaitIdle()only when synchronization is required
Data Alignment
Zenith.NET defines alignment constants in GraphicsContext for cross-platform compatibility:
| Constant | Value | Purpose |
|---|---|---|
ConstantBufferAlignment |
256 bytes | Minimum alignment for constant buffer data |
TextureRowPitchAlignment |
256 bytes | Alignment for texture row pitch |
TextureDepthPitchAlignment |
512 bytes | Alignment for 3D texture depth slice pitch |
Next Steps
- Tutorials - Hands-on coding examples
- API Reference - Detailed type documentation