-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL3 GPU WebGPU Backend #12046
Open
klukaszek
wants to merge
41
commits into
libsdl-org:main
Choose a base branch
from
klukaszek:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
SDL3 GPU WebGPU Backend #12046
Changes from 30 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
850caed
Nuked my repo due to it being 600 commits ahead of upstream even thou…
klukaszek 35afb6e
Got Point, Linear, and Aniso samplers working with Clamp and Repeat
klukaszek fd2e2f5
Began work on PushVertexUniformData. Investigated bug where certain G…
klukaszek b5b0b4e
Cleaned up logging in preparation for managing Uniform Buffers.
klukaszek 37d08d1
Refactored buffer and texture data structures to be more simple as th…
klukaszek 34f0a47
PushVertexUniformData() and PushFragmentUniformData() no longer cause…
klukaszek c380e4d
Fixed SDLToWGPUTextureUsageFlags() to properly handle bit flags inste…
klukaszek df19be0
Working on getting WebGPU_Blit() ready for implementation by solving …
klukaszek 7605ea7
Implemented simple miscellaneous functions to knock them off of the c…
klukaszek 9496c2e
Trying to get array layers working for 3D textures since WebGPU only …
klukaszek 478b4cd
Implemented a blitting pipeline for WebGPU since there is no blit fun…
klukaszek ee68d05
Refactored to use SDL_GPU_BlitCommon instead of writing my own WebGPU…
klukaszek abae635
Made more progess on 2D texture array blitting. Now I need to investi…
klukaszek 9b8e259
Refactored several calls to SDL_malloc to SDL_stack_alloc if data is …
klukaszek cecebf8
Feat: Added stencil reference adjustment
klukaszek fd085f6
Feat: Got BlitCube example working
klukaszek 4fe10d0
Refactor: Eliminated many unnecessary dynamic memory allocations. Far…
klukaszek 8a42bb4
Removed print statements that angered different test pipelines.
klukaszek 51a5c38
Misc: Moved SDL3 WebGPU Checklist to src/gpu/webgpu/
klukaszek cb91daf
Misc: Moved SDL3 WebGPU Checklist to src/gpu/webgpu/
klukaszek 140802a
Misc: Added SDL3 GPU ReadMe
klukaszek bcdc2d5
Misc: Added SDL3 GPU ReadMe
klukaszek 9e6dc5a
Misc: Updated emscripten's version for the test pipeline.
klukaszek 5565a59
Misc: Updated emscripten's version for the test pipeline.
klukaszek f967732
Misc: trying to get Emscripten test pipeline working.
klukaszek 467c870
Fix: Rebased with upstream and solved a recently implemented bug with…
klukaszek c21747f
Feat: Made swapchain a static allocation.
klukaszek 58e6140
Refactor: Removed Emscripten specific Swapchain logic. Now I manually…
klukaszek d570ca5
Feat: Implemented indirect drawing support for WebGPU.
klukaszek 11d8ef7
Refactor: Added explicit loop termination while waiting for the devic…
klukaszek 8d601ec
Refactor: Setting of viewport and scissor is done in WebGPU_BeginRend…
klukaszek a385d47
Misc: Added standard text to top of file.
klukaszek c226ca5
Misc: Changed some imports.
klukaszek 2b22917
Misc: Changed some more imports.
klukaszek e24094d
Refactor: Changed default renderpass state initialization to better m…
klukaszek c1d8428
Refactor: Removed ~0u conversion as I had forgotten that I had resolv…
klukaszek d2fbc02
Refactor: Moved SDL_internal.h to the very top
klukaszek 09523e4
Refactor: Started implementing fencing properly.
klukaszek 8e72939
Refactor: Added fence pool and associated internal functions.
klukaszek bc4a11c
Refactor: Added uniform buffer pool.
klukaszek 0533e73
Refactor: Implemented placeholder fencing logic. Has not actually bee…
klukaszek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SDL3 GPU WebGPU Backend | ||
Status: Work In Progress | ||
|
||
Author: Kyle Lukaszek | ||
|
||
## Compiling with Emscripten | ||
**Emscripten version 3.1.69+ is required to make use of SDL3 WebGPU.** | ||
**There is an issue with Emscripten versions (>=3.1.65 & < 3.1.69) that breaks buffer copying** | ||
|
||
To clone and build SDL WebGPU from source: | ||
``` | ||
git clone https://github.com/klukaszek/SDL | ||
cd SDL | ||
mkdir build | ||
cd build | ||
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release -DSDL_WEBGPU=ON -DSDL_RENDER_WEBGPU=ON | ||
cmake --build . --config Release --parallel | ||
sudo cmake --install . --config Release | ||
``` | ||
|
||
To clone and build examples: | ||
``` | ||
git clone https://github.com/klukaszek/SDL3-WebGPU-Examples | ||
cd SDL3-WebGPU-Examples | ||
git submodule update --init | ||
git submodule update --remote | ||
mkdir build | ||
cd build | ||
emcmake cmake .. -DSDL3_DIR="full/path/to/SDL/build" | ||
make | ||
``` | ||
|
||
You can also provide the `-GNinja` flag to any of the `emcmake` commands to use Ninja instead of Make. | ||
|
||
## More Info | ||
|
||
- See checklist for a list of completed SDL3 API functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# SDL WebGPU Driver Roadmap / Checklist | ||
|
||
These methods are tested by the example suite: | ||
- https://github.com/klukaszek/SDL3-WebGPU-Examples | ||
|
||
Getting my fork of the example suite merged with the original shouldn't be too much work but it needs to tested first. | ||
|
||
The original example suite can be found at: | ||
- https://github.com/TheSpydog/SDL_gpu_examples/ | ||
|
||
Currently, the WebGPU backend only supports Emscripten as the compilation target, though I've added Elie Michel's cross-platform surface configuration logic to the backend. I have not tested it with any native implementations however. | ||
|
||
# Checklist | ||
|
||
## General | ||
- [x] DestroyDevice | ||
- [x] SupportsPresentMode | ||
- [x] ClaimWindow | ||
- [x] ReleaseWindow | ||
|
||
## Swapchains | ||
- [x] SetSwapchainParameters | ||
- [x] SupportsTextureFormat | ||
- [x] SupportsSampleCount | ||
- [x] SupportsSwapchainComposition | ||
|
||
## Command Buffers and Fences | ||
- [x] AcquireCommandBuffer | ||
- [x] AcquireSwapchainTexture | ||
- [x] GetSwapchainTextureFormat | ||
- [x] Submit | ||
- [x] SubmitAndAcquireFence (Should just call Submit) | ||
- [x] Cancel (Should be no-op for WebGPU) | ||
- [x] Wait (Should be no-op for WebGPU) | ||
- [x] WaitForFences (Should be no-op for WebGPU) | ||
- [x] QueryFence (Should be no-op for WebGPU) | ||
- [x] ReleaseFence (Should be no-op for WebGPU) | ||
|
||
Note: WebGPU has no exposed fence API. | ||
|
||
## Buffers | ||
- [x] CreateBuffer | ||
- [x] ReleaseBuffer | ||
- [x] SetBufferName | ||
- [x] CreateTransferBuffer | ||
- [x] ReleaseTransferBuffer | ||
- [x] MapTransferBuffer | ||
- [x] UnmapTransferBuffer | ||
- [x] UploadToBuffer | ||
- [x] DownloadFromBuffer | ||
- [x] CopyBufferToBuffer | ||
|
||
## Textures | ||
- [x] CreateTexture | ||
- [x] ReleaseTexture | ||
- [x] SetTextureName | ||
- [x] UploadToTexture | ||
- [x] DownloadFromTexture (needs to be tested) | ||
- [x] CopyTextureToTexture (needs to be tested) | ||
- [ ] GenerateMipmaps | ||
- Requires custom compute pipeline implementation. | ||
- https://eliemichel.github.io/LearnWebGPU/basic-compute/image-processing/mipmap-generation.html | ||
|
||
## Samplers | ||
- [x] CreateSampler | ||
- [x] ReleaseSampler | ||
|
||
## Debugging | ||
- [x] InsertDebugLabel | ||
- [x] PushDebugGroup | ||
- [x] PopDebugGroup | ||
|
||
## Graphics Pipelines | ||
- [x] CreateGraphicsPipeline | ||
- [x] BindGraphicsPipeline | ||
- [x] ReleaseGraphicsPipeline | ||
|
||
## Compute Pipelines | ||
- [ ] CreateComputePipeline | ||
- [ ] BindComputePipeline | ||
- [ ] ReleaseComputePipeline | ||
|
||
## Shaders | ||
- [x] CreateShader | ||
- [x] ReleaseShader | ||
|
||
## Rendering | ||
- [x] BeginRenderPass | ||
- [x] EndRenderPass | ||
- [x] DrawPrimitivesIndirect | ||
- [x] DrawPrimitives | ||
- [x] DrawIndexedPrimitives | ||
- [x] DrawIndexedPrimitivesIndirect | ||
|
||
## Copy Passes | ||
- [x] BeginCopyPass | ||
- [x] EndCopyPass | ||
|
||
## Compute Passes | ||
- [ ] BeginComputePass | ||
- [ ] EndComputePass | ||
- [ ] DispatchCompute | ||
- [ ] DispatchComputeIndirect | ||
- [ ] BindComputeSamplers | ||
- [ ] BindComputeStorageTextures | ||
- [ ] BindComputeStorageBuffers | ||
- [ ] PushComputeUniformData | ||
|
||
## Fragment Stage | ||
- [x] BindFragmentSamplers | ||
- [ ] BindFragmentStorageTextures | ||
- [ ] BindFragmentStorageBuffers | ||
- [ ] PushFragmentUniformData | ||
- Needs to be rewritten. | ||
|
||
## Vertex Stage | ||
- [x] BindVertexBuffers | ||
- [x] BindIndexBuffer | ||
- [x] BindVertexSamplers | ||
- [ ] BindVertexStorageTextures | ||
- [ ] BindVertexStorageBuffers | ||
- [ ] PushVertexUniformData | ||
- Needs to be rewritten. | ||
|
||
## Rendering States | ||
- [x] SetViewport | ||
- [x] SetScissor | ||
- [x] SetBlendConstants | ||
- [x] SetStencilReference | ||
|
||
## Composition | ||
- [ ] Blit | ||
- Mostly functional. | ||
- Bug: Example "Blit2DArray.c" has a sampler issue where the RHS is not downsampled. | ||
- Bug: Example "TriangleMSAA.c" does not cycle between different sample counts. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect #include