WebGL renderer does not implement GP0(E6) destination mask protection
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by reading Draw_SetMask and the WebGL renderer path that handles GP0(E6); the issue provides a standalone C reproduction and expected framebuffer readback. Compare destination mask behavior with the GP0(E6) rules in PSX-SPX, then check drawing alongside uploads and VRAM copies, which the issue calls out as needing separate coverage. Done means protected destination pixels remain unchanged in the reproduction.
Written by the indexing model from the issue text.
Description
Masked VRAM pixels are overwritten by subsequent drawing. Draw_SetMask reports NOT_IMPLEMENTED for nonzero mask settings.
Tested on PsyZ 35c673e, Emscripten 6.0.13 / WebGL2, Chromium 157 (SwiftShader), macOS arm64.
Reproduction
Download the standalone C example (save as repro.c). No game source, executable or assets required.
All commands go through DrawOTag, deliberately avoiding the independent DrawPrim dispatch defect in #227.
- Send GP0(E6) with bit 0 set (
0xe6000001) and draw a green square. - Send GP0(E6) with bit 1 set (
0xe6000002) and draw an overlapping red square. - Read the framebuffer with
StoreImageandDrawSync.
Expected: the overlap remains green because its destination pixels are protected.
Actual: the overlap turns red. At (110, 110), the unmodified backend returns 0x801f; our mask-support prototype returns 0x83e0.
These are actual 320×240 VRAM readbacks, enlarged 2× with nearest-neighbour scaling. The comparison uses our local mask-support changes, without display, subpixel or perspective changes; it is not a hardware reference capture.
Building the standalone example
Save the attached file as repro.c, and place this CMakeLists.txt beside it:
cmake_minimum_required(VERSION 3.21)
project(drawprim_repro C CXX)
set(CMAKE_C_STANDARD 11)
add_compile_options(-pthread)
add_link_options(-pthread)
set(SDL_PTHREADS ON CACHE BOOL "" FORCE)
add_subdirectory("${PSYZ_ROOT}/psyz" psyz EXCLUDE_FROM_ALL)
add_executable(repro repro.c)
target_link_libraries(repro PRIVATE psyz)
target_link_options(repro PRIVATE -sASSERTIONS=1 -sPTHREAD_POOL_SIZE=2)
psyz_web_configure_target(repro OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/site")
Use a PsyZ checkout at the revision above, with its SDL submodule initialized:
emcmake cmake -S . -B build -DPSYZ_ROOT=/path/to/psyz -DCMAKE_BUILD_TYPE=Release
cmake --build build -j8
Serve build/site locally with Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp, as required by Emscripten pthreads. Open index.html. The example appends a canvas containing the VRAM readback below the normal page content; scroll down if necessary. It also logs GPU readback ready.
Compatibility considerations
Destination mask protection is separate from RGB blending and texture STP. A general implementation should also account for uploads and VRAM copies; framebuffer fill follows different rules. See GP0(E6) in PSX-SPX.
This minimal example demonstrates drawing only. Transfers, textured primitives, transparency, blending and multiple primitives in a batch need separate coverage.
- Dominant language
- C
- Stars
- 107
- Forks
- 26
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Xeeynamo/psyz
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
Similar issues
-
documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JulianKemmerer/PipelineC#409 ·
-
Linux build fails without libspeechd-dev, which INSTALL.md doesn't list and CMake reports as foundOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
GXF: heap buffer overflow in parse_ad_cdp() — unbounded cc_count in CDP cc data sectionPossibly taken @pranayr710 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CCExtractor/ccextractor#2498 ·
Maintainers usually reply within 1 day