gpu: internalize Texture types
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
0dae027602
commit
cccfef52f9
10 changed files with 221 additions and 232 deletions
|
|
@ -3,7 +3,6 @@ const ShaderStageFlags = @import("types.zig").ShaderStageFlags;
|
||||||
const Buffer = @import("buffer.zig").Buffer;
|
const Buffer = @import("buffer.zig").Buffer;
|
||||||
const Sampler = @import("sampler.zig").Sampler;
|
const Sampler = @import("sampler.zig").Sampler;
|
||||||
const Texture = @import("texture.zig").Texture;
|
const Texture = @import("texture.zig").Texture;
|
||||||
const TextureBindingLayout = @import("texture.zig").TextureBindingLayout;
|
|
||||||
const StorageTextureBindingLayout = @import("types.zig").StorageTextureBindingLayout;
|
const StorageTextureBindingLayout = @import("types.zig").StorageTextureBindingLayout;
|
||||||
const Impl = @import("interface.zig").Impl;
|
const Impl = @import("interface.zig").Impl;
|
||||||
|
|
||||||
|
|
@ -14,7 +13,7 @@ pub const BindGroupLayout = opaque {
|
||||||
visibility: ShaderStageFlags,
|
visibility: ShaderStageFlags,
|
||||||
buffer: Buffer.BindingLayout,
|
buffer: Buffer.BindingLayout,
|
||||||
sampler: Sampler.BindingLayout,
|
sampler: Sampler.BindingLayout,
|
||||||
texture: TextureBindingLayout,
|
texture: Texture.BindingLayout,
|
||||||
storage_texture: StorageTextureBindingLayout,
|
storage_texture: StorageTextureBindingLayout,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
const ChainedStruct = @import("types.zig").ChainedStruct;
|
const ChainedStruct = @import("types.zig").ChainedStruct;
|
||||||
const Texture = @import("texture.zig").Texture;
|
const Texture = @import("texture.zig").Texture;
|
||||||
const TextureUsageFlags = @import("texture.zig").TextureUsageFlags;
|
|
||||||
|
|
||||||
pub const CacheDeviceDescriptor = extern struct {
|
pub const CacheDeviceDescriptor = extern struct {
|
||||||
chain: ChainedStruct,
|
chain: ChainedStruct,
|
||||||
|
|
@ -21,7 +20,7 @@ pub const InstanceDescriptor = extern struct {
|
||||||
|
|
||||||
pub const TextureInternalUsageDescriptor = extern struct {
|
pub const TextureInternalUsageDescriptor = extern struct {
|
||||||
chain: ChainedStruct,
|
chain: ChainedStruct,
|
||||||
internal_usage: TextureUsageFlags = TextureUsageFlags.none,
|
internal_usage: Texture.UsageFlags = Texture.UsageFlags.none,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TogglesDeviceDescriptor = extern struct {
|
pub const TogglesDeviceDescriptor = extern struct {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ const ShaderModule = @import("shader_module.zig").ShaderModule;
|
||||||
const Surface = @import("surface.zig").Surface;
|
const Surface = @import("surface.zig").Surface;
|
||||||
const SwapChain = @import("swap_chain.zig").SwapChain;
|
const SwapChain = @import("swap_chain.zig").SwapChain;
|
||||||
const Texture = @import("texture.zig").Texture;
|
const Texture = @import("texture.zig").Texture;
|
||||||
const TextureDescriptor = @import("texture.zig").TextureDescriptor;
|
|
||||||
const ChainedStruct = @import("types.zig").ChainedStruct;
|
const ChainedStruct = @import("types.zig").ChainedStruct;
|
||||||
const FeatureName = @import("types.zig").FeatureName;
|
const FeatureName = @import("types.zig").FeatureName;
|
||||||
const RequiredLimits = @import("types.zig").RequiredLimits;
|
const RequiredLimits = @import("types.zig").RequiredLimits;
|
||||||
|
|
@ -116,7 +115,7 @@ pub const Device = opaque {
|
||||||
return Impl.deviceCreateSwapChain(device, surface, descriptor);
|
return Impl.deviceCreateSwapChain(device, surface, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createTexture(device: *Device, descriptor: *const TextureDescriptor) *Texture {
|
pub inline fn createTexture(device: *Device, descriptor: *const Texture.Descriptor) *Texture {
|
||||||
return Impl.deviceCreateTexture(device, descriptor);
|
return Impl.deviceCreateTexture(device, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ pub fn Interface(comptime T: type) type {
|
||||||
assertDecl(T, "deviceCreateSampler", fn (device: *gpu.Device, descriptor: ?*const gpu.Sampler.Descriptor) callconv(.Inline) *gpu.Sampler);
|
assertDecl(T, "deviceCreateSampler", fn (device: *gpu.Device, descriptor: ?*const gpu.Sampler.Descriptor) callconv(.Inline) *gpu.Sampler);
|
||||||
assertDecl(T, "deviceCreateShaderModule", fn (device: *gpu.Device, descriptor: *const gpu.ShaderModule.Descriptor) callconv(.Inline) *gpu.ShaderModule);
|
assertDecl(T, "deviceCreateShaderModule", fn (device: *gpu.Device, descriptor: *const gpu.ShaderModule.Descriptor) callconv(.Inline) *gpu.ShaderModule);
|
||||||
assertDecl(T, "deviceCreateSwapChain", fn (device: *gpu.Device, surface: ?*gpu.Surface, descriptor: *const gpu.SwapChain.Descriptor) callconv(.Inline) *gpu.SwapChain);
|
assertDecl(T, "deviceCreateSwapChain", fn (device: *gpu.Device, surface: ?*gpu.Surface, descriptor: *const gpu.SwapChain.Descriptor) callconv(.Inline) *gpu.SwapChain);
|
||||||
assertDecl(T, "deviceCreateTexture", fn (device: *gpu.Device, descriptor: *const gpu.TextureDescriptor) callconv(.Inline) *gpu.Texture);
|
assertDecl(T, "deviceCreateTexture", fn (device: *gpu.Device, descriptor: *const gpu.Texture.Descriptor) callconv(.Inline) *gpu.Texture);
|
||||||
assertDecl(T, "deviceDestroy", fn (device: *gpu.Device) callconv(.Inline) void);
|
assertDecl(T, "deviceDestroy", fn (device: *gpu.Device) callconv(.Inline) void);
|
||||||
assertDecl(T, "deviceEnumerateFeatures", fn (device: *gpu.Device, features: [*]gpu.FeatureName) callconv(.Inline) usize);
|
assertDecl(T, "deviceEnumerateFeatures", fn (device: *gpu.Device, features: [*]gpu.FeatureName) callconv(.Inline) usize);
|
||||||
assertDecl(T, "deviceGetLimits", fn (device: *gpu.Device, limits: *gpu.SupportedLimits) callconv(.Inline) bool);
|
assertDecl(T, "deviceGetLimits", fn (device: *gpu.Device, limits: *gpu.SupportedLimits) callconv(.Inline) bool);
|
||||||
|
|
@ -135,7 +135,7 @@ pub fn Interface(comptime T: type) type {
|
||||||
assertDecl(T, "queueSetLabel", fn (queue: *gpu.Queue, label: [*:0]const u8) callconv(.Inline) void);
|
assertDecl(T, "queueSetLabel", fn (queue: *gpu.Queue, label: [*:0]const u8) callconv(.Inline) void);
|
||||||
assertDecl(T, "queueSubmit", fn (queue: *gpu.Queue, command_count: u32, commands: [*]*gpu.CommandBuffer) callconv(.Inline) void);
|
assertDecl(T, "queueSubmit", fn (queue: *gpu.Queue, command_count: u32, commands: [*]*gpu.CommandBuffer) callconv(.Inline) void);
|
||||||
assertDecl(T, "queueWriteBuffer", fn (queue: *gpu.Queue, buffer: *gpu.Buffer, buffer_offset: u64, data: *anyopaque, size: usize) callconv(.Inline) void);
|
assertDecl(T, "queueWriteBuffer", fn (queue: *gpu.Queue, buffer: *gpu.Buffer, buffer_offset: u64, data: *anyopaque, size: usize) callconv(.Inline) void);
|
||||||
assertDecl(T, "queueWriteTexture", fn (queue: *gpu.Queue, data: *anyopaque, data_size: usize, data_layout: *const gpu.TextureDataLayout, write_size: *const gpu.Extent3D) callconv(.Inline) void);
|
assertDecl(T, "queueWriteTexture", fn (queue: *gpu.Queue, data: *anyopaque, data_size: usize, data_layout: *const gpu.Texture.DataLayout, write_size: *const gpu.Extent3D) callconv(.Inline) void);
|
||||||
assertDecl(T, "queueReference", fn (queue: *gpu.Queue) callconv(.Inline) void);
|
assertDecl(T, "queueReference", fn (queue: *gpu.Queue) callconv(.Inline) void);
|
||||||
assertDecl(T, "queueRelease", fn (queue: *gpu.Queue) callconv(.Inline) void);
|
assertDecl(T, "queueRelease", fn (queue: *gpu.Queue) callconv(.Inline) void);
|
||||||
assertDecl(T, "renderBundleReference", fn (render_bundle: *gpu.RenderBundle) callconv(.Inline) void);
|
assertDecl(T, "renderBundleReference", fn (render_bundle: *gpu.RenderBundle) callconv(.Inline) void);
|
||||||
|
|
@ -191,7 +191,7 @@ pub fn Interface(comptime T: type) type {
|
||||||
assertDecl(T, "shaderModuleRelease", fn (shader_module: *gpu.ShaderModule) callconv(.Inline) void);
|
assertDecl(T, "shaderModuleRelease", fn (shader_module: *gpu.ShaderModule) callconv(.Inline) void);
|
||||||
assertDecl(T, "surfaceReference", fn (surface: *gpu.Surface) callconv(.Inline) void);
|
assertDecl(T, "surfaceReference", fn (surface: *gpu.Surface) callconv(.Inline) void);
|
||||||
assertDecl(T, "surfaceRelease", fn (surface: *gpu.Surface) callconv(.Inline) void);
|
assertDecl(T, "surfaceRelease", fn (surface: *gpu.Surface) callconv(.Inline) void);
|
||||||
assertDecl(T, "swapChainConfigure", fn (swap_chain: *gpu.SwapChain, format: gpu.TextureFormat, allowed_usage: gpu.TextureUsageFlags, width: u32, height: u32) callconv(.Inline) void);
|
assertDecl(T, "swapChainConfigure", fn (swap_chain: *gpu.SwapChain, format: gpu.Texture.Format, allowed_usage: gpu.Texture.UsageFlags, width: u32, height: u32) callconv(.Inline) void);
|
||||||
assertDecl(T, "swapChainGetCurrentTextureView", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) *gpu.TextureView);
|
assertDecl(T, "swapChainGetCurrentTextureView", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) *gpu.TextureView);
|
||||||
assertDecl(T, "swapChainPresent", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void);
|
assertDecl(T, "swapChainPresent", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void);
|
||||||
assertDecl(T, "swapChainReference", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void);
|
assertDecl(T, "swapChainReference", fn (swap_chain: *gpu.SwapChain) callconv(.Inline) void);
|
||||||
|
|
@ -199,12 +199,12 @@ pub fn Interface(comptime T: type) type {
|
||||||
assertDecl(T, "textureCreateView", fn (texture: *gpu.Texture, descriptor: ?*const gpu.TextureView.Descriptor) 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, "textureDestroy", fn (texture: *gpu.Texture) callconv(.Inline) void);
|
||||||
assertDecl(T, "textureGetDepthOrArrayLayers", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
assertDecl(T, "textureGetDepthOrArrayLayers", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
||||||
assertDecl(T, "textureGetDimension", fn (texture: *gpu.Texture) callconv(.Inline) gpu.TextureDimension);
|
assertDecl(T, "textureGetDimension", fn (texture: *gpu.Texture) callconv(.Inline) gpu.Texture.Dimension);
|
||||||
assertDecl(T, "textureGetFormat", fn (texture: *gpu.Texture) callconv(.Inline) gpu.TextureFormat);
|
assertDecl(T, "textureGetFormat", fn (texture: *gpu.Texture) callconv(.Inline) gpu.Texture.Format);
|
||||||
assertDecl(T, "textureGetHeight", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
assertDecl(T, "textureGetHeight", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
||||||
assertDecl(T, "textureGetMipLevelCount", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
assertDecl(T, "textureGetMipLevelCount", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
||||||
assertDecl(T, "textureGetSampleCount", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
assertDecl(T, "textureGetSampleCount", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
||||||
assertDecl(T, "textureGetUsage", fn (texture: *gpu.Texture) callconv(.Inline) gpu.TextureUsageFlags);
|
assertDecl(T, "textureGetUsage", fn (texture: *gpu.Texture) callconv(.Inline) gpu.Texture.UsageFlags);
|
||||||
assertDecl(T, "textureGetWidth", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
assertDecl(T, "textureGetWidth", fn (texture: *gpu.Texture) callconv(.Inline) u32);
|
||||||
assertDecl(T, "textureSetLabel", fn (texture: *gpu.Texture, label: [*:0]const u8) callconv(.Inline) void);
|
assertDecl(T, "textureSetLabel", fn (texture: *gpu.Texture, label: [*:0]const u8) callconv(.Inline) void);
|
||||||
assertDecl(T, "textureReference", fn (texture: *gpu.Texture) callconv(.Inline) void);
|
assertDecl(T, "textureReference", fn (texture: *gpu.Texture) callconv(.Inline) void);
|
||||||
|
|
@ -634,7 +634,7 @@ pub fn Export(comptime T: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor);
|
// WGPU_EXPORT WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, WGPUTextureDescriptor const * descriptor);
|
||||||
export fn wgpuDeviceCreateTexture(device: *gpu.Device, descriptor: *const gpu.TextureDescriptor) *gpu.Texture {
|
export fn wgpuDeviceCreateTexture(device: *gpu.Device, descriptor: *const gpu.Texture.Descriptor) *gpu.Texture {
|
||||||
return T.deviceCreateTexture(device, descriptor);
|
return T.deviceCreateTexture(device, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -829,7 +829,7 @@ pub fn Export(comptime T: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize);
|
// WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize);
|
||||||
export fn wgpuQueueWriteTexture(queue: *gpu.Queue, data: *anyopaque, data_size: usize, data_layout: *const gpu.TextureDataLayout, write_size: *const gpu.Extent3D) void {
|
export fn wgpuQueueWriteTexture(queue: *gpu.Queue, data: *anyopaque, data_size: usize, data_layout: *const gpu.Texture.DataLayout, write_size: *const gpu.Extent3D) void {
|
||||||
T.queueWriteTexture(queue, data, data_size, data_layout, write_size);
|
T.queueWriteTexture(queue, data, data_size, data_layout, write_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1108,11 +1108,11 @@ pub fn Export(comptime T: type) type {
|
||||||
T.surfaceRelease(surface);
|
T.surfaceRelease(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Zig cannot currently export a packed struct gpu.TextureUsageFlags, so we use a u32
|
// TODO: Zig cannot currently export a packed struct gpu.Texture.UsageFlags, so we use a u32
|
||||||
// for now.
|
// for now.
|
||||||
// WGPU_EXPORT void wgpuSwapChainConfigure(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height);
|
// WGPU_EXPORT void wgpuSwapChainConfigure(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height);
|
||||||
export fn wgpuSwapChainConfigure(swap_chain: *gpu.SwapChain, format: gpu.TextureFormat, allowed_usage: u32, width: u32, height: u32) void {
|
export fn wgpuSwapChainConfigure(swap_chain: *gpu.SwapChain, format: gpu.Texture.Format, allowed_usage: u32, width: u32, height: u32) void {
|
||||||
T.swapChainConfigure(swap_chain, format, @bitCast(gpu.TextureUsageFlags, allowed_usage), width, height);
|
T.swapChainConfigure(swap_chain, format, @bitCast(gpu.Texture.UsageFlags, allowed_usage), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
|
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
|
||||||
|
|
@ -1151,12 +1151,12 @@ pub fn Export(comptime T: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WGPU_EXPORT WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture);
|
// WGPU_EXPORT WGPUTextureDimension wgpuTextureGetDimension(WGPUTexture texture);
|
||||||
export fn wgpuTextureGetDimension(texture: *gpu.Texture) gpu.TextureDimension {
|
export fn wgpuTextureGetDimension(texture: *gpu.Texture) gpu.Texture.Dimension {
|
||||||
return T.textureGetDimension(texture);
|
return T.textureGetDimension(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture);
|
// WGPU_EXPORT WGPUTextureFormat wgpuTextureGetFormat(WGPUTexture texture);
|
||||||
export fn wgpuTextureGetFormat(texture: *gpu.Texture) gpu.TextureFormat {
|
export fn wgpuTextureGetFormat(texture: *gpu.Texture) gpu.Texture.Format {
|
||||||
return T.textureGetFormat(texture);
|
return T.textureGetFormat(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1176,7 +1176,7 @@ pub fn Export(comptime T: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WGPU_EXPORT WGPUTextureUsage wgpuTextureGetUsage(WGPUTexture texture);
|
// WGPU_EXPORT WGPUTextureUsage wgpuTextureGetUsage(WGPUTexture texture);
|
||||||
export fn wgpuTextureGetUsage(texture: *gpu.Texture) gpu.TextureUsageFlags {
|
export fn wgpuTextureGetUsage(texture: *gpu.Texture) gpu.Texture.UsageFlags {
|
||||||
return T.textureGetUsage(texture);
|
return T.textureGetUsage(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1722,7 +1722,7 @@ pub const StubInterface = Interface(struct {
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn deviceCreateTexture(device: *gpu.Device, descriptor: *const gpu.TextureDescriptor) *gpu.Texture {
|
pub inline fn deviceCreateTexture(device: *gpu.Device, descriptor: *const gpu.Texture.Descriptor) *gpu.Texture {
|
||||||
_ = device;
|
_ = device;
|
||||||
_ = descriptor;
|
_ = descriptor;
|
||||||
unreachable;
|
unreachable;
|
||||||
|
|
@ -1954,7 +1954,7 @@ pub const StubInterface = Interface(struct {
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn queueWriteTexture(queue: *gpu.Queue, data: *anyopaque, data_size: usize, data_layout: *const gpu.TextureDataLayout, write_size: *const gpu.Extent3D) void {
|
pub inline fn queueWriteTexture(queue: *gpu.Queue, data: *anyopaque, data_size: usize, data_layout: *const gpu.Texture.DataLayout, write_size: *const gpu.Extent3D) void {
|
||||||
_ = queue;
|
_ = queue;
|
||||||
_ = data;
|
_ = data;
|
||||||
_ = data_size;
|
_ = data_size;
|
||||||
|
|
@ -2320,7 +2320,7 @@ pub const StubInterface = Interface(struct {
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn swapChainConfigure(swap_chain: *gpu.SwapChain, format: gpu.TextureFormat, allowed_usage: gpu.TextureUsageFlags, width: u32, height: u32) void {
|
pub inline fn swapChainConfigure(swap_chain: *gpu.SwapChain, format: gpu.Texture.Format, allowed_usage: gpu.Texture.UsageFlags, width: u32, height: u32) void {
|
||||||
_ = swap_chain;
|
_ = swap_chain;
|
||||||
_ = format;
|
_ = format;
|
||||||
_ = allowed_usage;
|
_ = allowed_usage;
|
||||||
|
|
@ -2365,12 +2365,12 @@ pub const StubInterface = Interface(struct {
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn textureGetDimension(texture: *gpu.Texture) gpu.TextureDimension {
|
pub inline fn textureGetDimension(texture: *gpu.Texture) gpu.Texture.Dimension {
|
||||||
_ = texture;
|
_ = texture;
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn textureGetFormat(texture: *gpu.Texture) gpu.TextureFormat {
|
pub inline fn textureGetFormat(texture: *gpu.Texture) gpu.Texture.Format {
|
||||||
_ = texture;
|
_ = texture;
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
@ -2390,7 +2390,7 @@ pub const StubInterface = Interface(struct {
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn textureGetUsage(texture: *gpu.Texture) gpu.TextureUsageFlags {
|
pub inline fn textureGetUsage(texture: *gpu.Texture) gpu.Texture.UsageFlags {
|
||||||
_ = texture;
|
_ = texture;
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const CommandBuffer = @import("command_buffer.zig").CommandBuffer;
|
const CommandBuffer = @import("command_buffer.zig").CommandBuffer;
|
||||||
const Buffer = @import("buffer.zig").Buffer;
|
const Buffer = @import("buffer.zig").Buffer;
|
||||||
const TextureDataLayout = @import("texture.zig").TextureDataLayout;
|
const Texture = @import("texture.zig").Texture;
|
||||||
const ImageCopyTexture = @import("types.zig").ImageCopyTexture;
|
const ImageCopyTexture = @import("types.zig").ImageCopyTexture;
|
||||||
const ChainedStruct = @import("types.zig").ChainedStruct;
|
const ChainedStruct = @import("types.zig").ChainedStruct;
|
||||||
const Extent3D = @import("types.zig").Extent3D;
|
const Extent3D = @import("types.zig").Extent3D;
|
||||||
|
|
@ -45,7 +45,7 @@ pub const Queue = opaque {
|
||||||
Impl.queueWriteBuffer(queue, buffer, buffer_offset, data, size);
|
Impl.queueWriteBuffer(queue, buffer, buffer_offset, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn writeTexture(queue: *Queue, data: *anyopaque, data_size: usize, data_layout: *const TextureDataLayout, write_size: *const Extent3D) void {
|
pub inline fn writeTexture(queue: *Queue, data: *anyopaque, data_size: usize, data_layout: *const Texture.DataLayout, write_size: *const Extent3D) void {
|
||||||
Impl.queueWriteTexture(queue, data, data_size, data_layout, write_size);
|
Impl.queueWriteTexture(queue, data, data_size, data_layout, write_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
const Texture = @import("texture.zig").Texture;
|
const Texture = @import("texture.zig").Texture;
|
||||||
const TextureFormat = @import("texture.zig").TextureFormat;
|
|
||||||
const Buffer = @import("buffer.zig").Buffer;
|
const Buffer = @import("buffer.zig").Buffer;
|
||||||
const BindGroup = @import("bind_group.zig").BindGroup;
|
const BindGroup = @import("bind_group.zig").BindGroup;
|
||||||
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
|
const RenderPipeline = @import("render_pipeline.zig").RenderPipeline;
|
||||||
|
|
@ -14,8 +13,8 @@ pub const RenderBundleEncoder = opaque {
|
||||||
label: ?[*:0]const u8 = null,
|
label: ?[*:0]const u8 = null,
|
||||||
color_formats_count: u32,
|
color_formats_count: u32,
|
||||||
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
|
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
|
||||||
color_formats: ?[*]const TextureFormat,
|
color_formats: ?[*]const Texture.Format,
|
||||||
depth_stencil_format: TextureFormat = .undef,
|
depth_stencil_format: Texture.Format = .undef,
|
||||||
sample_count: u32 = 1,
|
sample_count: u32 = 1,
|
||||||
depth_read_only: bool = false,
|
depth_read_only: bool = false,
|
||||||
stencil_read_only: bool = false,
|
stencil_read_only: bool = false,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
const ChainedStruct = @import("types.zig").ChainedStruct;
|
const ChainedStruct = @import("types.zig").ChainedStruct;
|
||||||
const PresentMode = @import("types.zig").PresentMode;
|
const PresentMode = @import("types.zig").PresentMode;
|
||||||
const Texture = @import("texture.zig").Texture;
|
const Texture = @import("texture.zig").Texture;
|
||||||
const TextureUsageFlags = @import("texture.zig").TextureUsageFlags;
|
|
||||||
const TextureFormat = @import("texture.zig").TextureFormat;
|
|
||||||
const TextureView = @import("texture_view.zig").TextureView;
|
const TextureView = @import("texture_view.zig").TextureView;
|
||||||
const Impl = @import("interface.zig").Impl;
|
const Impl = @import("interface.zig").Impl;
|
||||||
|
|
||||||
|
|
@ -10,8 +8,8 @@ pub const SwapChain = opaque {
|
||||||
pub const Descriptor = extern struct {
|
pub const Descriptor = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
label: ?[*:0]const u8 = null,
|
label: ?[*:0]const u8 = null,
|
||||||
usage: TextureUsageFlags,
|
usage: Texture.UsageFlags,
|
||||||
format: TextureFormat,
|
format: Texture.Format,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
present_mode: PresentMode,
|
present_mode: PresentMode,
|
||||||
|
|
@ -19,7 +17,7 @@ pub const SwapChain = opaque {
|
||||||
implementation: u64 = 0,
|
implementation: u64 = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn configure(swap_chain: *SwapChain, format: TextureFormat, allowed_usage: TextureUsageFlags, width: u32, height: u32) void {
|
pub inline fn configure(swap_chain: *SwapChain, format: Texture.Format, allowed_usage: Texture.UsageFlags, width: u32, height: u32) void {
|
||||||
Impl.swapChainConfigure(swap_chain, format, allowed_usage, width, height);
|
Impl.swapChainConfigure(swap_chain, format, allowed_usage, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,60 +6,7 @@ const Impl = @import("interface.zig").Impl;
|
||||||
const copy_stride_undefined = @import("main.zig").copy_stride_undefined;
|
const copy_stride_undefined = @import("main.zig").copy_stride_undefined;
|
||||||
|
|
||||||
pub const Texture = opaque {
|
pub const Texture = opaque {
|
||||||
pub inline fn createView(texture: *Texture, descriptor: ?*const TextureView.Descriptor) *TextureView {
|
pub const Aspect = enum(u32) {
|
||||||
return Impl.textureCreateView(texture, descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn destroy(texture: *Texture) void {
|
|
||||||
Impl.textureDestroy(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getDepthOrArrayLayers(texture: *Texture) u32 {
|
|
||||||
return Impl.textureGetDepthOrArrayLayers(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getDimension(texture: *Texture) TextureDimension {
|
|
||||||
return Impl.textureGetDimension(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getFormat(texture: *Texture) TextureFormat {
|
|
||||||
return Impl.textureGetFormat(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getHeight(texture: *Texture) u32 {
|
|
||||||
return Impl.textureGetHeight(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getMipLevelCount(texture: *Texture) u32 {
|
|
||||||
return Impl.textureGetMipLevelCount(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getSampleCount(texture: *Texture) u32 {
|
|
||||||
return Impl.textureGetSampleCount(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getUsage(texture: *Texture) TextureUsageFlags {
|
|
||||||
return Impl.textureGetUsage(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn getWidth(texture: *Texture) u32 {
|
|
||||||
return Impl.textureGetWidth(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn setLabel(texture: *Texture, label: [*:0]const u8) void {
|
|
||||||
Impl.textureSetLabel(texture, label);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn reference(texture: *Texture) void {
|
|
||||||
Impl.textureReference(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn release(texture: *Texture) void {
|
|
||||||
Impl.textureRelease(texture);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const TextureAspect = enum(u32) {
|
|
||||||
all = 0x00000000,
|
all = 0x00000000,
|
||||||
stencil_only = 0x00000001,
|
stencil_only = 0x00000001,
|
||||||
depth_only = 0x00000002,
|
depth_only = 0x00000002,
|
||||||
|
|
@ -67,20 +14,20 @@ pub const TextureAspect = enum(u32) {
|
||||||
plane1_only = 0x00000004,
|
plane1_only = 0x00000004,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureComponentType = enum(u32) {
|
pub const ComponentType = enum(u32) {
|
||||||
float = 0x00000000,
|
float = 0x00000000,
|
||||||
sint = 0x00000001,
|
sint = 0x00000001,
|
||||||
uint = 0x00000002,
|
uint = 0x00000002,
|
||||||
depth_comparison = 0x00000003,
|
depth_comparison = 0x00000003,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureDimension = enum(u32) {
|
pub const Dimension = enum(u32) {
|
||||||
dimension_1d = 0x00000000,
|
dimension_1d = 0x00000000,
|
||||||
dimension_2d = 0x00000001,
|
dimension_2d = 0x00000001,
|
||||||
dimension_3d = 0x00000002,
|
dimension_3d = 0x00000002,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureFormat = enum(u32) {
|
pub const Format = enum(u32) {
|
||||||
undef = 0x00000000,
|
undef = 0x00000000,
|
||||||
r8_unorm = 0x00000001,
|
r8_unorm = 0x00000001,
|
||||||
r8_snorm = 0x00000002,
|
r8_snorm = 0x00000002,
|
||||||
|
|
@ -179,7 +126,7 @@ pub const TextureFormat = enum(u32) {
|
||||||
r8_bg8_biplanar420_unorm = 0x0000005f,
|
r8_bg8_biplanar420_unorm = 0x0000005f,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureSampleType = enum(u32) {
|
pub const SampleType = enum(u32) {
|
||||||
undef = 0x00000000,
|
undef = 0x00000000,
|
||||||
float = 0x00000001,
|
float = 0x00000001,
|
||||||
unfilterable_float = 0x00000002,
|
unfilterable_float = 0x00000002,
|
||||||
|
|
@ -188,7 +135,7 @@ pub const TextureSampleType = enum(u32) {
|
||||||
uint = 0x00000005,
|
uint = 0x00000005,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureUsageFlags = packed struct {
|
pub const UsageFlags = packed struct {
|
||||||
copy_src: bool = false,
|
copy_src: bool = false,
|
||||||
copy_dst: bool = false,
|
copy_dst: bool = false,
|
||||||
texture_binding: bool = false,
|
texture_binding: bool = false,
|
||||||
|
|
@ -205,37 +152,90 @@ pub const TextureUsageFlags = packed struct {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const none = TextureUsageFlags{};
|
pub const none = UsageFlags{};
|
||||||
|
|
||||||
pub fn equal(a: TextureUsageFlags, b: TextureUsageFlags) bool {
|
pub fn equal(a: UsageFlags, b: UsageFlags) bool {
|
||||||
return @truncate(u6, @bitCast(u32, a)) == @truncate(u6, @bitCast(u32, b));
|
return @truncate(u6, @bitCast(u32, a)) == @truncate(u6, @bitCast(u32, b));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureBindingLayout = extern struct {
|
pub const BindingLayout = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
sample_type: TextureSampleType = .undef,
|
sample_type: SampleType = .undef,
|
||||||
view_dimension: TextureView.Dimension = .dimension_undef,
|
view_dimension: TextureView.Dimension = .dimension_undef,
|
||||||
multisampled: bool = false,
|
multisampled: bool = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureDataLayout = extern struct {
|
pub const DataLayout = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
offset: u64 = 0,
|
offset: u64 = 0,
|
||||||
bytes_per_row: u32 = copy_stride_undefined,
|
bytes_per_row: u32 = copy_stride_undefined,
|
||||||
rows_per_image: u32 = copy_stride_undefined,
|
rows_per_image: u32 = copy_stride_undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextureDescriptor = extern struct {
|
pub const Descriptor = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
label: ?[*:0]const u8 = null,
|
label: ?[*:0]const u8 = null,
|
||||||
usage: TextureUsageFlags,
|
usage: UsageFlags,
|
||||||
dimension: TextureDimension = .dimension_2d,
|
dimension: Dimension = .dimension_2d,
|
||||||
size: Extent3D,
|
size: Extent3D,
|
||||||
format: TextureFormat,
|
format: Format,
|
||||||
mip_level_count: u32 = 1,
|
mip_level_count: u32 = 1,
|
||||||
sample_count: u32 = 1,
|
sample_count: u32 = 1,
|
||||||
view_format_count: u32 = 0,
|
view_format_count: u32 = 0,
|
||||||
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
|
// TODO: file a bug on Dawn, this is not marked as nullable but in fact is.
|
||||||
view_formats: ?[*]const TextureFormat,
|
view_formats: ?[*]const Format,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub inline fn createView(texture: *Texture, descriptor: ?*const TextureView.Descriptor) *TextureView {
|
||||||
|
return Impl.textureCreateView(texture, descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn destroy(texture: *Texture) void {
|
||||||
|
Impl.textureDestroy(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getDepthOrArrayLayers(texture: *Texture) u32 {
|
||||||
|
return Impl.textureGetDepthOrArrayLayers(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getDimension(texture: *Texture) Dimension {
|
||||||
|
return Impl.textureGetDimension(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getFormat(texture: *Texture) Format {
|
||||||
|
return Impl.textureGetFormat(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getHeight(texture: *Texture) u32 {
|
||||||
|
return Impl.textureGetHeight(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getMipLevelCount(texture: *Texture) u32 {
|
||||||
|
return Impl.textureGetMipLevelCount(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getSampleCount(texture: *Texture) u32 {
|
||||||
|
return Impl.textureGetSampleCount(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getUsage(texture: *Texture) UsageFlags {
|
||||||
|
return Impl.textureGetUsage(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn getWidth(texture: *Texture) u32 {
|
||||||
|
return Impl.textureGetWidth(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn setLabel(texture: *Texture, label: [*:0]const u8) void {
|
||||||
|
Impl.textureSetLabel(texture, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn reference(texture: *Texture) void {
|
||||||
|
Impl.textureReference(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub inline fn release(texture: *Texture) void {
|
||||||
|
Impl.textureRelease(texture);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
const ChainedStruct = @import("types.zig").ChainedStruct;
|
const ChainedStruct = @import("types.zig").ChainedStruct;
|
||||||
const Texture = @import("texture.zig").Texture;
|
const Texture = @import("texture.zig").Texture;
|
||||||
const TextureFormat = @import("texture.zig").TextureFormat;
|
|
||||||
const TextureAspect = @import("texture.zig").TextureAspect;
|
|
||||||
const Impl = @import("interface.zig").Impl;
|
const Impl = @import("interface.zig").Impl;
|
||||||
const mip_level_count_undefined = @import("main.zig").mip_level_count_undefined;
|
const mip_level_count_undefined = @import("main.zig").mip_level_count_undefined;
|
||||||
const array_layer_count_undefined = @import("main.zig").array_layer_count_undefined;
|
const array_layer_count_undefined = @import("main.zig").array_layer_count_undefined;
|
||||||
|
|
@ -20,13 +18,13 @@ pub const TextureView = opaque {
|
||||||
pub const Descriptor = extern struct {
|
pub const Descriptor = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
label: ?[*:0]const u8 = null,
|
label: ?[*:0]const u8 = null,
|
||||||
format: TextureFormat = .undef,
|
format: Texture.Format = .undef,
|
||||||
dimension: Dimension = .dimension_undef,
|
dimension: Dimension = .dimension_undef,
|
||||||
base_mip_level: u32 = 0,
|
base_mip_level: u32 = 0,
|
||||||
mip_level_count: u32 = mip_level_count_undefined,
|
mip_level_count: u32 = mip_level_count_undefined,
|
||||||
base_array_layer: u32 = 0,
|
base_array_layer: u32 = 0,
|
||||||
array_layer_count: u32 = array_layer_count_undefined,
|
array_layer_count: u32 = array_layer_count_undefined,
|
||||||
aspect: TextureAspect = .all,
|
aspect: Texture.Aspect = .all,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn setLabel(texture_view: *TextureView, label: [*:0]const u8) void {
|
pub inline fn setLabel(texture_view: *TextureView, label: [*:0]const u8) void {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const Texture = @import("texture.zig").Texture;
|
const Texture = @import("texture.zig").Texture;
|
||||||
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 TextureView = @import("texture_view.zig").TextureView;
|
||||||
const Buffer = @import("buffer.zig").Buffer;
|
const Buffer = @import("buffer.zig").Buffer;
|
||||||
const ShaderModule = @import("shader_module.zig").ShaderModule;
|
const ShaderModule = @import("shader_module.zig").ShaderModule;
|
||||||
|
|
@ -509,7 +506,7 @@ pub const StencilFaceState = extern struct {
|
||||||
pub const StorageTextureBindingLayout = extern struct {
|
pub const StorageTextureBindingLayout = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
access: StorageTextureAccess = .undef,
|
access: StorageTextureAccess = .undef,
|
||||||
format: TextureFormat = .undef,
|
format: Texture.Format = .undef,
|
||||||
view_dimension: TextureView.Dimension = .dimension_undef,
|
view_dimension: TextureView.Dimension = .dimension_undef,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -533,7 +530,7 @@ pub const CompilationInfo = extern struct {
|
||||||
|
|
||||||
pub const DepthStencilState = extern struct {
|
pub const DepthStencilState = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
format: TextureFormat,
|
format: Texture.Format,
|
||||||
depth_write_enabled: bool = false,
|
depth_write_enabled: bool = false,
|
||||||
depth_compare: CompareFunction = .always,
|
depth_compare: CompareFunction = .always,
|
||||||
stencil_front: StencilFaceState,
|
stencil_front: StencilFaceState,
|
||||||
|
|
@ -547,7 +544,7 @@ pub const DepthStencilState = extern struct {
|
||||||
|
|
||||||
pub const ImageCopyBuffer = extern struct {
|
pub const ImageCopyBuffer = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
layout: TextureDataLayout,
|
layout: Texture.DataLayout,
|
||||||
buffer: *Buffer,
|
buffer: *Buffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -556,7 +553,7 @@ pub const ImageCopyTexture = extern struct {
|
||||||
texture: *Texture,
|
texture: *Texture,
|
||||||
mip_level: u32 = 0,
|
mip_level: u32 = 0,
|
||||||
origin: Origin3D,
|
origin: Origin3D,
|
||||||
aspect: TextureAspect = .all,
|
aspect: Texture.Aspect = .all,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ProgrammableStageDescriptor = extern struct {
|
pub const ProgrammableStageDescriptor = extern struct {
|
||||||
|
|
@ -603,7 +600,7 @@ pub const VertexBufferLayout = extern struct {
|
||||||
|
|
||||||
pub const ColorTargetState = extern struct {
|
pub const ColorTargetState = extern struct {
|
||||||
next_in_chain: ?*const ChainedStruct = null,
|
next_in_chain: ?*const ChainedStruct = null,
|
||||||
format: TextureFormat,
|
format: Texture.Format,
|
||||||
blend: ?*const BlendState,
|
blend: ?*const BlendState,
|
||||||
write_mask: ColorWriteMaskFlags = ColorWriteMaskFlags.all,
|
write_mask: ColorWriteMaskFlags = ColorWriteMaskFlags.all,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue