OffscreenFrameTarget
- Namespace: Turian.Engine.Core
- Source File: OffscreenFrameTarget.cs, OffscreenFrameTarget.Images.cs
Per-viewer offscreen render target. Mirrors SwapChain's attachment structure (MSAA color + depth + resolve) so existing render-system pipelines are compatible. The resolved image is blitted to a host-visible staging buffer each frame for CPU readback into an Avalonia WriteableBitmap. One instance per scene-viewer panel; all instances share the same Vulkan device.
Fields
ColorFormat (Format) = Format.B8G8R8A8Unorm: Color format used for the offscreen images. Matches Avalonia's Bgra8888 pixel format.
Properties
RenderPass
(RenderPass): Gets the render pass. Compatible with any pipeline built for the same format + MSAA sample count.
Width
(uint) { get; set }: Gets the current render width in pixels.
Height
(uint) { get; set }: Gets the current render height in pixels.
Public Methods
BeginFrame
public CommandBuffer? BeginFrame()
Begins a frame. Returns the command buffer to record rendering commands into, or null if the target has zero size.
Returns: CommandBuffer?
BeginRenderPass
public void BeginRenderPass(CommandBuffer cmd)
Begins the render pass on the given command buffer.
Parameters:
cmd(CommandBuffer)
EndRenderPass
public void EndRenderPass(CommandBuffer cmd)
Ends the render pass.
Parameters:
cmd(CommandBuffer)
EndFrame
public void EndFrame()
Ends the frame: copies the resolved color image into the staging buffer, submits, and waits for completion so the staging buffer is ready for CopyToSpan.
CopyToSpan
public void CopyToSpan(Span<byte> destination)
Copies the last rendered frame's pixels (BGRA8) into the given span. The span must be at least Width * Height * 4 bytes.
Parameters:
destination(Span)
Resize
public void Resize(uint newWidth, uint newHeight)
Resizes the target. Disposes and recreates all Vulkan resources.
Parameters:
newWidth(uint)newHeight(uint)
Dispose
public void Dispose()