gpu: add Texture.Usage flagset

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-07-11 09:02:20 -07:00 committed by Stephen Gutekanst
parent 72d9a325fe
commit 5ec7853d52
3 changed files with 28 additions and 12 deletions

View file

@ -1,17 +1,5 @@
typedef uint32_t WGPUFlags;
typedef enum WGPUTextureUsage {
WGPUTextureUsage_None = 0x00000000,
WGPUTextureUsage_CopySrc = 0x00000001,
WGPUTextureUsage_CopyDst = 0x00000002,
WGPUTextureUsage_TextureBinding = 0x00000004,
WGPUTextureUsage_StorageBinding = 0x00000008,
WGPUTextureUsage_RenderAttachment = 0x00000010,
WGPUTextureUsage_Present = 0x00000020,
WGPUTextureUsage_Force32 = 0x7FFFFFFF
} WGPUTextureUsage;
typedef WGPUFlags WGPUTextureUsageFlags;
typedef struct WGPUChainedStruct {
struct WGPUChainedStruct const * next;
WGPUSType sType;

View file

@ -39,6 +39,8 @@ pub const Usage = packed struct {
);
}
pub const none = Usage{};
pub fn equal(a: Usage, b: Usage) bool {
return @truncate(u10, @bitCast(u32, a)) == @truncate(u10, @bitCast(u32, b));
}

View file

@ -1,3 +1,5 @@
const std = @import("std");
ptr: *anyopaque,
pub const Aspect = enum(u32) {
@ -128,3 +130,27 @@ pub const SampleType = enum(u32) {
sint = 0x00000004,
uint = 0x00000005,
};
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,
_padding: u26 = 0,
comptime {
std.debug.assert(
@sizeOf(@This()) == @sizeOf(u32) and
@bitSizeOf(@This()) == @bitSizeOf(u32),
);
}
pub const none = Usage{};
pub fn equal(a: Usage, b: Usage) bool {
return @truncate(u6, @bitCast(u32, a)) == @truncate(u6, @bitCast(u32, b));
}
};