Repository navigation
Conversation
…texcoords handling - Fix pointer scaling overflow in rsxSetupContextData by casting addr to uintptr_t before adding byte length. - Add allowTex (bit 15) flag in compilerfp.cpp and LoadFragmentProgramLocation when fragment program samples textures. - Correct SetVertexProgramConstants second burst source offset to &value[16] instead of value. - Fix SetTimeStamp writing outside allocated packet bounds (currenp[1] instead of [2]). - Fix ResetCommandBuffer to query real buffer start offset via gcmAddressToOffset and rewind context->current. - Fix rsxContextCallback assembly calling convention to preserve registers across 32-bit OPD invocations. - Add missing vdec codec defines in vdec.h.
|
Independent confirmation on RPCS3 with the current ps3toolchain (GCC 13.2 PPU). Before this PR (PSL1GHT master Things that made no difference:
After applying this PR on top of master: the stock My reading, not verified by disassembly: this matches item 5. In the old Not tested on real hardware (my PS3 is offline right now). Environment: ps3toolchain master, GCC 13.2.0 PPU (powerpc64-ps3-elf), binutils 2.42, Ubuntu 24.04, RPCS3 v0.0.43-20291 (Vulkan), firmware 4.76, booting the |
|
Those are real issues to had to be fixed. I am doubtful about my PR is still awaiting. |
|
For future reference and maintainers: the OP was removed from the community for misconduct. The followup "independent confirmation" is not tested on a real PS3 by its own admission. Both reports also fail the AI policy introduced in dd4e8c9. This PR predates the official policy, but the concern is self-evident; PRs with no evidence of human involvement are assumed to not be understood by their original poster. Therefore, we can't confirm if these bugs are real. There may, however, be a genuine issue referenced in this PR and that is worth acknowledging. However, we cannot accept the precedent as it stands. |
|
So admitting pr rejection from "arbitrary" reasons and personal hate? |
Please, there's no value or makes any sense to "confirm on RPCS3" , unless you can test and validate things on real hardware, there's no further evidence that it will work on a real PS3 system. PSL1GHT's aim will always be to allow developers to build on real hardware. You can use tools and emulators, but unless things are thoroughly tested on a PS3, we won't take the code as valid. |
As i said they are tested on both of my Moonlight and Movian-Next projects. Both are tested on real hardware. :/ PSL1GHT's RSX code is broken, i found three of them and they needed to be fixed. |
|
@Cruslan - the current assumption is that these are likely to be RPCS3 bugs, and the current PR is incompatible with our AI policy. |
|
Since other users reported the example
That way we can verify and merge the changes to the repo. I'm open to review PRs , no arbitrary / personal issues here. |
Summary
This pull request introduces critical stability fixes to
librsx,cgcomp, and related GCM headers inPSL1GHT. These patches resolve severe hardware deadlocks, memory corruptions, pointer arithmetic overflows, and shader compilation failures that break continuous drawing and streaming workloads.These issues directly surfaced during the porting and bare-metal deployment of PS3-Moonlight and PS3-Movian.
Important
Bare-Metal Hardware Verification:
Both the reproduced failure states and their corresponding fixes have been thoroughly tested and validated on physical PlayStation 3 retail hardware running HEN as well as RPCS3. These fixes are proven in sustained real-world production workloads.
Technical Problem Breakdown & Fix Details
1.
librsx: Wrap User Callback in__get_opd32to Prevent Fatal Crash on Buffer Wrapb28d153ppu/librsx/init.cIn the 64-bit PowerPC ELF ABI (
ppc64), C function pointers do not point directly to executable machine code; they point to a 24-byte Official Procedure Descriptor (OPD) consisting of[function_entry_address, toc_pointer, environment_pointer].However, in
ppu/include/rsx/rsx_function_macros.h, the low-level GCM assembly callback dispatcher (rsxContextCallback) is designed with 32-bit word instructions (lwz 0, 0(%3); lwz 2, 4(%3); mtctr 0; bctrl), expecting a 32-bit OPD layout (opd32).Passing a standard 64-bit function pointer directly to
rsxSetContextCallbackcauses the dispatcher to read high 32-bit word halves as function entry and TOC pointers. The moment the RSX command buffer wraps around, the dispatcher executes a jump to corrupted memory, immediately producing a fatal PPU trap / panic.rsxSetContextCallbacknow wraps user callback handlers through__get_opd32(), guaranteeing that a properly formatted 32-bit OPD entry point and TOC descriptor are stored intocontext->callback.2.
librsx&cgcomp: Fix Pointer Arithmetic Overflow, Vertex Constant Offsets, and Texture Sampling Flagc4fb5c7ppu/librsx/init.c,ppu/librsx/commands_impl.h,ppu/librsx/buffer_impl.h,ppu/include/rsx/rsx_function_macros.h,tools/cgcomp/source/compilerfp.cpp,ppu/include/codec/vdec.hrsxSetupContextData(init.c):The command buffer initialization previously performed pointer arithmetic by adding a byte
lengthdirectly to a typeduint32_t*pointer. In standard C/C++, addinglengthtouint32_t*scales the offset bysizeof(uint32_t) == 4. For instance, a 1 MB buffer resulted in settingcontext->current4 MB ahead, pointing far outside the allocated buffer boundaries and immediately causing heap/memory corruption.Fix: Cast the base address to
uintptr_t/ raw byte offsets before adding the byte length.cgcompTexture Sampler Control Bit (allowTex/0x8000):When compiling Cg fragment shaders that perform texture sampling (such as YUV-to-RGB color space conversion in video playback and streaming), the RSX microcode requires bit 15 (
0x8000) to be set in the fragment program instruction word. Without this flag, texture coordinate interpolation and texture unit fetches fail or output black/garbage frames.Fix: Explicitly set
allowTex(bit 15) incompilerfp.cppwhenever the fragment shader references texture samplers.commands_impl.h):In
SetVertexProgramConstants, the second burst packet was reusing the base pointervalueinstead of advancing by 16 floats (&value[16]). When uploading matrix blocks or multi-vector arrays exceeding 16 constants, the first chunk was repeatedly overwritten while subsequent vectors were dropped.Fix: Properly advance the source data pointer to
&value[16]for the second transfer chunk.SetTimeStamp(commands_impl.h):SetTimeStampwas writing tocurrent[1]instead of[2], corrupting the command stream and misaligning subsequent GPU commands.Fix: Corrected packet indexing to respect packet payload sizing.
rsx_function_macros.h):The inline callback macro was clobbering caller-saved registers during 32-bit OPD dispatch, causing mysterious crashes upon returning from user callbacks.
Fix: Guarded register preservation across the assembly invocation.
vdec.h):Added missing standard VDEC codec constants (MPEG2, AVC/H.264, VC-1, DivX) required for hardware video decoding integration.
3.
librsx: Bounded Spin Timeout and Hardware Memory Barrier inResetCommandBuffer20241e3ppu/librsx/buffer_impl.hResetCommandBufferhad an unbounded loop waiting for the GPU read pointer to reach the offset:ctrl->getmay never matchoffset. This caused the PPU thread to enter an infinite spinlock, hard-freezing the entire console and requiring a physical power-cord disconnection.spins < 100000, ~3 second timeout) to gracefully break out of deadlocks.__sync()) before updatingctrl->put = offsetto ensure all previous cache flushes and memory transactions are committed to the RSX memory controller.gcmAddressToOffset(context->begin).Real-World Project Impact
0x8000), and hard PS3 freezes on frame burst stalls.