#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
use crate::empty::RafxCommandPoolEmpty;
#[cfg(feature = "rafx-metal")]
use crate::metal::RafxCommandPoolMetal;
#[cfg(feature = "rafx-vulkan")]
use crate::vulkan::RafxCommandPoolVulkan;
use crate::{RafxCommandBuffer, RafxCommandBufferDef, RafxDeviceContext, RafxResult};
pub enum RafxCommandPool {
#[cfg(feature = "rafx-vulkan")]
Vk(RafxCommandPoolVulkan),
#[cfg(feature = "rafx-metal")]
Metal(RafxCommandPoolMetal),
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
Empty(RafxCommandPoolEmpty),
}
impl RafxCommandPool {
pub fn device_context(&self) -> RafxDeviceContext {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxCommandPool::Vk(inner) => RafxDeviceContext::Vk(inner.device_context().clone()),
#[cfg(feature = "rafx-metal")]
RafxCommandPool::Metal(inner) => {
RafxDeviceContext::Metal(inner.device_context().clone())
}
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxCommandPool::Empty(inner) => {
RafxDeviceContext::Empty(inner.device_context().clone())
}
}
}
pub fn create_command_buffer(
&mut self,
command_buffer_def: &RafxCommandBufferDef,
) -> RafxResult<RafxCommandBuffer> {
Ok(match self {
#[cfg(feature = "rafx-vulkan")]
RafxCommandPool::Vk(inner) => {
RafxCommandBuffer::Vk(inner.create_command_buffer(command_buffer_def)?)
}
#[cfg(feature = "rafx-metal")]
RafxCommandPool::Metal(inner) => {
RafxCommandBuffer::Metal(inner.create_command_buffer(command_buffer_def)?)
}
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxCommandPool::Empty(inner) => {
RafxCommandBuffer::Empty(inner.create_command_buffer(command_buffer_def)?)
}
})
}
pub fn reset_command_pool(&mut self) -> RafxResult<()> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxCommandPool::Vk(inner) => inner.reset_command_pool(),
#[cfg(feature = "rafx-metal")]
RafxCommandPool::Metal(inner) => inner.reset_command_pool(),
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxCommandPool::Empty(inner) => inner.reset_command_pool(),
}
}
#[cfg(feature = "rafx-vulkan")]
pub fn vk_command_pool(&self) -> Option<&RafxCommandPoolVulkan> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxCommandPool::Vk(inner) => Some(inner),
#[cfg(feature = "rafx-metal")]
RafxCommandPool::Metal(_inner) => None,
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxCommandPool::Empty(_inner) => None,
}
}
#[cfg(feature = "rafx-metal")]
pub fn metal_command_pool(&self) -> Option<&RafxCommandPoolMetal> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxCommandPool::Vk(_inner) => None,
#[cfg(feature = "rafx-metal")]
RafxCommandPool::Metal(inner) => Some(inner),
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxCommandPool::Empty(_inner) => None,
}
}
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
pub fn empty_command_pool(&self) -> Option<&RafxCommandPoolEmpty> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxCommandPool::Vk(_inner) => None,
#[cfg(feature = "rafx-metal")]
RafxCommandPool::Metal(_inner) => None,
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxCommandPool::Empty(inner) => Some(inner),
}
}
}