mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 13:00:28 +00:00
wgpu: update to v22.1.0.1
This commit is contained in:
4
vendor/wgpu/README.md
vendored
4
vendor/wgpu/README.md
vendored
@@ -11,8 +11,8 @@ Have a look at the `example/` directory for the rendering of a basic triangle.
|
||||
## Getting the wgpu-native libraries
|
||||
|
||||
For native support (not the browser), some libraries are required. Fortunately this is
|
||||
extremely easy, just download them from the [releases on GitHub](https://github.com/gfx-rs/wgpu-native/releases/tag/v0.19.4.1),
|
||||
the bindings are for v0.19.4.1 at the moment.
|
||||
extremely easy, just download them from the [releases on GitHub](https://github.com/gfx-rs/wgpu-native/releases/tag/v22.1.0.1),
|
||||
the bindings are for v22.1.0.1 at the moment.
|
||||
|
||||
These are expected in the `lib` folder under the same name as they are released (just unzipped).
|
||||
By default it will look for a static release version (`wgpu-OS-ARCH-release.a|lib`),
|
||||
|
||||
4
vendor/wgpu/examples/glfw/main.odin
vendored
4
vendor/wgpu/examples/glfw/main.odin
vendored
@@ -158,15 +158,17 @@ frame :: proc "c" (dt: f32) {
|
||||
view = frame,
|
||||
loadOp = .Clear,
|
||||
storeOp = .Store,
|
||||
depthSlice = wgpu.DEPTH_SLICE_UNDEFINED,
|
||||
clearValue = { 0, 1, 0, 1 },
|
||||
},
|
||||
},
|
||||
)
|
||||
defer wgpu.RenderPassEncoderRelease(render_pass_encoder)
|
||||
|
||||
wgpu.RenderPassEncoderSetPipeline(render_pass_encoder, state.pipeline)
|
||||
wgpu.RenderPassEncoderDraw(render_pass_encoder, vertexCount=3, instanceCount=1, firstVertex=0, firstInstance=0)
|
||||
|
||||
wgpu.RenderPassEncoderEnd(render_pass_encoder)
|
||||
wgpu.RenderPassEncoderRelease(render_pass_encoder)
|
||||
|
||||
command_buffer := wgpu.CommandEncoderFinish(command_encoder, nil)
|
||||
defer wgpu.CommandBufferRelease(command_buffer)
|
||||
|
||||
4
vendor/wgpu/examples/sdl2/main.odin
vendored
4
vendor/wgpu/examples/sdl2/main.odin
vendored
@@ -158,15 +158,17 @@ frame :: proc "c" (dt: f32) {
|
||||
view = frame,
|
||||
loadOp = .Clear,
|
||||
storeOp = .Store,
|
||||
depthSlice = wgpu.DEPTH_SLICE_UNDEFINED,
|
||||
clearValue = { 0, 1, 0, 1 },
|
||||
},
|
||||
},
|
||||
)
|
||||
defer wgpu.RenderPassEncoderRelease(render_pass_encoder)
|
||||
|
||||
wgpu.RenderPassEncoderSetPipeline(render_pass_encoder, state.pipeline)
|
||||
wgpu.RenderPassEncoderDraw(render_pass_encoder, vertexCount=3, instanceCount=1, firstVertex=0, firstInstance=0)
|
||||
|
||||
wgpu.RenderPassEncoderEnd(render_pass_encoder)
|
||||
wgpu.RenderPassEncoderRelease(render_pass_encoder)
|
||||
|
||||
command_buffer := wgpu.CommandEncoderFinish(command_encoder, nil)
|
||||
defer wgpu.CommandBufferRelease(command_buffer)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
187
vendor/wgpu/wgpu.js
vendored
187
vendor/wgpu/wgpu.js
vendored
@@ -44,6 +44,7 @@ class WebGPUInterface {
|
||||
BlendFactor: ["zero", "one", "src", "one-minus-src", "src-alpha", "one-minus-src-alpha", "dst", "one-minus-dst", "dst-alpha", "one-minus-dst-alpha", "src-alpha-saturated", "constant", "one-minus-constant", ],
|
||||
PresentMode: ["fifo", "fifo-relaxed", "immediate", "mailbox", ],
|
||||
TextureAspect: ["all", "stencil-only", "depth-only"],
|
||||
DeviceLostReason: [undefined, "unknown", "destroyed"],
|
||||
};
|
||||
|
||||
/** @type {WebGPUObjectManager<{}>} */
|
||||
@@ -382,13 +383,19 @@ class WebGPUInterface {
|
||||
*/
|
||||
RenderPassColorAttachment(start) {
|
||||
const viewIdx = this.mem.loadPtr(start + 4);
|
||||
const resolveTargetIdx = this.mem.loadPtr(start + 8);
|
||||
const resolveTargetIdx = this.mem.loadPtr(start + 12);
|
||||
|
||||
let depthSlice = this.mem.loadU32(start + 8);
|
||||
if (depthSlice == 0xFFFFFFFF) { // DEPTH_SLICE_UNDEFINED.
|
||||
depthSlice = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
view: viewIdx > 0 ? this.textureViews.get(viewIdx) : undefined,
|
||||
resolveTarget: resolveTargetIdx > 0 ? this.textureViews.get(resolveTargetIdx) : undefined,
|
||||
loadOp: this.enumeration("LoadOp", start + 12),
|
||||
storeOp: this.enumeration("StoreOp", start + 16),
|
||||
depthSlice: depthSlice,
|
||||
loadOp: this.enumeration("LoadOp", start + 16),
|
||||
storeOp: this.enumeration("StoreOp", start + 20),
|
||||
clearValue: this.Color(start + 24),
|
||||
};
|
||||
}
|
||||
@@ -950,14 +957,25 @@ class WebGPUInterface {
|
||||
|
||||
/**
|
||||
* @param {number} adapterIdx
|
||||
* @param {number} propertiesPtr
|
||||
* @param {number} infoPtr
|
||||
*/
|
||||
wgpuAdapterGetProperties: (adapterIdx, propertiesPtr) => {
|
||||
this.assert(propertiesPtr != 0);
|
||||
// Unknown adapter.
|
||||
this.mem.storeI32(propertiesPtr + 28, 3);
|
||||
wgpuAdapterGetInfo: (adapterIdx, infoPtr) => {
|
||||
this.assert(infoPtr != 0);
|
||||
|
||||
// WebGPU backend.
|
||||
this.mem.storeI32(propertiesPtr + 32, 2);
|
||||
this.mem.storeI32(infoPtr + 20, 2);
|
||||
// Unknown adapter.
|
||||
this.mem.storeI32(infoPtr + 24, 3);
|
||||
|
||||
// NOTE: I don't think getting the other fields in this struct is possible.
|
||||
// `adapter.requestAdapterInfo` is deprecated.
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} infoPtr
|
||||
*/
|
||||
wgpuAdapterInfoFreeMembers: (infoPtr) => {
|
||||
// NOTE: nothing to free.
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -970,50 +988,6 @@ class WebGPUInterface {
|
||||
return adapter.features.has(this.enums.FeatureName[featureInt]);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} adapterIdx
|
||||
* @param {number} callbackPtr
|
||||
* @param {0|number} userdata
|
||||
*/
|
||||
wgpuAdapterRequestAdapterInfo: async (adapterIdx, callbackPtr, userdata) => {
|
||||
const adapter = this.adapters.get(adapterIdx);
|
||||
const callback = this.mem.exports.__indirect_function_table.get(callbackPtr);
|
||||
|
||||
const info = await adapter.requestAdapterInfo();
|
||||
|
||||
const addr = this.mem.exports.wgpu_alloc(16);
|
||||
|
||||
const vendorLength = new TextEncoder().encode(info.vendor).length;
|
||||
const vendorAddr = this.mem.exports.wgpu_alloc(vendorLength);
|
||||
this.mem.storeString(vendorAddr, info.vendor);
|
||||
this.mem.storeI32(addr + 0, vendorAddr);
|
||||
|
||||
const architectureLength = new TextEncoder().encode(info.architecture).length;
|
||||
const architectureAddr = this.mem.exports.wgpu_alloc(architectureLength);
|
||||
this.mem.storeString(architectureAddr, info.architecture);
|
||||
this.mem.storeI32(addr + 4, architectureAddr);
|
||||
|
||||
|
||||
const deviceLength = new TextEncoder().encode(info.device).length;
|
||||
const deviceAddr = this.mem.exports.wgpu_alloc(deviceLength);
|
||||
this.mem.storeString(deviceAddr, info.device);
|
||||
this.mem.storeI32(addr + 8, deviceAddr);
|
||||
|
||||
|
||||
const descriptionLength = new TextEncoder().encode(info.description).length;
|
||||
const descriptionAddr = this.mem.exports.wgpu_alloc(descriptionLength);
|
||||
this.mem.storeString(descriptionAddr, info.description);
|
||||
this.mem.storeI32(addr + 12, descriptionAddr);
|
||||
|
||||
callback(addr, userdata);
|
||||
|
||||
this.mem.exports.wgpu_free(descriptionAddr);
|
||||
this.mem.exports.wgpu_free(deviceAddr);
|
||||
this.mem.exports.wgpu_free(architectureAddr);
|
||||
this.mem.exports.wgpu_free(vendorAddr);
|
||||
this.mem.exports.wgpu_free(addr);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} adapterIdx
|
||||
* @param {0|number} descriptorPtr
|
||||
@@ -1040,14 +1014,69 @@ class WebGPUInterface {
|
||||
};
|
||||
}
|
||||
|
||||
let device;
|
||||
let deviceIdx;
|
||||
try {
|
||||
const device = await adapter.requestDevice(descriptor);
|
||||
device = await adapter.requestDevice(descriptor);
|
||||
deviceIdx = this.devices.create(device);
|
||||
// NOTE: don't callback here, any errors that happen later will then be caught by the catch here.
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
callback(1, null, null, userdata);
|
||||
const messageLength = new TextEncoder().encode(e.message).length;
|
||||
const messageAddr = this.mem.exports.wgpu_alloc(messageLength + 1);
|
||||
this.mem.storeString(messageAddr, e.message);
|
||||
|
||||
callback(1, null, messageAddr, userdata);
|
||||
|
||||
this.mem.exports.wgpu_free(messageAddr);
|
||||
}
|
||||
|
||||
let callbacksPtr = descriptorPtr + 24 + this.mem.intSize;
|
||||
|
||||
const deviceLostCallbackPtr = this.mem.loadPtr(callbacksPtr);
|
||||
if (deviceLostCallbackPtr != 0) {
|
||||
const deviceLostUserData = this.mem.loadPtr(callbacksPtr) + 4;
|
||||
const deviceLostCallback = this.mem.exports.__indirect_function_table.get(deviceLostCallbackPtr);
|
||||
|
||||
device.lost.then((info) => {
|
||||
const reason = this.enums.DeviceLostReason.indexOf(info.reason);
|
||||
|
||||
const messageLength = new TextEncoder().encode(info.message).length;
|
||||
const messageAddr = this.mem.exports.wgpu_alloc(messageLength + 1);
|
||||
this.mem.storeString(messageAddr, info.message);
|
||||
|
||||
deviceLostCallback(reason, messageAddr, deviceLostUserData);
|
||||
|
||||
this.mem.exports.wgpu_free(messageAddr);
|
||||
});
|
||||
}
|
||||
callbacksPtr += 8;
|
||||
|
||||
// Skip over `nextInChain`.
|
||||
callbacksPtr += 4;
|
||||
|
||||
const uncapturedErrorCallbackPtr = this.mem.loadPtr(callbacksPtr);
|
||||
if (uncapturedErrorCallbackPtr != 0) {
|
||||
const uncapturedErrorUserData = this.mem.loadPtr(callbacksPtr + 4);
|
||||
const uncapturedErrorCallback = this.mem.exports.__indirect_function_table.get(uncapturedErrorCallbackPtr);
|
||||
|
||||
device.onuncapturederror = (ev) => {
|
||||
let status = 4; // Unknown
|
||||
if (ev.error instanceof GPUValidationError) {
|
||||
status = 1; // Validation
|
||||
} else if (ev.error instanceof GPUOutOfMemoryError) {
|
||||
status = 2; // OutOfMemory
|
||||
} else if (ev.error instanceof GPUInternalError) {
|
||||
status = 3; // Internal
|
||||
}
|
||||
|
||||
const messageLength = new TextEncoder().encode(ev.error.message).length;
|
||||
const messageAddr = this.mem.exports.wgpu_alloc(messageLength + 1);
|
||||
this.mem.storeString(messageAddr, ev.error.message);
|
||||
|
||||
uncapturedErrorCallback(status, messageAddr, uncapturedErrorUserData);
|
||||
|
||||
this.mem.exports.wgpu_free(messageAddr);
|
||||
};
|
||||
}
|
||||
|
||||
callback(0, deviceIdx, null, userdata);
|
||||
@@ -1918,29 +1947,6 @@ class WebGPUInterface {
|
||||
device.pushErrorScope(this.enums.ErrorFilter[filterInt]);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} deviceIdx
|
||||
* @param {number} callbackPtr
|
||||
* @param {number} userdata
|
||||
*/
|
||||
wgpuDeviceSetUncapturedErrorCallback: (deviceIdx, callbackPtr, userdata) => {
|
||||
const device = this.devices.get(deviceIdx);
|
||||
const callback = this.mem.exports.__indirect_function_table.get(callbackPtr);
|
||||
|
||||
device.onuncapturederror = (ev) => {
|
||||
console.warn(ev.error);
|
||||
let status = 4;
|
||||
if (error instanceof GPUValidationError) {
|
||||
status = 1;
|
||||
} else if (error instanceof GPUOutOfMemoryError) {
|
||||
status = 2;
|
||||
} else if (error instanceof GPUInternalError) {
|
||||
status = 3;
|
||||
}
|
||||
callback(status, null, userdata);
|
||||
};
|
||||
},
|
||||
|
||||
...this.devices.interface(true),
|
||||
|
||||
/* ---------------------- Instance ---------------------- */
|
||||
@@ -2646,23 +2652,23 @@ class WebGPUInterface {
|
||||
const formatStr = navigator.gpu.getPreferredCanvasFormat();
|
||||
const format = this.enums.TextureFormat.indexOf(formatStr);
|
||||
|
||||
this.mem.storeUint(capabilitiesPtr + this.mem.intSize, 1);
|
||||
this.mem.storeUint(capabilitiesPtr + 8, 1);
|
||||
const formatAddr = this.mem.exports.wgpu_alloc(4);
|
||||
this.mem.storeI32(formatAddr, format);
|
||||
this.mem.storeI32(capabilitiesPtr + this.mem.intSize*2, formatAddr);
|
||||
this.mem.storeI32(capabilitiesPtr + 8 + this.mem.intSize, formatAddr);
|
||||
|
||||
// NOTE: present modes don't seem to actually do anything in JS, we can just give back a default FIFO though.
|
||||
this.mem.storeUint(capabilitiesPtr + this.mem.intSize*3, 1);
|
||||
this.mem.storeUint(capabilitiesPtr + 8 + this.mem.intSize*2, 1);
|
||||
const presentModesAddr = this.mem.exports.wgpu_alloc(4);
|
||||
this.mem.storeI32(presentModesAddr, 0);
|
||||
this.mem.storeI32(capabilitiesPtr + this.mem.intSize*4, presentModesAddr);
|
||||
this.mem.storeI32(capabilitiesPtr + 8 + this.mem.intSize*3, presentModesAddr);
|
||||
|
||||
// Browser seems to support opaque (1) and premultiplied (2).
|
||||
this.mem.storeUint(capabilitiesPtr + this.mem.intSize*5, 2);
|
||||
this.mem.storeUint(capabilitiesPtr + 8 + this.mem.intSize*4, 2);
|
||||
const alphaModesAddr = this.mem.exports.wgpu_alloc(8);
|
||||
this.mem.storeI32(alphaModesAddr + 0, 1); // Opaque.
|
||||
this.mem.storeI32(alphaModesAddr + 4, 2); // premultiplied.
|
||||
this.mem.storeI32(capabilitiesPtr + this.mem.intSize*6, alphaModesAddr);
|
||||
this.mem.storeI32(capabilitiesPtr + 8 + this.mem.intSize*5, alphaModesAddr);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -2680,17 +2686,6 @@ class WebGPUInterface {
|
||||
// TODO: determine suboptimal and/or status.
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} surfaceIdx
|
||||
* @param {number} texturePtr
|
||||
* @returns {number}
|
||||
*/
|
||||
wgpuSurfaceGetPreferredFormat: (surfaceIdx, adapterIdx) => {
|
||||
const formatStr = navigator.gpu.getPreferredCanvasFormat();
|
||||
const format = this.enums.TextureFormat.indexOf(formatStr);
|
||||
return format;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number} surfaceIdx
|
||||
*/
|
||||
|
||||
164
vendor/wgpu/wgpu.odin
vendored
164
vendor/wgpu/wgpu.odin
vendored
@@ -13,7 +13,7 @@ when ODIN_OS == .Windows {
|
||||
@(private) LIB :: "lib/wgpu-windows-" + ARCH + "-" + TYPE + "/wgpu_native" + EXT
|
||||
|
||||
when !#exists(LIB) {
|
||||
#panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v0.19.4.1, make sure to read the README at '" + #directory + "vendor/wgpu/README.md'")
|
||||
#panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v22.1.0.1, make sure to read the README at '" + #directory + "vendor/wgpu/README.md'")
|
||||
}
|
||||
|
||||
foreign import libwgpu {
|
||||
@@ -34,7 +34,7 @@ when ODIN_OS == .Windows {
|
||||
@(private) LIB :: "lib/wgpu-macos-" + ARCH + "-" + TYPE + "/libwgpu_native" + EXT
|
||||
|
||||
when !#exists(LIB) {
|
||||
#panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v0.19.4.1, make sure to read the README at '" + #directory + "vendor/wgpu/README.md'")
|
||||
#panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v22.1.0.1, make sure to read the README at '" + #directory + "vendor/wgpu/README.md'")
|
||||
}
|
||||
|
||||
foreign import libwgpu {
|
||||
@@ -49,7 +49,7 @@ when ODIN_OS == .Windows {
|
||||
@(private) LIB :: "lib/wgpu-linux-" + ARCH + "-" + TYPE + "/libwgpu_native" + EXT
|
||||
|
||||
when !#exists(LIB) {
|
||||
#panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v0.19.4.1, make sure to read the README at '" + #directory + "vendor/wgpu/README.md'")
|
||||
#panic("Could not find the compiled WGPU Native library at '" + #directory + LIB + "', these can be downloaded from https://github.com/gfx-rs/wgpu-native/releases/tag/v22.1.0.1, make sure to read the README at '" + #directory + "vendor/wgpu/README.md'")
|
||||
}
|
||||
|
||||
foreign import libwgpu {
|
||||
@@ -220,7 +220,8 @@ CullMode :: enum i32 {
|
||||
|
||||
DeviceLostReason :: enum i32 {
|
||||
Undefined = 0x00000000,
|
||||
Destroyed = 0x00000001,
|
||||
Unknown = 0x00000001,
|
||||
Destroyed = 0x00000002,
|
||||
}
|
||||
|
||||
ErrorFilter :: enum i32 {
|
||||
@@ -264,6 +265,30 @@ FeatureName :: enum i32 {
|
||||
PipelineStatisticsQuery,
|
||||
StorageResourceBindingArray,
|
||||
PartiallyBoundBindingArray,
|
||||
TextureFormat16bitNorm,
|
||||
TextureCompressionAstcHdr,
|
||||
// TODO: requires wgpu.h api change
|
||||
// TimestampQueryInsidePasses,
|
||||
MappablePrimaryBuffers = 0x0003000E,
|
||||
BufferBindingArray,
|
||||
UniformBufferAndStorageTextureArrayNonUniformIndexing,
|
||||
// TODO: requires wgpu.h api change
|
||||
// AddressModeClampToZero,
|
||||
// AddressModeClampToBorder,
|
||||
// PolygonModeLine,
|
||||
// PolygonModePoint,
|
||||
// ConservativeRasterization,
|
||||
// ClearTexture,
|
||||
// SprivShaderPassThrough,
|
||||
// MultiView,
|
||||
VertexAttribute64bit = 0x00030019,
|
||||
TextureFormatNv12,
|
||||
RayTracingAccelarationStructure,
|
||||
RayQuery,
|
||||
ShaderF64,
|
||||
ShaderI16,
|
||||
ShaderPrimitiveIndex,
|
||||
ShaderEarlyDepthTest,
|
||||
}
|
||||
|
||||
FilterMode :: enum i32 {
|
||||
@@ -520,6 +545,18 @@ TextureFormat :: enum i32 {
|
||||
ASTC12x10UnormSrgb = 0x0000005D,
|
||||
ASTC12x12Unorm = 0x0000005E,
|
||||
ASTC12x12UnormSrgb = 0x0000005F,
|
||||
|
||||
// Native.
|
||||
|
||||
// From FeatureName.TextureFormat16bitNorm
|
||||
R16Unorm = 0x00030001,
|
||||
R16Snorm,
|
||||
Rg16Unorm,
|
||||
Rg16Snorm,
|
||||
Rgba16Unorm,
|
||||
Rgba16Snorm,
|
||||
// From FeatureName.TextureFormatNv12
|
||||
NV12,
|
||||
}
|
||||
|
||||
TextureSampleType :: enum i32 {
|
||||
@@ -581,13 +618,13 @@ VertexStepMode :: enum i32 {
|
||||
VertexBufferNotUsed = 0x00000002,
|
||||
}
|
||||
|
||||
// WGSLFeatureName :: enum i32 {
|
||||
// Undefined = 0x00000000,
|
||||
// ReadonlyAndReadwriteStorageTextures = 0x00000001,
|
||||
// Packed4x8IntegerDotProduct = 0x00000002,
|
||||
// UnrestrictedPointerParameters = 0x00000003,
|
||||
// PointerCompositeAccess = 0x00000004,
|
||||
// }
|
||||
WGSLFeatureName :: enum i32 {
|
||||
Undefined = 0x00000000,
|
||||
ReadonlyAndReadwriteStorageTextures = 0x00000001,
|
||||
Packed4x8IntegerDotProduct = 0x00000002,
|
||||
UnrestrictedPointerParameters = 0x00000003,
|
||||
PointerCompositeAccess = 0x00000004,
|
||||
}
|
||||
|
||||
BufferUsage :: enum i32 {
|
||||
MapRead = 0x00000000,
|
||||
@@ -634,22 +671,18 @@ TextureUsage :: enum i32 {
|
||||
}
|
||||
TextureUsageFlags :: bit_set[TextureUsage; Flags]
|
||||
|
||||
|
||||
BufferMapAsyncCallback :: #type proc "c" (status: BufferMapAsyncStatus, /* NULLABLE */ userdata: rawptr)
|
||||
ShaderModuleGetCompilationInfoCallback :: #type proc "c" (status: CompilationInfoRequestStatus, compilationInfo: ^CompilationInfo, /* NULLABLE */ userdata: rawptr)
|
||||
DeviceCreateComputePipelineAsyncCallback :: #type proc "c" (status: CreatePipelineAsyncStatus, pipeline: ComputePipeline, message: cstring, /* NULLABLE */ userdata: rawptr)
|
||||
DeviceCreateRenderPipelineAsyncCallback :: #type proc "c" (status: CreatePipelineAsyncStatus, pipeline: RenderPipeline, message: cstring, /* NULLABLE */ userdata: rawptr)
|
||||
Proc :: distinct rawptr
|
||||
|
||||
DeviceLostCallback :: #type proc "c" (reason: DeviceLostReason, message: cstring, userdata: rawptr)
|
||||
ErrorCallback :: #type proc "c" (type: ErrorType, message: cstring, userdata: rawptr)
|
||||
|
||||
Proc :: distinct rawptr
|
||||
|
||||
QueueOnSubmittedWorkDoneCallback :: #type proc "c" (status: QueueWorkDoneStatus, /* NULLABLE */ userdata: rawptr)
|
||||
InstanceRequestAdapterCallback :: #type proc "c" (status: RequestAdapterStatus, adapter: Adapter, message: cstring, /* NULLABLE */ userdata: rawptr)
|
||||
AdapterRequestDeviceCallback :: #type proc "c" (status: RequestDeviceStatus, device: Device, message: cstring, /* NULLABLE */ userdata: rawptr)
|
||||
|
||||
// AdapterRequestAdapterInfoCallback :: #type proc "c" (adapterInfo: AdapterInfo, /* NULLABLE */ userdata: rawptr)
|
||||
BufferMapAsyncCallback :: #type proc "c" (status: BufferMapAsyncStatus, /* NULLABLE */ userdata: rawptr)
|
||||
DeviceCreateComputePipelineAsyncCallback :: #type proc "c" (status: CreatePipelineAsyncStatus, pipeline: ComputePipeline, message: cstring, /* NULLABLE */ userdata: rawptr)
|
||||
DeviceCreateRenderPipelineAsyncCallback :: #type proc "c" (status: CreatePipelineAsyncStatus, pipeline: RenderPipeline, message: cstring, /* NULLABLE */ userdata: rawptr)
|
||||
InstanceRequestAdapterCallback :: #type proc "c" (status: RequestAdapterStatus, adapter: Adapter, message: cstring, /* NULLABLE */ userdata: rawptr)
|
||||
QueueOnSubmittedWorkDoneCallback :: #type proc "c" (status: QueueWorkDoneStatus, /* NULLABLE */ userdata: rawptr)
|
||||
ShaderModuleGetCompilationInfoCallback :: #type proc "c" (status: CompilationInfoRequestStatus, compilationInfo: ^CompilationInfo, /* NULLABLE */ userdata: rawptr)
|
||||
|
||||
ChainedStruct :: struct {
|
||||
next: ^ChainedStruct,
|
||||
@@ -661,28 +694,23 @@ ChainedStructOut :: struct {
|
||||
sType: SType,
|
||||
}
|
||||
|
||||
// AdapterInfo :: struct {
|
||||
// next: ^ChainedStructOut,
|
||||
// vendor: cstring,
|
||||
// architecture: cstring,
|
||||
// device: cstring,
|
||||
// description: cstring,
|
||||
// backendType: BackendType,
|
||||
// adapterType: AdapterType,
|
||||
// vendorID: u32,
|
||||
// deviceID: u32,
|
||||
// }
|
||||
|
||||
AdapterProperties :: struct {
|
||||
AdapterInfo :: struct {
|
||||
nextInChain: ^ChainedStructOut,
|
||||
vendorID: u32,
|
||||
vendorName: cstring,
|
||||
vendor: cstring,
|
||||
architecture: cstring,
|
||||
deviceID: u32,
|
||||
name: cstring,
|
||||
driverDescription: cstring,
|
||||
adapterType: AdapterType,
|
||||
device: cstring,
|
||||
description: cstring,
|
||||
backendType: BackendType,
|
||||
adapterType: AdapterType,
|
||||
vendorID: u32,
|
||||
deviceID: u32,
|
||||
}
|
||||
when ODIN_OS == .JS {
|
||||
#assert(int(BackendType.WebGPU) == 2)
|
||||
#assert(offset_of(AdapterInfo, backendType) == 20)
|
||||
|
||||
#assert(int(AdapterType.Unknown) == 3)
|
||||
#assert(offset_of(AdapterInfo, adapterType) == 24)
|
||||
}
|
||||
|
||||
BindGroupEntry :: struct {
|
||||
@@ -943,6 +971,7 @@ StorageTextureBindingLayout :: struct {
|
||||
|
||||
SurfaceCapabilities :: struct {
|
||||
nextInChain: ^ChainedStructOut,
|
||||
usages: TextureUsageFlags,
|
||||
formatCount: uint,
|
||||
formats: /* const */ [^]TextureFormat `fmt:"v,formatCount"`,
|
||||
presentModeCount: uint,
|
||||
@@ -950,6 +979,16 @@ SurfaceCapabilities :: struct {
|
||||
alphaModeCount: uint,
|
||||
alphaModes: /* const */ [^]CompositeAlphaMode `fmt:"v,alphaModeCount"`,
|
||||
}
|
||||
when ODIN_OS == .JS {
|
||||
#assert(offset_of(SurfaceCapabilities, formatCount) == 8)
|
||||
#assert(offset_of(SurfaceCapabilities, formats) == 8 + 1*size_of(int))
|
||||
|
||||
#assert(offset_of(SurfaceCapabilities, presentModeCount) == 8 + 2*size_of(int))
|
||||
#assert(offset_of(SurfaceCapabilities, presentModes) == 8 + 3*size_of(int))
|
||||
|
||||
#assert(offset_of(SurfaceCapabilities, alphaModeCount) == 8 + 4*size_of(int))
|
||||
#assert(offset_of(SurfaceCapabilities, alphaModes) == 8 + 5*size_of(int))
|
||||
}
|
||||
|
||||
SurfaceConfiguration :: struct {
|
||||
nextInChain: ^ChainedStruct,
|
||||
@@ -1040,6 +1079,12 @@ TextureViewDescriptor :: struct {
|
||||
aspect: TextureAspect,
|
||||
}
|
||||
|
||||
UncapturedErrorCallbackInfo :: struct {
|
||||
nextInChain: ^ChainedStruct,
|
||||
callback: ErrorCallback,
|
||||
userdata: rawptr,
|
||||
}
|
||||
|
||||
VertexAttribute :: struct {
|
||||
format: VertexFormat,
|
||||
offset: u64,
|
||||
@@ -1120,12 +1165,21 @@ ProgrammableStageDescriptor :: struct {
|
||||
RenderPassColorAttachment :: struct {
|
||||
nextInChain: ^ChainedStruct,
|
||||
/* NULLABLE */ view: TextureView,
|
||||
// depthSlice: u32,
|
||||
depthSlice: u32,
|
||||
/* NULLABLE */ resolveTarget: TextureView,
|
||||
loadOp: LoadOp,
|
||||
storeOp: StoreOp,
|
||||
clearValue: Color,
|
||||
}
|
||||
when ODIN_OS == .JS {
|
||||
#assert(size_of(RenderPassColorAttachment) == 56)
|
||||
#assert(offset_of(RenderPassColorAttachment, view) == 4)
|
||||
#assert(offset_of(RenderPassColorAttachment, depthSlice) == 8)
|
||||
#assert(offset_of(RenderPassColorAttachment, resolveTarget) == 12)
|
||||
#assert(offset_of(RenderPassColorAttachment, loadOp) == 16)
|
||||
#assert(offset_of(RenderPassColorAttachment, storeOp) == 20)
|
||||
#assert(offset_of(RenderPassColorAttachment, clearValue) == 24)
|
||||
}
|
||||
|
||||
RequiredLimits :: struct {
|
||||
nextInChain: ^ChainedStruct,
|
||||
@@ -1194,6 +1248,10 @@ DeviceDescriptor :: struct {
|
||||
defaultQueue: QueueDescriptor,
|
||||
deviceLostCallback: DeviceLostCallback,
|
||||
deviceLostUserdata: rawptr,
|
||||
uncapturedErrorCallbackInfo: UncapturedErrorCallbackInfo,
|
||||
}
|
||||
when ODIN_OS == .JS {
|
||||
#assert(offset_of(DeviceDescriptor, deviceLostCallback) == 24 + size_of(int))
|
||||
}
|
||||
|
||||
RenderPassDescriptor :: struct {
|
||||
@@ -1245,16 +1303,18 @@ foreign libwgpu {
|
||||
// Methods of Adapter
|
||||
@(link_name="wgpuAdapterEnumerateFeatures")
|
||||
RawAdapterEnumerateFeatures :: proc(adapter: Adapter, features: [^]FeatureName) -> uint ---
|
||||
@(link_name="wgpuAdapterGetInfo")
|
||||
RawAdapterGetInfo :: proc(adapter: Adapter, info: ^AdapterInfo) ---
|
||||
@(link_name="wgpuAdapterGetLimits")
|
||||
RawAdapterGetLimits :: proc(adapter: Adapter, limits: ^SupportedLimits) -> b32 ---
|
||||
@(link_name="wgpuAdapterGetProperties")
|
||||
RawAdapterGetProperties :: proc(adapter: Adapter, properties: ^AdapterProperties) ---
|
||||
AdapterHasFeature :: proc(adapter: Adapter, feature: FeatureName) -> b32 ---
|
||||
// AdapterRequestAdapterInfo :: proc(adapter: Adapter, callback: AdapterRequestAdapterInfoCallback, /* NULLABLE */ userdata: rawptr) ---
|
||||
AdapterRequestDevice :: proc(adapter: Adapter, /* NULLABLE */ descriptor: /* const */ ^DeviceDescriptor, callback: AdapterRequestDeviceCallback, /* NULLABLE */ userdata: rawptr = nil) ---
|
||||
AdapterReference :: proc(adapter: Adapter) ---
|
||||
AdapterRelease :: proc(adapter: Adapter) ---
|
||||
|
||||
// Procs of AdapterInfo
|
||||
AdapterInfoFreeMembers :: proc(adapterInfo: AdapterInfo) ---
|
||||
|
||||
// Methods of BindGroup
|
||||
BindGroupSetLabel :: proc(bindGroup: BindGroup, label: cstring) ---
|
||||
BindGroupReference :: proc(bindGroup: BindGroup) ---
|
||||
@@ -1348,13 +1408,12 @@ foreign libwgpu {
|
||||
DevicePopErrorScope :: proc(device: Device, callback: ErrorCallback, userdata: rawptr) ---
|
||||
DevicePushErrorScope :: proc(device: Device, filter: ErrorFilter) ---
|
||||
DeviceSetLabel :: proc(device: Device, label: cstring) ---
|
||||
DeviceSetUncapturedErrorCallback :: proc(device: Device, callback: ErrorCallback, userdata: rawptr) ---
|
||||
DeviceReference :: proc(device: Device) ---
|
||||
DeviceRelease :: proc(device: Device) ---
|
||||
|
||||
// Methods of Instance
|
||||
InstanceCreateSurface :: proc(instance: Instance, descriptor: /* const */ ^SurfaceDescriptor) -> Surface ---
|
||||
// InstanceHasWGSLLanguageFeature :: proc(instance: Instance, feature: WGSLFeatureName) -> b32 ---
|
||||
InstanceHasWGSLLanguageFeature :: proc(instance: Instance, feature: WGSLFeatureName) -> b32 ---
|
||||
InstanceProcessEvents :: proc(instance: Instance) ---
|
||||
InstanceRequestAdapter :: proc(instance: Instance, /* NULLABLE */ options: /* const */ ^RequestAdapterOptions, callback: InstanceRequestAdapterCallback, /* NULLABLE */ userdata: rawptr = nil) ---
|
||||
InstanceReference :: proc(instance: Instance) ---
|
||||
@@ -1455,9 +1514,8 @@ foreign libwgpu {
|
||||
RawSurfaceGetCapabilities :: proc(surface: Surface, adapter: Adapter, capabilities: ^SurfaceCapabilities) ---
|
||||
@(link_name="wgpuSurfaceGetCurrentTexture")
|
||||
RawSurfaceGetCurrentTexture :: proc(surface: Surface, surfaceTexture: ^SurfaceTexture) ---
|
||||
SurfaceGetPreferredFormat :: proc(surface: Surface, adapter: Adapter) -> TextureFormat ---
|
||||
SurfacePresent :: proc(surface: Surface) ---
|
||||
// SurfaceSetLabel :: proc(surface: Surface, label: cstring) ---
|
||||
SurfaceSetLabel :: proc(surface: Surface, label: cstring) ---
|
||||
SurfaceUnconfigure :: proc(surface: Surface) ---
|
||||
SurfaceReference :: proc(surface: Surface) ---
|
||||
SurfaceRelease :: proc(surface: Surface) ---
|
||||
@@ -1500,8 +1558,8 @@ AdapterGetLimits :: proc(adapter: Adapter) -> (limits: SupportedLimits, ok: bool
|
||||
return
|
||||
}
|
||||
|
||||
AdapterGetProperties :: proc(adapter: Adapter) -> (properties: AdapterProperties) {
|
||||
RawAdapterGetProperties(adapter, &properties)
|
||||
AdapterGetInfo :: proc(adapter: Adapter) -> (info: AdapterInfo) {
|
||||
RawAdapterGetInfo(adapter, &info)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1634,8 +1692,8 @@ SurfaceGetCurrentTexture :: proc(surface: Surface) -> (surface_texture: SurfaceT
|
||||
|
||||
// WGPU Native bindings
|
||||
|
||||
BINDINGS_VERSION :: [4]u8{0, 19, 4, 1}
|
||||
BINDINGS_VERSION_STRING :: "0.19.4.1"
|
||||
BINDINGS_VERSION :: [4]u8{22, 1, 0, 1}
|
||||
BINDINGS_VERSION_STRING :: "22.1.0.1"
|
||||
|
||||
when ODIN_OS != .JS {
|
||||
@(private="file", init)
|
||||
|
||||
Reference in New Issue
Block a user