webgpu | WebGPU Samples & RnD | Learning library
kandi X-RAY | webgpu Summary
kandi X-RAY | webgpu Summary
These study samples run in Chrome Canary() behind the flag --enable-unsafe-webgpu.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of webgpu
webgpu Key Features
webgpu Examples and Code Snippets
Community Discussions
Trending Discussions on webgpu
QUESTION
I have some trouble understanding the return type of an async function. Here I would like to have a promise that returns only the type Promise< Glslang > and not Promise. Here is the code:
...ANSWER
Answered 2021-Mar-06 at 20:29First of all, you can simplify the code to always import the module. As I see you use Webpack to bundle the app, it will take care of importing and caching so you can delete ~75% of the logic - basically keep only this part:
QUESTION
I'm drawing a lot of rectangles, thus I'm using the WebGL2RenderingContext.drawArraysInstanced() for it. I'm also using a lot of buffers to control shaders per instance (containing such data as position, colors, state, etc). I want now to affect the order in which my instances are being drawn (for example, to bring to the front the instance clicked by the user) and I'm looking for something like INSTANCE_ARRAY_BUFFER
, something similar to ELEMENT_ARRAY_BUFFER
, but for instances instead of vertices. Something that would allow me to tell "draw instances in the following order: 3,1,2,0,...". Is there any API which would allow me to control the order of the drawn instances without modifying the order of elements of all the data buffers?
Based on my research so far I suspect the answer will be "no", but maybe I missed some hidden WebGL API. Moreover, as a bonus question – was something like that introduced maybe in recent OpenGL versions or the WebGPU?
...ANSWER
Answered 2020-Dec-20 at 01:09Your only actual question is
Is there any API which would allow me to control the order of the drawn instances without modifying the order of elements of all the data buffers?
Yes, put your data in textures, pass in an array of ids in a buffer
Some examples, not just quads here and here
I have no idea how much faster or slower this would be. My intuition is it would be slower but I haven't tested.
It would be strange to me that the only thing you're optimizing for is draw order and that you don't need to position all the quads and change their UVs. If you do need to position all the quads and change their UVs then just write them in the correct order in the first place.
Other comments based on the comments
Are instances the best way to draw lots of quads?
I think the verdict here is not so clear. 10 years ago my experience was instancing was 30% slower than just creating the data for all the quads. My tests indicate that's no longer true, at least not on any GPU I own and not in WebGL.
Is writing 4 or 6 vertices to buffers per quad a good solution?
It's common to just write all the data to buffers every frame for UIs. See pretty much every ImGUI library
QUESTION
I want to write applications in JavaScript that require a large amount of numerical computation. However, I'm very confused about the state of efficient linear-algebra-like computation in client-side JavaScript. There seems to be many approaches, but no clear indication of their readiness. Most of them seem to have restrictions of the size of vectors and matrices allowed for computation.
WebGLObviously allows for vector and matrix computations on the GPU, but I'm not clear on the limitations. Attempted wrappers around this library seem to limit size of matrices and vectors. Is this a practical limitation (browsers don't support anything else) or just a development limitation (someone need to write the code)?
WebCLWebCL is a proposed browser-level implementation of OpenCL, but appears to be stuck in development.
WebGPUApple has recently put forth an alternative to WebCL called WebGPU. So far, there is a prototype and demos, but it's not clear to me if this will see wide adoption.
SIMDMozilla has put out an API for SIMD operations, but it only has experimental support.
Are vectorized computations on the browser-side supported by JavaScript?
Notes:
My question is not "What's a good library for numerical computation in JavaScript" but "Are vectorized operations possible in JavaScript?" An acceptable answer would link to a demo of vectorized computation working in a non-experimental browser.
I may be getting SIMD, vectorization and GPU computation confused. I thought it was okay to use them synonymously in this context, given they all allow for efficient computations involving high-dimensional vectors using hardware acceleration.
ANSWER
Answered 2017-Apr-16 at 04:50The state of SIMD in JavaScript is partly a practical and a developmental problem.
PracticalWeb browsers are kind of like virtual machines. This means they need a ton of drivers for hardware. The drivers for exposing the few shaders and whatnot for WebGL are significantly different than the arbitrary kernel execution required for SIMD operations.
DevelopmentalHypothetically, one could just wrap WebGL to make it a general purpose GPU computer and someone has attempted to with gpgpu.js. However, it's got finicky support and is probably slower than just directly piping a kernel to the GPU.
ConclusionThe web isn't ready for SIMD yet. There are quite a few big companies working to make it ready. Until then, you're going to have to rely on WebWorkers for large batches of numerical computations.
QUESTION
Current release on Github of Tensorflow.js includes a WEBGPU backend, but when running tf.getBackend()
I get webgl
even with Chrome Canary with WEBGPU enabled. Also running tf.backend()
doesn't seem to indicate that WEBGPU is there.
ANSWER
Answered 2019-Sep-26 at 11:06Which tf
package are you importing? The WebGPU backend is not bundled with tfjs
by default - you need to import it specifically, like this:
QUESTION
I'm using a simple model of @tensorflow/tfjs
which simply shows accuracy. The same code when ran in code sandbox doesn't give any error while running it in visual studio code an invariant type error occur. My code is attached below. Also guide about input shape and unit term used in code and how to implement this code in react native.
ANSWER
Answered 2019-Nov-08 at 12:41You need to import the @tensorflow/tfjs-react-native
package. Additionnaly, tf.ready()
should be be used if the backend is asynchronous
Here is an example of how your react app should look like
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install webgpu
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page