[][src]Struct shaderc::Compiler

pub struct Compiler { /* fields omitted */ }

An opaque object managing all compiler states.

Creating an Compiler object has substantial resource costs; so it is recommended to keep one object around for all tasks.

Methods

impl Compiler[src]

pub fn new() -> Option<Compiler>[src]

Returns an compiler object that can be used to compile SPIR-V modules.

A return of None indicates that there was an error initializing the underlying compiler.

pub fn compile_into_spirv(
    &mut self,
    source_text: &str,
    shader_kind: ShaderKind,
    input_file_name: &str,
    entry_point_name: &str,
    additional_options: Option<&CompileOptions>
) -> Result<CompilationArtifact>
[src]

Compiles the given source string source_text to a SPIR-V binary module according to the given additional_options.

The source string will be compiled into a SPIR-V binary module contained in a CompilationArtifact object if no error happens.

The source string is treated as the given shader kind shader_kind. If InferFromSource is given, the compiler will try to deduce the shader kind from the source string via #pragma directives and a failure in deducing will generate an error. If the shader kind is set to one of the default shader kinds, the compiler will fall back to the default shader kind in case it failed to deduce the shader kind from the source string.

input_file_name is a string used as a tag to identify the source string in cases like emitting error messages. It doesn't have to be a canonical "file name".

entry_point_name is a string defines the name of the entry point to associate with the source string.

pub fn compile_into_spirv_assembly(
    &mut self,
    source_text: &str,
    shader_kind: ShaderKind,
    input_file_name: &str,
    entry_point_name: &str,
    additional_options: Option<&CompileOptions>
) -> Result<CompilationArtifact>
[src]

Like compile_into_spirv but the result contains SPIR-V assembly text instead of a SPIR-V binary module.

The output SPIR-V assembly string will be of the format defined in the SPIRV-Tools project.

pub fn preprocess(
    &mut self,
    source_text: &str,
    input_file_name: &str,
    entry_point_name: &str,
    additional_options: Option<&CompileOptions>
) -> Result<CompilationArtifact>
[src]

Like compile_into_spirv but the result contains preprocessed source code instead of a SPIR-V binary module.

pub fn assemble(
    &mut self,
    source_assembly: &str,
    additional_options: Option<&CompileOptions>
) -> Result<CompilationArtifact>
[src]

Assembles the given SPIR-V assembly string source_assembly into a SPIR-V binary module according to the given additional_options.

The input SPIR-V assembly string should be of the format defined in the SPIRV-Tools project.

For options specified in additional_options, the assembling will only pick those ones suitable for assembling.

Trait Implementations

impl Drop for Compiler[src]

Auto Trait Implementations

impl !Send for Compiler

impl Unpin for Compiler

impl !Sync for Compiler

impl UnwindSafe for Compiler

impl RefUnwindSafe for Compiler

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]