Repository navigation
startup: persist and reuse translated PSO recipes - #2919
Conversation
|
Strengthened the coverage in |
KelboLive
left a comment
There was a problem hiding this comment.
PR #2919 by @lambirou -- startup: persist and reuse translated PSO recipes
What works
- Solid foundational work establishing the 0x100 linear layout in gfx10_layout.h with careful derivation from AMD addrlib
- The linear_mode = 0 constant elegantly extends block_log2() to accept mode 0 without changing the tiled modes switch logic
- supports() check is correct: mode == linear_mode bypasses the block_log2 >= 12 requirement since linear has no tail
- Test infrastructure is excellent -- linear_order_control (expected failure with largest mip first), linear_addrlib (338K element addresses), and the unpadded negative control all add strong coverage
- Documentation accurately restates addrlib's linear mode algorithm in clear, testable terms
Issues
- supports() currently allows block-compressed formats (BC1-BC7) in linear mode via the fallthrough -- BC formats are block-based and don't have linear row semantics; consider gating them out explicitly like 1D does in #2929
- The check script in startup_address_console_check.py builds linear backing bytes from addrlib equations. This is correct but the linear path could break if the hardcoded equations drift from addrlib; a comment linking to the Mesa commit that derives these equations would help
Recommendations
- Good discipline in including the negative control (unpadded rows test) to verify the 256-byte pitch requirement
- Consider adding a TODO or assert in supports() that blocks linear mode for BC formats until explicitly validated against addrlib
Overall
A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.
KelboLive
left a comment
There was a problem hiding this comment.
PR #2919 by @lambirou -- startup: persist and reuse translated PSO recipes
What works
- Solid foundational work establishing the 0x100 linear layout in gfx10_layout.h with careful derivation from AMD addrlib
- The linear_mode = 0 constant elegantly extends block_log2() to accept mode 0 without changing the tiled modes switch logic
- supports() check is correct: mode == linear_mode bypasses the block_log2 >= 12 requirement since linear has no tail
- Test infrastructure is excellent -- linear_order_control (expected failure with largest mip first), linear_addrlib (338K element addresses), and the unpadded negative control all add strong coverage
- Documentation accurately restates addrlib's linear mode algorithm in clear, testable terms
Issues
- supports() currently allows block-compressed formats (BC1-BC7) in linear mode via the fallthrough -- BC formats are block-based and don't have linear row semantics; consider gating them out explicitly like 1D does in #2929
- The check script in startup_address_console_check.py builds linear backing bytes from addrlib equations. This is correct but the linear path could break if the hardcoded equations drift from addrlib; a comment linking to the Mesa commit that derives these equations would help
Recommendations
- Good discipline in including the negative control (unpadded rows test) to verify the 256-byte pitch requirement
- Consider adding a TODO or assert in supports() that blocks linear mode for BC formats until explicitly validated against addrlib
Overall
A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.
|
The two |
|
@R0Y00 the two |
|
Windows dev + release receipt on The two-process replay is the requested end-to-end control: first process writes the recipe, second process loads and precreates it, and the 32 RGBA bytes match. |
|
Could you share when you expect this PR to merge, and whether the record-limit behavior below should be addressed here? On head I also checked the 64-record boundary with the existing serializer and parser. A source-built file containing 64 valid records and a 65th with a different state key was 30,484 bytes, below the 65,536-byte file limit. The parser accepted 64, rejected the last with AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
Please address the writer/reader record boundary in this PR. On 711e7d95 plus main 1ec2c938 (tree 117604d5), I reproduced the effect through the ordinary draw entry point with a source-built VS/PS. At 63 valid seed records, the writer appended the live record as number 64 and the next process logged precreated 1. At 64 valid seed records, it appended number 65 at 30,810 bytes, well below 64 KiB. The next process logged recipe record limit reached, fell back and appended number 66. The pixels still matched on both WARP and RTX. This is a persistent cache miss after a successful write, so please align the append policy with the parser and cover the 64/65 boundary.
The implementation also opens the recipe file with FILE_SHARE_WRITE and seeks to the observed end. Two processes can both choose the same offset. Please make the count/size check and publication one writer transaction or document and enforce exclusive ownership, and keep a contending draw on the regular fallback path. I noted this from the code and did not fault-inject a concurrent interleaving.
Independent ctest --preset <dev|release> --no-tests=error -V -R '^(startup_pso_recipe|startup_stream_draw_(warp|hardware)|startup_compute_dispatch_native_(warp|hardware))$' gave four passes and one native-compute WARP 77 skip per preset. The normal two-process draw, manifest retry and exact red/green readbacks pass. Windows 11 26200.9974, SDK 10.0.26100, WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656. The standard stream test leaves the debug layer off; the boundary probe enabled it.
Refuse a 65th record instead of appending one the next process rejects, and hold the recipe file exclusively across the read, count/size check and append. A contending draw keeps its PSO and skips only the cache write. Cover 63/64/65 and an exclusive-lock draw on WARP and hardware.
|
Merged Record boundary:
The device-free check now covers 63 records (append allowed), 64 records (append refused), 65 records (parser rejects the extra record), and a malformed existing file. All 26 checks pass. Concurrency:
Windows receipt on
Windows checks #8169 is still running on this head; I will report the result when it finishes. |
|
Windows checks #8169 completed successfully on |
Seed the recipe file with 63 valid records for another translation key, verify the next draw appends the matching record as number 64 and the following process precreates it, then seed 64 and verify the draw still renders while no 65th record is written. Passes dev and release on WARP and the RX 9060 XT.
|
Added the runtime boundary control on head
Windows checks are running on the new head; the previous head |
|
Windows checks #8172 completed successfully on |
|
@R0Y00 the two CHANGES_REQUESTED points are addressed on |
R0Y00
left a comment
There was a problem hiding this comment.
The revised code holds one exclusive handle across the count and append, and the 63/64 controls cover the earlier record-limit issue. I found one remaining reader/writer boundary at 708416f3. Using the shipped C++ serializer, I removed only the last LF from one valid record. parse_pso_recipe_file still accepted that record (one accepted, zero rejected), and pso_recipe_append_allowed returned true. Appending the next serialized record produces endx2w-pso-recipe 1 on one line. The next read accepted zero records, including the previously valid one. With the separator restored, both records parse.
Please ensure a successful append preserves a line boundary. Rejecting the append without changing the file is sufficient. If the writer inserts a separator instead, include it in the 64 KiB cap. Add a control starting from a parseable record without a final LF and verify that the earlier record remains readable.
A file whose last record lacks its LF still parses, but appending would join end and the next header on one line. Refuse the append and leave the file unchanged; cover the policy and the runtime file.
|
Fixed on Controls:
Passes in dev and release on WARP and the RX 9060 XT: |
|
Windows checks #8191 completed successfully on |
R0Y00
left a comment
There was a problem hiding this comment.
Retested 360a9dff on main a9fd1488 (tree bcfaa9376a0cd5ee21944a5a42b5a41b075f2f38). The writer now refuses the append before changing a parseable file with no final LF. Besides the submitted unit and runtime controls, I seeded 63 valid foreign records with no final LF, a count still eligible for append. On both WARP and RTX the draw produced exact pixels, the file stayed byte-for-byte unchanged, and the next run rendered again. The adjacent 63-record file with a final LF still appended record 64 and precreated it in the following process. The 64-record and exclusive-handle controls also passed.
Built startup_stream_consumer d3d12_xs_shim startup_pso_recipe_check startup_manifest_retry_check compile_dxil. Debug and Release /O2 each gave five passes and one native-compute WARP wave32 skip using ctest --test-dir <build> --no-tests=error -j 1 -V -R '^startup_(pso_recipe|stream_draw_(warp|hardware)|compute_dispatch_native_(warp|hardware)|manifest_retry)$'. Windows 11 26200.9974, WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656 and SDK 10.0.26100. The stream draw fixture used the debug layer. This addresses both rounds of cache-write findings.
What changed
The translated draw path builds each desktop graphics PSO on its first draw, from state the shader cache does not store: the effective blend state after export write masks, depth-stencil state, rasterizer state, target formats, DSV format, sample mask and topology. A run therefore reconstructs that state and creates the PSO at the first draw.
This adds an opt-in persistent recipe cache:
X2W_PSO_RECIPE_DIR=<dir>, off by default.pipeline_forappends the exact state after a successfulCreateGraphicsPipelineState.load_translationreads the matching file and the firstpipeline_forreplays records whose target formats and DSV match the pass. A malformed record, an unknown version, a corrupt state key or a target-format mismatch is ignored and the unchanged creation path runs.This is state reconstruction, not a D3D12 pipeline library. A replayed record still calls
CreateGraphicsPipelineState; the driver may compile or find the PSO in its own cache. The change moves the state reconstruction and first-use creation earlier; it does not claim to eliminate driver compilation.Tests
startup_pso_recipepassed: 29 checks, 0 failed. It covers the serializer/parser round trip, two appended records, a corrupt state key, an unknown version, an oversized file, target-format and DSV mismatches, the recreated blend/depth/rasterizer/sample/topology fields, the 63/64/65 record boundary (63 accepts one more, 64 refuses a 65th, and the parser rejects a 65th), and a parseable record without its final LF (append refused, earlier record still readable).startup_stream_draw_warpandstartup_stream_draw_hardwareexercise the full path: the first translated stream draw writes a recipe, a second process with the same directory loads it, reports precreated records, and produces the same 32 RGBA bytes. They also hold the recipe file exclusively during a draw and check that the draw still renders with exact pixels while the file size stays unchanged. The runtime boundary control seeds 63 valid records for another translation key, checks that the next draw appends the matching record as number 64 and the following process logsprecreated 1, then seeds 64 records and checks that the draw still renders while the file stays at 64. It removes the final LF from that file, checks that the draw leaves it byte-for-byte unchanged, and checks that the next draw still reads it. The test found and fixed a real serializer/parser gap: an unused depth-stencil block was written as a zero-filledD3D12_DEPTH_STENCIL_DESC, whose zero stencil ops the parser rejects. The serializer now writes a valid default for an unused block, and the parser normalizes it back for the state key.Passed on
360a9dff, dev and release, on WARP (1414:008c, driver10.0.26100.10068) and on an AMD Radeon RX 9060 XT (1002:7590, driver32.0.32029.2010). The branch is merged with currentmaine1ea515d.Limits
The replay still calls
CreateGraphicsPipelineState; it does not serialize a driver PSO or use a D3D12 pipeline library. No game files or captures are included.Refs #870.
AI-assisted.