Repository navigation
Correct RGBA8 texture readback coordinates and row order - #1892
bkaradzic-microsoft merged 6 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address the rectangle-validation issue and update both test gates to account for disabled native image loading.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Corrects RGBA8 texture readback coordinates, row ordering, and rectangle validation across backends.
Changes:
- Converts crop coordinates and normalizes row order.
- Adds mip, crop, inversion, offset, and bounds regressions.
- Regenerates the compiled JavaScript test bundle.
| File | Summary | Review status |
|---|---|---|
Plugins/NativeEngine/Source/NativeEngine.cpp |
Implements readback coordinate and row-order fixes. | Changes required: validate original rectangle values before narrowing. |
Apps/UnitTests/JavaScript/src/tests.javaScript.all.ts |
Adds readback regression coverage. | Changes required: gate the test on native image loading. |
Apps/UnitTests/JavaScript/dist/tests.javaScript.all.js |
Updates the compiled test bundle. | Changes required: regenerate with the corrected test gate. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
Open (2)
Resolved since last review (1)
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 3
Open (4)
This test doesn’t appear to depend on native image loading (it only usesRawTexture+ GPU… · New Same gating concern as the previous test: this case exercises mip readback and validation paths… · Newstd::swap_rangesswaps byte-by-byte here, which is typically slower than swapping whole rows via… · New The new validation errors are correct but not very actionable because they don’t identify which… · New
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 3
Open (3)
Resolved since last review (4)
std::swap_rangesswaps byte-by-byte here, which is typically slower than swapping whole rows via… Same gating concern as the previous test: this case exercises mip readback and validation paths… This test doesn’t appear to depend on native image loading (it only usesRawTexture+ GPU… The new validation errors are correct but not very actionable because they don’t identify which…
Extract the RGBA8 readback fixes without changing the published JavaScript buffer contract. Reject rectangles outside their mip before converting Y. Add asymmetric full-image, edge, interior, mip, and buffer-offset controls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Validate mip and rectangle inputs before integer conversion, including 16-bit and 32-bit wraps, fractions, negative and non-finite values. Cover rejected calls with unchanged destination sentinels and gate both pixel regressions on native image-loading support. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Report the finite integer requirements and numeric bounds before narrowing readback coordinates, with exact-message coverage for invalid inputs. Swap image rows in place instead of allocating a temporary row buffer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Restore optimized whole-row copies after measuring GCC's byte-wise swap_ranges regression. Keep scratch storage thread-local so repeated readbacks reuse its capacity without cross-thread sharing. Name the invalid rectangle parameter, verify exact errors, and add a wide odd-height readback regression. Document why RawTexture fixtures require the native image-loading build option. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
4c88350 to
dee3cb1
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d35d0a8b-b073-4f2a-bbd3-a0b1d3584305
Review-Group: E2 Source: PR BabylonJS#1892 Squashed final review changes, including regressions and review follow-ups. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Reject invalid mip levels, rectangles, and face/layer indices before calculating requested storage sizes or allocating a null destination. Cover a 65535-by-65535 invalid crop with a null output buffer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e6c3c123-c355-4790-a3d4-94337ed6e052
Update the generated JavaScript test bundle to match the source regressions for stricter readTexture input and buffer validation. Keep the executable test artifact separate from the native readback implementation. Review-Group: E2 Source: PR BabylonJS#1892 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae Split-From: ac3f4081ed11b26f509693c60f97b296790451e2 Split-Part: support
Update the generated JavaScript test bundle to match the source regressions for stricter readTexture input and buffer validation. Keep the executable test artifact separate from the native readback implementation. Review-Group: E2 Source: PR BabylonJS#1892 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae Split-From: ac3f4081ed11b26f509693c60f97b296790451e2 Split-Part: support
Update the generated JavaScript test bundle to match the source regressions for stricter readTexture input and buffer validation. Keep the executable test artifact separate from the native readback implementation. Review-Group: E2 Source: PR BabylonJS#1892 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae Split-From: ac3f4081ed11b26f509693c60f97b296790451e2 Split-Part: support
Update the generated JavaScript test bundle to match the source regressions for stricter readTexture input and buffer validation. Keep the executable test artifact separate from the native readback implementation. Review-Group: E2 Source: PR BabylonJS#1892 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae Split-From: ac3f4081ed11b26f509693c60f97b296790451e2 Split-Part: support
Update the generated JavaScript test bundle to match the source regressions for stricter readTexture input and buffer validation. Keep the executable test artifact separate from the native readback implementation. Review-Group: E2 Source: PR BabylonJS#1892 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae Split-From: ac3f4081ed11b26f509693c60f97b296790451e2 Split-Part: support
Reject invalid buffer offsets, lengths, face/layer indices, and uninitialized textures before readback work begins. Check full source and destination storage sizes before bgfx's uint32 conversion. Link bimg independently of image decoding so these checks also build with image loading disabled. Review-Group: E2 Source: PR BabylonJS#1892 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae Split-From: ac3f4081ed11b26f509693c60f97b296790451e2 Split-Part: code



Summary
Independence
Based on upstream
master. Uses published Babylon.js 9.21.2 and unchanged native dependency pins. No protocol changes, float readback API, fixture/reference/tolerance changes, or dependency on the other open Native PRs.Extracts only the RGBA8 readback portion of the shotgun fixes.
Validation
Latest allocation-order follow-up, Windows x64 / D3D11 / Chakra / RelWithDebInfo:
JavaScript.All: 118 passing, including all three readback cases and the new huge null-destination rejection.Verified runtime evidence from the prior published-head CI run, before this allocation-order follow-up:
Fresh cross-platform CI for the allocation-order follow-up is pending; the OpenGL/Vulkan results above are explicitly from the previous head.