Remove PipelineLayoutDescNames (#712)

This commit is contained in:
tomaka 2017-08-03 12:01:25 +02:00 committed by GitHub
parent bf82214ec1
commit 6abeba4f3d
11 changed files with 18 additions and 136 deletions

View File

@ -31,7 +31,6 @@ use vulkano::command_buffer::DynamicState;
use vulkano::descriptor::descriptor::DescriptorDesc;
use vulkano::descriptor::descriptor::ShaderStages;
use vulkano::descriptor::pipeline_layout::PipelineLayoutDesc;
use vulkano::descriptor::pipeline_layout::PipelineLayoutDescNames;
use vulkano::descriptor::pipeline_layout::PipelineLayoutDescPcRange;
use vulkano::device::Device;
use vulkano::device::DeviceExtensions;
@ -266,11 +265,6 @@ fn main() {
stages: ShaderStages::all() })
}
}
unsafe impl PipelineLayoutDescNames for VertLayout {
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
match name { _ => None, }
}
}
// Same as with our vertex shader, but for fragment one instead.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@ -362,11 +356,6 @@ fn main() {
stages: ShaderStages::all() })
}
}
unsafe impl PipelineLayoutDescNames for FragLayout {
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
match name { _ => None, }
}
}
// NOTE: ShaderModule::*_shader_entry_point calls do not do any error
// checking and you have to verify correctness of what you are doing by

View File

@ -18,7 +18,6 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
// Finding all the descriptors.
let mut descriptors = Vec::new();
struct Descriptor {
name: String,
set: u32,
binding: u32,
desc_ty: String,
@ -70,7 +69,6 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
pointed_ty));
descriptors.push(Descriptor {
name: name,
desc_ty: desc_ty,
set: descriptor_set,
binding: binding,
@ -137,18 +135,6 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
.concat()
};
// Writing the body of the `descriptor_by_name_body` method.
let descriptor_by_name_body = descriptors
.iter()
.map(|d| {
format!(r#"{name:?} => Some(({set}, {binding})),"#,
name = d.name,
set = d.set,
binding = d.binding)
})
.collect::<Vec<_>>()
.concat();
// Writing the body of the `num_push_constants_ranges` method.
let num_push_constants_ranges_body = {
if push_constants_size == 0 { "0" } else { "1" }
@ -200,20 +186,9 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
{push_constants_range_body}
}}
}}
#[allow(unsafe_code)]
unsafe impl PipelineLayoutDescNames for Layout {{
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {{
match name {{
{descriptor_by_name_body}
_ => None
}}
}}
}}
"#,
num_sets = num_sets,
num_bindings_in_set_body = num_bindings_in_set_body,
descriptor_by_name_body = descriptor_by_name_body,
descriptor_body = descriptor_body,
num_push_constants_ranges_body = num_push_constants_ranges_body,
push_constants_range_body = push_constants_range_body

View File

@ -107,8 +107,6 @@ pub fn reflect<R>(name: &str, mut spirv: R) -> Result<String, Error>
#[allow(unused_imports)]
use vulkano::descriptor::pipeline_layout::PipelineLayoutDesc;
#[allow(unused_imports)]
use vulkano::descriptor::pipeline_layout::PipelineLayoutDescNames;
#[allow(unused_imports)]
use vulkano::descriptor::pipeline_layout::PipelineLayoutDescPcRange;
"#,
);

View File

@ -9,7 +9,6 @@
use descriptor::descriptor::DescriptorDesc;
use descriptor::pipeline_layout::PipelineLayoutDesc;
use descriptor::pipeline_layout::PipelineLayoutDescNames;
use descriptor::pipeline_layout::PipelineLayoutDescPcRange;
/// Description of an empty pipeline layout.
@ -54,10 +53,3 @@ unsafe impl PipelineLayoutDesc for EmptyPipelineDesc {
None
}
}
unsafe impl PipelineLayoutDescNames for EmptyPipelineDesc {
#[inline]
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
None
}
}

View File

@ -55,7 +55,6 @@ pub use self::sys::PipelineLayoutCreationError;
pub use self::sys::PipelineLayoutSys;
pub use self::traits::PipelineLayoutAbstract;
pub use self::traits::PipelineLayoutDesc;
pub use self::traits::PipelineLayoutDescNames;
pub use self::traits::PipelineLayoutDescPcRange;
pub use self::traits::PipelineLayoutNotSupersetError;
pub use self::traits::PipelineLayoutPushConstantsCompatible;

View File

