Skip to content

Extract U32 texture data upload logic and restore pixelStorei parameters#367

Merged
dmarcos merged 1 commit into
sparkjsdev:mainfrom
mrxz:fix-render-state
Jun 16, 2026
Merged

Extract U32 texture data upload logic and restore pixelStorei parameters#367
dmarcos merged 1 commit into
sparkjsdev:mainfrom
mrxz:fix-render-state

Conversation

@mrxz

@mrxz mrxz commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Both SplatPager and SparkRenderer manually uploaded texture data using the WebGLRenderingContext directly. This stems from a limitation in Three.js preventing 2D regions from easily being updated, see mrdoob/three.js#32254. This PR extracts the logic into a utility function to avoid duplication.

Additionally the pixelStorei parameters set as part of this procedure weren't restored to the values they were before the upload. This becomes a problem with Three.js >= r184 as it now caches the parameter values in its WebGLState, see #366. This PR ensures they are now properly restored. Once Spark requires Three.js 184 or later it can switch to renderer.state.pixelStorei instead.

Fixes #366

@mrxz mrxz force-pushed the fix-render-state branch from c327292 to 9c6804f Compare June 16, 2026 07:17
@dmarcos dmarcos merged commit 155af7b into sparkjsdev:main Jun 16, 2026
2 checks passed
@dmarcos

dmarcos commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

we should probably bump to r184 sooner than later

@mrxz

mrxz commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

we should probably bump to r184 sooner than later

On one hand keeping up with the latest release is nice to ensure it keeps working, but we should stick to the oldest version we intend to support. Especially considering not all frameworks that use Three.js update at the same cadence as Three itself. Unless there is a clear reason for it, Spark shouldn't force users to update Three IMHO.

It's unfortunate when things break/regress like it did here, but that's likely going to be infrequent, whereas building against/relying on new additions/features is a bigger compat risk.

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.

SparkRenderer leaks WebGL UNPACK_FLIP_Y pixel-store state into the host Three.js renderer → flipped texture re-uploads

2 participants