feat(libScePrecompiledShaders): export the texmap shaders the piglet sample uses #6520
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6520"
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?
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-15T18:36:45Z.
What
The OpenOrbis piglet sample draws with the PS4 GLES library, libScePigletv2VSH, and takes its shaders from
libScePrecompiledShaders: it looks uptexmap/v_2.vertandtexmap/f_2.fragin the exported tablescePrecompiledShaderEntriesand passes their data toglShaderBinary. The table is an array of 0x28-byte entries (name at 0x0, size at 0x18, data at 0x20) that ends with a null name. AnyPS5 has nolibScePrecompiledShaders, and the console table holds Sony's compiled shaders, which AnyPS5 cannot ship.This adds the library with a table of AnyPS5's own two shaders under those names. Each is GLSL ES 3.10 source behind an
APS5GLSLline, a format of AnyPS5's own that the Piglet library in #6521 compiles with glslang; a PS4 binary given to thatglShaderBinarythrows. The shaders are written from the interface the sample uses:a_vertex, with the position inxyand the texture coordinate inzw;u_projectionMatrix,u_modelViewMatrixandu_textureSpaceMatrix;u_opacity, applied to alpha, as the sample'sGL_SRC_ALPHAblending expects;s_sampler.What the console shaders compute, the other names in the console table and the entry fields at 0x8 and 0x10 are unknown; they are recorded in the new
docs/dev/debt/libScePrecompiledShaders.md. Part of the PS4 homebrew work tracked in #3093.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, onmain03c4cb5e7:guest_precompiled_shaderstest walks the table to its null entry and checks the two names, that the reserved fields are 0, and that each size is the length of the source without its terminator. It compiles and links both shaders with glslang and checks the reflected interface: the threemat4matrices, thefloatopacity, thesampler2D, anda_vertexas the onlyvec4input. It also checks that the fragment shader produces SPIR-V.APS5GLSLline, the opacity not applied, the texture-space matrix not applied. Reading the position fromzwinstead ofxyis caught only byguest_pigletin #6521, which renders with these shaders.main03c4cb5e7with this, #6519, #6521, #5990 to #5994, #6376, #5138 and a change that answers the LinuxTIOCGWINSZwithENOTTY, as #5569 did: it finds both shaders (Found shader texmap/v_2.vert ... of size 342,Found shader texmap/f_2.frag ... of size 263) and draws at 59.96 FPS. With neither this library nor Piglet's, it stops at start-up with 48FAIL: unresolved ELF importlines, the firstQ-JroQdKRfM(scePrecompiledShaderEntries) and one for each Piglet function.main03c4cb5e7: 1296 of 1300 pass.agc_driver_gpu_indirect_arguments_misaligned_writer_aheaddoes not compile with MinGW onmain(#6452 fixes it), andprx_thread_local_destructorsfails as it did onmain92cdc7b62on this machine without my changes;agc_shader_disk_cache(timeout) andagc_driver_multisample_fill_host_onlyfailed underctest -j8and pass when run alone. Full ctest of the build with all my open pull requests: 1304 of 1306 pass; the two that do not are the first two above.tools/check_conventions.pypasses.Not tested on Linux or macOS.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T20:19:16Z.
Review: COMMENTED
Linux run (Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests), head
2f779a57emerged ontomain44df21632. The description says it was not tested on Linux.OK: .../libScePrecompiledShaders.prx);guest_precompiled_shaderspasses, including the glslang compile and link of both shaders.Non-GPU suite (
ctest -E "^agc"): same result asmain; onlyfile_writer_binaryandfile_writer_textfail, and they fail onmaintoo on this machine (Ubuntu 26.04 coreutils).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-15T23:26:39Z.
Thanks for the Linux run, @jotitadev. Good to know glslang compiles and links both shaders there too.
AI-assisted: yes (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by javierUDP on 2026-10-19T19:05:35Z.
Review: COMMENTED
Static review of this PR and of #6519, both read against the OpenOrbis
pigletsample rather than executed: the full build does not configure on macOS, so I could not compile or run either one. I found nothing to change in either. Recording what I checked so the next reader does not repeat it.The entry names match the sample.
stringsonsamples/piglet/.../piglet.elffromsamples-elf-llvm-18.zip(v0.5.3) contains exactlytexmap/v_2.vertandtexmap/f_2.frag, the two entries this PR exports, and no other shader path.The symbol kind matches how the sample imports it.
relinker --registryon that sample resolvesscePrecompiledShaderEntriesasR_X86_64_GLOB_DAT, so the importer expects data, which is whatscePrecompiledShaderEntries_nid_postfix[]provides;scePigletSetConfigurationVSHcomes through asR_X86_64_JUMP_SLOT, a function, matching #6521.The source marker is produced and consumed consistently.
SourceMagicis written by both entries here and checked in #6521 atContext.cpp:342, which refuses a binary without it and strips it before handing the text to glslang, so theAPS5GLSL\nprefix never reaches the compiler.On #6519:
SystemLibraryPathrejects a name with a path separator, which keeps/common/lib/../x.sprxout, and the test covers that case along with a missing module and a.prxsuffix.sceKernelGetFsSandboxRandomWordreturns a static constant, so the sandbox prefix cannot be built from a null pointer, and the same concatenation already appears inSandboxCertificates.cpp.I did not review the GLES state machine in #6521 beyond what I commented there.
Written with AI assistance. The sample cross-checks above were run on my own machine; nothing was compiled or executed from these PRs.
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-21T21:51:23Z.
Thanks @javierUDP for checking the entry names, the symbol kinds and the source marker against the sample. Doing that from the sample itself is the check this PR needed.
The branch is rebased onto
maincecb540a6(now0b42ec382), with #6521 on top of it. #6519 has merged, so the piglet sample now needs only this PR and #6521.guest_precompiled_shaderspasses on Windows 11, andcheck_conventions.pypasses.AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T03:22:52Z.
Review: APPROVED
Reviewed — looks good
The changed files are readable and the library is included by the existing PRX build loop; author-reported tests and runtime checks were not rerun here.
What I ran
Reviewed head
0b42ec38273c7638cd11f98acb0a962f55e74f6f. I read the prepared description, commits, diff and manifest, all five changed files, and the relevant PRX target-discovery section ofcore/libs/CMakeLists.txt. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported Windows build, ctest results, convention check and Piglet sample runtime were not independently verified. Linux and macOS behavior was not tested. No files were excluded by the manifest; all five files marked reviewed were read.
To get this to a good state
Nothing is required.
Pull request closed