All other methods

Defines

FIELD_MATCHES(field)
HALF_TEXEL_OFSF
D3D_HAS_QUADS
d3derr(c, m)
d3d_err(c)

Typedefs

typedef TMatrix4 Matrix44
typedef intptr_t main_wnd_f(void*, unsigned, uintptr_t, intptr_t)
typedef Sbuffer Ibuffer
typedef Sbuffer Vbuffer
using ResourceHeapCreateFlags = uint32_t

Enums

enum class ResourceActivationAction : unsigned

Values:

enumerator REWRITE_AS_COPY_DESTINATION
enumerator REWRITE_AS_UAV
enumerator REWRITE_AS_RTV_DSV
enumerator CLEAR_F_AS_UAV
enumerator CLEAR_I_AS_UAV
enumerator CLEAR_AS_RTV_DSV
enumerator DISCARD_AS_UAV
enumerator DISCARD_AS_RTV_DSV
enum class DepthAccess

Values:

enumerator RW

For regular depth attachement.

enumerator SampledRO

For read-only depth attachement 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.

enum ResourceHeapCreateFlag

Values:

enumerator RHCF_NONE
enumerator RHCF_REQUIRES_DEDICATED_HEAP
enum class APISupport

Values:

enumerator FULL_SUPPORT
enumerator OUTDATED_DRIVER
enumerator BLACKLISTED_DRIVER
enumerator NO_DEVICE_FOUND

Functions

inline ResourceClearValue make_clear_value(uint32_t r, uint32_t g, uint32_t b, uint32_t a)
inline ResourceClearValue make_clear_value(int32_t r, int32_t g, int32_t b, int32_t a)
inline ResourceClearValue make_clear_value(float r, float g, float b, float a)
inline ResourceClearValue make_clear_value(float d, uint8_t s)
void d3derr_in_device_reset(const char *msg)

Variables

bool dagor_d3d_force_driver_reset
class Driver3dInitCallback

Public Types

using NeedStereoRenderFunc = bool (*)()
using StereoRenderDimensionFunc = int (*)()
using StereoRenderExtensionsFunc = const char *(*)()
using StereoRenderVersionsFunc = VersionRange (*)()
using StereoRenderAdapterFunc = int64_t (*)()

Public Functions

inline virtual void verifyResolutionSettings(int &ref_scr_wdt, int &ref_scr_hgt, int base_scr_wdt, int base_scr_hgt, bool window_mode) const
virtual int validateDesc(Driver3dDesc&) const = 0
virtual int compareDesc(Driver3dDesc &A, Driver3dDesc &B) const = 0
inline virtual bool desiredStereoRender() const
inline virtual int64_t desiredAdapter() const
inline virtual RenderSize desiredRendererSize() const
inline virtual const char *desiredRendererDeviceExtensions() const
inline virtual const char *desiredRendererInstanceExtensions() const
inline virtual VersionRange desiredRendererVersionRange() const
struct RenderSize

Public Members

int width
int height
struct VersionRange

Public Members

uint64_t minVersion
uint64_t maxVersion
class Sbuffer : public D3dResource

Public Functions

inline virtual bool setReloadCallback(IReloadData*)
inline int restype() const final override
virtual int lock(uint32_t ofs_bytes, uint32_t size_bytes, void **p, int flags) = 0
virtual int unlock() = 0
virtual int getFlags() const = 0
inline const char *getBufName() const
inline virtual int getElementSize() const
inline virtual int getNumElements() const
inline virtual bool copyTo(Sbuffer*)
inline virtual bool copyTo(Sbuffer*, uint32_t, uint32_t, uint32_t)
template<typename T>
inline int lockEx(uint32_t ofs_bytes, uint32_t size_bytes, T **p, int flags)
inline void checkLockParams(uint32_t offset, uint32_t size, int flags, int bufFlags)
inline bool updateDataWithLock(uint32_t ofs_bytes, uint32_t size_bytes, const void *src, int lockFlags)
inline virtual bool updateData(uint32_t ofs_bytes, uint32_t size_bytes, const void *src, uint32_t lockFlags)
inline int lock(uint32_t ofs_bytes, uint32_t size_bytes, uint16_t **p, int flags)
inline int lock32(uint32_t ofs_bytes, uint32_t size_bytes, uint32_t **p, int flags)

Protected Functions

inline ~Sbuffer() override
struct IReloadData

Public Functions

inline virtual ~IReloadData()
virtual void reloadD3dRes(Sbuffer *sb) = 0
virtual void destroySelf() = 0
class ResourceBarrierDesc

Public Functions

