NoGraphicsAPI README

项目的 README,来自 github.com/sebbbi/NoGraphicsAPI。合并为一个 markdown 文件:README.md。

NoGraphicsAPI

NoGraphicsAPI is a C++20 graphics library for Metal 4 devices and Vulkan 1.4 devices with VK_EXT_descriptor_heap and VK_EXT_mesh_shader. It implements the ideas in Sebastian Aaltonen's No Graphics API with GPU pointers, descriptor heaps, and shared Slang shaders.

The goal is to make GPU programming feel more like working with ordinary memory and data structures: GPU pointers for data, heap indices for textures, and one GPU pointer to the arguments of each draw or dispatch.

Metal and Vulkan are supported native backends. CMake selects Metal on macOS/iOS and Vulkan on Windows/Linux. Both use the same C++ API and Slang sources. Windows and macOS include windowed examples; Linux currently supports headless use.

What changes from classic rendering?

A conventional renderer creates buffer objects, describes vertex and resource-binding layouts, and assembles bindings before drawing. The blog asks how much of this machinery modern bindless hardware still needs. NoGraphicsAPI makes that alternative data model the foundation of the library:

This is a low-level library: the application still owns allocation policy, resource lifetime, and GPU synchronization. The optional NoGraphicsAPIUtility library supplies shared shader types, math, allocators, upload queues, and deferred deletion without making them part of the graphics API.

Initialization and resource creation failures return an error or an empty handle. Ordinary frame operations, including draws, dispatches, and descriptor writes, return no error codes; native results are checked with debug assertions. Install set_error_callback on the initialization thread for backend diagnostics, including the Vulkan operation, result and requested allocation size. The callback is synchronous, thread-local, and disabled by default. Clear it before ordinary frame execution when diagnostics are intended only for startup. Check UploadQueue::valid() after construction; failed initialization releases its partial resources.

What a draw's data looks like

Declare the arguments once in a shared C++/Slang header:

struct RootArguments
{
    Vertex* vertices;
    Material* material;
    float4x4 transform;
    uint32 texture_index;
    uint32 padding[3];
};

Allocate a root from application-owned mapped storage, fill it through the CPU address, then pass its GPU address:

const gpu::GpuCpuRange<RootArguments> root = bump_allocator.allocate<RootArguments>();
*root.cpu = {
    .vertices = vertex_memory.gpu,
    .material = material_memory.gpu,
    .transform = transform,
    .texture_index = texture_index,
};
gpu::draw(commands, root.gpu, vertex_count);

With <NoGraphicsAPI/shader.slang>, the shader accesses the same data directly:

GPU_ROOT(RootArguments, root);
Vertex vertex = root.vertices[vertex_id];
Material material = *root.material;
Texture2D<float4> texture = gpu_texture<Texture2D<float4>>(root.texture_index);

Draws and dispatches take GPU root pointers directly, including roots written by earlier GPU work. All graphics stages share the same root. Roots follow the shared constant-buffer layout; pointed-to data keeps C POD layout. Keep each root allocation alive and stable until its GPU use completes. See the design comparison for the remaining differences and the shader guide for complete examples.

Native implementations

Metal 4 draw/dispatch commands accept native GPU addresses directly and use MTLTextureViewPool for indexed textures. Vulkan uses device-address commands when available and resolves addresses to backing buffers otherwise. See Metal implementation and Vulkan implementation for how these map to NoGraphicsAPI.

Hardware requirements

Metal

Requires Metal 4, macOS, iOS or iPadOS 26+, and Apple GPU family 7 or newer.

Platform Supported devices
Mac Apple silicon Macs (M1 and newer)
iPhone iPhone 12 and newer (A14 and newer)
iPad Pro 2021 and newer (M1 and newer)
iPad Air 2020 and newer (A14 and newer)
iPad mini 2021 and newer (A15 and newer)
iPad 2022 and newer (A14 and newer)

See Apple's supported devices. Direct task/mesh draws work throughout this baseline; indirect mesh draws require A17 Pro / M3 or newer. BC texture compression is a separate capability. See Metal implementation for these limits and validation for tested hardware and known issues. Intel Macs, Simulator, tvOS and visionOS are not supported targets.

Vulkan 1.4

The Vulkan backend targets little-endian x86-64; utility math requires AVX2 and FMA. Vulkan 1.4 alone is insufficient. Required extensions include:

VK_KHR_device_address_commands is optional: without it, command addresses resolve to backing buffers and offsets. VK_KHR_unified_image_layouts is optional and makes the backend's common image layout efficient. See the Vulkan implementation for the complete feature contract.

Missing required extensions are the main reason for unsupported GPUs below; the remaining requirements are more widely supported on recent GPUs.

The table preserves the driver reports checked on 5 September 2026. These are compatibility snapshots, not a live driver list. The checked Windows packages were AMD Adrenalin 26.9.1 and NVIDIA 616.64 WHQL.

Architecture Driver snapshot Products CPU-visible heap Required extensions
AMD RDNA 2 (dGPU) Windows / Adrenalin 26.9.1 RX 6000 ReBAR 🔴 Unsupported
AMD RDNA 2 (iGPU) Windows / Adrenalin 26.9.1 600M UMA 🔴 Unsupported
AMD RDNA 2 (iGPU) Linux / Mesa RADV 26.2+ Steam Deck UMA Supported
AMD RDNA 3 (dGPU) Windows / Adrenalin 26.9.1 RX 7000 ReBAR Supported
AMD RDNA 3 (iGPU) Windows / Adrenalin 26.9.1 700M UMA Supported
AMD RDNA 4 (dGPU) Windows / Adrenalin 26.9.1 RX 9000 ReBAR Supported
NVIDIA Turing Windows / NVIDIA 616.64 GTX 16 series 256MB Supported
NVIDIA Turing Windows / NVIDIA 616.64 RTX 20 series 256MB Supported
NVIDIA Ampere Windows / NVIDIA 616.64 RTX 30 series ReBAR Supported
NVIDIA Ada Lovelace Windows / NVIDIA 616.64 RTX 40 series ReBAR Supported
NVIDIA Blackwell Windows / NVIDIA 616.64 RTX 50 series ReBAR Supported

🔴 marks missing required extensions. Mapped heaps require coherent CPU-visible GPU memory. Enable PCIe ReBAR where available on discrete GPUs; integrated GPUs use UMA, with heap sizes depending on system configuration.

GPUs without PCIe ReBAR support provide up to 256 MB of CPU-visible data heap memory. NoGraphicsAPI can be used on these GPUs, but applications must minimize CPU-visible data. GPU-only heaps have no ReBAR-related size limit; use copy commands to copy data into GPU-only heaps. Texture heaps are unaffected by PCIe ReBAR.

The checked Windows RDNA 2 reports lack descriptor-heap support. Pascal / GTX 10 lacks the required extensions. Intel Windows support was not verified; the checked Arc report also lacks required extensions. Mesa RADV and ANV 26.2+ expose the required extensions on the reported Linux/SteamOS targets.

See known driver issues for observed problems and workarounds.

macOS installation and quick start

Install Xcode 26+ with its Metal compiler, CMake, and Slang 2026.18.2+. Build the examples and tests:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=macosx -DNOGRAPHICSAPI_BUILD_EXAMPLES=ON \
  -DNOGRAPHICSAPI_BUILD_TESTS=ON -DNOGRAPHICSAPI_SLANGC=/path/to/slangc
cmake --build build
ctest --test-dir build --output-on-failure
build/examples/triangle/example_triangle

See building and integration for iOS builds and Metal validation for known test limitations.

Windows installation and quick start

  1. Install Visual Studio 2022 with the Desktop development with C++ workload, including the Windows SDK. The supplied msvc preset targets Visual Studio 2022 x64.
  2. Install CMake 3.24+ and make cmake available on PATH.
  3. Install the Vulkan SDK 1.4.357+. Shader validation requires SPIRV-Tools 2026.3+; make the SDK's Bin directory, containing spirv-val.exe, available on PATH.
  4. Use Slang 2026.14.1+ from the Vulkan SDK, or download a standalone Windows x64 release, extract it, and add its bin directory to PATH.
  5. Install a GPU driver meeting the hardware requirements above. The Vulkan SDK does not replace the GPU driver.

Clone the repository or download its source archive, then open PowerShell in the repository directory. Configure, build, test, and run the triangle example:

cmake --preset msvc
cmake --build --preset msvc-release
ctest --preset msvc-release
.\build-msvc\examples\triangle\Release\example_triangle.exe

