ValidationError-ify commands, add some validation to UnsafeCommandBufferBuilder (#2266)

* ValidationError-ify commands, add some validation to `UnsafeCommandBufferBuilder`

* Use `SubpassBeginInfo` for the triangle example
This commit is contained in:
Rua 2023-08-04 20:55:16 +02:00 committed by GitHub
parent 0cb0728776
commit d0144c2d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 17022 additions and 11347 deletions

View File

@ -52,7 +52,7 @@ use vulkano::{
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferImageCopy, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferImageCopy,
ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo,
PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -597,11 +597,13 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
@ -614,10 +616,12 @@ fn main() {
.clone(), .clone(),
), ),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -213,12 +213,14 @@ fn main() {
// anyway). In this example we would avoid cloning them since this is the last time we use // anyway). In this example we would avoid cloning them since this is the last time we use
// them, but in real code you would probably need to clone them. // them, but in real code you would probably need to clone them.
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.dispatch([1024, 1, 1]) .dispatch([1024, 1, 1])
.unwrap(); .unwrap();

View File

@ -20,7 +20,7 @@ use vulkano::{
}, },
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -381,16 +381,19 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
// Draw our buffer // Draw our buffer
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, buffer) .bind_vertex_buffers(0, buffer)
.unwrap()
.draw(num_vertices, 1, 0, 0) .draw(num_vertices, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -11,7 +11,7 @@ use std::sync::Arc;
use vulkano::{ use vulkano::{
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, ClearAttachment, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, ClearAttachment,
ClearRect, CommandBufferUsage, RenderPassBeginInfo, SubpassContents, ClearRect, CommandBufferUsage, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -223,7 +223,7 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
// Clear attachments with clear values and rects information. All the rects will be // Clear attachments with clear values and rects information. All the rects will be
@ -260,7 +260,7 @@ fn main() {
.collect(), .collect(),
) )
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -198,15 +198,20 @@ impl AmbientLightingSystem {
.unwrap(); .unwrap();
builder builder
.set_viewport(0, [viewport].into_iter().collect()) .set_viewport(0, [viewport].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(self.pipeline.clone()) .bind_pipeline_graphics(self.pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
self.pipeline.layout().clone(), self.pipeline.layout().clone(),
0, 0,
descriptor_set, descriptor_set,
) )
.unwrap()
.push_constants(self.pipeline.layout().clone(), 0, push_constants) .push_constants(self.pipeline.layout().clone(), 0, push_constants)
.unwrap()
.bind_vertex_buffers(0, self.vertex_buffer.clone()) .bind_vertex_buffers(0, self.vertex_buffer.clone())
.unwrap()
.draw(self.vertex_buffer.len() as u32, 1, 0, 0) .draw(self.vertex_buffer.len() as u32, 1, 0, 0)
.unwrap(); .unwrap();
builder.build().unwrap() builder.build().unwrap()

View File

@ -212,15 +212,20 @@ impl DirectionalLightingSystem {
.unwrap(); .unwrap();
builder builder
.set_viewport(0, [viewport].into_iter().collect()) .set_viewport(0, [viewport].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(self.pipeline.clone()) .bind_pipeline_graphics(self.pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
self.pipeline.layout().clone(), self.pipeline.layout().clone(),
0, 0,
descriptor_set, descriptor_set,
) )
.unwrap()
.push_constants(self.pipeline.layout().clone(), 0, push_constants) .push_constants(self.pipeline.layout().clone(), 0, push_constants)
.unwrap()
.bind_vertex_buffers(0, self.vertex_buffer.clone()) .bind_vertex_buffers(0, self.vertex_buffer.clone())
.unwrap()
.draw(self.vertex_buffer.len() as u32, 1, 0, 0) .draw(self.vertex_buffer.len() as u32, 1, 0, 0)
.unwrap(); .unwrap();
builder.build().unwrap() builder.build().unwrap()

View File

@ -225,15 +225,20 @@ impl PointLightingSystem {
.unwrap(); .unwrap();
builder builder
.set_viewport(0, [viewport].into_iter().collect()) .set_viewport(0, [viewport].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(self.pipeline.clone()) .bind_pipeline_graphics(self.pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
self.pipeline.layout().clone(), self.pipeline.layout().clone(),
0, 0,
descriptor_set, descriptor_set,
) )
.unwrap()
.push_constants(self.pipeline.layout().clone(), 0, push_constants) .push_constants(self.pipeline.layout().clone(), 0, push_constants)
.unwrap()
.bind_vertex_buffers(0, self.vertex_buffer.clone()) .bind_vertex_buffers(0, self.vertex_buffer.clone())
.unwrap()
.draw(self.vertex_buffer.len() as u32, 1, 0, 0) .draw(self.vertex_buffer.len() as u32, 1, 0, 0)
.unwrap(); .unwrap();
builder.build().unwrap() builder.build().unwrap()

View File

@ -18,7 +18,7 @@ use vulkano::{
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
PrimaryAutoCommandBuffer, RenderPassBeginInfo, SecondaryCommandBufferAbstract, PrimaryAutoCommandBuffer, RenderPassBeginInfo, SecondaryCommandBufferAbstract,
SubpassContents, SubpassBeginInfo, SubpassContents,
}, },
descriptor_set::allocator::StandardDescriptorSetAllocator, descriptor_set::allocator::StandardDescriptorSetAllocator,
device::Queue, device::Queue,
@ -363,7 +363,10 @@ impl FrameSystem {
], ],
..RenderPassBeginInfo::framebuffer(framebuffer.clone()) ..RenderPassBeginInfo::framebuffer(framebuffer.clone())
}, },
SubpassContents::SecondaryCommandBuffers, SubpassBeginInfo {
contents: SubpassContents::SecondaryCommandBuffers,
..Default::default()
},
) )
.unwrap(); .unwrap();
@ -428,7 +431,13 @@ impl<'a> Frame<'a> {
self.command_buffer_builder self.command_buffer_builder
.as_mut() .as_mut()
.unwrap() .unwrap()
.next_subpass(SubpassContents::SecondaryCommandBuffers) .next_subpass(
Default::default(),
SubpassBeginInfo {
contents: SubpassContents::SecondaryCommandBuffers,
..Default::default()
},
)
.unwrap(); .unwrap();
// And returning an object that will allow the user to apply lighting to the scene. // And returning an object that will allow the user to apply lighting to the scene.
@ -442,7 +451,7 @@ impl<'a> Frame<'a> {
self.command_buffer_builder self.command_buffer_builder
.as_mut() .as_mut()
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = self.command_buffer_builder.take().unwrap().build().unwrap(); let command_buffer = self.command_buffer_builder.take().unwrap().build().unwrap();

View File

@ -151,8 +151,11 @@ impl TriangleDrawSystem {
.into_iter() .into_iter()
.collect(), .collect(),
) )
.unwrap()
.bind_pipeline_graphics(self.pipeline.clone()) .bind_pipeline_graphics(self.pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, self.vertex_buffer.clone()) .bind_vertex_buffers(0, self.vertex_buffer.clone())
.unwrap()
.draw(self.vertex_buffer.len() as u32, 1, 0, 0) .draw(self.vertex_buffer.len() as u32, 1, 0, 0)
.unwrap(); .unwrap();
builder.build().unwrap() builder.build().unwrap()

View File

@ -250,12 +250,14 @@ fn main() {
#[allow(clippy::erasing_op, clippy::identity_op)] #[allow(clippy::erasing_op, clippy::identity_op)]
builder builder
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set.clone().offsets([0 * align as u32]), set.clone().offsets([0 * align as u32]),
) )
.unwrap()
.dispatch([12, 1, 1]) .dispatch([12, 1, 1])
.unwrap() .unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
@ -264,6 +266,7 @@ fn main() {
0, 0,
set.clone().offsets([1 * align as u32]), set.clone().offsets([1 * align as u32]),
) )
.unwrap()
.dispatch([12, 1, 1]) .dispatch([12, 1, 1])
.unwrap() .unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
@ -272,6 +275,7 @@ fn main() {
0, 0,
set.offsets([2 * align as u32]), set.offsets([2 * align as u32]),
) )
.unwrap()
.dispatch([12, 1, 1]) .dispatch([12, 1, 1])
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -260,12 +260,14 @@ fn main() {
.unwrap(); .unwrap();
builder builder
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
// Note that dispatch dimensions must be proportional to the local size. // Note that dispatch dimensions must be proportional to the local size.
.dispatch([1024 / local_size_x, 1024 / local_size_y, 1]) .dispatch([1024 / local_size_x, 1024 / local_size_y, 1])
.unwrap() .unwrap()

View File

@ -18,7 +18,6 @@ mod linux {
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder,
CommandBufferUsage, RenderPassBeginInfo, SemaphoreSubmitInfo, SubmitInfo, CommandBufferUsage, RenderPassBeginInfo, SemaphoreSubmitInfo, SubmitInfo,
SubpassContents,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -378,21 +377,25 @@ mod linux {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set.clone(), set.clone(),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -14,7 +14,6 @@ use vulkano::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BlitImageInfo, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BlitImageInfo,
BufferImageCopy, ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, BufferImageCopy, ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo,
CopyImageInfo, ImageBlit, ImageCopy, PrimaryCommandBufferAbstract, RenderPassBeginInfo, CopyImageInfo, ImageBlit, ImageCopy, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
SubpassContents,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -471,21 +470,25 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set.clone(), set.clone(),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -12,7 +12,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -418,21 +418,25 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set.clone(), set.clone(),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -21,7 +21,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -439,21 +439,25 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set.clone(), set.clone(),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -31,7 +31,7 @@ use vulkano::{
}, },
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
DrawIndirectCommand, RenderPassBeginInfo, SubpassContents, DrawIndirectCommand, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -474,12 +474,14 @@ fn main() {
// vertices and fill out the draw call arguments. // vertices and fill out the draw call arguments.
builder builder
.bind_pipeline_compute(compute_pipeline.clone()) .bind_pipeline_compute(compute_pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
compute_pipeline.layout().clone(), compute_pipeline.layout().clone(),
0, 0,
cs_desciptor_set, cs_desciptor_set,
) )
.unwrap()
.dispatch([1, 1, 1]) .dispatch([1, 1, 1])
.unwrap() .unwrap()
.begin_render_pass( .begin_render_pass(
@ -489,17 +491,20 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(render_pipeline.clone()) .bind_pipeline_graphics(render_pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, vertices) .bind_vertex_buffers(0, vertices)
.unwrap()
// The indirect draw call is placed in the command buffer with a reference to // The indirect draw call is placed in the command buffer with a reference to
// the buffer that will contain the arguments for the draw. // the buffer that will contain the arguments for the draw.
.draw_indirect(indirect_buffer) .draw_indirect(indirect_buffer)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -17,7 +17,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -415,13 +415,16 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
// We pass both our lists of vertices here. // We pass both our lists of vertices here.
.bind_vertex_buffers(0, (vertex_buffer.clone(), instance_buffer.clone())) .bind_vertex_buffers(0, (vertex_buffer.clone(), instance_buffer.clone()))
.unwrap()
.draw( .draw(
vertex_buffer.len() as u32, vertex_buffer.len() as u32,
instance_buffer.len() as u32, instance_buffer.len() as u32,
@ -429,7 +432,7 @@ fn main() {
0, 0,
) )
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -175,8 +175,11 @@ impl FractalComputePipeline {
}; };
builder builder
.bind_pipeline_compute(self.pipeline.clone()) .bind_pipeline_compute(self.pipeline.clone())
.unwrap()
.bind_descriptor_sets(PipelineBindPoint::Compute, pipeline_layout.clone(), 0, set) .bind_descriptor_sets(PipelineBindPoint::Compute, pipeline_layout.clone(), 0, set)
.unwrap()
.push_constants(pipeline_layout.clone(), 0, push_constants) .push_constants(pipeline_layout.clone(), 0, push_constants)
.unwrap()
.dispatch([image_extent[0] / 8, image_extent[1] / 8, 1]) .dispatch([image_extent[0] / 8, image_extent[1] / 8, 1])
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -228,15 +228,20 @@ impl PixelsDrawPipeline {
.into_iter() .into_iter()
.collect(), .collect(),
) )
.unwrap()
.bind_pipeline_graphics(self.pipeline.clone()) .bind_pipeline_graphics(self.pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
self.pipeline.layout().clone(), self.pipeline.layout().clone(),
0, 0,
desc_set, desc_set,
) )
.unwrap()
.bind_vertex_buffers(0, self.vertices.clone()) .bind_vertex_buffers(0, self.vertices.clone())
.unwrap()
.bind_index_buffer(self.indices.clone()) .bind_index_buffer(self.indices.clone())
.unwrap()
.draw_indexed(self.indices.len() as u32, 1, 0, 0, 0) .draw_indexed(self.indices.len() as u32, 1, 0, 0, 0)
.unwrap(); .unwrap();
builder.build().unwrap() builder.build().unwrap()

View File

@ -12,7 +12,7 @@ use std::sync::Arc;
use vulkano::{ use vulkano::{
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
}, },
descriptor_set::allocator::StandardDescriptorSetAllocator, descriptor_set::allocator::StandardDescriptorSetAllocator,
device::Queue, device::Queue,
@ -111,7 +111,10 @@ impl RenderPassPlaceOverFrame {
clear_values: vec![Some([0.0; 4].into())], clear_values: vec![Some([0.0; 4].into())],
..RenderPassBeginInfo::framebuffer(framebuffer) ..RenderPassBeginInfo::framebuffer(framebuffer)
}, },
SubpassContents::SecondaryCommandBuffers, SubpassBeginInfo {
contents: SubpassContents::SecondaryCommandBuffers,
..Default::default()
},
) )
.unwrap(); .unwrap();
@ -122,7 +125,9 @@ impl RenderPassPlaceOverFrame {
command_buffer_builder.execute_commands(cb).unwrap(); command_buffer_builder.execute_commands(cb).unwrap();
// End render pass. // End render pass.
command_buffer_builder.end_render_pass().unwrap(); command_buffer_builder
.end_render_pass(Default::default())
.unwrap();
// Build command buffer. // Build command buffer.
let command_buffer = command_buffer_builder.build().unwrap(); let command_buffer = command_buffer_builder.build().unwrap();

View File

@ -67,7 +67,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
CopyImageToBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, CopyImageToBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -394,15 +394,18 @@ fn main() {
clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into()), None], clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into()), None],
..RenderPassBeginInfo::framebuffer(framebuffer) ..RenderPassBeginInfo::framebuffer(framebuffer)
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport].into_iter().collect()) .set_viewport(0, [viewport].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline) .bind_pipeline_graphics(pipeline)
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap() .unwrap()
.copy_image_to_buffer(CopyImageToBufferInfo::image_buffer(image, buf.clone())) .copy_image_to_buffer(CopyImageToBufferInfo::image_buffer(image, buf.clone()))
.unwrap(); .unwrap();

