move pipeline loader in world
This commit is contained in:
parent
9c651c5e0a
commit
6ba61e040e
5 changed files with 70 additions and 99 deletions
|
@ -9,7 +9,7 @@ use crate::core::render::primitives::camera::Camera3D;
|
|||
use crate::core::render::primitives::transform::Transform;
|
||||
use crate::core::render::primitives::velocity::Velocity;
|
||||
use crate::core::render::primitives::vulkan_resource::{
|
||||
VulkanCommandBufferAllocator, VulkanDescriptorSetAllocator, VulkanDevice, VulkanGraphicsQueue,
|
||||
VulkanCommandBufferAllocator, VulkanDescriptorSetAllocator, VulkanGraphicsQueue,
|
||||
VulkanMemoryAllocator,
|
||||
};
|
||||
use crate::core::render::primitives::{AsDescriptorSet, AsRecordable};
|
||||
|
@ -42,7 +42,6 @@ pub struct Square;
|
|||
pub struct Cube;
|
||||
|
||||
pub struct MainSceneState {
|
||||
pipeline_loader: PipelineLoader,
|
||||
square: SquareMesh,
|
||||
obj: ObjMesh,
|
||||
camera: Camera3D,
|
||||
|
@ -65,18 +64,7 @@ impl AsScene for MainScene {
|
|||
world: &mut World,
|
||||
window_context: &mut WindowContext,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let depth_image_view = window_context.with_renderer_mut(|renderer| {
|
||||
renderer.get_additional_image_view(DEPTH_IMAGE_ID).clone()
|
||||
});
|
||||
|
||||
let swapchain_image_view =
|
||||
window_context.with_renderer(|renderer| renderer.swapchain_image_view().clone());
|
||||
|
||||
let mut pipeline_loader = PipelineLoader::new(
|
||||
VulkanDevice::get_from_world(world).clone(),
|
||||
swapchain_image_view.format(),
|
||||
depth_image_view.format(),
|
||||
);
|
||||
let mut pipeline_loader = world.resource_mut::<PipelineLoader>();
|
||||
pipeline_loader.register::<SimplePipeline>()?;
|
||||
pipeline_loader.load_pending_pipelines()?;
|
||||
|
||||
|
@ -138,7 +126,6 @@ impl AsScene for MainScene {
|
|||
self.state = Some(MainSceneState {
|
||||
square,
|
||||
obj,
|
||||
pipeline_loader,
|
||||
camera,
|
||||
speed: 50.0,
|
||||
scheduler,
|
||||
|
@ -257,36 +244,35 @@ impl AsScene for MainScene {
|
|||
)?;
|
||||
|
||||
let texture_loader = world.resource::<TextureLoader>();
|
||||
let pipeline_loader = world.resource::<PipelineLoader>();
|
||||
|
||||
state
|
||||
.pipeline_loader
|
||||
.with_pipeline::<SimplePipeline, _>(|pipeline| {
|
||||
SimplePipeline::record_commands(
|
||||
&mut builder,
|
||||
&VulkanDescriptorSetAllocator::get_from_world(world),
|
||||
pipeline,
|
||||
&state.square,
|
||||
&square_transform_uniform,
|
||||
vec![
|
||||
camera_uniform.clone() as Arc<dyn AsDescriptorSet>,
|
||||
texture_loader.get_texture("wooden-crate").unwrap().clone(),
|
||||
],
|
||||
)?;
|
||||
pipeline_loader.with_pipeline::<SimplePipeline, _>(|pipeline| {
|
||||
SimplePipeline::record_commands(
|
||||
&mut builder,
|
||||
&VulkanDescriptorSetAllocator::get_from_world(world),
|
||||
pipeline,
|
||||
&state.square,
|
||||
&square_transform_uniform,
|
||||
vec![
|
||||
camera_uniform.clone() as Arc<dyn AsDescriptorSet>,
|
||||
texture_loader.get_texture("wooden-crate").unwrap().clone(),
|
||||
],
|
||||
)?;
|
||||
|
||||
SimplePipeline::record_commands(
|
||||
&mut builder,
|
||||
&VulkanDescriptorSetAllocator::get_from_world(world),
|
||||
pipeline,
|
||||
&state.obj,
|
||||
&cube_transform_uniform,
|
||||
vec![
|
||||
camera_uniform.clone() as Arc<dyn AsDescriptorSet>,
|
||||
texture_loader.get_texture("cube-diffuse").unwrap().clone(),
|
||||
],
|
||||
)?;
|
||||
SimplePipeline::record_commands(
|
||||
&mut builder,
|
||||
&VulkanDescriptorSetAllocator::get_from_world(world),
|
||||
pipeline,
|
||||
&state.obj,
|
||||
&cube_transform_uniform,
|
||||
vec![
|
||||
camera_uniform.clone() as Arc<dyn AsDescriptorSet>,
|
||||
texture_loader.get_texture("cube-diffuse").unwrap().clone(),
|
||||
],
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(())
|
||||
})?;
|
||||
|
||||
RenderPassManager::end_rendering(&mut builder)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue