From cc15992aa24c4328728aad9a5a835c61fd8ce56b Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sat, 10 Dec 2016 11:54:41 +0100 Subject: [PATCH] More safety in the descriptor writes --- vulkano/src/descriptor/descriptor_set/simple.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vulkano/src/descriptor/descriptor_set/simple.rs b/vulkano/src/descriptor/descriptor_set/simple.rs index 5d382b2c..55ee00e7 100644 --- a/vulkano/src/descriptor/descriptor_set/simple.rs +++ b/vulkano/src/descriptor/descriptor_set/simple.rs @@ -12,6 +12,7 @@ use std::sync::Arc; use buffer::Buffer; use buffer::BufferViewRef; use command_buffer::cmd::CommandsListSink; +use descriptor::descriptor::DescriptorType; use descriptor::descriptor_set::DescriptorSet; use descriptor::descriptor_set::TrackedDescriptorSet; use descriptor::descriptor_set::UnsafeDescriptorSetLayout; @@ -168,8 +169,16 @@ unsafe impl SimpleDescriptorSetBufferExt for T assert_eq!(set_id, i.set_id); // TODO: Result instead let desc = i.layout.desc().descriptor(set_id, binding_id).unwrap(); // TODO: Result instead - // TODO: dispatch depending on the descriptor - i.writes.push(unsafe { DescriptorWrite::uniform_buffer(binding_id as u32, &self) }); + assert!(desc.array_count == 1); // not implemented + i.writes.push(match desc.ty.ty().unwrap() { + DescriptorType::UniformBuffer => unsafe { + DescriptorWrite::uniform_buffer(binding_id as u32, &self) + }, + DescriptorType::StorageBuffer => unsafe { + DescriptorWrite::storage_buffer(binding_id as u32, &self) + }, + _ => panic!() + }); SimpleDescriptorSetBuilder { layout: i.layout,