idk?
This commit is contained in:
parent
d942589108
commit
cfc5f8594c
|
|
@ -101,7 +101,50 @@ impl Plugin for RenderPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_vulkan(app: &mut App) -> Option<()> {
|
fn init_vulkan(app: &mut App) -> Option<()> {
|
||||||
let device = renderer::device::Device::new_from_default_desc(None, &[]).ok()?;
|
let instance_desc = renderer::instance::InstanceDesc {
|
||||||
|
app_name: Some("Vidya"),
|
||||||
|
layers: &[],
|
||||||
|
layer_settings: &[],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let instance = renderer::instance::Instance::new(&instance_desc).ok()?;
|
||||||
|
|
||||||
|
let required_extensions = [
|
||||||
|
renderer::make_extension!(renderer::ash::ext::mesh_shader),
|
||||||
|
renderer::make_extension!(renderer::ash::ext::index_type_uint8),
|
||||||
|
renderer::make_extension!(renderer::ash::khr::spirv_1_4),
|
||||||
|
];
|
||||||
|
let features = renderer::PhysicalDeviceFeatures {
|
||||||
|
core: renderer::ash::vk::PhysicalDeviceFeatures::default()
|
||||||
|
.sampler_anisotropy(true)
|
||||||
|
.fill_mode_non_solid(true)
|
||||||
|
.multi_draw_indirect(true),
|
||||||
|
core11: renderer::ash::vk::PhysicalDeviceVulkan11Features::default()
|
||||||
|
.shader_draw_parameters(true),
|
||||||
|
core12: renderer::ash::vk::PhysicalDeviceVulkan12Features::default()
|
||||||
|
.shader_int8(true)
|
||||||
|
.runtime_descriptor_array(true)
|
||||||
|
.descriptor_binding_partially_bound(true)
|
||||||
|
.shader_sampled_image_array_non_uniform_indexing(true)
|
||||||
|
.descriptor_binding_sampled_image_update_after_bind(true)
|
||||||
|
.storage_buffer8_bit_access(true),
|
||||||
|
core13: renderer::ash::vk::PhysicalDeviceVulkan13Features::default()
|
||||||
|
.synchronization2(true)
|
||||||
|
.dynamic_rendering(true)
|
||||||
|
.maintenance4(true),
|
||||||
|
mesh_shader: Some(
|
||||||
|
renderer::ash::vk::PhysicalDeviceMeshShaderFeaturesEXT::default()
|
||||||
|
.mesh_shader(true)
|
||||||
|
.task_shader(true),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
let adapter = instance
|
||||||
|
.choose_adapter_default(None, &required_extensions, Some(&features))
|
||||||
|
.ok()?;
|
||||||
|
let device = adapter
|
||||||
|
.create_logical_device(&instance, &required_extensions, features, None)
|
||||||
|
.ok()?;
|
||||||
|
|
||||||
let device = RenderDevice { device };
|
let device = RenderDevice { device };
|
||||||
app.insert_resource(device.clone());
|
app.insert_resource(device.clone());
|
||||||
|
|
|
||||||
|
|
@ -139,27 +139,49 @@ pub(crate) fn configure_surfaces(
|
||||||
window.handle.get_window_handle(),
|
window.handle.get_window_handle(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let surface = WindowSurface::new(
|
let surface = unsafe {
|
||||||
(**device).clone(),
|
Surface::new_from_raw_window_handle(
|
||||||
vk::Extent2D {
|
device.instance(),
|
||||||
width: window.physical_width,
|
display_handle,
|
||||||
height: window.physical_height,
|
window_handle,
|
||||||
},
|
)
|
||||||
window_handle,
|
}
|
||||||
display_handle,
|
|
||||||
)
|
|
||||||
.expect("Failed to create window surface");
|
.expect("Failed to create window surface");
|
||||||
|
surface
|
||||||
|
.configure(
|
||||||
|
&**device,
|
||||||
|
SwapchainConfiguration {
|
||||||
|
extent: vk::Extent2D {
|
||||||
|
width: window.physical_width,
|
||||||
|
height: window.physical_height,
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.expect("Failed to configure window surface");
|
||||||
|
|
||||||
SurfaceData { surface }
|
SurfaceData { surface }
|
||||||
});
|
});
|
||||||
|
|
||||||
if window.size_changed {
|
if window.size_changed {
|
||||||
|
let config = surface
|
||||||
|
.surface
|
||||||
|
.swapchain()
|
||||||
|
.as_ref()
|
||||||
|
.map(|swapchain| swapchain.config().clone())
|
||||||
|
.unwrap_or_default();
|
||||||
surface
|
surface
|
||||||
.surface
|
.surface
|
||||||
.recreate_with(Some(vk::Extent2D {
|
.configure(
|
||||||
width: window.physical_width,
|
&**device,
|
||||||
height: window.physical_height,
|
SwapchainConfiguration {
|
||||||
}))
|
extent: vk::Extent2D {
|
||||||
|
width: window.physical_width,
|
||||||
|
height: window.physical_height,
|
||||||
|
},
|
||||||
|
..config
|
||||||
|
},
|
||||||
|
)
|
||||||
.expect("Failed to recreate surface");
|
.expect("Failed to recreate surface");
|
||||||
}
|
}
|
||||||
surfaces.configured.insert(window.entity);
|
surfaces.configured.insert(window.entity);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue