Skip to content

Instantly share code, notes, and snippets.

@Deco
Created March 11, 2017 15:08
Show Gist options
  • Save Deco/afe9e0e2abe8914ee3f62e84707a2dea to your computer and use it in GitHub Desktop.
Save Deco/afe9e0e2abe8914ee3f62e84707a2dea to your computer and use it in GitHub Desktop.
#[allow(unused_imports)]
use std::sync::Arc;
#[allow(unused_imports)]
use std::vec::IntoIter as VecIntoIter;
#[allow(unused_imports)]
use vulkano::device::Device;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::DescriptorDesc;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::DescriptorDescTy;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::DescriptorBufferDesc;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::DescriptorImageDesc;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::DescriptorImageDescDimensions;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::DescriptorImageDescArray;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::ShaderStages;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor_set::DescriptorSet;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor_set::UnsafeDescriptorSet;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor_set::UnsafeDescriptorSetLayout;
#[allow(unused_imports)]
use vulkano::descriptor::pipeline_layout::PipelineLayout;
#[allow(unused_imports)]
use vulkano::descriptor::pipeline_layout::PipelineLayoutDesc;
#[allow(unused_imports)]
use vulkano::descriptor::pipeline_layout::UnsafePipelineLayout;
pub struct Shader {
shader: ::std::sync::Arc<::vulkano::pipeline::shader::ShaderModule>,
}
impl Shader {
/// Loads the shader in Vulkan as a `ShaderModule`.
#[inline]
#[allow(unsafe_code)]
pub fn load(device: &::std::sync::Arc<::vulkano::device::Device>)
-> Result<Shader, ::vulkano::OomError>
{
unsafe {
let data = [3, 2, 35, 7, 0, 0, 1, 0, 1, 0, 8, 0, 12, 0, 0, 0, 0, 0, 0, 0, 17, 0, 2, 0, 1, 0, 0, 0, 11, 0, 6, 0, 1, 0, 0, 0, 71, 76, 83, 76, 46, 115, 116, 100, 46, 52, 53, 48, 0, 0, 0, 0, 14, 0, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 15, 0, 6, 0, 4, 0, 0, 0, 4, 0, 0, 0, 109, 97, 105, 110, 0, 0, 0, 0, 9, 0, 0, 0, 16, 0, 3, 0, 4, 0, 0, 0, 7, 0, 0, 0, 3, 0, 3, 0, 2, 0, 0, 0, 194, 1, 0, 0, 4, 0, 9, 0, 71, 76, 95, 65, 82, 66, 95, 115, 101, 112, 97, 114, 97, 116, 101, 95, 115, 104, 97, 100, 101, 114, 95, 111, 98, 106, 101, 99, 116, 115, 0, 0, 5, 0, 4, 0, 4, 0, 0, 0, 109, 97, 105, 110, 0, 0, 0, 0, 5, 0, 4, 0, 9, 0, 0, 0, 102, 95, 99, 111, 108, 111, 114, 0, 71, 0, 4, 0, 9, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 19, 0, 2, 0, 2, 0, 0, 0, 33, 0, 3, 0, 3, 0, 0, 0, 2, 0, 0, 0, 22, 0, 3, 0, 6, 0, 0, 0, 32, 0, 0, 0, 23, 0, 4, 0, 7, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0, 32, 0, 4, 0, 8, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0, 59, 0, 4, 0, 8, 0, 0, 0, 9, 0, 0, 0, 3, 0, 0, 0, 43, 0, 4, 0, 6, 0, 0, 0, 10, 0, 0, 0, 0, 0, 128, 63, 44, 0, 7, 0, 7, 0, 0, 0, 11, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 54, 0, 5, 0, 2, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 248, 0, 2, 0, 5, 0, 0, 0, 62, 0, 3, 0, 9, 0, 0, 0, 11, 0, 0, 0, 253, 0, 1, 0, 56, 0, 1, 0];
Ok(Shader {
shader: try!(::vulkano::pipeline::shader::ShaderModule::new(device.clone(), &data))
})
}
}
/// Returns the module that was created.
#[allow(dead_code)]
#[inline]
pub fn module(&self) -> &::std::sync::Arc<::vulkano::pipeline::shader::ShaderModule> {
&self.shader
}
/// Returns a logical struct describing the entry point named `main`.
#[inline]
#[allow(unsafe_code)]
pub fn main_entry_point(&self) -> ::vulkano::pipeline::shader::FragmentShaderEntryPoint<(), MainInput, MainOutput, Layout> {
unsafe {
#[allow(dead_code)]
static NAME: [u8; 5] = [109, 97, 105, 110, 0]; // "main"
self.shader.fragment_shader_entry_point(::std::ffi::CStr::from_ptr(NAME.as_ptr() as *const _), MainInput, MainOutput, Layout(ShaderStages { fragment: true, .. ShaderStages::none() }))
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct MainInput;
#[allow(unsafe_code)]
unsafe impl ::vulkano::pipeline::shader::ShaderInterfaceDef for MainInput {
type Iter = MainInputIter;
fn elements(&self) -> MainInputIter {
MainInputIter { num: 0 }
}
}
#[derive(Debug, Copy, Clone)]
pub struct MainInputIter { num: u16 }
impl Iterator for MainInputIter {
type Item = ::vulkano::pipeline::shader::ShaderInterfaceDefEntry;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
None
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let len = (0 - self.num) as usize;
(len, Some(len))
}
}
impl ExactSizeIterator for MainInputIter {}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct MainOutput;
#[allow(unsafe_code)]
unsafe impl ::vulkano::pipeline::shader::ShaderInterfaceDef for MainOutput {
type Iter = MainOutputIter;
fn elements(&self) -> MainOutputIter {
MainOutputIter { num: 0 }
}
}
#[derive(Debug, Copy, Clone)]
pub struct MainOutputIter { num: u16 }
impl Iterator for MainOutputIter {
type Item = ::vulkano::pipeline::shader::ShaderInterfaceDefEntry;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
if self.num == 0 {
self.num += 1;
return Some(::vulkano::pipeline::shader::ShaderInterfaceDefEntry {
location: 0 .. 1,
format: ::vulkano::format::Format::R32G32B32A32Sfloat,
name: Some(::std::borrow::Cow::Borrowed("f_color"))
});
}
None
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let len = (1 - self.num) as usize;
(len, Some(len))
}
}
impl ExactSizeIterator for MainOutputIter {}
pub mod ty {}
pub struct Layout(ShaderStages);
#[allow(unsafe_code)]
unsafe impl PipelineLayoutDesc for Layout {
type SetsIter = VecIntoIter<Self::DescIter>;
type DescIter = VecIntoIter<DescriptorDesc>;
fn descriptors_desc(&self) -> Self::SetsIter {
vec![
].into_iter()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment