Some tweaks to UnsafeDescriptorSetLayout

This commit is contained in:
Pierre Krieger 2017-04-01 16:14:17 +02:00
parent d59e00102d
commit df2f859584

View File

@ -21,6 +21,7 @@ use vk;
use descriptor::descriptor::DescriptorDesc; use descriptor::descriptor::DescriptorDesc;
use descriptor::descriptor_set::DescriptorsCount; use descriptor::descriptor_set::DescriptorsCount;
use device::Device; use device::Device;
use device::DeviceOwned;
/// Describes to the Vulkan implementation the layout of all descriptors within a descriptor set. /// Describes to the Vulkan implementation the layout of all descriptors within a descriptor set.
/// ///
@ -94,12 +95,6 @@ impl UnsafeDescriptorSetLayout {
}) })
} }
/// Returns the device used to create this layout.
#[inline]
pub fn device(&self) -> &Arc<Device> {
&self.device
}
/// Returns the number of descriptors of each type. /// Returns the number of descriptors of each type.
#[inline] #[inline]
pub fn descriptors_count(&self) -> &DescriptorsCount { pub fn descriptors_count(&self) -> &DescriptorsCount {
@ -107,6 +102,13 @@ impl UnsafeDescriptorSetLayout {
} }
} }
unsafe impl DeviceOwned for UnsafeDescriptorSetLayout {
#[inline]
fn device(&self) -> &Arc<Device> {
&self.device
}
}
unsafe impl VulkanObject for UnsafeDescriptorSetLayout { unsafe impl VulkanObject for UnsafeDescriptorSetLayout {
type Object = vk::DescriptorSetLayout; type Object = vk::DescriptorSetLayout;
@ -130,11 +132,40 @@ impl Drop for UnsafeDescriptorSetLayout {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::iter; use std::iter;
use descriptor::descriptor_set::unsafe_layout::UnsafeDescriptorSetLayout; use descriptor::descriptor::DescriptorDesc;
use descriptor::descriptor::DescriptorDescTy;
use descriptor::descriptor::DescriptorBufferDesc;
use descriptor::descriptor::DescriptorBufferContentDesc;
use descriptor::descriptor::ShaderStages;
use descriptor::descriptor_set::DescriptorsCount;
use descriptor::descriptor_set::UnsafeDescriptorSetLayout;
#[test] #[test]
fn empty() { fn empty() {
let (device, _) = gfx_dev_and_queue!(); let (device, _) = gfx_dev_and_queue!();
let _layout = UnsafeDescriptorSetLayout::new(device, iter::empty()); let _layout = UnsafeDescriptorSetLayout::new(device, iter::empty());
} }
#[test]
fn basic_create() {
let (device, _) = gfx_dev_and_queue!();
let layout = DescriptorDesc {
ty: DescriptorDescTy::Buffer(DescriptorBufferDesc {
dynamic: Some(false),
storage: false,
content: DescriptorBufferContentDesc::F32,
}),
array_count: 1,
stages: ShaderStages::all_graphics(),
readonly: true,
};
let sl = UnsafeDescriptorSetLayout::new(device.clone(), iter::once(Some(layout))).unwrap();
assert_eq!(sl.descriptors_count(), &DescriptorsCount {
uniform_buffer: 1,
.. DescriptorsCount::zero()
});
}
} }