diff --git a/gpu/TODO-webgpu.h b/gpu/TODO-webgpu.h index 232b59bd..a798ebbc 100644 --- a/gpu/TODO-webgpu.h +++ b/gpu/TODO-webgpu.h @@ -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; diff --git a/gpu/src/Buffer.zig b/gpu/src/Buffer.zig index 586f5698..0141e63f 100644 --- a/gpu/src/Buffer.zig +++ b/gpu/src/Buffer.zig @@ -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)); } diff --git a/gpu/src/Texture.zig b/gpu/src/Texture.zig index 235081e3..c749a0e0 100644 --- a/gpu/src/Texture.zig +++ b/gpu/src/Texture.zig @@ -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)); + } +};