inline ResourceBarrierDesc()
ResourceBarrierDesc(const ResourceBarrierDesc&) = default
inline ResourceBarrierDesc(Sbuffer *buf, ResourceBarrier rb)
inline ResourceBarrierDesc(Sbuffer *const *bufs, const ResourceBarrier *rb, unsigned count)
template<unsigned N>
inline ResourceBarrierDesc(Sbuffer *(&bufs)[N], ResourceBarrier (&rb)[N])
inline ResourceBarrierDesc(std::initializer_list<Sbuffer*> bufs, std::initializer_list<ResourceBarrier> rb)
inline ResourceBarrierDesc(BaseTexture *tex, ResourceBarrier rb, unsigned sub_res_index, unsigned sub_res_range)
inline ResourceBarrierDesc(BaseTexture *const *texs, const ResourceBarrier *rb, const unsigned *sub_res_index, const unsigned *sub_res_range, unsigned count)
template<unsigned N>
inline ResourceBarrierDesc(BaseTexture *(&texs)[N], ResourceBarrier (&rb)[N], unsigned (&sub_res_index)[N], unsigned (&sub_res_range)[N])
inline ResourceBarrierDesc(std::initializer_list<BaseTexture*> texs, std::initializer_list<ResourceBarrier> rb, std::initializer_list<unsigned> sub_res_index, std::initializer_list<unsigned> sub_res_range)
inline ResourceBarrierDesc(Sbuffer *const *bufs, const ResourceBarrier *b_rb, unsigned b_count, BaseTexture *const *texs, const ResourceBarrier *t_rb, const unsigned *t_sub_res_index, const unsigned *t_sub_res_range, unsigned t_count)
inline ResourceBarrierDesc(Sbuffer *buf, ResourceBarrier b_rb, BaseTexture *const *texs, const ResourceBarrier *t_rb, const unsigned *t_sub_res_index, const unsigned *t_sub_res_range, unsigned t_count)
inline ResourceBarrierDesc(Sbuffer *const *bufs, const ResourceBarrier *b_rb, unsigned b_count, BaseTexture *tex, ResourceBarrier t_rb, unsigned t_sub_res_index, unsigned t_sub_res_range)
inline ResourceBarrierDesc(Sbuffer *buf, ResourceBarrier b_rb, BaseTexture *tex, ResourceBarrier t_rb, unsigned t_sub_res_index, unsigned t_sub_res_range)
inline ResourceBarrierDesc(std::initializer_list<Sbuffer*> bufs, std::initializer_list<ResourceBarrier> buf_rb, std::initializer_list<BaseTexture*> texs, std::initializer_list<ResourceBarrier> tex_rb, std::initializer_list<unsigned> sub_res_index, std::initializer_list<unsigned> sub_res_range)
inline explicit ResourceBarrierDesc(ResourceBarrier rb)
template<typename T>
inline void enumerateBufferBarriers(T clb)
template<typename T>
inline void enumerateTextureBarriers(T clb)

Public Members

Sbuffer *buffer
Sbuffer *const *buffers
BaseTexture *texture
BaseTexture *const *textures
ResourceBarrier bufferState
const ResourceBarrier *bufferStates
ResourceBarrier textureState
const ResourceBarrier *textureStates
unsigned textureSubResIndex
const unsigned *textureSubResIndices
unsigned textureSubResRange
const unsigned *textureSubResRanges

Private Members

union ResourceBarrierDesc::[anonymous] [anonymous]
union ResourceBarrierDesc::[anonymous] [anonymous]
union ResourceBarrierDesc::[anonymous] [anonymous]
union ResourceBarrierDesc::[anonymous] [anonymous]
union ResourceBarrierDesc::[anonymous] [anonymous]
union ResourceBarrierDesc::[anonymous] [anonymous]
unsigned bufferCount = 0
unsigned textureCount = 0

Private Static Attributes

static constexpr unsigned single_element_count = ~0u
union ResourceClearValue

Public Members

uint32_t asUint[4]
struct ResourceClearValue::[anonymous] [anonymous]
int32_t asInt[4]
struct ResourceClearValue::[anonymous] [anonymous]
float asFloat[4]
struct ResourceClearValue::[anonymous] [anonymous]
float asDepth
uint8_t asStencil
struct ResourceClearValue::[anonymous] [anonymous]
struct BasicResourceDescription

Subclassed by BasicTextureResourceDescription, BufferResourceDescription

Public Members

uint32_t cFlags
ResourceActivationAction activation
ResourceClearValue clearValue
struct BufferResourceDescription : public BasicResourceDescription

Public Members

uint32_t elementSizeInBytes
uint32_t elementCount
uint32_t viewFormat
struct BasicTextureResourceDescription : public BasicResourceDescription

Subclassed by CubeTextureResourceDescription, TextureResourceDescription

Public Members

uint32_t mipLevels
struct TextureResourceDescription : public BasicTextureResourceDescription

Subclassed by ArrayTextureResourceDescription, VolTextureResourceDescription

Public Members

uint32_t width
uint32_t height
struct VolTextureResourceDescription : public TextureResourceDescription

Public Members

uint32_t depth
struct ArrayTextureResourceDescription : public TextureResourceDescription

Public Members

uint32_t arrayLayers
struct CubeTextureResourceDescription : public BasicTextureResourceDescription

Subclassed by ArrayCubeTextureResourceDescription

Public Members

uint32_t extent
struct ArrayCubeTextureResourceDescription : public CubeTextureResourceDescription

Public Members

uint32_t cubes
struct ResourceDescription

Public Types

using HashT = size_t

Public Functions

