[dawn][emscripten] Removes SwapChain remnants in Emscripten bindings.
- Since SwapChain stuff was removed in
https://dawn-review.googlesource.com/c/dawn/+/208994,
update the Emscripten bindings to reflect the changes.
- Needed for Dawn->google3 roll since the Emscripten bindings are
broken without this update.
Change-Id: Id65f14823ad91286cef194afadf13e03ff1e2858
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/209595
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/third_party/emdawnwebgpu/library_webgpu.js b/third_party/emdawnwebgpu/library_webgpu.js
index 2aa72d7..8cbd00d 100644
--- a/third_party/emdawnwebgpu/library_webgpu.js
+++ b/third_party/emdawnwebgpu/library_webgpu.js
@@ -517,6 +517,11 @@
},
#endif
+ emwgpuGetPreferredFormat: () => {
+ var format = navigator["gpu"]["getPreferredCanvasFormat"]();
+ return WebGPU.Int_PreferredFormat[format];
+ },
+
// --------------------------------------------------------------------------
// WebGPU function definitions, with methods organized by "class".
//
@@ -1665,44 +1670,6 @@
return ptr;
},
- wgpuDeviceCreateSwapChain__deps: ['emwgpuCreateSwapChain'],
- wgpuDeviceCreateSwapChain: (devicePtr, surfacePtr, descriptor) => {
- {{{ gpu.makeCheckDescriptor('descriptor') }}}
- var device = WebGPU._tableGet(devicePtr);
- var context = WebGPU._tableGet(surfacePtr);
-
-#if ASSERTIONS
- assert({{{ gpu.PresentMode.Fifo }}} ===
- {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.presentMode) }}});
-#endif
-
- var canvasSize = [
- {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.width) }}},
- {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.height) }}}
- ];
-
- if (canvasSize[0] !== 0) {
- context["canvas"]["width"] = canvasSize[0];
- }
-
- if (canvasSize[1] !== 0) {
- context["canvas"]["height"] = canvasSize[1];
- }
-
- var configuration = {
- "device": device,
- "format": WebGPU.TextureFormat[
- {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.format) }}}],
- "usage": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.usage) }}},
- "alphaMode": "opaque",
- };
- context.configure(configuration);
-
- var ptr = _emwgpuCreateSwapChain();
- WebGPU._tableInsert(ptr, context);
- return ptr;
- },
-
wgpuDeviceCreateTexture__deps: ['emwgpuCreateTexture'],
wgpuDeviceCreateTexture: (devicePtr, descriptor) => {
{{{ gpu.makeCheckDescriptor('descriptor') }}}
@@ -2386,11 +2353,6 @@
}
},
- wgpuSurfaceGetPreferredFormat: (surfacePtr, adapterPtr) => {
- var format = navigator["gpu"]["getPreferredCanvasFormat"]();
- return WebGPU.Int_PreferredFormat[format];
- },
-
wgpuSurfacePresent: (surfacePtr) => {
// TODO: This could probably be emulated with ASYNCIFY.
abort('wgpuSurfacePresent is unsupported (use requestAnimationFrame via html5.h instead)');
@@ -2402,31 +2364,6 @@
},
// --------------------------------------------------------------------------
- // Methods of SwapChain
- // --------------------------------------------------------------------------
-
- wgpuSwapChainGetCurrentTexture__deps: ['emwgpuCreateTexture'],
- wgpuSwapChainGetCurrentTexture: (swapChainPtr) => {
- var context = WebGPU._tableGet(swapChainPtr);
- var ptr = _emwgpuCreateTexture();
- WebGPU._tableInsert(ptr, context.getCurrentTexture());
- return ptr;
- },
-
- wgpuSwapChainGetCurrentTextureView__deps: ['emwgpuCreateTextureView'],
- wgpuSwapChainGetCurrentTextureView: (swapChainPtr) => {
- var context = WebGPU._tableGet(swapChainPtr);
- var ptr = _emwgpuCreateTextureView();
- WebGPU._tableInsert(ptr, context.getCurrentTexture().createView());
- return ptr;
- },
-
- wgpuSwapChainPresent: (swapChainPtr) => {
- // TODO: This could probably be emulated with ASYNCIFY.
- abort('wgpuSwapChainPresent is unsupported (use requestAnimationFrame via html5.h instead)');
- },
-
- // --------------------------------------------------------------------------
// Methods of Texture
// --------------------------------------------------------------------------
diff --git a/third_party/emdawnwebgpu/webgpu.cpp b/third_party/emdawnwebgpu/webgpu.cpp
index 850b4a6..efc9a98 100644
--- a/third_party/emdawnwebgpu/webgpu.cpp
+++ b/third_party/emdawnwebgpu/webgpu.cpp
@@ -39,6 +39,7 @@
FutureID emwgpuWaitAny(FutureID const* futurePtr,
size_t futureCount,
uint64_t const* timeoutNSPtr);
+WGPUTextureFormat emwgpuGetPreferredFormat();
// Future/async operation that need to be forwarded to JS.
void emwgpuAdapterRequestDevice(WGPUAdapter adapter,
@@ -251,7 +252,6 @@
X(Sampler) \
X(ShaderModule) \
X(Surface) \
- X(SwapChain) \
X(Texture) \
X(TextureView)
@@ -275,7 +275,6 @@
X(Sampler) \
X(ShaderModule) \
X(Surface) \
- X(SwapChain) \
X(Texture) \
X(TextureView)
// clang-format on
@@ -1292,7 +1291,7 @@
WGPUTextureFormat_RGBA8Unorm,
WGPUTextureFormat_RGBA16Float,
};
- WGPUTextureFormat preferredFormat = wgpuSurfaceGetPreferredFormat(surface, adapter);
+ WGPUTextureFormat preferredFormat = emwgpuGetPreferredFormat();
switch (preferredFormat) {
case WGPUTextureFormat_RGBA8Unorm:
capabilities->formatCount = kSurfaceFormatsRGBAFirst.size();
@@ -1326,10 +1325,6 @@
}
// ----------------------------------------------------------------------------
-// Methods of SwapChain
-// ----------------------------------------------------------------------------
-
-// ----------------------------------------------------------------------------
// Methods of Texture
// ----------------------------------------------------------------------------