Struct naga::front::glsl::Frontend

source ·
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

source

pub fn parse( &mut self, options: &Options, source: &str ) -> Result<Module, ParseErrors>

Parses a shader either outputting a shader Module or a list of Errors.

Multiple calls using the same Frontend and different shaders are supported.

source

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.

Trait Implementations§

source§

impl Debug for Frontend

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Frontend

source§

fn default() -> Frontend

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.