fix(libSceGLSlimVSH): copy texture uploads and glReadPixels output through checked host buffers #20807
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20807"
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 milescoviello on 2026-11-15T15:51:19Z.
What
glTexImage2DandglTexSubImage2D(through the sharedUploadhelper) decoded the guestpixelsbuffer in place, pixel by pixel.glReadPixelsmemcpy'd each converted pixel straight into the guest buffer. An unmapped or partly mapped pixel buffer faulted the host. The library's debt file already lists this as needing a bounded host buffer.Upload
Uploadnow copies the source rows into a host vector with oneGuestCopyIn_nid_no_patch, then decodes from there.(height - 1) * stride + width * size, with no padding after the last row. A buffer that ends right after its last row still works.GL_INVALID_VALUE(0x0501). The texture is left unchanged:glTexImage2Ddoes not replace the image, andglTexSubImage2Dwrites nothing.glTexSubImage2Dnow catchesbad_allocfrom the host vector asGL_OUT_OF_MEMORY, the same asglTexImage2Dalready does.glReadPixels
GuestCopyOutRows_nid_no_patch(#20832), whether they are contiguous in the guest buffer or strided by column clipping or pack padding. (Edited: before the rebase this wrote oneGuestCopyOut_nid_no_patchper clipped row.)These are whole-image copies: one checked copy per upload and one batched row copy per read. They replace per-pixel guest accesses, so the cost per call goes down rather than up.
The existing debt entry is rewritten through a
## changefragment underdocs/dev/debt/changes/. It records 0x0501 as a host-safety fallback, since console behaviour here is not measured. That code matches what this library already returns for other unreadable arrays (glDelete*,glShaderSource).Tested
Linux (Ubuntu 26.04.1), GCC 15.2, Release.
maine4caa07950(head2d02fe2db9) to use #20832'sGuestCopyOutRows_nid_no_patch. The fourguest_glslim*tests pass, 3 runs of 3, including the clipped and contiguousglReadPixelscases below.PixelFaultsstep inguest_glslim_state. The buffers sit at the end of a page followed by aPROT_NONEpage (PAGE_NOACCESSon Windows).UNPACK_ALIGNMENT8 (stride 16) ends exactly at the page end, 28 bytes, and reads back right.glReadPixelsinto the page end writes the expected bytes.x = -1) leaves column 0 at its fill value and writes the rest.errnoleft at 71:glTexImage2Dfrom0x10;glTexSubImage2Dfrom0x10;glReadPixelsto0x10;glReadPixelsinto a buffer whose second row is on the protected page, both contiguous and clipped.guest_glslim_stateand the other GLSlim tests pass.Images.cppfrommainwith these tests dies with SIGSEGV at address0x10. The valid page-end cases run first and pass onmaintoo.git merge-treeis clean againstmain, #14212, #20798, #20802 and #20804.main, all five GLSlim tests anddebt_fold.py --checkpass.tools/check_conventions.pypasses on the branch and this body.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)