gpu: update TODOs, give all chain fields default values

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-16 19:44:57 -07:00
parent 093be3aa53
commit 26755e0837
6 changed files with 18 additions and 22 deletions

View file

@ -4,25 +4,25 @@ pub const Interface = @import("dawn_impl.zig").Interface;
/// TODO: Can be chained in gpu.Device.Descriptor
pub const CacheDeviceDescriptor = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_cache_device_descriptor },
isolation_key: [*:0]const u8 = "",
};
/// TODO: Can be chained in gpu.CommandEncoder.Descriptor
pub const EncoderInternalUsageDescriptor = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_encoder_internal_usage_descriptor },
use_internal_usages: bool = false,
};
/// TODO: Can be chained in gpu.Instance.Descriptor
pub const InstanceDescriptor = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_instance_descriptor },
additional_runtime_search_paths_count: u32 = 0,
additional_runtime_search_paths: ?[*]const u8 = null,
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_instance_descriptor },
additional_runtime_search_paths: ?[]const u8 = null,
}) InstanceDescriptor {
return .{
@ -35,13 +35,13 @@ pub const InstanceDescriptor = extern struct {
/// TODO: Can be chained in gpu.Texture.Descriptor
pub const TextureInternalUsageDescriptor = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_texture_internal_usage_descriptor },
internal_usage: Texture.UsageFlags = Texture.UsageFlags.none,
};
/// TODO: Can be chained in gpu.Device.Descriptor
pub const TogglesDeviceDescriptor = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_toggles_device_descriptor },
force_enabled_toggles_count: u32 = 0,
force_enabled_toggles: ?[*]const u8 = null,
force_disabled_toggles_count: u32 = 0,
@ -49,7 +49,7 @@ pub const TogglesDeviceDescriptor = extern struct {
/// Provides a slightly friendlier Zig API to initialize this structure.
pub inline fn init(v: struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .dawn_toggles_device_descriptor },
force_enabled_toggles: ?[]const u8 = null,
force_disabled_toggles: ?[]const u8 = null,
}) TogglesDeviceDescriptor {

View file

@ -108,7 +108,7 @@ pub const Interface = struct {
procs.bufferDestroy.?(@ptrCast(c.WGPUBuffer, buffer));
}
// TODO: file a bug on Dawn docstrings, this returns null but is not documented as such.
// TODO: dawn: return value not marked as nullable in dawn.json but in fact is.
pub inline fn bufferGetConstMappedRange(buffer: *gpu.Buffer, offset: usize, size: usize) ?*const anyopaque {
return procs.bufferGetConstMappedRange.?(
@ptrCast(c.WGPUBuffer, buffer),
@ -117,7 +117,7 @@ pub const Interface = struct {
);
}
// TODO: file a bug on Dawn docstrings, this returns null but is not documented as such.
// TODO: dawn: return value not marked as nullable in dawn.json but in fact is.
pub inline fn bufferGetMappedRange(buffer: *gpu.Buffer, offset: usize, size: usize) ?*anyopaque {
return procs.bufferGetMappedRange.?(
@ptrCast(c.WGPUBuffer, buffer),

View file

@ -5,13 +5,13 @@ const Impl = @import("interface.zig").Impl;
pub const ExternalTexture = opaque {
/// TODO: Can be chained in gpu.BindGroup.Entry
pub const BindingEntry = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .external_texture_binding_entry },
external_texture: *ExternalTexture,
};
/// TODO: Can be chained in gpu.BindGroupLayout.Entry
pub const BindingLayout = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .external_texture_binding_layout },
};
pub const Descriptor = extern struct {

View file

@ -333,8 +333,6 @@ pub fn Export(comptime T: type) type {
return T.bufferGetUsage(buffer);
}
// TODO: Zig cannot currently export a packed struct gpu.MapModeFlags, so we use a u32 for
// now.
// WGPU_EXPORT void wgpuBufferMapAsync(WGPUBuffer buffer, WGPUMapModeFlags mode, size_t offset, size_t size, WGPUBufferMapCallback callback, void * userdata);
export fn wgpuBufferMapAsync(buffer: *gpu.Buffer, mode: u32, offset: usize, size: usize, callback: gpu.Buffer.MapCallback, userdata: ?*anyopaque) void {
T.bufferMapAsync(buffer, @bitCast(gpu.MapModeFlags, mode), offset, size, callback, userdata);
@ -1115,8 +1113,6 @@ pub fn Export(comptime T: type) type {
T.surfaceRelease(surface);
}
// TODO: Zig cannot currently export a packed struct gpu.Texture.UsageFlags, so we use a u32
// for now.
// WGPU_EXPORT void wgpuSwapChainConfigure(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height);
export fn wgpuSwapChainConfigure(swap_chain: *gpu.SwapChain, format: gpu.Texture.Format, allowed_usage: u32, width: u32, height: u32) void {
T.swapChainConfigure(swap_chain, format, @bitCast(gpu.Texture.UsageFlags, allowed_usage), width, height);
@ -1322,7 +1318,7 @@ pub const StubInterface = Interface(struct {
unreachable;
}
// TODO: file a bug on Dawn docstrings, this returns null but is not documented as such.
// TODO: dawn: return value not marked as nullable in dawn.json but in fact is.
pub inline fn bufferGetConstMappedRange(buffer: *gpu.Buffer, offset: usize, size: usize) ?*const anyopaque {
_ = buffer;
_ = offset;
@ -1330,7 +1326,7 @@ pub const StubInterface = Interface(struct {
unreachable;
}
// TODO: file a bug on Dawn docstrings, this returns null but is not documented as such.
// TODO: dawn: return value not marked as nullable in dawn.json but in fact is.
pub inline fn bufferGetMappedRange(buffer: *gpu.Buffer, offset: usize, size: usize) ?*anyopaque {
_ = buffer;
_ = offset;

View file

@ -30,7 +30,7 @@ pub const Queue = opaque {
Impl.queueCopyTextureForBrowser(queue, source, destination, copy_size, options);
}
// TODO: is it not possible to *unset* this callback? Presumably it should be nullable?
// TODO: presumably callback should be nullable for unsetting
pub inline fn onSubmittedWorkDone(
queue: *Queue,
signal_value: u64,

View file

@ -466,13 +466,13 @@ pub const ShaderStageFlags = packed struct {
};
pub const ChainedStruct = extern struct {
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
// TODO: dawn: not marked as nullable in dawn.json but in fact is.
next: ?*const ChainedStruct = null,
s_type: SType,
};
pub const ChainedStructOut = extern struct {
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
// TODO: dawn: not marked as nullable in dawn.json but in fact is.
next: ?*ChainedStructOut = null,
s_type: SType,
};
@ -573,7 +573,7 @@ pub const MultisampleState = extern struct {
/// TODO: Can be chained in gpu.PrimitiveState
pub const PrimitiveDepthClipControl = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .primitive_depth_clip_control },
unclipped_depth: bool = false,
};
@ -587,7 +587,7 @@ pub const PrimitiveState = extern struct {
/// TODO: Can be chained in gpu.RenderPassDescriptor
pub const RenderPassDescriptorMaxDrawCount = extern struct {
chain: ChainedStruct,
chain: ChainedStruct = .{ .next = null, .s_type = .render_pass_descriptor_max_draw_count },
max_draw_count: u64 = 50000000,
};