pub struct Context { /* private fields */ }Expand description
Context for 3D (combined heightmap and normal) rendering
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(gpu: &Gpu) -> Self
pub fn new(gpu: &Gpu) -> Self
Build a new 3D rendering context, given a device and queue
If render timestamps are desirable, then the device should be
initialized with wgpu::Features::TIMESTAMP_QUERY.
Sourcepub fn buffers(&self, image_size: VoxelSize) -> Result<Buffers, BuffersError>
pub fn buffers(&self, image_size: VoxelSize) -> Result<Buffers, BuffersError>
Builds a new Buffers object for the given render size
An image rendered with the resulting buffers will have the given width
and height; image_size.depth() sets the number of voxels to evaluate
within each pixel of the image (stacked into a column going into the
screen).
Sourcepub fn image_buffer(&self, buffers: &Buffers) -> ImageReadBuffer
pub fn image_buffer(&self, buffers: &Buffers) -> ImageReadBuffer
Returns an ImageReadBuffer, sized to read from a Buffers object
This is infallible because the Buffers constructor also ensures that
the image size is appropriate for the image read buffer (even though
it’s constructed separately).
Sourcepub fn shape(&self, shape: &VmShape) -> Result<RenderShape, RenderShapeError>
pub fn shape(&self, shape: &VmShape) -> Result<RenderShape, RenderShapeError>
Builds a new RenderShape object for the given shape
Sourcepub fn run(
&self,
shape: &RenderShape,
buffers: &Buffers,
out: &mut ImageReadBuffer,
settings: RenderConfig,
) -> Result<Image, MissingVar>
pub fn run( &self, shape: &RenderShape, buffers: &Buffers, out: &mut ImageReadBuffer, settings: RenderConfig, ) -> Result<Image, MissingVar>
Renders the image, with a blocking wait to read pixel data from the GPU
This function is not present when built for the wasm32 target
Sourcepub fn run_with_vars(
&self,
shape: &RenderShape,
vars: &ShapeVars<f32>,
buffers: &Buffers,
out: &mut ImageReadBuffer,
settings: RenderConfig,
) -> Result<Image, MissingVar>
pub fn run_with_vars( &self, shape: &RenderShape, vars: &ShapeVars<f32>, buffers: &Buffers, out: &mut ImageReadBuffer, settings: RenderConfig, ) -> Result<Image, MissingVar>
Renders the image, with a blocking wait to read pixel data from the GPU
This function is not present when built for the wasm32 target
Sourcepub async fn run_async(
&self,
shape: &RenderShape,
buffers: &Buffers,
out: &mut ImageReadBuffer,
settings: RenderConfig,
) -> Result<Image, MissingVar>
pub async fn run_async( &self, shape: &RenderShape, buffers: &Buffers, out: &mut ImageReadBuffer, settings: RenderConfig, ) -> Result<Image, MissingVar>
Renders the image, with a blocking wait to read pixel data from the GPU
This function is only relevant for the web target
Sourcepub async fn run_with_vars_async(
&self,
shape: &RenderShape,
vars: &ShapeVars<f32>,
buffers: &Buffers,
out: &mut ImageReadBuffer,
settings: RenderConfig,
) -> Result<Image, MissingVar>
pub async fn run_with_vars_async( &self, shape: &RenderShape, vars: &ShapeVars<f32>, buffers: &Buffers, out: &mut ImageReadBuffer, settings: RenderConfig, ) -> Result<Image, MissingVar>
Renders the image, with a blocking wait to read pixel data from the GPU
This function is only relevant for the web target
Sourcepub fn submit(
&self,
shape: &RenderShape,
buffers: &mut Buffers,
out: Option<&mut ImageReadBuffer>,
settings: &RenderConfig,
) -> Result<(), MissingVar>
pub fn submit( &self, shape: &RenderShape, buffers: &mut Buffers, out: Option<&mut ImageReadBuffer>, settings: &RenderConfig, ) -> Result<(), MissingVar>
Submits a single image to be rendered on the GPU
The resulting image (as a buffer of GeometryPixel data) is available
on the GPU in
buffers.image_storage_buffer().
If out is present, then the rendered image is also copied to that
ImageReadBuffer (which may then be mapped for CPU reading by
map_image or
map_image_async).
Sourcepub fn submit_with_vars(
&self,
shape: &RenderShape,
vars: &ShapeVars<f32>,
buffers: &Buffers,
out: Option<&mut ImageReadBuffer>,
settings: &RenderConfig,
) -> Result<(), MissingVar>
pub fn submit_with_vars( &self, shape: &RenderShape, vars: &ShapeVars<f32>, buffers: &Buffers, out: Option<&mut ImageReadBuffer>, settings: &RenderConfig, ) -> Result<(), MissingVar>
Submits a single image to be rendered on the GPU, with extra variables
See submit for additional details.
Sourcepub fn map_image<'a>(&self, image: &'a mut ImageReadBuffer) -> MappedImage<'a>
pub fn map_image<'a>(&self, image: &'a mut ImageReadBuffer) -> MappedImage<'a>
Synchronously maps an image read buffer
The image read buffer should be populated by passing it as an argument
when calling submit.
The image is borrowed exclusively to avoid double-mapping
This is a blocking function suitable for use on the desktop
Sourcepub async fn map_image_async<'a>(
&self,
image: &'a mut ImageReadBuffer,
) -> MappedImage<'a>
pub async fn map_image_async<'a>( &self, image: &'a mut ImageReadBuffer, ) -> MappedImage<'a>
Asynchronously maps an image read buffer
The image read buffer should be populated by passing it as an argument
when calling submit.
The image is borrowed exclusively to avoid double-mapping
This is an async function suitable for use in WebAssembly.
Sourcepub fn set_buffers_image_size(
&self,
buffers: &mut Buffers,
image_size: VoxelSize,
) -> Result<(), BuffersError>
pub fn set_buffers_image_size( &self, buffers: &mut Buffers, image_size: VoxelSize, ) -> Result<(), BuffersError>
Resizes buffers to the given image size
Buffer allocations may grow but do not shrink; delete and recreate buffers if their capacity exceeds their size to a significant degree.
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
impl Freeze for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.