Skip to content

Commit 1c56165

Browse files
kainino0xjankrassnigg
authored andcommitted
[emdawnwebgpu] Port forward wgpuSurfaceConfigure viewFormats fix
From emscripten-core/emscripten#22961 Co-authored-by: Jan Krassnigg <[email protected]> No-Try: true Change-Id: I292829616a7dac543a9500847a7112af4487afcb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/215834 Reviewed-by: Loko Kung <[email protected]> Commit-Queue: Kai Ninomiya <[email protected]>
1 parent 839eadc commit 1c56165

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

third_party/emdawnwebgpu/library_webgpu.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,8 +1728,8 @@ var LibraryWebGPU = {
17281728
if (viewFormatCount) {
17291729
var viewFormatsPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUTextureDescriptor.viewFormats, '*') }}};
17301730
// viewFormatsPtr pointer to an array of TextureFormat which is an enum of size uint32_t
1731-
desc["viewFormats"] = Array.from({{{ makeHEAPView('32', 'viewFormatsPtr', `viewFormatsPtr + viewFormatCount * 4`) }}},
1732-
function(format) { return WebGPU.TextureFormat[format]; });
1731+
desc['viewFormats'] = Array.from({{{ makeHEAPView('32', 'viewFormatsPtr', 'viewFormatsPtr + viewFormatCount * 4') }}},
1732+
format => WebGPU.TextureFormat[format]);
17331733
}
17341734

17351735
var device = WebGPU.getJsObject(devicePtr);
@@ -2336,9 +2336,6 @@ var LibraryWebGPU = {
23362336
var context = WebGPU.getJsObject(surfacePtr);
23372337

23382338
#if ASSERTIONS
2339-
var viewFormatCount = {{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.viewFormatCount) }}};
2340-
var viewFormats = {{{ makeGetValue('config', C_STRUCTS.WGPUSurfaceConfiguration.viewFormats, '*') }}};
2341-
assert(viewFormatCount === 0 && viewFormats === 0, "TODO: Support viewFormats.");
23422339
assert({{{ gpu.PresentMode.Fifo }}} ===
23432340
{{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.presentMode) }}});
23442341
#endif
@@ -2364,6 +2361,15 @@ var LibraryWebGPU = {
23642361
"alphaMode": WebGPU.CompositeAlphaMode[
23652362
{{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.alphaMode) }}}],
23662363
};
2364+
2365+
var viewFormatCount = {{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.viewFormatCount) }}};
2366+
if (viewFormatCount) {
2367+
var viewFormatsPtr = {{{ makeGetValue('config', C_STRUCTS.WGPUSurfaceConfiguration.viewFormats, '*') }}};
2368+
// viewFormatsPtr pointer to an array of TextureFormat which is an enum of size uint32_t
2369+
configuration['viewFormats'] = Array.from({{{ makeHEAPView('32', 'viewFormatsPtr', 'viewFormatsPtr + viewFormatCount * 4') }}},
2370+
format => WebGPU.TextureFormat[format]);
2371+
}
2372+
23672373
context.configure(configuration);
23682374
},
23692375

0 commit comments

Comments
 (0)