Pmfx

Struct Pmfx 

Source
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,

Source

pub fn create(device: &mut D, shader_heap_size: usize) -> Self

Create a new empty pmfx instance

Source

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.

Source

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

Source

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

Source

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

Source

pub fn get_shader<'stack>( &'stack self, file: &Option<String>, ) -> Option<&'stack D::Shader>

Returns a shader reference for use when building pso

Source

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

Source

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

Source

pub fn get_texture_2d_size(&self, texture_name: &str) -> Option<(u64, u64)>

Returns the tuple (width, height) of a texture

Source

pub fn get_texture_3d_size(&self, texture_name: &str) -> Option<(u64, u64, u32)>

Returns the tuple (width, height, depth) of a texture

Source

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

Source

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

Source

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

Source

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

Source

pub fn generate_mip_maps( &mut self, device: &mut D, texture_name: &str, ) -> Result<(), Error>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

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

Source

pub fn get_compute_pipeline<'stack>( &'stack self, pipeline_name: &str, ) -> Result<&'stack D::ComputePipeline, Error>

Fetch a prebuilt ComputePipeline

Source

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

Source

pub fn reload(&mut self, device: &mut D) -> Result<(), Error>

Reload all active resources based on hashes

Source

pub fn get_window_size(&self, window_name: &str) -> (f32, f32)

Source

pub fn get_window_aspect(&self, window_name: &str) -> f32

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn get_render_graph_execute_order(&self) -> &Vec<String>

Source

pub fn execute(&mut self, device: &mut D)

Execute command buffers in order

Source

pub fn log_error(&self, view_name: &str, msg: &str)

Log an error with an assosiated view and message.

Source

pub fn get_total_stats(&self) -> &TotalStats

Return the total statistics for the previous frame

Trait Implementations§

Source§

impl<D, A> UserInterface<D, A> for Pmfx<D>
where D: Device, A: App, D::RenderPipeline: Pipeline,

Source§

fn show_ui(&mut self, imgui: &mut ImGui<D, A>, open: bool) -> bool

Auto Trait Implementations§

§

impl<D> Freeze for Pmfx<D>
where <D as Device>::Heap: Freeze, <D as Device>::Buffer: Freeze,

§

impl<D> RefUnwindSafe for Pmfx<D>

§

impl<D> Send for Pmfx<D>

§

impl<D> Sync for Pmfx<D>

§

impl<D> Unpin for Pmfx<D>
where <D as Device>::Heap: Unpin, <D as Device>::Buffer: Unpin, <D as Device>::CmdBuf: Unpin, <D as Device>::ComputePipeline: Unpin, <D as Device>::Shader: Unpin, <D as Device>::QueryHeap: Unpin, <D as Device>::Texture: Unpin, <D as Device>::RenderPipeline: Unpin,

§

impl<D> UnwindSafe for Pmfx<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.