Created GpuPrimitiveTolopogy to replace c.WGPUPrimitiveTopology
This commit is contained in:
parent
bcb1b1e98b
commit
fc57bee3af
@ -18,7 +18,17 @@ pub const RenderDef = struct {
|
|||||||
vertex_entry: []const u8 = "vs_main",
|
vertex_entry: []const u8 = "vs_main",
|
||||||
fragment_entry: []const u8 = "fs_main",
|
fragment_entry: []const u8 = "fs_main",
|
||||||
/// Primitive topology, default to triangle list
|
/// 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,
|
pip: c.WGPURenderPipeline,
|
||||||
@ -41,7 +51,7 @@ pub fn init(device: GpuDevice, wgsl: []const u8, def: RenderDef) !@This() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const color_target = c.WGPUColorTargetState{
|
const color_target = c.WGPUColorTargetState{
|
||||||
.format = @intCast(@intFromEnum(def.texture_format)),
|
.format = @intFromEnum(def.texture_format),
|
||||||
.blend = &blend,
|
.blend = &blend,
|
||||||
.writeMask = c.WGPUColorWriteMask_All,
|
.writeMask = c.WGPUColorWriteMask_All,
|
||||||
};
|
};
|
||||||
@ -61,7 +71,7 @@ pub fn init(device: GpuDevice, wgsl: []const u8, def: RenderDef) !@This() {
|
|||||||
.entryPoint = sv(def.vertex_entry),
|
.entryPoint = sv(def.vertex_entry),
|
||||||
},
|
},
|
||||||
.primitive = .{
|
.primitive = .{
|
||||||
.topology = def.topology,
|
.topology = @intFromEnum(def.topology),
|
||||||
.stripIndexFormat = c.WGPUIndexFormat_Undefined,
|
.stripIndexFormat = c.WGPUIndexFormat_Undefined,
|
||||||
.frontFace = c.WGPUFrontFace_CCW,
|
.frontFace = c.WGPUFrontFace_CCW,
|
||||||
.cullMode = c.WGPUCullMode_None,
|
.cullMode = c.WGPUCullMode_None,
|
||||||
|
|||||||
@ -29,7 +29,7 @@ pub fn init(gloc: GpuAllocator, format: GpuTextureFormat, size: c.WGPUExtent3D,
|
|||||||
.usage = use,
|
.usage = use,
|
||||||
.dimension = c.WGPUTextureDimension_2D,
|
.dimension = c.WGPUTextureDimension_2D,
|
||||||
.size = size,
|
.size = size,
|
||||||
.format = @intCast(@intFromEnum(format)),
|
.format = @intFromEnum(format),
|
||||||
.mipLevelCount = 1,
|
.mipLevelCount = 1,
|
||||||
.sampleCount = 1,
|
.sampleCount = 1,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -29,7 +29,7 @@ pub fn main(init: std.process.Init) !void {
|
|||||||
.{
|
.{
|
||||||
.bindings = &.{},
|
.bindings = &.{},
|
||||||
.texture_format = .RGBA8Unorm,
|
.texture_format = .RGBA8Unorm,
|
||||||
.topology = c.WGPUPrimitiveTopology_TriangleStrip,
|
.topology = .TriangleStrip,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
defer circle_rp.deinit();
|
defer circle_rp.deinit();
|
||||||
|
|||||||
@ -6,7 +6,7 @@ pub const GpuCompute = @import("GpuCompute.zig");
|
|||||||
pub const GpuRender = @import("GpuRender.zig");
|
pub const GpuRender = @import("GpuRender.zig");
|
||||||
pub const GpuTexture = @import("GpuTexture.zig");
|
pub const GpuTexture = @import("GpuTexture.zig");
|
||||||
|
|
||||||
pub const GpuTextureFormat = enum(c_int) {
|
pub const GpuTextureFormat = enum(c_uint) {
|
||||||
Undefined = 0,
|
Undefined = 0,
|
||||||
R8Unorm = 1,
|
R8Unorm = 1,
|
||||||
R8Snorm = 2,
|
R8Snorm = 2,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user