gpu: make Buffer an enum with methods
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
425eb81019
commit
35054ff938
2 changed files with 49 additions and 45 deletions
|
|
@ -1,47 +1,51 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
ptr: *anyopaque,
|
pub const Buffer = enum(usize) {
|
||||||
|
_,
|
||||||
|
|
||||||
pub const BindingType = enum(u32) {
|
pub const none: Buffer = @intToEnum(Buffer, 0);
|
||||||
undef = 0x00000000,
|
|
||||||
uniform = 0x00000001,
|
pub const BindingType = enum(u32) {
|
||||||
storage = 0x00000002,
|
undef = 0x00000000,
|
||||||
read_only_storage = 0x00000003,
|
uniform = 0x00000001,
|
||||||
};
|
storage = 0x00000002,
|
||||||
|
read_only_storage = 0x00000003,
|
||||||
pub const MapAsyncStatus = enum(u32) {
|
};
|
||||||
success = 0x00000000,
|
|
||||||
err = 0x00000001,
|
pub const MapAsyncStatus = enum(u32) {
|
||||||
unknown = 0x00000002,
|
success = 0x00000000,
|
||||||
device_lost = 0x00000003,
|
err = 0x00000001,
|
||||||
destroyed_before_callback = 0x00000004,
|
unknown = 0x00000002,
|
||||||
unmapped_before_callback = 0x00000005,
|
device_lost = 0x00000003,
|
||||||
};
|
destroyed_before_callback = 0x00000004,
|
||||||
|
unmapped_before_callback = 0x00000005,
|
||||||
pub const Usage = packed struct {
|
};
|
||||||
map_read: bool = false,
|
|
||||||
map_write: bool = false,
|
pub const Usage = packed struct {
|
||||||
copy_src: bool = false,
|
map_read: bool = false,
|
||||||
copy_dst: bool = false,
|
map_write: bool = false,
|
||||||
index: bool = false,
|
copy_src: bool = false,
|
||||||
vertex: bool = false,
|
copy_dst: bool = false,
|
||||||
uniform: bool = false,
|
index: bool = false,
|
||||||
storage: bool = false,
|
vertex: bool = false,
|
||||||
indirect: bool = false,
|
uniform: bool = false,
|
||||||
query_resolve: bool = false,
|
storage: bool = false,
|
||||||
|
indirect: bool = false,
|
||||||
_padding: u22 = 0,
|
query_resolve: bool = false,
|
||||||
|
|
||||||
comptime {
|
_padding: u22 = 0,
|
||||||
std.debug.assert(
|
|
||||||
@sizeOf(@This()) == @sizeOf(u32) and
|
comptime {
|
||||||
@bitSizeOf(@This()) == @bitSizeOf(u32),
|
std.debug.assert(
|
||||||
);
|
@sizeOf(@This()) == @sizeOf(u32) and
|
||||||
}
|
@bitSizeOf(@This()) == @bitSizeOf(u32),
|
||||||
|
);
|
||||||
pub const none = Usage{};
|
}
|
||||||
|
|
||||||
pub fn equal(a: Usage, b: Usage) bool {
|
pub const none = Usage{};
|
||||||
return @truncate(u10, @bitCast(u32, a)) == @truncate(u10, @bitCast(u32, b));
|
|
||||||
}
|
pub fn equal(a: Usage, b: Usage) bool {
|
||||||
|
return @truncate(u10, @bitCast(u32, a)) == @truncate(u10, @bitCast(u32, b));
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ pub const whole_size = 0xffffffffffffffff;
|
||||||
pub const Adapter = @import("Adapter.zig");
|
pub const Adapter = @import("Adapter.zig");
|
||||||
pub const BindGroup = @import("BindGroup.zig");
|
pub const BindGroup = @import("BindGroup.zig");
|
||||||
pub const BindGroupLayout = @import("BindGroupLayout.zig");
|
pub const BindGroupLayout = @import("BindGroupLayout.zig");
|
||||||
pub const Buffer = @import("Buffer.zig");
|
pub const Buffer = @import("buffer.zig").Buffer;
|
||||||
pub const CommandBuffer = @import("CommandBuffer.zig");
|
pub const CommandBuffer = @import("CommandBuffer.zig");
|
||||||
pub const CommandEncoder = @import("CommandEncoder.zig");
|
pub const CommandEncoder = @import("CommandEncoder.zig");
|
||||||
pub const ComputePassEncoder = @import("ComputePassEncoder.zig");
|
pub const ComputePassEncoder = @import("ComputePassEncoder.zig");
|
||||||
|
|
@ -40,7 +40,7 @@ test {
|
||||||
refAllDecls(@import("Adapter.zig"));
|
refAllDecls(@import("Adapter.zig"));
|
||||||
refAllDecls(@import("BindGroup.zig"));
|
refAllDecls(@import("BindGroup.zig"));
|
||||||
refAllDecls(@import("BindGroupLayout.zig"));
|
refAllDecls(@import("BindGroupLayout.zig"));
|
||||||
refAllDecls(@import("Buffer.zig"));
|
refAllDecls(@import("buffer.zig"));
|
||||||
refAllDecls(@import("CommandBuffer.zig"));
|
refAllDecls(@import("CommandBuffer.zig"));
|
||||||
refAllDecls(@import("CommandEncoder.zig"));
|
refAllDecls(@import("CommandEncoder.zig"));
|
||||||
refAllDecls(@import("ComputePassEncoder.zig"));
|
refAllDecls(@import("ComputePassEncoder.zig"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue