Skip to content

GPU: make placed-texture heap slots that shaders actually read - #13

Merged
DesertGamer merged 1 commit into
DesertGamer:mainfrom
antocorvo3000:heap-usage
Nov 25, 2026
Merged

DesertGamer merged 1 commit into
DesertGamer:mainfrom
antocorvo3000:heap-usage

Conversation

@antocorvo3000

Copy link
Copy Markdown
Contributor

Shaders that take descriptors from the resource heap itself (bindless
materials) read placed-texture slots that the heap mirror leaves null
until a draw reads them through a table (the shortcut that keeps ~20,000
host textures from being made at once). In Grand Theft Auto VI most
world materials sample that way, so their G-buffer albedo came out
black and the lit scene stayed dark.

Translated shaders now mark each heap slot they take a shader resource
view from in a bitmap (u1 in the memory space, an atomic OR per lane),
bound per list like the written-pages bitmap. After the list ran, each
marked slot still holding a placed texture left for later is made, so it
reads from the next list on. Only the textures in use are made.

VICTORY_HEAP_USAGE=0 turns the marks off (shaders as before). The frame
line reports slots marked, views made, and why marked slots were not
made. Unit tests leave the marks off (the hardware harness binds only
the parameters each test names).

Measured in the world: albedo coverage from ~20% to 99% of the screen;
about 10-20 views made per 5 s once streamed in; no view failed to make.

Same change as Marvisak/VIctory#1962, rebased on this main (c7846f1), with the new tests here updated for the added HostShader::heap_usage field.

Testing

  • cargo test --release -p victory-gpu --lib: 172 passed.
  • cargo test --release -p victory-shader --lib: 302 passed; emit::semantics_tests::arithmetic_matches_the_hardware fails here, and fails the same way on c7846f1 without this change (RX 6800 XT).
  • In game on Marvisak main (Grand Theft Auto VI, Series X mode): world albedo went from ~20% to 99% of the screen; no placed-texture view failed to make.

Shaders that take descriptors from the resource heap itself (bindless
materials) read placed-texture slots that the heap mirror leaves null
until a draw reads them through a table (the shortcut that keeps ~20,000
host textures from being made at once). In Grand Theft Auto VI most
world materials sample that way, so their G-buffer albedo came out
black and the lit scene stayed dark.

Translated shaders now mark each heap slot they take a shader resource
view from in a bitmap (u1 in the memory space, an atomic OR per lane),
bound per list like the written-pages bitmap. After the list ran, each
marked slot still holding a placed texture left for later is made, so it
reads from the next list on. Only the textures in use are made.

VICTORY_HEAP_USAGE=0 turns the marks off (shaders as before). The frame
line reports slots marked, views made, and why marked slots were not
made. Unit tests leave the marks off (the hardware harness binds only
the parameters each test names).

Measured in the world: albedo coverage from ~20% to 99% of the screen;
about 10-20 views made per 5 s once streamed in; no view failed to make.
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.

2 participants