fixed macros, fixed teapot example

This commit is contained in:
Georg Echterling 2016-04-14 23:45:10 +02:00
parent 6593618feb
commit 2d0ff20cd7
3 changed files with 33 additions and 17 deletions

View File

@ -78,8 +78,7 @@ fn main() {
};
let cb_pool = vulkano::command_buffer::CommandBufferPool::new(&device, &queue.family())
.expect("failed to create command buffer pool");
let cb_pool = vulkano::command_buffer::CommandBufferPool::new(&device, &queue.family());
let depth_buffer = vulkano::image::attachment::AttachmentImage::transient(&device, images[0].dimensions(), vulkano::format::D16Unorm).unwrap();
@ -162,9 +161,9 @@ fn main() {
let renderpass = renderpass::CustomRenderPass::new(&device, &renderpass::Formats {
color: (images[0].format(), 1),
depth: (vulkano::format::D16Unorm, 1)
}).unwrap();
});
let descriptor_pool = vulkano::descriptor::descriptor_set::DescriptorPool::new(&device).unwrap();
let descriptor_pool = vulkano::descriptor::descriptor_set::DescriptorPool::new(&device);
mod pipeline_layout {
pipeline_layout!{
@ -177,7 +176,7 @@ fn main() {
let pipeline_layout = pipeline_layout::CustomPipeline::new(&device).unwrap();
let set = pipeline_layout::set0::Set::new(&descriptor_pool, &pipeline_layout, &pipeline_layout::set0::Descriptors {
uniforms: &uniform_buffer
}).unwrap();
});
let pipeline = vulkano::pipeline::GraphicsPipeline::new(&device, vulkano::pipeline::GraphicsPipelineParams {
vertex_input: vulkano::pipeline::vertex::TwoBuffersDefinition::new(),
@ -214,7 +213,7 @@ fn main() {
let command_buffers = framebuffers.iter().map(|framebuffer| {
vulkano::command_buffer::PrimaryCommandBufferBuilder::new(&cb_pool).unwrap()
vulkano::command_buffer::PrimaryCommandBufferBuilder::new(&cb_pool)
.draw_inline(&renderpass, &framebuffer, renderpass::ClearValues {
color: [0.0, 0.0, 1.0, 1.0].into(),
depth: 1.0,
@ -222,7 +221,7 @@ fn main() {
.draw_indexed(&pipeline, (&vertex_buffer, &normals_buffer), &index_buffer,
&vulkano::command_buffer::DynamicState::none(), &set, &())
.draw_end()
.build().unwrap()
.build()
}).collect::<Vec<_>>();
let mut submissions: Vec<Arc<vulkano::command_buffer::Submission>> = Vec::new();

View File

@ -49,7 +49,7 @@ macro_rules! pipeline_layout {
{
let layouts = vec![
$(
try!($name::build_set_layout(device))
Arc::new(try!($name::build_set_layout_raw(device)))
),*
];
@ -160,19 +160,29 @@ macro_rules! pipeline_layout {
impl Set {
#[inline]
#[allow(non_camel_case_types)]
pub fn new<$($field: ValidParameter<$ty>),*>
pub fn raw<$($field: ValidParameter<$ty>),*>
(pool: &Arc<DescriptorPool>, layout: &Arc<CustomPipeline>,
descriptors: &Descriptors<$($field),*>)
-> Result<Arc<Set>, OomError>
-> Result<Set, OomError>
{
#![allow(unsafe_code)]
unsafe {
let layout = layout.inner_pipeline_layout().descriptor_set_layout($num).unwrap();
let mut set = try!(UnsafeDescriptorSet::uninitialized(pool, layout));
let mut set = try!(UnsafeDescriptorSet::uninitialized_raw(pool, layout));
set.write(descriptors.writes());
Ok(Arc::new(Set { inner: set }))
Ok(Set { inner: set })
}
}
#[inline]
#[allow(non_camel_case_types)]
pub fn new<$($field: ValidParameter<$ty>),*>
(pool: &Arc<DescriptorPool>, layout: &Arc<CustomPipeline>,
descriptors: &Descriptors<$($field),*>)
-> Arc<Set>
{
Arc::new(Set::raw(pool, layout, descriptors).unwrap())
}
}
#[allow(unsafe_code)]
@ -195,8 +205,8 @@ macro_rules! pipeline_layout {
}
#[allow(unused_assignments)]
pub fn build_set_layout(device: &Arc<Device>)
-> Result<Arc<UnsafeDescriptorSetLayout>, OomError>
pub fn build_set_layout_raw(device: &Arc<Device>)
-> Result<UnsafeDescriptorSetLayout, OomError>
{
let mut descriptors = Vec::new();
let mut binding = 0;
@ -213,7 +223,14 @@ macro_rules! pipeline_layout {
binding += 1;
)*
UnsafeDescriptorSetLayout::new(device, descriptors.into_iter())
UnsafeDescriptorSetLayout::raw(device, descriptors.into_iter())
}
#[inline]
pub fn build_set_layout(device: &Arc<Device>)
-> Arc<UnsafeDescriptorSetLayout>
{
Arc::new(build_set_layout_raw(device).unwrap())
}
}

View File

@ -90,7 +90,7 @@ macro_rules! ordered_passes_renderpass {
#![allow(unsafe_code)]
let rp = try!(unsafe {
UnsafeRenderPass::new(device, attachments(formats), passes(), dependencies())
UnsafeRenderPass::raw(device, attachments(formats), passes(), dependencies())
});
Ok(CustomRenderPass {
@ -103,7 +103,7 @@ macro_rules! ordered_passes_renderpass {
pub fn new(device: &Arc<Device>, formats: &Formats)
-> Arc<CustomRenderPass>
{
CustomRenderPass::raw(device, formats)
Arc::new(CustomRenderPass::raw(device, formats).unwrap())
}
}