feat: Add Indirect buffer usage and support .dispatchWorkgroupsIndirect API#2105
feat: Add Indirect buffer usage and support .dispatchWorkgroupsIndirect API#2105
Indirect buffer usage and support .dispatchWorkgroupsIndirect API#2105Conversation
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:
Dynamic test results:
📋 All resultsClick to reveal the results table (335 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
|
pkg.pr.new packages benchmark commit |
| const meta = new Map<string, StructFieldMeta>(); | ||
|
|
||
| let runStart = 0; | ||
| for (let i = 0; i < propNames.length; i++) { | ||
| const name = propNames[i]; | ||
| if (!name) { | ||
| continue; | ||
| } | ||
| const info = offsets[name] as PropOffsetInfo; | ||
| const padding = info.padding ?? 0; | ||
|
|
||
| const isRunEnd = i === propNames.length - 1 || padding > 0; | ||
| if (!isRunEnd) { | ||
| continue; | ||
| } | ||
|
|
||
| const runEnd = info.offset + info.size; | ||
| for (let j = runStart; j <= i; j++) { | ||
| const runName = propNames[j]; | ||
| if (!runName) { | ||
| continue; | ||
| } | ||
| const runInfo = offsets[runName] as PropOffsetInfo; | ||
| meta.set(runName, { offset: runInfo.offset, runEnd }); | ||
| } | ||
| runStart = i + 1; | ||
| } |
There was a problem hiding this comment.
I'm not quite sure we need this. We could just walk from accessed prop until we run out of requested memory or hit padding. This would make the API less flexible though (and worst case actually calculate more). This solution seemed nice for detecting contiguous memory and I thought maybe we could use it in the future (compiled partial write). I can simplify it if it's deemed too complex/expensive.
There was a problem hiding this comment.
Great use of accessors. However, the calculation of the longest contiguous block starting at given offset isn't correct. See #2159
| let runStart = 0; | ||
| for (let i = 0; i < propNames.length; i++) { | ||
| const name = propNames[i]; | ||
| if (!name) { |
There was a problem hiding this comment.
Can user define a struct with the empty string as a key?
There was a problem hiding this comment.
isValidProp does not yet filter this, but it should
| const meta = new Map<string, StructFieldMeta>(); | ||
|
|
||
| let runStart = 0; | ||
| for (let i = 0; i < propNames.length; i++) { | ||
| const name = propNames[i]; | ||
| if (!name) { | ||
| continue; | ||
| } | ||
| const info = offsets[name] as PropOffsetInfo; | ||
| const padding = info.padding ?? 0; | ||
|
|
||
| const isRunEnd = i === propNames.length - 1 || padding > 0; | ||
| if (!isRunEnd) { | ||
| continue; | ||
| } | ||
|
|
||
| const runEnd = info.offset + info.size; | ||
| for (let j = runStart; j <= i; j++) { | ||
| const runName = propNames[j]; | ||
| if (!runName) { | ||
| continue; | ||
| } | ||
| const runInfo = offsets[runName] as PropOffsetInfo; | ||
| meta.set(runName, { offset: runInfo.offset, runEnd }); | ||
| } | ||
| runStart = i + 1; | ||
| } |
| ); | ||
|
|
||
| expect(info.offset).toBe(128); | ||
| expect(info.contiguous).toBe(16); |
There was a problem hiding this comment.
| expect(info.contiguous).toBe(16); | |
| expect(info.contiguous).toBe(28); |
Look at #2159
Update: I guess TODO solved - we now expose the API to the user
TODO: Solve the caching problem (should we cache the accessor callbacks? Proxy creation per frame will have significant overhead)