gpu: convert Texture.Usage to packed struct
This commit is contained in:
parent
adf5332969
commit
614322edc7
4 changed files with 35 additions and 14 deletions
|
|
@ -504,7 +504,7 @@ const device_vtable = Device.VTable{
|
|||
const desc = c.WGPUSwapChainDescriptor{
|
||||
.nextInChain = null,
|
||||
.label = if (descriptor.label) |l| l else null,
|
||||
.usage = @enumToInt(descriptor.usage),
|
||||
.usage = @bitCast(u32, descriptor.usage),
|
||||
.format = @enumToInt(descriptor.format),
|
||||
.width = descriptor.width,
|
||||
.height = descriptor.height,
|
||||
|
|
@ -1017,7 +1017,7 @@ const swap_chain_vtable = SwapChain.VTable{
|
|||
c.wgpuSwapChainConfigure(
|
||||
@ptrCast(c.WGPUSwapChain, ptr),
|
||||
@enumToInt(format),
|
||||
@enumToInt(allowed_usage),
|
||||
@bitCast(u32, allowed_usage),
|
||||
width,
|
||||
height,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ pub const Descriptor = struct {
|
|||
pub fn equal(a: *const Descriptor, b: *const Descriptor) bool {
|
||||
if ((a.label == null) != (b.label == null)) return false;
|
||||
if (a.label != null and !std.mem.eql(u8, a.label.?, b.label.?)) return false;
|
||||
if (a.usage != b.usage) return false;
|
||||
if (!a.usage.equal(b.usage)) return false;
|
||||
if (a.format != b.format) return false;
|
||||
if (a.width != b.width) return false;
|
||||
if (a.height != b.height) return false;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
const std = @import("std");
|
||||
|
||||
const Extent3D = @import("data.zig").Extent3D;
|
||||
|
||||
const TextureView = @import("TextureView.zig");
|
||||
|
|
@ -48,14 +50,33 @@ pub const Descriptor = struct {
|
|||
sample_count: u32,
|
||||
};
|
||||
|
||||
pub const Usage = enum(u32) {
|
||||
none = 0x00000000,
|
||||
copy_src = 0x00000001,
|
||||
copy_dst = 0x00000002,
|
||||
texture_binding = 0x00000004,
|
||||
storage_binding = 0x00000008,
|
||||
render_attachment = 0x00000010,
|
||||
present = 0x00000020,
|
||||
pub const Usage = packed struct {
|
||||
copy_src: bool = false,
|
||||
copy_dst: bool = false,
|
||||
texture_binding: bool = false,
|
||||
storage_binding: bool = false,
|
||||
render_attachment: bool = false,
|
||||
present: bool = false,
|
||||
|
||||
_pad0: u2 = 0,
|
||||
_pad1: u8 = 0,
|
||||
_pad2: u16 = 0,
|
||||
|
||||
comptime {
|
||||
std.debug.assert(
|
||||
@sizeOf(@This()) == @sizeOf(u32) and
|
||||
@bitSizeOf(@This()) == @bitSizeOf(u32),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn equal(a: Usage, b: Usage) bool {
|
||||
return a.copy_src == b.copy_src and
|
||||
a.copy_dst == b.copy_dst and
|
||||
a.texture_binding == b.texture_binding and
|
||||
a.storage_binding == b.storage_binding and
|
||||
a.render_attachment == b.render_attachment and
|
||||
a.present == b.present;
|
||||
}
|
||||
};
|
||||
|
||||
pub const Format = enum(u32) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue