pub struct Frontend { /* private fields */ }
Expand description
The Frontend
is the central structure of the GLSL frontend.
To instantiate a new Frontend
the Default
trait is used, so a
call to the associated function Frontend::default
will
return a new Frontend
instance.
To parse a shader simply call the parse
method with a
Options
struct and a &str
holding the glsl code.
The Frontend
also provides the metadata
to get some
further information about the previously parsed shader, like version and
extensions used (see the documentation for
ShaderMetadata
to see all the returned information)
Example usage
use naga::ShaderStage;
use naga::front::glsl::{Frontend, Options};
let glsl = r#"
#version 450 core
void main() {}
"#;
let mut frontend = Frontend::default();
let options = Options::from(ShaderStage::Vertex);
frontend.parse(&options, glsl);
Reusability
If there’s a need to parse more than one shader reusing the same Frontend
instance may be beneficial since internal allocations will be reused.
Calling the parse
method multiple times will reset the
Frontend
so no extra care is needed when reusing.
Implementations§
source§impl Frontend
impl Frontend
sourcepub const fn metadata(&self) -> &ShaderMetadata
pub const fn metadata(&self) -> &ShaderMetadata
Returns additional information about the parsed shader which might not
be stored in the Module
, see the documentation for
ShaderMetadata
for more information about the returned data.
Notes
Following an unsuccessful parsing the state of the returned information is undefined, it might contain only partial information about the current shader, the previous shader or both.