Skip to content

Commit

Permalink
Merge #213
Browse files Browse the repository at this point in the history
213: Allow creating spirv shader from byte array r=jaynus a=Frizi



Co-authored-by: Frizi <frizi09@gmail.com>
  • Loading branch information
bors[bot] and Frizi committed Sep 27, 2019
2 parents 2d5a4a1 + 9bfe9d7 commit 28ab593
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions shader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ impl SpirvShader {
entry: entrypoint.to_string(),
}
}

/// Create Spir-V shader from bytecode stored as bytes.
/// Errors when passed byte array length is not a multiple of 4.
pub fn from_bytes(
spirv: &[u8],
stage: ShaderStageFlags,
entrypoint: &str,
) -> std::io::Result<Self> {
Ok(Self::new(
gfx_hal::pso::read_spirv(std::io::Cursor::new(spirv))?,
stage,
entrypoint,
))
}
}

impl Shader for SpirvShader {
Expand Down

0 comments on commit 28ab593

Please sign in to comment.