gpu: move TextureUsage -> Texture.Usage

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-11 15:43:28 -07:00 committed by Stephen Gutekanst
parent 58c27b41a8
commit 281d6a2016
5 changed files with 15 additions and 17 deletions

View file

@ -37,7 +37,6 @@ const CommandEncoder = @import("CommandEncoder.zig");
const ComputePassEncoder = @import("ComputePassEncoder.zig");
const ComputePipeline = @import("ComputePipeline.zig");
const TextureUsage = @import("enums.zig").TextureUsage;
const TextureFormat = @import("enums.zig").TextureFormat;
const PresentMode = @import("enums.zig").PresentMode;
@ -511,7 +510,7 @@ const swap_chain_vtable = SwapChain.VTable{
}
}).release,
.configure = (struct {
pub fn configure(ptr: *anyopaque, format: TextureFormat, allowed_usage: TextureUsage, width: u32, height: u32) void {
pub fn configure(ptr: *anyopaque, format: TextureFormat, allowed_usage: Texture.Usage, width: u32, height: u32) void {
c.wgpuSwapChainConfigure(
@ptrCast(c.WGPUSwapChain, ptr),
@enumToInt(format),

View file

@ -1,5 +1,5 @@
const std = @import("std");
const TextureUsage = @import("enums.zig").TextureUsage;
const Texture = @import("Texture.zig");
const TextureFormat = @import("enums.zig").TextureFormat;
const PresentMode = @import("enums.zig").PresentMode;
@ -13,7 +13,7 @@ vtable: *const VTable,
pub const VTable = struct {
reference: fn (ptr: *anyopaque) void,
release: fn (ptr: *anyopaque) void,
configure: fn (ptr: *anyopaque, format: TextureFormat, allowed_usage: TextureUsage, width: u32, height: u32) void,
configure: fn (ptr: *anyopaque, format: TextureFormat, allowed_usage: Texture.Usage, width: u32, height: u32) void,
// TODO:
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
// WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain);
@ -30,7 +30,7 @@ pub inline fn release(swap_chain: SwapChain) void {
pub inline fn configure(
swap_chain: SwapChain,
format: TextureFormat,
allowed_usage: TextureUsage,
allowed_usage: Texture.Usage,
width: u32,
height: u32,
) void {
@ -39,7 +39,7 @@ pub inline fn configure(
pub const Descriptor = struct {
label: ?[:0]const u8 = null,
usage: TextureUsage,
usage: Texture.Usage,
format: TextureFormat,
width: u32,
height: u32,

View file

@ -30,6 +30,16 @@ pub inline fn destroy(texture: Texture) void {
texture.vtable.destroy(texture.ptr);
}
pub const Usage = enum(u32) {
none = 0x00000000,
copy_src = 0x00000001,
copy_dst = 0x00000002,
texture_binding = 0x00000004,
storage_binding = 0x00000008,
render_attachment = 0x00000010,
present = 0x00000020,
};
test "syntax" {
_ = VTable;
_ = reference;

View file

@ -128,16 +128,6 @@ pub const TextureFormat = enum(u32) {
r8bg8biplanar420_unorm = 0x00000060,
};
pub const TextureUsage = enum(u32) {
none = 0x00000000,
copy_src = 0x00000001,
copy_dst = 0x00000002,
texture_binding = 0x00000004,
storage_binding = 0x00000008,
render_attachment = 0x00000010,
present = 0x00000020,
};
pub const AlphaMode = enum(u32) {
premultiplied = 0x00000000,
unpremultiplied = 0x00000001,

View file

@ -94,7 +94,6 @@ pub const PrimitiveState = @import("structs.zig").PrimitiveState;
// Enumerations
pub const Feature = @import("enums.zig").Feature;
pub const TextureUsage = @import("enums.zig").TextureUsage;
pub const TextureFormat = @import("enums.zig").TextureFormat;
pub const PresentMode = @import("enums.zig").PresentMode;
pub const AddressMode = @import("enums.zig").AddressMode;