Skip to content

PMREMGenerator: Fix compute target disposal and mip-size queries. - #4

Merged
DennisSmolek merged 2 commits into
DennisSmolek:pmrem-computefrom
bhouston:fix-pmrem-compute-lifecycle
Oct 22, 2026
Merged

DennisSmolek merged 2 commits into
DennisSmolek:pmrem-computefrom
bhouston:fix-pmrem-compute-lifecycle

Conversation

@bhouston

Copy link
Copy Markdown

Compute-generated PMREM targets bypass render-target initialization, so disposing a returned target leaves its GPU texture allocated. Initialize the target before dispatch so allocation and disposal follow the existing render-target lifecycle.

Storage-capable PMREMs also make textureSize( cubeTexture( pmrem.texture ), 2 ) return the base size. Pass the texture node to the size generator so WGSL distinguishes a sampled binding from a storage binding; a 256 PMREM now reports 64 at mip 2.

Based directly on mrdoob#35130 at b4dcfbacc5f4463f4864ec719ded3222af80f81d. The two fix commits are 710161f0d3d and 9689c8a7168. Targets DennisSmolek/three.js pmrem-compute, the source branch of that PR, and contains only the two fixes.

Validation:

  • Core lint passed.
  • Source QUnit suite: 1,970 passed, 0 failed, 1 TODO; addons: 116 passed, 0 failed. Used a local Puppeteer runner with D3D11 and no software-renderer configuration.
  • NVIDIA RTX 3060 Ti, hardware WebGPU adapter (NVIDIA Ampere, non-fallback): reproduced both failures before fixes and verified both fixes afterward. WebGL 2 fallback passed the same checks, with and without initial blur.
  • Compared compute and fragment outputs on all six faces at every mip for 256 and 512 directional-gradient captures, including sigma 0.04 at 256. Maximum absolute component difference was 0.00048828125; no non-finite texels or GPU validation errors.
  • No typecheck script is defined in this JavaScript repository.

@bhouston
bhouston marked this pull request as ready for review October 21, 2026 17:17
@DennisSmolek
DennisSmolek merged commit a6fefb5 into DennisSmolek:pmrem-compute Oct 22, 2026
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.

2 participants