Merge branch 'master' of ssh://gavania.de:23/hodasemi/vulkan_lib
This commit is contained in:
commit
520d1c4cf6
7 changed files with 76 additions and 5 deletions
|
@ -7,4 +7,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.160", features = ["derive"] }
|
||||
serde = { version = "1.0.162", features = ["derive"] }
|
||||
|
|
|
@ -9,7 +9,7 @@ build = "build.rs"
|
|||
|
||||
[dependencies]
|
||||
vulkan-sys = { path = "../vulkan-sys" }
|
||||
anyhow = { version = "1.0.70", features = ["backtrace"] }
|
||||
anyhow = { version = "1.0.71", features = ["backtrace"] }
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0.79"
|
|
@ -8,6 +8,6 @@ edition = "2021"
|
|||
image = "0.24.6"
|
||||
vulkan-sys = { path = "../vulkan-sys" }
|
||||
vma-rs = { path = "../vma-rs" }
|
||||
anyhow = { version = "1.0.70", features = ["backtrace"] }
|
||||
anyhow = { version = "1.0.71", features = ["backtrace"] }
|
||||
assetpath = { path = "../assetpath" }
|
||||
utilities = { git = "https://gavania.de/hodasemi/utilities.git" }
|
||||
|
|
|
@ -72,7 +72,7 @@ impl DescriptorPoolBuilder {
|
|||
pub struct DescriptorPool {
|
||||
device: Arc<Device>,
|
||||
descriptor_pool: VkDescriptorPool,
|
||||
descriptor_set_layout: Arc<DescriptorSetLayout>,
|
||||
pub(crate) descriptor_set_layout: Arc<DescriptorSetLayout>,
|
||||
}
|
||||
|
||||
impl DescriptorPool {
|
||||
|
|
|
@ -266,6 +266,24 @@ impl DescriptorSet {
|
|||
pub fn update(&self, writes: &[DescriptorWrite]) -> Result<()> {
|
||||
debug_assert!(!writes.is_empty());
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
assert!(writes.len() <= self.pool.descriptor_set_layout.bindings().len());
|
||||
|
||||
for (i, binding) in self
|
||||
.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut vk_writes = Vec::new();
|
||||
let mut handles_lock = self.handles.lock().unwrap();
|
||||
|
||||
|
|
|
@ -70,6 +70,12 @@ impl DescriptorSetLayoutBuilder {
|
|||
*/
|
||||
}
|
||||
|
||||
let bindings = self
|
||||
.layout_bindings
|
||||
.iter()
|
||||
.map(|b| DescriptorLayoutBinding::from(b.clone()))
|
||||
.collect();
|
||||
|
||||
let descriptor_set_layout = device.create_descriptor_set_layout(&descriptor_set_ci)?;
|
||||
|
||||
let pool_sizes = self
|
||||
|
@ -85,6 +91,8 @@ impl DescriptorSetLayoutBuilder {
|
|||
device,
|
||||
descriptor_set_layout,
|
||||
pool_sizes,
|
||||
|
||||
bindings,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -94,6 +102,8 @@ pub struct DescriptorSetLayout {
|
|||
device: Arc<Device>,
|
||||
descriptor_set_layout: VkDescriptorSetLayout,
|
||||
pool_sizes: Vec<VkDescriptorPoolSize>,
|
||||
|
||||
bindings: Vec<DescriptorLayoutBinding>,
|
||||
}
|
||||
|
||||
impl DescriptorSetLayout {
|
||||
|
@ -108,6 +118,10 @@ impl DescriptorSetLayout {
|
|||
pub(crate) fn pool_sizes(&self) -> &[VkDescriptorPoolSize] {
|
||||
self.pool_sizes.as_slice()
|
||||
}
|
||||
|
||||
pub fn bindings(&self) -> &[DescriptorLayoutBinding] {
|
||||
&self.bindings
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanDevice for DescriptorSetLayout {
|
||||
|
@ -128,3 +142,42 @@ impl Drop for DescriptorSetLayout {
|
|||
.destroy_descriptor_set_layout(self.descriptor_set_layout);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DescriptorLayoutBinding {
|
||||
pub binding: u32,
|
||||
pub desc_type: VkDescriptorType,
|
||||
pub stage_flags: Vec<VkShaderStageFlags>,
|
||||
}
|
||||
|
||||
impl From<VkDescriptorSetLayoutBinding> for DescriptorLayoutBinding {
|
||||
fn from(value: VkDescriptorSetLayoutBinding) -> Self {
|
||||
let flag_enum_list = [
|
||||
VK_SHADER_STAGE_VERTEX_BIT,
|
||||
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
|
||||
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
|
||||
VK_SHADER_STAGE_GEOMETRY_BIT,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
VK_SHADER_STAGE_ALL_GRAPHICS,
|
||||
VK_SHADER_STAGE_ALL,
|
||||
VK_SHADER_STAGE_RAYGEN_BIT_KHR,
|
||||
VK_SHADER_STAGE_ANY_HIT_BIT_KHR,
|
||||
VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR,
|
||||
VK_SHADER_STAGE_MISS_BIT_KHR,
|
||||
VK_SHADER_STAGE_INTERSECTION_BIT_KHR,
|
||||
VK_SHADER_STAGE_CALLABLE_BIT_KHR,
|
||||
VK_SHADER_STAGE_TASK_BIT_NV,
|
||||
VK_SHADER_STAGE_MESH_BIT_NV,
|
||||
];
|
||||
|
||||
Self {
|
||||
binding: value.binding,
|
||||
desc_type: value.descriptorType,
|
||||
stage_flags: flag_enum_list
|
||||
.into_iter()
|
||||
.filter(|&flag| (flag & value.stageFlagBits) != 0)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@ edition = "2021"
|
|||
library_loader = { path = "../library_loader" }
|
||||
paste = "1.0.12"
|
||||
shared_library = "0.1.9"
|
||||
anyhow = { version = "1.0.70", features = ["backtrace"] }
|
||||
anyhow = { version = "1.0.71", features = ["backtrace"] }
|
||||
utilities = { git = "https://gavania.de/hodasemi/utilities.git" }
|
||||
|
|
Loading…
Reference in a new issue