aboutsummaryrefslogtreecommitdiff
path: root/src/command_buffer/synced/tests.rs
blob: d40654ba386b037df950ba07bda48a7ca189a8ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2016 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.

use crate::buffer::BufferUsage;
use crate::buffer::CpuAccessibleBuffer;
use crate::command_buffer::pool::CommandPool;
use crate::command_buffer::pool::CommandPoolBuilderAlloc;
use crate::command_buffer::synced::base::SyncCommandBufferBuilder;
use crate::command_buffer::synced::base::SyncCommandBufferBuilderError;
use crate::command_buffer::sys::Flags;
use crate::command_buffer::Kind;
use crate::device::Device;
use std::iter;

#[test]
fn basic_creation() {
    unsafe {
        let (device, queue) = gfx_dev_and_queue!();
        let pool = Device::standard_command_pool(&device, queue.family());
        let pool_builder_alloc = pool.alloc(false, 1).unwrap().next().unwrap();
        SyncCommandBufferBuilder::new(&pool_builder_alloc.inner(), Kind::primary(), Flags::None)
            .unwrap();
    }
}

#[test]
fn basic_conflict() {
    unsafe {
        let (device, queue) = gfx_dev_and_queue!();

        let pool = Device::standard_command_pool(&device, queue.family());
        let pool_builder_alloc = pool.alloc(false, 1).unwrap().next().unwrap();
        let mut sync = SyncCommandBufferBuilder::new(
            &pool_builder_alloc.inner(),
            Kind::primary(),
            Flags::None,
        )
        .unwrap();
        let buf = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), false, 0u32).unwrap();

        match sync.copy_buffer(buf.clone(), buf.clone(), iter::once((0, 0, 4))) {
            Err(SyncCommandBufferBuilderError::Conflict { .. }) => (),
            _ => panic!(),
        };
    }
}