Beginner Question: what does Naga do? #8058
-
I stumbled upon this recent post where it says:
I got curious about the conceptual part of this. Is it saying that Naga does something like this diagram below?
Were we simply choose a source language, and it will translate to any supported by the platform. And I think then one has an overall system like:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This seems mostly right, minus a couple of details that I think are important for this high-level overview. Your diagram suggests that Naga can ingest and emit all shader languages equally. But if you examine https://github.com/gfx-rs/wgpu/tree/1bf1671ed877a6a9ccf5f1a349ec167cd28af3d7/naga#supported-end-points, you'll see that only some languages are supported frontends, with a superset of them supported as a backend. In the language of your diagram, that means not all arrows between WGSL is the most common for the web world, but we have a fair number of WGPU users using other shader languages. Yet another interesting way they provide shaders for WGPU is via "passthrough" shaders, where (1) the user supplies a shader in the language of the platform's graphics runtime and which (2) the user promises (on penalty of undefined behavior) is compatible with their subsequent usage of the shader module. |
Beta Was this translation helpful? Give feedback.
This seems mostly right, minus a couple of details that I think are important for this high-level overview.
Your diagram suggests that Naga can ingest and emit all shader languages equally. But if you examine https://github.com/gfx-rs/wgpu/tree/1bf1671ed877a6a9ccf5f1a349ec167cd28af3d7/naga#supported-end-points, you'll see that only some languages are supported frontends, with a superset of them supported as a backend. In the language of your diagram, that means not all arrows between
Common IR
and the other languages are actually bidirectional links.WGSL is the most common for the web world, but we have a fair number of WGPU users using other shader languages. Yet another interesting way…