From 31040831438bd5bd446bda395a5bf168e8f91b6a Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Thu, 11 Aug 2022 12:42:40 -0700 Subject: [PATCH] gpu: add BindGroup.Entry buffer/sampler/textureView constructor helpers Signed-off-by: Stephen Gutekanst --- gpu/src/bind_group.zig | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gpu/src/bind_group.zig b/gpu/src/bind_group.zig index 11da0a73..37d03508 100644 --- a/gpu/src/bind_group.zig +++ b/gpu/src/bind_group.zig @@ -14,6 +14,34 @@ pub const BindGroup = opaque { size: u64, sampler: ?*Sampler = null, texture_view: ?*TextureView = null, + + /// Helper to create a buffer BindGroup.Entry. + pub fn buffer(binding: u32, buf: *Buffer, offset: u64, size: u64) Entry { + return .{ + .binding = binding, + .buffer = buf, + .offset = offset, + .size = size, + }; + } + + /// Helper to create a sampler BindGroup.Entry. + pub fn sampler(binding: u32, _sampler: *Sampler) Entry { + return .{ + .binding = binding, + .sampler = _sampler, + .size = 0, + }; + } + + /// Helper to create a texture view BindGroup.Entry. + pub fn textureView(binding: u32, texture_view: *TextureView) Entry { + return .{ + .binding = binding, + .texture_view = texture_view, + .size = 0, + }; + } }; pub const Descriptor = extern struct {