Repository navigation
Shaders: lower image_get_lod on cube textures (#1004) - #50
Open
LAKSHYA-cmd-tech wants to merge 122 commits into
Open
LAKSHYA-cmd-tech wants to merge 122 commits into
LAKSHYA-cmd-tech wants to merge 122 commits into
Conversation
… reads Host copies of title buffers start in the common state and relied on implicit promotion, which allows a buffer to be written (unordered access) or read in a list, not both. The world's 174 MB heap is both: the argument clamp and title passes write it, draws read vertices and indices from it. indirect.rs also moved the argument buffer from unordered access to indirect arguments and back after every execution, whatever state the buffer was really in. Each list now tracks the state of every host copy it uses (BufferStates): reads (vertex, index, constant, shader resource, arguments) in GENERIC_READ, shader writes in UNORDERED_ACCESS, with a transition where the use changes. The list's prelude moves each buffer from common to its first state and the list moves it back before closing, so state never leaks into the next list of a submission. indirect::execute replaces the fixed UAV <-> INDIRECT_ARGUMENT barriers. Refs Marvisak#199, Marvisak#264. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title's descriptor writes and texture releases reach the host at once, from its own threads, while the host runs a submission for most of a second in the world. A descriptor slot rewritten then dropped the resource it held, and a released title texture dropped its host copy, while the running submission still read them: device-removed data showed a page fault inside a freed 1024x1024 BC7 texture, about 65 s into the world (DXGI_ERROR_DEVICE_HUNG, RX 7600). Those objects now go to a retired list tagged with the submission count and are dropped when that submission has been waited for (at once if none is running). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSD61BBk7E79WkryEQA
The world's peak counted 3,630 host textures, 8.9 GB, against a 7 GB video memory budget on an 8 GB card: the driver moves the excess to system memory, where it counts against the commit limit. A texture the title makes and the GPU never uses (no view, target, copy or barrier) now costs nothing; the creation state and clear value are kept for the copy made on first use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSCvCZuokASx7f59sAG
A root SRV is a bare GPU address: nothing bounds what a shader reads through it. Vertex fetch reads its stream through a root SRV with no record limit, and a mesh shader read past the end of the buffer's host copy into memory the host had already freed (the "inside freed texture" device removal after the fix for #59: the fault lay just past the copy's end, in the gap where released textures had been). Each root SRV is now a one-descriptor table holding a raw view of the host copy from the root address to the copy's end, made once per address per list in the heap's dynamic slots; reads past the end return zero, as for any bounded view. A root SRV the title did not set, or one with no host copy, gets a null raw view (an unset table is undefined). Addresses not on 16 bytes, which a raw view cannot start at, read zeros and are logged once. VICTORY_ROOT_SRV_DIRECT=1 restores root descriptors.
… names A buffer read whose element stride is not known at translation takes a raw handle and a byte offset from the runtime stride table. The handle was of the slot the title's view is in, and a raw handle over a structured or typed view is undefined in D3D12: for the load of [index 2, offset 4] an RTX 5070 reads dword 21 of a structured view of 12 bytes (dword 7 asked for) and dword 36 of one of 16 bytes or a typed RGBA32F one (dword 9 asked for), where a Radeon and WARP read the bytes asked for. No handle of another kind is right everywhere either: with a structured handle whose declared stride differs from the view's, the RTX 5070 addresses by the view's stride and the Radeon and WARP by the declared one. The table's entry per slot is now a StrideEntry of two dwords: the stride, and the heap slot holding a raw view of the bytes the slot's view reads (none: the slot's own view is raw), with the bytes from that raw view's start to the view's first byte (raw views start on 16 bytes on the host). The shader reads, stores and runs atomics through a raw handle of the slot named, so the handle's kind always matches the view. RawWindow gives the host the raw view for a byte range. The GPU side writes the new entries without raw slots yet, which reads as before. The test binds raw, structured (12, 16, 20 bytes) and typed (RGBA32F, R32_UINT) views, as shader views for the load and as unordered access views for the store and the atomics, with their raw views beside them, on the hardware adapter and WARP; a second one takes the descriptor from a join of two loads. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The programs that read a buffer without a known stride pick its heap slot at run time, so the runtime stride table has to be looked up by the slot the shader computes, and the view in it can differ from one thread group to the next. A new test loads the heap slot from a buffer per thread group (a scalar load whose offset is the loaded value), with a structured view of 12 bytes in one slot and one of 16 bytes in the other: the four lanes of each group read the bytes of the view their group chose, in one dispatch and again with the choice swapped. A lane reading past the three elements of the first view reads zero, not the buffer's next bytes. The test host's raw views now cover a window of the buffer (as RawWindow gives the host for a view's elements) rather than all of it, which is what ends the read there; the view kinds test takes its raw views and entries from the same function, with views starting 4 and 12 bytes into their raw views. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ide reads A shader that reads a buffer without knowing its stride takes a raw handle of the slot the runtime stride table names. The host heap now makes that slot: when it makes a structured or typed buffer view (for a shader or for unordered access), it also makes a raw view of the same bytes of the same host copy in a pool of 65,536 slots after the dynamic ones, and writes the slot, the stride and the bytes from the raw view's start to the view's first byte (raw views start on 16 bytes) into the slot's entry. A raw view keeps its own slot. The raw view ends with the view's last element, so reads past it give zeros. The entry and the raw view are written wherever the slot's descriptor is (tables made for a draw, title slots a draw reads through a table, slots made null), so they are as current as the descriptor; a slot made again reuses its raw view slot, and one made null, raw or constant, or a dynamic slot given back, returns it to the pool. Views the host cannot make raw (starting off a dword of the copy, or with the pool full) point at a null raw view and are logged once. The test makes placed structured, typed and raw views in a host heap and runs the translated program of victory-shader's run-time slot test on it: each thread group reads the bytes of the view in the slot it chose, zeros past the view's end, and the new view's bytes after the slots are made again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main moved under Marvisak#193 and this branch. One conflict, in HostHeap::new (descriptor/host.rs): Marvisak#336 tries the heap with DYNAMIC dynamic slots, then with MIN_DYNAMIC, then capped, and records the range it got in `dynamic`; this branch puts ALIASES raw-view slots after the dynamic ones. Both kept: each attempt asks for the alias slots too, the capped count leaves room for them, the lease bitmap has `extra` entries as on main, and `alias_base` stays `count + extra`. A merge rather than a rebase so Marvisak#193's commits keep their ids. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…clamps, and non-multiple-of-4 stride refusal
…spilled lane masks
…ess/virtualized environments (Marvisak#727)
main now has CI (clippy with -D warnings, then the workspace's tests). No conflict; both of CI's clippy commands are clean on the result. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ew-kinds Marvisak#193 moved: buffer views are clamped to what is left of the host copy, a shader that reads the stride table without a host view heap is not run, and a known stride that is no multiple of four is refused. Conflicts were with main, not with this branch's change: `bind` already returns whether the draw may run (Marvisak#336), with its doc comment and the dropped counter, and main already renamed the second test module in host.rs. main's side kept in all three; Marvisak#193's `return false` in the stride-table branch is in. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… refusals on joined values (Marvisak#736)
…ta6-world-and-shader-fixes
…rld-and-shader-fixes
…to integrate/gta6-world-and-shader-fixes
…-and-shader-fixes
…query HLE: implement DirectStorage CancelRequestsWithTag (0x38) and Query (0x58) slots
HLE: implement XTaskQueueRegisterWaiter and XTaskQueueUnregisterWaiter slots
On the console, whole-quad mode puts a pixel shader's helper lanes in EXEC, so a waterfall loop (read the first lane's value, run the lanes with that value, take them out of EXEC) serves them too. On the host, wave operations leave helper lanes out: once only helper lanes are left in such a loop, WaveReadLaneFirst reads no lane, no lane matches, and the loop runs to the iteration limit in each of them. In a retail title's world, draws took 0.3 to 1.3 s each until a submission passed the host's 2 s limit: DEVICE_HUNG about 200 s into the world. A helper lane now takes its own value, so it matches in the first pass and leaves. What it computes only feeds derivatives; its stores are dropped already. Waterfall reads the proof already turns into per-lane reads are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arvisak#904) B5G6R5, B5G5R5A1, and B4G4R4A4 map to R8G8B8A8_UNORM (28) and R9G9B9E5_SHAREDEXP maps to R16G16B16A16_FLOAT (10), preventing host render target and UAV creation failure on modern D3D12 drivers.
…dfirstlane Shaders, GPU: helper lane readfirstlane fix and pc_format fallbacks
…f E_NOTIMPL ID3D12Device::GetDeviceRemovedReason "gets the reason that the device was removed, or S_OK if the device isn't removed" (Microsoft D3D12 reference). Slot 37 (0x128) in the device function table was left on the default handler, returning E_NOTIMPL (0x80004001) on a healthy device, which a title checking FAILED(GetDeviceRemovedReason()) takes as a lost device. Wire slot 37 to removed_reason, which queries the host device's GetDeviceRemovedReason() and returns S_OK on Ok (or when there is no host device) and the error's HRESULT otherwise. Add a unit test verifying slot 0x128 returns S_OK on a healthy device. Co-Authored-By: Gemini 4 Neon <noreply@google.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e device D3D12 treats a buffer SRV or UAV with NumElements 0 as an invalid call and removes the device (DXGI_ERROR_INVALID_CALL), with no debug layer needed. `buffer_srv` and `buffer_uav` passed such a title view straight to the host. On the console a view of no elements reads and writes nothing, as the null view the slot now gets does. The new test makes placed buffer views of one and of no elements on the host device: without the change the device is removed with 0x887A0001. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…remap-epoch caching
In world frames, Staging::refresh_now() spends ~380 ms/frame checking ~156 MB of
unchanged unwatched textures in physical-page views:
1. Every submission re-ran watch::writes(..., false) (taking the global JOURNAL
mutex + a failing GetWriteWatch syscall) because Staging did not cache
NOT_WATCHED like Shadow does.
2. Every submission re-walked VirtualQuery across every 64 KiB mapped view in
committed(), even when no views had been mapped or unmapped.
3. Every submission hashed the full tiled texture with cryptographic blake3::hash.
Changes:
- watch.rs: bump an AtomicU64 REMAP_EPOCH in title_memory_remapped() and expose
remap_epoch().
- texture.rs:
- Cache watched: AtomicU8 (NOT_WATCHED) on Staging once committed, and cache
committed_epoch for MEM_MAPPED ranges only (all MEM_MAPPED unmaps go through
title_memory_remapped(); MEM_PRIVATE ranges still call VirtualQuery). Both
invalidate immediately whenever remap_epoch() advances.
- Replace blake3::hash with a 4-lane u64 128-bit non-cryptographic content
digest (as_chunks::<32> + SplitMix64 finalizer): 160 MiB drops from 71.4 ms
(2.24 GB/s) to 11.6 ms (13.77 GB/s, 6.1x faster) in release builds, while
still checking every byte on every submission.
- Add unit tests for single-bit/tail/order/length sensitivity, committed_kind
(MEM_MAPPED vs MEM_PRIVATE) + remap_epoch, and an ignored throughput benchmark.
Co-authored-by: BlueKaiman <360454391+BlueKaiman@users.noreply.github.com>
…ow in XMA In crates/victory-formats/src/xma.rs, Bits::signed(n) computed ((read(n) << (32 - n)) as i32) >> (32 - n) without checking for n == 0 or n >= 32. For n == 0, 32 - n is 32, which causes an overflow panic on 32-bit shift in Rust. Similarly, Bits::read(n) for n >= 32 caused subtraction underflow on 32 - n. Add guards for n == 0 and n >= 32 in both read() and signed(), and add a synthetic unit test covering boundary bit widths (0, 32, and signed two'\''s-complement parsing).
Parsing an SGD5 shader container record previously used unguarded slice indexing and unchecked additions when calculating payload boundaries and header field offsets. On truncated archives or boundary offsets near the file limits, this could panic on slice index out-of-bounds or integer overflow. Use checked_add/checked_sub and .get() boundary checks for all record offsets, and add unit tests exercising boundary offsets, size mismatches, payload truncation, and oversized unpacked limits.
…not VirtualQuery With device-removed data on, every draw and dispatch builds a note naming the views it reads, and the note for a constant view read its first 16 bytes after asking VirtualQuery whether they are committed. In a retail title's big pools that query walks the region's pages (about a millisecond), and a world frame asked it thousands of times: recording threads spent most of their time there and world frames took 9-12 s instead of under one. ReadProcessMemory reads the bytes and fails on an unmapped page without the walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves upstream Marvisak#924. - Change \clwb_len\ to accept \&[u8]\ and safely bounds-check each decoded byte. - Remove the \ >= 15\ page-room guard in \emulate_amd_only\, allowing single-instruction \clwb\ emulation to succeed when sitting within the last 14 bytes of a page (0xFF2..=0xFFB). - Expanded \clwb_lengths\ regression test.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes Marvisak#1004. Supports image_get_lod (dx.op.calculateLOD.f32, opcode 81) on cube textures (dim = 3) in pixel shaders by routing through cube_direction and removing op == 81 refusal.