From 093be3aa534d71c7c4dad17f23aa45d07a6498dc Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Tue, 16 Aug 2022 19:32:45 -0700 Subject: [PATCH] gpu: add CompilationInfo.getMessages slice helper Signed-off-by: Stephen Gutekanst --- gpu/README.md | 1 + gpu/src/types.zig | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gpu/README.md b/gpu/README.md index dcbcbc09..5fdfcb54 100644 --- a/gpu/README.md +++ b/gpu/README.md @@ -180,6 +180,7 @@ And, to initialize data structures with slices in them, the following helpers ar * `VertexBufferLayout.init` * `VertexState.init` * `FragmentState.init` +* `CompilationInfo.getMessages` ### Typed callbacks diff --git a/gpu/src/types.zig b/gpu/src/types.zig index 029a6bfe..a9fd22ba 100644 --- a/gpu/src/types.zig +++ b/gpu/src/types.zig @@ -618,9 +618,16 @@ pub const BlendState = extern struct { pub const CompilationInfo = extern struct { next_in_chain: ?*const ChainedStruct = null, - // TODO: slice helper message_count: u32, messages: ?[*]const CompilationMessage = null, + + /// Helper to get messages as a slice. + pub fn getMessages(info: CompilationInfo) ?[]const CompilationMessage { + if (info.messages) |messages| { + return messages[0..info.message_count]; + } + return null; + } }; pub const DepthStencilState = extern struct {