raytracing: Software RT with --raytracing #1559
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1559
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1559"
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?
@defektu on GitHub · 2026-10-16 15:46 UTC · original
defektu:pr/mfgt-raytracing→main· +5001 −260 · 68 files · 25 commits · openPart of getting My First Gran Turismo (PPSA24156) running with ray tracing (reflections). This PR adds
--raytracing(off by default) and the compute path behind it. Draft.Dependencies: the title does not start on
mainalone. It needs the tessellation lowering (#1032) and mixed sample counts / EQAA (#1035) first; neither is part of this PR. #1032 is based ond7974dc7("Fix scalar buffer reads across sparse guest mappings"), whichmainhas since reverted (d01633e1): test this PR with #1032 and #1035 merged on top of currentmain, not on a base that still hasd7974dc7.What it does
The game's ray tracing kernels are compute shaders that call a table of about 290 shader functions, chosen by the GPU at run time.
KYTY_RT_COMPILE_SLOTS, default 12, 1..16). A dispatch waits for its pipeline, because skipping one leaves its part of the image unlit (the reflections)._PipelineCache/rtfn_*.txt).--raytracingswitch, so other titles are not affected by the option.S_CODE_END, image creation fallback, buffers outside mapped memory (bound as null with a warning), unaligned read-only storage buffers (copied to an aligned stream range, with a warning).Known gaps
KYTY_RT_COMPILE_SLOTSon small machines. Retranslation adds a few pipelines while the scene reveals new functions (about 110 in total in a long run).shader_recompiler_compute_tests.ErrorDeviceLostinMasterSemaphore::Wait) about 5 minutes after a kernel was retranslated several times in a row; the log was repeatingRT calls: unexpected call table stride=16 records=4578. I do not know yet whether that is related to the fallback described above or was always there.Testing: Windows (Release, clang-cl). On
mainat5dec5231with this PR:resource_tracking_tests,resource_materialization_tests,scalar_provenance_tests,shader_cfg_testsandshader_recompiler_compute_testspass. With #1032 and #1035 merged on top, the game shows the reflections (109 pipelines compiled, 12 retranslations in a long run).🤖 Generated with Claude Code
@defektu on GitHub · 2026-10-16 15:48 UTC · original
Takes up upto 15 mins to compile pipelines. It is draft and sometimes drops or recompiles pipelines. So a bit unstable. Beware of that.


