Skip to content

Tint: extend kAllowStructMemberSizeMismatch to the struct total-size check - #4

Open
octopusburrow wants to merge 1 commit into
dwalter:webgpu-4.6.2from
octopusburrow:pr2-tint-total-size
Open

Tint: extend kAllowStructMemberSizeMismatch to the struct total-size check#4
octopusburrow wants to merge 1 commit into
dwalter:webgpu-4.6.2from
octopusburrow:pr2-tint-total-size

Conversation

@octopusburrow

Copy link
Copy Markdown

Without this, SPIR-V→WGSL conversion rejects the Mobile renderer's scene shaders and the
WebGPU rendering path produces no pixels. This completes the exemption your patch 0002
introduced: kAllowStructMemberSizeMismatch (your Group B — specialization constants)
exempts the per-member size check for Godot's runtime-specialized shaders, and this
extends the same capability to the whole-struct total-size check that still rejected the
same shaders.

Same producer, measured: instrumenting both check sites shows one struct,
InstanceDataBuffer_1_1_a64 (declared size 16, member extent 208 — a spec-constant-sized
trailing array folded at conversion), tripping the member-size check your 0002 rescues
AND the total-size check this patch rescues. The two checks reject the identical
reflection pattern; 0002 without this leaves the conversion failing one validator later.

Scope disclosure: like patch 0002, the capability is granted to all SPIR-V-read modules,
so this widens what that already-global flag suppresses — a struct whose declared total
size disagrees with its members' extent now converts instead of failing validation. The
check is validator-only (no codegen change), so correct shaders are unaffected; the cost
is a later, less-obvious failure for genuinely malformed reflection data. A narrower
form (exempt only specialization-constant-sized trailing arrays) would be preferable if
Tint's IR exposes enough to detect it at that point; happy to iterate if you'd rather
gate it tighter.

Verified by reverting the patch: zero pixels on the RD/WebGPU renderers (forward_plus
and mobile) on desktop Chrome; with it, both render correctly.

…check

Vendored as patches/0007 per the thirdparty/tint/patches/ convention.
This is a Group B (Specialization Constants) patch, completing the
capability this fork introduced in 0002 and extended in 0003/0005:
Godot's specialization constants change effective struct and array sizes
at runtime, so a spec-constant-sized array leaves the containing struct's
Size() at its unfolded value and the validator's TOTAL-size check
(str->Size() < cur_offset) fires on IR that the fork's own 0002 rationale
already classifies as valid-by-construction. 0002 relaxed the per-MEMBER
size check for this exact producer; this patch applies the same
capability to the struct-total check a few lines below it.

Without this, the Mobile renderer's scene shader (depth shadow atlas +
sampler UBO with spec-constant-sized arrays) fails Tint validation and
every lit 3D scene renders black on Dawn/Windows, including this fork's
own sample projects. Unshaded scenes are unaffected, which is why the
gap survived: the fork's Windows TODO note and this failure are the same
bug.

Layer choice: an alternative would be changing Godot's shader generation
so emitted SPIR-V never carries the mismatch, touching no vendored code.
This fork already faced that choice for the member-size case and chose
validator relaxation, three times (0002, 0003, 0005, documented as
Group B in patches/README.md); this patch follows the established
architecture rather than opening a second front. If Group B is ever
re-architected toward shader-gen fixes, this check belongs in that
migration with the rest of the group.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant