d3d12/
queue.rs

1use crate::{com::ComPtr, sync::Fence, CommandList, HRESULT};
2use winapi::um::d3d12;
3
4#[repr(u32)]
5pub enum Priority {
6    Normal = d3d12::D3D12_COMMAND_QUEUE_PRIORITY_NORMAL,
7    High = d3d12::D3D12_COMMAND_QUEUE_PRIORITY_HIGH,
8    GlobalRealtime = d3d12::D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME,
9}
10
11bitflags::bitflags! {
12    #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
13    pub struct CommandQueueFlags: u32 {
14        const DISABLE_GPU_TIMEOUT = d3d12::D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT;
15    }
16}
17
18pub type CommandQueue = ComPtr<d3d12::ID3D12CommandQueue>;
19
20impl CommandQueue {
21    pub fn execute_command_lists(&self, command_lists: &[CommandList]) {
22        let command_lists = command_lists
23            .iter()
24            .map(CommandList::as_mut_ptr)
25            .collect::<Box<[_]>>();
26        unsafe { self.ExecuteCommandLists(command_lists.len() as _, command_lists.as_ptr()) }
27    }
28
29    pub fn signal(&self, fence: &Fence, value: u64) -> HRESULT {
30        unsafe { self.Signal(fence.as_mut_ptr(), value) }
31    }
32}