Add logging for experimental features - #9109
Conversation
Vaivaswat2244
left a comment
There was a problem hiding this comment.
Hi @davepagurek , I had a few thoughts on this.
| fn.buildMaterialShader = function (cb, scope) { | ||
| return this.baseMaterialShader().modify(cb, scope); | ||
| }; | ||
| p5.registerDecorator('p5.prototype.buildMaterialShader', markExperimental('p5.strands', p5)); |
There was a problem hiding this comment.
buildNormalShader also has beta tag, that should also be here?
There was a problem hiding this comment.
yep, good catch!
| } | ||
| return this._renderer.createStorage(dataOrCount); | ||
| }; | ||
| p5.registerDecorator('p5.prototype.createStorage', markExperimental('webgpu', p5)); |
There was a problem hiding this comment.
baseComputeShader() (L2379) and compute() (L2725) are @beta and live on Renderer3D, so they are reachable in WEBGL mode where the RendererWebGPU constructor warning never fires...
There was a problem hiding this comment.
Compute shaders only actually work in WebGPU mode and will throw an error in WebGL mode so I figured that path was less critical to flag.
ksen0
left a comment
There was a problem hiding this comment.
Thank you for these very helpful documentation updates! I've added some small but major notes re: error message. The important thing with experimental features is being transparent that API may not be stable.
| */ | ||
|
|
||
| const experimentalMessages = { | ||
| webgpu: 'WEBGPU mode is experimental. Your feedback will help direct its development!', |
There was a problem hiding this comment.
"WEBGPU mode is experimental, and API related to it (functions and constraints) may change in future versions. You can get involved by giving feedback to help direct its development!"
There was a problem hiding this comment.
What do constraints refer to in this context?
There was a problem hiding this comment.
can be rephrased I am just trying to be explicit that API may change (and that means functions or constants may change) in the future
|
|
||
| const experimentalMessages = { | ||
| webgpu: 'WEBGPU mode is experimental. Your feedback will help direct its development!', | ||
| 'p5.strands': 'p5.strands shaders are experimental. Your feedback will help shape its future!', |
There was a problem hiding this comment.
Liekwise "p5.strands API (build shader functions, the hooks in them, and related constants) may change in future versions. You can get involved by giving feedback to help shape its future!"
| fn.buildStrokeShader = function (cb, scope) { | ||
| return this.baseStrokeShader().modify(cb, scope); | ||
| }; | ||
| p5.registerDecorator('p5.prototype.buildStrokeShader', markExperimental('p5.strands', p5)); |
There was a problem hiding this comment.
There is a trick that you may or may not want to use (I only just thought of it so it may not work) which is that the pattern matcher (first argument) can be a function and if it returns true the decorator will apply and false it won't, which means that if say you add some flags onto the functions itself to mark it as experimental:
p5.prototype.buildStrokeShader.experimental = trueyou can just call registerDecorator once and return true whenever the flag is present on a function. That way you don't have to call registerDecorator every time a new experimental API is added.
Resolves #9108
Changes:
Live example: https://editor.p5js.org/davepagurek/sketches/p1c5jvRAf
PR Checklist
npm run lintpasses