Render Targets

Typedefs

typedef BaseTexture Texture

Enums

enum class DepthAccess

Specifies the access mode for a depth attachment.

Values:

enumerator RW

For regular depth attachment.

enumerator SampledRO

For read-only depth attachment which can also be sampled as a texture in the same shader. IF YOU DON’T NEED TO SAMPLE THE DEPTH, USE z_write=false WITH DepthAccess::RW INSTEAD. Using this state will cause HiZ decompression on some hardware and split of renderpass with flush of tile data into memory in a TBR.

struct RenderTarget

Represents a render target to set it into slot.

Public Members

BaseTexture *tex

Texture to set as render target.

uint32_t mip_level

Mip level to set as render target.

uint32_t layer

Layer to set as render target.

namespace d3d

Functions

bool copy_from_current_render_target(BaseTexture *to_tex)

Copy the current render target to a texture. It is useful to get a backbuffer content on such drivers as Metal.

Parameters:

to_tex – Texture to copy the current render target to.

Returns:

true if the operation was successful, false otherwise.

bool clear_rt(const RenderTarget &rt, const ResourceClearValue &clear_val = {})

Clear the render target. Perform full clear on the RT according to its’ creation flag.

Parameters:
  • rt – Render target to clear.

  • clear_val – Clear value.

Returns:

true if the operation was successful, false otherwise.

bool set_render_target()

Set the default render target (backbuffer) as a single current render target.

Returns:

true if the operation was successful, false otherwise.

bool set_depth(BaseTexture *tex, DepthAccess access)

Set the depth texture target.

Parameters:
  • tex – Texture to set as depth target. NULL means NO depth.

  • access – Access mode for the depth attachment.

Returns:

true if the operation was successful, false otherwise.

bool set_depth(BaseTexture *tex, int layer, DepthAccess access)

Set the depth texture target.

Parameters:
  • tex – Texture to set as depth target. NULL means NO depth.

  • layer – Layer of the tex to set as depth target.

  • access – Access mode for the depth attachment.

Returns:

true if the operation was successful, false otherwise.

bool set_render_target(int rt_index, BaseTexture*, int fc, uint8_t level)

Sets the render target for rendering.

Deprecated:

Use set_render_target(RenderTarget depth, DepthAccess depth_access, dag::ConstSpan<RenderTarget> colors) instead.

Warning

if texture is depth texture format, it is the same as call set_depth() DON’T USE THIS BEHAVIOR!!!

Parameters:
  • rt_index – The index of the render target. The maximum number of render targets is defined by Driver3dRenderTarget::MAX_SIMRT.

  • texture – A pointer to the BaseTexture object representing the render target.

  • fc – The face of the texture (for cube textures and texture arrays). If face is RENDER_TO_WHOLE_ARRAY, then the whole Texture Array/Volume Tex will be set as render target. This is to be used with geom shader (and Metal allows with vertex shader).

  • level – The level of the render target.

Returns:

True if the render target was set successfully, false otherwise.

bool set_render_target(int rt_index, BaseTexture*, uint8_t level)

Sets the render target for rendering.

Deprecated:

Use set_render_target(RenderTarget depth, DepthAccess depth_access, dag::ConstSpan<RenderTarget> colors) instead.

Warning

if texture is depth texture format, it is the same as call set_depth() DON’T USE THIS BEHAVIOR!!!

Parameters:
  • rt_index – The index of the render target. The maximum number of render targets is defined by Driver3dRenderTarget::MAX_SIMRT.

  • texture – A pointer to the BaseTexture object representing the render target.

  • level – The level of the render target.

Returns:

True if the render target was set successfully, false otherwise.

inline bool set_render_target(BaseTexture *t, uint8_t level)

Sets the render target for rendering. All other render targets will be set to nullptr.

Deprecated:

Use set_render_target(RenderTarget depth, DepthAccess depth_access, dag::ConstSpan<RenderTarget> colors) instead.

Warning

if texture is depth texture format, it is the same as call set_depth() DON’T USE THIS BEHAVIOR!!!

Parameters:
  • texture – A pointer to the BaseTexture object representing the render target.

  • level – The level of the render target.

Returns:

True if the render target was set successfully, false otherwise.

inline bool set_render_target(BaseTexture *t, int fc, uint8_t level)

Sets the render target for rendering. All other render targets will be set to nullptr.

Deprecated:

Use set_render_target(RenderTarget depth, DepthAccess depth_access, dag::ConstSpan<RenderTarget> colors) instead.

Warning

if texture is depth texture format, it is the same as call set_depth() DON’T USE THIS BEHAVIOR!!!

Parameters:
  • t – A pointer to the BaseTexture object representing the render target.

  • fc – The face of the texture (for cube textures and texture arrays). If face is RENDER_TO_WHOLE_ARRAY, then the whole Texture Array/Volume Tex will be set as render target. This is to be used with geom shader (and Metal allows with vertex shader).

  • level – The level of the render target.

Returns:

True if the render target was set successfully, false otherwise.

inline void set_render_target(RenderTarget depth, DepthAccess depth_access, dag::ConstSpan<RenderTarget> colors)

Sets the render target for rendering. All other render targets will be set to nullptr.

Parameters:
  • depth – The depth render target.

  • depth_access – The access mode for the depth attachment.

  • colors – The color render targets.

Returns:

True if the render target was set successfully, false otherwise.

inline void set_render_target(RenderTarget depth, DepthAccess depth_access, const std::initializer_list<RenderTarget> colors)

Sets the render target for rendering. All other render targets will be set to nullptr.

Parameters:
  • depth – The depth render target.

  • depth_access – The access mode for the depth attachment.

  • colors – The color render targets.

Returns:

True if the render target was set successfully, false otherwise.

void get_render_target(Driver3dRenderTarget &out_rt)

Get the render target object.

Deprecated:

Don’t use it since the method relies on a global state.

Parameters:

out_rt – The render target object to fill.

bool set_render_target(const Driver3dRenderTarget &rt)

Set the render target object.

Parameters:

rt – The render target object to set. Usually, it is obtained by get_render_target(Driver3dRenderTarget &out_rt).

Returns:

true if the operation was successful, false otherwise.

bool get_target_size(int &w, int &h)

Get the size of the render target.

Deprecated:

If you need to use the method, it seems that you are doing something wrong.

Parameters:
  • w – The width of the render target.

  • h – The height of the render target.

Returns:

true if the operation was successful, false otherwise.

bool get_render_target_size(int &w, int &h, BaseTexture *rt_tex, uint8_t level = 0)

Get the size of the render target texture.

Deprecated:

If you need to use the method, it seems that you are doing something wrong.

Parameters:
  • w – The width of the render target texture.

  • h – The height of the render target texture.

  • rt_tex – The render target texture. If nullptr, the size of the backbuffer will be written to w and h.

  • level – The level of the render target texture.

Returns:

true if the operation was successful, false otherwise.

bool clearview(int what, E3DCOLOR c, float z, uint32_t stencil)

clear all view

Clear the view. What is view will be explained in the params.

Parameters:
  • what – The view to clear. It can be one of the CLEAR_*** enum. It will clears either color, depth, or stencil buffer.

  • c – The color to clear the view with.

  • z – The depth to clear the view with.

  • stencil – The stencil to clear the view with.

Returns:

true if the operation was successful, false otherwise.

void get_screen_size(int &w, int &h)

Get the size of the screen (backbuffer).

Warning

The size of the screen can be different from the size of the framebuffer.

Parameters:
  • w – The width of the screen.

  • h – The height of the screen.

Texture *get_backbuffer_tex()

Get the backbuffer texture.

Backbuffer is only valid while the GPU is acquired, and can be recreated in between.

Returns:

The backbuffer texture.

Texture *get_secondary_backbuffer_tex()

Get the secondary backbuffer texture.

Secondary backbuffer is only valid while the GPU is acquired, and can be recreated in between. It exists only for Xbox. Mostly used as a backbuffer with a higher resolution to draw UI.

Returns:

The secondary backbuffer texture.