Skip to content

rename string-number map to avoid override #21032

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

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,21 @@ var LibraryWebGPU = {
},

// Map from enum string back to enum number, for callbacks.
BufferMapState: {
Int_BufferMapState: {
'unmapped': 0,
'pending': 1,
'mapped': 2,
},
CompilationMessageType : {
Int_CompilationMessageType : {
'error': 0,
'warning': 1,
'info': 2,
},
DeviceLostReason: {
Int_DeviceLostReason: {
'undefined': 0,
'destroyed': 1,
},
PreferredFormat: {
Int_PreferredFormat: {
'rgba8unorm': 0x12,
'bgra8unorm': 0x17,
},
Expand Down Expand Up @@ -1812,7 +1812,7 @@ var LibraryWebGPU = {
messageStringPtrs.push(messagePtr);
stringToUTF8(compilationMessage.message, messagePtr, messageSize);
{{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.message, 'messagePtr', '*') }}};
{{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.type, 'WebGPU.CompilationMessageType[compilationMessage.type]', 'i32') }}};
{{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.type, 'WebGPU.Int_CompilationMessageType[compilationMessage.type]', 'i32') }}};
{{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.lineNum, 'compilationMessage.lineNum', 'i64') }}};
{{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.linePos, 'compilationMessage.linePos', 'i64') }}};
{{{ makeSetValue('compilationMessagePtr', C_STRUCTS.WGPUCompilationMessage.offset, 'compilationMessage.offset', 'i64') }}};
Expand Down Expand Up @@ -1909,7 +1909,7 @@ var LibraryWebGPU = {

wgpuBufferGetMapState: (bufferId) => {
var buffer = WebGPU.mgrBuffer.get(bufferId);
return WebGPU.BufferMapState[buffer.mapState];
return WebGPU.Int_BufferMapState[buffer.mapState];
},

// In webgpu.h offset and size are passed in as size_t.
Expand Down Expand Up @@ -2577,7 +2577,7 @@ var LibraryWebGPU = {
if (deviceLostCallbackPtr) {
device["lost"].then((info) => {
callUserCallback(() => WebGPU.errorCallback(deviceLostCallbackPtr,
WebGPU.DeviceLostReason[info.reason], info.message, deviceLostUserdataPtr));
WebGPU.Int_DeviceLostReason[info.reason], info.message, deviceLostUserdataPtr));
});
}
{{{ makeDynCall('vippp', 'callback') }}}({{{ gpu.RequestDeviceStatus.Success }}}, deviceId, 0, userdata);
Expand All @@ -2604,7 +2604,7 @@ var LibraryWebGPU = {

wgpuSurfaceGetPreferredFormat: (surfaceId, adapterId) => {
var format = navigator["gpu"]["getPreferredCanvasFormat"]();
return WebGPU.PreferredFormat[format];
return WebGPU.Int_PreferredFormat[format];
},

// WGPUSwapChain
Expand Down