diff --git a/gpu/TODO-webgpu.h b/gpu/TODO-webgpu.h index 00871079..19d43fb6 100644 --- a/gpu/TODO-webgpu.h +++ b/gpu/TODO-webgpu.h @@ -1,13 +1,3 @@ -pub const WGPUBindGroupLayoutEntry = extern struct { - next_in_chain: *const ChainedStruct, - binding: u32, - visibility: ShaderStageFlags, - buffer: BufferBindingLayout, - sampler: SamplerBindingLayout, - texture: TextureBindingLayout, - storage_texture: StorageTextureBindingLayout, -}; - pub const BlendState = extern struct { color: BlendComponent, alpha: BlendComponent, diff --git a/gpu/src/bind_group_layout.zig b/gpu/src/bind_group_layout.zig index af904921..4e1e3e4d 100644 --- a/gpu/src/bind_group_layout.zig +++ b/gpu/src/bind_group_layout.zig @@ -1,6 +1,23 @@ +const ChainedStruct = @import("types.zig").ChainedStruct; +const ShaderStageFlags = @import("types.zig").ShaderStageFlags; +const Buffer = @import("buffer.zig").Buffer; +const Sampler = @import("sampler.zig").Sampler; +const Texture = @import("texture.zig").Texture; +const StorageTextureBindingLayout = @import("types.zig").StorageTextureBindingLayout; + pub const BindGroupLayout = enum(usize) { _, // TODO: verify there is a use case for nullable value of this type. pub const none: BindGroupLayout = @intToEnum(BindGroupLayout, 0); + + pub const Entry = extern struct { + next_in_chain: *const ChainedStruct, + binding: u32, + visibility: ShaderStageFlags, + buffer: Buffer.BindingLayout, + sampler: Sampler.BindingLayout, + texture: Texture.BindingLayout, + storage_texture: StorageTextureBindingLayout, + }; }; diff --git a/gpu/src/types.zig b/gpu/src/types.zig index c9dfb488..6c1c07dc 100644 --- a/gpu/src/types.zig +++ b/gpu/src/types.zig @@ -345,7 +345,7 @@ pub const MapMode = packed struct { } }; -pub const ShaderStage = packed struct { +pub const ShaderStageFlags = packed struct { vertex: bool = false, fragment: bool = false, compute: bool = false, @@ -359,9 +359,9 @@ pub const ShaderStage = packed struct { ); } - pub const none = ShaderStage{}; + pub const none = ShaderStageFlags{}; - pub fn equal(a: ShaderStage, b: ShaderStage) bool { + pub fn equal(a: ShaderStageFlags, b: ShaderStageFlags) bool { return @truncate(u3, @bitCast(u32, a)) == @truncate(u3, @bitCast(u32, b)); } };