pub struct Bytecode(/* private fields */);
Expand description

A 4-byte aligned SPIR-V bytecode buffer.

This helper struct can be used to ensure the correct alignment of the SPIR-V bytecode for a shader before providing it to a crate::vk::ShaderModuleCreateInfo to create a shader module.

let vert_bytes = include_bytes!("../../tutorial/shaders/09/vert.spv");
let vert_bytecode = Bytecode::new(vert_bytes).unwrap();
let vert_info = vk::ShaderModuleCreateInfo::builder()
    .code_size(vert_bytecode.code_size())
    .code(vert_bytecode.code());

Implementations§

source§

impl Bytecode

source

pub fn new(bytecode: &[u8]) -> Result<Self, BytecodeError>

Copies a SPIR-V bytecode slice into a new 4-byte aligned SPIR-V bytecode buffer.

source

pub fn code_size(&self) -> usize

The length of this SPIR-V bytecode buffer in bytes.

source

pub fn code(&self) -> &[u32]

The value of this SPIR-V bytecode buffer.

Trait Implementations§

source§

impl Drop for Bytecode

source§

fn drop(&mut self)

Executes the destructor for this 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.