mach icon indicating copy to clipboard operation
mach copied to clipboard

sysgpu: supersede WebGPU with new sysgpu graphics API

Open emidoots opened this issue 2 years ago • 6 comments

This is a tracking issue for ongoing development of Dusk. Dusk started as a WGPU implementation (and is one today) but is being developed beyond that, into a new graphics API called DGPU. We are making some key changes to the WGPU API, for specific reasons, and this issue is for tracking those changes / decisions.

Proposals / decisions made:

  • WebGPU API divergences
    • ✅ Native render graph support
    • ✅ Remove next_in_chain
    • ✅ All Mach and Dawn extensions become non-extensions (just become part of the API) if desirable
    • D3D StructuredBuffers
    • Streaming Uniforms
  • Shading language divergences
    • ✅ Remove WGSL support in favor of Zig-inspired shading language
    • ✅ Explicit adapter enumeration/selection
  • Goals
    • ✅ First-class C API support
    • ✅ Ability to intercept API calls / wrap implementation in Zig (like gpu.Interface)
    • ✅ Backends:
      • Direct3D 12
      • Vulkan (1.0?)
      • Metal
      • WebGPU (Dawn native fallback, browser)

Things worth considering if we can improve:

emidoots avatar Oct 05 '23 03:10 emidoots

Will Mach still run in browsers that only support native WGPU?

mateli avatar Oct 05 '23 07:10 mateli

Yes, DGPU will have a WebGPU backend

emidoots avatar Oct 05 '23 15:10 emidoots

Two changes I would like to add to the list:

D3D StructuredBuffers

  • WebGPU implementation requires use of ByteAddressBuffer
  • StructuredBuffer is faster on many GPUs (see https://github.com/sebbbi/perftest) but requires stride be specified in the binding layout

Streaming Uniforms

  • WebGPU cannot make use of Push/Root Constants or Metal set buffer bytes (although this is being discussed as an explicit feature for later versions)
  • We can expose a higher-level API for updating uniforms on the encoder
  • This simplifies application use (no need to manage dynamic offsets on bind groups) and enables use of these features in the backend

pdoane avatar Oct 07 '23 02:10 pdoane

Vertex/Fragment linkage

HLSL vertex-fragment linkage requires stage variables to be in the same order, and all variables in the later stage must be present in the earlier stage. When HLSL is generated at pipeline generation time, input/output structs can be sorted and unused vertex outputs eliminated. Offline compilation will require the shaders to match.

pdoane avatar Oct 11 '23 00:10 pdoane

Optional Input Assembler

D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT should not be passed for root signatures unless needed. Add a flag to PipelineLayout to indicate that vertex buffers are used by the pipeline.

pdoane avatar Oct 11 '23 00:10 pdoane

MSAA Depth Resolve

Add support for MSAA depth targets in render passes

pdoane avatar Oct 11 '23 00:10 pdoane