From 158ba8db5945491d3643875a5f481ea797e2e231 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Wed, 27 Jul 2022 09:38:26 -0700 Subject: [PATCH] gpu: correct nullable slice / _count-ed pointers (bug in Dawn docs) Signed-off-by: Stephen Gutekanst --- gpu/src/bind_group.zig | 3 ++- gpu/src/bind_group_layout.zig | 3 ++- gpu/src/dawn.zig | 3 ++- gpu/src/main.zig | 6 ++++-- gpu/src/pipeline_layout.zig | 3 ++- gpu/src/query_set.zig | 3 ++- gpu/src/texture.zig | 3 ++- gpu/src/types.zig | 15 ++++++++++----- 8 files changed, 26 insertions(+), 13 deletions(-) diff --git a/gpu/src/bind_group.zig b/gpu/src/bind_group.zig index fb7fe1a8..03b2657a 100644 --- a/gpu/src/bind_group.zig +++ b/gpu/src/bind_group.zig @@ -34,5 +34,6 @@ pub const BindGroupDescriptor = extern struct { label: ?[*:0]const u8 = null, layout: BindGroupLayout, entry_count: u32, - entries: [*]const BindGroupEntry, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + entries: ?[*]const BindGroupEntry, }; diff --git a/gpu/src/bind_group_layout.zig b/gpu/src/bind_group_layout.zig index 76cdb8a3..ce53c40c 100644 --- a/gpu/src/bind_group_layout.zig +++ b/gpu/src/bind_group_layout.zig @@ -37,5 +37,6 @@ pub const BindGroupLayoutDescriptor = extern struct { next_in_chain: *const ChainedStruct, label: ?[*:0]const u8 = null, entry_count: u32, - entries: [*]const BindGroupLayoutEntry, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + entries: ?[*]const BindGroupLayoutEntry, }; diff --git a/gpu/src/dawn.zig b/gpu/src/dawn.zig index b9080310..ebc48f3d 100644 --- a/gpu/src/dawn.zig +++ b/gpu/src/dawn.zig @@ -15,7 +15,8 @@ pub const EncoderInternalUsageDescriptor = extern struct { pub const InstanceDescriptor = extern struct { chain: ChainedStruct, additional_runtime_search_paths_count: u32, - additional_runtime_search_paths: [*]const u8, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + additional_runtime_search_paths: ?[*]const u8, }; pub const TextureInternalUsageDescriptor = extern struct { diff --git a/gpu/src/main.zig b/gpu/src/main.zig index e9f6b1f8..aafdb012 100644 --- a/gpu/src/main.zig +++ b/gpu/src/main.zig @@ -112,11 +112,13 @@ pub const RenderPassDescriptor = extern struct { next_in_chain: *const types.ChainedStruct, label: ?[*:0]const u8 = null, color_attachment_count: u32, - color_attachments: [*]const types.RenderPassColorAttachment, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + color_attachments: ?[*]const types.RenderPassColorAttachment, depth_stencil_attachment: ?[*]const RenderPassDepthStencilAttachment = null, occlusion_query_set: ?query_set.QuerySet, timestamp_write_count: u32, - timestamp_writes: [*]const RenderPassTimestampWrite, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + timestamp_writes: ?[*]const RenderPassTimestampWrite, }; pub inline fn createInstance(descriptor: ?*const instance.InstanceDescriptor) ?instance.Instance { diff --git a/gpu/src/pipeline_layout.zig b/gpu/src/pipeline_layout.zig index f102ecd2..a17d09db 100644 --- a/gpu/src/pipeline_layout.zig +++ b/gpu/src/pipeline_layout.zig @@ -20,5 +20,6 @@ pub const PipelineLayoutDescriptor = extern struct { next_in_chain: *const ChainedStruct, label: ?[*:0]const u8 = null, bind_group_layout_count: u32, - bind_group_layouts: [*]const BindGroupLayout, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + bind_group_layouts: ?[*]const BindGroupLayout, }; diff --git a/gpu/src/query_set.zig b/gpu/src/query_set.zig index 0a368db1..779ec1e8 100644 --- a/gpu/src/query_set.zig +++ b/gpu/src/query_set.zig @@ -34,6 +34,7 @@ pub const QuerySetDescriptor = extern struct { label: ?[*:0]const u8 = null, type: QueryType, count: u32, - pipeline_statistics: [*]const PipelineStatisticName, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + pipeline_statistics: ?[*]const PipelineStatisticName, pipeline_statistics_count: u32, }; diff --git a/gpu/src/texture.zig b/gpu/src/texture.zig index ec171ce2..74e5e03e 100644 --- a/gpu/src/texture.zig +++ b/gpu/src/texture.zig @@ -238,5 +238,6 @@ pub const TextureDescriptor = extern struct { mip_level_count: u32 = 1, sample_count: u32 = 1, view_format_count: u32 = 0, - view_formats: [*]const TextureFormat, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + view_formats: ?[*]const TextureFormat, }; diff --git a/gpu/src/types.zig b/gpu/src/types.zig index 3c530026..89b2929a 100644 --- a/gpu/src/types.zig +++ b/gpu/src/types.zig @@ -542,7 +542,8 @@ pub const BlendState = extern struct { pub const CompilationInfo = extern struct { next_in_chain: *const ChainedStruct, message_count: u32, - messages: [*]const CompilationMessage, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + messages: ?[*]const CompilationMessage, }; pub const DepthStencilState = extern struct { @@ -578,7 +579,8 @@ pub const ProgrammableStageDescriptor = extern struct { module: ShaderModule, entry_point: [*:0]const u8, constant_count: u32, - constants: [*]const ConstantEntry, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + constants: ?[*]const ConstantEntry, }; pub const RenderPassColorAttachment = extern struct { @@ -604,7 +606,8 @@ pub const VertexBufferLayout = extern struct { array_stride: u64, step_mode: VertexStepMode, attribute_count: u32, - attributes: [*]const VertexAttribute, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + attributes: ?[*]const VertexAttribute, }; pub const ColorTargetState = extern struct { @@ -619,9 +622,11 @@ pub const VertexState = extern struct { module: ShaderModule, entry_point: [*:0]const u8, constant_count: u32, - constants: [*]const ConstantEntry, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + constants: ?[*]const ConstantEntry, buffer_count: u32, - buffers: [*]const VertexBufferLayout, + // TODO: file a bug on Dawn, this is not marked as nullable but in fact is. + buffers: ?[*]const VertexBufferLayout, }; pub const FragmentState = extern struct {