2015-01-12 17:26:46 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <string/string_list.h>
|
|
|
|
#include "video_driver.h"
|
2015-01-12 19:20:58 +00:00
|
|
|
#include "video_thread_wrapper.h"
|
2015-01-12 17:28:32 +00:00
|
|
|
#include "../general.h"
|
2015-01-12 17:26:46 +00:00
|
|
|
|
|
|
|
static const video_driver_t *video_drivers[] = {
|
|
|
|
#ifdef HAVE_OPENGL
|
|
|
|
&video_gl,
|
|
|
|
#endif
|
|
|
|
#ifdef XENON
|
|
|
|
&video_xenon360,
|
|
|
|
#endif
|
|
|
|
#if defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) || defined(HAVE_WIN32_D3D9)
|
|
|
|
&video_d3d,
|
|
|
|
#endif
|
|
|
|
#ifdef SN_TARGET_PSP2
|
|
|
|
&video_vita,
|
|
|
|
#endif
|
|
|
|
#ifdef PSP
|
|
|
|
&video_psp1,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SDL
|
|
|
|
&video_sdl,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
&video_sdl2,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_XVIDEO
|
|
|
|
&video_xvideo,
|
|
|
|
#endif
|
|
|
|
#ifdef GEKKO
|
|
|
|
&video_gx,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VG
|
|
|
|
&video_vg,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_OMAP
|
|
|
|
&video_omap,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_EXYNOS
|
|
|
|
&video_exynos,
|
|
|
|
#endif
|
|
|
|
&video_null,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* video_driver_find_handle:
|
2015-01-15 20:10:36 +00:00
|
|
|
* @idx : index of driver to get handle to.
|
2015-01-12 17:26:46 +00:00
|
|
|
*
|
|
|
|
* Returns: handle to video driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
2015-01-15 20:10:36 +00:00
|
|
|
const void *video_driver_find_handle(int idx)
|
2015-01-12 17:26:46 +00:00
|
|
|
{
|
2015-01-15 20:10:36 +00:00
|
|
|
const void *drv = video_drivers[idx];
|
2015-01-12 17:26:46 +00:00
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* video_driver_find_ident:
|
2015-01-15 20:10:36 +00:00
|
|
|
* @idx : index of driver to get handle to.
|
2015-01-12 17:26:46 +00:00
|
|
|
*
|
|
|
|
* Returns: Human-readable identifier of video driver at index. Can be NULL
|
|
|
|
* if nothing found.
|
|
|
|
**/
|
2015-01-15 20:10:36 +00:00
|
|
|
const char *video_driver_find_ident(int idx)
|
2015-01-12 17:26:46 +00:00
|
|
|
{
|
2015-01-15 20:10:36 +00:00
|
|
|
const video_driver_t *drv = video_drivers[idx];
|
2015-01-12 17:26:46 +00:00
|
|
|
if (!drv)
|
|
|
|
return NULL;
|
|
|
|
return drv->ident;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* config_get_video_driver_options:
|
|
|
|
*
|
|
|
|
* Get an enumerated list of all video driver names, separated by '|'.
|
|
|
|
*
|
|
|
|
* Returns: string listing of all video driver names, separated by '|'.
|
|
|
|
**/
|
|
|
|
const char* config_get_video_driver_options(void)
|
|
|
|
{
|
|
|
|
union string_list_elem_attr attr;
|
|
|
|
unsigned i;
|
|
|
|
char *options = NULL;
|
|
|
|
int options_len = 0;
|
|
|
|
struct string_list *options_l = string_list_new();
|
|
|
|
|
|
|
|
attr.i = 0;
|
|
|
|
|
|
|
|
for (i = 0; video_driver_find_handle(i); i++)
|
|
|
|
{
|
|
|
|
const char *opt = video_driver_find_ident(i);
|
|
|
|
options_len += strlen(opt) + 1;
|
|
|
|
string_list_append(options_l, opt, attr);
|
|
|
|
}
|
|
|
|
|
|
|
|
options = (char*)calloc(options_len, sizeof(char));
|
|
|
|
|
|
|
|
string_list_join_concat(options, options_len, options_l, "|");
|
|
|
|
|
|
|
|
string_list_free(options_l);
|
|
|
|
options_l = NULL;
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
void find_video_driver(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
#if defined(HAVE_OPENGL) && defined(HAVE_FBO)
|
|
|
|
if (g_extern.system.hw_render_callback.context_type)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Using HW render, OpenGL driver forced.\n");
|
|
|
|
driver.video = &video_gl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (driver.frontend_ctx &&
|
|
|
|
driver.frontend_ctx->get_video_driver)
|
|
|
|
{
|
|
|
|
driver.video = driver.frontend_ctx->get_video_driver();
|
|
|
|
|
|
|
|
if (driver.video)
|
|
|
|
return;
|
|
|
|
RARCH_WARN("Frontend supports get_video_driver() but did not specify one.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
i = find_driver_index("video_driver", g_settings.video.driver);
|
|
|
|
if (i >= 0)
|
2015-01-12 21:47:12 +00:00
|
|
|
driver.video = (const video_driver_t*)video_driver_find_handle(i);
|
2015-01-12 17:26:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned d;
|
|
|
|
RARCH_ERR("Couldn't find any video driver named \"%s\"\n",
|
|
|
|
g_settings.video.driver);
|
|
|
|
RARCH_LOG_OUTPUT("Available video drivers are:\n");
|
|
|
|
for (d = 0; video_driver_find_handle(d); d++)
|
|
|
|
RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d));
|
|
|
|
RARCH_WARN("Going to default to first video driver...\n");
|
|
|
|
|
2015-01-12 21:47:12 +00:00
|
|
|
driver.video = (const video_driver_t*)video_driver_find_handle(0);
|
2015-01-12 17:26:46 +00:00
|
|
|
|
|
|
|
if (!driver.video)
|
|
|
|
rarch_fail(1, "find_video_driver()");
|
|
|
|
}
|
|
|
|
}
|
2015-01-12 19:20:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* driver_video_resolve:
|
|
|
|
* @drv : real video driver will be set to this.
|
|
|
|
*
|
|
|
|
* Use this if you need the real video driver
|
|
|
|
* and driver data pointers.
|
|
|
|
*
|
|
|
|
* Returns: video driver's userdata.
|
|
|
|
**/
|
|
|
|
void *driver_video_resolve(const video_driver_t **drv)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
if (g_settings.video.threaded
|
|
|
|
&& !g_extern.system.hw_render_callback.context_type)
|
|
|
|
return rarch_threaded_video_resolve(drv);
|
|
|
|
#endif
|
|
|
|
if (drv)
|
|
|
|
*drv = driver.video;
|
|
|
|
|
|
|
|
return driver.video_data;
|
|
|
|
}
|
2015-01-19 03:19:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* video_driver_get_current_framebuffer:
|
|
|
|
*
|
|
|
|
* Gets pointer to current hardware renderer framebuffer object.
|
|
|
|
* Used by RETRO_ENVIRONMENT_SET_HW_RENDER.
|
|
|
|
*
|
|
|
|
* Returns: pointer to hardware framebuffer object, otherwise 0.
|
|
|
|
**/
|
|
|
|
uintptr_t video_driver_get_current_framebuffer(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_FBO
|
|
|
|
if (driver.video_poke && driver.video_poke->get_current_framebuffer)
|
|
|
|
return driver.video_poke->get_current_framebuffer(driver.video_data);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
retro_proc_address_t video_driver_get_proc_address(const char *sym)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_FBO
|
|
|
|
if (driver.video_poke && driver.video_poke->get_proc_address)
|
|
|
|
return driver.video_poke->get_proc_address(driver.video_data, sym);
|
|
|
|
#endif
|
|
|
|
return NULL;
|
|
|
|
}
|