@ -25,7 +25,6 @@ use descriptor::descriptor::ShaderStages;
use descriptor::descriptor_set::UnsafeDescriptorSetLayout;
use descriptor::pipeline_layout::PipelineLayoutAbstract;
use descriptor::pipeline_layout::PipelineLayoutDesc;
use descriptor::pipeline_layout::PipelineLayoutDescNames;
use descriptor::pipeline_layout::PipelineLayoutDescPcRange;
use device::Device;
use device::DeviceOwned;
@ -181,7 +180,7 @@ impl<L> PipelineLayout<L>
}
unsafe impl<D> PipelineLayoutAbstract for PipelineLayout<D>
where D: PipelineLayoutDescNames
where D: PipelineLayoutDesc
{
#[inline]
fn sys(&self) -> PipelineLayoutSys {
@ -223,15 +222,6 @@ unsafe impl<D> PipelineLayoutDesc for PipelineLayout<D>
}
}
unsafe impl<D> PipelineLayoutDescNames for PipelineLayout<D>
where D: PipelineLayoutDescNames
{
#[inline]
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
self.desc.descriptor_by_name(name)
}
}
unsafe impl<D> DeviceOwned for PipelineLayout<D> {
#[inline]
fn device(&self) -> &Arc<Device> {

View File

@ -25,8 +25,7 @@ use device::Device;
use device::DeviceOwned;
/// Trait for objects that describe the layout of the descriptors and push constants of a pipeline.
// TODO: meh for PipelineLayoutDescNames ; the `Names` thing shouldn't be mandatory
pub unsafe trait PipelineLayoutAbstract: PipelineLayoutDescNames + DeviceOwned {
pub unsafe trait PipelineLayoutAbstract: PipelineLayoutDesc + DeviceOwned {
/// Returns an opaque object that allows internal access to the pipeline layout.
///
/// Can be obtained by calling `PipelineLayoutAbstract::sys()` on the pipeline layout.
@ -154,24 +153,6 @@ unsafe impl<T> PipelineLayoutDesc for T
}
}
/// Extension trait for `PipelineLayoutDesc`. Allows retreiving a descriptor by its name.
pub unsafe trait PipelineLayoutDescNames: PipelineLayoutDesc {
/// Returns the set ID and descriptor ID within set of the descriptor with the given name.
///
/// Returns `None` if the name was not found.
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)>;
}
unsafe impl<T> PipelineLayoutDescNames for T
where T: SafeDeref,
T::Target: PipelineLayoutDescNames
{
#[inline]
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
(**self).descriptor_by_name(name)
}
}
/// Traits that allow determining whether a pipeline layout is a superset of another one.
///
/// This trait is automatically implemented on all types that implement `PipelineLayoutAbstract`.

View File

@ -6,11 +6,10 @@
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.
use descriptor::descriptor::DescriptorDesc;
use descriptor::descriptor_set::UnsafeDescriptorSetLayout;
use descriptor::pipeline_layout::PipelineLayoutDesc;
use descriptor::pipeline_layout::PipelineLayoutDescNames;
use descriptor::pipeline_layout::PipelineLayoutDescPcRange;
use std::cmp;
use std::sync::Arc;
@ -45,11 +44,11 @@ unsafe impl<A, B> PipelineLayoutDesc for PipelineLayoutDescUnion<A, B>
let a = self.a.num_bindings_in_set(set);
let b = self.b.num_bindings_in_set(set);
match (a, b) {
(Some(a), Some(b)) => Some(cmp::max(a, b)),
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
match (a, b) {
(Some(a), Some(b)) => Some(cmp::max(a, b)),
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
}
}
@ -58,11 +57,11 @@ unsafe impl<A, B> PipelineLayoutDesc for PipelineLayoutDescUnion<A, B>
let a = self.a.descriptor(set, binding);
let b = self.b.descriptor(set, binding);
match (a, b) {
(Some(a), Some(b)) => Some(a.union(&b).expect("Can't be union-ed")),
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
match (a, b) {
(Some(a), Some(b)) => Some(a.union(&b).expect("Can't be union-ed")),
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
}
}
@ -134,24 +133,3 @@ unsafe impl<A, B> PipelineLayoutDesc for PipelineLayoutDescUnion<A, B>
None
}
}
unsafe impl<A, B> PipelineLayoutDescNames for PipelineLayoutDescUnion<A, B>
where A: PipelineLayoutDescNames,
B: PipelineLayoutDescNames
{
#[inline]
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
let a = self.a.descriptor_by_name(name);
let b = self.b.descriptor_by_name(name);
match (a, b) {
(None, None) => None,
(Some(r), None) => Some(r),
(None, Some(r)) => Some(r),
(Some(a), Some(b)) => {
assert_eq!(a, b);
Some(a)
},
}
}
}

