idk man...
This commit is contained in:
parent
7b7badd4d4
commit
d29b121aca
|
@ -16,6 +16,10 @@ struct WindowState {
|
|||
egui_platform: egui_winit_platform::Platform,
|
||||
}
|
||||
|
||||
struct EguiRenderState {
|
||||
textures: BTreeMap<u64, ()>,
|
||||
}
|
||||
|
||||
struct WinitState {
|
||||
last_resize_events: BTreeMap<WindowId, PhysicalSize<u32>>,
|
||||
window_attrs: WindowAttributes,
|
||||
|
@ -77,7 +81,11 @@ impl WinitState {
|
|||
|
||||
// rendering
|
||||
self.renderer
|
||||
.debug_draw(&window_id, || window.window.pre_present_notify())
|
||||
.debug_draw(
|
||||
&window_id,
|
||||
|| { // window.window.pre_present_notify()
|
||||
},
|
||||
)
|
||||
.expect("drawing");
|
||||
window.window.request_redraw();
|
||||
}
|
||||
|
|
|
@ -1,19 +1,31 @@
|
|||
use super::{Device, Queue, VkAllocator};
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::{Device, Queue};
|
||||
use ash::{prelude::*, vk};
|
||||
use vk_mem::Alloc;
|
||||
|
||||
pub struct Image2D {
|
||||
alloc: VkAllocator,
|
||||
image: vk::Image,
|
||||
device: Device,
|
||||
size: vk::Extent2D,
|
||||
mip_levels: u32,
|
||||
format: vk::Format,
|
||||
image: vk::Image,
|
||||
allocation: vk_mem::Allocation,
|
||||
}
|
||||
|
||||
impl Drop for Image2D {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
self.device
|
||||
.alloc()
|
||||
.destroy_image(self.image, &mut self.allocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Image2D {
|
||||
pub fn new_exclusive(
|
||||
alloc: VkAllocator,
|
||||
device: &Device,
|
||||
extent: vk::Extent2D,
|
||||
mip_levels: u32,
|
||||
array_layers: u32,
|
||||
|
@ -22,7 +34,7 @@ impl Image2D {
|
|||
usage: vk::ImageUsageFlags,
|
||||
memory_usage: vk_mem::MemoryUsage,
|
||||
alloc_flags: vk_mem::AllocationCreateFlags,
|
||||
) -> VkResult<Image2D> {
|
||||
) -> VkResult<Arc<Self>> {
|
||||
let create_info = vk::ImageCreateInfo::default()
|
||||
.array_layers(array_layers)
|
||||
.mip_levels(mip_levels)
|
||||
|
@ -46,25 +58,25 @@ impl Image2D {
|
|||
};
|
||||
|
||||
let (image, allocation) =
|
||||
unsafe { alloc.create_image(&create_info, &alloc_info)? };
|
||||
unsafe { device.alloc().create_image(&create_info, &alloc_info)? };
|
||||
|
||||
Ok(Self {
|
||||
alloc,
|
||||
image,
|
||||
Ok(Arc::new(Self {
|
||||
size: extent,
|
||||
mip_levels,
|
||||
format,
|
||||
device: device.clone(),
|
||||
image,
|
||||
allocation,
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn view(
|
||||
&self,
|
||||
self: &Arc<Self>,
|
||||
device: &Device,
|
||||
aspect: vk::ImageAspectFlags,
|
||||
) -> VkResult<vk::ImageView> {
|
||||
) -> VkResult<Arc<ImageView2D>> {
|
||||
let create_info = vk::ImageViewCreateInfo::default()
|
||||
.image(self.image)
|
||||
.image(self.image())
|
||||
.view_type(vk::ImageViewType::TYPE_2D)
|
||||
.format(self.format)
|
||||
.components(vk::ComponentMapping::default())
|
||||
|
@ -80,7 +92,11 @@ impl Image2D {
|
|||
let view =
|
||||
unsafe { device.dev().create_image_view(&create_info, None)? };
|
||||
|
||||
Ok(view)
|
||||
Ok(Arc::new(ImageView2D {
|
||||
view,
|
||||
image: self.clone(),
|
||||
aspect,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn image(&self) -> vk::Image {
|
||||
|
@ -88,14 +104,22 @@ impl Image2D {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for Image2D {
|
||||
pub struct ImageView2D {
|
||||
view: vk::ImageView,
|
||||
aspect: vk::ImageAspectFlags,
|
||||
image: Arc<Image2D>,
|
||||
}
|
||||
|
||||
impl Drop for ImageView2D {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
self.alloc.destroy_image(self.image, &mut self.allocation);
|
||||
self.image.device.dev().destroy_image_view(self.view, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ImageView2D {}
|
||||
|
||||
pub struct QueueOwnership {
|
||||
src: u32,
|
||||
dst: u32,
|
||||
|
|
|
@ -36,9 +36,8 @@ use tracing::info;
|
|||
mod commands;
|
||||
mod images;
|
||||
mod render_graph;
|
||||
mod sync;
|
||||
|
||||
type VkAllocator = Arc<vk_mem::Allocator>;
|
||||
mod sync;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
|
@ -470,6 +469,7 @@ impl DeviceQueueFamilies {
|
|||
struct DeviceInner {
|
||||
instance: Arc<Instance>,
|
||||
physical: PhysicalDevice,
|
||||
alloc: vk_mem::Allocator,
|
||||
device: ash::Device,
|
||||
swapchain: khr::swapchain::Device,
|
||||
debug_utils: ash::ext::debug_utils::Device,
|
||||
|
@ -505,6 +505,9 @@ impl Device {
|
|||
fn weak(&self) -> WeakDevice {
|
||||
Arc::downgrade(&self.0)
|
||||
}
|
||||
fn alloc(&self) -> &vk_mem::Allocator {
|
||||
&self.0.alloc
|
||||
}
|
||||
fn dev(&self) -> &ash::Device {
|
||||
&self.0.device
|
||||
}
|
||||
|
@ -1194,7 +1197,6 @@ impl Drop for Surface {
|
|||
pub struct Vulkan {
|
||||
instance: Arc<Instance>,
|
||||
device: Device,
|
||||
alloc: VkAllocator,
|
||||
}
|
||||
|
||||
impl Drop for Vulkan {
|
||||
|
@ -1393,19 +1395,7 @@ impl Vulkan {
|
|||
let device =
|
||||
Self::create_device(instance.clone(), pdev, &mut features)?;
|
||||
|
||||
let alloc_info = vk_mem::AllocatorCreateInfo::new(
|
||||
&instance.instance,
|
||||
device.dev(),
|
||||
device.phy(),
|
||||
);
|
||||
|
||||
let alloc = Arc::new(unsafe { vk_mem::Allocator::new(alloc_info)? });
|
||||
|
||||
Ok(Self {
|
||||
instance,
|
||||
device,
|
||||
alloc,
|
||||
})
|
||||
Ok(Self { instance, device })
|
||||
}
|
||||
|
||||
fn queue_family_supports_presentation(
|
||||
|
@ -1693,6 +1683,14 @@ impl Vulkan {
|
|||
.map(get_queue)
|
||||
.unwrap_or(compute_queue.clone());
|
||||
|
||||
let alloc_info = vk_mem::AllocatorCreateInfo::new(
|
||||
&instance.instance,
|
||||
&device,
|
||||
pdev.pdev,
|
||||
);
|
||||
|
||||
let alloc = unsafe { vk_mem::Allocator::new(alloc_info)? };
|
||||
|
||||
Device::new(DeviceInner {
|
||||
device: device.clone(),
|
||||
physical: pdev,
|
||||
|
@ -1705,6 +1703,7 @@ impl Vulkan {
|
|||
&device,
|
||||
),
|
||||
instance,
|
||||
alloc,
|
||||
allocated_queues,
|
||||
main_queue,
|
||||
present_queue,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ash::vk;
|
||||
|
||||
struct Rgba([f32;4]);
|
||||
struct Rgba([f32; 4]);
|
||||
|
||||
enum LoadOp {
|
||||
Clear(Rgba),
|
||||
|
@ -9,7 +9,8 @@ enum LoadOp {
|
|||
}
|
||||
|
||||
enum StoreOp {
|
||||
DontCare,Store,
|
||||
DontCare,
|
||||
Store,
|
||||
}
|
||||
|
||||
struct AttachmentInfo {
|
||||
|
@ -23,5 +24,4 @@ struct Texture {
|
|||
texture: vk::Image,
|
||||
}
|
||||
|
||||
pub struct RenderGraph {
|
||||
}
|
||||
pub struct RenderGraph {}
|
||||
|
|
Loading…
Reference in a new issue