Skip to content

Commit

Permalink
Make command buffer/descriptor set allocators Sync again (#2046)
Browse files Browse the repository at this point in the history
* Make cmd buffer/desc set allocators `Sync` again

* Ingles
  • Loading branch information
marc0246 authored Oct 27, 2022
1 parent 99aea52 commit 8a1c91f
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 93 deletions.
10 changes: 5 additions & 5 deletions examples/src/bin/deferred/frame/ambient_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// according to those terms.

use bytemuck::{Pod, Zeroable};
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
buffer::{BufferUsage, CpuAccessibleBuffer, TypedBufferAccess},
command_buffer::{
Expand Down Expand Up @@ -40,8 +40,8 @@ pub struct AmbientLightingSystem {
vertex_buffer: Arc<CpuAccessibleBuffer<[Vertex]>>,
subpass: Subpass,
pipeline: Arc<GraphicsPipeline>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
}

impl AmbientLightingSystem {
Expand All @@ -50,8 +50,8 @@ impl AmbientLightingSystem {
gfx_queue: Arc<Queue>,
subpass: Subpass,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
) -> AmbientLightingSystem {
// TODO: vulkano doesn't allow us to draw without a vertex buffer, otherwise we could
// hard-code these values in the shader
Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/deferred/frame/directional_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use bytemuck::{Pod, Zeroable};
use cgmath::Vector3;
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
buffer::{BufferUsage, CpuAccessibleBuffer, TypedBufferAccess},
command_buffer::{
Expand Down Expand Up @@ -41,8 +41,8 @@ pub struct DirectionalLightingSystem {
vertex_buffer: Arc<CpuAccessibleBuffer<[Vertex]>>,
subpass: Subpass,
pipeline: Arc<GraphicsPipeline>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
}

impl DirectionalLightingSystem {
Expand All @@ -51,8 +51,8 @@ impl DirectionalLightingSystem {
gfx_queue: Arc<Queue>,
subpass: Subpass,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
) -> DirectionalLightingSystem {
// TODO: vulkano doesn't allow us to draw without a vertex buffer, otherwise we could
// hard-code these values in the shader
Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/deferred/frame/point_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use bytemuck::{Pod, Zeroable};
use cgmath::{Matrix4, Vector3};
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
buffer::{BufferUsage, CpuAccessibleBuffer, TypedBufferAccess},
command_buffer::{
Expand Down Expand Up @@ -40,8 +40,8 @@ pub struct PointLightingSystem {
vertex_buffer: Arc<CpuAccessibleBuffer<[Vertex]>>,
subpass: Subpass,
pipeline: Arc<GraphicsPipeline>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
}

impl PointLightingSystem {
Expand All @@ -50,8 +50,8 @@ impl PointLightingSystem {
gfx_queue: Arc<Queue>,
subpass: Subpass,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
) -> PointLightingSystem {
// TODO: vulkano doesn't allow us to draw without a vertex buffer, otherwise we could
// hard-code these values in the shader
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/deferred/frame/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{
point_lighting_system::PointLightingSystem,
};
use cgmath::{Matrix4, SquareMatrix, Vector3};
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
Expand All @@ -40,7 +40,7 @@ pub struct FrameSystem {
render_pass: Arc<RenderPass>,

memory_allocator: Arc<StandardMemoryAllocator>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,

// Intermediate render target that will contain the albedo of each pixel of the scene.
diffuse_buffer: Arc<ImageView<AttachmentImage>>,
Expand Down Expand Up @@ -74,7 +74,7 @@ impl FrameSystem {
gfx_queue: Arc<Queue>,
final_output_format: Format,
memory_allocator: Arc<StandardMemoryAllocator>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
) -> FrameSystem {
// Creating the render pass.
//
Expand Down Expand Up @@ -196,7 +196,7 @@ impl FrameSystem {
)
.unwrap();

let descriptor_set_allocator = Rc::new(StandardDescriptorSetAllocator::new(
let descriptor_set_allocator = Arc::new(StandardDescriptorSetAllocator::new(
gfx_queue.device().clone(),
));

Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/deferred/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
triangle_draw_system::TriangleDrawSystem,
};
use cgmath::{Matrix4, SquareMatrix, Vector3};
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
command_buffer::allocator::StandardCommandBufferAllocator,
device::{
Expand Down Expand Up @@ -166,7 +166,7 @@ fn main() {
};

let memory_allocator = Arc::new(StandardMemoryAllocator::new_default(device.clone()));
let command_buffer_allocator = Rc::new(StandardCommandBufferAllocator::new(device.clone()));
let command_buffer_allocator = Arc::new(StandardCommandBufferAllocator::new(device.clone()));

// Here is the basic initialization for the deferred system.
let mut frame_system = FrameSystem::new(
Expand Down
6 changes: 3 additions & 3 deletions examples/src/bin/deferred/triangle_draw_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// according to those terms.

use bytemuck::{Pod, Zeroable};
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
buffer::{BufferUsage, CpuAccessibleBuffer, TypedBufferAccess},
command_buffer::{
Expand All @@ -35,7 +35,7 @@ pub struct TriangleDrawSystem {
vertex_buffer: Arc<CpuAccessibleBuffer<[Vertex]>>,
subpass: Subpass,
pipeline: Arc<GraphicsPipeline>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
}

impl TriangleDrawSystem {
Expand All @@ -44,7 +44,7 @@ impl TriangleDrawSystem {
gfx_queue: Arc<Queue>,
subpass: Subpass,
memory_allocator: &StandardMemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
) -> TriangleDrawSystem {
let vertices = [
Vertex {
Expand Down
6 changes: 3 additions & 3 deletions examples/src/bin/interactive_fractal/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use crate::fractal_compute_pipeline::FractalComputePipeline;
use crate::place_over_frame::RenderPassPlaceOverFrame;
use cgmath::Vector2;
use std::sync::Arc;
use std::time::Instant;
use std::{rc::Rc, sync::Arc};
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
use vulkano::device::Queue;
Expand Down Expand Up @@ -64,10 +64,10 @@ impl FractalApp {
let memory_allocator = Arc::new(StandardMemoryAllocator::new_default(
gfx_queue.device().clone(),
));
let command_buffer_allocator = Rc::new(StandardCommandBufferAllocator::new(
let command_buffer_allocator = Arc::new(StandardCommandBufferAllocator::new(
gfx_queue.device().clone(),
));
let descriptor_set_allocator = Rc::new(StandardDescriptorSetAllocator::new(
let descriptor_set_allocator = Arc::new(StandardDescriptorSetAllocator::new(
gfx_queue.device().clone(),
));

Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/interactive_fractal/fractal_compute_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use cgmath::Vector2;
use rand::Rng;
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
buffer::{BufferUsage, CpuAccessibleBuffer},
command_buffer::{
Expand All @@ -31,8 +31,8 @@ pub struct FractalComputePipeline {
queue: Arc<Queue>,
pipeline: Arc<ComputePipeline>,
memory_allocator: Arc<StandardMemoryAllocator>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
palette: Arc<CpuAccessibleBuffer<[[f32; 4]]>>,
palette_size: i32,
end_color: [f32; 4],
Expand All @@ -42,8 +42,8 @@ impl FractalComputePipeline {
pub fn new(
queue: Arc<Queue>,
memory_allocator: Arc<StandardMemoryAllocator>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
) -> FractalComputePipeline {
// Initial colors
let colors = vec![
Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/interactive_fractal/pixels_draw_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// according to those terms.

use bytemuck::{Pod, Zeroable};
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
buffer::{BufferUsage, CpuAccessibleBuffer, TypedBufferAccess},
command_buffer::{
Expand Down Expand Up @@ -72,8 +72,8 @@ pub struct PixelsDrawPipeline {
gfx_queue: Arc<Queue>,
subpass: Subpass,
pipeline: Arc<GraphicsPipeline>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
vertices: Arc<CpuAccessibleBuffer<[TexturedVertex]>>,
indices: Arc<CpuAccessibleBuffer<[u32]>>,
}
Expand All @@ -83,8 +83,8 @@ impl PixelsDrawPipeline {
gfx_queue: Arc<Queue>,
subpass: Subpass,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
) -> PixelsDrawPipeline {
let (vertices, indices) = textured_quad(2.0, 2.0);
let vertex_buffer = CpuAccessibleBuffer::<[TexturedVertex]>::from_iter(
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/interactive_fractal/place_over_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// according to those terms.

use crate::pixels_draw_pipeline::PixelsDrawPipeline;
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
Expand All @@ -29,15 +29,15 @@ pub struct RenderPassPlaceOverFrame {
gfx_queue: Arc<Queue>,
render_pass: Arc<RenderPass>,
pixels_draw_pipeline: PixelsDrawPipeline,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
}

impl RenderPassPlaceOverFrame {
pub fn new(
gfx_queue: Arc<Queue>,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
output_format: Format,
) -> RenderPassPlaceOverFrame {
let render_pass = vulkano::single_pass_renderpass!(gfx_queue.device().clone(),
Expand Down
6 changes: 3 additions & 3 deletions examples/src/bin/multi_window_game_of_life/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
game_of_life::GameOfLifeComputePipeline, render_pass::RenderPassPlaceOverFrame, SCALING,
WINDOW2_HEIGHT, WINDOW2_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH,
};
use std::{collections::HashMap, rc::Rc, sync::Arc};
use std::{collections::HashMap, sync::Arc};
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
use vulkano::memory::allocator::StandardMemoryAllocator;
Expand All @@ -33,10 +33,10 @@ impl RenderPipeline {
swapchain_format: Format,
) -> RenderPipeline {
let memory_allocator = StandardMemoryAllocator::new_default(gfx_queue.device().clone());
let command_buffer_allocator = Rc::new(StandardCommandBufferAllocator::new(
let command_buffer_allocator = Arc::new(StandardCommandBufferAllocator::new(
gfx_queue.device().clone(),
));
let descriptor_set_allocator = Rc::new(StandardDescriptorSetAllocator::new(
let descriptor_set_allocator = Arc::new(StandardDescriptorSetAllocator::new(
gfx_queue.device().clone(),
));

Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/multi_window_game_of_life/game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use cgmath::Vector2;
use rand::Rng;
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
use vulkano::image::{ImageUsage, StorageImage};
Expand All @@ -34,8 +34,8 @@ use vulkano_util::renderer::DeviceImageView;
pub struct GameOfLifeComputePipeline {
compute_queue: Arc<Queue>,
compute_life_pipeline: Arc<ComputePipeline>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
life_in: Arc<CpuAccessibleBuffer<[u32]>>,
life_out: Arc<CpuAccessibleBuffer<[u32]>>,
image: DeviceImageView,
Expand Down Expand Up @@ -63,8 +63,8 @@ impl GameOfLifeComputePipeline {
pub fn new(
compute_queue: Arc<Queue>,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
size: [u32; 2],
) -> GameOfLifeComputePipeline {
let life_in = rand_grid(memory_allocator, size);
Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/multi_window_game_of_life/pixels_draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// according to those terms.

use bytemuck::{Pod, Zeroable};
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
buffer::{BufferUsage, CpuAccessibleBuffer, TypedBufferAccess},
command_buffer::{
Expand Down Expand Up @@ -72,8 +72,8 @@ pub struct PixelsDrawPipeline {
gfx_queue: Arc<Queue>,
subpass: Subpass,
pipeline: Arc<GraphicsPipeline>,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
vertices: Arc<CpuAccessibleBuffer<[TexturedVertex]>>,
indices: Arc<CpuAccessibleBuffer<[u32]>>,
}
Expand All @@ -83,8 +83,8 @@ impl PixelsDrawPipeline {
gfx_queue: Arc<Queue>,
subpass: Subpass,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
) -> PixelsDrawPipeline {
let (vertices, indices) = textured_quad(2.0, 2.0);
let vertex_buffer = CpuAccessibleBuffer::<[TexturedVertex]>::from_iter(
Expand Down
8 changes: 4 additions & 4 deletions examples/src/bin/multi_window_game_of_life/render_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// according to those terms.

use crate::pixels_draw::PixelsDrawPipeline;
use std::{rc::Rc, sync::Arc};
use std::sync::Arc;
use vulkano::{
command_buffer::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
Expand All @@ -29,15 +29,15 @@ pub struct RenderPassPlaceOverFrame {
gfx_queue: Arc<Queue>,
render_pass: Arc<RenderPass>,
pixels_draw_pipeline: PixelsDrawPipeline,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
}

impl RenderPassPlaceOverFrame {
pub fn new(
gfx_queue: Arc<Queue>,
memory_allocator: &impl MemoryAllocator,
command_buffer_allocator: Rc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Rc<StandardDescriptorSetAllocator>,
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
output_format: Format,
) -> RenderPassPlaceOverFrame {
let render_pass = vulkano::single_pass_renderpass!(gfx_queue.device().clone(),
Expand Down
Loading

0 comments on commit 8a1c91f

Please sign in to comment.