View File

@ -21,7 +21,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -462,15 +462,18 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -201,8 +201,11 @@ impl GameOfLifeComputePipeline {
}; };
builder builder
.bind_pipeline_compute(self.compute_life_pipeline.clone()) .bind_pipeline_compute(self.compute_life_pipeline.clone())
.unwrap()
.bind_descriptor_sets(PipelineBindPoint::Compute, pipeline_layout.clone(), 0, set) .bind_descriptor_sets(PipelineBindPoint::Compute, pipeline_layout.clone(), 0, set)
.unwrap()
.push_constants(pipeline_layout.clone(), 0, push_constants) .push_constants(pipeline_layout.clone(), 0, push_constants)
.unwrap()
.dispatch([image_extent[0] / 8, image_extent[1] / 8, 1]) .dispatch([image_extent[0] / 8, image_extent[1] / 8, 1])
.unwrap(); .unwrap();
} }

View File

@ -224,15 +224,20 @@ impl PixelsDrawPipeline {
.into_iter() .into_iter()
.collect(), .collect(),
) )
.unwrap()
.bind_pipeline_graphics(self.pipeline.clone()) .bind_pipeline_graphics(self.pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
self.pipeline.layout().clone(), self.pipeline.layout().clone(),
0, 0,
desc_set, desc_set,
) )
.unwrap()
.bind_vertex_buffers(0, self.vertices.clone()) .bind_vertex_buffers(0, self.vertices.clone())
.unwrap()
.bind_index_buffer(self.indices.clone()) .bind_index_buffer(self.indices.clone())
.unwrap()
.draw_indexed(self.indices.len() as u32, 1, 0, 0, 0) .draw_indexed(self.indices.len() as u32, 1, 0, 0, 0)
.unwrap(); .unwrap();
builder.build().unwrap() builder.build().unwrap()

View File

@ -12,7 +12,7 @@ use std::sync::Arc;
use vulkano::{ use vulkano::{
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
}, },
device::Queue, device::Queue,
format::Format, format::Format,
@ -101,7 +101,10 @@ impl RenderPassPlaceOverFrame {
clear_values: vec![Some([0.0; 4].into())], clear_values: vec![Some([0.0; 4].into())],
..RenderPassBeginInfo::framebuffer(framebuffer) ..RenderPassBeginInfo::framebuffer(framebuffer)
}, },
SubpassContents::SecondaryCommandBuffers, SubpassBeginInfo {
contents: SubpassContents::SecondaryCommandBuffers,
..Default::default()
},
) )
.unwrap(); .unwrap();
@ -112,7 +115,9 @@ impl RenderPassPlaceOverFrame {
command_buffer_builder.execute_commands(cb).unwrap(); command_buffer_builder.execute_commands(cb).unwrap();
// End the render pass. // End the render pass.
command_buffer_builder.end_render_pass().unwrap(); command_buffer_builder
.end_render_pass(Default::default())
.unwrap();
// Build the command buffer. // Build the command buffer.
let command_buffer = command_buffer_builder.build().unwrap(); let command_buffer = command_buffer_builder.build().unwrap();

View File

@ -17,7 +17,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferImageCopy, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferImageCopy,
CommandBufferUsage, CopyImageToBufferInfo, RenderPassBeginInfo, SubpassContents, CommandBufferUsage, CopyImageToBufferInfo, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features,
@ -346,14 +346,16 @@ fn main() {
clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into())], clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into())],
..RenderPassBeginInfo::framebuffer(framebuffer) ..RenderPassBeginInfo::framebuffer(framebuffer)
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.bind_pipeline_graphics(pipeline) .bind_pipeline_graphics(pipeline)
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
// Copy the image layers to different buffers to save them as individual images to disk. // Copy the image layers to different buffers to save them as individual images to disk.

View File

