Compare commits
No commits in common. "43fef690b385f218789ffa9c8f80598fca8b0552" and "fdd58debfb60def1416caa0c6c1b509132cf21ed" have entirely different histories.
43fef690b3
...
fdd58debfb
13 changed files with 105 additions and 134 deletions
|
@ -9,7 +9,7 @@ build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
vulkan-sys = { path = "../vulkan-sys" }
|
vulkan-sys = { path = "../vulkan-sys" }
|
||||||
anyhow = { version = "1.0.82", features = ["backtrace"] }
|
anyhow = { version = "1.0.81", features = ["backtrace"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cc = "1.0.92"
|
cc = "1.0.90"
|
|
@ -5,9 +5,9 @@ authors = ["hodasemi <superschneider@t-online.de>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
image = "0.25.1"
|
image = "0.25.0"
|
||||||
vulkan-sys = { path = "../vulkan-sys" }
|
vulkan-sys = { path = "../vulkan-sys" }
|
||||||
vma-rs = { path = "../vma-rs" }
|
vma-rs = { path = "../vma-rs" }
|
||||||
anyhow = { version = "1.0.82", features = ["backtrace"] }
|
anyhow = { version = "1.0.81", features = ["backtrace"] }
|
||||||
assetpath = { path = "../assetpath" }
|
assetpath = { path = "../assetpath" }
|
||||||
utilities = { git = "https://gavania.de/hodasemi/utilities.git" }
|
utilities = { git = "https://gavania.de/hodasemi/utilities.git" }
|
||||||
|
|
|
@ -270,8 +270,15 @@ impl DescriptorSet {
|
||||||
{
|
{
|
||||||
assert!(writes.len() <= self.pool.descriptor_set_layout.bindings().len());
|
assert!(writes.len() <= self.pool.descriptor_set_layout.bindings().len());
|
||||||
|
|
||||||
for binding in self.pool.descriptor_set_layout.bindings().iter() {
|
for (i, binding) in self
|
||||||
if let Some(write) = writes.iter().find(|write| write.binding == binding.binding) {
|
.pool
|
||||||
|
.descriptor_set_layout
|
||||||
|
.bindings()
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
|
if let Some(write) = writes.get(i) {
|
||||||
|
assert_eq!(write.binding, binding.binding);
|
||||||
assert_eq!(write.descriptor_type, binding.desc_type);
|
assert_eq!(write.descriptor_type, binding.desc_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,31 +24,6 @@ macro_rules! impl_vk_handle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($struct_name:ident $(<$( $name:ident: $type:ident, )*>)?, $target_name:ident, $value:ident) => {
|
|
||||||
impl$(<$( $name: $type, )*>)? VkHandle<$target_name> for $struct_name$(<$($name,)?>)? {
|
|
||||||
fn vk_handle(&self) -> $target_name {
|
|
||||||
self.$value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a $($(, $name: $type)*)?> VkHandle<$target_name> for &'a $struct_name$(<$($name,)?>)? {
|
|
||||||
fn vk_handle(&self) -> $target_name {
|
|
||||||
self.$value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl$(<$( $name: $type, )*>)? VkHandle<$target_name> for Arc<$struct_name$(<$($name,)?>)?> {
|
|
||||||
fn vk_handle(&self) -> $target_name {
|
|
||||||
self.$value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a $($(, $name: $type)*)?> VkHandle<$target_name> for &'a Arc<$struct_name$(<$($name,)?>)?> {
|
|
||||||
fn vk_handle(&self) -> $target_name {
|
|
||||||
self.$value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_vk_handle_t {
|
macro_rules! impl_vk_handle_t {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::prelude::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct ComputePipelineBuilder<'a> {
|
pub struct ComputePipelineBuilder<'a> {
|
||||||
shader_module: Option<&'a Arc<ShaderModule<shader_type::Compute>>>,
|
shader_module: Option<&'a Arc<ShaderModule<{ ShaderType::Compute as u8 }>>>,
|
||||||
pipeline_cache: Option<&'a Arc<PipelineCache>>,
|
pipeline_cache: Option<&'a Arc<PipelineCache>>,
|
||||||
flags: VkPipelineCreateFlagBits,
|
flags: VkPipelineCreateFlagBits,
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ impl<'a> ComputePipelineBuilder<'a> {
|
||||||
// TODO: add support for specialization constants
|
// TODO: add support for specialization constants
|
||||||
pub fn set_shader_module(
|
pub fn set_shader_module(
|
||||||
mut self,
|
mut self,
|
||||||
shader_module: &'a Arc<ShaderModule<shader_type::Compute>>,
|
shader_module: &'a Arc<ShaderModule<{ ShaderType::Compute as u8 }>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
if self.shader_module.is_some() {
|
if self.shader_module.is_some() {
|
||||||
|
|
|
@ -12,21 +12,21 @@ pub struct GraphicsPipelineBuilder {
|
||||||
|
|
||||||
amd_rasterization_order: Option<VkPipelineRasterizationStateRasterizationOrderAMD>,
|
amd_rasterization_order: Option<VkPipelineRasterizationStateRasterizationOrderAMD>,
|
||||||
|
|
||||||
vertex_shader: Option<Arc<ShaderModule<shader_type::Vertex>>>,
|
vertex_shader: Option<Arc<ShaderModule<{ ShaderType::Vertex as u8 }>>>,
|
||||||
vertex_binding_description: Vec<VkVertexInputBindingDescription>,
|
vertex_binding_description: Vec<VkVertexInputBindingDescription>,
|
||||||
vertex_attribute_description: Vec<VkVertexInputAttributeDescription>,
|
vertex_attribute_description: Vec<VkVertexInputAttributeDescription>,
|
||||||
|
|
||||||
input_assembly: Option<VkPipelineInputAssemblyStateCreateInfo>,
|
input_assembly: Option<VkPipelineInputAssemblyStateCreateInfo>,
|
||||||
|
|
||||||
tesselation_shader: Option<(
|
tesselation_shader: Option<(
|
||||||
Arc<ShaderModule<shader_type::TesselationControl>>,
|
Arc<ShaderModule<{ ShaderType::TesselationControl as u8 }>>,
|
||||||
Arc<ShaderModule<shader_type::TesselationEvaluation>>,
|
Arc<ShaderModule<{ ShaderType::TesselationEvaluation as u8 }>>,
|
||||||
)>,
|
)>,
|
||||||
patch_control_points: u32,
|
patch_control_points: u32,
|
||||||
|
|
||||||
geometry_shader: Option<Arc<ShaderModule<shader_type::Geometry>>>,
|
geometry_shader: Option<Arc<ShaderModule<{ ShaderType::Geometry as u8 }>>>,
|
||||||
|
|
||||||
fragment_shader: Option<Arc<ShaderModule<shader_type::Fragment>>>,
|
fragment_shader: Option<Arc<ShaderModule<{ ShaderType::Fragment as u8 }>>>,
|
||||||
|
|
||||||
viewports: Vec<VkViewport>,
|
viewports: Vec<VkViewport>,
|
||||||
scissors: Vec<VkRect2D>,
|
scissors: Vec<VkRect2D>,
|
||||||
|
@ -45,7 +45,7 @@ impl GraphicsPipelineBuilder {
|
||||||
// TODO: add support for specialization constants
|
// TODO: add support for specialization constants
|
||||||
pub fn set_vertex_shader<T: VertexInputDescription>(
|
pub fn set_vertex_shader<T: VertexInputDescription>(
|
||||||
mut self,
|
mut self,
|
||||||
shader: Arc<ShaderModule<shader_type::Vertex>>,
|
shader: Arc<ShaderModule<{ ShaderType::Vertex as u8 }>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.vertex_shader = Some(shader);
|
self.vertex_shader = Some(shader);
|
||||||
self.vertex_binding_description = T::bindings();
|
self.vertex_binding_description = T::bindings();
|
||||||
|
@ -57,8 +57,8 @@ impl GraphicsPipelineBuilder {
|
||||||
// TODO: add support for specialization constants
|
// TODO: add support for specialization constants
|
||||||
pub fn set_tesselation_shader(
|
pub fn set_tesselation_shader(
|
||||||
mut self,
|
mut self,
|
||||||
tesselation_control: Arc<ShaderModule<shader_type::TesselationControl>>,
|
tesselation_control: Arc<ShaderModule<{ ShaderType::TesselationControl as u8 }>>,
|
||||||
tesselation_evaluation: Arc<ShaderModule<shader_type::TesselationEvaluation>>,
|
tesselation_evaluation: Arc<ShaderModule<{ ShaderType::TesselationEvaluation as u8 }>>,
|
||||||
patch_control_points: u32,
|
patch_control_points: u32,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.tesselation_shader = Some((tesselation_control, tesselation_evaluation));
|
self.tesselation_shader = Some((tesselation_control, tesselation_evaluation));
|
||||||
|
@ -68,14 +68,20 @@ impl GraphicsPipelineBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add support for specialization constants
|
// TODO: add support for specialization constants
|
||||||
pub fn set_geometry_shader(mut self, shader: Arc<ShaderModule<shader_type::Geometry>>) -> Self {
|
pub fn set_geometry_shader(
|
||||||
|
mut self,
|
||||||
|
shader: Arc<ShaderModule<{ ShaderType::Geometry as u8 }>>,
|
||||||
|
) -> Self {
|
||||||
self.geometry_shader = Some(shader);
|
self.geometry_shader = Some(shader);
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add support for specialization constants
|
// TODO: add support for specialization constants
|
||||||
pub fn set_fragment_shader(mut self, shader: Arc<ShaderModule<shader_type::Fragment>>) -> Self {
|
pub fn set_fragment_shader(
|
||||||
|
mut self,
|
||||||
|
shader: Arc<ShaderModule<{ ShaderType::Fragment as u8 }>>,
|
||||||
|
) -> Self {
|
||||||
self.fragment_shader = Some(shader);
|
self.fragment_shader = Some(shader);
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|
|
@ -31,8 +31,8 @@ impl<'a> Library<'a> {
|
||||||
|
|
||||||
macro_rules! impl_from_shader_type {
|
macro_rules! impl_from_shader_type {
|
||||||
($struct: ident, $shader_type: ident) => {
|
($struct: ident, $shader_type: ident) => {
|
||||||
impl From<Arc<ShaderModule<shader_type::$shader_type>>> for $struct {
|
impl From<Arc<ShaderModule<{ ShaderType::$shader_type as u8 }>>> for $struct {
|
||||||
fn from(value: Arc<ShaderModule<shader_type::$shader_type>>) -> Self {
|
fn from(value: Arc<ShaderModule<{ ShaderType::$shader_type as u8 }>>) -> Self {
|
||||||
Self::$shader_type(value)
|
Self::$shader_type(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@ macro_rules! impl_from_shader_type {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
enum RaytracingShader {
|
enum RaytracingShader {
|
||||||
RayGeneration(Arc<ShaderModule<shader_type::RayGeneration>>),
|
RayGeneration(Arc<ShaderModule<{ ShaderType::RayGeneration as u8 }>>),
|
||||||
ClosestHit(Arc<ShaderModule<shader_type::ClosestHit>>),
|
ClosestHit(Arc<ShaderModule<{ ShaderType::ClosestHit as u8 }>>),
|
||||||
Miss(Arc<ShaderModule<shader_type::Miss>>),
|
Miss(Arc<ShaderModule<{ ShaderType::Miss as u8 }>>),
|
||||||
AnyHit(Arc<ShaderModule<shader_type::AnyHit>>),
|
AnyHit(Arc<ShaderModule<{ ShaderType::AnyHit as u8 }>>),
|
||||||
Intersection(Arc<ShaderModule<shader_type::Intersection>>),
|
Intersection(Arc<ShaderModule<{ ShaderType::Intersection as u8 }>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_from_shader_type!(RaytracingShader, RayGeneration);
|
impl_from_shader_type!(RaytracingShader, RayGeneration);
|
||||||
|
@ -75,9 +75,9 @@ impl From<OtherShader> for RaytracingShader {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum HitShader {
|
pub enum HitShader {
|
||||||
ClosestHit(Arc<ShaderModule<shader_type::ClosestHit>>),
|
ClosestHit(Arc<ShaderModule<{ ShaderType::ClosestHit as u8 }>>),
|
||||||
AnyHit(Arc<ShaderModule<shader_type::AnyHit>>),
|
AnyHit(Arc<ShaderModule<{ ShaderType::AnyHit as u8 }>>),
|
||||||
Intersection(Arc<ShaderModule<shader_type::Intersection>>),
|
Intersection(Arc<ShaderModule<{ ShaderType::Intersection as u8 }>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_from_shader_type!(HitShader, ClosestHit);
|
impl_from_shader_type!(HitShader, ClosestHit);
|
||||||
|
@ -86,8 +86,8 @@ impl_from_shader_type!(HitShader, Intersection);
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum OtherShader {
|
pub enum OtherShader {
|
||||||
RayGeneration(Arc<ShaderModule<shader_type::RayGeneration>>),
|
RayGeneration(Arc<ShaderModule<{ ShaderType::RayGeneration as u8 }>>),
|
||||||
Miss(Arc<ShaderModule<shader_type::Miss>>),
|
Miss(Arc<ShaderModule<{ ShaderType::Miss as u8 }>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_from_shader_type!(OtherShader, RayGeneration);
|
impl_from_shader_type!(OtherShader, RayGeneration);
|
||||||
|
|
|
@ -24,9 +24,8 @@ pub use super::renderpass::RenderPass;
|
||||||
pub use super::sampler_manager::{Sampler, SamplerBuilder};
|
pub use super::sampler_manager::{Sampler, SamplerBuilder};
|
||||||
pub use super::semaphore::Semaphore;
|
pub use super::semaphore::Semaphore;
|
||||||
pub use super::shadermodule::{
|
pub use super::shadermodule::{
|
||||||
shader_type::{self, ShaderType},
|
AddSpecializationConstant, PipelineStageInfo, ShaderModule, ShaderType,
|
||||||
AddSpecializationConstant, PipelineStageInfo, ShaderModule, SpecializationConstants,
|
SpecializationConstants, VertexInputDescription,
|
||||||
VertexInputDescription,
|
|
||||||
};
|
};
|
||||||
pub use super::surface::Surface;
|
pub use super::surface::Surface;
|
||||||
pub use super::swapchain::Swapchain;
|
pub use super::swapchain::Swapchain;
|
||||||
|
|
|
@ -4,59 +4,51 @@ use anyhow::{Context, Result};
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub mod shader_type {
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
mod sealed {
|
#[repr(u8)]
|
||||||
pub trait Sealed {}
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
impl Sealed for super::Vertex {}
|
pub enum ShaderType {
|
||||||
impl Sealed for super::Fragment {}
|
None,
|
||||||
impl Sealed for super::Geometry {}
|
Vertex,
|
||||||
impl Sealed for super::TesselationControl {}
|
Fragment,
|
||||||
impl Sealed for super::TesselationEvaluation {}
|
Geometry,
|
||||||
impl Sealed for super::Compute {}
|
TesselationControl,
|
||||||
impl Sealed for super::RayGeneration {}
|
TesselationEvaluation,
|
||||||
impl Sealed for super::ClosestHit {}
|
Compute,
|
||||||
impl Sealed for super::Miss {}
|
RayGeneration,
|
||||||
impl Sealed for super::AnyHit {}
|
ClosestHit,
|
||||||
impl Sealed for super::Intersection {}
|
Miss,
|
||||||
|
AnyHit,
|
||||||
|
Intersection,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<u8> for ShaderType {
|
||||||
|
fn from(value: u8) -> Self {
|
||||||
|
match value {
|
||||||
|
0 => Self::None,
|
||||||
|
1 => Self::Vertex,
|
||||||
|
2 => Self::Fragment,
|
||||||
|
3 => Self::Geometry,
|
||||||
|
4 => Self::TesselationControl,
|
||||||
|
5 => Self::TesselationEvaluation,
|
||||||
|
6 => Self::Compute,
|
||||||
|
7 => Self::RayGeneration,
|
||||||
|
8 => Self::ClosestHit,
|
||||||
|
9 => Self::Miss,
|
||||||
|
10 => Self::AnyHit,
|
||||||
|
11 => Self::Intersection,
|
||||||
|
|
||||||
|
_ => panic!("can't convert ShaderType from {}", value),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait ShaderType: sealed::Sealed {}
|
impl Default for ShaderType {
|
||||||
|
fn default() -> Self {
|
||||||
pub struct Vertex;
|
ShaderType::None
|
||||||
impl ShaderType for Vertex {}
|
}
|
||||||
|
|
||||||
pub struct Fragment;
|
|
||||||
impl ShaderType for Fragment {}
|
|
||||||
|
|
||||||
pub struct Geometry;
|
|
||||||
impl ShaderType for Geometry {}
|
|
||||||
|
|
||||||
pub struct TesselationControl;
|
|
||||||
impl ShaderType for TesselationControl {}
|
|
||||||
|
|
||||||
pub struct TesselationEvaluation;
|
|
||||||
impl ShaderType for TesselationEvaluation {}
|
|
||||||
|
|
||||||
pub struct Compute;
|
|
||||||
impl ShaderType for Compute {}
|
|
||||||
|
|
||||||
pub struct RayGeneration;
|
|
||||||
impl ShaderType for RayGeneration {}
|
|
||||||
|
|
||||||
pub struct ClosestHit;
|
|
||||||
impl ShaderType for ClosestHit {}
|
|
||||||
|
|
||||||
pub struct Miss;
|
|
||||||
impl ShaderType for Miss {}
|
|
||||||
|
|
||||||
pub struct AnyHit;
|
|
||||||
impl ShaderType for AnyHit {}
|
|
||||||
|
|
||||||
pub struct Intersection;
|
|
||||||
impl ShaderType for Intersection {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait VertexInputDescription: ReprC + Sized {
|
pub trait VertexInputDescription: ReprC + Sized {
|
||||||
|
@ -77,7 +69,7 @@ pub trait PipelineStageInfo {
|
||||||
|
|
||||||
macro_rules! impl_pipeline_stage_info {
|
macro_rules! impl_pipeline_stage_info {
|
||||||
($func:ident, $type:ident) => {
|
($func:ident, $type:ident) => {
|
||||||
impl PipelineStageInfo for ShaderModule<$type> {
|
impl PipelineStageInfo for ShaderModule<{ ShaderType::$type as u8 }> {
|
||||||
fn pipeline_stage_info(&self) -> VkPipelineShaderStageCreateInfo {
|
fn pipeline_stage_info(&self) -> VkPipelineShaderStageCreateInfo {
|
||||||
VkPipelineShaderStageCreateInfo::$func(self.shader_module)
|
VkPipelineShaderStageCreateInfo::$func(self.shader_module)
|
||||||
}
|
}
|
||||||
|
@ -86,30 +78,25 @@ macro_rules! impl_pipeline_stage_info {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ShaderModule<ShaderModuleType: ShaderType> {
|
pub struct ShaderModule<const TYPE: u8> {
|
||||||
t: PhantomData<ShaderModuleType>,
|
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
shader_module: VkShaderModule,
|
shader_module: VkShaderModule,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<ShaderModuleType: ShaderType> ShaderModule<ShaderModuleType> {
|
impl<const TYPE: u8> ShaderModule<TYPE> {
|
||||||
pub fn new(device: Arc<Device>, path: &str) -> Result<Arc<ShaderModule<ShaderModuleType>>> {
|
pub fn new(device: Arc<Device>, path: &str) -> Result<Arc<ShaderModule<TYPE>>> {
|
||||||
let code = Self::shader_code(path)?;
|
let code = Self::shader_code(path)?;
|
||||||
|
|
||||||
Self::from_slice(device, code.as_slice())
|
Self::from_slice(device, code.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_slice(
|
pub fn from_slice(device: Arc<Device>, code: &[u8]) -> Result<Arc<ShaderModule<TYPE>>> {
|
||||||
device: Arc<Device>,
|
|
||||||
code: &[u8],
|
|
||||||
) -> Result<Arc<ShaderModule<ShaderModuleType>>> {
|
|
||||||
let shader_module_ci =
|
let shader_module_ci =
|
||||||
VkShaderModuleCreateInfo::new(VK_SHADER_MODULE_CREATE_NULL_BIT, code);
|
VkShaderModuleCreateInfo::new(VK_SHADER_MODULE_CREATE_NULL_BIT, code);
|
||||||
|
|
||||||
let shader_module = device.create_shader_module(&shader_module_ci)?;
|
let shader_module = device.create_shader_module(&shader_module_ci)?;
|
||||||
|
|
||||||
Ok(Arc::new(ShaderModule {
|
Ok(Arc::new(ShaderModule {
|
||||||
t: PhantomData,
|
|
||||||
device,
|
device,
|
||||||
shader_module,
|
shader_module,
|
||||||
}))
|
}))
|
||||||
|
@ -129,8 +116,6 @@ impl<ShaderModuleType: ShaderType> ShaderModule<ShaderModuleType> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use shader_type::*;
|
|
||||||
|
|
||||||
impl_pipeline_stage_info!(vertex, Vertex);
|
impl_pipeline_stage_info!(vertex, Vertex);
|
||||||
impl_pipeline_stage_info!(geometry, Geometry);
|
impl_pipeline_stage_info!(geometry, Geometry);
|
||||||
impl_pipeline_stage_info!(tesselation_control, TesselationControl);
|
impl_pipeline_stage_info!(tesselation_control, TesselationControl);
|
||||||
|
@ -143,15 +128,15 @@ impl_pipeline_stage_info!(closest_hit, ClosestHit);
|
||||||
impl_pipeline_stage_info!(ray_generation, RayGeneration);
|
impl_pipeline_stage_info!(ray_generation, RayGeneration);
|
||||||
impl_pipeline_stage_info!(miss, Miss);
|
impl_pipeline_stage_info!(miss, Miss);
|
||||||
|
|
||||||
impl<ShaderModuleType: ShaderType> VulkanDevice for ShaderModule<ShaderModuleType> {
|
impl<const TYPE: u8> VulkanDevice for ShaderModule<TYPE> {
|
||||||
fn device(&self) -> &Arc<Device> {
|
fn device(&self) -> &Arc<Device> {
|
||||||
&self.device
|
&self.device
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_vk_handle!(ShaderModule<ShaderModuleType: ShaderType,>, VkShaderModule, shader_module);
|
impl_vk_handle!(ShaderModule<const TYPE: u8,>, VkShaderModule, shader_module);
|
||||||
|
|
||||||
impl<ShaderModuleType: ShaderType> Drop for ShaderModule<ShaderModuleType> {
|
impl<const TYPE: u8> Drop for ShaderModule<TYPE> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.device.destroy_shader_module(self.shader_module);
|
self.device.destroy_shader_module(self.shader_module);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,15 +50,11 @@ impl Swapchain {
|
||||||
image_usage: impl Into<VkImageUsageFlagBits>,
|
image_usage: impl Into<VkImageUsageFlagBits>,
|
||||||
prefered_format: VkFormat,
|
prefered_format: VkFormat,
|
||||||
array_layers: u32,
|
array_layers: u32,
|
||||||
window_size: (u32, u32),
|
|
||||||
) -> Result<Arc<Swapchain>> {
|
) -> Result<Arc<Swapchain>> {
|
||||||
let surface_caps = surface.capabilities(&device)?;
|
let surface_caps = surface.capabilities(&device)?;
|
||||||
|
|
||||||
let extent = if surface_caps.currentExtent.width == u32::max_value() {
|
let extent = if surface_caps.currentExtent.width == u32::max_value() {
|
||||||
VkExtent2D {
|
return Err(anyhow::Error::msg("Surface has no extent"));
|
||||||
width: window_size.0,
|
|
||||||
height: window_size.1,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
VkExtent2D {
|
VkExtent2D {
|
||||||
width: surface_caps.currentExtent.width,
|
width: surface_caps.currentExtent.width,
|
||||||
|
@ -182,7 +178,7 @@ impl Swapchain {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recreate(&self, window_size: (u32, u32)) -> Result<()> {
|
pub fn recreate(&self) -> Result<()> {
|
||||||
// wait for the device to get idle
|
// wait for the device to get idle
|
||||||
self.device.wait_idle()?;
|
self.device.wait_idle()?;
|
||||||
|
|
||||||
|
@ -191,10 +187,7 @@ impl Swapchain {
|
||||||
let extent = if surface_caps.currentExtent.width == u32::max_value()
|
let extent = if surface_caps.currentExtent.width == u32::max_value()
|
||||||
|| surface_caps.currentExtent.height == u32::max_value()
|
|| surface_caps.currentExtent.height == u32::max_value()
|
||||||
{
|
{
|
||||||
VkExtent2D {
|
return Err(anyhow::Error::msg("Surface has no extent"));
|
||||||
width: window_size.0,
|
|
||||||
height: window_size.1,
|
|
||||||
}
|
|
||||||
} else if surface_caps.currentExtent.width == 0 || surface_caps.currentExtent.height == 0 {
|
} else if surface_caps.currentExtent.width == 0 || surface_caps.currentExtent.height == 0 {
|
||||||
// don't recreate swapchain
|
// don't recreate swapchain
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
@ -8,5 +8,5 @@ edition = "2021"
|
||||||
library_loader = { path = "../library_loader" }
|
library_loader = { path = "../library_loader" }
|
||||||
paste = "1.0.14"
|
paste = "1.0.14"
|
||||||
shared_library = "0.1.9"
|
shared_library = "0.1.9"
|
||||||
anyhow = { version = "1.0.82", features = ["backtrace"] }
|
anyhow = { version = "1.0.81", features = ["backtrace"] }
|
||||||
utilities = { git = "https://gavania.de/hodasemi/utilities.git" }
|
utilities = { git = "https://gavania.de/hodasemi/utilities.git" }
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub enum VkSampleCountFlags {
|
||||||
impl From<u32> for VkSampleCountFlags {
|
impl From<u32> for VkSampleCountFlags {
|
||||||
fn from(n: u32) -> Self {
|
fn from(n: u32) -> Self {
|
||||||
match n {
|
match n {
|
||||||
0 | 1 => Self::VK_SAMPLE_COUNT_1_BIT,
|
1 => Self::VK_SAMPLE_COUNT_1_BIT,
|
||||||
2 => Self::VK_SAMPLE_COUNT_2_BIT,
|
2 => Self::VK_SAMPLE_COUNT_2_BIT,
|
||||||
4 => Self::VK_SAMPLE_COUNT_4_BIT,
|
4 => Self::VK_SAMPLE_COUNT_4_BIT,
|
||||||
8 => Self::VK_SAMPLE_COUNT_8_BIT,
|
8 => Self::VK_SAMPLE_COUNT_8_BIT,
|
||||||
|
|
|
@ -29,8 +29,12 @@ pub use super::computepipelinecreateinfo::*;
|
||||||
pub use super::copydescriptorset::*;
|
pub use super::copydescriptorset::*;
|
||||||
pub use super::debugreportcallbackcreateinfoext::*;
|
pub use super::debugreportcallbackcreateinfoext::*;
|
||||||
pub use super::debugutilmessengercallbackdataext::*;
|
pub use super::debugutilmessengercallbackdataext::*;
|
||||||
|
pub use super::debugutilmessengercallbackdataext::*;
|
||||||
|
pub use super::debugutilslabelext::*;
|
||||||
pub use super::debugutilslabelext::*;
|
pub use super::debugutilslabelext::*;
|
||||||
pub use super::debugutilsmessengercreateinfoext::*;
|
pub use super::debugutilsmessengercreateinfoext::*;
|
||||||
|
pub use super::debugutilsmessengercreateinfoext::*;
|
||||||
|
pub use super::debugutilsobjectnameinfoext::*;
|
||||||
pub use super::debugutilsobjectnameinfoext::*;
|
pub use super::debugutilsobjectnameinfoext::*;
|
||||||
pub use super::descriptorbufferinfo::*;
|
pub use super::descriptorbufferinfo::*;
|
||||||
pub use super::descriptorimageinfo::*;
|
pub use super::descriptorimageinfo::*;
|
||||||
|
@ -69,6 +73,7 @@ pub use super::imagesubresourcelayers::*;
|
||||||
pub use super::imagesubresourcerange::*;
|
pub use super::imagesubresourcerange::*;
|
||||||
pub use super::imageviewcreateinfo::*;
|
pub use super::imageviewcreateinfo::*;
|
||||||
pub use super::instancecreateinfo::*;
|
pub use super::instancecreateinfo::*;
|
||||||
|
pub use super::instancecreateinfo::*;
|
||||||
pub use super::iossurfacecreateinfomvk::*;
|
pub use super::iossurfacecreateinfomvk::*;
|
||||||
pub use super::layerproperties::*;
|
pub use super::layerproperties::*;
|
||||||
pub use super::macossurfacecreateinfomvk::*;
|
pub use super::macossurfacecreateinfomvk::*;
|
||||||
|
@ -84,6 +89,7 @@ pub use super::mvkswapchainperformance::*;
|
||||||
pub use super::offset2d::*;
|
pub use super::offset2d::*;
|
||||||
pub use super::offset3d::*;
|
pub use super::offset3d::*;
|
||||||
pub use super::physicaldevicefeatures::*;
|
pub use super::physicaldevicefeatures::*;
|
||||||
|
pub use super::physicaldevicefeatures::*;
|
||||||
pub use super::physicaldevicelimits::*;
|
pub use super::physicaldevicelimits::*;
|
||||||
pub use super::physicaldevicemaintanence3properties::*;
|
pub use super::physicaldevicemaintanence3properties::*;
|
||||||
pub use super::physicaldevicememoryproperties::*;
|
pub use super::physicaldevicememoryproperties::*;
|
||||||
|
|
Loading…
Reference in a new issue