gpu: example: use default values, gpu helper APIs

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-17 01:26:52 -07:00
parent 46ec50b207
commit 7227e9a13f

View file

@ -72,17 +72,16 @@ pub fn main() !void {
.blend = &blend, .blend = &blend,
.write_mask = gpu.ColorWriteMaskFlags.all, .write_mask = gpu.ColorWriteMaskFlags.all,
}; };
const fragment = gpu.FragmentState{ const fragment = gpu.FragmentState.init(.{
.module = fs_module, .module = fs_module,
.entry_point = "main", .entry_point = "main",
.target_count = 1, .targets = &.{color_target},
.targets = &[_]gpu.ColorTargetState{color_target}, });
};
const pipeline_descriptor = gpu.RenderPipeline.Descriptor{ const pipeline_descriptor = gpu.RenderPipeline.Descriptor{
.fragment = &fragment, .fragment = &fragment,
.layout = null, .layout = null,
.depth_stencil = null, .depth_stencil = null,
.vertex = .{ .vertex = gpu.VertexState{
.module = vs_module, .module = vs_module,
.entry_point = "main", .entry_point = "main",
}, },
@ -152,12 +151,9 @@ fn frame(params: FrameParams) !void {
}; };
const encoder = params.device.createCommandEncoder(null); const encoder = params.device.createCommandEncoder(null);
const render_pass_info = gpu.RenderPassDescriptor{ const render_pass_info = gpu.RenderPassDescriptor.init(.{
.color_attachment_count = 1, .color_attachments = &.{color_attachment},
.color_attachments = &[_]gpu.RenderPassColorAttachment{color_attachment}, });
.depth_stencil_attachment = null,
.occlusion_query_set = null,
};
const pass = encoder.beginRenderPass(&render_pass_info); const pass = encoder.beginRenderPass(&render_pass_info);
pass.setPipeline(params.pipeline); pass.setPipeline(params.pipeline);
pass.draw(3, 1, 0, 0); pass.draw(3, 1, 0, 0);