2020-04-12 01:40:30 +00:00
|
|
|
use super::RenderResourceContext;
|
2020-04-12 21:47:41 +00:00
|
|
|
use crate::{
|
2020-04-13 20:04:31 +00:00
|
|
|
pass::{PassDescriptor, RenderPass},
|
2020-04-12 21:47:41 +00:00
|
|
|
pipeline::{BindGroupDescriptor, PipelineDescriptor},
|
|
|
|
render_resource::{RenderResource, RenderResourceAssignments, RenderResourceSetId},
|
|
|
|
shader::Shader,
|
|
|
|
texture::TextureDescriptor,
|
|
|
|
};
|
|
|
|
use bevy_asset::{AssetStorage, Handle};
|
2020-04-09 22:03:54 +00:00
|
|
|
|
|
|
|
pub trait RenderContext {
|
2020-04-12 01:40:30 +00:00
|
|
|
fn resources(&self) -> &dyn RenderResourceContext;
|
|
|
|
fn resources_mut(&mut self) -> &mut dyn RenderResourceContext;
|
|
|
|
|
2020-04-09 22:03:54 +00:00
|
|
|
fn create_texture_with_data(
|
|
|
|
&mut self,
|
|
|
|
texture_descriptor: &TextureDescriptor,
|
2020-04-10 08:39:38 +00:00
|
|
|
bytes: &[u8],
|
2020-04-09 22:03:54 +00:00
|
|
|
) -> RenderResource;
|
|
|
|
fn copy_buffer_to_buffer(
|
|
|
|
&mut self,
|
|
|
|
source_buffer: RenderResource,
|
|
|
|
source_offset: u64,
|
|
|
|
destination_buffer: RenderResource,
|
|
|
|
destination_offset: u64,
|
|
|
|
size: u64,
|
|
|
|
);
|
2020-04-12 21:47:41 +00:00
|
|
|
fn create_bind_group(
|
|
|
|
&mut self,
|
|
|
|
bind_group_descriptor: &BindGroupDescriptor,
|
|
|
|
render_resource_assignments: &RenderResourceAssignments,
|
|
|
|
) -> Option<RenderResourceSetId>;
|
|
|
|
fn create_render_pipeline(
|
|
|
|
&mut self,
|
|
|
|
pipeline_handle: Handle<PipelineDescriptor>,
|
2020-04-24 04:06:40 +00:00
|
|
|
pipeline_descriptor: &PipelineDescriptor,
|
2020-04-12 21:47:41 +00:00
|
|
|
shader_storage: &AssetStorage<Shader>,
|
|
|
|
);
|
|
|
|
fn setup_bind_groups(
|
|
|
|
&mut self,
|
|
|
|
pipeline_descriptor: &PipelineDescriptor,
|
|
|
|
render_resource_assignments: &RenderResourceAssignments,
|
|
|
|
) {
|
|
|
|
let pipeline_layout = pipeline_descriptor.get_layout().unwrap();
|
|
|
|
for bind_group in pipeline_layout.bind_groups.iter() {
|
|
|
|
self.create_bind_group(bind_group, render_resource_assignments);
|
|
|
|
}
|
|
|
|
}
|
2020-04-13 20:04:31 +00:00
|
|
|
fn begin_pass(
|
|
|
|
&mut self,
|
|
|
|
pass_descriptor: &PassDescriptor,
|
|
|
|
render_resource_assignments: &RenderResourceAssignments,
|
2020-04-15 22:55:00 +00:00
|
|
|
run_pass: &mut dyn Fn(&mut dyn RenderPass),
|
2020-04-13 20:04:31 +00:00
|
|
|
);
|
2020-04-09 22:03:54 +00:00
|
|
|
}
|