ResourceDescription() = default
ResourceDescription(const ResourceDescription&) = default
inline ResourceDescription(const BufferResourceDescription &buf)
inline ResourceDescription(const TextureResourceDescription &tex)
inline ResourceDescription(const VolTextureResourceDescription &tex)
inline ResourceDescription(const ArrayTextureResourceDescription &tex)
inline ResourceDescription(const CubeTextureResourceDescription &tex)
inline ResourceDescription(const ArrayCubeTextureResourceDescription &tex)
inline bool operator==(const ResourceDescription &r) const
inline HashT hash() const

Private Static Functions

static inline HashT hashPack()
template<typename T, typename ...Ts>
static inline HashT hashPack(const T &first, const Ts&... other)
struct ResourceHeapGroupProperties

Public Members

uint32_t flags
bool isCPUVisible
bool isGPULocal
bool isOnChip
union ResourceHeapGroupProperties::[anonymous] [anonymous]
uint64_t maxResourceSize
uint64_t maxHeapSize
uint64_t optimalMaxHeapSize
struct ResourceAllocationProperties

Public Members

size_t sizeInBytes
size_t offsetAlignment
ResourceHeapGroup *heapGroup
struct RenderTarget

Public Members

BaseTexture *tex
uint32_t mip_level
uint32_t layer
struct RenderPassBind

Description of render target bind inside render pass.

Fully defines operation that will happen with target at defined subpass slot

Public Members

int32_t target

Index of render target in render targets array that will be used for this bind.

int32_t subpass

Index of subpass where bind happens.

int32_t slot

Index of slot where target will be used.

RenderPassTargetAction action

defines what will happen with target used in binding

ResourceBarrier dependencyBarrier

optional user barrier for generic(emulated) implementation

struct RenderPassTargetDesc

Early description of render target.

Gives necessary info at render pass creation so render pass is compatible with targets of same type later on

Public Members

BaseTexture *templateResource

Resource from which information is extracted, can be nullptr.

unsigned texcf

Raw texture create flags, used if template resource is not provided.

bool aliased

Must be set if template resource is empty and target will use aliased memory.

struct RenderPassTarget

Description of target that is used inside render pass.

Public Members

RenderTarget resource

Actual render target subresource reference.

ResourceClearValue clearValue

Clear value that is used on clear action.

struct RenderPassDesc

Render pass resource description, used to create RenderPass object.

Public Members

const char *debugName

Name that is visible only in developer builds and inside graphics tools, if possible.

uint32_t targetCount

Total amount of targets inside render pass.

uint32_t bindCount

Total amount of bindings for render pass.

const RenderPassTargetDesc *targetsDesc

Array of targetCount elements, supplying early description of render target.

const RenderPassBind *binds

Array of bindCount elements, describing all subpasses.

uint32_t subpassBindingOffset

Texture binding offset for shader subpass reads used on APIs without native render passes.

Generic(emulated) implementation will use registers starting from this offset, to bind input attachments. This must be properly handled inside shader code for generic implementation to work properly!

struct RenderPassArea

Area of render target where rendering will happen inside render pass.

Public Members

uint32_t left
uint32_t top
uint32_t width
uint32_t height
float minZ
float maxZ
struct TextureTilingInfo

Public Members

size_t totalNumberOfTiles
size_t numUnpackedMips
size_t numPackedMips
size_t numTilesNeededForPackedMips
size_t firstPackedTileIndex
size_t tileWidthInPixels
size_t tileHeightInPixels
size_t tileDepthInPixels
size_t tileMemorySize
size_t subresourceWidthInTiles
size_t subresourceHeightInTiles
size_t subresourceDepthInTiles
size_t subresourceStartTileIndex
struct TileMapping

Public Members

size_t texX
size_t texY
size_t texZ
size_t texSubresource
size_t heapTileIndex
size_t heapTileSpan
namespace ddsx
namespace eastl
template<>
class hash<ResourceDescription>

Public Functions

inline size_t operator()(const ResourceDescription &desc) const
namespace d3d

opaque class that holds data for resource/texture update

Enums

enum [anonymous]

Values:

enumerator USAGE_TEXTURE
enumerator USAGE_DEPTH
enumerator USAGE_RTARGET
enumerator USAGE_AUTOGENMIPS
enumerator USAGE_FILTER
enumerator USAGE_BLEND
enumerator USAGE_VERTEXTEXTURE
enumerator USAGE_SRGBREAD
enumerator USAGE_SRGBWRITE
enumerator USAGE_SAMPLECMP
enumerator USAGE_PIXREADWRITE
enumerator USAGE_TILED
enumerator USAGE_UNORDERED
enumerator USAGE_UNORDERED_LOAD

Indicates the format supports unordered loads.

enum [anonymous]

Values:

enumerator CAPFMT_X8R8G8B8
enumerator CAPFMT_R8G8B8
enumerator CAPFMT_R5G6B5
enumerator CAPFMT_X1R5G5B5

Functions

void update_window_mode()
int guess_gpu_vendor(String *out_gpu_desc = NULL, uint32_t *out_drv_ver = NULL, DagorDateTime *out_drv_date = NULL, uint32_t *device_id = nullptr)

guesses and returns GPU vendor ID; may be called before d3d::init_driver()

DagorDateTime get_gpu_driver_date(int vendor)
unsigned get_dedicated_gpu_memory_size_kb()

determines and returns size of dedicated GPU memory in KB; may be called before d3d::init_driver()

unsigned get_free_dedicated_gpu_memory_size_kb()
void get_current_gpu_memory_kb(uint32_t *dedicated_total, uint32_t *dedicated_free)

fast implementation to get the memory during the game, supports only Nvidia GPUs.

bool get_gpu_freq(String &out_freq)
int get_gpu_temperature()
void get_video_vendor_str(String &out_str)
float get_display_scale()

DPI of the primary display divided by 96 (96 dpi is for 100% scale in Windows)

void disable_sli()
bool init_driver()

initalizes 3d device driver

bool is_inited()

returns true when d3d API is inited

bool init_video(void *hinst, main_wnd_f*, const char *wcname, int ncmdshow, void *&mainwnd, void *renderwnd, void *hicon, const char *title, Driver3dInitCallback *cb)

start up, read cfg, create window, init 3d hard&soft, … if renderwnd!=NULL, mainwnd and renderwnd are used for rendering (when possible) on error, returns false on sucess, return true

void release_driver()

shutdown driver and release all resources

bool fill_interface_table(D3dInterfaceTable &d3dit)

fills function-pointers table for d3d API, or returns false if unsupported

const char *get_driver_name()

returns driver name (pointer to static string)

DriverCode get_driver_code()

returns driver code

static inline bool is_stub_driver()

returns true when d3d-stub driver is used

const char *get_device_driver_version()

returns device driver version (pointer to static string)

const char *get_device_name()

returns device name (pointer to static string)

const char *get_last_error()

returns pointer to static buffer containing last error message

uint32_t get_last_error_code()
void prepare_for_destroy()

notify driver before window destruction

void window_destroyed(void *hwnd)

notify driver on window destruction

void *get_device()

returns raw pointer to device interface (implementation and platform specific)

void *get_context()

returns raw pointer to device interface

const Driver3dDesc &get_driver_desc()

returns driver description (pointer to static object)

int driver_command(int command, void *par1, void *par2, void *par3)

send specific command to driver (see dag_drv3dCmd.h)

bool device_lost(bool *can_reset_now)

returns true when device is lost; when it is safe to reset device can_reset_now is set with 1 returns false when device is ok

bool reset_device()

performs device reset; returns true if succeded

bool is_in_device_reset_now()

returns true when device is lost or device is reseted right now

bool is_window_occluded()

returns if the game rendering window is completely occluded right now

bool should_use_compute_for_image_processing(std::initializer_list<unsigned> formats)

Returns if for image processing, compute or graphics commands should be preferred.

bool check_texformat(int cflg)

check whether this texture format is available returns false if texture of the specified format can’t be created

int get_max_sample_count(int cflg)

returns the maximum sample count for the given texture format

unsigned get_texformat_usage(int cflg, int restype = RES3D_TEX)
bool issame_texformat(int cflg1, int cflg2)

check whether specified texture creation flags result in the same format

bool check_cubetexformat(int cflg)

check whether this cube texture format is available returns false if cube texture of the specified format can’t be created

bool issame_cubetexformat(int cflg1, int cflg2)

check whether specified cube texture creation flags result in the same format

bool check_voltexformat(int cflg)

check whether this volume texture format is available returns false if cube texture of the specified format can’t be created

bool issame_voltexformat(int cflg1, int cflg2)

check whether specified volume texture creation flags result in the same format

BaseTexture *create_tex(TexImage32 *img, int w, int h, int flg, int levels, const char *stat_name = NULL)

create texture; if img==NULL, size (w/h) must be specified if img!=NULL and size==0, dimension will be taken from img levels specify maximum number of mipmap levels if levels==0, whole mipmap set will be created if device supports mipmaps img format is TexPixel32 returns NULL on error

BaseTexture *create_ddsx_tex(IGenLoad &crd, int flg, int quality_id, int levels = 0, const char *stat_name = NULL)

create texture from DDSx stream; quality_id specifies quality index (0=high, 1=medium, 2=low, 3=ultralow) levels specifies number of loaded mipmaps (0=all, >0=only first ‘levels’ mipmaps) returns NULL on error

BaseTexture *alloc_ddsx_tex(const ddsx::Header &hdr, int flg, int quality_id, int levels = 0, const char *stat_name = NULL, int stub_tex_idx = -1)

create texture object using DDSx header (not texture contents loaded at this time)

static inline bool load_ddsx_tex_contents(BaseTexture *t, const ddsx::Header &hdr, IGenLoad &crd, int q_id)

load texture content from DDSx stream using DDSx header for previously allocated texture

BaseTexture *create_cubetex(int size, int flg, int levels, const char *stat_name = NULL)

create cubic texture levels specify maximum number of mipmap levels if levels==0, whole mipmap set will be created if device supports mipmaps returns NULL on error

BaseTexture *create_voltex(int w, int h, int d, int flg, int levels, const char *stat_name = NULL)

create volume texture levels specify maximum number of mipmap levels if levels==0, whole mipmap set will be created if device supports mipmaps returns NULL on error

BaseTexture *create_array_tex(int w, int h, int d, int flg, int levels, const char *stat_name)

create texture2d array levels specify maximum number of mipmap levels if levels==0, whole mipmap set will be created if device supports mipmaps returns NULL on error

BaseTexture *create_cube_array_tex(int side, int d, int flg, int levels, const char *stat_name)
BaseTexture *alias_tex(BaseTexture *baseTexture, TexImage32 *img, int w, int h, int flg, int levels, const char *stat_name = NULL)

Create texture alias, a texture using the same memory as an other texture, but as a different format. You can think of it as the old texture data is cast to the aliased texture format; Calling it is the same as create_tex, but the GPU memory of baseTexture will be used as the backing GPU memory for this texture As this is only an alias to the GPU memory area, the lifetime of the GPU memory area is still controlled by baseTexture, so no alias texture should be used in the rendering pipeline after their base texture is deleted.

BaseTexture *alias_cubetex(BaseTexture *baseTexture, int size, int flg, int levels, const char *stat_name = NULL)
BaseTexture *alias_voltex(BaseTexture *baseTexture, int w, int h, int d, int flg, int levels, const char *stat_name = NULL)
BaseTexture *alias_array_tex(BaseTexture *baseTexture, int w, int h, int d, int flg, int levels, const char *stat_name)
BaseTexture *alias_cube_array_tex(BaseTexture *baseTexture, int side, int d, int flg, int levels, const char *stat_name)
bool set_tex_usage_hint(int w, int h, int mips, const char *format, unsigned int tex_num)
void discard_managed_textures()

discards all managed textures

bool stretch_rect(BaseTexture *src, BaseTexture *dst, RectInt *rsrc = NULL, RectInt *rdst = NULL)
bool copy_from_current_render_target(BaseTexture *to_tex)
void get_texture_statistics(uint32_t *num_textures, uint64_t *total_mem, String *out_dump)
bool set_tex(unsigned shader_stage, unsigned slot, BaseTexture *tex, bool use_sampler = true)
static inline bool settex(int slot, BaseTexture *tex)
static inline bool settex_vs(int slot, BaseTexture *tex)
SamplerHandle create_sampler(const SamplerInfo &sampler_info)
void destroy_sampler(SamplerHandle sampler)
void set_sampler(unsigned shader_stage, unsigned slot, SamplerHandle sampler)
uint32_t register_bindless_sampler(BaseTexture *texture)
uint32_t allocate_bindless_resource_range(uint32_t resource_type, uint32_t count)
uint32_t resize_bindless_resource_range(uint32_t resource_type, uint32_t index, uint32_t current_count, uint32_t new_count)
void free_bindless_resource_range(uint32_t resource_type, uint32_t index, uint32_t count)
void update_bindless_resource(uint32_t index, D3dResource *res)
void update_bindless_resources_to_null(uint32_t resource_type, uint32_t index, uint32_t count)
bool set_rwtex(unsigned shader_stage, unsigned slot, BaseTexture *tex, uint32_t face, uint32_t mip_level, bool as_uint = false)
bool clear_rwtexi(BaseTexture *tex, const unsigned val[4], uint32_t face, uint32_t mip_level)
bool clear_rwtexf(BaseTexture *tex, const float val[4], uint32_t face, uint32_t mip_level)
bool clear_rwbufi(Sbuffer *buf, const unsigned val[4])
bool clear_rwbuff(Sbuffer *buf, const float val[4])
PROGRAM create_program(VPROG vprog, FSHADER fsh, VDECL vdecl, unsigned *strides = 0, unsigned streams = 0)
PROGRAM create_program(const uint32_t *vpr_native, const uint32_t *fsh_native, VDECL vdecl, unsigned *strides = 0, unsigned streams = 0)
PROGRAM create_program_cs(const uint32_t *cs_native, CSPreloaded preloaded)
bool set_program(PROGRAM)
void delete_program(PROGRAM)
VPROG create_vertex_shader(const uint32_t *native_code)
void delete_vertex_shader(VPROG vs)
bool set_const(unsigned stage, unsigned reg_base, const void *data, unsigned num_regs)
static inline bool set_vs_const(unsigned reg_base, const void *data, unsigned num_regs)
static inline bool set_ps_const(unsigned reg_base, const void *data, unsigned num_regs)
static inline bool set_cs_const(unsigned reg_base, const void *data, unsigned num_regs)
static inline bool set_vs_const1(unsigned reg, float v0, float v1, float v2, float v3)
static inline bool set_ps_const1(unsigned reg, float v0, float v1, float v2, float v3)
bool set_immediate_const(unsigned stage, const uint32_t *data, unsigned num_words)
FSHADER create_pixel_shader(const uint32_t *native_code)
void delete_pixel_shader(FSHADER ps)
bool set_const_buffer(unsigned stage, unsigned slot, const float *data, unsigned num_regs)
bool set_const_buffer(unsigned stage, unsigned slot, Sbuffer *buffer, uint32_t consts_offset = 0, uint32_t consts_size = 0)
int set_vs_constbuffer_size(int required_size)
int set_cs_constbuffer_size(int required_size)
static inline bool set_cb0_data(unsigned stage, const float *data, unsigned num_regs)
static inline void release_cb0_data(unsigned stage)
Sbuffer *create_vb(int size_bytes, int flags, const char *name = "")
Sbuffer *create_ib(int size_bytes, int flags, const char *stat_name = "ib")
Sbuffer *create_sbuffer(int struct_size, int elements, unsigned flags, unsigned texfmt, const char *name)
bool set_buffer(unsigned shader_stage, unsigned slot, Sbuffer *buffer)
bool set_rwbuffer(unsigned shader_stage, unsigned slot, Sbuffer *buffer)
bool set_render_target()

set default render target (display) returns false on error

bool set_depth(BaseTexture *tex, DepthAccess access)

set depth texture target. NULL means NO depth. use set_backbuf_depth for backbuf render target

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

set back buffer depth target.

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

set texture as render target if texture is depth texture format, it is the same as call set_depth() if face is RENDER_TO_WHOLE_ARRAY, then 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)

bool set_render_target(int rt_index, BaseTexture*, int level)
inline bool set_render_target(BaseTexture *t, int level)
inline bool set_render_target(BaseTexture *t, int fc, int level)
inline void set_render_target(RenderTarget depth, DepthAccess depth_access, dag::ConstSpan<RenderTarget> colors)
inline void set_render_target(RenderTarget depth, DepthAccess depth_access, const std::initializer_list<RenderTarget> colors)
void get_render_target(Driver3dRenderTarget &out_rt)
bool set_render_target(const Driver3dRenderTarget &rt)
bool get_target_size(int &w, int &h)

get current render target resolution returns false on error

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

get size of RT texture or backbuf (for rt_tex==NULL)

void set_variable_rate_shading(unsigned rate_x, unsigned rate_y, VariableRateShadingCombiner vertex_combiner = VariableRateShadingCombiner::VRS_PASSTHROUGH, VariableRateShadingCombiner pixel_combiner = VariableRateShadingCombiner::VRS_PASSTHROUGH)

Sets variable rate shading setup for next draw calls.

Note

Rates (rate_x, rate_y) of 1 by 4 or 4 by 1 are invalid.

Note

Depth/Stencil values are always computed at full rate and so shaders that modify depth value output may interfere with the pixel_combiner.

Parameters
  • rate_x, rate_y – Constant rates for the next draw calls, those are supported by all VRS capable devices. Valid values for both are 1, 2 and with the corresponding feature cap 4.

  • vertex_combiner – The mode in which the constant rate of rate_x and rate_y is combined with a possible vertex/geometry shader rate output. For shader outputs see SV_ShadingRate, note that the provoking vertex or the per primitive value is used.

  • pixel_combiner – The mode in which the result of ‘vertex_combiner’ is combined with the rate of the sampling rate texture set by set_variable_rate_shading_texture.

void set_variable_rate_shading_texture(BaseTexture *rate_texture = nullptr)

Sets the variable rate shading texture for the next draw calls.

Note that when you start to modify the used texture, you should reset the used shading rate texture to null to ensure that on next use as a shading rate source, the texture is in a state the device can use.

Note

It is invalid to call this when DeviceDriverCapabilities::hasVariableRateShadingTexture feature is not supported.

Parameters

rate_texture – The texture to use as a shading rate source.

bool settm(int which, const Matrix44 *tm)
bool settm(int which, const TMatrix &tm)
void settm(int which, const mat44f &out_tm)
bool gettm(int which, Matrix44 *out_tm)
bool gettm(int which, TMatrix &out_tm)
void gettm(int which, mat44f &out_tm)
const mat44f &gettm_cref(int which)
void getm2vtm(TMatrix &out_m2v)

get model to view matrix

void getglobtm(Matrix44&)

get model to clip (full) matrix and (optional) scale coefficients

void setglobtm(Matrix44&)

set custom globtm matrix

void getglobtm(mat44f&)
void setglobtm(const mat44f&)
bool setpersp(const Driver3dPerspective &p, TMatrix4 *proj_tm = nullptr)

calculate and set perspective matrix, optionally returning the matrix itself

bool getpersp(Driver3dPerspective &p)

get last values set by setpersp()

bool validatepersp(const Driver3dPerspective &p)

check if p has a valid perspective

bool calcproj(const Driver3dPerspective &p, mat44f &proj_tm)

calculate the perspective matrix, without setting it

bool calcproj(const Driver3dPerspective &p, TMatrix4 &proj_tm)
void calcglobtm(const mat44f &view_tm, const mat44f &proj_tm, mat44f &result)

calculate the globtm, without setting it

void calcglobtm(const mat44f &view_tm, const Driver3dPerspective &persp, mat44f &result)
void calcglobtm(const TMatrix &view_tm, const TMatrix4 &proj_tm, TMatrix4 &result)
void calcglobtm(const TMatrix &view_tm, const Driver3dPerspective &persp, TMatrix4 &result)
bool setscissor(int x, int y, int w, int h)
bool setscissors(dag::ConstSpan<ScissorRect> scissorRects)
bool setview(int x, int y, int w, int h, float minz, float maxz)
bool setviews(dag::ConstSpan<Viewport> viewports)
bool getview(int &x, int &y, int &w, int &h, float &minz, float &maxz)
bool clearview(int what, E3DCOLOR, float z, uint32_t stencil)

clear all view

bool update_screen(bool app_active = true)

flip video pages or copy to screen app_active==false is hint to the driver returns false on error

bool setvsrc_ex(int stream, Sbuffer*, int offset, int stride_bytes)

set vertex stream source

inline bool setvsrc(int stream, Sbuffer *vb, int stride_bytes)
bool setind(Sbuffer *ib)

set indices

VDECL create_vdecl(VSDTYPE *vsd)
void delete_vdecl(VDECL vdecl)

delete vertex declaration

bool setvdecl(VDECL vdecl)

set current vertex declaration

bool draw_base(int type, int start, int numprim, uint32_t num_instances, uint32_t start_instance)

draw primitives

inline bool draw(int type, int start, int numprim)
inline bool draw_instanced(int type, int start, int numprim, uint32_t num_instances, uint32_t start_instance = 0)
bool drawind_base(int type, int startind, int numprim, int base_vertex, uint32_t num_instances, uint32_t start_instance)

draw indexed primitives

inline bool drawind_instanced(int type, int startind, int numprim, int base_vertex, uint32_t num_instances, uint32_t start_instance = 0)
inline bool drawind(int type, int startind, int numprim, int base_vertex)
bool draw_up(int type, int numprim, const void *ptr, int stride_bytes)

draw primitives from user pointer (rather slow)

bool drawind_up(int type, int minvert, int numvert, int numprim, const uint16_t *ind, const void *ptr, int stride_bytes)

draw indexed primitives from user pointer (rather slow)

bool draw_indirect(int type, Sbuffer *args, uint32_t byte_offset = 0)

draw primitives

bool draw_indexed_indirect(int type, Sbuffer *args, uint32_t byte_offset = 0)
bool multi_draw_indirect(int prim_type, Sbuffer *args, uint32_t draw_count, uint32_t stride_bytes, uint32_t byte_offset = 0)
bool multi_draw_indexed_indirect(int prim_type, Sbuffer *args, uint32_t draw_count, uint32_t stride_bytes, uint32_t byte_offset = 0)
bool dispatch(uint32_t thread_group_x, uint32_t thread_group_y, uint32_t thread_group_z, GpuPipeline gpu_pipeline = GpuPipeline::GRAPHICS)
bool dispatch_indirect(Sbuffer *args, uint32_t byte_offset = 0, GpuPipeline gpu_pipeline = GpuPipeline::GRAPHICS)
void dispatch_mesh(uint32_t thread_group_x, uint32_t thread_group_y, uint32_t thread_group_z)
void dispatch_mesh_indirect(Sbuffer *args, uint32_t dispatch_count, uint32_t stride_bytes, uint32_t byte_offset = 0)
void dispatch_mesh_indirect_count(Sbuffer *args, uint32_t args_stride_bytes, uint32_t args_byte_offset, Sbuffer *count, uint32_t count_byte_offset, uint32_t max_count)
GPUFENCEHANDLE insert_fence(GpuPipeline gpu_pipeline)
void insert_wait_on_fence(GPUFENCEHANDLE &fence, GpuPipeline gpu_pipeline)
bool setantialias(int aa_type)
int getantialias()
bool set_blend_factor(E3DCOLOR color)
bool setstencil(uint32_t ref)
bool setwire(bool in)
bool set_depth_bounds(float zmin, float zmax)
bool supports_depth_bounds()
bool set_srgb_backbuffer_write(bool)
bool set_msaa_pass()
bool set_depth_resolve()
bool setgamma(float)
bool isVcolRgba()
float get_screen_aspect_ratio()
void change_screen_aspect_ratio(float ar)
void *fast_capture_screen(int &w, int &h, int &stride_bytes, int &format)

capture screen to buffer.fast, but not guaranteed many captures can be followed by only one end_fast_capture_screen()

void end_fast_capture_screen()
TexPixel32 *capture_screen(int &w, int &h, int &stride_bytes)

capture screen to TexPixel32 buffer slow, and not 100% guaranted returns NULL on error

void release_capture_buffer()

release buffer used to capture screen

void get_screen_size(int &w, int &h)

returns the size of the backbuffer. it can be different from the size of the framebuffer

int create_predicate()

conditional rendering. conditional rendering is used to skip rendering of triangles completelyon GPU. the only commands, that would be ignored, if survey fails are DIPs (all commands and states will still be executed), so it is better to use reports to completely skip object rendering max index is defined per platform surveying.

void free_predicate(int id)
bool begin_survey(int id)
void end_survey(int id)
void begin_conditional_render(int id)
void end_conditional_render(int id)
PROGRAM get_debug_program()
void beginEvent(const char*)
void endEvent()
bool get_vrr_supported()
bool get_vsync_enabled()
bool enable_vsync(bool enable)
Texture *get_backbuffer_tex()
Texture *get_secondary_backbuffer_tex()
Texture *get_backbuffer_tex_depth()
void resource_barrier(ResourceBarrierDesc desc, GpuPipeline gpu_pipeline = GpuPipeline::GRAPHICS)
ResourceAllocationProperties get_resource_allocation_properties(const ResourceDescription &desc)
ResourceHeap *create_resource_heap(ResourceHeapGroup *heap_group, size_t size, ResourceHeapCreateFlags flags)
void destroy_resource_heap(ResourceHeap *heap)
Sbuffer *place_buffere_in_resource_heap(ResourceHeap *heap, const ResourceDescription &desc, size_t offset, const ResourceAllocationProperties &alloc_info, const char *name)
BaseTexture *place_texture_in_resource_heap(ResourceHeap *heap, const ResourceDescription &desc, size_t offset, const ResourceAllocationProperties &alloc_info, const char *name)
ResourceHeapGroupProperties get_resource_heap_group_properties(ResourceHeapGroup *heap_group)
void map_tile_to_resource(BaseTexture *tex, ResourceHeap *heap, const TileMapping *mapping, size_t mapping_count)
TextureTilingInfo get_texture_tiling_info(BaseTexture *tex, size_t subresource)
void activate_buffer(Sbuffer *buf, ResourceActivationAction action, const ResourceClearValue &value = {}, GpuPipeline gpu_pipeline = GpuPipeline::GRAPHICS)
void activate_texture(BaseTexture *tex, ResourceActivationAction action, const ResourceClearValue &value = {}, GpuPipeline gpu_pipeline = GpuPipeline::GRAPHICS)
void deactivate_buffer(Sbuffer *buf, GpuPipeline gpu_pipeline = GpuPipeline::GRAPHICS)
void deactivate_texture(BaseTexture *tex, GpuPipeline gpu_pipeline = GpuPipeline::GRAPHICS)
ResUpdateBuffer *allocate_update_buffer_for_tex_region(BaseTexture *dest_base_texture, unsigned dest_mip, unsigned dest_slice, unsigned offset_x, unsigned offset_y, unsigned offset_z, unsigned width, unsigned height, unsigned depth)
ResUpdateBuffer *allocate_update_buffer_for_tex(BaseTexture *dest_tex, int dest_mip, int dest_slice)

allocates update buffer in system memory to be filled directly and then dispatched to apply_tex_update_buffer this method can fail if too much allocations happens in N-frame period caller should retry after rendering frame on screen if this happens

void release_update_buffer(ResUpdateBuffer *&rub)

releases update buffer (clears pointer afterwards); skips any update, just releases data

char *get_update_buffer_addr_for_write(ResUpdateBuffer *rub)

returns data address to fill update data

size_t get_update_buffer_size(ResUpdateBuffer *rub)

returns size of update buffer

size_t get_update_buffer_pitch(ResUpdateBuffer *rub)

returns pitch of update buffer (if applicable)

size_t get_update_buffer_slice_pitch(ResUpdateBuffer *rub)
bool update_texture_and_release_update_buffer(ResUpdateBuffer *&src_rub)

applies update to target d3dres and releases update buffer (clears pointer afterwards)

RenderPass *create_render_pass(const RenderPassDesc &rp_desc)

Creates render pass object.

Render pass objects are intended to be created once (and ahead of time), used many times

Note

No external sync required

Warning

Do not run per frame/realtime!

Warning

Avoid using at time sensitive places!

Parameters

rp_desc – Description of render pass to be created

Returns

Pointer to opaque RenderPass object, may be nullptr if description is invalid

void delete_render_pass(RenderPass *rp)

Deletes render pass object.

Note

Sync with usage is required (must not delete object that is in use in current CPU frame)

Warning

All usage to object becomes invalid right after method call

Parameters

rp – Object to be deleted

void begin_render_pass(RenderPass *rp, const RenderPassArea area, const RenderPassTarget *targets)

Begins render pass rendering.

After this command, viewport is reset to area supplied and subpass 0, described in render pass object, is started

Note

Must be external synced (GPU lock required)

Warning

When inside pass, all other GPU execution methods aside of Draw* are prohibited!

Warning

Avoid writes/reads outside area, it is UB in general

Warning

Will assert-fail if other render pass is already in process

Parameters
  • rp – Render pass resource to begin with

  • area – Rendering area restriction

  • targets – Array of targets that will be used in rendering

void next_subpass()

Advances to next subpass.

Increases subpass number and executes necessary synchronization as well as binding, described for this subpass

Viewport is reset to render area on every call

Note

Must be external synced (GPU lock required)

Warning

Will assert-fail if there is no subpass to advance to

Warning

Will assert-fail if called outside of render pass

void end_render_pass()

Ends render pass.

Processes store&sync operations described in render pass

After this call, any non Draw operations are allowed and render targets are reset to backbuffer

Note

Must be external synced (GPU lock required)

Warning

Will assert-fail if subpass is not final

Warning

Will assert-fail if called outside of render pass

shaders::DriverRenderStateId create_render_state(const shaders::RenderState &state)
bool set_render_state(shaders::DriverRenderStateId state_id)
void clear_render_states()
inline void resummarize_htile(BaseTexture*)
inline void set_esram_layout(const wchar_t*)
inline void unset_esram_layout()
inline void reset_esram_layout()
inline void prefetch_movable_textures()
inline void writeback_movable_textures()

Variables

static constexpr int RENDER_TO_WHOLE_ARRAY = 1023
const float HALF_TEXEL_OFSFU
const bool HALF_TEXEL_OFS