emdawnwebgpu: support Premultiplied canvas output
Port of this Emscripten fix into emdawnwebgpu:
https://github.com/emscripten-core/emscripten/pull/22494/files
Bug: https://github.com/emscripten-core/emscripten/issues/22491
Change-Id: Id3ed385d47ce2045d20e61f31e890a6f459ffb88
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/205075
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json
index 60bdaab7..10a534f 100644
--- a/src/dawn/dawn.json
+++ b/src/dawn/dawn.json
@@ -1250,7 +1250,7 @@
"composite alpha mode": {
"category": "enum",
"values": [
- {"value": 0, "name": "auto"},
+ {"value": 0, "name": "auto", "jsrepr": "undefined"},
{"value": 1, "name": "opaque"},
{"value": 2, "name": "premultiplied"},
{"value": 3, "name": "unpremultiplied"},
diff --git a/third_party/emdawnwebgpu/library_webgpu.js b/third_party/emdawnwebgpu/library_webgpu.js
index 10d6aab..0c5e132 100644
--- a/third_party/emdawnwebgpu/library_webgpu.js
+++ b/third_party/emdawnwebgpu/library_webgpu.js
@@ -2364,10 +2364,6 @@
var viewFormatCount = {{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.viewFormatCount) }}};
var viewFormats = {{{ makeGetValue('config', C_STRUCTS.WGPUSurfaceConfiguration.viewFormats, '*') }}};
assert(viewFormatCount === 0 && viewFormats === 0, "TODO: Support viewFormats.");
- var alphaMode = {{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.alphaMode) }}};
- assert(alphaMode === {{{ gpu.CompositeAlphaMode.Auto }}} ||
- alphaMode === {{{ gpu.CompositeAlphaMode.Opaque }}},
- "TODO: Support WGPUCompositeAlphaMode_Premultiplied.");
assert({{{ gpu.PresentMode.Fifo }}} ===
{{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.presentMode) }}});
#endif
@@ -2390,7 +2386,8 @@
"format": WebGPU.TextureFormat[
{{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.format) }}}],
"usage": {{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.usage) }}},
- "alphaMode": "opaque",
+ "alphaMode": WebGPU.CompositeAlphaMode[
+ {{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.alphaMode) }}}],
};
context.configure(configuration);
},