Repository navigation
Conversation
Reading an RGBA16F or RGBA32F attachment through readFrameBuffer requests RGBA/UNSIGNED_BYTE, which GLES rejects with GL_INVALID_OPERATION. Native ANGLE reproduces error 0x502 while the normalized RGBA8 control succeeds. Read floating-point GLES attachments with RGBA/FLOAT, then clamp and round into the requested RGBA8/BGRA8 byte layout. Use the selected read attachment for mixed render targets and honor the main framebuffer override. Preserve the caller's buffer range and release temporary float storage in finally. Restrict conversion to the explicit supported byte layouts. Seven regression cases fail before the fix; all ten pass afterward. Native GLES and desktop GL each pass 22,570 checks for float targets, channel order, buffer guards, explicit float output, main overrides and MRT selection. The original GLES implementation fails the HDR read while desktop GL passes. Full core suite passes 1,181 tests with one skipped and no failures. Both core Checkstyle tasks and LWJGL3 compilation pass. Native validation is from Linux/NVIDIA; other platforms remain for CI.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
jaime-jmebot
left a comment
There was a problem hiding this comment.
Hi, thanks for putting together a focused fix and a thorough regression suite for GLES HDR readback. I reviewed the renderer changes and the new tests. The implementation identifies the effective read attachment before deciding whether the GLES float-read conversion applies, which is important for both MRT read-buffer selection and the main framebuffer path. Restricting the conversion to RGBA8/BGRA8 requests also avoids silently changing the semantics of other output formats.
The conversion itself keeps the caller’s buffer range intact, clamps and rounds normalized values as described, handles BGRA channel order, and releases its temporary buffer in a finally block. The tests exercise those details along with floating-point versus byte reads and attachment selection, providing good coverage for the edge cases this change introduces.
I don’t see any blocking issues. The reported native GLES and desktop validation, together with the core suite and compile/style checks, are reassuring. Looks good to me—thanks for tackling this.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 642b0c07c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A texture target retains its original RenderBuffer format after Texture.setImage replaces the image. Choose the readback type from the current image so normalized-to-float and float-to-normalized replacements use legal GLES reads. Renderbuffer targets continue using their stored format. Both new regressions fail before the fix and pass afterward; native GLES reproduces error 0x502 before the fix and passes both replacement directions afterward. The full core suite and style checks pass.
|
I'm not fully convinced by the approach of allocating a temporary buffer on every read. Could we reuse a scratch buffer instead, growing it in chunks as needed to accommodate the largest read and retaining that capacity for subsequent reads? |
On ANGLE/GLES,
renderer.readFrameBuffer(hdrFramebuffer, buffer)can fail when the color attachment isRGBA16ForRGBA32F. The current code requestsRGBA/UNSIGNED_BYTE; GLES rejects that read from a floating-point surface withGL_INVALID_OPERATION, leaving the caller without the image. I reproduced this on native ANGLE: an RGBA8 control succeeds, then reading the RGBA16F target reports GL error0x502.For RGBA8/BGRA8 byte output from floating-point GLES attachments, read
RGBA/FLOATand convert the pixels on the CPU. This is a supported read format in EXT_color_buffer_float. Components are clamped to [0, 1] and rounded to bytes:(0.25, 0.5, 0.75, 1)becomes(64, 128, 191, 255). BGRA output swaps red and blue. There is no exposure or gamma adjustment.The conversion uses the actual read attachment, including mixed render targets and the main framebuffer override. Texture attachments use their current image format after image replacement; renderbuffers use their stored format. It preserves the caller's buffer position/limit. It uses a temporary RGBA float buffer, released after conversion. The format check is explicit so other requested channel layouts cannot silently receive RGBA bytes.
Validation: seven regression cases fail on the original implementation; all twelve pass with the fix. Native GLES and desktop GL each pass 30,776 checks, including both texture-format replacement directions, covering 16F/32F targets, RGBA/BGRA output, buffer sentinels, explicit float output, the main override and mixed read attachments. On the original implementation the native GLES HDR read fails while the desktop control passes.
Full core suite: 1,183 passed, one skipped, zero failures. Core Checkstyle tasks and LWJGL3 compilation pass; existing style warnings remain. Native validation is from this Linux/NVIDIA machine.