View File

@ -20,7 +20,6 @@ use descriptor::pipeline_layout::PipelineLayout;
use descriptor::pipeline_layout::PipelineLayoutAbstract;
use descriptor::pipeline_layout::PipelineLayoutCreationError;
use descriptor::pipeline_layout::PipelineLayoutDesc;
use descriptor::pipeline_layout::PipelineLayoutDescNames;
use descriptor::pipeline_layout::PipelineLayoutDescPcRange;
use descriptor::pipeline_layout::PipelineLayoutNotSupersetError;
use descriptor::pipeline_layout::PipelineLayoutSuperset;
@ -262,15 +261,6 @@ unsafe impl<Pl> PipelineLayoutDesc for ComputePipeline<Pl>
}
}
unsafe impl<Pl> PipelineLayoutDescNames for ComputePipeline<Pl>
where Pl: PipelineLayoutDescNames
{
#[inline]
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
self.pipeline_layout.descriptor_by_name(name)
}
}
unsafe impl<Pl> DeviceOwned for ComputePipeline<Pl> {
#[inline]
fn device(&self) -> &Arc<Device> {

View File

@ -31,7 +31,6 @@ use descriptor::descriptor::DescriptorDesc;
use descriptor::descriptor_set::UnsafeDescriptorSetLayout;
use descriptor::pipeline_layout::PipelineLayout;
use descriptor::pipeline_layout::PipelineLayoutDesc;
use descriptor::pipeline_layout::PipelineLayoutDescNames;
use descriptor::pipeline_layout::PipelineLayoutDescPcRange;
use descriptor::pipeline_layout::PipelineLayoutDescUnion;
use descriptor::pipeline_layout::PipelineLayoutNotSupersetError;
@ -1388,15 +1387,6 @@ unsafe impl<Mv, L, Rp> PipelineLayoutDesc for GraphicsPipeline<Mv, L, Rp>
}
}
unsafe impl<Mv, L, Rp> PipelineLayoutDescNames for GraphicsPipeline<Mv, L, Rp>
where L: PipelineLayoutDescNames
{
#[inline]
fn descriptor_by_name(&self, name: &str) -> Option<(usize, usize)> {
self.layout.descriptor_by_name(name)
}
}
unsafe impl<Mv, L, Rp> DeviceOwned for GraphicsPipeline<Mv, L, Rp> {
#[inline]
fn device(&self) -> &Arc<Device> {

View File

@ -30,7 +30,7 @@ use std::ptr;
use std::sync::Arc;
use descriptor::pipeline_layout::EmptyPipelineDesc;
use descriptor::pipeline_layout::PipelineLayoutDescNames;
use descriptor::pipeline_layout::PipelineLayoutDesc;
use format::Format;
use pipeline::input_assembly::PrimitiveTopology;
@ -186,7 +186,7 @@ pub struct GraphicsEntryPoint<'a, S, I, O, L> {
}
unsafe impl<'a, S, I, O, L> EntryPointAbstract for GraphicsEntryPoint<'a, S, I, O, L>
where L: PipelineLayoutDescNames,
where L: PipelineLayoutDesc,
I: ShaderInterfaceDef,
O: ShaderInterfaceDef,
S: SpecializationConstants,
@ -211,7 +211,7 @@ unsafe impl<'a, S, I, O, L> EntryPointAbstract for GraphicsEntryPoint<'a, S, I,
}
unsafe impl<'a, S, I, O, L> GraphicsEntryPointAbstract for GraphicsEntryPoint<'a, S, I, O, L>
where L: PipelineLayoutDescNames,
where L: PipelineLayoutDesc,
I: ShaderInterfaceDef,
O: ShaderInterfaceDef,
S: SpecializationConstants,
@ -279,7 +279,7 @@ impl GeometryShaderExecutionMode {
}
pub unsafe trait EntryPointAbstract {
type PipelineLayout: PipelineLayoutDescNames;
type PipelineLayout: PipelineLayoutDesc;
type SpecializationConstants: SpecializationConstants;
/// Returns the module this entry point comes from.
@ -304,7 +304,7 @@ pub struct ComputeEntryPoint<'a, S, L> {
}
unsafe impl<'a, S, L> EntryPointAbstract for ComputeEntryPoint<'a, S, L>
where L: PipelineLayoutDescNames,
where L: PipelineLayoutDesc,
S: SpecializationConstants,
{
type PipelineLayout = L;