-
Notifications
You must be signed in to change notification settings - Fork 2k
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
base: main
Are you sure you want to change the base?
SDL3 GPU WebGPU Backend #12046
Changes from 2 commits
850caed
35afb6e
fd2e2f5
b5b0b4e
37d08d1
34f0a47
c380e4d
df19be0
7605ea7
9496c2e
478b4cd
ee68d05
abae635
9b8e259
cecebf8
fd085f6
4fe10d0
8a42bb4
51a5c38
cb91daf
140802a
bcdc2d5
9e6dc5a
5565a59
f967732
467c870
c21747f
58e6140
d570ca5
11d8ef7
8d601ec
a385d47
c226ca5
2b22917
e24094d
c1d8428
d2fbc02
09523e4
8e72939
bc4a11c
0533e73
8fabcca
56f9a9c
1f669f7
9c1875c
60e2d73
85b992d
8521e4e
733354f
2f7f0eb
01b4880
70d2269
3f8682b
e93956d
a37c1c6
0c33fad
600bff2
283c5b9
bca377b
5a0099a
ea6f5fb
8fa803d
923b925
07fcef4
585b68a
3d39bb9
c0fb4a5
4e92ba2
abf5db8
dd64914
0b3b440
ebb99a2
7960aa3
1cfb6af
3988cd3
2dcd6c7
2b4838b
dbc8855
3ee7c13
e861a1e
f61a114
0a941ea
a4845c4
ef1788b
30bbcee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2025 Sam Lantinga <[email protected]> | ||
|
||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
arising from the use of this software. | ||
|
||
Permission is granted to anyone to use this software for any purpose, | ||
including commercial applications, and to alter it and redistribute it | ||
freely, subject to the following restrictions: | ||
|
||
1. The origin of this software must not be misrepresented; you must not | ||
claim that you wrote the original software. If you use this software | ||
in a product, an acknowledgment in the product documentation would be | ||
appreciated but is not required. | ||
2. Altered source versions must be plainly marked as such, and must not be | ||
misrepresented as being the original software. | ||
3. This notice may not be removed or altered from any source distribution. | ||
*/ | ||
|
||
// File: /webgpu/SDL_gpu_webgpu.c | ||
// Author: Kyle Lukaszek | ||
// Email: kylelukaszek [at] gmail [dot] com | ||
|
@@ -1966,11 +1987,6 @@ static SDL_GPUCommandBuffer *WebGPU_AcquireCommandBuffer(SDL_GPURenderer *driver | |
commandBuffer->renderer = renderer; | ||
commandBuffer->common.device = renderer->sdlDevice; | ||
|
||
int width, height; | ||
SDL_GetWindowSize(renderer->claimedWindows[0]->window, &width, &height); | ||
commandBuffer->currentViewport = (WebGPUViewport){ 0, 0, width, height, 0.0, 1.0 }; | ||
commandBuffer->currentScissor = (WebGPURect){ 0, 0, width, height }; | ||
|
||
SDL_zero(commandBuffer->layerViews); | ||
commandBuffer->layerViewCount = 0; | ||
|
||
|
@@ -2090,6 +2106,11 @@ void WebGPU_BeginRenderPass(SDL_GPUCommandBuffer *commandBuffer, | |
return; | ||
} | ||
|
||
int width, height; | ||
SDL_GetWindowSize(wgpu_cmd_buf->renderer->claimedWindows[0]->window, &width, &height); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still not right, the viewport and scissor should be set to the smallest size of bound render targets. Please reference how the other backends implemented this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I get it now! I'll return to this after some rest I think. I read up on the Vulkan implementation and will follow that one tomorrow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link: e24094d It's still not 1-to-1 with the Vulkan backend but the viewport and scissor now use the smallest available size of all bound render targets. It also now sets the other default states for the render pass. |
||
wgpu_cmd_buf->currentViewport = (WebGPUViewport){ 0, 0, width, height, 0.0, 1.0 }; | ||
wgpu_cmd_buf->currentScissor = (WebGPURect){ 0, 0, width, height }; | ||
|
||
// Handle color attachments | ||
WGPURenderPassColorAttachment colorAttachments[colorAttachmentCount]; | ||
for (uint32_t i = 0; i < colorAttachmentCount; i++) { | ||
|
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.
Please include the standard text from https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_copying.h and add any copyright attribution you'd like here.
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.
Link: a385d47