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