To open the generated solution in Visual Studio, use build-msvc/NoGraphicsAPI.sln. For a validation-enabled Debug build, use msvc-debug in the build and test commands.

If the shader tools are not on PATH, supply their locations when configuring. Adjust these example paths to your installations:

cmake --preset msvc -DNOGRAPHICSAPI_SLANGC=C:/Slang/2026.14.1/bin/slangc.exe -DNOGRAPHICSAPI_SPIRV_VAL=C:/VulkanSDK/1.4.357.0/Bin/spirv-val.exe

To install the Release libraries and headers locally:

cmake --install build-msvc --config Release --prefix ./install

The install includes the independent NoGraphicsAPI and NoGraphicsAPIUtility CMake packages. See building and integration for using them in your own project or building the library without examples and tests.

Examples

The executables are under build-msvc/examples/<example>/Release when using the supplied preset.

Documentation

License

NoGraphicsAPI and NoGraphicsAPIUtility use the MIT License. See third-party notices for bundled assets and dependencies.

NoGraphicsAPI (sebbbi/NoGraphicsAPI)

正在搜索数据库…

这是什么?NoGraphicsAPI 是对 Sebastian Aaltonen “无图形 API” 理念的一个实验性 Vulkan 1.4 实现,探索当着色器改用原始 64 位 GPU 指针而非缓冲对象和绑定时,传统图形 API 里有哪些东西随之消失。
它是游戏引擎,还是只是一个封装库?它是一个极简的底层 C++ 库——一层薄薄的 Vulkan 封装,没有引擎级抽象、描述符集或管线布局,并不是完整的引擎或框架。
怎么构建它?用 CMake 配置并构建;默认只构建 NoGraphicsAPI 和 NoGraphicsAPIUtility 这两个库,triangle、cube 和 deferredrenderer 示例应用以及测试需要你显式打开对应的开关。
构建之前需要装什么?CMake 3.24+、C++20 编译器,以及小端 x86-64 目标平台上 1.4.357 或更新版本的 Vulkan SDK 头文件/库;构建示例应用还需要 Slang 2026.14.1+ 和 SPIRV-Tools 2026.3+。
它能在我的任何 Vulkan GPU 上跑吗?不能——它需要一些较新的特定 Vulkan 扩展(描述符堆、设备地址命令、无类型指针、网格着色器),很多现有驱动都不具备;目前的 Windows RDNA2 驱动和 Turing 之前的 NVIDIA GPU 都不提供这些扩展。
除了 Windows,它也能在 Linux 上跑吗?自带的需要窗口呈现的示例应用目前只能在 Windows 上运行;无头库可以在其他平台上用 GNU/Clang 编译,但 Linux/SteamOS 的窗口呈现还没实现。
它需要什么样的显存?它需要 CPU 可见的连贯 GPU 内存——独立显卡走 PCIe ReBAR,核显走 UMA——另外还需要兼容的设备本地内存来放缓冲区和纹理。
三个示例应用分别是什么?Triangle 是最小的顶点/片元绘制与呈现路径;cube 展示基于类型化 GPU 指针的顶点获取和由应用管理的纹理/采样器堆;deferredrenderer 跑一个多通道 GPU 计算加网格着色器的工作负载,用基于指针的场景数据和由 timeline 管理的 CPU/GPU 重叠。
除 Vulkan 之外还支持 Metal 吗?不支持,Metal 支持没有实现。文档里记录了一个拟议的 Metal 4 映射方案和它的未决问题,但今天真正能用的只有 Vulkan 后端。
为什么没有描述符集和管线布局?这个设计用 64 位 GPU 指针和应用自管理的描述符堆取代了传统绑定,所以后端根本不会创建 VkDescriptorSetLayout、VkDescriptorPool、VkDescriptorSet 或 VkPipelineLayout。
不用常量缓冲区的话,数据怎么传给着色器?一个小的共享 C++/Slang 根结构体在每次绘制或 dispatch 时经 vkCmdPushDataEXT 推送;它的指针字段携带 GPU 地址,普通值则直接复制,而且根结构体不必在调用结束后继续存活。
有哪些类似的项目?Jet, taskflow, dxvk, bgfx, spirula-studio, Vulkan, hells-gate-recomp, sokol
作者
sebbbi
大小
0.8 MB
星标
1.7K
更新
提交Oct 19
时长
3个月
提交 · 90 天