pub struct Pmfx<D: Device> {
pub shader_heap: D::Heap,
pub unit_quad_mesh: Mesh<D>,
pub reloader: Reloader,
pub view_errors: Arc<Mutex<HashMap<String, String>>>,
pub active_render_graph: String,
/* private fields */
}
Expand description
Pmfx instance,containing render objects and resources
Fields§
§shader_heap: D::Heap
Heaps for shader resource view allocations
unit_quad_mesh: Mesh<D>
Unit quad mesh for fullscreen passes on the raster pipeline
reloader: Reloader
Watches for filestamp changes and will trigger callbacks in the PmfxReloadResponder
view_errors: Arc<Mutex<HashMap<String, String>>>
Errors which occur through render systems can be pushed here for feedback to the user
active_render_graph: String
Tracks the currently active render graph name
Implementations§
Source§impl<D> Pmfx<D>where
D: Device,
impl<D> Pmfx<D>where
D: Device,
Sourcepub fn create(device: &mut D, shader_heap_size: usize) -> Self
pub fn create(device: &mut D, shader_heap_size: usize) -> Self
Create a new empty pmfx instance
Sourcepub fn reserve_world_buffers(
&mut self,
device: &mut D,
info: WorldBufferReserveInfo,
)
pub fn reserve_world_buffers( &mut self, device: &mut D, info: WorldBufferReserveInfo, )
Resizes the set of world buffers used for rendering, this assumes that the buffers will be populated each frame creates new buffers if the requested count exceeds the capacity.
Sourcepub fn get_world_buffers_mut(&mut self) -> &mut DynamicWorldBuffers<D>
pub fn get_world_buffers_mut(&mut self) -> &mut DynamicWorldBuffers<D>
Returns a mutable refernce to the the world buffers, these are persistently mapped GPU buffers which can be
updated using the .write
function
Sourcepub fn get_world_buffer_info(&self) -> WorldBufferInfo
pub fn get_world_buffer_info(&self) -> WorldBufferInfo
Retunrs a WorldBufferInfo
that contains the serv index and count of the various world buffers used
during rendering
Sourcepub fn load(&mut self, filepath: &str) -> Result<(), Error>
pub fn load(&mut self, filepath: &str) -> Result<(), Error>
Load a pmfx from a folder, where the folder contains a pmfx info.json and shader binaries in separate files within the directory You can load multiple pmfx files which will be merged together, shaders are grouped by pmfx_name/ps_main.psc Render graphs and pipleines must have unique names, if multiple pmfx name a pipeline the same name
Sourcepub fn get_shader<'stack>(
&'stack self,
file: &Option<String>,
) -> Option<&'stack D::Shader>
pub fn get_shader<'stack>( &'stack self, file: &Option<String>, ) -> Option<&'stack D::Shader>
Returns a shader reference for use when building pso
Sourcepub fn create_texture(
&mut self,
device: &mut D,
texture_name: &str,
) -> Result<(), Error>
pub fn create_texture( &mut self, device: &mut D, texture_name: &str, ) -> Result<(), Error>
Creates a texture if it has not already been created from information specified in .pmfx file
Sourcepub fn get_texture<'stack>(
&'stack self,
texture_name: &str,
) -> Option<&'stack D::Texture>
pub fn get_texture<'stack>( &'stack self, texture_name: &str, ) -> Option<&'stack D::Texture>
Returns a texture reference if the texture exists or none otherwise
Sourcepub fn get_texture_2d_size(&self, texture_name: &str) -> Option<(u64, u64)>
pub fn get_texture_2d_size(&self, texture_name: &str) -> Option<(u64, u64)>
Returns the tuple (width, height) of a texture
Sourcepub fn get_texture_3d_size(&self, texture_name: &str) -> Option<(u64, u64, u32)>
pub fn get_texture_3d_size(&self, texture_name: &str) -> Option<(u64, u64, u32)>
Returns the tuple (width, height, depth) of a texture
Sourcepub fn get_texture_dimension(&self, texture_name: &str) -> Vec3u
pub fn get_texture_dimension(&self, texture_name: &str) -> Vec3u
Return 2d or 3d texture dimension where applicable with 1 default in unused dimension and zero if the texture is not found
Sourcepub fn get_view(&self, view_name: &str) -> Result<ViewRef<D>, Error>
pub fn get_view(&self, view_name: &str) -> Result<ViewRef<D>, Error>
Return a reference to a view if the view exists or error otherwise
Sourcepub fn get_compute_pass(
&self,
pass_name: &str,
) -> Result<ComputePassRef<D>, Error>
pub fn get_compute_pass( &self, pass_name: &str, ) -> Result<ComputePassRef<D>, Error>
Return a reference to a compute pass if the pass exists or error otherwise
Sourcepub fn create_render_graph_views(
&mut self,
device: &mut D,
graph_name: &str,
) -> Result<(), Error>
pub fn create_render_graph_views( &mut self, device: &mut D, graph_name: &str, ) -> Result<(), Error>
Create all views required for a render graph if necessary, skip if a view already exists
pub fn generate_mip_maps( &mut self, device: &mut D, texture_name: &str, ) -> Result<(), Error>
Sourcepub fn unload_views(&mut self)
pub fn unload_views(&mut self)
Unloads all views, so that a subsequent call to create_render_graph
wiill build from clean
make sure call this after SwapChain::wait_for_last_fame()
so any dropped resources will
not be in use on the GPU
Sourcepub fn create_render_graph(
&mut self,
device: &mut D,
graph_name: &str,
) -> Result<(), Error>
pub fn create_render_graph( &mut self, device: &mut D, graph_name: &str, ) -> Result<(), Error>
Create a render graph wih automatic resource barrier generation from info specified insie .pmfx file
Sourcepub fn create_compute_pipeline(
&mut self,
device: &D,
pipeline_name: &str,
) -> Result<(), Error>
pub fn create_compute_pipeline( &mut self, device: &D, pipeline_name: &str, ) -> Result<(), Error>
Create a ComputePipeline instance for the combination of pmfx_pipeline settings
Sourcepub fn create_render_pipeline(
&mut self,
device: &D,
pipeline_name: &str,
pass: &D::RenderPass,
) -> Result<(), Error>
pub fn create_render_pipeline( &mut self, device: &D, pipeline_name: &str, pass: &D::RenderPass, ) -> Result<(), Error>
Create a RenderPipeline instance for the combination of pmfx_pipeline settings and an associated RenderPass
Sourcepub fn get_render_pipeline_for_format<'stack>(
&'stack self,
pipeline_name: &str,
format_hash: u64,
) -> Result<&'stack D::RenderPipeline, Error>
pub fn get_render_pipeline_for_format<'stack>( &'stack self, pipeline_name: &str, format_hash: u64, ) -> Result<&'stack D::RenderPipeline, Error>
Returns a pmfx defined pipeline compatible with the supplied format hash if it exists
Sourcepub fn get_render_pipeline<'stack>(
&'stack self,
pipeline_name: &str,
) -> Result<&'stack D::RenderPipeline, Error>
pub fn get_render_pipeline<'stack>( &'stack self, pipeline_name: &str, ) -> Result<&'stack D::RenderPipeline, Error>
Returns a pmfx pipline for a random / unknown render target format… prefer to use get_render_pipeline_for_format
if you know the format the target you are rendering in to.
Sourcepub fn get_render_pipeline_permutation_for_format<'stack>(
&'stack self,
pipeline_name: &str,
permutation: u32,
format_hash: u64,
) -> Result<&'stack D::RenderPipeline, Error>
pub fn get_render_pipeline_permutation_for_format<'stack>( &'stack self, pipeline_name: &str, permutation: u32, format_hash: u64, ) -> Result<&'stack D::RenderPipeline, Error>
Returns a pmfx defined pipeline compatible with the supplied format hash if it exists
Sourcepub fn get_compute_pipeline<'stack>(
&'stack self,
pipeline_name: &str,
) -> Result<&'stack D::ComputePipeline, Error>
pub fn get_compute_pipeline<'stack>( &'stack self, pipeline_name: &str, ) -> Result<&'stack D::ComputePipeline, Error>
Fetch a prebuilt ComputePipeline
Sourcepub fn new_frame(
&mut self,
device: &mut D,
swap_chain: &D::SwapChain,
) -> Result<(), Error>
pub fn new_frame( &mut self, device: &mut D, swap_chain: &D::SwapChain, ) -> Result<(), Error>
Start a new frame and syncronise command buffers to the designated swap chain
Sourcepub fn reload(&mut self, device: &mut D) -> Result<(), Error>
pub fn reload(&mut self, device: &mut D) -> Result<(), Error>
Reload all active resources based on hashes
pub fn get_window_size(&self, window_name: &str) -> (f32, f32)
pub fn get_window_aspect(&self, window_name: &str) -> f32
Sourcepub fn update_window(
&mut self,
device: &mut D,
size: (f32, f32),
name: &str,
) -> Result<(), Error>
pub fn update_window( &mut self, device: &mut D, size: (f32, f32), name: &str, ) -> Result<(), Error>
Update render targets or views associated with a window, this will resize textures and rebuild views which need to be modified if a window size changes
Sourcepub fn update_camera_constants(
&mut self,
name: &str,
constants: &CameraConstants,
)
pub fn update_camera_constants( &mut self, name: &str, constants: &CameraConstants, )
Update camera constants for the named camera, will create a new entry if one does not exist
Sourcepub fn update_cubemap_camera_constants(
&mut self,
name: &str,
pos: Vec3f,
near: f32,
far: f32,
)
pub fn update_cubemap_camera_constants( &mut self, name: &str, pos: Vec3f, near: f32, far: f32, )
Update camera constants for the named camera, will create a new entry if one does not exist
Sourcepub fn get_camera_constants(
&self,
name: &str,
) -> Result<&CameraConstants, Error>
pub fn get_camera_constants( &self, name: &str, ) -> Result<&CameraConstants, Error>
Borrow camera constants to push into a command buffer, return None
if they do not exist
Sourcepub fn reset(&mut self, swap_chain: &D::SwapChain)
pub fn reset(&mut self, swap_chain: &D::SwapChain)
Resets all command buffers, this assumes they have been used and need to be reset for the next frame
Sourcepub fn get_render_graph_function_info(
&self,
render_graph: &str,
) -> Vec<(String, String)>
pub fn get_render_graph_function_info( &self, render_graph: &str, ) -> Vec<(String, String)>
Returns a vector of information to call render functions. It returns a tuple (function_name, view_name)
which is called as so: function_name(view)
so functions can be re-used for different views
Sourcepub fn get_render_graph_hash(&self, render_graph: &str) -> PmfxHash
pub fn get_render_graph_hash(&self, render_graph: &str) -> PmfxHash
Returns the build hash for the render graph so you can compare if the graph has rebuilt and needs reloading
pub fn get_render_graph_execute_order(&self) -> &Vec<String>
Sourcepub fn log_error(&self, view_name: &str, msg: &str)
pub fn log_error(&self, view_name: &str, msg: &str)
Log an error with an assosiated view and message.
Sourcepub fn get_total_stats(&self) -> &TotalStats
pub fn get_total_stats(&self) -> &TotalStats
Return the total statistics for the previous frame