gpu: keep ps_binding when a pixel shader needs only view_addresses (#410) #416
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!416
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-412"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Sheffy007 on GitHub · 2026-11-27 17:19 UTC · original
Sheffy007:fix/ps-binding-view-addresses→main· +158 −1 · 2 files · 1 commits · merged 2026-11-28 00:28 UTCSummary
In
Title::make_render(crates/victory-gpu/src/native/shaders.rs),ps_layoutis built withBinding::layout, which appendsRootParam::Srv { register: 1, space: MEMORY_SPACE }(t1, space3) wheneverps_full.view_addressesistrue. Two lines below,ps_bindingwas filtered with:omitting
b.view_addresses.Whenever a pixel shader indexed
ResourceDescriptorHeapdirectly (s2, or an interpolated heap index in a waterfall loop, as in the pixel shaders in #411) and queried texture dimensions or buffer fields throughview_addresseswithout user-data dwords, root views, or the pool page table (b.view_addresses && !b.memory && b.dwords == 0 && b.views.is_empty()):ps_bindingbecameNone.NativeHost::prep(Cmd::Draw) skippedview_address_argsfor the pixel stage, never built or made residentheap.addresses, and leftp.ps_root = None.Metal::bind_root_render(fragment.unwrap_or(root)) bound the vertex stage'srootbytes at fragmentbuffer(2), causing the fragment shader to dereference the vertex stage's first 8 bytes as a 64-bit GPU pointer fort1.Changes
b.view_addressesinTitle::make_render'sps_bindingfilter (b.memory || b.view_addresses || b.dwords > 0 || !b.views.is_empty()), matching every condition that adds root parameters inBinding::layout.a_pixel_shader_with_only_view_addresses_gets_its_own_fragment_rootinheap_tests.rs, where the vertex shader binds non-pointer sentinel root constants (0xDEAD_BEEFx 2) while adwords == 0pixel shader samples entry 0 and reads entry 1's13x7dimensions viaview_addresses(t1, space3), asserting rendered texels[13, 7, 200, 255].Verification
cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtaskcargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warningscargo clippy --workspace --all-targets --all-features --target x86_64-pc-windows-gnullvm -- -D warningscargo xtask policycc @Olima34
Closes #414
Refs #79, #258, #306, #411
Title::make_render built ps_layout with Binding::layout (which appends RootParam::Srv { register: 1, space: MEMORY_SPACE } when view_addresses is true), then filtered ps_binding with b.memory || b.dwords > 0 || !b.views.is_empty(), omitting b.view_addresses. When a pixel shader indexed ResourceDescriptorHeap directly (dwords == 0, views.is_empty(), !memory) and queried texture dimensions or buffer fields through view_addresses, ps_binding became None: NativeHost::prep skipped view_address_args for the pixel stage, left p.ps_root as None, and Metal::bind_root_render bound the vertex shader's root bytes at fragment buffer(2) as the 64-bit GPU pointer for t1. Include b.view_addresses in the ps_binding filter and add an end-to-end Metal GPU test with non-pointer vertex root constants.49e3bb9ef9toeec2a736f2