Skip to content

fix: allow null for unused WriteDescriptorSet pImageInfo - #271

Merged
Snektron merged 2 commits into
Snektron:masterfrom
sean0407:codex/vulkan-zig-149-write-descriptor-null-pointer
Oct 24, 2026
Merged

Snektron merged 2 commits into
Snektron:masterfrom
sean0407:codex/vulkan-zig-149-write-descriptor-null-pointer

Conversation

@sean0407

Copy link
Copy Markdown
Contributor

Summary

VkWriteDescriptorSet.pImageInfo is unused for non-image descriptor types, but the Vulkan registry does not mark this member optional. The generator therefore emitted a non-null Zig pointer and rejected a valid null value. Mark this specific generated field nullable.

VkWriteDescriptorSet
  descriptorType selects the active info pointer
  pImageInfo unused -> null is accepted

Evidence

  • Before: With the current Vulkan registry, a compile probe assigning null to p_image_info failed: expected type '[*]const DescriptorImageInfo', found '@TypeOf(null)'.
  • After: The generated field is ?[*]const DescriptorImageInfo = null; the same probe passes (1/1).
  • zig build -Dregistry=/registry/vk.xml test passed in an isolated, no-network container.
  • zig fmt --check src/vulkan/parse.zig and git diff --check passed.

Merge Danger

Door: two-way

Blast Radius: narrow

Consumers that read p_image_info must handle its nullable type. The change is limited to the generated representation of this one conditional pointer.

Closes #149

@Snektron

Copy link
Copy Markdown
Owner

What about pBufferInfo and pTexelBufferView? I'm fine with applying this fix. In the past I've dealt with this by just setting those fields to undefined, but given that the validation layers seem to check for more null-ness, I suppose it would be better to apply this workaround after all.

@sean0407

Copy link
Copy Markdown
Contributor Author

Thanks for pointing these out. The Vulkan spec describes pImageInfo, pBufferInfo, and pTexelBufferView as selected by descriptorType; the two unused pointers are ignored. Based on that, I extended the parser override to make all three pointers nullable when unused and expanded the regression test to cover each one.

The focused test failed against the old parser behavior and passes with this change. In an isolated, network-disconnected container using the same Zig master build recorded by the official download index, the focused parser regression passed, zig build test passed (11/11), and zig fmt --check . passed. git diff --check and patch policy also passed. GitHub checks had not appeared yet in the post-push readback.

@Snektron
Snektron merged commit 91a3537 into Snektron:master Oct 24, 2026
1 check passed
@Snektron

Copy link
Copy Markdown
Owner

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WriteDescriptorSet should allow null for p_image_info

2 participants