Skip to content

Fix #8756: Allow computed array indexing on non-storage vectors#8768

Open
SOUMITRO-SAHA wants to merge 1 commit intoprocessing:dev-2.0from
SOUMITRO-SAHA:fix-8756-array-indexing
Open

Fix #8756: Allow computed array indexing on non-storage vectors#8768
SOUMITRO-SAHA wants to merge 1 commit intoprocessing:dev-2.0from
SOUMITRO-SAHA:fix-8756-array-indexing

Conversation

@SOUMITRO-SAHA
Copy link
Copy Markdown

Resolves #8756

Changes:

This PR fixes the bug where get() could only be used on storage buffers in p5.strands, preventing array indexing (arr[0]) on non-storage vectors like those returned from helper functions.

Root Cause:

The transpiler converted ALL computed member access (arr[0]) to .get() calls, but the get() method in strands_node.js had a guard that only allowed it for storage buffers, throwing "get() can only be used on storage buffers" for non-storage vectors.

  • src/strands/strands_node.js
  • src/strands/strands_transpiler.js
  • src/webgl/strands_glslBackend.js (Added ARRAY_ACCESS handler, missing from GLSL backend - flagged by @Nixxx19 ).
  • test/unit/webgpu/p5.Shader.js

Screenshots of the change:

PR Checklist

- Enable array indexing for storage and vector buffers
- Added validation for array literals in shaders (2-4 elements only)
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