diff --git a/gpu/src/interface.zig b/gpu/src/interface.zig index d8e921c0..8ed95881 100644 --- a/gpu/src/interface.zig +++ b/gpu/src/interface.zig @@ -196,7 +196,7 @@ pub fn Interface(comptime T: type) type { assertDecl(T, "swapChainPresent", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void); assertDecl(T, "swapChainReference", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void); assertDecl(T, "swapChainRelease", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void); - assertDecl(T, "textureCreateView", fn (texture: *gpu.Texture, descriptor: ?*const gpu.TextureViewDescriptor) callconv(.Inline) *gpu.TextureView); + assertDecl(T, "textureCreateView", fn (texture: *gpu.Texture, descriptor: ?*const gpu.TextureView.Descriptor) callconv(.Inline) *gpu.TextureView); assertDecl(T, "textureDestroy", fn (texture: *gpu.Texture) callconv(.Inline) void); assertDecl(T, "textureGetDepthOrArrayLayers", fn (texture: *gpu.Texture) callconv(.Inline) u32); assertDecl(T, "textureGetDimension", fn (texture: *gpu.Texture) callconv(.Inline) gpu.TextureDimension); @@ -1136,7 +1136,7 @@ pub fn Export(comptime T: type) type { } // WGPU_EXPORT WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, WGPUTextureViewDescriptor const * descriptor /* nullable */); - export fn wgpuTextureCreateView(texture: *gpu.Texture, descriptor: ?*const gpu.TextureViewDescriptor) *gpu.TextureView { + export fn wgpuTextureCreateView(texture: *gpu.Texture, descriptor: ?*const gpu.TextureView.Descriptor) *gpu.TextureView { return T.textureCreateView(texture, descriptor); } @@ -2349,7 +2349,7 @@ pub const StubInterface = Interface(struct { unreachable; } - pub inline fn textureCreateView(texture: *gpu.Texture, descriptor: ?*const gpu.TextureViewDescriptor) *gpu.TextureView { + pub inline fn textureCreateView(texture: *gpu.Texture, descriptor: ?*const gpu.TextureView.Descriptor) *gpu.TextureView { _ = texture; _ = descriptor; unreachable; diff --git a/gpu/src/texture.zig b/gpu/src/texture.zig index 6390d691..1e7f0c98 100644 --- a/gpu/src/texture.zig +++ b/gpu/src/texture.zig @@ -1,14 +1,12 @@ const std = @import("std"); const ChainedStruct = @import("types.zig").ChainedStruct; const TextureView = @import("texture_view.zig").TextureView; -const TextureViewDimension = @import("texture_view.zig").TextureViewDimension; -const TextureViewDescriptor = @import("texture_view.zig").TextureViewDescriptor; const Extent3D = @import("types.zig").Extent3D; const Impl = @import("interface.zig").Impl; const copy_stride_undefined = @import("main.zig").copy_stride_undefined; pub const Texture = opaque { - pub inline fn createView(texture: *Texture, descriptor: ?*const TextureViewDescriptor) *TextureView { + pub inline fn createView(texture: *Texture, descriptor: ?*const TextureView.Descriptor) *TextureView { return Impl.textureCreateView(texture, descriptor); } @@ -217,7 +215,7 @@ pub const TextureUsageFlags = packed struct { pub const TextureBindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, sample_type: TextureSampleType = .undef, - view_dimension: TextureViewDimension = .dimension_undef, + view_dimension: TextureView.Dimension = .dimension_undef, multisampled: bool = false, }; diff --git a/gpu/src/texture_view.zig b/gpu/src/texture_view.zig index 84d1be35..ea2ec16d 100644 --- a/gpu/src/texture_view.zig +++ b/gpu/src/texture_view.zig @@ -7,6 +7,28 @@ const mip_level_count_undefined = @import("main.zig").mip_level_count_undefined; const array_layer_count_undefined = @import("main.zig").array_layer_count_undefined; pub const TextureView = opaque { + pub const Dimension = enum(u32) { + dimension_undef = 0x00000000, + dimension_1d = 0x00000001, + dimension_2d = 0x00000002, + dimension_2d_array = 0x00000003, + dimension_cube = 0x00000004, + dimension_cube_array = 0x00000005, + dimension_3d = 0x00000006, + }; + + pub const Descriptor = extern struct { + next_in_chain: ?*const ChainedStruct = null, + label: ?[*:0]const u8 = null, + format: TextureFormat = .undef, + dimension: Dimension = .dimension_undef, + base_mip_level: u32 = 0, + mip_level_count: u32 = mip_level_count_undefined, + base_array_layer: u32 = 0, + array_layer_count: u32 = array_layer_count_undefined, + aspect: TextureAspect = .all, + }; + pub inline fn setLabel(texture_view: *TextureView, label: [*:0]const u8) void { Impl.textureViewSetLabel(texture_view, label); } @@ -19,25 +41,3 @@ pub const TextureView = opaque { Impl.textureViewRelease(texture_view); } }; - -pub const TextureViewDimension = enum(u32) { - dimension_undef = 0x00000000, - dimension_1d = 0x00000001, - dimension_2d = 0x00000002, - dimension_2d_array = 0x00000003, - dimension_cube = 0x00000004, - dimension_cube_array = 0x00000005, - dimension_3d = 0x00000006, -}; - -pub const TextureViewDescriptor = extern struct { - next_in_chain: ?*const ChainedStruct = null, - label: ?[*:0]const u8 = null, - format: TextureFormat = .undef, - dimension: TextureViewDimension = .dimension_undef, - base_mip_level: u32 = 0, - mip_level_count: u32 = mip_level_count_undefined, - base_array_layer: u32 = 0, - array_layer_count: u32 = array_layer_count_undefined, - aspect: TextureAspect = .all, -}; diff --git a/gpu/src/types.zig b/gpu/src/types.zig index 049f5920..e24e9a9a 100644 --- a/gpu/src/types.zig +++ b/gpu/src/types.zig @@ -5,7 +5,6 @@ const TextureFormat = @import("texture.zig").TextureFormat; const TextureAspect = @import("texture.zig").TextureAspect; const TextureDataLayout = @import("texture.zig").TextureDataLayout; const TextureView = @import("texture_view.zig").TextureView; -const TextureViewDimension = @import("texture_view.zig").TextureViewDimension; const Buffer = @import("buffer.zig").Buffer; const ShaderModule = @import("shader_module.zig").ShaderModule; const limit_u32_undefined = @import("main.zig").limit_u32_undefined; @@ -511,7 +510,7 @@ pub const StorageTextureBindingLayout = extern struct { next_in_chain: ?*const ChainedStruct = null, access: StorageTextureAccess = .undef, format: TextureFormat = .undef, - view_dimension: TextureViewDimension = .dimension_undef, + view_dimension: TextureView.Dimension = .dimension_undef, }; pub const VertexAttribute = extern struct {