Browse Source

contain descriptor information better

master
Alison Watson 11 months ago
parent
commit
cdfe400a00
  1. 150
      fw/render.rs

150
fw/render.rs

@ -612,22 +612,7 @@ impl StaticData {
stkvec_r![<[_; 8]> unsafe { self.new_buf(&Buf::BON) }; n_sc_imgs]?;
// create the descriptor pool
let size_info = [
vk::DescriptorPoolSize {
ty: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: n_sc_imgs.cast(),
},
vk::DescriptorPoolSize {
ty: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: n_sc_imgs.cast(),
},
/*
vk::DescriptorPoolSize {
ty: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
descriptor_count: n_sc_imgs.cast(),
},
*/
];
let size_info = get_desc_pool_sizes(n_sc_imgs.cast());
let create_info = vk::DescriptorPoolCreateInfo {
pool_size_count: size_info.len().cast(),
@ -659,34 +644,9 @@ impl StaticData {
ufm_bufs.iter(),
bon_bufs.iter(),
)) {
write_descriptors.push(vk::WriteDescriptorSet {
dst_set,
dst_binding: BIND_IDEN_UFM,
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: 1,
p_buffer_info: &ufm.info,
..Default::default()
});
write_descriptors.push(vk::WriteDescriptorSet {
dst_set,
dst_binding: BIND_IDEN_BON,
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: 1,
p_buffer_info: &bon.info,
..Default::default()
});
/*
write_descriptors.push(vk::WriteDescriptorSet {
dst_set,
dst_binding: BIND_IDEN_SMP,
descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
descriptor_count: 1,
p_image_info: &infos.2,
..Default::default()
});
*/
write_descriptors.extend_from_slice(&get_write_descriptors(
dst_set, &ufm.info, &bon.info,
));
}
unsafe { self.dev.update_descriptor_sets(&write_descriptors, &[]) };
@ -701,25 +661,23 @@ impl StaticData {
let cmd_bufs =
unsafe { self.dev.allocate_command_buffers(&create_info)? };
let clear_values = [
vk::ClearValue {
color: vk::ClearColorValue { float32: [0.101, 0.078, 0.113, 1.0] },
},
vk::ClearValue {
depth_stencil: vk::ClearDepthStencilValue {
depth: 1.0,
stencil: 0,
},
},
];
for (&buf, &framebuffer, &set) in crate::iter::ClosedZip((
cmd_bufs.iter(),
framebuffers.iter(),
desc_sets.iter(),
)) {
let clear_values = [
vk::ClearValue {
color: vk::ClearColorValue {
float32: [0.086, 0.098, 0.149, 1.0],
},
},
vk::ClearValue {
depth_stencil: vk::ClearDepthStencilValue {
depth: 1.0,
stencil: 0,
},
},
];
let begin_info = vk::RenderPassBeginInfo {
render_pass,
framebuffer,
@ -1199,20 +1157,23 @@ struct BufferInfo {
props: vk::MemoryPropertyFlags,
}
const BIND_IDEN_UFM: u32 = 0;
const BIND_IDEN_BON: u32 = 1;
//const BIND_IDEN_SMP: u32 = 2;
#[repr(u32)]
enum BindIden {
Ufm = 0,
Bon,
//Smp,
}
const BIND_DESC: [vk::DescriptorSetLayoutBinding; 2] = [
const BIND_DESC: &[vk::DescriptorSetLayoutBinding] = &[
vk::DescriptorSetLayoutBinding {
binding: BIND_IDEN_UFM,
binding: BindIden::Ufm as u32,
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: 1,
stage_flags: vk::ShaderStageFlags::VERTEX,
p_immutable_samplers: std::ptr::null(),
},
vk::DescriptorSetLayoutBinding {
binding: BIND_IDEN_BON,
binding: BindIden::Bon as u32,
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: 1,
stage_flags: vk::ShaderStageFlags::VERTEX,
@ -1220,7 +1181,7 @@ const BIND_DESC: [vk::DescriptorSetLayoutBinding; 2] = [
},
/*
vk::DescriptorSetLayoutBinding {
binding: BIND_IDEN_SMP,
binding: BindIden::Smp as u32,
descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
descriptor_count: 1,
stage_flags: vk::ShaderStageFlags::FRAGMENT,
@ -1229,14 +1190,67 @@ const BIND_DESC: [vk::DescriptorSetLayoutBinding; 2] = [
*/
];
const VTX_BIND_DESC: [vk::VertexInputBindingDescription; 1] =
[vk::VertexInputBindingDescription {
const fn get_desc_pool_sizes(n_sc_imgs: u32) -> [vk::DescriptorPoolSize; 2] {
[
vk::DescriptorPoolSize {
ty: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: n_sc_imgs,
},
vk::DescriptorPoolSize {
ty: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: n_sc_imgs,
},
/*
vk::DescriptorPoolSize {
ty: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
descriptor_count: n_sc_imgs,
},
*/
]
}
fn get_write_descriptors(
dst_set: vk::DescriptorSet, ufm_buf_info: &vk::DescriptorBufferInfo,
bon_buf_info: &vk::DescriptorBufferInfo, /*, smp_img_info: vk::DescriptorImageInfo*/
) -> [vk::WriteDescriptorSet; 2] {
[
vk::WriteDescriptorSet {
dst_set,
dst_binding: BindIden::Ufm as u32,
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: 1,
p_buffer_info: ufm_buf_info,
..Default::default()
},
vk::WriteDescriptorSet {
dst_set,
dst_binding: BindIden::Bon as u32,
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: 1,
p_buffer_info: bon_buf_info,
..Default::default()
},
/*
vk::WriteDescriptorSet {
dst_set,
dst_binding: BindIden::Smp as u32,
descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
descriptor_count: 1,
p_image_info: smp_img_info,
..Default::default()
},
*/
]
}
const VTX_BIND_DESC: &[vk::VertexInputBindingDescription] =
&[vk::VertexInputBindingDescription {
binding: 0,
stride: size_of::<Vertex>() as u32,
input_rate: vk::VertexInputRate::VERTEX,
}];
const VTX_ATTR_DESC: [vk::VertexInputAttributeDescription; 7] = [
const VTX_ATTR_DESC: &[vk::VertexInputAttributeDescription] = &[
vk::VertexInputAttributeDescription {
location: Vertex::FIELDS.pos.indx as u32,
binding: 0,

Loading…
Cancel
Save