@ -16,7 +16,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -436,7 +436,9 @@ fn main() {
.reset_query_pool(query_pool.clone(), 0..3) .reset_query_pool(query_pool.clone(), 0..3)
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.begin_render_pass( .begin_render_pass(
RenderPassBeginInfo { RenderPassBeginInfo {
clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into()), Some(1.0.into())], clear_values: vec![Some([0.0, 0.0, 1.0, 1.0].into()), Some(1.0.into())],
@ -444,7 +446,7 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
// Begin query 0, then draw the red triangle. Enabling the // Begin query 0, then draw the red triangle. Enabling the
@ -458,6 +460,7 @@ fn main() {
) )
.unwrap() .unwrap()
.bind_vertex_buffers(0, triangle1.clone()) .bind_vertex_buffers(0, triangle1.clone())
.unwrap()
.draw(triangle1.len() as u32, 1, 0, 0) .draw(triangle1.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
// End query 0. // End query 0.
@ -467,6 +470,7 @@ fn main() {
.begin_query(query_pool.clone(), 1, QueryControlFlags::empty()) .begin_query(query_pool.clone(), 1, QueryControlFlags::empty())
.unwrap() .unwrap()
.bind_vertex_buffers(0, triangle2.clone()) .bind_vertex_buffers(0, triangle2.clone())
.unwrap()
.draw(triangle2.len() as u32, 1, 0, 0) .draw(triangle2.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_query(query_pool.clone(), 1) .end_query(query_pool.clone(), 1)
@ -475,11 +479,12 @@ fn main() {
.begin_query(query_pool.clone(), 2, QueryControlFlags::empty()) .begin_query(query_pool.clone(), 2, QueryControlFlags::empty())
.unwrap() .unwrap()
.bind_vertex_buffers(0, triangle3.clone()) .bind_vertex_buffers(0, triangle3.clone())
.unwrap()
.draw(triangle3.len() as u32, 1, 0, 0) .draw(triangle3.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_query(query_pool.clone(), 2) .end_query(query_pool.clone(), 2)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
} }

View File

@ -191,13 +191,16 @@ fn main() {
.unwrap(); .unwrap();
builder builder
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.push_constants(pipeline.layout().clone(), 0, push_constants) .push_constants(pipeline.layout().clone(), 0, push_constants)
.unwrap()
.dispatch([1024, 1, 1]) .dispatch([1024, 1, 1])
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -12,7 +12,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet}, descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet},
device::{ device::{
@ -412,11 +412,13 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.push_descriptor_set( .push_descriptor_set(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
@ -425,10 +427,12 @@ fn main() {
.into_iter() .into_iter()
.collect(), .collect(),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -26,7 +26,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -357,15 +357,18 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(graphics_pipeline.clone()) .bind_pipeline_graphics(graphics_pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -12,7 +12,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags, allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags,
@ -547,21 +547,25 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set.clone(), set.clone(),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -186,12 +186,14 @@ fn main() {
}) })
.unwrap() .unwrap()
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.dispatch([1024, 1, 1]) .dispatch([1024, 1, 1])
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -177,12 +177,14 @@ fn main() {
.unwrap(); .unwrap();
builder builder
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.dispatch([1024, 1, 1]) .dispatch([1024, 1, 1])
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -209,13 +209,16 @@ fn main() {
.unwrap(); .unwrap();
builder builder
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.push_constants(pipeline.layout().clone(), 0, parameters) .push_constants(pipeline.layout().clone(), 0, parameters)
.unwrap()
.dispatch([1024, 1, 1]) .dispatch([1024, 1, 1])
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -17,7 +17,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -582,14 +582,17 @@ fn main() {
builder builder
// Push constants for compute shader. // Push constants for compute shader.
.push_constants(compute_pipeline.layout().clone(), 0, push_constants) .push_constants(compute_pipeline.layout().clone(), 0, push_constants)
.unwrap()
// Perform compute operation to update particle positions. // Perform compute operation to update particle positions.
.bind_pipeline_compute(compute_pipeline.clone()) .bind_pipeline_compute(compute_pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
compute_pipeline.layout().clone(), compute_pipeline.layout().clone(),
0, // Bind this descriptor set to index 0. 0, // Bind this descriptor set to index 0.
descriptor_set.clone(), descriptor_set.clone(),
) )
.unwrap()
.dispatch([PARTICLE_COUNT as u32 / 128, 1, 1]) .dispatch([PARTICLE_COUNT as u32 / 128, 1, 1])
.unwrap() .unwrap()
// Use render-pass to draw particles to swapchain. // Use render-pass to draw particles to swapchain.
@ -600,14 +603,16 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.bind_pipeline_graphics(graphics_pipeline.clone()) .bind_pipeline_graphics(graphics_pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(PARTICLE_COUNT as u32, 1, 0, 0) .draw(PARTICLE_COUNT as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -177,12 +177,14 @@ fn main() {
.unwrap(); .unwrap();
builder builder
.bind_pipeline_compute(pipeline.clone()) .bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.dispatch([1024, 1, 1]) .dispatch([1024, 1, 1])
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -17,7 +17,7 @@ use vulkano::{
}, },
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -382,21 +382,25 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.bind_vertex_buffers(0, (vertex_buffer.clone(), normals_buffer.clone())) .bind_vertex_buffers(0, (vertex_buffer.clone(), normals_buffer.clone()))
.unwrap()
.bind_index_buffer(index_buffer.clone()) .bind_index_buffer(index_buffer.clone())
.unwrap()
.draw_indexed(index_buffer.len() as u32, 1, 0, 0, 0) .draw_indexed(index_buffer.len() as u32, 1, 0, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -26,7 +26,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features,
@ -473,15 +473,18 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -12,7 +12,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassContents, CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
@ -429,21 +429,25 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
SubpassContents::Inline, Default::default(),
) )
.unwrap() .unwrap()
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Graphics, PipelineBindPoint::Graphics,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set.clone(), set.clone(),
) )
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
.draw(vertex_buffer.len() as u32, 3, 0, 0) .draw(vertex_buffer.len() as u32, 3, 0, 0)
.unwrap() .unwrap()
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
let command_buffer = builder.build().unwrap(); let command_buffer = builder.build().unwrap();

View File

@ -635,8 +635,11 @@ fn main() {
// //
// TODO: Document state setting and how it affects subsequent draw commands. // TODO: Document state setting and how it affects subsequent draw commands.
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
// We add a draw command. // We add a draw command.
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()

View File

@ -21,7 +21,7 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
RenderPassBeginInfo, SubpassContents, RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
}, },
device::{ device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
@ -618,24 +618,30 @@ fn main() {
framebuffers[image_index as usize].clone(), framebuffers[image_index as usize].clone(),
) )
}, },
// The contents of the first (and only) subpass. This can be either SubpassBeginInfo {
// `Inline` or `SecondaryCommandBuffers`. The latter is a bit more advanced // The contents of the first (and only) subpass.
// and is not covered here. // This can be either `Inline` or `SecondaryCommandBuffers`.
SubpassContents::Inline, // The latter is a bit more advanced and is not covered here.
contents: SubpassContents::Inline,
..Default::default()
},
) )
.unwrap() .unwrap()
// We are now inside the first subpass of the render pass. // We are now inside the first subpass of the render pass.
// //
// TODO: Document state setting and how it affects subsequent draw commands. // TODO: Document state setting and how it affects subsequent draw commands.
.set_viewport(0, [viewport.clone()].into_iter().collect()) .set_viewport(0, [viewport.clone()].into_iter().collect())
.unwrap()
.bind_pipeline_graphics(pipeline.clone()) .bind_pipeline_graphics(pipeline.clone())
.unwrap()
.bind_vertex_buffers(0, vertex_buffer.clone()) .bind_vertex_buffers(0, vertex_buffer.clone())
.unwrap()
// We add a draw command. // We add a draw command.
.draw(vertex_buffer.len() as u32, 1, 0, 0) .draw(vertex_buffer.len() as u32, 1, 0, 0)
.unwrap() .unwrap()
// We leave the render pass. Note that if we had multiple subpasses we could // We leave the render pass. Note that if we had multiple subpasses we could
// have called `next_subpass` to jump to the next subpass. // have called `next_subpass` to jump to the next subpass.
.end_render_pass() .end_render_pass(Default::default())
.unwrap(); .unwrap();
// Finish building the command buffer by calling `build`. // Finish building the command buffer by calling `build`.

View File

@ -129,7 +129,7 @@ fn write_descriptor_binding_requirements(
let image_scalar_type = match image_scalar_type { let image_scalar_type = match image_scalar_type {
Some(image_scalar_type) => { Some(image_scalar_type) => {
let ident = format_ident!("{}", format!("{:?}", image_scalar_type)); let ident = format_ident!("{}", format!("{:?}", image_scalar_type));
quote! { Some(::vulkano::shader::ShaderScalarType::#ident) } quote! { Some(::vulkano::format::NumericType::#ident) }
} }
None => quote! { None }, None => quote! { None },
}; };
@ -305,7 +305,7 @@ fn write_interface(interface: &ShaderInterface) -> TokenStream {
location: #location, location: #location,
component: #component, component: #component,
ty: ::vulkano::shader::ShaderInterfaceEntryType { ty: ::vulkano::shader::ShaderInterfaceEntryType {
base_type: ::vulkano::shader::ShaderScalarType::#base_type, base_type: ::vulkano::format::NumericType::#base_type,
num_components: #num_components, num_components: #num_components,
num_elements: #num_elements, num_elements: #num_elements,
is_64bit: #is_64bit, is_64bit: #is_64bit,

View File

@ -53,9 +53,9 @@ struct FormatMember {
compression: Option<Ident>, compression: Option<Ident>,
planes: Vec<Ident>, planes: Vec<Ident>,
texels_per_block: u8, texels_per_block: u8,
type_color: Option<Ident>, numeric_format_color: Option<Ident>,
type_depth: Option<Ident>, numeric_format_depth: Option<Ident>,
type_stencil: Option<Ident>, numeric_format_stencil: Option<Ident>,
ycbcr_chroma_sampling: Option<Ident>, ycbcr_chroma_sampling: Option<Ident>,
type_std_array: Option<TokenStream>, type_std_array: Option<TokenStream>,
@ -182,31 +182,37 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
}) })
}, },
); );
let type_color_items = members.iter().filter_map( let numeric_format_color_items = members.iter().filter_map(
|FormatMember { |FormatMember {
name, type_color, .. name,
numeric_format_color,
..
}| { }| {
type_color numeric_format_color
.as_ref() .as_ref()
.map(|ty| quote! { Self::#name => Some(NumericType::#ty), }) .map(|ty| quote! { Self::#name => Some(NumericFormat::#ty), })
}, },
); );
let type_depth_items = members.iter().filter_map( let numeric_format_depth_items = members.iter().filter_map(
|FormatMember { |FormatMember {
name, type_depth, .. name,
numeric_format_depth,
..
}| { }| {
type_depth numeric_format_depth
.as_ref() .as_ref()
.map(|ty| quote! { Self::#name => Some(NumericType::#ty), }) .map(|ty| quote! { Self::#name => Some(NumericFormat::#ty), })
}, },
); );
let type_stencil_items = members.iter().filter_map( let numeric_format_stencil_items = members.iter().filter_map(
|FormatMember { |FormatMember {
name, type_stencil, .. name,
numeric_format_stencil,
..
}| { }| {
type_stencil numeric_format_stencil
.as_ref() .as_ref()
.map(|ty| quote! { Self::#name => Some(NumericType::#ty), }) .map(|ty| quote! { Self::#name => Some(NumericFormat::#ty), })
}, },
); );
let ycbcr_chroma_sampling_items = members.iter().filter_map( let ycbcr_chroma_sampling_items = members.iter().filter_map(
@ -432,29 +438,29 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
} }
} }
/// Returns the numeric data type of the color aspect of this format. Returns `None` /// Returns the numeric format of the color aspect of this format. Returns `None`
/// for depth/stencil formats. /// for depth/stencil formats.
pub fn type_color(self) -> Option<NumericType> { pub fn numeric_format_color(self) -> Option<NumericFormat> {
match self { match self {
#(#type_color_items)* #(#numeric_format_color_items)*
_ => None, _ => None,
} }
} }
/// Returns the numeric data type of the depth aspect of this format. Returns `None` /// Returns the numeric format of the depth aspect of this format. Returns `None`
/// color and stencil-only formats. /// color and stencil-only formats.
pub fn type_depth(self) -> Option<NumericType> { pub fn numeric_format_depth(self) -> Option<NumericFormat> {
match self { match self {
#(#type_depth_items)* #(#numeric_format_depth_items)*
_ => None, _ => None,
} }
} }
/// Returns the numeric data type of the stencil aspect of this format. Returns `None` /// Returns the numeric format of the stencil aspect of this format. Returns `None`
/// for color and depth-only formats. /// for color and depth-only formats.
pub fn type_stencil(self) -> Option<NumericType> { pub fn numeric_format_stencil(self) -> Option<NumericFormat> {
match self { match self {
#(#type_stencil_items)* #(#numeric_format_stencil_items)*
_ => None, _ => None,
} }
} }
@ -606,9 +612,9 @@ fn formats_members(
compression: None, compression: None,
planes: vec![], planes: vec![],
texels_per_block: 0, texels_per_block: 0,
type_color: None, numeric_format_color: None,
type_depth: None, numeric_format_depth: None,
type_stencil: None, numeric_format_stencil: None,
ycbcr_chroma_sampling: None, ycbcr_chroma_sampling: None,
type_std_array: None, type_std_array: None,
@ -655,9 +661,9 @@ fn formats_members(
.map(|c| format_ident!("{}", c.replace(' ', "_"))), .map(|c| format_ident!("{}", c.replace(' ', "_"))),
planes: vec![], planes: vec![],
texels_per_block: format.texelsPerBlock, texels_per_block: format.texelsPerBlock,
type_color: None, numeric_format_color: None,
type_depth: None, numeric_format_depth: None,
type_stencil: None, numeric_format_stencil: None,
ycbcr_chroma_sampling: None, ycbcr_chroma_sampling: None,
type_std_array: None, type_std_array: None,
@ -684,32 +690,32 @@ fn formats_members(
"R" => { "R" => {
member.aspect_color = true; member.aspect_color = true;
member.components[0] += bits; member.components[0] += bits;
member.type_color = Some(ty); member.numeric_format_color = Some(ty);
} }
"G" => { "G" => {
member.aspect_color = true; member.aspect_color = true;
member.components[1] += bits; member.components[1] += bits;
member.type_color = Some(ty); member.numeric_format_color = Some(ty);
} }
"B" => { "B" => {
member.aspect_color = true; member.aspect_color = true;
member.components[2] += bits; member.components[2] += bits;
member.type_color = Some(ty); member.numeric_format_color = Some(ty);
} }
"A" => { "A" => {
member.aspect_color = true; member.aspect_color = true;
member.components[3] += bits; member.components[3] += bits;
member.type_color = Some(ty); member.numeric_format_color = Some(ty);
} }
"D" => { "D" => {
member.aspect_depth = true; member.aspect_depth = true;
member.components[0] += bits; member.components[0] += bits;
member.type_depth = Some(ty); member.numeric_format_depth = Some(ty);
} }
"S" => { "S" => {
member.aspect_stencil = true; member.aspect_stencil = true;
member.components[1] += bits; member.components[1] += bits;
member.type_stencil = Some(ty); member.numeric_format_stencil = Some(ty);
} }
_ => { _ => {
panic!("Unknown component type {} on format {}", name, format.name) panic!("Unknown component type {} on format {}", name, format.name)
@ -752,7 +758,7 @@ fn formats_members(
} }
}; };
if let (Some(numeric_type), true) = (&member.type_color, member.planes.is_empty()) { if let (Some(numeric_type), true) = (&member.numeric_format_color, member.planes.is_empty()) {
if format.compressed.is_some() { if format.compressed.is_some() {
member.type_std_array = Some({ member.type_std_array = Some({
let block_size = Literal::usize_unsuffixed(format.blockSize as usize); let block_size = Literal::usize_unsuffixed(format.blockSize as usize);

View File

@ -24,7 +24,7 @@ use crate::{
SecondaryCommandBufferResourcesUsage, SubpassContents, SecondaryCommandBufferResourcesUsage, SubpassContents,
}, },
descriptor_set::{DescriptorSetResources, DescriptorSetWithOffsets}, descriptor_set::{DescriptorSetResources, DescriptorSetWithOffsets},
device::{Device, DeviceOwned, QueueFamilyProperties}, device::{Device, DeviceOwned},
image::{view::ImageView, Image, ImageAspects, ImageLayout, ImageSubresourceRange}, image::{view::ImageView, Image, ImageAspects, ImageLayout, ImageSubresourceRange},
pipeline::{ pipeline::{
graphics::{ graphics::{
@ -42,7 +42,7 @@ use crate::{
range_set::RangeSet, range_set::RangeSet,
render_pass::{Framebuffer, Subpass}, render_pass::{Framebuffer, Subpass},
sync::{ sync::{
AccessFlags, BufferMemoryBarrier, DependencyInfo, ImageMemoryBarrier, AccessFlags, BufferMemoryBarrier, DependencyFlags, DependencyInfo, ImageMemoryBarrier,
PipelineStageAccessFlags, PipelineStages, PipelineStageAccessFlags, PipelineStages,
}, },
DeviceSize, Validated, ValidationError, VulkanError, DeviceSize, Validated, ValidationError, VulkanError,
@ -293,7 +293,13 @@ where
if let Some(barriers) = barriers.remove(&command_index) { if let Some(barriers) = barriers.remove(&command_index) {
for dependency_info in barriers { for dependency_info in barriers {
unsafe { unsafe {
self.inner.pipeline_barrier(&dependency_info); #[cfg(debug_assertions)]
self.inner
.pipeline_barrier(&dependency_info)
.expect("bug in Vulkano");
#[cfg(not(debug_assertions))]
self.inner.pipeline_barrier_unchecked(&dependency_info);
} }
} }
} }
@ -305,7 +311,13 @@ where
if let Some(final_barriers) = barriers.remove(&final_barrier_index) { if let Some(final_barriers) = barriers.remove(&final_barrier_index) {
for dependency_info in final_barriers { for dependency_info in final_barriers {
unsafe { unsafe {
self.inner.pipeline_barrier(&dependency_info); #[cfg(debug_assertions)]
self.inner
.pipeline_barrier(&dependency_info)
.expect("bug in Vulkano");
#[cfg(not(debug_assertions))]
self.inner.pipeline_barrier_unchecked(&dependency_info);
} }
} }
} }
@ -402,11 +414,6 @@ impl<L, A> AutoCommandBufferBuilder<L, A>
where where
A: CommandBufferAllocator, A: CommandBufferAllocator,
{ {
#[inline]
pub(in crate::command_buffer) fn queue_family_properties(&self) -> &QueueFamilyProperties {
self.inner.queue_family_properties()
}
pub(in crate::command_buffer) fn add_command( pub(in crate::command_buffer) fn add_command(
&mut self, &mut self,
name: &'static str, name: &'static str,
@ -490,7 +497,10 @@ impl AutoSyncState {
level, level,
command_index: 0, command_index: 0,
pending_barrier: DependencyInfo::default(), pending_barrier: DependencyInfo {
dependency_flags: DependencyFlags::BY_REGION,
..DependencyInfo::default()
},
barriers: Default::default(), barriers: Default::default(),
first_unflushed: 0, first_unflushed: 0,
latest_render_pass_enter: has_inherited_render_pass.then_some(0), latest_render_pass_enter: has_inherited_render_pass.then_some(0),
@ -517,7 +527,10 @@ impl AutoSyncState {
// Add one last barrier to transition images to their desired final layout. // Add one last barrier to transition images to their desired final layout.
if self.level == CommandBufferLevel::Primary { if self.level == CommandBufferLevel::Primary {
let mut final_barrier = DependencyInfo::default(); let mut final_barrier = DependencyInfo {
dependency_flags: DependencyFlags::BY_REGION,
..DependencyInfo::default()
};
for (image, range_map) in self.images.iter_mut() { for (image, range_map) in self.images.iter_mut() {
for (range, state) in range_map for (range, state) in range_map

View File

@ -73,8 +73,8 @@ pub(in crate::command_buffer) use self::builder::{
use super::{ use super::{
allocator::{CommandBufferAllocator, StandardCommandBufferAllocator}, allocator::{CommandBufferAllocator, StandardCommandBufferAllocator},
sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder}, sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder},
CommandBufferExecError, CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
CommandBufferState, CommandBufferUsage, PrimaryCommandBufferAbstract, ResourceInCommand, CommandBufferUsage, PrimaryCommandBufferAbstract, ResourceInCommand,
SecondaryCommandBufferAbstract, SecondaryCommandBufferResourcesUsage, SecondaryResourceUseRef, SecondaryCommandBufferAbstract, SecondaryCommandBufferResourcesUsage, SecondaryResourceUseRef,
}; };
use crate::{ use crate::{
@ -82,7 +82,7 @@ use crate::{
device::{Device, DeviceOwned}, device::{Device, DeviceOwned},
image::{Image, ImageLayout, ImageSubresourceRange}, image::{Image, ImageLayout, ImageSubresourceRange},
sync::PipelineStageAccessFlags, sync::PipelineStageAccessFlags,
DeviceSize, VulkanObject, DeviceSize, ValidationError, VulkanObject,
}; };
use parking_lot::{Mutex, MutexGuard}; use parking_lot::{Mutex, MutexGuard};
use std::{ use std::{
@ -187,20 +187,34 @@ where
self.inner.inheritance_info().as_ref().unwrap() self.inner.inheritance_info().as_ref().unwrap()
} }
fn lock_record(&self) -> Result<(), CommandBufferExecError> { fn lock_record(&self) -> Result<(), Box<ValidationError>> {
match self.submit_state { match self.submit_state {
SubmitState::OneTime { SubmitState::OneTime {
ref already_submitted, ref already_submitted,
} => { } => {
let was_already_submitted = already_submitted.swap(true, Ordering::SeqCst); let was_already_submitted = already_submitted.swap(true, Ordering::SeqCst);
if was_already_submitted { if was_already_submitted {
return Err(CommandBufferExecError::OneTimeSubmitAlreadySubmitted); return Err(Box::new(ValidationError {
problem: "the command buffer was created with the \
`CommandBufferUsage::OneTimeSubmit` usage, but \
it was already submitted before"
.into(),
// vuids?
..Default::default()
}));
} }
} }
SubmitState::ExclusiveUse { ref in_use } => { SubmitState::ExclusiveUse { ref in_use } => {
let already_in_use = in_use.swap(true, Ordering::SeqCst); let already_in_use = in_use.swap(true, Ordering::SeqCst);
if already_in_use { if already_in_use {
return Err(CommandBufferExecError::ExclusiveAlreadyInUse); return Err(Box::new(ValidationError {
problem: "the command buffer was created with the \
`CommandBufferUsage::MultipleSubmit` usage, but \
it is currently being executed"
.into(),
// vuids?
..Default::default()
}));
} }
} }
SubmitState::Concurrent => (), SubmitState::Concurrent => (),
@ -308,8 +322,7 @@ mod tests {
buffer::{Buffer, BufferCreateInfo, BufferUsage}, buffer::{Buffer, BufferCreateInfo, BufferUsage},
command_buffer::{ command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferCopy, allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferCopy,
CommandBufferExecError, CommandBufferUsage, CopyBufferInfoTyped, CopyError, CommandBufferUsage, CopyBufferInfoTyped, PrimaryCommandBufferAbstract,
ExecuteCommandsError, PrimaryCommandBufferAbstract,
}, },
descriptor_set::{ descriptor_set::{
allocator::StandardDescriptorSetAllocator, allocator::StandardDescriptorSetAllocator,
@ -458,12 +471,7 @@ mod tests {
// Recording the same non-concurrent secondary command buffer twice into the same // Recording the same non-concurrent secondary command buffer twice into the same
// primary is an error. // primary is an error.
assert!(matches!( assert!(builder.execute_commands(secondary.clone()).is_err());
builder.execute_commands(secondary.clone()),
Err(ExecuteCommandsError::ExecError(
CommandBufferExecError::ExclusiveAlreadyInUse
))
));
} }
{ {
@ -485,12 +493,7 @@ mod tests {
// Recording the same non-concurrent secondary command buffer into multiple // Recording the same non-concurrent secondary command buffer into multiple
// primaries is an error. // primaries is an error.
assert!(matches!( assert!(builder.execute_commands(secondary.clone()).is_err());
builder.execute_commands(secondary.clone()),
Err(ExecuteCommandsError::ExecError(
CommandBufferExecError::ExclusiveAlreadyInUse
))
));
std::mem::drop(cb1); std::mem::drop(cb1);
@ -582,8 +585,8 @@ mod tests {
) )
.unwrap(); .unwrap();
assert!(matches!( assert!(builder
builder.copy_buffer(CopyBufferInfoTyped { .copy_buffer(CopyBufferInfoTyped {
regions: [BufferCopy { regions: [BufferCopy {
src_offset: 0, src_offset: 0,
dst_offset: 1, dst_offset: 1,
@ -592,12 +595,8 @@ mod tests {
}] }]
.into(), .into(),
..CopyBufferInfoTyped::buffers(source.clone(), source) ..CopyBufferInfoTyped::buffers(source.clone(), source)
}),
Err(CopyError::OverlappingRegions {
src_region_index: 0,
dst_region_index: 0,
}) })
)); .is_err());
} }
#[test] #[test]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -14,13 +14,9 @@ use crate::{
}, },
device::{DeviceOwned, QueueFlags}, device::{DeviceOwned, QueueFlags},
instance::debug::DebugUtilsLabel, instance::debug::DebugUtilsLabel,
Requires, RequiresAllOf, RequiresOneOf, VulkanObject, Requires, RequiresAllOf, RequiresOneOf, ValidationError, VulkanObject,
};
use std::{
error::Error,
ffi::CString,
fmt::{Display, Error as FmtError, Formatter},
}; };
use std::ffi::CString;
/// # Commands for debugging. /// # Commands for debugging.
/// ///
@ -35,43 +31,17 @@ where
pub fn begin_debug_utils_label( pub fn begin_debug_utils_label(
&mut self, &mut self,
label_info: DebugUtilsLabel, label_info: DebugUtilsLabel,
) -> Result<&mut Self, DebugUtilsError> { ) -> Result<&mut Self, Box<ValidationError>> {
self.validate_begin_debug_utils_label(&label_info)?; self.validate_begin_debug_utils_label(&label_info)?;
unsafe { unsafe { Ok(self.begin_debug_utils_label_unchecked(label_info)) }
self.begin_debug_utils_label_unchecked(label_info);
}
Ok(self)
} }
fn validate_begin_debug_utils_label( fn validate_begin_debug_utils_label(
&self, &self,
_label_info: &DebugUtilsLabel, label_info: &DebugUtilsLabel,
) -> Result<(), DebugUtilsError> { ) -> Result<(), Box<ValidationError>> {
if !self self.inner.validate_begin_debug_utils_label(label_info)?;
.device()
.instance()
.enabled_extensions()
.ext_debug_utils
{
return Err(DebugUtilsError::RequirementNotMet {
required_for: "`AutoCommandBufferBuilder::begin_debug_utils_label`",
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::InstanceExtension(
"ext_debug_utils",
)])]),
});
}
let queue_family_properties = self.queue_family_properties();
// VUID-vkCmdBeginDebugUtilsLabelEXT-commandBuffer-cmdpool
if !queue_family_properties
.queue_flags
.intersects(QueueFlags::GRAPHICS | QueueFlags::COMPUTE)
{
return Err(DebugUtilsError::NotSupportedByQueueFamily);
}
Ok(()) Ok(())
} }
@ -85,7 +55,7 @@ where
"begin_debug_utils_label", "begin_debug_utils_label",
Default::default(), Default::default(),
move |out: &mut UnsafeCommandBufferBuilder<A>| { move |out: &mut UnsafeCommandBufferBuilder<A>| {
out.begin_debug_utils_label(&label_info); out.begin_debug_utils_label_unchecked(&label_info);
}, },
); );
@ -99,44 +69,18 @@ where
/// - When submitting the command buffer, there must be an outstanding command buffer label /// - When submitting the command buffer, there must be an outstanding command buffer label
/// region begun with `begin_debug_utils_label` in the queue, either within this command /// region begun with `begin_debug_utils_label` in the queue, either within this command
/// buffer or a previously submitted one. /// buffer or a previously submitted one.
pub unsafe fn end_debug_utils_label(&mut self) -> Result<&mut Self, DebugUtilsError> { pub unsafe fn end_debug_utils_label(&mut self) -> Result<&mut Self, Box<ValidationError>> {
self.validate_end_debug_utils_label()?; self.validate_end_debug_utils_label()?;
self.end_debug_utils_label_unchecked(); Ok(self.end_debug_utils_label_unchecked())
Ok(self)
} }
fn validate_end_debug_utils_label(&self) -> Result<(), DebugUtilsError> { fn validate_end_debug_utils_label(&self) -> Result<(), Box<ValidationError>> {
if !self self.inner.validate_end_debug_utils_label()?;
.device()
.instance()
.enabled_extensions()
.ext_debug_utils
{
return Err(DebugUtilsError::RequirementNotMet {
required_for: "`AutoCommandBufferBuilder::end_debug_utils_label`",
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::InstanceExtension(
"ext_debug_utils",
)])]),
});
}
let queue_family_properties = self.queue_family_properties();
// VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-cmdpool
if !queue_family_properties
.queue_flags
.intersects(QueueFlags::GRAPHICS | QueueFlags::COMPUTE)
{
return Err(DebugUtilsError::NotSupportedByQueueFamily);
}
// TODO:
// VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912 // VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912
// TODO: not checked, so unsafe for now
// VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01913 // VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01913
// TODO: not checked, so unsafe for now
Ok(()) Ok(())
} }
@ -147,7 +91,7 @@ where
"end_debug_utils_label", "end_debug_utils_label",
Default::default(), Default::default(),
move |out: &mut UnsafeCommandBufferBuilder<A>| { move |out: &mut UnsafeCommandBufferBuilder<A>| {
out.end_debug_utils_label(); out.end_debug_utils_label_unchecked();
}, },
); );
@ -158,43 +102,17 @@ where
pub fn insert_debug_utils_label( pub fn insert_debug_utils_label(
&mut self, &mut self,
label_info: DebugUtilsLabel, label_info: DebugUtilsLabel,
) -> Result<&mut Self, DebugUtilsError> { ) -> Result<&mut Self, Box<ValidationError>> {
self.validate_insert_debug_utils_label(&label_info)?; self.validate_insert_debug_utils_label(&label_info)?;
unsafe { unsafe { Ok(self.insert_debug_utils_label_unchecked(label_info)) }
self.insert_debug_utils_label_unchecked(label_info);
}
Ok(self)
} }
fn validate_insert_debug_utils_label( fn validate_insert_debug_utils_label(
&self, &self,
_label_info: &DebugUtilsLabel, label_info: &DebugUtilsLabel,
) -> Result<(), DebugUtilsError> { ) -> Result<(), Box<ValidationError>> {
if !self self.inner.validate_insert_debug_utils_label(label_info)?;
.device()
.instance()
.enabled_extensions()
.ext_debug_utils
{
return Err(DebugUtilsError::RequirementNotMet {
required_for: "`AutoCommandBufferBuilder::insert_debug_utils_label`",
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::InstanceExtension(
"ext_debug_utils",
)])]),
});
}
let queue_family_properties = self.queue_family_properties();
// VUID-vkCmdInsertDebugUtilsLabelEXT-commandBuffer-cmdpool
if !queue_family_properties
.queue_flags
.intersects(QueueFlags::GRAPHICS | QueueFlags::COMPUTE)
{
return Err(DebugUtilsError::NotSupportedByQueueFamily);
}
Ok(()) Ok(())
} }
@ -208,7 +126,7 @@ where
"insert_debug_utils_label", "insert_debug_utils_label",
Default::default(), Default::default(),
move |out: &mut UnsafeCommandBufferBuilder<A>| { move |out: &mut UnsafeCommandBufferBuilder<A>| {
out.insert_debug_utils_label(&label_info); out.insert_debug_utils_label_unchecked(&label_info);
}, },
); );
@ -220,13 +138,55 @@ impl<A> UnsafeCommandBufferBuilder<A>
where where
A: CommandBufferAllocator, A: CommandBufferAllocator,
{ {
/// Calls `vkCmdBeginDebugUtilsLabelEXT` on the builder. pub unsafe fn begin_debug_utils_label(
/// &mut self,
/// # Safety label_info: &DebugUtilsLabel,
/// The command pool that this command buffer was allocated from must support graphics or ) -> Result<&mut Self, Box<ValidationError>> {
/// compute operations self.validate_begin_debug_utils_label(label_info)?;
#[inline]
pub unsafe fn begin_debug_utils_label(&mut self, label_info: &DebugUtilsLabel) -> &mut Self { Ok(self.begin_debug_utils_label_unchecked(label_info))
}
fn validate_begin_debug_utils_label(
&self,
_label_info: &DebugUtilsLabel,
) -> Result<(), Box<ValidationError>> {
if !self
.device()
.instance()
.enabled_extensions()
.ext_debug_utils
{
return Err(Box::new(ValidationError {
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::InstanceExtension(
"ext_debug_utils",
)])]),
..Default::default()
}));
}
if !self
.queue_family_properties()
.queue_flags
.intersects(QueueFlags::GRAPHICS | QueueFlags::COMPUTE)
{
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics or compute operations"
.into(),
vuids: &["VUID-vkCmdBeginDebugUtilsLabelEXT-commandBuffer-cmdpool"],
..Default::default()
}));
}
Ok(())
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn begin_debug_utils_label_unchecked(
&mut self,
label_info: &DebugUtilsLabel,
) -> &mut Self {
let &DebugUtilsLabel { let &DebugUtilsLabel {
ref label_name, ref label_name,
color, color,
@ -246,26 +206,101 @@ where
self self
} }
/// Calls `vkCmdEndDebugUtilsLabelEXT` on the builder. pub unsafe fn end_debug_utils_label(&mut self) -> Result<&mut Self, Box<ValidationError>> {
/// self.validate_end_debug_utils_label()?;
/// # Safety
/// There must be an outstanding `vkCmdBeginDebugUtilsLabelEXT` command prior to the Ok(self.end_debug_utils_label_unchecked())
/// `vkQueueEndDebugUtilsLabelEXT` on the queue tha `CommandBuffer` is submitted to. }
#[inline]
pub unsafe fn end_debug_utils_label(&mut self) -> &mut Self { fn validate_end_debug_utils_label(&self) -> Result<(), Box<ValidationError>> {
if !self
.device()
.instance()
.enabled_extensions()
.ext_debug_utils
{
return Err(Box::new(ValidationError {
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::InstanceExtension(
"ext_debug_utils",
)])]),
..Default::default()
}));
}
if !self
.queue_family_properties()
.queue_flags
.intersects(QueueFlags::GRAPHICS | QueueFlags::COMPUTE)
{
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics or compute operations"
.into(),
vuids: &["VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-cmdpool"],
..Default::default()
}));
}
Ok(())
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn end_debug_utils_label_unchecked(&mut self) -> &mut Self {
let fns = self.device().instance().fns(); let fns = self.device().instance().fns();
(fns.ext_debug_utils.cmd_end_debug_utils_label_ext)(self.handle()); (fns.ext_debug_utils.cmd_end_debug_utils_label_ext)(self.handle());
self self
} }
/// Calls `vkCmdInsertDebugUtilsLabelEXT` on the builder. pub unsafe fn insert_debug_utils_label(
/// &mut self,
/// # Safety label_info: &DebugUtilsLabel,
/// The command pool that this command buffer was allocated from must support graphics or ) -> Result<&mut Self, Box<ValidationError>> {
/// compute operations self.validate_insert_debug_utils_label(label_info)?;
#[inline]
pub unsafe fn insert_debug_utils_label(&mut self, label_info: &DebugUtilsLabel) -> &mut Self { Ok(self.insert_debug_utils_label_unchecked(label_info))
}
fn validate_insert_debug_utils_label(
&self,
_label_info: &DebugUtilsLabel,
) -> Result<(), Box<ValidationError>> {
if !self
.device()
.instance()
.enabled_extensions()
.ext_debug_utils
{
return Err(Box::new(ValidationError {
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::InstanceExtension(
"ext_debug_utils",
)])]),
..Default::default()
}));
}
if !self
.queue_family_properties()
.queue_flags
.intersects(QueueFlags::GRAPHICS | QueueFlags::COMPUTE)
{
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics or compute operations"
.into(),
vuids: &["VUID-vkCmdInsertDebugUtilsLabelEXT-commandBuffer-cmdpool"],
..Default::default()
}));
}
Ok(())
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn insert_debug_utils_label_unchecked(
&mut self,
label_info: &DebugUtilsLabel,
) -> &mut Self {
let &DebugUtilsLabel { let &DebugUtilsLabel {
ref label_name, ref label_name,
color, color,
@ -285,35 +320,3 @@ where
self self
} }
} }
/// Error that can happen when recording a debug utils command.
#[derive(Clone, Debug)]
pub enum DebugUtilsError {
RequirementNotMet {
required_for: &'static str,
requires_one_of: RequiresOneOf,
},
/// The queue family doesn't allow this operation.
NotSupportedByQueueFamily,
}
impl Error for DebugUtilsError {}
impl Display for DebugUtilsError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
match self {
Self::RequirementNotMet {
required_for,
requires_one_of,
} => write!(
f,
"a requirement was not met for: {}; requires one of: {}",
required_for, requires_one_of,
),
Self::NotSupportedByQueueFamily => {
write!(f, "the queue family doesn't allow this operation")
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,12 +9,12 @@
use crate::{ use crate::{
command_buffer::{allocator::CommandBufferAllocator, sys::UnsafeCommandBufferBuilder}, command_buffer::{allocator::CommandBufferAllocator, sys::UnsafeCommandBufferBuilder},
device::DeviceOwned, device::{DeviceOwned, QueueFlags},
sync::{ sync::{
event::Event, BufferMemoryBarrier, DependencyFlags, DependencyInfo, ImageMemoryBarrier, event::Event, BufferMemoryBarrier, DependencyFlags, DependencyInfo, ImageMemoryBarrier,
MemoryBarrier, PipelineStages, MemoryBarrier, PipelineStages,
}, },
Version, VulkanObject, Requires, RequiresAllOf, RequiresOneOf, ValidationError, Version, VulkanObject,
}; };
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{ptr, sync::Arc}; use std::{ptr, sync::Arc};
@ -23,23 +23,199 @@ impl<A> UnsafeCommandBufferBuilder<A>
where where
A: CommandBufferAllocator, A: CommandBufferAllocator,
{ {
#[inline] pub unsafe fn pipeline_barrier(
pub unsafe fn pipeline_barrier(&mut self, dependency_info: &DependencyInfo) -> &mut Self { &mut self,
dependency_info: &DependencyInfo,
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_pipeline_barrier(dependency_info)?;
Ok(self.pipeline_barrier_unchecked(dependency_info))
}
fn validate_pipeline_barrier(
&self,
dependency_info: &DependencyInfo,
) -> Result<(), Box<ValidationError>> {
let queue_family_properties = self.queue_family_properties();
if !queue_family_properties.queue_flags.intersects(
QueueFlags::TRANSFER
| QueueFlags::GRAPHICS
| QueueFlags::COMPUTE
| QueueFlags::VIDEO_DECODE
| QueueFlags::VIDEO_ENCODE,
) {
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
transfer, graphics, compute, video decode or video encode operations"
.into(),
vuids: &["VUID-vkCmdPipelineBarrier2-commandBuffer-cmdpool"],
..Default::default()
}));
}
dependency_info
.validate(self.device())
.map_err(|err| err.add_context("dependency_info"))?;
let &DependencyInfo {
dependency_flags: _,
ref memory_barriers,
ref buffer_memory_barriers,
ref image_memory_barriers,
_ne,
} = dependency_info;
let supported_pipeline_stages = PipelineStages::from(queue_family_properties.queue_flags);
for (barrier_index, memory_barrier) in memory_barriers.iter().enumerate() {
let &MemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
_ne: _,
} = memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.memory_barriers[{}].src_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdPipelineBarrier2-srcStageMask-03849"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.memory_barriers[{}].dst_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdPipelineBarrier2-dstStageMask-03850"],
..Default::default()
}));
}
}
for (barrier_index, buffer_memory_barrier) in buffer_memory_barriers.iter().enumerate() {
let &BufferMemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
queue_family_ownership_transfer: _,
buffer: _,
range: _,
_ne: _,
} = buffer_memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.buffer_memory_barriers[{}].src_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdPipelineBarrier2-srcStageMask-03849"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.buffer_memory_barriers[{}].dst_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdPipelineBarrier2-dstStageMask-03850"],
..Default::default()
}));
}
}
for (barrier_index, image_memory_barrier) in image_memory_barriers.iter().enumerate() {
let &ImageMemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
old_layout: _,
new_layout: _,
queue_family_ownership_transfer: _,
image: _,
subresource_range: _,
_ne: _,
} = image_memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.image_memory_barriers[{}].src_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdPipelineBarrier2-srcStageMask-03849"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.image_memory_barriers[{}].dst_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdPipelineBarrier2-dstStageMask-03850"],
..Default::default()
}));
}
}
Ok(())
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn pipeline_barrier_unchecked(
&mut self,
dependency_info: &DependencyInfo,
) -> &mut Self {
if dependency_info.is_empty() { if dependency_info.is_empty() {
return self; return self;
} }
let &DependencyInfo { let &DependencyInfo {
mut dependency_flags, dependency_flags,
ref memory_barriers, ref memory_barriers,
ref buffer_memory_barriers, ref buffer_memory_barriers,
ref image_memory_barriers, ref image_memory_barriers,
_ne: _, _ne: _,
} = dependency_info; } = dependency_info;
// TODO: Is this needed?
dependency_flags |= DependencyFlags::BY_REGION;
if self.device().enabled_features().synchronization2 { if self.device().enabled_features().synchronization2 {
let memory_barriers_vk: SmallVec<[_; 2]> = memory_barriers let memory_barriers_vk: SmallVec<[_; 2]> = memory_barriers
.iter() .iter()
@ -287,12 +463,200 @@ where
self self
} }
/// Calls `vkCmdSetEvent` on the builder.
#[inline]
pub unsafe fn set_event( pub unsafe fn set_event(
&mut self, &mut self,
event: &Event, event: &Event,
dependency_info: &DependencyInfo, dependency_info: &DependencyInfo,
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_set_event(event, dependency_info)?;
Ok(self.set_event_unchecked(event, dependency_info))
}
fn validate_set_event(
&self,
event: &Event,
dependency_info: &DependencyInfo,
) -> Result<(), Box<ValidationError>> {
let queue_family_properties = self.queue_family_properties();
if !queue_family_properties.queue_flags.intersects(
QueueFlags::GRAPHICS
| QueueFlags::COMPUTE
| QueueFlags::VIDEO_DECODE
| QueueFlags::VIDEO_ENCODE,
) {
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics, compute, video decode or video encode operations"
.into(),
vuids: &["VUID-vkCmdSetEvent2-commandBuffer-cmdpool"],
..Default::default()
}));
}
// VUID-vkCmdSetEvent2-commonparent
assert_eq!(self.device(), event.device());
dependency_info
.validate(self.device())
.map_err(|err| err.add_context("dependency_info"))?;
let &DependencyInfo {
dependency_flags,
ref memory_barriers,
ref buffer_memory_barriers,
ref image_memory_barriers,
_ne,
} = dependency_info;
if !dependency_flags.is_empty() {
return Err(Box::new(ValidationError {
context: "dependency_info.dependency_flags".into(),
problem: "is not empty".into(),
vuids: &["VUID-vkCmdSetEvent2-dependencyFlags-03825"],
..Default::default()
}));
}
let supported_pipeline_stages = PipelineStages::from(queue_family_properties.queue_flags);
for (barrier_index, memory_barrier) in memory_barriers.iter().enumerate() {
let &MemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
_ne: _,
} = memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.memory_barriers[{}].src_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-srcStageMask-03827"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.memory_barriers[{}].dst_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-dstStageMask-03828"],
..Default::default()
}));
}
}
for (barrier_index, buffer_memory_barrier) in buffer_memory_barriers.iter().enumerate() {
let &BufferMemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
queue_family_ownership_transfer: _,
buffer: _,
range: _,
_ne: _,
} = buffer_memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.buffer_memory_barriers[{}].src_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-srcStageMask-03827"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.buffer_memory_barriers[{}].dst_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-dstStageMask-03828"],
..Default::default()
}));
}
}
for (barrier_index, image_memory_barrier) in image_memory_barriers.iter().enumerate() {
let &ImageMemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
old_layout: _,
new_layout: _,
queue_family_ownership_transfer: _,
image: _,
subresource_range: _,
_ne: _,
} = image_memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.image_memory_barriers[{}].src_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-srcStageMask-03827"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"dependency_info.image_memory_barriers[{}].dst_stages",
barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of the \
command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-dstStageMask-03828"],
..Default::default()
}));
}
}
Ok(())
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn set_event_unchecked(
&mut self,
event: &Event,
dependency_info: &DependencyInfo,
) -> &mut Self { ) -> &mut Self {
let &DependencyInfo { let &DependencyInfo {
mut dependency_flags, mut dependency_flags,
@ -453,8 +817,193 @@ where
self self
} }
/// Calls `vkCmdWaitEvents` on the builder. pub unsafe fn wait_events(
pub unsafe fn wait_events(&mut self, events: &[(Arc<Event>, DependencyInfo)]) -> &mut Self { &mut self,
events: &[(Arc<Event>, DependencyInfo)],
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_wait_events(events)?;
Ok(self.wait_events_unchecked(events))
}
fn validate_wait_events(
&self,
events: &[(Arc<Event>, DependencyInfo)],
) -> Result<(), Box<ValidationError>> {
let queue_family_properties = self.queue_family_properties();
if !queue_family_properties.queue_flags.intersects(
QueueFlags::GRAPHICS
| QueueFlags::COMPUTE
| QueueFlags::VIDEO_DECODE
| QueueFlags::VIDEO_ENCODE,
) {
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics, compute, video decode or video encode operations"
.into(),
vuids: &["VUID-vkCmdWaitEvents2-commandBuffer-cmdpool"],
..Default::default()
}));
}
for (event_index, (event, dependency_info)) in events.iter().enumerate() {
// VUID-vkCmdWaitEvents2-commandBuffer-cmdpool
assert_eq!(self.device(), event.device());
dependency_info
.validate(self.device())
.map_err(|err| err.add_context(format!("events[{}].1", event_index)))?;
let &DependencyInfo {
dependency_flags: _,
ref memory_barriers,
ref buffer_memory_barriers,
ref image_memory_barriers,
_ne,
} = dependency_info;
let supported_pipeline_stages =
PipelineStages::from(queue_family_properties.queue_flags);
for (barrier_index, memory_barrier) in memory_barriers.iter().enumerate() {
let &MemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
_ne: _,
} = memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"events[{}].1.memory_barriers[{}].src_stages",
event_index, barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of \
the command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-srcStageMask-03827"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"events[{}].1.memory_barriers[{}].dst_stages",
event_index, barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of \
the command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-dstStageMask-03828"],
..Default::default()
}));
}
}
for (barrier_index, buffer_memory_barrier) in buffer_memory_barriers.iter().enumerate()
{
let &BufferMemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
queue_family_ownership_transfer: _,
buffer: _,
range: _,
_ne: _,
} = buffer_memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"events[{}].1.buffer_memory_barriers[{}].src_stages",
event_index, barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of \
the command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-srcStageMask-03827"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"events[{}].1.buffer_memory_barriers[{}].dst_stages",
event_index, barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of \
the command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-dstStageMask-03828"],
..Default::default()
}));
}
}
for (barrier_index, image_memory_barrier) in image_memory_barriers.iter().enumerate() {
let &ImageMemoryBarrier {
src_stages,
src_access: _,
dst_stages,
dst_access: _,
old_layout: _,
new_layout: _,
queue_family_ownership_transfer: _,
image: _,
subresource_range: _,
_ne: _,
} = image_memory_barrier;
if !supported_pipeline_stages.contains(src_stages) {
return Err(Box::new(ValidationError {
context: format!(
"events[{}].1.image_memory_barriers[{}].src_stages",
event_index, barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of \
the command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-srcStageMask-03827"],
..Default::default()
}));
}
if !supported_pipeline_stages.contains(dst_stages) {
return Err(Box::new(ValidationError {
context: format!(
"events[{}].1.image_memory_barriers[{}].dst_stages",
event_index, barrier_index
)
.into(),
problem: "contains stages that are not supported by the queue family of \
the command buffer"
.into(),
vuids: &["VUID-vkCmdSetEvent2-dstStageMask-03828"],
..Default::default()
}));
}
}
}
Ok(())
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn wait_events_unchecked(
&mut self,
events: &[(Arc<Event>, DependencyInfo)],
) -> &mut Self {
let fns = self.device().fns(); let fns = self.device().fns();
if self.device().enabled_features().synchronization2 { if self.device().enabled_features().synchronization2 {
@ -775,9 +1324,233 @@ where
self self
} }
/// Calls `vkCmdResetEvent` on the builder. pub unsafe fn reset_event(
#[inline] &mut self,
pub unsafe fn reset_event(&mut self, event: Arc<Event>, stages: PipelineStages) -> &mut Self { event: &Event,
stages: PipelineStages,
) -> Result<&mut Self, Box<ValidationError>> {
self.validate_reset_event(event, stages)?;
Ok(self.reset_event_unchecked(event, stages))
}
fn validate_reset_event(
&self,
event: &Event,
stages: PipelineStages,
) -> Result<(), Box<ValidationError>> {
if !self.queue_family_properties().queue_flags.intersects(
QueueFlags::GRAPHICS
| QueueFlags::COMPUTE
| QueueFlags::VIDEO_DECODE
| QueueFlags::VIDEO_ENCODE,
) {
return Err(Box::new(ValidationError {
problem: "the queue family of the command buffer does not support \
graphics, compute, video decode or video encode operations"
.into(),
vuids: &["VUID-vkCmdResetEvent2-commandBuffer-cmdpool"],
..Default::default()
}));
}
let device = self.device();
// VUID-vkCmdResetEvent2-commonparent
assert_eq!(device, event.device());
stages
.validate_device(device)
.map_err(|err| ValidationError {
context: "stages".into(),
vuids: &["VUID-vkCmdResetEvent2-stageMask-parameter"],
..ValidationError::from_requirement(err)
})?;
if !device.enabled_features().synchronization2 {
if stages.contains_flags2() {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains flags from `VkPipelineStageFlagBits2`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"synchronization2",
)])]),
..Default::default()
}));
}
}
if !device.enabled_features().geometry_shader {
if stages.intersects(PipelineStages::GEOMETRY_SHADER) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::GEOMETRY_SHADER`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"geometry_shader",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03929"],
}));
}
}
if !device.enabled_features().tessellation_shader {
if stages.intersects(
PipelineStages::TESSELLATION_CONTROL_SHADER
| PipelineStages::TESSELLATION_EVALUATION_SHADER,
) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::TESSELLATION_CONTROL_SHADER` or \
`PipelineStages::TESSELLATION_EVALUATION_SHADER`"
.into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"tessellation_shader",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03930"],
}));
}
}
if !device.enabled_features().conditional_rendering {
if stages.intersects(PipelineStages::CONDITIONAL_RENDERING) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::CONDITIONAL_RENDERING`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"conditional_rendering",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03931"],
}));
}
}
if !device.enabled_features().fragment_density_map {
if stages.intersects(PipelineStages::FRAGMENT_DENSITY_PROCESS) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::FRAGMENT_DENSITY_PROCESS`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"fragment_density_map",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03932"],
}));
}
}
if !device.enabled_features().transform_feedback {
if stages.intersects(PipelineStages::TRANSFORM_FEEDBACK) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::TRANSFORM_FEEDBACK`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"transform_feedback",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03933"],
}));
}
}
if !device.enabled_features().mesh_shader {
if stages.intersects(PipelineStages::MESH_SHADER) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::MESH_SHADER`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"mesh_shader",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03934"],
}));
}
}
if !device.enabled_features().task_shader {
if stages.intersects(PipelineStages::TASK_SHADER) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::TASK_SHADER`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"task_shader",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03935"],
}));
}
}
if !(device.enabled_features().attachment_fragment_shading_rate
|| device.enabled_features().shading_rate_image)
{
if stages.intersects(PipelineStages::FRAGMENT_SHADING_RATE_ATTACHMENT) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::FRAGMENT_SHADING_RATE_ATTACHMENT`".into(),
requires_one_of: RequiresOneOf(&[
RequiresAllOf(&[Requires::Feature("attachment_fragment_shading_rate")]),
RequiresAllOf(&[Requires::Feature("shading_rate_image")]),
]),
vuids: &["VUID-VkImageMemoryBarrier2-shadingRateImage-07316"],
}));
}
}
if !device.enabled_features().subpass_shading {
if stages.intersects(PipelineStages::SUBPASS_SHADING) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::SUBPASS_SHADING`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"subpass_shading",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-04957"],
}));
}
}
if !device.enabled_features().invocation_mask {
if stages.intersects(PipelineStages::INVOCATION_MASK) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::INVOCATION_MASK`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"invocation_mask",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-04995"],
}));
}
}
if !(device.enabled_extensions().nv_ray_tracing
|| device.enabled_features().ray_tracing_pipeline)
{
if stages.intersects(PipelineStages::RAY_TRACING_SHADER) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::RAY_TRACING_SHADER`".into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::Feature(
"ray_tracing_pipeline",
)])]),
vuids: &["VUID-vkCmdResetEvent2-stageMask-07946"],
}));
}
}
if stages.intersects(PipelineStages::HOST) {
return Err(Box::new(ValidationError {
context: "stages".into(),
problem: "contains `PipelineStages::HOST`".into(),
vuids: &["VUID-vkCmdResetEvent2-stageMask-03830"],
..Default::default()
}));
}
Ok(())
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn reset_event_unchecked(
&mut self,
event: &Event,
stages: PipelineStages,
) -> &mut Self {
let fns = self.device().fns(); let fns = self.device().fns();
if self.device().enabled_features().synchronization2 { if self.device().enabled_features().synchronization2 {

View File

@ -91,11 +91,11 @@
//! queue.queue_family_index(), //! queue.queue_family_index(),
//! CommandBufferUsage::MultipleSubmit //! CommandBufferUsage::MultipleSubmit
//! ).unwrap() //! ).unwrap()
//! .begin_render_pass(render_pass_begin_info, SubpassContents::Inline).unwrap() //! .begin_render_pass(render_pass_begin_info, Default::default()).unwrap()
//! .bind_pipeline_graphics(graphics_pipeline.clone()) //! .bind_pipeline_graphics(graphics_pipeline.clone()).unwrap()
//! .bind_vertex_buffers(0, vertex_buffer.clone()) //! .bind_vertex_buffers(0, vertex_buffer.clone()).unwrap()
//! .draw(vertex_buffer.len() as u32, 1, 0, 0).unwrap() //! .draw(vertex_buffer.len() as u32, 1, 0, 0).unwrap()
//! .end_render_pass().unwrap() //! .end_render_pass(Default::default()).unwrap()
//! .build().unwrap(); //! .build().unwrap();
//! //!
//! let _future = cb.execute(queue.clone()); //! let _future = cb.execute(queue.clone());
@ -111,19 +111,8 @@
pub use self::{ pub use self::{
auto::{AutoCommandBufferBuilder, PrimaryAutoCommandBuffer, SecondaryAutoCommandBuffer}, auto::{AutoCommandBufferBuilder, PrimaryAutoCommandBuffer, SecondaryAutoCommandBuffer},
commands::{ commands::{
clear::{ClearColorImageInfo, ClearDepthStencilImageInfo, ClearError}, acceleration_structure::*, clear::*, copy::*, debug::*, dynamic_state::*, pipeline::*,
copy::{ query::*, render_pass::*, secondary::*, sync::*,
BlitImageInfo, BufferCopy, BufferImageCopy, CopyBufferInfo, CopyBufferInfoTyped,
CopyBufferToImageInfo, CopyError, CopyErrorResource, CopyImageInfo,
CopyImageToBufferInfo, ImageBlit, ImageCopy, ImageResolve, ResolveImageInfo,
},
pipeline::PipelineExecutionError,
query::QueryError,
render_pass::{
ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError,
RenderingAttachmentInfo, RenderingAttachmentResolveInfo, RenderingInfo,
},
secondary::ExecuteCommandsError,
}, },
traits::{ traits::{
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBufferAbstract, CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBufferAbstract,

View File

@ -22,7 +22,7 @@ use crate::{
}, },
PipelineStages, PipelineStages,
}, },
DeviceSize, SafeDeref, VulkanObject, DeviceSize, SafeDeref, ValidationError, VulkanObject,
}; };
use parking_lot::{Mutex, MutexGuard}; use parking_lot::{Mutex, MutexGuard};
use std::{ use std::{
@ -172,7 +172,7 @@ pub unsafe trait SecondaryCommandBufferAbstract:
/// and if so locks it. /// and if so locks it.
/// ///
/// If you call this function, then you should call `unlock` afterwards. /// If you call this function, then you should call `unlock` afterwards.
fn lock_record(&self) -> Result<(), CommandBufferExecError>; fn lock_record(&self) -> Result<(), Box<ValidationError>>;
/// Unlocks the command buffer. Should be called once for each call to `lock_record`. /// Unlocks the command buffer. Should be called once for each call to `lock_record`.
/// ///
@ -198,7 +198,7 @@ where
(**self).inheritance_info() (**self).inheritance_info()
} }
fn lock_record(&self) -> Result<(), CommandBufferExecError> { fn lock_record(&self) -> Result<(), Box<ValidationError>> {
(**self).lock_record() (**self).lock_record()
} }

View File

@ -94,11 +94,11 @@
//! method on a format. //! method on a format.
use crate::{ use crate::{
device::physical::PhysicalDevice, device::{physical::PhysicalDevice, Device},
image::{ImageAspects, ImageTiling}, image::{ImageAspects, ImageTiling},
macros::vulkan_bitflags, macros::vulkan_bitflags,
shader::spirv::ImageFormat, shader::spirv::ImageFormat,
DeviceSize, DeviceSize, Requires, RequiresAllOf, RequiresOneOf, ValidationError,
}; };
// Generated by build.rs // Generated by build.rs
@ -276,9 +276,9 @@ impl ChromaSampling {
} }
} }
/// The numeric type that represents data of a format in memory. /// The numeric format in memory of the components of a format.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum NumericType { pub enum NumericFormat {
/// Signed floating-point number. /// Signed floating-point number.
SFLOAT, SFLOAT,
/// Unsigned floating-point number. /// Unsigned floating-point number.
@ -300,6 +300,38 @@ pub enum NumericType {
SRGB, SRGB,
} }
impl NumericFormat {
// https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap47.html#formats-numericformat
pub const fn numeric_type(self) -> NumericType {
match self {
NumericFormat::SFLOAT
| NumericFormat::UFLOAT
| NumericFormat::SNORM
| NumericFormat::UNORM
| NumericFormat::SSCALED
| NumericFormat::USCALED
| NumericFormat::SRGB => NumericType::Float,
NumericFormat::SINT => NumericType::Int,
NumericFormat::UINT => NumericType::Uint,
}
}
}
/// The numeric base type of a scalar value, in a format, a shader, or elsewhere.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum NumericType {
Float,
Int,
Uint,
}
impl From<NumericFormat> for NumericType {
#[inline]
fn from(val: NumericFormat) -> Self {
val.numeric_type()
}
}
/// An opaque type that represents a format compatibility class. /// An opaque type that represents a format compatibility class.
/// ///
/// Two formats are compatible if their compatibility classes compare equal. /// Two formats are compatible if their compatibility classes compare equal.
@ -417,6 +449,40 @@ pub enum ClearValue {
DepthStencil((f32, u32)), DepthStencil((f32, u32)),
} }
impl ClearValue {
pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> {
if let ClearValue::Depth(depth) | ClearValue::DepthStencil((depth, _)) = self {
if !(0.0..=1.0).contains(depth)
&& !device.enabled_extensions().ext_depth_range_unrestricted
{
return Err(Box::new(ValidationError {
problem: "is `ClearValue::Depth` or `ClearValue::DepthStencil`, and \
the depth value is not between 0.0 and 1.0 inclusive"
.into(),
requires_one_of: RequiresOneOf(&[RequiresAllOf(&[Requires::DeviceExtension(
"ext_depth_range_unrestricted",
)])]),
vuids: &["VUID-VkClearDepthStencilValue-depth-00022"],
..Default::default()
}));
}
}
Ok(())
}
pub(crate) fn clear_value_type(&self) -> ClearValueType {
match self {
ClearValue::Float(_) => ClearValueType::Float,
ClearValue::Int(_) => ClearValueType::Int,
ClearValue::Uint(_) => ClearValueType::Uint,
ClearValue::Depth(_) => ClearValueType::Depth,
ClearValue::Stencil(_) => ClearValueType::Stencil,
ClearValue::DepthStencil(_) => ClearValueType::DepthStencil,
}
}
}
impl From<ClearValue> for ash::vk::ClearValue { impl From<ClearValue> for ash::vk::ClearValue {
#[inline] #[inline]
fn from(val: ClearValue) -> Self { fn from(val: ClearValue) -> Self {
@ -562,6 +628,16 @@ impl From<(f32, u32)> for ClearValue {
} }
} }
#[derive(Debug, PartialEq, Eq)]
pub(crate) enum ClearValueType {
Float,
Int,
Uint,
Depth,
Stencil,
DepthStencil,
}
/// A value that will be used to clear a color image. /// A value that will be used to clear a color image.
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub enum ClearColorValue { pub enum ClearColorValue {
@ -573,6 +649,17 @@ pub enum ClearColorValue {
Uint([u32; 4]), Uint([u32; 4]),
} }
impl ClearColorValue {
/// Returns the numeric type of the clear value.
pub fn numeric_type(&self) -> NumericType {
match self {
ClearColorValue::Float(_) => NumericType::Float,
ClearColorValue::Int(_) => NumericType::Int,
ClearColorValue::Uint(_) => NumericType::Uint,
}
}
}
impl From<ClearColorValue> for ash::vk::ClearColorValue { impl From<ClearColorValue> for ash::vk::ClearColorValue {
#[inline] #[inline]
fn from(val: ClearColorValue) -> Self { fn from(val: ClearColorValue) -> Self {

View File

@ -49,7 +49,7 @@ pub mod ycbcr;
use self::ycbcr::SamplerYcbcrConversion; use self::ycbcr::SamplerYcbcrConversion;
use crate::{ use crate::{
device::{Device, DeviceOwned, DeviceOwnedDebugWrapper}, device::{Device, DeviceOwned, DeviceOwnedDebugWrapper},
format::FormatFeatures, format::{FormatFeatures, NumericType},
image::{ image::{
view::{ImageView, ImageViewType}, view::{ImageView, ImageViewType},
ImageAspects, ImageAspects,
@ -57,7 +57,6 @@ use crate::{
instance::InstanceOwnedDebugWrapper, instance::InstanceOwnedDebugWrapper,
macros::{impl_id_counter, vulkan_enum}, macros::{impl_id_counter, vulkan_enum},
pipeline::graphics::depth_stencil::CompareOp, pipeline::graphics::depth_stencil::CompareOp,
shader::ShaderScalarType,
Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, VulkanError, VulkanObject, Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, VulkanError, VulkanObject,
}; };
use std::{mem::MaybeUninit, num::NonZeroU64, ops::RangeInclusive, ptr, sync::Arc}; use std::{mem::MaybeUninit, num::NonZeroU64, ops::RangeInclusive, ptr, sync::Arc};
@ -395,18 +394,18 @@ impl Sampler {
if let Some(border_color) = self.border_color { if let Some(border_color) = self.border_color {
let aspects = image_view.subresource_range().aspects; let aspects = image_view.subresource_range().aspects;
let view_scalar_type = ShaderScalarType::from( let view_numeric_type = NumericType::from(
if aspects.intersects( if aspects.intersects(
ImageAspects::COLOR ImageAspects::COLOR
| ImageAspects::PLANE_0 | ImageAspects::PLANE_0
| ImageAspects::PLANE_1 | ImageAspects::PLANE_1
| ImageAspects::PLANE_2, | ImageAspects::PLANE_2,
) { ) {
image_view.format().type_color().unwrap() image_view.format().numeric_format_color().unwrap()
} else if aspects.intersects(ImageAspects::DEPTH) { } else if aspects.intersects(ImageAspects::DEPTH) {
image_view.format().type_depth().unwrap() image_view.format().numeric_format_depth().unwrap()
} else if aspects.intersects(ImageAspects::STENCIL) { } else if aspects.intersects(ImageAspects::STENCIL) {
image_view.format().type_stencil().unwrap() image_view.format().numeric_format_stencil().unwrap()
} else { } else {
// Per `ImageViewBuilder::aspects` and // Per `ImageViewBuilder::aspects` and
// VUID-VkDescriptorImageInfo-imageView-01976 // VUID-VkDescriptorImageInfo-imageView-01976
@ -421,10 +420,7 @@ impl Sampler {
// The sampler borderColor is an integer type and the image view // The sampler borderColor is an integer type and the image view
// format is not one of the VkFormat integer types or a stencil // format is not one of the VkFormat integer types or a stencil
// component of a depth/stencil format. // component of a depth/stencil format.
if !matches!( if !matches!(view_numeric_type, NumericType::Int | NumericType::Uint) {
view_scalar_type,
ShaderScalarType::Sint | ShaderScalarType::Uint
) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
problem: "the sampler has an integer border color, and \ problem: "the sampler has an integer border color, and \
the image view does not have an integer format" the image view does not have an integer format"
@ -439,7 +435,7 @@ impl Sampler {
// The sampler borderColor is a float type and the image view // The sampler borderColor is a float type and the image view
// format is not one of the VkFormat float types or a depth // format is not one of the VkFormat float types or a depth
// component of a depth/stencil format. // component of a depth/stencil format.
if !matches!(view_scalar_type, ShaderScalarType::Float) { if !matches!(view_numeric_type, NumericType::Float) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
problem: "the sampler has an floating-point border color, and \ problem: "the sampler has an floating-point border color, and \
the image view does not have a floating-point format" the image view does not have a floating-point format"

View File

@ -111,7 +111,7 @@
use crate::{ use crate::{
device::{Device, DeviceOwned}, device::{Device, DeviceOwned},
format::{ChromaSampling, Format, FormatFeatures, NumericType}, format::{ChromaSampling, Format, FormatFeatures, NumericFormat},
image::sampler::{ComponentMapping, ComponentSwizzle, Filter}, image::sampler::{ComponentMapping, ComponentSwizzle, Filter},
instance::InstanceOwnedDebugWrapper, instance::InstanceOwnedDebugWrapper,
macros::{impl_id_counter, vulkan_enum}, macros::{impl_id_counter, vulkan_enum},
@ -518,8 +518,8 @@ impl SamplerYcbcrConversionCreateInfo {
})?; })?;
if !format if !format
.type_color() .numeric_format_color()
.map_or(false, |ty| ty == NumericType::UNORM) .map_or(false, |ty| ty == NumericFormat::UNORM)
{ {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
context: "format".into(), context: "format".into(),

View File

@ -1170,7 +1170,7 @@ unsafe fn get_format_features(view_format: Format, image: &Image) -> FormatFeatu
|| device.enabled_extensions().khr_format_feature_flags2) || device.enabled_extensions().khr_format_feature_flags2)
&& matches!(image.tiling(), ImageTiling::Linear | ImageTiling::Optimal) && matches!(image.tiling(), ImageTiling::Linear | ImageTiling::Optimal)
{ {
if view_format.type_color().is_none() if view_format.numeric_format_color().is_none()
&& format_features.intersects(FormatFeatures::SAMPLED_IMAGE) && format_features.intersects(FormatFeatures::SAMPLED_IMAGE)
{ {
format_features |= FormatFeatures::SAMPLED_IMAGE_DEPTH_COMPARISON; format_features |= FormatFeatures::SAMPLED_IMAGE_DEPTH_COMPARISON;

View File

@ -493,12 +493,14 @@ mod tests {
) )
.unwrap(); .unwrap();
cbb.bind_pipeline_compute(pipeline.clone()) cbb.bind_pipeline_compute(pipeline.clone())
.unwrap()
.bind_descriptor_sets( .bind_descriptor_sets(
PipelineBindPoint::Compute, PipelineBindPoint::Compute,
pipeline.layout().clone(), pipeline.layout().clone(),
0, 0,
set, set,
) )
.unwrap()
.dispatch([1, 1, 1]) .dispatch([1, 1, 1])
.unwrap(); .unwrap();
let cb = cbb.build().unwrap(); let cb = cbb.build().unwrap();

View File

@ -74,7 +74,7 @@ use super::{
}; };
use crate::{ use crate::{
device::{Device, DeviceOwned, DeviceOwnedDebugWrapper}, device::{Device, DeviceOwned, DeviceOwnedDebugWrapper},
format::{FormatFeatures, NumericType}, format::FormatFeatures,
image::{ImageAspect, ImageAspects}, image::{ImageAspect, ImageAspects},
instance::InstanceOwnedDebugWrapper, instance::InstanceOwnedDebugWrapper,
macros::impl_id_counter, macros::impl_id_counter,
@ -91,7 +91,7 @@ use crate::{
}, },
shader::{ shader::{
DescriptorBindingRequirements, FragmentShaderExecution, FragmentTestsStages, DescriptorBindingRequirements, FragmentShaderExecution, FragmentTestsStages,
ShaderExecution, ShaderScalarType, ShaderStage, ShaderStages, ShaderExecution, ShaderStage, ShaderStages,
}, },
Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, VulkanError, VulkanObject, Requires, RequiresAllOf, RequiresOneOf, Validated, ValidationError, VulkanError, VulkanObject,
}; };
@ -2702,27 +2702,18 @@ impl GraphicsPipelineCreateInfo {
// same location but in different components. // same location but in different components.
let shader_type = element.ty.base_type; let shader_type = element.ty.base_type;
let attribute_type = attribute_desc.format.type_color().unwrap(); let attribute_type = attribute_desc
.format
.numeric_format_color()
.unwrap()
.numeric_type();
// VUID? // VUID?
if !matches!( if shader_type != attribute_type {
(shader_type, attribute_type),
(
ShaderScalarType::Float,
NumericType::SFLOAT
| NumericType::UFLOAT
| NumericType::SNORM
| NumericType::UNORM
| NumericType::SSCALED
| NumericType::USCALED
| NumericType::SRGB,
) | (ShaderScalarType::Sint, NumericType::SINT)
| (ShaderScalarType::Uint, NumericType::UINT)
) {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
problem: format!( problem: format!(
"`vertex_input_state.attributes[{}].format` has a different \ "`vertex_input_state.attributes[{}].format` has a different \
scalar type than the vertex shader input variable with \ numeric type than the vertex shader input variable with \
location {0}", location {0}",
location, location,
) )

View File

@ -496,8 +496,8 @@ impl FramebufferCreateInfo {
for image_view in attachments.iter() { for image_view in attachments.iter() {
let image_view_extent = image_view.image().extent(); let image_view_extent = image_view.image().extent();
let image_view_array_layers = image_view.subresource_range().array_layers.end let image_view_array_layers =
- image_view.subresource_range().array_layers.start; image_view.subresource_range().array_layers.len() as u32;
auto_extent[0] = auto_extent[0].min(image_view_extent[0]); auto_extent[0] = auto_extent[0].min(image_view_extent[0]);
auto_extent[1] = auto_extent[1].min(image_view_extent[1]); auto_extent[1] = auto_extent[1].min(image_view_extent[1]);

View File

@ -28,7 +28,7 @@
pub use self::framebuffer::{Framebuffer, FramebufferCreateFlags, FramebufferCreateInfo}; pub use self::framebuffer::{Framebuffer, FramebufferCreateFlags, FramebufferCreateInfo};
use crate::{ use crate::{
device::{Device, DeviceOwned, QueueFlags}, device::{Device, DeviceOwned, QueueFlags},
format::{Format, FormatFeatures}, format::{ClearValueType, Format, FormatFeatures, NumericType},
image::{ImageAspects, ImageLayout, SampleCount}, image::{ImageAspects, ImageLayout, SampleCount},
instance::InstanceOwnedDebugWrapper, instance::InstanceOwnedDebugWrapper,
macros::{impl_id_counter, vulkan_bitflags, vulkan_bitflags_enum, vulkan_enum}, macros::{impl_id_counter, vulkan_bitflags, vulkan_bitflags_enum, vulkan_enum},
@ -1261,7 +1261,7 @@ impl RenderPassCreateInfo {
let resolve_format = resolve_attachment_desc.format; let resolve_format = resolve_attachment_desc.format;
if !(resolve_format.components()[0] == format.components()[0] if !(resolve_format.components()[0] == format.components()[0]
&& resolve_format.type_depth() == format.type_depth()) && resolve_format.numeric_format_depth() == format.numeric_format_depth())
{ {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
problem: format!( problem: format!(
@ -1282,7 +1282,8 @@ impl RenderPassCreateInfo {
} }
if !(resolve_format.components()[1] == format.components()[1] if !(resolve_format.components()[1] == format.components()[1]
&& resolve_format.type_stencil() == format.type_stencil()) && resolve_format.numeric_format_stencil()
== format.numeric_format_stencil())
{ {
return Err(Box::new(ValidationError { return Err(Box::new(ValidationError {
problem: format!( problem: format!(
@ -2187,6 +2188,29 @@ impl AttachmentDescription {
Ok(()) Ok(())
} }
pub(crate) fn required_clear_value(&self) -> Option<ClearValueType> {
if let Some(numeric_format) = self.format.numeric_format_color() {
(self.load_op == AttachmentLoadOp::Clear).then(|| match numeric_format.numeric_type() {
NumericType::Float => ClearValueType::Float,
NumericType::Int => ClearValueType::Int,
NumericType::Uint => ClearValueType::Uint,
})
} else {
let aspects = self.format.aspects();
let need_depth =
aspects.intersects(ImageAspects::DEPTH) && self.load_op == AttachmentLoadOp::Clear;
let need_stencil = aspects.intersects(ImageAspects::STENCIL)
&& self.stencil_load_op.unwrap_or(self.load_op) == AttachmentLoadOp::Clear;
match (need_depth, need_stencil) {
(true, true) => Some(ClearValueType::DepthStencil),
(true, false) => Some(ClearValueType::Depth),
(false, true) => Some(ClearValueType::Stencil),
(false, false) => None,
}
}
}
} }
vulkan_bitflags! { vulkan_bitflags! {

View File

@ -730,7 +730,7 @@ pub struct DescriptorBindingRequirements {
/// The base scalar type required for the format of image views bound to this binding. /// The base scalar type required for the format of image views bound to this binding.
/// This is `None` for non-image bindings. /// This is `None` for non-image bindings.
pub image_scalar_type: Option<ShaderScalarType>, pub image_scalar_type: Option<NumericType>,
/// The view type that is required for image views bound to this binding. /// The view type that is required for image views bound to this binding.
/// This is `None` for non-image bindings. /// This is `None` for non-image bindings.
@ -1140,7 +1140,7 @@ pub struct ShaderInterfaceEntry {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct ShaderInterfaceEntryType { pub struct ShaderInterfaceEntryType {
/// The base numeric type. /// The base numeric type.
pub base_type: ShaderScalarType, pub base_type: NumericType,
/// The number of vector components. Must be in the range 1..=4. /// The number of vector components. Must be in the range 1..=4.
pub num_components: u32, pub num_components: u32,
@ -1160,32 +1160,6 @@ impl ShaderInterfaceEntryType {
} }
} }
/// The numeric base type of a shader variable.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ShaderScalarType {
Float,
Sint,
Uint,
}
// https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap43.html#formats-numericformat
impl From<NumericType> for ShaderScalarType {
#[inline]
fn from(val: NumericType) -> Self {
match val {
NumericType::SFLOAT => Self::Float,
NumericType::UFLOAT => Self::Float,
NumericType::SINT => Self::Sint,
NumericType::UINT => Self::Uint,
NumericType::SNORM => Self::Float,
NumericType::UNORM => Self::Float,
NumericType::SSCALED => Self::Float,
NumericType::USCALED => Self::Float,
NumericType::SRGB => Self::Float,
}
}
}
vulkan_bitflags_enum! { vulkan_bitflags_enum! {
#[non_exhaustive] #[non_exhaustive]

View File

@ -20,8 +20,8 @@ use crate::{
StorageClass, StorageClass,
}, },
DescriptorIdentifier, DescriptorRequirements, EntryPointInfo, GeometryShaderExecution, DescriptorIdentifier, DescriptorRequirements, EntryPointInfo, GeometryShaderExecution,
GeometryShaderInput, ShaderExecution, ShaderInterface, ShaderInterfaceEntry, GeometryShaderInput, NumericType, ShaderExecution, ShaderInterface, ShaderInterfaceEntry,
ShaderInterfaceEntryType, ShaderScalarType, ShaderStage, SpecializationConstant, ShaderInterfaceEntryType, ShaderStage, SpecializationConstant,
}, },
DeviceSize, DeviceSize,
}; };
@ -854,14 +854,14 @@ fn descriptor_binding_requirements_of(spirv: &Spirv, variable_id: Id) -> Descrip
} => { } => {
assert!(width == 32); // TODO: 64-bit components assert!(width == 32); // TODO: 64-bit components
match signedness { match signedness {
0 => ShaderScalarType::Uint, 0 => NumericType::Uint,
1 => ShaderScalarType::Sint, 1 => NumericType::Int,
_ => unreachable!(), _ => unreachable!(),
} }
} }
Instruction::TypeFloat { width, .. } => { Instruction::TypeFloat { width, .. } => {
assert!(width == 32); // TODO: 64-bit components assert!(width == 32); // TODO: 64-bit components
ShaderScalarType::Float NumericType::Float
} }
_ => unreachable!(), _ => unreachable!(),
}); });
@ -1347,8 +1347,8 @@ fn shader_interface_type_of(
assert!(!ignore_first_array); assert!(!ignore_first_array);
ShaderInterfaceEntryType { ShaderInterfaceEntryType {
base_type: match signedness { base_type: match signedness {
0 => ShaderScalarType::Uint, 0 => NumericType::Uint,
1 => ShaderScalarType::Sint, 1 => NumericType::Int,
_ => unreachable!(), _ => unreachable!(),
}, },
num_components: 1, num_components: 1,
@ -1363,7 +1363,7 @@ fn shader_interface_type_of(
Instruction::TypeFloat { width, .. } => { Instruction::TypeFloat { width, .. } => {
assert!(!ignore_first_array); assert!(!ignore_first_array);
ShaderInterfaceEntryType { ShaderInterfaceEntryType {
base_type: ShaderScalarType::Float, base_type: NumericType::Float,
num_components: 1, num_components: 1,
num_elements: 1, num_elements: 1,
is_64bit: match width { is_64bit: match width {

File diff suppressed because it is too large Load Diff