video_driver.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  1. /* RetroArch - A frontend for libretro.
  2. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
  3. * Copyright (C) 2011-2021 - Daniel De Matteis
  4. *
  5. * RetroArch is free software: you can redistribute it and/or modify it under the terms
  6. * of the GNU General Public License as published by the Free Software Found-
  7. * ation, either version 3 of the License, or (at your option) any later version.
  8. *
  9. * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. * PURPOSE. See the GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with RetroArch.
  14. * If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef RARCH_VIDEO_DRIVER_H__
  17. #define RARCH_VIDEO_DRIVER_H__
  18. #include <stddef.h>
  19. #include <libretro.h>
  20. #include <retro_common_api.h>
  21. #include <boolean.h>
  22. #ifdef HAVE_CONFIG_H
  23. #include "../config.h"
  24. #endif
  25. #ifdef HAVE_THREADS
  26. #include <rthreads/rthreads.h>
  27. #endif
  28. #include <gfx/scaler/pixconv.h>
  29. #include <gfx/scaler/scaler.h>
  30. #include "../configuration.h"
  31. #include "../input/input_driver.h"
  32. #include "../input/input_types.h"
  33. #include "video_defines.h"
  34. #ifdef HAVE_CRTSWITCHRES
  35. #include "video_crt_switch.h"
  36. #endif
  37. #include "video_coord_array.h"
  38. #include "video_shader_parse.h"
  39. #include "video_filter.h"
  40. #define RARCH_SCALE_BASE 256
  41. #define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
  42. #define VIDEO_SHADER_STOCK_BLEND (GFX_MAX_SHADERS - 1)
  43. #define VIDEO_SHADER_MENU (GFX_MAX_SHADERS - 2)
  44. #define VIDEO_SHADER_MENU_2 (GFX_MAX_SHADERS - 3)
  45. #define VIDEO_SHADER_MENU_3 (GFX_MAX_SHADERS - 4)
  46. #define VIDEO_SHADER_MENU_4 (GFX_MAX_SHADERS - 5)
  47. #define VIDEO_SHADER_MENU_5 (GFX_MAX_SHADERS - 6)
  48. #define VIDEO_SHADER_MENU_6 (GFX_MAX_SHADERS - 7)
  49. #define VIDEO_SHADER_STOCK_HDR (GFX_MAX_SHADERS - 8)
  50. #define VIDEO_SHADER_STOCK_NOBLEND (GFX_MAX_SHADERS - 9)
  51. #define VIDEO_HDR_MAX_CONTRAST 10.0f
  52. #if defined(_XBOX360)
  53. #define DEFAULT_SHADER_TYPE RARCH_SHADER_HLSL
  54. #elif defined(HAVE_OPENGLES2) || defined(HAVE_GLSL)
  55. #define DEFAULT_SHADER_TYPE RARCH_SHADER_GLSL
  56. #elif defined(HAVE_CG)
  57. #define DEFAULT_SHADER_TYPE RARCH_SHADER_CG
  58. #else
  59. #define DEFAULT_SHADER_TYPE RARCH_SHADER_NONE
  60. #endif
  61. #ifndef MAX_EGLIMAGE_TEXTURES
  62. #define MAX_EGLIMAGE_TEXTURES 32
  63. #endif
  64. #define MAX_VARIABLES 64
  65. #ifdef HAVE_THREADS
  66. #define VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st) ((!video_driver_is_hw_context() && (((video_st->threaded)) ? true : false)))
  67. #define VIDEO_DRIVER_LOCK(video_st) \
  68. if (video_st->display_lock) \
  69. slock_lock(video_st->display_lock)
  70. #define VIDEO_DRIVER_UNLOCK(video_st) \
  71. if (video_st->display_lock) \
  72. slock_unlock(video_st->display_lock)
  73. #define VIDEO_DRIVER_CONTEXT_LOCK(video_st) \
  74. if (video_st->context_lock) \
  75. slock_lock(video_st->context_lock)
  76. #define VIDEO_DRIVER_CONTEXT_UNLOCK(video_st) \
  77. if (video_st->context_lock) \
  78. slock_unlock(video_st->context_lock)
  79. #define VIDEO_DRIVER_LOCK_FREE(video_st) \
  80. slock_free(video_st->display_lock); \
  81. slock_free(video_st->context_lock); \
  82. video_st->display_lock = NULL; \
  83. video_st->context_lock = NULL
  84. #define VIDEO_DRIVER_THREADED_LOCK(video_st, is_threaded) \
  85. if (is_threaded) \
  86. VIDEO_DRIVER_LOCK(video_st)
  87. #define VIDEO_DRIVER_THREADED_UNLOCK(video_st, is_threaded) \
  88. if (is_threaded) \
  89. VIDEO_DRIVER_UNLOCK(video_st)
  90. #define VIDEO_DRIVER_GET_PTR_INTERNAL(video_st) ((VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st)) ? video_thread_get_ptr(video_st) : video_st->data)
  91. #else
  92. #define VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st) (false)
  93. #define VIDEO_DRIVER_LOCK(video_st) ((void)0)
  94. #define VIDEO_DRIVER_UNLOCK(video_st) ((void)0)
  95. #define VIDEO_DRIVER_LOCK_FREE(video_st) ((void)0)
  96. #define VIDEO_DRIVER_THREADED_LOCK(video_st, is_threaded) ((void)0)
  97. #define VIDEO_DRIVER_THREADED_UNLOCK(video_st, is_threaded) ((void)0)
  98. #define VIDEO_DRIVER_CONTEXT_LOCK(video_st) ((void)0)
  99. #define VIDEO_DRIVER_CONTEXT_UNLOCK(video_st) ((void)0)
  100. #define VIDEO_DRIVER_GET_PTR_INTERNAL(video_st) (video_st->data)
  101. #endif
  102. #define VIDEO_DRIVER_GET_HW_CONTEXT_INTERNAL(video_st) (&video_st->hw_render)
  103. #define VIDEO_HAS_FOCUS(video_st) (video_st->current_video->focus ? (video_st->current_video->focus(video_st->data)) : true)
  104. RETRO_BEGIN_DECLS
  105. enum video_driver_state_flags
  106. {
  107. VIDEO_FLAG_DEFERRED_VIDEO_CTX_DRIVER_SET_FLAGS = (1 << 0 ),
  108. VIDEO_FLAG_WINDOW_TITLE_UPDATE = (1 << 1 ),
  109. VIDEO_FLAG_WIDGETS_PAUSED = (1 << 2 ),
  110. VIDEO_FLAG_WIDGETS_FAST_FORWARD = (1 << 3 ),
  111. VIDEO_FLAG_WIDGETS_REWINDING = (1 << 4 ),
  112. VIDEO_FLAG_STARTED_FULLSCREEN = (1 << 5 ),
  113. /* Graphics driver requires RGBA byte order data (ABGR on little-endian)
  114. * for 32-bit.
  115. * This takes effect for overlay and shader cores that wants to load
  116. * data into graphics driver. Kinda hackish to place it here, it is only
  117. * used for GLES.
  118. * TODO: Refactor this better. */
  119. VIDEO_FLAG_USE_RGBA = (1 << 6 ),
  120. /* Graphics driver supports HDR displays
  121. * Currently only D3D11/D3D12/Vulkan supports HDR displays
  122. * on Windows and whether we've enabled it */
  123. VIDEO_FLAG_HDR_SUPPORT = (1 << 7 ),
  124. /* If set during context deinit, the driver should keep
  125. * graphics context alive to avoid having to reset all
  126. * context state. */
  127. VIDEO_FLAG_CACHE_CONTEXT = (1 << 8 ),
  128. /* Set to true by driver if context caching succeeded. */
  129. VIDEO_FLAG_CACHE_CONTEXT_ACK = (1 << 9 ),
  130. VIDEO_FLAG_ACTIVE = (1 << 10),
  131. VIDEO_FLAG_STATE_OUT_RGB32 = (1 << 11),
  132. VIDEO_FLAG_CRT_SWITCHING_ACTIVE = (1 << 12),
  133. VIDEO_FLAG_FORCE_FULLSCREEN = (1 << 13),
  134. VIDEO_FLAG_IS_SWITCHING_DISPLAY_MODE = (1 << 14),
  135. VIDEO_FLAG_SHADER_PRESETS_NEED_RELOAD = (1 << 15),
  136. VIDEO_FLAG_CLI_SHADER_DISABLE = (1 << 16),
  137. VIDEO_FLAG_RUNAHEAD_IS_ACTIVE = (1 << 17)
  138. };
  139. struct LinkInfo
  140. {
  141. struct video_shader_pass *pass;
  142. unsigned tex_w, tex_h;
  143. };
  144. struct shader_program_info
  145. {
  146. void *data;
  147. const char *vertex;
  148. const char *fragment;
  149. const char *combined;
  150. unsigned idx;
  151. bool is_file;
  152. };
  153. struct uniform_info
  154. {
  155. bool enabled;
  156. int32_t location;
  157. int32_t count;
  158. unsigned type; /* shader uniform type */
  159. struct
  160. {
  161. enum shader_program_type type;
  162. const char *ident;
  163. uint32_t idx;
  164. bool add_prefix;
  165. bool enable;
  166. } lookup;
  167. struct
  168. {
  169. float *floatv;
  170. intptr_t *integerv;
  171. uintptr_t *unsigned_integerv;
  172. struct
  173. {
  174. intptr_t v0;
  175. intptr_t v1;
  176. intptr_t v2;
  177. intptr_t v3;
  178. } integer;
  179. struct
  180. {
  181. uintptr_t v0;
  182. uintptr_t v1;
  183. uintptr_t v2;
  184. uintptr_t v3;
  185. } unsigned_integer;
  186. struct
  187. {
  188. float v0;
  189. float v1;
  190. float v2;
  191. float v3;
  192. } f;
  193. } result;
  194. };
  195. typedef struct shader_backend
  196. {
  197. void *(*init)(void *data, const char *path);
  198. void (*init_menu_shaders)(void *data);
  199. void (*deinit)(void *data);
  200. /* Set shader parameters. */
  201. void (*set_params)(void *data, void *shader_data);
  202. void (*set_uniform_parameter)(void *data, struct uniform_info *param,
  203. void *uniform_data);
  204. /* Compile a shader program. */
  205. bool (*compile_program)(void *data, unsigned idx,
  206. void *program_data, struct shader_program_info *program_info);
  207. /* Use a shader program specified by variable 'index'. */
  208. void (*use)(void *data, void *shader_data, unsigned index, bool set_active);
  209. /* Returns the number of currently loaded shaders. */
  210. unsigned (*num_shaders)(void *data);
  211. bool (*filter_type)(void *data, unsigned index, bool *smooth);
  212. enum gfx_wrap_type (*wrap_type)(void *data, unsigned index);
  213. void (*shader_scale)(void *data,
  214. unsigned index, struct gfx_fbo_scale *scale);
  215. bool (*set_coords)(void *shader_data, const struct video_coords *coords);
  216. bool (*set_mvp)(void *shader_data, const void *mat_data);
  217. unsigned (*get_prev_textures)(void *data);
  218. bool (*get_feedback_pass)(void *data, unsigned *pass);
  219. bool (*mipmap_input)(void *data, unsigned index);
  220. struct video_shader *(*get_current_shader)(void *data);
  221. void (*get_flags)(uint32_t*);
  222. enum rarch_shader_type type;
  223. /* Human readable string. */
  224. const char *ident;
  225. } shader_backend_t;
  226. typedef struct video_shader_ctx_params
  227. {
  228. void *data;
  229. const void *info;
  230. const void *prev_info;
  231. const void *feedback_info;
  232. const void *fbo_info;
  233. unsigned width;
  234. unsigned height;
  235. unsigned tex_width;
  236. unsigned tex_height;
  237. unsigned out_width;
  238. unsigned out_height;
  239. unsigned frame_counter;
  240. unsigned fbo_info_cnt;
  241. } video_shader_ctx_params_t;
  242. typedef struct video_shader_ctx
  243. {
  244. struct video_shader *data;
  245. } video_shader_ctx_t;
  246. typedef struct video_pixel_scaler
  247. {
  248. struct scaler_ctx *scaler;
  249. void *scaler_out;
  250. } video_pixel_scaler_t;
  251. typedef void (*gfx_ctx_proc_t)(void);
  252. typedef struct video_info
  253. {
  254. const char *path_font;
  255. uintptr_t parent;
  256. int swap_interval;
  257. /* Width of window.
  258. * If fullscreen mode is requested,
  259. * a width of 0 means the resolution of the
  260. * desktop should be used. */
  261. unsigned width;
  262. /* Height of window.
  263. * If fullscreen mode is requested,
  264. * a height of 0 means the resolutiof the desktop should be used.
  265. */
  266. unsigned height;
  267. #ifdef GEKKO
  268. /* TODO - we can't really have driver system-specific
  269. * variables in here. There should be some
  270. * kind of publicly accessible driver implementation
  271. * video struct for specific things like this.
  272. */
  273. /* Wii-specific settings. Ignored for everything else. */
  274. unsigned viwidth;
  275. #endif
  276. /*
  277. * input_scale defines the maximum size of the picture that will
  278. * ever be used with the frame callback.
  279. *
  280. * The maximum resolution is a multiple of 256x256 size (RARCH_SCALE_BASE),
  281. * so an input scale of 2 means you should allocate a texture or of 512x512.
  282. *
  283. * Maximum input size: RARCH_SCALE_BASE * input_scale
  284. */
  285. unsigned input_scale;
  286. float font_size;
  287. bool adaptive_vsync;
  288. #ifdef GEKKO
  289. bool vfilter;
  290. #endif
  291. /* If true, applies bilinear filtering to the image,
  292. * otherwise nearest filtering. */
  293. bool smooth;
  294. bool ctx_scaling;
  295. bool is_threaded;
  296. /* Use 32bit RGBA rather than native RGB565/XBGR1555.
  297. *
  298. * XRGB1555 format is 16-bit and has byte ordering: 0RRRRRGGGGGBBBBB,
  299. * in native endian.
  300. *
  301. * ARGB8888 is AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB, native endian.
  302. * Alpha channel should be disregarded.
  303. * */
  304. bool rgb32;
  305. /* Launch in fullscreen mode instead of windowed mode. */
  306. bool fullscreen;
  307. /* Start with V-Sync enabled. */
  308. bool vsync;
  309. /* If true, the output image should have the aspect ratio
  310. * as set in aspect_ratio. */
  311. bool force_aspect;
  312. bool font_enable;
  313. } video_info_t;
  314. typedef struct video_frame_info
  315. {
  316. void *userdata;
  317. void *widgets_userdata;
  318. void *disp_userdata;
  319. int custom_vp_x;
  320. int custom_vp_y;
  321. int crt_switch_center_adjust;
  322. int crt_switch_porch_adjust;
  323. unsigned hard_sync_frames;
  324. unsigned runahead_frames;
  325. unsigned aspect_ratio_idx;
  326. unsigned max_swapchain_images;
  327. unsigned monitor_index;
  328. unsigned crt_switch_resolution;
  329. unsigned crt_switch_resolution_super;
  330. unsigned width;
  331. unsigned height;
  332. unsigned xmb_theme;
  333. unsigned xmb_color_theme;
  334. unsigned menu_shader_pipeline;
  335. unsigned materialui_color_theme;
  336. unsigned ozone_color_theme;
  337. unsigned custom_vp_width;
  338. unsigned custom_vp_height;
  339. unsigned custom_vp_full_width;
  340. unsigned custom_vp_full_height;
  341. unsigned black_frame_insertion;
  342. unsigned fps_update_interval;
  343. unsigned memory_update_interval;
  344. unsigned msg_queue_delay;
  345. float menu_wallpaper_opacity;
  346. float menu_framebuffer_opacity;
  347. float menu_header_opacity;
  348. float menu_footer_opacity;
  349. float refresh_rate;
  350. float font_size;
  351. float font_msg_pos_x;
  352. float font_msg_pos_y;
  353. float font_msg_color_r;
  354. float font_msg_color_g;
  355. float font_msg_color_b;
  356. float xmb_alpha_factor;
  357. struct
  358. {
  359. /* Drop shadow offset.
  360. * If both are 0, no drop shadow will be rendered. */
  361. int drop_x, drop_y;
  362. /* ABGR. Use the macros. */
  363. uint32_t color;
  364. float x;
  365. float y;
  366. float scale;
  367. /* Drop shadow color multiplier. */
  368. float drop_mod;
  369. /* Drop shadow alpha */
  370. float drop_alpha;
  371. enum text_alignment text_align;
  372. bool full_screen;
  373. } osd_stat_params;
  374. char stat_text[1024];
  375. bool widgets_active;
  376. bool notifications_hidden;
  377. bool menu_mouse_enable;
  378. bool widgets_is_paused;
  379. bool widgets_is_fast_forwarding;
  380. bool widgets_is_rewinding;
  381. bool input_menu_swap_ok_cancel_buttons;
  382. bool input_driver_nonblock_state;
  383. bool input_driver_grab_mouse_state;
  384. bool hard_sync;
  385. bool runahead;
  386. bool runahead_second_instance;
  387. bool preemptive_frames;
  388. bool fps_show;
  389. bool memory_show;
  390. bool statistics_show;
  391. bool framecount_show;
  392. bool core_status_msg_show;
  393. bool post_filter_record;
  394. bool windowed_fullscreen;
  395. bool fullscreen;
  396. bool font_enable;
  397. bool use_rgba;
  398. bool hdr_support;
  399. bool libretro_running;
  400. bool xmb_shadows_enable;
  401. bool battery_level_enable;
  402. bool timedate_enable;
  403. bool runloop_is_slowmotion;
  404. bool runloop_is_paused;
  405. bool fastforward_frameskip;
  406. bool menu_is_alive;
  407. bool menu_screensaver_active;
  408. bool msg_bgcolor_enable;
  409. bool crt_switch_hires_menu;
  410. bool hdr_enable;
  411. bool overlay_behind_menu;
  412. } video_frame_info_t;
  413. typedef void (*update_window_title_cb)(void*);
  414. typedef bool (*get_metrics_cb)(void *data, enum display_metric_types type,
  415. float *value);
  416. typedef bool (*set_resize_cb)(void*, unsigned, unsigned);
  417. typedef struct gfx_ctx_driver
  418. {
  419. /* The opaque pointer is the underlying video driver data (e.g. gl_t for
  420. * OpenGL contexts). Although not advised, the context driver is allowed
  421. * to hold a pointer to it as the context never outlives the video driver.
  422. *
  423. * The context driver is responsible for it's own data.*/
  424. void* (*init)(void *video_driver);
  425. void (*destroy)(void *data);
  426. enum gfx_ctx_api (*get_api)(void *data);
  427. /* Which API to bind to. */
  428. bool (*bind_api)(void *video_driver, enum gfx_ctx_api,
  429. unsigned major, unsigned minor);
  430. /* Sets the swap interval. */
  431. void (*swap_interval)(void *data, int);
  432. /* Sets video mode. Creates a window, etc. */
  433. bool (*set_video_mode)(void*, unsigned, unsigned, bool);
  434. /* Gets current window size.
  435. * If not initialized yet, it returns current screen size. */
  436. void (*get_video_size)(void*, unsigned*, unsigned*);
  437. float (*get_refresh_rate)(void*);
  438. void (*get_video_output_size)(void*, unsigned*, unsigned*, char *, size_t);
  439. void (*get_video_output_prev)(void*);
  440. void (*get_video_output_next)(void*);
  441. get_metrics_cb get_metrics;
  442. /* Translates a window size to an aspect ratio.
  443. * In most cases this will be just width / height, but
  444. * some contexts will better know which actual aspect ratio is used.
  445. * This can be NULL to assume the default behavior.
  446. */
  447. float (*translate_aspect)(void*, unsigned, unsigned);
  448. /* Asks driver to update window title (FPS, etc). */
  449. update_window_title_cb update_window_title;
  450. /* Queries for resize and quit events.
  451. * Also processes events. */
  452. void (*check_window)(void*, bool*, bool*,
  453. unsigned*, unsigned*);
  454. /* Acknowledge a resize event. This is needed for some APIs.
  455. * Most backends will ignore this. */
  456. set_resize_cb set_resize;
  457. /* Checks if window has input focus. */
  458. bool (*has_focus)(void*);
  459. /* Should the screensaver be suppressed? */
  460. bool (*suppress_screensaver)(void *data, bool enable);
  461. /* Checks if context driver has windowed support. */
  462. bool has_windowed;
  463. /* Swaps buffers. VBlank sync depends on
  464. * earlier calls to swap_interval. */
  465. void (*swap_buffers)(void*);
  466. /* Most video backends will want to use a certain input driver.
  467. * Checks for it here. */
  468. void (*input_driver)(void*, const char *, input_driver_t**, void**);
  469. /* Wraps whatever gl_proc_address() there is.
  470. * Does not take opaque, to avoid lots of ugly wrapper code. */
  471. gfx_ctx_proc_t (*get_proc_address)(const char*);
  472. /* Returns true if this context supports EGLImage buffers for
  473. * screen drawing and was initalized correctly. */
  474. bool (*image_buffer_init)(void*, const video_info_t*);
  475. /* Writes the frame to the EGLImage and sets image_handle to it.
  476. * Returns true if a new image handle is created.
  477. * Always returns true the first time it's called for a new index.
  478. * The graphics core must handle a change in the handle correctly. */
  479. bool (*image_buffer_write)(void*, const void *frame, unsigned width,
  480. unsigned height, unsigned pitch, bool rgb32,
  481. unsigned index, void **image_handle);
  482. /* Shows or hides mouse. Can be NULL if context doesn't
  483. * have a concept of mouse pointer. */
  484. void (*show_mouse)(void *data, bool state);
  485. /* Human readable string. */
  486. const char *ident;
  487. uint32_t (*get_flags)(void *data);
  488. void (*set_flags)(void *data, uint32_t flags);
  489. /* Optional. Binds HW-render offscreen context. */
  490. void (*bind_hw_render)(void *data, bool enable);
  491. /* Optional. Gets base data for the context which is used by the driver.
  492. * This is mostly relevant for graphics APIs such as Vulkan
  493. * which do not have global context state. */
  494. void *(*get_context_data)(void *data);
  495. /* Optional. Makes driver context (only GL right now)
  496. * active for this thread. */
  497. void (*make_current)(bool release);
  498. } gfx_ctx_driver_t;
  499. typedef struct gfx_ctx_mode
  500. {
  501. unsigned width;
  502. unsigned height;
  503. bool fullscreen;
  504. } gfx_ctx_mode_t;
  505. typedef struct gfx_ctx_metrics
  506. {
  507. float *value;
  508. enum display_metric_types type;
  509. } gfx_ctx_metrics_t;
  510. typedef struct gfx_ctx_input
  511. {
  512. input_driver_t **input;
  513. void **input_data;
  514. } gfx_ctx_input_t;
  515. typedef struct gfx_ctx_ident
  516. {
  517. const char *ident;
  518. } gfx_ctx_ident_t;
  519. /* Optionally implemented interface to poke more
  520. * deeply into video driver. */
  521. typedef struct video_poke_interface
  522. {
  523. uint32_t (*get_flags)(void *data);
  524. uintptr_t (*load_texture)(void *video_data, void *data,
  525. bool threaded, enum texture_filter_type filter_type);
  526. void (*unload_texture)(void *data, bool threaded, uintptr_t id);
  527. void (*set_video_mode)(void *data, unsigned width,
  528. unsigned height, bool fullscreen);
  529. float (*get_refresh_rate)(void *data);
  530. void (*set_filtering)(void *data, unsigned index, bool smooth, bool ctx_scaling);
  531. void (*get_video_output_size)(void *data,
  532. unsigned *width, unsigned *height, char *desc, size_t desc_len);
  533. /* Move index to previous resolution */
  534. void (*get_video_output_prev)(void *data);
  535. /* Move index to next resolution */
  536. void (*get_video_output_next)(void *data);
  537. uintptr_t (*get_current_framebuffer)(void *data);
  538. retro_proc_address_t (*get_proc_address)(void *data, const char *sym);
  539. void (*set_aspect_ratio)(void *data, unsigned aspectratio_index);
  540. void (*apply_state_changes)(void *data);
  541. /* Update texture. */
  542. void (*set_texture_frame)(void *data, const void *frame, bool rgb32,
  543. unsigned width, unsigned height, float alpha);
  544. /* Enable or disable rendering. */
  545. void (*set_texture_enable)(void *data, bool enable, bool full_screen);
  546. void (*set_osd_msg)(void *data,
  547. const char *msg,
  548. const struct font_params *params, void *font);
  549. void (*show_mouse)(void *data, bool state);
  550. void (*grab_mouse_toggle)(void *data);
  551. struct video_shader *(*get_current_shader)(void *data);
  552. bool (*get_current_software_framebuffer)(void *data,
  553. struct retro_framebuffer *framebuffer);
  554. bool (*get_hw_render_interface)(void *data,
  555. const struct retro_hw_render_interface **iface);
  556. /* hdr settings */
  557. void (*set_hdr_max_nits)(void *data, float max_nits);
  558. void (*set_hdr_paper_white_nits)(void *data, float paper_white_nits);
  559. void (*set_hdr_contrast)(void *data, float contrast);
  560. void (*set_hdr_expand_gamut)(void *data, bool expand_gamut);
  561. } video_poke_interface_t;
  562. /* msg is for showing a message on the screen
  563. * along with the video frame. */
  564. typedef bool (*video_driver_frame_t)(void *data,
  565. const void *frame, unsigned width,
  566. unsigned height, uint64_t frame_count,
  567. unsigned pitch, const char *msg, video_frame_info_t *video_info);
  568. typedef struct video_driver
  569. {
  570. /* Should the video driver act as an input driver as well?
  571. * The video initialization might preinitialize an input driver
  572. * to override the settings in case the video driver relies on
  573. * input driver for event handling. */
  574. void *(*init)(const video_info_t *video,
  575. input_driver_t **input,
  576. void **input_data);
  577. /* Updates frame on the screen.
  578. * Frame can be either XRGB1555, RGB565 or ARGB32 format
  579. * depending on rgb32 setting in video_info_t.
  580. * Pitch is the distance in bytes between two scanlines in memory.
  581. *
  582. * When msg is non-NULL,
  583. * it's a message that should be displayed to the user. */
  584. video_driver_frame_t frame;
  585. /* Should we care about syncing to vblank? Fast forwarding.
  586. *
  587. * Requests nonblocking operation.
  588. *
  589. * True = VSync is turned off.
  590. * False = VSync is turned on.
  591. * */
  592. void (*set_nonblock_state)(void *data, bool toggle,
  593. bool adaptive_vsync_enabled,
  594. unsigned swap_interval);
  595. /* Is the window still active? */
  596. bool (*alive)(void *data);
  597. /* Does the window have focus? */
  598. bool (*focus)(void *data);
  599. /* Should the screensaver be suppressed? */
  600. bool (*suppress_screensaver)(void *data, bool enable);
  601. /* Does the graphics context support windowed mode? */
  602. bool (*has_windowed)(void *data);
  603. /* Sets shader. Might not be implemented. Will be moved to
  604. * poke_interface later. */
  605. bool (*set_shader)(void *data, enum rarch_shader_type type,
  606. const char *path);
  607. /* Frees driver. */
  608. void (*free)(void *data);
  609. /* Human-readable identifier. */
  610. const char *ident;
  611. void (*set_viewport)(void *data, unsigned width, unsigned height,
  612. bool force_full, bool allow_rotate);
  613. void (*set_rotation)(void *data, unsigned rotation);
  614. void (*viewport_info)(void *data, struct video_viewport *vp);
  615. /* Reads out in BGR byte order (24bpp). */
  616. bool (*read_viewport)(void *data, uint8_t *buffer, bool is_idle);
  617. /* Returns a pointer to a newly allocated buffer that can
  618. * (and must) be passed to free() by the caller, containing a
  619. * copy of the current raw frame in the active pixel format
  620. * and sets width, height and pitch to the correct values. */
  621. void* (*read_frame_raw)(void *data, unsigned *width,
  622. unsigned *height, size_t *pitch);
  623. #ifdef HAVE_OVERLAY
  624. void (*overlay_interface)(void *data,
  625. const video_overlay_interface_t **iface);
  626. #endif
  627. void (*poke_interface)(void *data, const video_poke_interface_t **iface);
  628. unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type);
  629. #if defined(HAVE_GFX_WIDGETS)
  630. /* if set to true, will use display widgets when applicable
  631. * if set to false, will use OSD as a fallback */
  632. bool (*gfx_widgets_enabled)(void *data);
  633. #endif
  634. } video_driver_t;
  635. typedef struct
  636. {
  637. #ifdef HAVE_CRTSWITCHRES
  638. videocrt_switch_t crt_switch_st; /* double alignment */
  639. #endif
  640. struct retro_system_av_info av_info; /* double alignment */
  641. retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT];
  642. retro_time_t core_frame_time;
  643. uint64_t frame_time_count;
  644. uint64_t frame_count;
  645. uint8_t *record_gpu_buffer;
  646. #ifdef HAVE_VIDEO_FILTER
  647. rarch_softfilter_t *state_filter;
  648. void *state_buffer;
  649. #endif
  650. void *data;
  651. video_driver_t *current_video;
  652. /* Interface for "poking". */
  653. const video_poke_interface_t *poke;
  654. gfx_ctx_driver_t current_video_context; /* ptr alignment */
  655. struct retro_hw_render_callback hw_render; /* ptr alignment */
  656. struct rarch_dir_shader_list dir_shader_list; /* ptr alignment */
  657. #ifdef HAVE_THREADS
  658. slock_t *display_lock;
  659. slock_t *context_lock;
  660. #endif
  661. /* Used for 15-bit -> 16-bit conversions that take place before
  662. * being passed to video driver. */
  663. video_pixel_scaler_t *scaler_ptr;
  664. video_driver_frame_t frame_bak; /* ptr alignment */
  665. void *current_display_server_data;
  666. const void *frame_cache_data;
  667. const struct
  668. retro_hw_render_context_negotiation_interface *
  669. hw_render_context_negotiation;
  670. #ifdef HAVE_MENU
  671. struct video_shader *menu_driver_shader;
  672. #endif
  673. void *context_data;
  674. /* Opaque handles to currently running window.
  675. * Used by e.g. input drivers which bind to a window.
  676. * Drivers are responsible for setting these if an input driver
  677. * could potentially make use of this. */
  678. uintptr_t display_userdata;
  679. uintptr_t display;
  680. uintptr_t window;
  681. size_t frame_cache_pitch;
  682. size_t window_title_len;
  683. uint32_t flags;
  684. #ifdef HAVE_VIDEO_FILTER
  685. unsigned state_scale;
  686. unsigned state_out_bpp;
  687. #endif
  688. unsigned frame_cache_width;
  689. unsigned frame_cache_height;
  690. unsigned width;
  691. unsigned height;
  692. float core_hz;
  693. float aspect_ratio;
  694. float video_refresh_rate_original;
  695. enum retro_pixel_format pix_fmt;
  696. enum rarch_display_type display_type;
  697. enum rotation initial_screen_orientation;
  698. enum rotation current_screen_orientation;
  699. /**
  700. * dynamic.c:dynamic_request_hw_context will try to set flag data when the context
  701. * is in the middle of being rebuilt; in these cases we will save flag
  702. * data and set this to true.
  703. * When the context is reinit, it checks this, reads from
  704. * deferred_flag_data and cleans it.
  705. *
  706. * TODO - Dirty hack, fix it better
  707. */
  708. gfx_ctx_flags_t deferred_flag_data; /* uint32_t alignment */
  709. char cli_shader_path[PATH_MAX_LENGTH];
  710. char window_title[512];
  711. char gpu_device_string[128];
  712. char gpu_api_version_string[128];
  713. char title_buf[64];
  714. char cached_driver_id[32];
  715. uint8_t frame_delay_target;
  716. uint8_t frame_delay_effective;
  717. bool frame_delay_pause;
  718. bool threaded;
  719. } video_driver_state_t;
  720. typedef struct video_frame_delay_auto
  721. {
  722. float refresh_rate;
  723. uint16_t frame_time_target;
  724. uint16_t frame_time_avg;
  725. uint8_t frame_time_interval;
  726. uint8_t delay_decrease;
  727. } video_frame_delay_auto_t;
  728. struct aspect_ratio_elem
  729. {
  730. float value;
  731. char name[64];
  732. };
  733. extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END];
  734. bool video_driver_has_windowed(void);
  735. bool video_driver_has_focus(void);
  736. bool video_driver_cached_frame_has_valid_framebuffer(void);
  737. void video_driver_set_cached_frame_ptr(const void *data);
  738. void video_driver_set_stub_frame(void);
  739. void video_driver_unset_stub_frame(void);
  740. bool video_driver_supports_viewport_read(void);
  741. bool video_driver_prefer_viewport_read(void);
  742. bool video_driver_supports_read_frame_raw(void);
  743. float video_driver_get_core_aspect(void);
  744. void video_driver_set_viewport_core(void);
  745. void video_driver_reset_custom_viewport(settings_t *settings);
  746. void video_driver_set_rgba(void);
  747. void video_driver_unset_rgba(void);
  748. bool video_driver_supports_rgba(void);
  749. void video_driver_set_hdr_support(void);
  750. void video_driver_unset_hdr_support(void);
  751. bool video_driver_supports_hdr(void);
  752. bool video_driver_get_next_video_out(void);
  753. bool video_driver_get_prev_video_out(void);
  754. void video_driver_monitor_reset(void);
  755. void video_driver_set_aspect_ratio(void);
  756. void video_driver_update_viewport(struct video_viewport* vp, bool force_full, bool keep_aspect);
  757. void video_driver_show_mouse(void);
  758. void video_driver_hide_mouse(void);
  759. void video_driver_apply_state_changes(void);
  760. bool video_driver_read_viewport(uint8_t *buffer, bool is_idle);
  761. void video_driver_cached_frame(void);
  762. bool video_driver_is_hw_context(void);
  763. struct retro_hw_render_callback *video_driver_get_hw_context(void);
  764. const struct retro_hw_render_context_negotiation_interface
  765. *video_driver_get_context_negotiation_interface(void);
  766. bool video_driver_get_viewport_info(struct video_viewport *viewport);
  767. /**
  768. * config_get_video_driver_options:
  769. *
  770. * Get an enumerated list of all video driver names, separated by '|'.
  771. *
  772. * Returns: string listing of all video driver names, separated by '|'.
  773. **/
  774. const char* config_get_video_driver_options(void);
  775. /**
  776. * video_driver_get_ptr:
  777. *
  778. * Use this if you need the real video driver
  779. * and driver data pointers.
  780. *
  781. * Returns: video driver's userdata.
  782. **/
  783. void *video_driver_get_ptr(void);
  784. video_driver_state_t *video_state_get_ptr(void);
  785. bool video_driver_set_rotation(unsigned rotation);
  786. bool video_driver_set_video_mode(unsigned width,
  787. unsigned height, bool fullscreen);
  788. bool video_driver_get_video_output_size(
  789. unsigned *width, unsigned *height, char *desc, size_t desc_len);
  790. void video_driver_set_texture_enable(bool enable, bool full_screen);
  791. void video_driver_set_texture_frame(const void *frame, bool rgb32,
  792. unsigned width, unsigned height, float alpha);
  793. void * video_driver_read_frame_raw(unsigned *width,
  794. unsigned *height, size_t *pitch);
  795. void video_driver_set_filtering(unsigned index, bool smooth, bool ctx_scaling);
  796. const char *video_driver_get_ident(void);
  797. void video_driver_set_viewport(unsigned width, unsigned height,
  798. bool force_fullscreen, bool allow_rotate);
  799. void video_driver_get_size(unsigned *width, unsigned *height);
  800. void video_driver_set_size(unsigned width, unsigned height);
  801. float video_driver_get_aspect_ratio(void);
  802. void video_driver_set_aspect_ratio_value(float value);
  803. enum retro_pixel_format video_driver_get_pixel_format(void);
  804. void video_driver_cached_frame_set(const void *data, unsigned width,
  805. unsigned height, size_t pitch);
  806. void video_driver_cached_frame_get(const void **data, unsigned *width,
  807. unsigned *height, size_t *pitch);
  808. void video_driver_menu_settings(void **list_data, void *list_info_data,
  809. void *group_data, void *subgroup_data, const char *parent_group);
  810. /**
  811. * video_viewport_get_scaled_integer:
  812. * @vp : Viewport handle
  813. * @width : Width.
  814. * @height : Height.
  815. * @aspect_ratio : Aspect ratio (in float).
  816. * @keep_aspect : Preserve aspect ratio?
  817. *
  818. * Gets viewport scaling dimensions based on
  819. * scaled integer aspect ratio.
  820. **/
  821. void video_viewport_get_scaled_integer(struct video_viewport *vp,
  822. unsigned width, unsigned height,
  823. float aspect_ratio, bool keep_aspect);
  824. struct retro_system_av_info *video_viewport_get_system_av_info(void);
  825. struct video_viewport *video_viewport_get_custom(void);
  826. /**
  827. * video_monitor_set_refresh_rate:
  828. * @hz : New refresh rate for monitor.
  829. *
  830. * Sets monitor refresh rate to new value.
  831. **/
  832. void video_monitor_set_refresh_rate(float hz);
  833. /**
  834. * video_monitor_compute_fps_statistics:
  835. *
  836. * Computes monitor FPS statistics.
  837. **/
  838. void video_monitor_compute_fps_statistics(uint64_t
  839. frame_time_count);
  840. /**
  841. * video_monitor_fps_statistics
  842. * @refresh_rate : Monitor refresh rate.
  843. * @deviation : Deviation from measured refresh rate.
  844. * @sample_points : Amount of sampled points.
  845. *
  846. * Gets the monitor FPS statistics based on the current
  847. * runtime.
  848. *
  849. * Returns: true (1) on success.
  850. * false (0) if:
  851. * a) threaded video mode is enabled
  852. * b) less than 2 frame time samples.
  853. * c) FPS monitor enable is off.
  854. **/
  855. bool video_monitor_fps_statistics(double *refresh_rate,
  856. double *deviation, unsigned *sample_points);
  857. bool video_driver_monitor_adjust_system_rates(
  858. float timing_skew_hz,
  859. float video_refresh_rate,
  860. bool vrr_runloop_enable,
  861. float audio_max_timing_skew,
  862. unsigned video_swap_interval,
  863. double input_fps);
  864. void crt_switch_driver_refresh(void);
  865. char* crt_switch_core_name(void);
  866. #define video_driver_translate_coord_viewport_wrap(vp, mouse_x, mouse_y, res_x, res_y, res_screen_x, res_screen_y) \
  867. (video_driver_get_viewport_info(vp) ? video_driver_translate_coord_viewport(vp, mouse_x, mouse_y, res_x, res_y, res_screen_x, res_screen_y) : false)
  868. /**
  869. * video_driver_translate_coord_viewport:
  870. * @mouse_x : Pointer X coordinate.
  871. * @mouse_y : Pointer Y coordinate.
  872. * @res_x : Scaled X coordinate.
  873. * @res_y : Scaled Y coordinate.
  874. * @res_screen_x : Scaled screen X coordinate.
  875. * @res_screen_y : Scaled screen Y coordinate.
  876. *
  877. * Translates pointer [X,Y] coordinates into scaled screen
  878. * coordinates based on viewport info.
  879. *
  880. * Returns: true (1) if successful, false if video driver doesn't support
  881. * viewport info.
  882. **/
  883. bool video_driver_translate_coord_viewport(
  884. struct video_viewport *vp,
  885. int mouse_x, int mouse_y,
  886. int16_t *res_x, int16_t *res_y, int16_t *res_screen_x,
  887. int16_t *res_screen_y);
  888. uintptr_t video_driver_display_userdata_get(void);
  889. uintptr_t video_driver_display_get(void);
  890. enum rarch_display_type video_driver_display_type_get(void);
  891. uintptr_t video_driver_window_get(void);
  892. void video_driver_display_type_set(enum rarch_display_type type);
  893. void video_driver_display_set(uintptr_t idx);
  894. void video_driver_display_userdata_set(uintptr_t idx);
  895. void video_driver_window_set(uintptr_t idx);
  896. bool video_driver_texture_load(void *data,
  897. enum texture_filter_type filter_type,
  898. uintptr_t *id);
  899. bool video_driver_texture_unload(uintptr_t *id);
  900. void video_driver_build_info(video_frame_info_t *video_info);
  901. void video_driver_reinit(int flags);
  902. size_t video_driver_get_window_title(char *buf, unsigned len);
  903. bool *video_driver_get_threaded(void);
  904. void video_driver_set_threaded(bool val);
  905. void video_frame_delay_auto(video_driver_state_t *video_st, video_frame_delay_auto_t *vfda);
  906. /**
  907. * video_context_driver_init:
  908. * @core_set_shared_context : Boolean value that tells us whether shared context
  909. * is set.
  910. * @ctx : Graphics context driver to initialize.
  911. * @ident : Identifier of graphics context driver to find.
  912. * @api : API of higher-level graphics API.
  913. * @major : Major version number of higher-level graphics API.
  914. * @minor : Minor version number of higher-level graphics API.
  915. * @hw_render_ctx : Request a graphics context driver capable of
  916. * hardware rendering?
  917. *
  918. * Initialize graphics context driver.
  919. *
  920. * Returns: graphics context driver if successfully initialized,
  921. * otherwise NULL.
  922. **/
  923. const gfx_ctx_driver_t *video_context_driver_init(
  924. bool core_set_shared_context,
  925. settings_t *settings,
  926. void *data,
  927. const gfx_ctx_driver_t *ctx,
  928. const char *ident,
  929. enum gfx_ctx_api api, unsigned major,
  930. unsigned minor, bool hw_render_ctx,
  931. void **ctx_data);
  932. /**
  933. * video_context_driver_init_first:
  934. * @data : Input data.
  935. * @ident : Identifier of graphics context driver to find.
  936. * @api : API of higher-level graphics API.
  937. * @major : Major version number of higher-level graphics API.
  938. * @minor : Minor version number of higher-level graphics API.
  939. * @hw_render_ctx : Request a graphics context driver capable of
  940. * hardware rendering?
  941. *
  942. * Finds first suitable graphics context driver and initializes.
  943. *
  944. * Returns: graphics context driver if found, otherwise NULL.
  945. **/
  946. const gfx_ctx_driver_t *video_context_driver_init_first(
  947. void *data, const char *ident,
  948. enum gfx_ctx_api api, unsigned major, unsigned minor,
  949. bool hw_render_ctx, void **ctx_data);
  950. bool video_context_driver_set(const gfx_ctx_driver_t *data);
  951. bool video_context_driver_get_ident(gfx_ctx_ident_t *ident);
  952. bool video_context_driver_get_refresh_rate(float *refresh_rate);
  953. bool video_context_driver_set_flags(gfx_ctx_flags_t *flags);
  954. bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics);
  955. void video_context_driver_destroy(gfx_ctx_driver_t *ctx_driver);
  956. enum gfx_ctx_api video_context_driver_get_api(void);
  957. void video_context_driver_free(void);
  958. bool video_shader_driver_get_current_shader(video_shader_ctx_t *shader);
  959. float video_driver_get_refresh_rate(void);
  960. #if defined(HAVE_GFX_WIDGETS)
  961. bool video_driver_has_widgets(void);
  962. #endif
  963. bool video_driver_is_threaded(void);
  964. bool video_context_driver_get_flags(gfx_ctx_flags_t *flags);
  965. bool video_driver_test_all_flags(enum display_flags testflag);
  966. gfx_ctx_flags_t video_driver_get_flags_wrapper(void);
  967. void video_driver_set_gpu_device_string(const char *str);
  968. const char* video_driver_get_gpu_device_string(void);
  969. void video_driver_set_gpu_api_version_string(const char *str);
  970. const char* video_driver_get_gpu_api_version_string(void);
  971. void video_driver_force_fallback(const char *driver);
  972. /* string list stays owned by the caller and must be available at all times after the video driver is inited */
  973. void video_driver_set_gpu_api_devices(enum gfx_ctx_api api, struct string_list *list);
  974. struct string_list* video_driver_get_gpu_api_devices(enum gfx_ctx_api api);
  975. enum retro_hw_context_type hw_render_context_type(const char *s);
  976. const char *hw_render_context_name(
  977. enum retro_hw_context_type type, int major, int minor);
  978. video_driver_t *hw_render_context_driver(
  979. enum retro_hw_context_type type, int major, int minor);
  980. void video_driver_pixel_converter_free(
  981. video_pixel_scaler_t *scalr);
  982. video_pixel_scaler_t *video_driver_pixel_converter_init(
  983. const enum retro_pixel_format video_driver_pix_fmt,
  984. struct retro_hw_render_callback *hwr,
  985. unsigned size);
  986. void recording_dump_frame(
  987. const void *data, unsigned width,
  988. unsigned height, size_t pitch, bool is_idle);
  989. void video_driver_gpu_record_deinit(void);
  990. void video_driver_filter_init(enum retro_pixel_format colfmt_int,
  991. settings_t *settings);
  992. void video_context_driver_reset(void);
  993. void video_driver_free_internal(void);
  994. /**
  995. * video_driver_get_current_framebuffer:
  996. *
  997. * Gets pointer to current hardware renderer framebuffer object.
  998. * Used by RETRO_ENVIRONMENT_SET_HW_RENDER.
  999. *
  1000. * Returns: pointer to hardware framebuffer object, otherwise 0.
  1001. **/
  1002. uintptr_t video_driver_get_current_framebuffer(void);
  1003. retro_proc_address_t video_driver_get_proc_address(const char *sym);
  1004. void video_driver_free_hw_context(void);
  1005. #ifdef HAVE_VIDEO_FILTER
  1006. void video_driver_filter_free(void);
  1007. #endif
  1008. #ifdef HAVE_THREADS
  1009. /**
  1010. * video_thread_get_ptr:
  1011. *
  1012. * Gets the underlying video driver associated with the
  1013. * threaded video wrapper. Sets @drv to the found
  1014. * video driver.
  1015. *
  1016. * Returns: Video driver data of the video driver associated
  1017. * with the threaded wrapper (if successful). If not successful,
  1018. * NULL.
  1019. **/
  1020. void *video_thread_get_ptr(video_driver_state_t *video_st);
  1021. #endif
  1022. void video_driver_lock_new(void);
  1023. bool video_driver_find_driver(
  1024. void *settings_data,
  1025. const char *prefix, bool verbosity_enabled);
  1026. void video_driver_restore_cached(void *settings_data);
  1027. void video_driver_set_viewport_config(
  1028. struct retro_game_geometry *geom,
  1029. float video_aspect_ratio,
  1030. bool video_aspect_ratio_auto);
  1031. void video_driver_set_viewport_square_pixel(struct retro_game_geometry *geom);
  1032. uint32_t video_driver_get_st_flags(void);
  1033. bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled);
  1034. /**
  1035. * video_driver_frame:
  1036. * @data : pointer to data of the video frame.
  1037. * @width : width of the video frame.
  1038. * @height : height of the video frame.
  1039. * @pitch : pitch of the video frame.
  1040. *
  1041. * Video frame render callback function.
  1042. **/
  1043. void video_driver_frame(const void *data, unsigned width,
  1044. unsigned height, size_t pitch);
  1045. extern const video_driver_t *video_drivers[];
  1046. extern video_driver_t video_gl3;
  1047. extern video_driver_t video_gl2;
  1048. extern video_driver_t video_gl1;
  1049. extern video_driver_t video_vulkan;
  1050. extern video_driver_t video_metal;
  1051. extern video_driver_t video_psp1;
  1052. extern video_driver_t video_vita2d;
  1053. extern video_driver_t video_ps2;
  1054. extern video_driver_t video_ctr;
  1055. extern video_driver_t video_gcm;
  1056. extern video_driver_t video_switch;
  1057. extern video_driver_t video_d3d8;
  1058. extern video_driver_t video_d3d9_cg;
  1059. extern video_driver_t video_d3d9_hlsl;
  1060. extern video_driver_t video_d3d10;
  1061. extern video_driver_t video_d3d11;
  1062. extern video_driver_t video_d3d12;
  1063. extern video_driver_t video_gx;
  1064. extern video_driver_t video_wiiu;
  1065. extern video_driver_t video_xenon360;
  1066. extern video_driver_t video_xvideo;
  1067. extern video_driver_t video_sdl;
  1068. extern video_driver_t video_sdl2;
  1069. extern video_driver_t video_sdl_dingux;
  1070. extern video_driver_t video_sdl_rs90;
  1071. extern video_driver_t video_vg;
  1072. extern video_driver_t video_omap;
  1073. extern video_driver_t video_exynos;
  1074. extern video_driver_t video_dispmanx;
  1075. extern video_driver_t video_sunxi;
  1076. extern video_driver_t video_drm;
  1077. extern video_driver_t video_xshm;
  1078. extern video_driver_t video_caca;
  1079. extern video_driver_t video_gdi;
  1080. extern video_driver_t video_vga;
  1081. extern video_driver_t video_fpga;
  1082. extern video_driver_t video_sixel;
  1083. extern video_driver_t video_network;
  1084. extern video_driver_t video_oga;
  1085. extern video_driver_t video_null;
  1086. extern const gfx_ctx_driver_t gfx_ctx_osmesa;
  1087. extern const gfx_ctx_driver_t gfx_ctx_sdl_gl;
  1088. extern const gfx_ctx_driver_t gfx_ctx_x_egl;
  1089. extern const gfx_ctx_driver_t gfx_ctx_uwp;
  1090. extern const gfx_ctx_driver_t gfx_ctx_vk_wayland;
  1091. extern const gfx_ctx_driver_t gfx_ctx_wayland;
  1092. extern const gfx_ctx_driver_t gfx_ctx_x;
  1093. extern const gfx_ctx_driver_t gfx_ctx_vk_x;
  1094. extern const gfx_ctx_driver_t gfx_ctx_drm;
  1095. extern const gfx_ctx_driver_t gfx_ctx_go2_drm;
  1096. extern const gfx_ctx_driver_t gfx_ctx_mali_fbdev;
  1097. extern const gfx_ctx_driver_t gfx_ctx_vivante_fbdev;
  1098. extern const gfx_ctx_driver_t gfx_ctx_android;
  1099. extern const gfx_ctx_driver_t gfx_ctx_vk_android;
  1100. extern const gfx_ctx_driver_t gfx_ctx_ps3;
  1101. extern const gfx_ctx_driver_t gfx_ctx_w_vk;
  1102. extern const gfx_ctx_driver_t gfx_ctx_wgl;
  1103. extern const gfx_ctx_driver_t gfx_ctx_videocore;
  1104. extern const gfx_ctx_driver_t gfx_ctx_qnx;
  1105. extern const gfx_ctx_driver_t gfx_ctx_cgl;
  1106. extern const gfx_ctx_driver_t gfx_ctx_cocoagl;
  1107. extern const gfx_ctx_driver_t gfx_ctx_cocoavk;
  1108. extern const gfx_ctx_driver_t gfx_ctx_emscripten;
  1109. extern const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev;
  1110. extern const gfx_ctx_driver_t gfx_ctx_khr_display;
  1111. extern const gfx_ctx_driver_t gfx_ctx_gdi;
  1112. extern const gfx_ctx_driver_t gfx_ctx_fpga;
  1113. extern const gfx_ctx_driver_t gfx_ctx_sixel;
  1114. extern const gfx_ctx_driver_t gfx_ctx_network;
  1115. extern const gfx_ctx_driver_t switch_ctx;
  1116. extern const gfx_ctx_driver_t orbis_ctx;
  1117. extern const gfx_ctx_driver_t vita_ctx;
  1118. extern const gfx_ctx_driver_t gfx_ctx_null;
  1119. extern const shader_backend_t gl_glsl_backend;
  1120. extern const shader_backend_t gl_cg_backend;
  1121. RETRO_END_DECLS
  1122. #endif