Repository navigation
fix(agc): fuse geometry shader halves into one self-contained program - #124
Conversation
|
Tested this locally with The Smurfs Dreams (UE, Linux). The game calls What worked here: report |
|
Thanks for testing with The Smurfs Dreams. You're right: the title doesn't honour the reported alignment, so the library has to align inside the scratch memory. I'll report |
c7a106e to
67c3256
Compare
|
Pushed: the fused program is now placed at the first 256-byte boundary inside the scratch memory, and the size query includes 255 bytes of padding. The test fuses into aligned and misaligned scratch (0xa0 and 4 bytes off) and fails without the change. Rebased on current main as well. Could you check it with The Smurfs Dreams when you get a chance? |
…its scratch memory Titles pass scratch memory without honouring the reported alignment; the size query now includes 255 bytes of padding and the fused program is aligned inside the scratch. Same change as upstream PR boykopovar#124. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
67c3256 to
0cdb5df
Compare
…, boykopovar#129) into astrobot Conflicts resolved: - Shader disk cache (boykopovar#129 as merged upstream): upstream's version, plus astrobot's imageDepthCompare and waveLayout fields (format 3). - Shader fusion: upstream's fd4700b replaces astrobot's boykopovar#124 version. - -KRzWekV120: upstream's export replaces astrobot's; its test now calls sceAgcUnknown__MKRzWekV120. - Misaligned buffer views: upstream's push-constant adjustment (3dec6ce) replaces astrobot's view aliases; GuestBufferMemory is the rebased boykopovar#121 version (write watch on shared direct memory). - DirectMemory: rebased boykopovar#121 (re-register after the shared-backing remap, aliased pages leave the watch) plus boykopovar#164's per-piece unmap. - Depth: astrobot's DepthTarget model is kept for attachments; upstream's DepthSurface module is dropped (it would duplicate it). Upstream's mip-chain colour targets, CB_COLOR_VIEW MIP_LEVEL at bits 26-29 and export formats are taken into DecodeColorBuffer. - GPU-selected V#s: upstream's gpuDescriptor replaces astrobot's opt-in runtimeDescriptor; image_bvh_intersect_ray is upstream's. - Occlusion counter dumps: upstream's Vulkan occlusion queries replace astrobot's always-visible PIXEL_PIPE_STAT dump. - AudioOut2 DualSense ports: rebased boykopovar#180 on upstream's 16-bit ports. - Pixel stage decode: rebased boykopovar#136; mesh push constants: rebased boykopovar#133. - Label waits (boykopovar#178): noteHeldAtSubmit moved into reserveOutputs.
… again Upstream's sceAgcUnknownFuseShaderHalves (fd4700b) fuses at the register level: the back half's registers with SPI_SHADER_PGM_LO_ES pointing at the front half's code. The driver then compiles that front half as the draw's whole program (type 4, Stage::Mesh) and skips the back (Role::GeometryBack); nothing links the two (LinkedProgram is only serialized and DecodeRdnaFrontProgram has no caller). The front ends in s_setpc_b64 s[6:7] and has no s_endpgm, so the decode runs on into the s_code_end padding and the program trailer: Astro Bot's geometry-shader draws were skipped with "unsupported SOPP opcode 31" (s_code_end) and "unsupported scalar source operand code 115 at program counter 64". Geometry halves are fused as astrobot did before (boykopovar#124): the front up to its s_setpc_b64, s_nop padding to 256 bytes and the back, with a self-contained header in the scratch memory. Hull halves keep upstream's register-level fusion, which the tessellation path's separate local and hull programs fit.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
Some data on how this compares with the fusion that landed on main (fd4700b), from PPSA21564. With main's register-level fusion, the geometry-shader draws in PPSA21564 are skipped: What happens: the fused registers keep the back half's state with With this PR's approach for geometry halves (the front up to its I'll rebase this PR onto current main so it only replaces the geometry path and leaves the hull path as it is on main. |
sceAgcUnknownFuseShaderHalves (fd4700b) fuses both kinds of halves at the register level: the back half's registers with the front half's program address in PGM_LO_ES (PGM_LO_LS for hull halves). For geometry halves the driver then compiles that front half as the draw's whole program (type 4, Stage::Mesh) and skips the back (Role::GeometryBack); nothing links the two. The front ends in s_setpc_b64 s[6:7] and has no s_endpgm, so the decode runs on into the s_code_end padding and the program trailer. In PPSA21564 the geometry shader draws were skipped with "unsupported SOPP opcode 31" (s_code_end) and "unsupported scalar source operand code 115 at program counter 64". Geometry halves are now fused into one Gs program: the front half's code up to its final s_setpc_b64 s[6:7] (its length comes from the program trailer), s_nop padding to the next 256 bytes, then the whole back half, so the front falls through into the back. Its SH registers are the back half's, with PGM_LO/HI_GS pointing at the copied back code, the ES program address at the fused code, RSRC1 taking the larger VGPR and SGPR counts of the two halves, RSRC2 taking the front half's user-SGPR count (the SPI loads the front layout; the back reloads its own from memory through s[0:1]), and the front's other SH registers except its checksum appended. Context registers are merged the same way. Inputs come from the front, outputs, specials and user data from the back; the scratch size is the larger of the two. Everything the fused Shader points to, including a copy of the header itself, is written into the caller's memory after the code, and the header is registered with the driver as a self-contained shader. Titles pass memory without honouring the reported alignment, so the program is placed at the first 256-byte boundary inside it, and the size query returns the total plus 255 bytes of padding (alignment reported as log2 8). Halves with embedded constant buffers, a front half without a trailer or final s_setpc_b64, a front half that needs RSRC2 state the back half does not enable, and geometry halves without fused memory throw. Hull halves keep the register-level fusion, which the tessellation path's separate local and hull programs fit. The half-type and stage checks stay shared. The driver now loads s[0:1] of a Gs program from its user-data address registers whenever they are set, not only for GsFront programs, since the back half of a fused program reloads its user data from there; a program without those registers keeps zero there (from SamG-Coder's 8345fbc).
0cdb5df to
258e4d5
Compare
…opovar#208 test layout, our merged PRs) into astrobot Conflicts resolved: - Driver.cpp: upstream split it into Execution/src/Driver/*; astrobot's driver changes are ported into the split files (flip throttle APS5_MAX_QUEUED_FLIPS, dispatch tolerance, NoteProgram, metadata-pass switch and DB HTILE blits, depth state in the draw register key, HTILE fill clears, wait outcome counters, opt-in deferred EOP interrupts). boykopovar#192's KnownDrawRejection is taken. - Our merged PRs take upstream's reviewed versions: boykopovar#124 shader fusion, boykopovar#128 videoout open param, boykopovar#132 CB metadata passes, boykopovar#138 EOP events, boykopovar#176 GE_INDX_OFFSET, boykopovar#136/boykopovar#137 pixel inputs and NoPerspective by I/J pair, boykopovar#133 mesh tests. boykopovar#142's interpolation validation is upstream's. - Depth: astrobot's DepthTarget model stays; upstream's DepthSurface module is dropped again, boykopovar#188's 16-bit depth-bit reads are kept on top. - Videodec2: upstream's ffmpeg-core version (boykopovar#42 rework); 3rdparty/FFmpeg stays for libSceAvPlayer only. - Tests follow boykopovar#208's layout (add_test_executable, build/tests); the AvPlayer, GDS and wave tests are defined the same way. - Shader disk cache format 5 and request serialization version 7 cover both sides' fields. - Duplicates the auto-merge produced (state decoders, RequestInputInfo, structurizer helpers, image offsets, opcode enum, tests) are removed.
What
Rebased onto current
main. This PR now replaces only the geometry path ofsceAgcUnknownFuseShaderHalves(fd5Bp5tGTgo) andsceAgcUnknownGetFusedShaderSize(dolOmWH+huQ). Hull halves keep the register-level fusion from fd4700b unchanged, and the half-type andVGT_SHADER_STAGES_ENchecks stay shared.Why the geometry path changes. fd4700b fuses geometry halves at the register level: the back half's registers with
SPI_SHADER_PGM_LO_ESpointing at the front half's code. The driver then compiles that front half as the draw's whole program (type 4,Stage::Mesh) and skips the back (Role::GeometryBack). Nothing links the two halves (LinkedProgramis only serialized, andDecodeRdnaFrontProgramhas no caller). The front half ends ins_setpc_b64 s[6:7]with nos_endpgm, so decoding runs on into thes_code_endpadding and the program trailer. In PPSA21564 the geometry-shader draws are skipped:Hull halves work with the register-level fusion, since the tessellation path compiles the local and hull programs separately, so they are left as they are.
Geometry halves are fused into one self-contained
Gsprogram:s_setpc_b64 s[6:7](its length comes from the program trailer), thens_noppadding to 256 bytes, then the whole back half. The front falls through into the back.PGM_LO/HI_GSpoints at the copied back code, and the ES program address at the fused code.s[0:1].Shaderpoints to, including a copy of the header, is written into the caller's memory after the code, and the header is registered with the driver as a self-contained shader. Titles pass memory without honouring the reported alignment (found by @Pacuka with The Smurfs Dreams), so the program is placed at the first 256-byte boundary inside it, andGetFusedShaderSizereturns the total size plus 255 bytes of padding, with log2 alignment 8.SizeAlignmoves intoShaderFusion.hppunchanged, so the test can call both functions.s_setpc_b64 s[6:7], a front half needing RSRC2 state the back half doesn't enable, geometry halves without fused memory, missing tables, and a program address above 48 bits. Mismatched half types and stage bits return0x8a6c0008as onmain.s[0:1]of aGsprogram is now loaded from its user-data address registers whenever they are set. Before, this only happened forGsFrontprograms. The back half of a fused program reads its user data through them. A program without those registers keeps zero there (SamG-Coder's fix, 8345fbc).Tested
agc_shader_fusion_tests, registered in ctest:s_nopfall-through, both patched program addresses, the RSRC1/RSRC2 merge, the SH and context register merge, semantics, specials, scratch size and user data copied into the fused memory, the self-contained header, and nothing written past the reported size;main(checksums from the front, RSRC merge,PGM_LO/HI_LSat the front code, back registers untouched) andmain's size query;With
main'sShaderFusion.cppthe geometry cases fail ("fused shaders are not 256-byte aligned").ctest: 80/80 pass.agc_driver_graphics_tests,agc_driver_mesh_tests,agc_driver_testsandagc_driver_recorder_testspass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository