1#ifndef GRAPHICS_PRIVATE_H
2#define GRAPHICS_PRIVATE_H
13#define DTTR_INVALID_TEXTURE 0
62#define DTTR_D3DTOP_DISABLE 1
63#define DTTR_D3DTOP_SELECTARG1 2
64#define DTTR_D3DTOP_SELECTARG2 3
65#define DTTR_D3DTOP_MODULATE 4
67#define DTTR_D3DTA_DIFFUSE 0
68#define DTTR_D3DTA_CURRENT 1
69#define DTTR_D3DTA_TEXTURE 2
78#define DTTR_CLEAR_COLOR 0x01
79#define DTTR_CLEAR_DEPTH 0x02
80#define DTTR_CLEAR_STENCIL 0x04
102#define DTTR_MAX_STAGED_TEXTURES 4096
103#define DTTR_UPLOAD_POOL_SIZE 256
139 const uint8_t *pixels,
180#define DTTR_BLEND_OFF 0
181#define DTTR_BLEND_ALPHA 1
182#define DTTR_BLEND_ADDITIVE 2
183#define DTTR_PIPELINE_COUNT 12
184#define DTTR_PIPELINE_INDEX(bmode, dtest, dwrite) ((bmode) * 4 + (dtest) * 2 + (dwrite))
186#define DTTR_SAMPLER_COUNT 4
187#define DTTR_MAX_ANISOTROPY 16.0f
188#define DTTR_MAT4_SIZE (sizeof(float) * 16)
189#define DTTR_VERTEX_ATTRIBUTE_COUNT 4
191#define DTTR_MAX_FRAME_VERTICES 262144
192#define DTTR_VERTEX_SIZE ((uint32_t)sizeof(DTTR_Vertex))
201 SDL_GPUCommandBuffer *
cmd;
287 const uint8_t *pixels,
314#ifdef DTTR_MODS_ENABLED
324 bool imgui_frame_active,
325 bool overlay_rendered
333 bool imgui_frame_active,
334 bool overlay_rendered
405 bool overlay_rendered
419 SDL_GPUShaderFormat formats
DTTR_Graphics_COM_Direct3DDevice7 void *status DTTR_Graphics_COM_Direct3DDevice7 DWORD DWORD void DWORD DWORD f DTTR_Graphics_COM_Direct3DDevice7 DWORD void DWORD st
DTTR_Graphics_COM_Direct3DDevice7 void DWORD flags DWORD count
const DTTR_BackendState * state
const DTTR_PrimitiveType type
DTTR_Graphics_COM_DirectDraw7 *self DWORD DWORD h
DTTR_Graphics_COM_DirectDraw7 *self DWORD w
struct SDL_Window SDL_Window
SDL_Window * dttr_graphics_get_window()
static void dttr_graphics_mod_device_destroying(DTTR_BackendState *)
void dttr_graphics_fill_mesh_seams(DTTR_Vertex *verts, uint32_t count, int logical_width, int logical_height, int render_width, int render_height)
Expands triangle-list vertices by a tiny physical-pixel amount to hide mesh cracks.
void dttr_graphics_mat4_identity(float *m)
#define DTTR_PIPELINE_COUNT
void dttr_graphics_set_logical_resolution(int width, int height)
#define DTTR_SAMPLER_COUNT
@ DTTR_BLEND_INVDESTCOLOR
@ DTTR_BLEND_INVDESTALPHA
SDL_GPUDevice * dttr_graphics_get_device()
SDL_GPUShaderFormat dttr_graphics_select_shader_format_for_driver(const char *driver, SDL_GPUShaderFormat formats)
bool dttr_graphics_ensure_staged_texture(DTTR_BackendState *state, DTTR_StagedTexture *st)
HWND dttr_graphics_init()
typedef kvec_t(int) DTTR_IntVector
bool dttr_graphics_is_gpu_thread()
bool dttr_graphics_opengl_init(DTTR_BackendState *state)
#define DTTR_UPLOAD_POOL_SIZE
SDL_GPUShaderFormat dttr_graphics_requested_shader_formats()
static void dttr_graphics_mod_window_resized(DTTR_BackendState *)
static void dttr_graphics_mod_device_lost(DTTR_BackendState *)
static void dttr_graphics_mod_before_game_frame(DTTR_BackendState *)
bool dttr_graphics_should_fill_mesh_seams(DTTR_PrimitiveType type, bool transformed, bool depth_test, bool blend_enabled)
Returns true when a draw call should receive subpixel logical-scaling seam fill.
bool dttr_graphics_sdl3gpu_init(DTTR_BackendState *state)
void dttr_graphics_handle_window_resize(int width, int height)
void dttr_graphics_surface_texture_cache_reset()
static void dttr_graphics_mod_device_restored(DTTR_BackendState *)
SDL_GPUShaderFormat dttr_graphics_select_shader_format(SDL_GPUShaderFormat formats)
void dttr_graphics_mod_present_rect_before(DTTR_BackendState *state, const DTTR_PresentRect *present)
void dttr_graphics_mod_present_rect_after(DTTR_BackendState *state, const DTTR_PresentRect *present, bool overlay_rendered)
SDL_GPUShaderFormat dttr_graphics_shader_format_for_driver(const char *driver)
static void dttr_graphics_mod_before_present(DTTR_BackendState *, uint32_t, uint32_t, uint32_t, uint32_t, bool, bool)
static void dttr_graphics_mod_device_created(DTTR_BackendState *)
DTTR_PresentRect dttr_graphics_compute_present_rect(int dst_w, int dst_h, int src_w, int src_h, bool stretch, bool integer_fit, float fallback_scale)
static void dttr_graphics_mod_window_destroying(DTTR_BackendState *)
DTTR_BackendState dttr_backend
static void dttr_graphics_mod_window_created(DTTR_BackendState *)
void dttr_graphics_begin_frame()
const char * dttr_graphics_shader_format_name(SDL_GPUShaderFormat format)
static void dttr_graphics_mod_after_present(DTTR_BackendState *, uint32_t, uint32_t, uint32_t, uint32_t, bool, bool)
static void dttr_graphics_mod_after_game_frame(DTTR_BackendState *)
static void dttr_graphics_mod_frame_begin(DTTR_BackendState *)
static void dttr_graphics_mod_frame_end(DTTR_BackendState *)
@ DTTR_PRIM_TRIANGLESTRIP
#define DTTR_MAX_STAGED_TEXTURES
void dttr_graphics_cleanup()
bool dttr_graphics_present_video_frame_bgra(const uint8_t *pixels, int width, int height, int stride)
int dttr_graphics_calc_mip_levels(int w, int h)
void dttr_graphics_end_frame()
uint32_t perf_draws_accum
uint32_t perf_mips_skipped_accum
SDL_GPUShaderFormat shader_format
uint64_t perf_frame_start_ns
uint32_t perf_sampler_binds_accum
DTTR_UploadPoolSlot upload_pool[DTTR_UPLOAD_POOL_SIZE]
DTTR_Texture bound_texture_handle
uint32_t perf_frame_accum_count
uint32_t perf_clears_accum
SDL_GPUTexture * video_texture
uint64_t perf_upload_bytes_accum
SDL_GPUTexture * depth_texture
SDL_GPUTexture * render_target
SDL_GPUTexture * dummy_texture
SDL_GPUSampler * samplers[DTTR_SAMPLER_COUNT]
uint64_t perf_cpu_ns_accum
uint32_t perf_pipeline_binds_accum
SDL_GPUBuffer * vertex_buffer
SDL_GPUTexture * msaa_render_target
SDL_ThreadID gpu_thread_id
SDL_GPUTexture * swapchain_tex
DTTR_BackendType backend_type
SDL_GPUGraphicsPipeline * pipelines[DTTR_PIPELINE_COUNT]
SDL_GPUTransferBuffer * transfer_buffer
DTTR_StagedTexture staged_textures[DTTR_MAX_STAGED_TEXTURES]
uint32_t perf_upload_textures_accum
DTTR_BatchRecordVector batch_records
SDL_GPURenderPass * render_pass
SDL_Mutex * texture_mutex
DTTR_TextureAddress addr_v
DTTR_IntVector pending_upload_indices
DTTR_TextureAddress addr_u
DTTR_BlendFactor blend_dst
SDL_GPUSampleCount msaa_sample_count
SDL_GPUCommandBuffer * cmd
const DTTR_RendererVtbl * renderer
SDL_GPUTexture * bound_texture
uint32_t perf_mips_generated_accum
A recorded clear or draw command replayed during frame submission.
DTTR_BatchRecordType type
Game-image placement within the present target, in target pixels.
Backend-specific operations dispatched through function pointers.
bool(* present_video_frame_bgra)(DTTR_BackendState *state, const uint8_t *pixels, int width, int height, int stride)
void(* cleanup)(DTTR_BackendState *state)
void(* end_frame)(DTTR_BackendState *state)
void(* begin_frame)(DTTR_BackendState *state)
bool(* resize)(DTTR_BackendState *state, int width, int height)
void(* defer_texture_destroy)(DTTR_BackendState *state, int texture_index)
uint64_t last_update_frame
One reusable upload slot holding a transfer buffer for texture uploads.
SDL_GPUTransferBuffer * transfer_buffer