more descriptor implimentations

master
Tom Gowan 6 years ago
parent 52946a0ec3
commit f753563525

@ -1,9 +1,9 @@
use crate::error::{ConvertError, Error};
use crate::sr;
use crate::vk;
use crate::error::{ConvertError, Error};
use std::convert::TryFrom;
use vk::descriptor::descriptor::*;
use vk::format::Format;
use std::convert::TryFrom;
pub struct SpirvTy<T> {
inner: T,
@ -14,7 +14,6 @@ pub struct DescriptorDescInfo {
pub image: sr::types::ReflectImageTraits,
}
impl<T> SpirvTy<T> {
pub fn inner(self) -> T {
self.inner
@ -29,16 +28,24 @@ impl TryFrom<DescriptorDescInfo> for SpirvTy<DescriptorDescTy> {
match d.descriptor_type {
SR::Undefined => Err(ConvertError::Unimplemented),
SR::Sampler => Ok(VK::Sampler),
SR::CombinedImageSampler => Ok(VK::CombinedImageSampler(SpirvTy::try_from(d.image)?.inner())),
SR::SampledImage => Err(ConvertError::Unimplemented),
SR::CombinedImageSampler => Ok(VK::CombinedImageSampler(
SpirvTy::try_from(d.image)?.inner(),
)),
SR::SampledImage => Ok(VK::Image(SpirvTy::try_from(d.image)?.inner())),
SR::StorageImage => Err(ConvertError::Unimplemented),
SR::UniformTexelBuffer => Err(ConvertError::Unimplemented),
SR::StorageTexelBuffer => Err(ConvertError::Unimplemented),
SR::UniformBuffer => Err(ConvertError::Unimplemented),
SR::StorageBuffer => Err(ConvertError::Unimplemented),
SR::UniformBufferDynamic => Err(ConvertError::Unimplemented),
SR::StorageBufferDynamic => Err(ConvertError::Unimplemented),
SR::InputAttachment => Err(ConvertError::Unimplemented),
SR::UniformTexelBuffer => Ok(VK::TexelBuffer {
storage: false,
format: None,
}),
SR::StorageTexelBuffer => Ok(VK::TexelBuffer {
storage: false,
format: None,
}),
SR::UniformBuffer => Ok(VK::Buffer(DescriptorBufferDesc{ dynamic: Some(false), storage: false })),
SR::StorageBuffer => Ok(VK::Buffer(DescriptorBufferDesc{ dynamic: Some(false), storage: true })),
SR::UniformBufferDynamic => Ok(VK::Buffer(DescriptorBufferDesc{ dynamic: Some(true), storage: false })),
SR::StorageBufferDynamic => Ok(VK::Buffer(DescriptorBufferDesc{ dynamic: Some(true), storage: true })),
SR::InputAttachment => Ok(SpirvTy::try_from(d.image)?.inner()),
SR::AccelerationStructureNV => Err(ConvertError::Unimplemented),
}
.map(|t| SpirvTy { inner: t })
@ -51,7 +58,9 @@ impl TryFrom<sr::types::ReflectImageTraits> for SpirvTy<DescriptorImageDesc> {
fn try_from(d: sr::types::ReflectImageTraits) -> Result<Self, Self::Error> {
let conv_array_layers = |a, d| {
if a != 0 {
DescriptorImageDescArray::Arrayed{max_layers: Some(d)}
DescriptorImageDescArray::Arrayed {
max_layers: Some(d),
}
} else {
DescriptorImageDescArray::NonArrayed
}
@ -69,6 +78,25 @@ impl TryFrom<sr::types::ReflectImageTraits> for SpirvTy<DescriptorImageDesc> {
}
}
impl TryFrom<sr::types::ReflectImageTraits> for SpirvTy<DescriptorDescTy> {
type Error = Error;
fn try_from(d: sr::types::ReflectImageTraits) -> Result<Self, Self::Error> {
let conv_array_layers = |a, d| {
if a != 0 {
DescriptorImageDescArray::Arrayed {
max_layers: Some(d),
}
} else {
DescriptorImageDescArray::NonArrayed
}
};
let t = DescriptorDescTy::InputAttachment {
multisampled: d.ms != 0,
array_layers: conv_array_layers(d.arrayed, d.depth),
};
Ok(SpirvTy { inner: t })
}
}
impl TryFrom<sr::types::variable::ReflectDimension> for SpirvTy<DescriptorImageDescDimensions> {
type Error = Error;
fn try_from(d: sr::types::variable::ReflectDimension) -> Result<Self, Self::Error> {

Loading…
Cancel
Save