diff --git a/src/GpuRender.zig b/src/GpuRender.zig index 3f31ab8..e84fc5f 100644 --- a/src/GpuRender.zig +++ b/src/GpuRender.zig @@ -18,7 +18,17 @@ pub const RenderDef = struct { vertex_entry: []const u8 = "vs_main", fragment_entry: []const u8 = "fs_main", /// Primitive topology, default to triangle list - topology: c.WGPUPrimitiveTopology = c.WGPUPrimitiveTopology_TriangleList, + topology: GpuPrimitiveTopology = .TriangleList, +}; + +const GpuPrimitiveTopology = enum(c_uint) { + Undefined = 0x00000000, + PointList = 0x00000001, + LineList = 0x00000002, + LineStrip = 0x00000003, + TriangleList = 0x00000004, + TriangleStrip = 0x00000005, + Force32 = 0x7FFFFFFF, }; pip: c.WGPURenderPipeline, @@ -41,7 +51,7 @@ pub fn init(device: GpuDevice, wgsl: []const u8, def: RenderDef) !@This() { }; const color_target = c.WGPUColorTargetState{ - .format = @intCast(@intFromEnum(def.texture_format)), + .format = @intFromEnum(def.texture_format), .blend = &blend, .writeMask = c.WGPUColorWriteMask_All, }; @@ -61,7 +71,7 @@ pub fn init(device: GpuDevice, wgsl: []const u8, def: RenderDef) !@This() { .entryPoint = sv(def.vertex_entry), }, .primitive = .{ - .topology = def.topology, + .topology = @intFromEnum(def.topology), .stripIndexFormat = c.WGPUIndexFormat_Undefined, .frontFace = c.WGPUFrontFace_CCW, .cullMode = c.WGPUCullMode_None, diff --git a/src/GpuTexture.zig b/src/GpuTexture.zig index 4a1500b..35eb409 100644 --- a/src/GpuTexture.zig +++ b/src/GpuTexture.zig @@ -29,7 +29,7 @@ pub fn init(gloc: GpuAllocator, format: GpuTextureFormat, size: c.WGPUExtent3D, .usage = use, .dimension = c.WGPUTextureDimension_2D, .size = size, - .format = @intCast(@intFromEnum(format)), + .format = @intFromEnum(format), .mipLevelCount = 1, .sampleCount = 1, }; diff --git a/src/circle.zig b/src/circle.zig index 6d4d35d..5805b9c 100644 --- a/src/circle.zig +++ b/src/circle.zig @@ -29,7 +29,7 @@ pub fn main(init: std.process.Init) !void { .{ .bindings = &.{}, .texture_format = .RGBA8Unorm, - .topology = c.WGPUPrimitiveTopology_TriangleStrip, + .topology = .TriangleStrip, }, ); defer circle_rp.deinit(); diff --git a/src/lib.zig b/src/lib.zig index e39900d..b7209a1 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -6,7 +6,7 @@ pub const GpuCompute = @import("GpuCompute.zig"); pub const GpuRender = @import("GpuRender.zig"); pub const GpuTexture = @import("GpuTexture.zig"); -pub const GpuTextureFormat = enum(c_int) { +pub const GpuTextureFormat = enum(c_uint) { Undefined = 0, R8Unorm = 1, R8Snorm = 2,