fix: use window inner_size() for resize on Wayland
Wayland surface always reports current_extent as 0xFFFFFFFF (undefined), meaning the swapchain size is determined by the application, not the surface. Previous code returned early when this happened, so resize never worked — cells stretched to fill the window. Fix: when current_extent is 0xFFFFFFFF, use winit's window.inner_size() to get the actual pixel dimensions. This works on both X11 and Wayland. Both renderers (ascii + graphics) updated. 109 tests, 0 failures
This commit is contained in:
@@ -65,7 +65,7 @@ pub struct GraphicsRenderer {
|
|||||||
instance_ptr: *mut ColorInstance,
|
instance_ptr: *mut ColorInstance,
|
||||||
instance_count: usize,
|
instance_count: usize,
|
||||||
|
|
||||||
_window: Arc<winit::window::Window>,
|
window: Arc<winit::window::Window>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GraphicsRenderer {
|
impl GraphicsRenderer {
|
||||||
@@ -300,7 +300,7 @@ impl GraphicsRenderer {
|
|||||||
image_available, render_finished, in_flight, frame_index: 0,
|
image_available, render_finished, in_flight, frame_index: 0,
|
||||||
vertex_buffer, vertex_memory, index_buffer, index_memory,
|
vertex_buffer, vertex_memory, index_buffer, index_memory,
|
||||||
instance_buffer, instance_memory, instance_ptr, instance_count,
|
instance_buffer, instance_memory, instance_ptr, instance_count,
|
||||||
_window: window,
|
window,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +451,12 @@ impl GraphicsRenderer {
|
|||||||
let new_extent = if caps.current_extent.width != u32::MAX {
|
let new_extent = if caps.current_extent.width != u32::MAX {
|
||||||
caps.current_extent
|
caps.current_extent
|
||||||
} else {
|
} else {
|
||||||
return;
|
// Wayland: surface extent is undefined, use window inner size
|
||||||
|
let inner = self.window.inner_size();
|
||||||
|
vk::Extent2D {
|
||||||
|
width: inner.width.max(1),
|
||||||
|
height: inner.height.max(1),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if new_extent.width == self.swapchain_extent.width
|
if new_extent.width == self.swapchain_extent.width
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ pub struct VulkanRenderer {
|
|||||||
descriptor_set: vk::DescriptorSet,
|
descriptor_set: vk::DescriptorSet,
|
||||||
descriptor_set_layout: vk::DescriptorSetLayout,
|
descriptor_set_layout: vk::DescriptorSetLayout,
|
||||||
tick_count: u64,
|
tick_count: u64,
|
||||||
|
window: Arc<winit::window::Window>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VulkanRenderer {
|
impl VulkanRenderer {
|
||||||
@@ -157,6 +158,7 @@ impl VulkanRenderer {
|
|||||||
instance_buffer, instance_memory, instance_ptr, instance_count,
|
instance_buffer, instance_memory, instance_ptr, instance_count,
|
||||||
descriptor_pool, descriptor_set, descriptor_set_layout,
|
descriptor_pool, descriptor_set, descriptor_set_layout,
|
||||||
tick_count: 0,
|
tick_count: 0,
|
||||||
|
window,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +323,12 @@ impl VulkanRenderer {
|
|||||||
let new_extent = if caps.current_extent.width != u32::MAX {
|
let new_extent = if caps.current_extent.width != u32::MAX {
|
||||||
caps.current_extent
|
caps.current_extent
|
||||||
} else {
|
} else {
|
||||||
return;
|
// Wayland: surface extent is undefined, use window inner size
|
||||||
|
let inner = self.window.inner_size();
|
||||||
|
vk::Extent2D {
|
||||||
|
width: inner.width.max(1),
|
||||||
|
height: inner.height.max(1),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if new_extent.width == self.swapchain_extent.width
|
if new_extent.width == self.swapchain_extent.width
|
||||||
|
|||||||
Reference in New Issue
Block a user