vulkan: Rename name mistake to handle
This commit is contained in:
parent
dd8a5a97ea
commit
001547dbc2
5 changed files with 22 additions and 22 deletions
|
@ -22,7 +22,7 @@ impl VkGraphicsPipeline {
|
|||
let shader_entry_name = CStr::from_bytes_with_nul(b"main\0")?;
|
||||
|
||||
let vert_shader_module =
|
||||
VkShaderModule::from_spv_file(device.clone(), "res/shaders/main.vert.spv")?;
|
||||
VkShaderModule::from_spv_file(device, "res/shaders/main.vert.spv")?;
|
||||
|
||||
let vert_shader_info = vk::PipelineShaderStageCreateInfo::default()
|
||||
.module(vert_shader_module.handle)
|
||||
|
@ -30,7 +30,7 @@ impl VkGraphicsPipeline {
|
|||
.stage(vk::ShaderStageFlags::VERTEX);
|
||||
|
||||
let frag_shader_module =
|
||||
VkShaderModule::from_spv_file(device.clone(), "res/shaders/main.frag.spv")?;
|
||||
VkShaderModule::from_spv_file(device, "res/shaders/main.frag.spv")?;
|
||||
|
||||
let frag_shader_info = vk::PipelineShaderStageCreateInfo::default()
|
||||
.module(frag_shader_module.handle)
|
||||
|
|
|
@ -187,7 +187,7 @@ impl VkRenderContext {
|
|||
.queue_submit(*queue, &[submit_info], self.in_flight_fence.handle)?
|
||||
};
|
||||
|
||||
let swapchains = [self.swapchain.swapchain.unwrap()];
|
||||
let swapchains = [self.swapchain.handle.unwrap()];
|
||||
let indices = [index];
|
||||
let present_info = vk::PresentInfoKHR::default()
|
||||
.wait_semaphores(&signal_semaphores)
|
||||
|
|
|
@ -10,7 +10,7 @@ pub struct VkShaderModule {
|
|||
}
|
||||
|
||||
impl VkShaderModule {
|
||||
pub fn from_spv_file<P: AsRef<Path>>(device: Arc<VkDevice>, path: P) -> anyhow::Result<Self> {
|
||||
pub fn from_spv_file<P: AsRef<Path>>(device: &Arc<VkDevice>, path: P) -> anyhow::Result<Self> {
|
||||
let mut file = std::fs::File::open(&path)?;
|
||||
let frag_shader_str = ash::util::read_spv(&mut file)?;
|
||||
|
||||
|
@ -26,7 +26,7 @@ impl VkShaderModule {
|
|||
);
|
||||
|
||||
Ok(Self {
|
||||
device,
|
||||
device: device.clone(),
|
||||
handle: shader_module,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct SwapchainSupportDetails(
|
|||
pub struct VkSurface {
|
||||
instance: Arc<VkInstance>,
|
||||
|
||||
pub(super) surface: vk::SurfaceKHR,
|
||||
pub(super) handle: vk::SurfaceKHR,
|
||||
}
|
||||
|
||||
impl VkSurface {
|
||||
|
@ -34,7 +34,7 @@ impl VkSurface {
|
|||
|
||||
log::debug!("Surface created ({:?})", surface);
|
||||
|
||||
Ok(Self { instance, surface })
|
||||
Ok(Self { instance, handle: surface })
|
||||
}
|
||||
|
||||
pub fn physical_device_queue_supported(
|
||||
|
@ -48,7 +48,7 @@ impl VkSurface {
|
|||
.get_physical_device_surface_support(
|
||||
physical_device.handle,
|
||||
queue_index,
|
||||
self.surface,
|
||||
self.handle,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -61,17 +61,17 @@ impl VkSurface {
|
|||
let formats = self
|
||||
.instance
|
||||
.surface_loader
|
||||
.get_physical_device_surface_formats(physical_device.handle, self.surface)?;
|
||||
.get_physical_device_surface_formats(physical_device.handle, self.handle)?;
|
||||
|
||||
let capabilities = self
|
||||
.instance
|
||||
.surface_loader
|
||||
.get_physical_device_surface_capabilities(physical_device.handle, self.surface)?;
|
||||
.get_physical_device_surface_capabilities(physical_device.handle, self.handle)?;
|
||||
|
||||
let present_modes = self
|
||||
.instance
|
||||
.surface_loader
|
||||
.get_physical_device_surface_present_modes(physical_device.handle, self.surface)?;
|
||||
.get_physical_device_surface_present_modes(physical_device.handle, self.handle)?;
|
||||
|
||||
Ok(SwapchainSupportDetails(
|
||||
formats,
|
||||
|
@ -87,8 +87,8 @@ impl Drop for VkSurface {
|
|||
unsafe {
|
||||
self.instance
|
||||
.surface_loader
|
||||
.destroy_surface(self.surface, None);
|
||||
.destroy_surface(self.handle, None);
|
||||
}
|
||||
log::debug!("Surface destroyed ({:?})", self.surface);
|
||||
log::debug!("Surface destroyed ({:?})", self.handle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct VkSwapchain {
|
|||
surface: Arc<VkSurface>,
|
||||
device: Arc<VkDevice>,
|
||||
|
||||
pub(super) swapchain: Option<vk::SwapchainKHR>,
|
||||
pub(super) handle: Option<vk::SwapchainKHR>,
|
||||
swapchain_support_details: SwapchainSupportDetails,
|
||||
|
||||
pub(super) desired_image_count: u32,
|
||||
|
@ -64,7 +64,7 @@ impl VkSwapchain {
|
|||
surface: surface.clone(),
|
||||
device: device.clone(),
|
||||
|
||||
swapchain: None,
|
||||
handle: None,
|
||||
new_requested_surface_resolution: None,
|
||||
swapchain_support_details,
|
||||
desired_image_count,
|
||||
|
@ -89,7 +89,7 @@ impl VkSwapchain {
|
|||
|
||||
let mut swapchain_create_info = self.create_swapchain_info(&self.surface);
|
||||
|
||||
if let Some(old_swapchain) = self.swapchain {
|
||||
if let Some(old_swapchain) = self.handle {
|
||||
swapchain_create_info.old_swapchain = old_swapchain;
|
||||
}
|
||||
|
||||
|
@ -114,14 +114,14 @@ impl VkSwapchain {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
if log::log_enabled!(log::Level::Debug) {
|
||||
let label = match self.swapchain {
|
||||
let label = match self.handle {
|
||||
None => "Swapchain created",
|
||||
Some(_) => "Swapchain updated",
|
||||
};
|
||||
log::debug!("{label} ({swapchain:?}) : {swapchain_create_info:#?}");
|
||||
}
|
||||
|
||||
self.swapchain = Some(swapchain);
|
||||
self.handle = Some(swapchain);
|
||||
self.present_image_views = Some(present_images_view);
|
||||
self.present_images = Some(present_images);
|
||||
|
||||
|
@ -177,7 +177,7 @@ impl VkSwapchain {
|
|||
pub(super) fn acquire_next_image(&self, semaphore: &VkSemaphore) -> VkResult<(u32, bool)> {
|
||||
unsafe {
|
||||
self.device.swapchain_loader.acquire_next_image(
|
||||
self.swapchain.unwrap(),
|
||||
self.handle.unwrap(),
|
||||
u64::MAX,
|
||||
semaphore.handle,
|
||||
vk::Fence::null(),
|
||||
|
@ -191,7 +191,7 @@ impl VkSwapchain {
|
|||
|
||||
fn create_swapchain_info(&self, surface: &VkSurface) -> vk::SwapchainCreateInfoKHR {
|
||||
vk::SwapchainCreateInfoKHR::default()
|
||||
.surface(surface.surface)
|
||||
.surface(surface.handle)
|
||||
.min_image_count(self.desired_image_count)
|
||||
.image_color_space(self.surface_format.color_space)
|
||||
.image_format(self.surface_format.format)
|
||||
|
@ -287,13 +287,13 @@ impl VkSwapchain {
|
|||
|
||||
impl Drop for VkSwapchain {
|
||||
fn drop(&mut self) {
|
||||
if let Some(swapchain) = self.swapchain {
|
||||
if let Some(swapchain) = self.handle {
|
||||
unsafe {
|
||||
self.device
|
||||
.swapchain_loader
|
||||
.destroy_swapchain(swapchain, None);
|
||||
}
|
||||
self.swapchain = None;
|
||||
self.handle = None;
|
||||
log::debug!("Swapchain destroyed ({swapchain:?})");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue