Skip to content

Round interpolated texture IDs before texture and resolution lookup - #7378

Open
AyyoubAha wants to merge 1 commit into
phaserjs:masterfrom
AyyoubAha:fix/round-texture-id
Open

AyyoubAha wants to merge 1 commit into
phaserjs:masterfrom
AyyoubAha:fix/round-texture-id

Conversation

@AyyoubAha

Copy link
Copy Markdown

This PR

  • Fixes a bug

Round the interpolated texture ID before selecting a texture or its resolution. An ID slightly above or below an integer previously fell through the exact-equality checks, returning a transparent sample or a zero resolution. Both helpers now use floor(outTexDatum + 0.5). Single-texture batches and the fallback for out-of-range integer IDs are unchanged.

Based on DainDwarf's report and suggested rounding approach in #7372. Related to #7372; the original SwiftShader rotation reproduction still needs confirmation with this patch.

Validation:

  • Added tests/renderer/webgl/texture-id-regression.html, a manual WebGL 1 test that compiles the actual generated GLSL helpers and reads back pixels. It supplies exact IDs, positive/negative perturbations, and out-of-range integer controls; tests texture sampling and resolution lookup, mediump/highp, and 1, 2, and the device maximum number of texture units. Serve the repository root over HTTP, open the file, and click Run shader checks.
  • On Intel Graphics / ANGLE D3D11, Chromium 152, 16 texture units: before the change, 144 checks failed and 108 passed; after the change, all 252 passed. The non-integer inputs are deliberate fault injection, not a claim that this GPU reproduces the reported interpolation drift.
  • The original 120-text example renders intact at 1° and 45° on this Intel GPU, with both the released 4.2.1 build and the patched build. No SwiftShader, mobile GPU, or performance benchmark was run.
  • npm test -- tests/renderer/webgl --maxWorkers=2: 69 files / 1,544 tests passed. An existing circular-dependency warning was emitted.
  • npm run build: webpack compiled successfully. The optional copy step reports that the sibling examples repository is absent.
  • Targeted ESLint 8.57.1 with the repository's existing configuration and --no-ignore passed for both changed generated JavaScript files. The repository-wide npm run lint fails to load .eslintrc.json under its installed ESLint 10 (ERR_IMPORT_ATTRIBUTE_MISSING); this PR does not alter dependencies or lint configuration.
  • git diff --check passed.

The GLSL sources and their generated JavaScript modules are included; README, changelog, and distribution bundles are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant