feat: isBeingTranspiled + getTargetShaderLanguage#2518
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:
📋 All resultsClick to reveal the results table (356 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.91, 2.01, 4.62, 7.04, 7.34, 10.35, 21.74, 25.27]
line [0.96, 1.95, 4.61, 6.34, 7.56, 11.21, 21.98, 23.43]
line [0.87, 1.86, 4.18, 6.11, 7.83, 11.98, 20.38, 23.21]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.31, 0.56, 0.76, 0.85, 1.13, 1.22, 1.47, 1.56]
line [0.35, 0.54, 0.66, 0.87, 1.15, 1.27, 1.50, 1.65]
line [0.34, 0.55, 0.73, 0.85, 1.14, 1.24, 1.46, 1.58]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.96, 2.15, 4.96, 6.93, 13.54, 26.62, 56.21, 113.87]
line [1.00, 2.22, 4.84, 7.10, 13.08, 25.82, 55.59, 113.15]
line [0.84, 2.12, 4.32, 6.40, 12.62, 25.48, 57.29, 113.80]
|
|
I'll just note down the mechanism we talked about today: isBeingTranspiled
getTargetShaderLanguage
The function is supposed to return The only question is, what od we want |
Also, I think Your version:
My version:
|
|
@cieplypolar You're totally right, I updated the comment to match your version. |
|
Also, if we ever want to change the SIMULATE env behavior, it will be straightforward; simple check if By the way, we should consider returning |
WIll there ever be |
Honestly, I don't know. Now, |
aleksanderkatan
left a comment
There was a problem hiding this comment.
Good job! 🐑ℹ️✝︎
The target branch is merged already, you can change the target to main.
| * return isBeingTranspiled() ? 1 : 0; | ||
| * }; | ||
| * | ||
| * f() // returns 0, but resolved WGSL looks like this: |
There was a problem hiding this comment.
nit
| * f() // returns 0, but resolved WGSL looks like this: | |
| * f(); // returns 0, but resolved WGSL looks like this: |
| * } | ||
| * | ||
| * @note | ||
| * Inside `lazy`, it always returns `wgsl`. |
There was a problem hiding this comment.
Until now I didn't know lazy is not callable in JS. What no docs does to a man. Can we mention it here?
| * Inside `lazy`, it always returns `wgsl`. | |
| * Inside `lazy`, since it is only accessible during resolution, it always returns `wgsl`. |
| import { it } from 'typegpu-testing-utility'; | ||
| import { expect, describe } from 'vitest'; | ||
|
|
||
| import tgpu, { d, std } from '../../src/index.js'; |
There was a problem hiding this comment.
| import tgpu, { d, std } from '../../src/index.js'; | |
| import tgpu, { d, std } from 'typegpu'; |
| impl.toString = () => 'isBeingTranspiled'; | ||
| impl[$gpuCallable] = { | ||
| call(_ctx, _args) { | ||
| return snip(true, bool, 'constant'); |
There was a problem hiding this comment.
Could we use coerceToSnippet here? This will allow future snippet properties to be properly applied, like side effects.
| return snip(true, bool, 'constant'); | |
| return coerceToSnippet(true); |
falsewgslfalseundefinedfalseundefinedtruewgslfalseundefined