nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.Drawing.DirectX / DxRenderSurface

DxRenderSurface

Full name Microsoft.VisualBasic.Drawing.DirectX.DxRenderSurface Assembly Microsoft.VisualBasic.Drawing.DirectX Members 15

The abstract gpu render surface that the DxGraphics canvas draws on.

00 Remarks

Two render surfaces are implemented in this project:

  1. DxRenderTarget - an off screen d3d11 texture, the rendered pixels can be read back into the managed memory for generating the raster image output
  2. DxSwapChainTarget - a dxgi flip model swap chain that is bound to a window handle, every finished frame is presented onto the window

The whole drawing implementation of DxGraphics only depends on this contract, so that exactly the same drawing code runs on both of the surfaces.

01 Syntax

Microsoft.VisualBasic.Drawing.DirectX.DxRenderSurface

02 Methods

NameOverloadsSummary
Resize 1 update the size of this surface, the native resources of the new size must be recreated by the implementation.
BeginDraw 1 open a new drawing batch on the render target
EndDraw 1 finish the current drawing batch, for a window surface the frame is presented onto the screen here.
Recreate 1 rebuild the native resources after DxRenderSurface.NeedsRecreate is set
Flush 1 submit all of the pending drawing commands to the gpu device
ReadPixels 1 read back the rendered pixels from the gpu device
SetSize 1 update the canvas size, this is only called by the implementation of DxRenderSurface.Resize())
ReleaseHandle 1 release every native resource that is owned by this surface

03 Properties

NameOverloadsSummary
Width 1 the size of this surface in pixels
Device 1 the direct2d / d3d11 device that owns this surface
Target 1 the direct2d render target which receives the drawing commands
NeedsRecreate 1 does this surface have to be rebuilt before the next frame?
SupportsReadback 1 can the rendered pixels be read back into the managed memory?
VSync 1 should the frame submission wait for the vertical blank?
CapturedPixels 1 the pixels that were captured while the last frame was submitted

04 Members

method Resize #
Resize(Int32, Int32)

update the size of this surface, the native resources of the new size must be recreated by the implementation.

method BeginDraw #
BeginDraw

open a new drawing batch on the render target

method EndDraw #
EndDraw

finish the current drawing batch, for a window surface the frame is presented onto the screen here.

method Recreate #
Recreate

rebuild the native resources after DxRenderSurface.NeedsRecreate is set

method Flush #
Flush

submit all of the pending drawing commands to the gpu device

method ReadPixels #
ReadPixels(Boolean)

read back the rendered pixels from the gpu device

Parameters
NameTypeDescription
deferredBoolean

The back buffer of a flip model swap chain only holds valid pixels while the frame is submitted: right after the presentation its content is undefined again. Such a surface returns this flag as True and no pixels at all, the caller has to finish the current frame through DxRenderSurface.EndDraw() instead and then read the pixels from DxRenderSurface.CapturedPixels.

Returns

a BGRA (blue, green, red, alpha) ordered pixel buffer with the premultiplied alpha value

method SetSize #
SetSize(Int32, Int32)

update the canvas size, this is only called by the implementation of DxRenderSurface.Resize()

method ReleaseHandle #
ReleaseHandle

release every native resource that is owned by this surface

property Width #
Width

the size of this surface in pixels

property Device #
Device

the direct2d / d3d11 device that owns this surface

property Target #
Target

the direct2d render target which receives the drawing commands

property NeedsRecreate #
NeedsRecreate

does this surface have to be rebuilt before the next frame?

Remarks

a window swap chain sets this flag when the gpu device was removed or reset during the previous frame submission. the drawing canvas checks this flag at the beginning of a frame and calls DxRenderSurface.Recreate() when it is set.

property SupportsReadback #
SupportsReadback

can the rendered pixels be read back into the managed memory?

Remarks

the back buffer of a flip model swap chain can not be mapped directly, so such a surface reports false here and its pixels can only be captured through a staging texture copy.

property VSync #
VSync

should the frame submission wait for the vertical blank?

property CapturedPixels #
CapturedPixels

the pixels that were captured while the last frame was submitted

Remarks

see the deferred parameter of DxRenderSurface.ReadPixels()