gpu: make setBindGroup methods use slice helper API
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
b369635193
commit
5d88387dac
7 changed files with 35 additions and 16 deletions
|
|
@ -155,10 +155,13 @@ The slice helpers are:
|
|||
* `Buffer.getConstMappedRange`
|
||||
* `Buffer.getMappedRange`
|
||||
* `CommandEncoder.writeBuffer`
|
||||
* `ComputePassEncoder.setBindGroup`
|
||||
* `Device.enumerateFeaturesOwned`
|
||||
* `Queue.writeTexture`
|
||||
* `Queue.writeBuffer`
|
||||
* `RenderPassEncoder.executeBundles`
|
||||
* `RenderBundleEncoder.setBindGroup`
|
||||
* `RenderPassEncoder.setBindGroup`
|
||||
|
||||
### Typed callbacks
|
||||
|
||||
|
|
@ -220,7 +223,4 @@ There may be other opportunities for helpers, to improve the existing APIs, or a
|
|||
|
||||
The following are definitive candidates for helpers we haven't implemented yet:
|
||||
|
||||
* `gpu.ComputePassEncoder.setBindGroup` (slice param)
|
||||
* `gpu.RenderBundleEncoder.setBindGroup` (slice param)
|
||||
* `gpu.RenderPassEncoder.setBindGroup` (slice param)
|
||||
* Other `next_in_chain` extensions (look at dawn.json after the bug to get this documented was fixed)
|
||||
* Other `next_in_chain` extensions (marked with a `// TODO` already)
|
||||
|
|
|
|||
|
|
@ -33,8 +33,14 @@ pub const ComputePassEncoder = opaque {
|
|||
|
||||
/// Default `dynamic_offset_count`: 0
|
||||
/// Default `dynamic_offsets`: null
|
||||
pub inline fn setBindGroup(compute_pass_encoder: *ComputePassEncoder, group_index: u32, group: *BindGroup, dynamic_offset_count: u32, dynamic_offsets: ?[*]const u32) void {
|
||||
Impl.computePassEncoderSetBindGroup(compute_pass_encoder, group_index, group, dynamic_offset_count, dynamic_offsets);
|
||||
pub inline fn setBindGroup(compute_pass_encoder: *ComputePassEncoder, group_index: u32, group: *BindGroup, dynamic_offsets: ?[]const u32) void {
|
||||
Impl.computePassEncoderSetBindGroup(
|
||||
compute_pass_encoder,
|
||||
group_index,
|
||||
group,
|
||||
if (dynamic_offsets) |v| @intCast(u32, v.len) else 0,
|
||||
if (dynamic_offsets) |v| v.ptr else null,
|
||||
);
|
||||
}
|
||||
|
||||
pub inline fn setLabel(compute_pass_encoder: *ComputePassEncoder, label: [*:0]const u8) void {
|
||||
|
|
|
|||
|
|
@ -547,10 +547,10 @@ pub const Interface = struct {
|
|||
procs.deviceDestroy.?(@ptrCast(c.WGPUDevice, device));
|
||||
}
|
||||
|
||||
pub inline fn deviceEnumerateFeatures(device: *gpu.Device, features: [*]gpu.FeatureName) usize {
|
||||
pub inline fn deviceEnumerateFeatures(device: *gpu.Device, features: ?[*]gpu.FeatureName) usize {
|
||||
return procs.deviceEnumerateFeatures.?(
|
||||
@ptrCast(c.WGPUDevice, device),
|
||||
@ptrCast([*]c.WGPUFeatureName, features),
|
||||
@ptrCast(?[*]c.WGPUFeatureName, features),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
const std = @import("std");
|
||||
const Queue = @import("queue.zig").Queue;
|
||||
const BindGroup = @import("bind_group.zig").BindGroup;
|
||||
const BindGroupLayout = @import("bind_group_layout.zig").BindGroupLayout;
|
||||
|
|
@ -184,7 +185,7 @@ pub const Device = opaque {
|
|||
/// Call once with null to determine the array length, and again to fetch the feature list.
|
||||
///
|
||||
/// Consider using the enumerateFeaturesOwned helper.
|
||||
pub inline fn enumerateFeatures(device: *Device, features: [*]FeatureName) usize {
|
||||
pub inline fn enumerateFeatures(device: *Device, features: ?[*]FeatureName) usize {
|
||||
return Impl.deviceEnumerateFeatures(device, features);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ pub fn Interface(comptime T: type) type {
|
|||
assertDecl(T, "deviceCreateSwapChain", fn (device: *gpu.Device, surface: ?*gpu.Surface, descriptor: *const gpu.SwapChain.Descriptor) callconv(.Inline) *gpu.SwapChain);
|
||||
assertDecl(T, "deviceCreateTexture", fn (device: *gpu.Device, descriptor: *const gpu.Texture.Descriptor) callconv(.Inline) *gpu.Texture);
|
||||
assertDecl(T, "deviceDestroy", fn (device: *gpu.Device) callconv(.Inline) void);
|
||||
assertDecl(T, "deviceEnumerateFeatures", fn (device: *gpu.Device, features: [*]gpu.FeatureName) callconv(.Inline) usize);
|
||||
assertDecl(T, "deviceEnumerateFeatures", fn (device: *gpu.Device, features: ?[*]gpu.FeatureName) callconv(.Inline) usize);
|
||||
assertDecl(T, "deviceGetLimits", fn (device: *gpu.Device, limits: *gpu.SupportedLimits) callconv(.Inline) bool);
|
||||
assertDecl(T, "deviceGetQueue", fn (device: *gpu.Device) callconv(.Inline) *gpu.Queue);
|
||||
assertDecl(T, "deviceHasFeature", fn (device: *gpu.Device, feature: gpu.FeatureName) callconv(.Inline) bool);
|
||||
|
|
@ -651,7 +651,7 @@ pub fn Export(comptime T: type) type {
|
|||
}
|
||||
|
||||
// WGPU_EXPORT size_t wgpuDeviceEnumerateFeatures(WGPUDevice device, WGPUFeatureName * features);
|
||||
export fn wgpuDeviceEnumerateFeatures(device: *gpu.Device, features: [*]gpu.FeatureName) usize {
|
||||
export fn wgpuDeviceEnumerateFeatures(device: *gpu.Device, features: ?[*]gpu.FeatureName) usize {
|
||||
return T.deviceEnumerateFeatures(device, features);
|
||||
}
|
||||
|
||||
|
|
@ -1747,7 +1747,7 @@ pub const StubInterface = Interface(struct {
|
|||
unreachable;
|
||||
}
|
||||
|
||||
pub inline fn deviceEnumerateFeatures(device: *gpu.Device, features: [*]gpu.FeatureName) usize {
|
||||
pub inline fn deviceEnumerateFeatures(device: *gpu.Device, features: ?[*]gpu.FeatureName) usize {
|
||||
_ = device;
|
||||
_ = features;
|
||||
unreachable;
|
||||
|
|
|
|||
|
|
@ -60,8 +60,14 @@ pub const RenderBundleEncoder = opaque {
|
|||
|
||||
/// Default `dynamic_offsets_count`: 0
|
||||
/// Default `dynamic_offsets`: `null`
|
||||
pub inline fn setBindGroup(render_bundle_encoder: *RenderBundleEncoder, group_index: u32, group: *BindGroup, dynamic_offset_count: u32, dynamic_offsets: ?[*]const u32) void {
|
||||
Impl.renderBundleEncoderSetBindGroup(render_bundle_encoder, group_index, group, dynamic_offset_count, dynamic_offsets);
|
||||
pub inline fn setBindGroup(render_bundle_encoder: *RenderBundleEncoder, group_index: u32, group: *BindGroup, dynamic_offsets: ?[]const u32) void {
|
||||
Impl.renderBundleEncoderSetBindGroup(
|
||||
render_bundle_encoder,
|
||||
group_index,
|
||||
group,
|
||||
if (dynamic_offsets) |v| @intCast(u32, v.len) else 0,
|
||||
if (dynamic_offsets) |v| v.ptr else null,
|
||||
);
|
||||
}
|
||||
|
||||
/// Default `offset`: 0
|
||||
|
|
|
|||
|
|
@ -68,8 +68,14 @@ pub const RenderPassEncoder = opaque {
|
|||
|
||||
/// Default `dynamic_offsets_count`: 0
|
||||
/// Default `dynamic_offsets`: `null`
|
||||
pub inline fn setBindGroup(render_pass_encoder: *RenderPassEncoder, group_index: u32, group: *BindGroup, dynamic_offset_count: u32, dynamic_offsets: ?[*]const u32) void {
|
||||
Impl.renderPassEncoderSetBindGroup(render_pass_encoder, group_index, group, dynamic_offset_count, dynamic_offsets);
|
||||
pub inline fn setBindGroup(render_pass_encoder: *RenderPassEncoder, group_index: u32, group: *BindGroup, dynamic_offsets: ?[]const u32) void {
|
||||
Impl.renderPassEncoderSetBindGroup(
|
||||
render_pass_encoder,
|
||||
group_index,
|
||||
group,
|
||||
if (dynamic_offsets) |v| @intCast(u32, v.len) else 0,
|
||||
if (dynamic_offsets) |v| v.ptr else null,
|
||||
);
|
||||
}
|
||||
|
||||
pub inline fn setBlendConstant(render_pass_encoder: *RenderPassEncoder, color: *const Color) void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue