The abstract gpu render surface that the DxGraphics canvas draws on.
DxRenderSurface
00 Remarks
Two render surfaces are implemented in this project:
- DxRenderTarget - an off screen d3d11 texture, the rendered pixels can be read back into the managed memory for generating the raster image output
- 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
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| 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
| Name | Overloads | Summary |
|---|---|---|
| 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
Int32, Int32)update the size of this surface, the native resources of the new size must be recreated by the implementation.
open a new drawing batch on the render target
finish the current drawing batch, for a window surface the frame is presented onto the screen here.
rebuild the native resources after DxRenderSurface.NeedsRecreate is set
submit all of the pending drawing commands to the gpu device
Boolean)read back the rendered pixels from the gpu device
| Name | Type | Description |
|---|---|---|
deferred | Boolean | 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. |
a BGRA (blue, green, red, alpha) ordered pixel buffer with the premultiplied alpha value
Int32, Int32)update the canvas size, this is only called by the implementation of DxRenderSurface.Resize()
release every native resource that is owned by this surface
the size of this surface in pixels
the direct2d / d3d11 device that owns this surface
the direct2d render target which receives the drawing commands
does this surface have to be rebuilt before the next frame?
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.
can the rendered pixels be read back into the managed memory?
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.
should the frame submission wait for the vertical blank?
the pixels that were captured while the last frame was submitted
see the deferred parameter of DxRenderSurface.ReadPixels()