gpu: Added helpers to BindGroup.Entry; make dynamic_offset a const slice (#215)

Helps hexops/mach#
This commit is contained in:
Michal Ziulek 2022-04-11 20:47:02 +02:00 committed by GitHub
parent 8c8534e609
commit f2ce208aa1
Failed to generate hash of commit
3 changed files with 33 additions and 5 deletions

View file

@ -35,6 +35,34 @@ pub const Entry = struct {
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, sam: Sampler) Entry {
return .{
.binding = binding,
.sampler = sam,
.size = 0,
};
}
/// Helper to create a texture view BindGroup.Entry.
pub fn textureView(binding: u32, texview: TextureView) Entry {
return .{
.binding = binding,
.texture_view = texview,
.size = 0,
};
}
};
pub const Descriptor = struct {