@defektu on GitHub · 2026-10-16 21:14 UTC · original · edited 2026-10-16 21:35 UTC
Design note: a retranslated kernel keeps running its previous program until the new pipeline is compiled
A call-table kernel inlines only the functions the GPU has been seen to call. When the GPU calls a function that has no inlined copy, the kernel is retranslated with that function, and each call group that grew gets a new pipeline. Compiling one of these pipelines takes from seconds to minutes (257 s at worst on an RTX 5060 Ti), and a dispatch that waits for it freezes the game: in a run with a cold pipeline cache the frame counter barely moved for minutes at every retranslation.
This PR therefore keeps the previous program of a retranslated kernel as a fallback. Its dispatches keep running with the old pipeline while the new one compiles on a worker thread; once the new pipeline is ready the dispatches switch to it and the old program is dropped. Without a usable previous program (the first translation of a kernel) a dispatch still waits for its pipeline, because skipping it leaves its part of the image unlit.
The trade-off: for the seconds a retranslated pipeline compiles, a call to a function the old program does not inline takes the same path it took before the retranslation, so that part of the reflections can be missing until the switch. With this the game stayed responsive during retranslations (about 35 frames per 20 s on a cold cache, against a handful before).
Open: one long run on the combined tree (this PR + #1032 + #1035) ended in a GPU hang (
ErrorDeviceLost) a few minutes after a kernel was retranslated several times in a row, with the log repeatingRT calls: unexpected call table stride=16 records=4578. I have not yet established whether the fallback has anything to do with it, so I am not sure this is the right call. The alternative is to hold the game at every retranslation, which is what the first version of this PR did. Feedback welcome.Expect crashes, memory leaks and flashing pictures.
@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
📝 Walkthrough
The pull request adds an experimental ray-tracing option and implements compute-shader call-table expansion, feedback, resource specialization, and asynchronous pipeline compilation. It also adds packed texture format handling and 64-bit buffer atomics. Vulkan image and descriptor paths gain fallback handling. Shader IR validation, SSA rewriting, and scalar optimization passes are updated, with new tests for these changes.
Suggested reviewers:
nmzik,senaxx,claxten10Priority: ➖ Normal
Change: Feature
Merge Risk: 🟠 High · up to
fa1d9This change breaks compilation on supported Linux and macOS builds, and introduces a descriptor-repair path that can silently corrupt texture/sampler descriptors even with ray tracing disabled. The experimental ray-tracing path also has issues that can run function bodies twice, skip unrelated compute dispatches, and leak shader modules. These should be resolved before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 20.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 216 functions across 50 files. (18 skipped: 3 unsupported, 15 over the file limit.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -244,0 +272,4 @@case BufferFormat::k8_8_8_8UScaled: return BufferFormat::k8_8_8_8UNorm;case BufferFormat::k8_8_8_8SScaled: return BufferFormat::k8_8_8_8SNorm;case BufferFormat::k16_16_16_16UScaled: return BufferFormat::k16_16_16_16UNorm;case BufferFormat::k16_16_16_16SScaled: return BufferFormat::k16_16_16_16SNorm;@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15146
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 35859
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 23053
Scale remapped scaled formats by their component range.
RemapTextureFormatmaps 16-bit and signed scaled formats to normalized formats.UnpackImageTexelandUnpackImageGatherthen apply a fixed255.0fscale. This is correct only for 8-bit unsigned formats. Use a scale derived from component width and signedness, such as65535.0ffor 16-bit unsigned,127.0ffor 8-bit signed, and32767.0ffor 16-bit signed formats.The conversion guard also rejects
Sscaledformats. Allow supported signed scaled conversions through that guard.@ -135,2 +135,2 @@if (adjustment >= 256 || size > max_range - adjustment) {EXIT("storage buffer offset adjustment is unsupported\n");if ((adjustment % sizeof(uint32_t) != 0 && !resource.written) || adjustment >= 256 ||size > max_range - adjustment) {@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9898
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12343
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 39268
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9279
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2148
Reject non-dword adjustments for written buffers.
A written buffer with a non-dword
adjustmentbelow 256 bypasses the guard. The shader addsbuffer_offsetto the byte address and shifts the result right by two for dword stores. This can target the wrong dword.🐛 Suggested fix
📝 Committable suggestion
@ -346,0 +379,4 @@input_info.needs_call_passes = passes->second;return ShaderProgram {};}}@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12940
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 20333
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 18448
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 13730
Reset
lookup_key.variantbefore the compute requirement lookups.lookup_keyis a reusedProgramCachemember. An RT table mismatch can leavevariantnonzero. The compute requirement maps use keys withvariant == 0, so the probes can miss and fall through toShaderRecompiler::TranslateProgram. This can cause an unnecessary translation beforeneeds_call_passesis rediscovered. The later call-pass dispatches do not repeat this specific miss because the translation path resetsvariantto zero.Suggested fix
@ -355,0 +524,4 @@programs.erase(programs.find(lookup_key));entry = programs.end();break;}@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Destroy the shader modules of program-cache entries that are erased.
Only
~ProgramCachecallsdestroyShaderModule, and only for entries that are still inprograms. Three new paths drop entries without destroying theirPermutation::handle.module:programs.erase(entry)after an entry moves toretired. This one is safe because the entry still exists inretired.retired.erase(kept)at Line 514 andretired.erase(old)insettle(Line 401).programs.erase(programs.find(lookup_key))at Line 524, when the variant limit is reached.Every retranslation and every eviction past 16 variants therefore leaks the SPIR-V modules of a large ray-tracing kernel. The PR already notes high memory use.
A module can only be destroyed after any
createComputePipelinescall that uses it has returned. The detached worker inStartAsyncComputeholds the rawmodule. Suggested fix:(program_id, module)pairs.m_async_computehas no pending job for that ID, or when the job isready.m_compute_pipelinesentries for the erased IDs at the same time, or they also stay allocated.@ -495,0 +732,4 @@std::fprintf(stderr, "RT calls: a pipeline is still compiling at shutdown, ending the process\n");std::fflush(nullptr);std::_Exit(0);}@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Do not read the driver cache while a ray-tracing compile is running.
The comment at Lines 1336-1338 says that reading the pipeline cache during a compile crashed the driver. Only
TakeAsyncComputechecksg_active_rt_compiles, and two other paths still callSave()without that check:CheckpointDriverCache()callsSave()every 5 minutes fromGetGraphicsPipelineandGetComputePipeline. Worker threads may be insidecreateComputePipelineson the samem_driver_cacheat that moment.~PipelineCachecallsSave()at Line 728, before this check. On shutdown during a compile, it reads the cache while the compile is still running.Move the check into
Save()itself so that every caller is covered. The dirty flag keeps the save pending until no compile is active. In the destructor, run the async check beforeSave().Proposed fix
g_active_rt_compilesonly counts threads that have acquired a slot. A small race remains, but these changes remove the deterministic overlap.@ -49,0 +50,4 @@{Prospero::BufferFormat::k2_10_10_10UNorm, vk::Format::eA2B10G10R10UnormPack32},{Prospero::BufferFormat::k2_10_10_10SNorm, vk::Format::eA2B10G10R10SnormPack32},{Prospero::BufferFormat::k2_10_10_10UInt, vk::Format::eA2B10G10R10UintPack32},{Prospero::BufferFormat::k2_10_10_10SInt, vk::Format::eA2B10G10R10SintPack32},@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12785
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 23962
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 44400
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41438
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 21097
Do not map
k2_10_10_10*toeA2B10G10R10*.DccAlphaOnMsbdistinguishes the layouts:k2_10_10_10has alpha off the most-significant bits, whilek10_10_10_2has alpha on the most-significant bits.eA2B10G10R10*stores 2-bit alpha on the most-significant bits. The currentVulkanFormatlookup therefore decodesk2_10_10_10*with the wrong packed layout.Use integer backing with shader-side decoding for these four formats. The existing
ColorMappingBgraandReverse10_11_11paths already handlek10_11_11Float.@ -1051,0 +1057,4 @@vk::BufferCreateInfo buffer_info;buffer_info.size = size;buffer_info.usage = vk::BufferUsageFlagBits::eShaderDeviceAddress | vk::BufferUsageFlagBits::eStorageBuffer;auto buffer = graphic_ctx.device.createBuffer(buffer_info).value;@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Retain and release the feedback buffer.
When ray tracing is enabled,
CreateVulkancreates a buffer and allocates memory, but both handles remain local.WindowContext::~WindowContexttherefore destroys the device without unmapping or releasing them. Store both handles on the context. Clear the published feedback pointers, then unmap, destroy the buffer, and free its memory before destroying the device.@ -420,0 +505,4 @@ctx.state.builder.AddFunction(spv::OpCompositeConstruct, TypeU32Vector(ctx.state, 4), result,values[0], values[1], values[2], values[3]);return result;}@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject 16-bit data reads for
k10_10_10_2Float.StoreTexelcallsEXIT_NOT_IMPLEMENTEDformem.data_bits == 16uwith this format.UnpackImageTexelhas no equivalent guard.For this format,
ResultVectortakesvalue_classfromSampledTextureNumericClass(conversion). That class isUint, becauseuint_textureistrueinkFormatInfo. Fordata_bits == 16u,ResultVectorthen uses its integer pack path. It packs the low 16 bits of each decoded f32 bit pattern. That discards the exponent and the mantissa MSBs. The shader gets wrong values without any error.Add a guard that matches the store path.
Proposed fix
📝 Committable suggestion
@ -519,0 +580,4 @@found = true;distinct = 1u;} else if (!(candidate == result)) {++distinct;@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preserve sampler selection when valid records disagree.
If two records contain different valid samplers,
MaterializeHopSamplerselects the first and only logs the difference. Calls through the other record then use the first record’s filtering and addressing state, producing incorrect sampling. Represent the sampler choice per record, or decline this specialization rather than silently binding a different sampler.@ -740,0 +845,4 @@// The record points at the descriptor. A null or unreadable pointer is an unused record: its// descriptor stays zero and normalization rejects it.uint64_t target = 0;if (!ReadPointerPath(indirect, table_base, table_size, table_offset, runtime, target)) return false;@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Skip an unreadable pointer-hop record instead of failing the table.
A counted table can contain a record whose pointer path is unreadable.
ReadPointerPaththen returns false, and this branch fails materialization for the entire resource, althoughMaterializeHopSamplerskips an unreadable candidate and the descriptor read below already permits an empty candidate. Treat that record as null so other valid records remain usable.@ -965,0 +1149,4 @@site_class.numeric_class = site.atomic ? Prospero::TextureNumericClass::Uint : Prospero::TextureNumericClass::Float;site_class.dimension = site.dimension == Decoder::ImageDimension::Unknown ? Decoder::ImageDimension::Dim2D : site.dimension;site_class.cube = site.cube;site_class.mip_count = 1u;@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Do not null valid textures against a hard-coded site class.
For a padded sampled-image table,
site_classalways requiresFloatand one mip level. The check at Line 1178 consequently nulls a valid unsigned-integer candidate or a valid multi-mip candidate even when it matches the image operation’s dimension. Derive the required class and mip behavior from a supported site contract, or retain distinct compatible variants.@ -3102,0 +3259,4 @@bool TryMakePointerHop(Inst& handle, const DescriptorSource& descriptor, IndirectDescriptorPlan& plan,ValueOpcode expected, uint32_t width, uint32_t companion_offset = UINT32_MAX) {if (handle.GetOpcode() != expected || handle.NumArgs() != width) return false;plan = {};@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42938
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 38925
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 17395
Restore
read_dwordsafter resetting the plan.plan_handleinitializesplan.read_dwordsbeforeTryMakePointerHop. The helper clears the plan and does not restore the width. A successful non-retained pointer-hop plan can therefore leave its reads unmarked as planning-only and let them reachCollectas ordinary address reads.🐛 Suggested fix
📝 Committable suggestion
@ -3694,0 +4064,4 @@handle->SetArg(bad_dword, Value(0u));continue;}}@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Limit
TracesToWaveMaskto real lane-mask scratch and enable it only for ray tracing.TracesToWaveMaskwalks every operand of every instruction, including memory-load addresses. A typical waterfall descriptor has the formdword = Load(table, FindILsb(Ballot(...)) * stride). That descriptor is selected by the GPU, but this check reaches theBallotthrough the address and treats the word as wave-mask scratch.GetHandlethen replaces the word with zero in bothdescriptorandhandle.The comment says the check "keeps a genuinely divergent descriptor failing loudly", but the code does not do that. Before this change, such shaders reached
Fail. Now they silently sample with a corrupted image or sampler descriptor.The block does not check
m_program.gpu_selected_call_payloads, so it also runs when--raytracingis off. The image dword 7 rule in Lines 4073-4079 is not gated either.Suggested fix:
ReadFirstLane, andPhiinstructions.Ballot, possibly wrapped in bitwise or extract operations.m_program.gpu_selected_call_payloadsis set.Proposed gating
In
TracesToWaveMask, returnfalseinstead of recursing wheninstis a memory read (BufferAccessOf,AddressOpcodeInfoOf, orImageOpcodeInfoOfis notNone), aReadFirstLane, or aPhi.📝 Committable suggestion
@ -582,0 +637,4 @@std::memcpy(destination, reinterpret_cast<const void*>(address), words * sizeof(uint32_t));return true;} __except (1) {return false;@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🔴 Critical | 🏗️ Heavy lift
Replace the Windows-only guest-memory read on non-Windows builds.
ReadGuestWordsuses__tryand__exceptwithout a platform guard. The same file has a POSIXpthreadpath, but a non-Windows compiler cannot compile this Windows SEH block. Provide a supported non-Windows memory-read implementation or guard the SEH implementation with a platform-specific alternative.@ -582,0 +947,4 @@for (const auto low: all_functions) {if (functions.size() >= RtCallGroupMinimum) break;functions.insert(low);}@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Do not execute padding functions in another call group.
When a group has fewer than four functions, this loop inserts functions from
all_functionsregardless ofCallGroupOf. The compare chain then executes those functions in their own group and in the padded group. A function with a store or atomic operation can apply its effect twice for one call. Keep the descriptor-resolution padding without making foreign-group bodies executable.@ -582,0 +1308,4 @@return opcode_word | (static_cast<uint32_t>(delta) & 0xffffu);};// the call becomes a branch to the first chunk's entry chainout[return_index - 1u] = branch_word(0xbf820000u, return_index - 1u, chunks[0].entry);@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Check the call-to-entry branch range.
branch_wordretains only the low 16 bits of the signed branch displacement. If the original program is large, or an earlier call-site expansion has already appended enough code,chunks[0].entrycan be more than 32,767 words from this call. The rewritten call then branches to the wrong instruction. Reject that layout or place a reachable relay near the call; apply the same range check to return relays.@ -595,3 +1470,3 @@Decoder::DecodeProgram(code, source.decoded);}if (source.decoded.has_swap_pc) {if (source.decoded.has_swap_pc && !RtOwnsCalls(options)) {@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Keep the existing scalar-call linking path for non-RT compute shaders.
With
--raytracing,RtOwnsCallsbypassesPrepareCallTargetfor every compute shader withS_SWAPPC_B64. The existingRefreshShaderSourcepath supports scalar leaf calls, but an unrelated call thatExpandOneCallcannot expand now reachesuses_function_callsand has its dispatch skipped. Select RT ownership from an eligible call-table form rather than the global flag and compute stage alone.@coderabbitai[bot] on GitHub · 2026-10-21 21:31 UTC · original · reviewed
Actionable comments posted: 17
ℹ️ Review info
⚙️ Run configuration
e3430fea-7310-48ba-80e5-db0f8fd994da📥 Commits
Reviewing files that changed from the base of the PR and between
5dec523143andfa1d98c6d8.📒 Files selected for processing: 68
CMakeLists.txtsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/graphics/guest_gpu/gpu_format.cppsrc/graphics/host_gpu/renderer/image/image.cppsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/host_gpu/renderer/pipeline/shaders.cppsrc/graphics/host_gpu/renderer/render.hsrc/graphics/host_gpu/renderer/renderCompute.cppsrc/graphics/host_gpu/vulkanCommon.cppsrc/graphics/presentation/window/vulkanWindow.cppsrc/graphics/shader/recompiler/RtFeedback.hsrc/graphics/shader/recompiler/ShaderRecompiler.cppsrc/graphics/shader/recompiler/ShaderRecompiler.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterBvh.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/frontend/decode/MemoryOps.cppsrc/graphics/shader/recompiler/frontend/decode/ScalarAluOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/frontend/translate/Scalar.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.hsrc/graphics/shader/recompiler/frontend/translate/Translator.hsrc/graphics/shader/recompiler/ir/Block.cppsrc/graphics/shader/recompiler/ir/Program.cppsrc/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/Value.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/graphics/shader/recompiler/ir/passes/ConstantPropagation.cppsrc/graphics/shader/recompiler/ir/passes/ConstantPropagation.hsrc/graphics/shader/recompiler/ir/passes/DynamicBuffer.cppsrc/graphics/shader/recompiler/ir/passes/DynamicBuffer.hsrc/graphics/shader/recompiler/ir/passes/PhiWebs.cppsrc/graphics/shader/recompiler/ir/passes/PhiWebs.hsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/ResourceTracking.cppsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cppsrc/graphics/shader/recompiler/ir/passes/SrtWalker.cppsrc/graphics/shader/recompiler/ir/passes/SrtWalker.hsrc/graphics/shader/recompiler/ir/passes/SsaRewrite.cppsrc/graphics/shader/shader.cppsrc/graphics/shader/shader.hsrc/kernel/memory.cppsrc/kernel/memory.hsrc/launcher/forms/configuration_edit_dialog.uisrc/launcher/include/configuration.hsrc/launcher/src/configuration.cppsrc/launcher/src/configurationEditDialog.cppsrc/launcher/src/mainDialog.cppsrc/main.cpptests/RaytracingConfigStub.cpptests/ResourceTrackingTests.cpptests/ScalarProvenanceTests.cpptests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@ew-sudo on GitHub · 2026-10-26 19:45 UTC · original
Tested this PR on Gran Turismo 7 (PPSA01317), RTX 4070 Laptop. GT7's garage uses a ray tracing kernel with a call table of 12 hit functions. Without this PR, main stops in
FindScalarDefinition(the call target is path-dependent). With it, the table is found (group 0/12 inlines 4 of 12 known functions), the 13 pipelines compile, and the car renders correctly in the garage. It needed two small changes, both below.1. A function return encoded as
S_SWAPPC_B64 NULL, s[14:15]. GT7's hit functions return withbefd210einstead ofS_SETPC_B64 s[14:15](be80200e).FindFunctionExtentdid not see the end of the function, decoded the data after it (0x30306c73, ASCII) and stopped withunsupported scalar source operand 0x73. Treating both encodings as a return fixes it in the three places that look forSetPcWordS14:diff
2. GPU-selected images and samplers in RT kernels (workaround, not a real fix). Kernel
0x5d8fac8c06b94572loads the T# and S# of the hit object's material through a chain of pointers (LoadAddressU32(GetAddressResource(LoadAddressU32(...)))), so resource tracking stops withGetImageResource dword 0 is not a valid runtime value(then the same forGetSamplerResource). As a stopgap, in call-table kernels only, such a descriptor becomes a null image or the zero sampler. The kernel then runs, but reflected objects lose their texture. A real fix would read the descriptor in the shader; I left that to you since it is your design.diff
Also seen:
RT calls: only 2 free SGPRs for the call saves (s83 not preserved)on this kernel.Performance: below 1 fps in the garage once the pipelines are compiled, and about 70 s of RT pipeline compiles on the first visit.
Notes:
5f29374d, which this PR's base predates.What is still missing (for a real fix)
only 2 free SGPRs for the call saves (s83 not preserved)means some state may not survive a call. It did not show visibly in the garage, but results may be wrong.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.