gpu: internalize BindGroup types
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
e6f3d3c2f0
commit
e10432834b
3 changed files with 23 additions and 24 deletions
|
|
@ -6,6 +6,25 @@ const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
|
|||
const Impl = @import("interface.zig").Impl;
|
||||
|
||||
pub const BindGroup = opaque {
|
||||
pub const Entry = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
binding: u32,
|
||||
buffer: ?*Buffer,
|
||||
offset: u64 = 0,
|
||||
size: u64,
|
||||
sampler: ?*Sampler,
|
||||
texture_view: ?*TextureView,
|
||||
};
|
||||
|
||||
pub const Descriptor = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
label: ?[*:0]const u8 = null,
|
||||
layout: *BindGroupLayout,
|
||||
entry_count: u32,
|
||||
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
|
||||
entries: ?[*]const Entry,
|
||||
};
|
||||
|
||||
pub inline fn setLabel(bind_group: *BindGroup, label: [*:0]const u8) void {
|
||||
Impl.bindGroupSetLabel(bind_group, label);
|
||||
}
|
||||
|
|
@ -18,22 +37,3 @@ pub const BindGroup = opaque {
|
|||
Impl.bindGroupRelease(bind_group);
|
||||
}
|
||||
};
|
||||
|
||||
pub const BindGroupEntry = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
binding: u32,
|
||||
buffer: ?*Buffer,
|
||||
offset: u64 = 0,
|
||||
size: u64,
|
||||
sampler: ?*Sampler,
|
||||
texture_view: ?*TextureView,
|
||||
};
|
||||
|
||||
pub const BindGroupDescriptor = extern struct {
|
||||
next_in_chain: ?*const ChainedStruct = null,
|
||||
label: ?[*:0]const u8 = null,
|
||||
layout: *BindGroupLayout,
|
||||
entry_count: u32,
|
||||
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
|
||||
entries: ?[*]const BindGroupEntry,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
const Queue = @import("queue.zig").Queue;
|
||||
const QueueDescriptor = @import("queue.zig").QueueDescriptor;
|
||||
const BindGroup = @import("bind_group.zig").BindGroup;
|
||||
const BindGroupDescriptor = @import("bind_group.zig").BindGroupDescriptor;
|
||||
const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
|
||||
const Buffer = @import("buffer.zig").Buffer;
|
||||
const BufferDescriptor = @import("buffer.zig").BufferDescriptor;
|
||||
|
|
@ -41,7 +40,7 @@ const CreateRenderPipelineAsyncCallback = @import("callbacks.zig").CreateRenderP
|
|||
const Impl = @import("interface.zig").Impl;
|
||||
|
||||
pub const Device = opaque {
|
||||
pub inline fn createBindGroup(device: *Device, descriptor: *const BindGroupDescriptor) *BindGroup {
|
||||
pub inline fn createBindGroup(device: *Device, descriptor: *const BindGroup.Descriptor) *BindGroup {
|
||||
return Impl.deviceCreateBindGroup(device, descriptor);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ pub fn Interface(comptime T: type) type {
|
|||
assertDecl(T, "computePipelineSetLabel", fn (compute_pipeline: *gpu.ComputePipeline, label: [*:0]const u8) callconv(.Inline) void);
|
||||
assertDecl(T, "computePipelineReference", fn (compute_pipeline: *gpu.ComputePipeline) callconv(.Inline) void);
|
||||
assertDecl(T, "computePipelineRelease", fn (compute_pipeline: *gpu.ComputePipeline) callconv(.Inline) void);
|
||||
assertDecl(T, "deviceCreateBindGroup", fn (device: *gpu.Device, descriptor: *const gpu.BindGroupDescriptor) callconv(.Inline) *gpu.BindGroup);
|
||||
assertDecl(T, "deviceCreateBindGroup", fn (device: *gpu.Device, descriptor: *const gpu.BindGroup.Descriptor) callconv(.Inline) *gpu.BindGroup);
|
||||
assertDecl(T, "deviceCreateBindGroupLayout", fn (device: *gpu.Device, descriptor: *const gpu.BindGroupLayout.Descriptor) callconv(.Inline) *gpu.BindGroupLayout);
|
||||
assertDecl(T, "deviceCreateBuffer", fn (device: *gpu.Device, descriptor: *const gpu.BufferDescriptor) callconv(.Inline) *gpu.Buffer);
|
||||
assertDecl(T, "deviceCreateCommandEncoder", fn (device: *gpu.Device, descriptor: ?*const gpu.CommandEncoderDescriptor) callconv(.Inline) *gpu.CommandEncoder);
|
||||
|
|
@ -549,7 +549,7 @@ pub fn Export(comptime T: type) type {
|
|||
}
|
||||
|
||||
// WGPU_EXPORT WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, WGPUBindGroupDescriptor const * descriptor);
|
||||
export fn wgpuDeviceCreateBindGroup(device: *gpu.Device, descriptor: *const gpu.BindGroupDescriptor) *gpu.BindGroup {
|
||||
export fn wgpuDeviceCreateBindGroup(device: *gpu.Device, descriptor: *const gpu.BindGroup.Descriptor) *gpu.BindGroup {
|
||||
return T.deviceCreateBindGroup(device, descriptor);
|
||||
}
|
||||
|
||||
|
|
@ -1617,7 +1617,7 @@ pub const StubInterface = Interface(struct {
|
|||
unreachable;
|
||||
}
|
||||
|
||||
pub inline fn deviceCreateBindGroup(device: *gpu.Device, descriptor: *const gpu.BindGroupDescriptor) *gpu.BindGroup {
|
||||
pub inline fn deviceCreateBindGroup(device: *gpu.Device, descriptor: *const gpu.BindGroup.Descriptor) *gpu.BindGroup {
|
||||
_ = device;
|
||||
_ = descriptor;
|
||||
unreachable;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue