[bug, unconfirmed] buffer_store_format_xyzw through a structured or typed writable buffer view stores nothing #255
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T05:31:41Z.
Status: unconfirmed. Help confirming or ruling it out is the ask.
In a synthetic GPU test,
buffer_store_format_xyzwwithidxenstored nothing at all when the destination wasR32G32B32A32_UINTtyped writable buffer view,while
buffer_store_dwordx4with the same four words through the same descriptor stored correctly.Why it might not be real
The test builds the view's descriptor words by hand. If the emulated format of those views differs from what the title really binds, the test proves nothing. We do not yet know the view format the title uses for these buffers.
Why it matters if real
The culling compute shaders write their output with a buffer store. A store that silently writes nothing through this kind of view would by itself explain buffers that stay empty (see the black-world issue).
What would settle it
crates/victory-gputhat stores through a view built with that exact format, withbuffer_store_format_xyzwand withbuffer_store_dwordx4, and reads the bytes back.Places to look: the formatted-store lowering in
crates/victory-shader/src/emit/lower.rs, and how writable buffer views are created incrates/victory-gpu/src/native.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-27T06:24:25Z.
Confirmed, and broader than the formatted store. On the native host every store by element index (
idxen) through a structured or typed writable buffer view is lost,buffer_store_dwordx4included. The cause is host-side: the native host never binds the view-stride table.Test:
heap_tests::formatted_and_dword_stores_through_structured_and_typed_buffer_viewsonmarcus-4:test/buffer-store-format-views, one commit on main2a3b03d1. Hand-assembled with llvm-mc, gfx1030, 32 lanes.The views are made through
create_placed_uavwithCreateUnorderedAccessViewdescriptions, as the title makes them. This addresses the "descriptor words by hand" doubt in the report. Each lane stores four dwords at elementlane:lane * 16buffer_store_dwordx4 offenbuffer_store_format_xyzw idxenbuffer_store_dwordx4 idxenR32G32B32A32_UINTbuffer_store_format_xyzw idxenR32G32B32A32_UINTbuffer_store_dwordx4 idxenThe stored values appear nowhere in the 256 KiB pool, so they are dropped rather than misaddressed. The host's decode gives the right range for all four (
buffer_view: base, and 32 × 16 = 512 bytes).Why. In
lower.rs, an indexed buffer access whose table entry comes from FSPX metadata (which gives no stride) takes its stride fromview_stride. That reads the host's view-stride table, root SRVt255(VIEW_STRIDES), at the view's heap index. Only the D3D12 host fills and binds that table (descriptor/host.rsset_stride,draw.rs); there is no reference to it undervictory-gpu/src/nativeorvictory-metal. On Metal the stride reads 0, and every indexed access through such a view goes wrong.This looks like the "per-heap stride table" @Ketan-Kapse described in #258 and is opening a PR for, so I have not written a host fix. The test may be useful to that PR: it fails on main and should pass once the native host binds the table.
Not settled here:
M1 Pro, macOS 27.2.1, Xcode 27.2, MSC 4.0.3. The control and the rest of
victory-gpupass; clippy (gnullvm,-D warnings) is clean.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T06:48:24Z.
Thank you. This is a better result than the report I wrote: the cause is host-side and not the formatted store, and your control row shows the test itself is sound.
I read main the same way:
VIEW_STRIDESis filled and bound only by the D3D12 host (descriptor/host.rs,draw.rs), and nothing undernativebinds it. I have not run it.Ketan-Kapse has said in #258 that the per-heap stride table is one of his two pull requests. A test that fails on main cannot merge alone, so please offer your test to that pull request, or open yours so it lands together with his fix. Either is fine; I only want the test and the fix to arrive together and not twice.
The descriptor format the title binds for these buffers is still open, as you say. I have not checked it either.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T07:52:43Z.
/claim
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T07:53:06Z.
Follow-up on why
buffer_store_format_xyzw ... idxenstill stores nothing even whenVIEW_STRIDES(t255, #264) is not involved or is bound:crates/victory-shader/src/emit/lower.rs:12591,Lower::view_strideis only taken when!typed: So untyped indexed accesses (buffer_store_dwordx4 ... idxenwithout static stride metadata) failed due to missingt255(#264), whereasbuffer_store_format_*andbuffer_load_format_*(typed == true) bypassview_strideand lower to DXILTypedBuffer(bufferStore.f32,bufferLoad.f32,getDimensions).metal-shaderconverter4.0.3 AIR bitcode (llvm-dison the converted.metallib) showsTypedBuffercompiles to@air.write_texture_buffer_1d.v4f32,@air.read_texture_buffer_1d.v4f32, and@air.get_width_texture_buffer_1d, all reading word 1 (textureViewIDat byte+8) of the 24-byteIRDescriptorTableEntry, whilerawBufferStore.i32(buffer_store_dwordx4) reads word 0 (gpuVAat byte+0).Metal::write_bufferwrote[gpu, 0, size as u64], leavingtextureViewID = 0(nullMTLResourceID), so formatted stores were silently dropped and formatted loads /getDimensionsreturned0even on a declared table UAV wherebuffer_store_dwordx4succeeded.Opened #278 to populate a zero-copy
MTLTextureType::TypeTextureBufferin word 1 alongsidegpuVAin word 0 for typed buffer SRVs/UAVs and 4-, 8-, and 16-byte structured buffer SRVs/UAVs, with an Apple Silicon GPU test (heap_tests::formatted_buffer_stores_and_loads_through_structured_and_typed_uavs) covering structured,R32G32B32A32_UINT,R32G32B32A32_FLOAT,R8G8B8A8_UNORM,R16G16B16A16_FLOAT, andR16G16B16A16_UINTviews.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T08:08:05Z.
Thank you. This is a second cause that the stride table does not cover, and it explains why a formatted store would still be lost with #264 applied. #278 gets its own review.
Three things. First,
/claimwas not live when you wrote it, so nothing was booked. The pull request that adds it (#266) is going in now; please comment/claimagain once it is merged. #255 is shared as it is: the stride table is Ketan-Kapse's #264, and marcus-4 has the failing test. Please look at those two before changing the same lines indescriptors.rsandhost.rs.Second, please say that the
llvm-disoutput you describe is from the converter's output for your own small test program and not from the title, and that no listing is in the repository or in the comments. Describing what it showed is fine.Third, I have not checked whether our cullers use formatted stores at all. If you know which instruction they use for the records, please say so with how you know.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T10:48:52Z.
/claim
Following up on all three points:
/claimnow that #266 is live (shared with @Ketan-Kapse's #264 forVIEW_STRIDESand @marcus-4's test). Also inspected #264's diff and restructured #278 (38112699) soDecoded::Buffer,descriptors::decode, and #264'sstrideshunks indescriptors.rs,list.rs, andhost.rsno longer touch the same lines, and changed #278 toRefs #255.llvm-disoutput described above was frommetal-shaderconverterrun on a small synthetic DXIL test program of our own, not from the title, and no listing from it is in the repository or in the comments.crates/victory-shader/src/emit/lower.rs:12595,Lower::view_stride(t255VIEW_STRIDES) is only read when!typed:Some(i) if used.is_none_or(|u| u.stride == 0) && !typed => { let stride = self.view_stride(src)?; ... }buffer_store_format_*) havetyped == true, so they bypassview_stridecompletely and emitbufferStore.f32(word 1textureViewID). Untyped indexed stores (buffer_store_dword* ... idxenon a view without static stride metadata) have!typed, multiplyindex * view_stride, and emitrawBufferStore.i32(word 0gpuVA).t255(VIEW_STRIDES) alone caused the cullers' indirect-argument records to populate on Metal, the cullers must write those records with untyped indexed stores (buffer_store_dword* ... idxen), while #278 covers shaders that genuinely usebuffer_load_format_*/buffer_store_format_*/ typed-buffergetDimensions(now lazily materialized only when a bound shader's DXIL usesTypedBuffer).Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T10:49:03Z.
Claimed by @Sheffy007. Open a draft pull request with
Refs #255in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T15:04:14Z.
/release
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T15:04:23Z.
Released. This issue is free to claim.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by tiagonogueiraa-bit on 2026-11-27T17:11:34Z.
Status check on main
b998bb6: #264 (the view-stride table) and #278 (typed loads and stores) are merged.heap_tests::formatted_buffer_stores_and_loads_through_structured_and_typed_uavspasses on Metal (M-series, MSC 4.0 beta 3). That test covers formatted and dword stores and loads withidxenthrough a 16-byte structured view,R32G32B32A32_UINT,R32G32B32A32_FLOATandR8G8B8A8_UNORMwritable buffer views, all made withcreate_placed_uav. As far as the synthetic cases go, this report looks resolved. The format the title binds in a world frame was never confirmed; that needs a descriptor trace from a run. Closing is up to you.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by theappartment on 2026-11-27T18:01:17Z.
/claim
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T18:01:26Z.
Claimed by @theappartment. Open a draft pull request with
Refs #255in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T18:59:30Z.
The claim by @theappartment has expired: no pull request referenced it within 24 hours. This issue is free to claim.