Skip to content

Commit 541a3f9

Browse files
gracicotkainino0x
andauthored
Fix webgpu warning when configuring swapchain on canvas (#17421)
* Fix webgpu warning when configuring swapchain on canvas * Set the width and height directly to the canvas * Only set canvas size when not zero * style nit for closure Co-authored-by: Guillaume Racicot <grc@pixmob.com> Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
1 parent 9a0a4bc commit 541a3f9

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/library_webgpu.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,15 +2551,25 @@ var LibraryWebGPU = {
25512551
{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.presentMode) }}});
25522552
#endif
25532553

2554+
var canvasSize = [
2555+
{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.width) }}},
2556+
{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.height) }}}
2557+
];
2558+
2559+
if (canvasSize[0] !== 0) {
2560+
context["canvas"]["width"] = canvasSize[0];
2561+
}
2562+
2563+
if (canvasSize[1] !== 0) {
2564+
context["canvas"]["height"] = canvasSize[1];
2565+
}
2566+
25542567
var configuration = {
25552568
"device": device,
25562569
"format": WebGPU.TextureFormat[
25572570
{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.format) }}}],
25582571
"usage": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.usage) }}},
2559-
"size": [
2560-
{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.width) }}},
2561-
{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.height) }}},
2562-
],
2572+
"alphaMode": "opaque",
25632573
};
25642574
context["configure"](configuration);
25652575

0 commit comments

Comments
 (0)