mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 18:50:29 +00:00
Cleanups
This commit is contained in:
parent
9214469470
commit
30ca42cb9d
@ -78,7 +78,7 @@ static void gfx_ctx_qnx_destroy(void *data)
|
||||
eglTerminate(g_egl_dpy);
|
||||
}
|
||||
|
||||
// Be as careful as possible in deinit.
|
||||
/* Be as careful as possible in deinit. */
|
||||
|
||||
g_egl_ctx = NULL;
|
||||
g_egl_hw_ctx = NULL;
|
||||
@ -332,7 +332,7 @@ static void gfx_ctx_qnx_check_window(void *data, bool *quit,
|
||||
*resize = true;
|
||||
}
|
||||
|
||||
// Check if we are exiting.
|
||||
/* Check if we are exiting. */
|
||||
if (g_extern.system.shutdown)
|
||||
*quit = true;
|
||||
}
|
||||
@ -367,7 +367,8 @@ static bool gfx_ctx_qnx_set_video_mode(void *data,
|
||||
}
|
||||
|
||||
|
||||
static void gfx_ctx_qnx_input_driver(void *data, const input_driver_t **input, void **input_data)
|
||||
static void gfx_ctx_qnx_input_driver(void *data,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
(void)data;
|
||||
*input = NULL;
|
||||
@ -385,7 +386,8 @@ static gfx_ctx_proc_t gfx_ctx_qnx_get_proc_address(const char *symbol)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool gfx_ctx_qnx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
static bool gfx_ctx_qnx_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
(void)data;
|
||||
(void)major;
|
||||
@ -411,7 +413,8 @@ static void gfx_qnx_ctx_bind_hw_render(void *data, bool enable)
|
||||
(void)data;
|
||||
g_use_hw_ctx = enable;
|
||||
if (g_egl_dpy && g_egl_surf)
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx);
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf,
|
||||
g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx);
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_bbqnx = {
|
||||
|
@ -128,7 +128,8 @@ static void gfx_ctx_d3d_update_title(void *data)
|
||||
char mem[128];
|
||||
MEMORYSTATUS stat;
|
||||
GlobalMemoryStatus(&stat);
|
||||
snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
|
||||
snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB",
|
||||
stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
|
||||
strlcat(buffer_fps, mem, sizeof(buffer_fps));
|
||||
#endif
|
||||
msg_queue_push(g_extern.msg_queue, buffer_fps, 1, 1);
|
||||
@ -160,29 +161,35 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS
|
||||
#else
|
||||
d3dpp->Windowed = g_settings.video.windowed_fullscreen || !info->fullscreen;
|
||||
#endif
|
||||
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
if (info->vsync)
|
||||
{
|
||||
switch (g_settings.video.swap_interval)
|
||||
{
|
||||
default:
|
||||
case 1: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; break;
|
||||
case 2: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; break;
|
||||
case 3: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; break;
|
||||
case 4: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; break;
|
||||
case 1:
|
||||
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
break;
|
||||
case 2:
|
||||
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO;
|
||||
break;
|
||||
case 3:
|
||||
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE;
|
||||
break;
|
||||
case 4:
|
||||
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
}
|
||||
|
||||
d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp->BackBufferCount = 2;
|
||||
#ifdef _XBOX
|
||||
d3dpp->BackBufferFormat =
|
||||
#ifdef _XBOX360
|
||||
g_extern.console.screen.gamma_correction ? (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) :
|
||||
g_extern.console.screen.gamma_correction ?
|
||||
(D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) :
|
||||
#endif
|
||||
info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5;
|
||||
#else
|
||||
@ -303,7 +310,8 @@ static bool gfx_ctx_d3d_has_windowed(void *data)
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool gfx_ctx_d3d_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
static bool gfx_ctx_d3d_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
(void)data;
|
||||
(void)major;
|
||||
@ -311,7 +319,8 @@ static bool gfx_ctx_d3d_bind_api(void *data, enum gfx_ctx_api api, unsigned majo
|
||||
(void)api;
|
||||
#if defined(_XBOX1)
|
||||
return api == GFX_CTX_DIRECT3D8_API;
|
||||
#else /* As long as we don't have a D3D11 implementation, we default to this */
|
||||
#else
|
||||
/* As long as we don't have a D3D11 implementation, we default to this */
|
||||
return api == GFX_CTX_DIRECT3D9_API;
|
||||
#endif
|
||||
}
|
||||
@ -328,7 +337,8 @@ static void gfx_ctx_d3d_destroy(void *data)
|
||||
(void)data;
|
||||
}
|
||||
|
||||
static void gfx_ctx_d3d_input_driver(void *data, const input_driver_t **input, void **input_data)
|
||||
static void gfx_ctx_d3d_input_driver(void *data,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
(void)data;
|
||||
#ifdef _XBOX
|
||||
@ -342,7 +352,8 @@ static void gfx_ctx_d3d_input_driver(void *data, const input_driver_t **input, v
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gfx_ctx_d3d_get_video_size(void *data, unsigned *width, unsigned *height)
|
||||
static void gfx_ctx_d3d_get_video_size(void *data,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
||||
#ifdef _XBOX
|
||||
@ -438,12 +449,11 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
#ifdef _XBOX
|
||||
LPDIRECT3DDEVICE d3dr = d3d->dev;
|
||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||
unsigned d3d_interval = interval ?
|
||||
D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
if (interval)
|
||||
d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, D3DPRESENT_INTERVAL_ONE);
|
||||
else
|
||||
d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, D3DPRESENT_INTERVAL_IMMEDIATE);
|
||||
d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, d3d_interval);
|
||||
#else
|
||||
d3d_restore(d3d);
|
||||
#endif
|
||||
|
@ -637,6 +637,14 @@ static EGLint *egl_fill_attribs(EGLint *attr)
|
||||
return attr;
|
||||
}
|
||||
|
||||
#define DRM_EGL_ATTRIBS_BASE \
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \
|
||||
EGL_RED_SIZE, 1, \
|
||||
EGL_GREEN_SIZE, 1, \
|
||||
EGL_BLUE_SIZE, 1, \
|
||||
EGL_ALPHA_SIZE, 0, \
|
||||
EGL_DEPTH_SIZE, 0
|
||||
|
||||
static bool gfx_ctx_drm_egl_set_video_mode(void *data,
|
||||
unsigned width, unsigned height,
|
||||
bool fullscreen)
|
||||
@ -644,7 +652,8 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data,
|
||||
int i, ret = 0;
|
||||
struct sigaction sa = {{0}};
|
||||
struct drm_fb *fb = NULL;
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)driver.video_context_data;
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)
|
||||
driver.video_context_data;
|
||||
|
||||
if (!drm)
|
||||
return false;
|
||||
@ -655,36 +664,29 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data,
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
|
||||
#define EGL_ATTRIBS_BASE \
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \
|
||||
EGL_RED_SIZE, 1, \
|
||||
EGL_GREEN_SIZE, 1, \
|
||||
EGL_BLUE_SIZE, 1, \
|
||||
EGL_ALPHA_SIZE, 0, \
|
||||
EGL_DEPTH_SIZE, 0
|
||||
|
||||
static const EGLint egl_attribs_gl[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
DRM_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
static const EGLint egl_attribs_gles[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
DRM_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
#ifdef EGL_KHR_create_context
|
||||
static const EGLint egl_attribs_gles3[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
DRM_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
|
||||
EGL_NONE,
|
||||
};
|
||||
#endif
|
||||
|
||||
static const EGLint egl_attribs_vg[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
DRM_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
@ -836,7 +838,8 @@ error:
|
||||
|
||||
static void gfx_ctx_drm_egl_destroy(void *data)
|
||||
{
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)driver.video_context_data;
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)
|
||||
driver.video_context_data;
|
||||
|
||||
if (!drm)
|
||||
return;
|
||||
@ -860,7 +863,8 @@ static void gfx_ctx_drm_egl_input_driver(void *data,
|
||||
|
||||
static bool gfx_ctx_drm_egl_has_focus(void *data)
|
||||
{
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)driver.video_context_data;
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)
|
||||
driver.video_context_data;
|
||||
(void)data;
|
||||
|
||||
if (drm)
|
||||
@ -909,7 +913,8 @@ static bool gfx_ctx_drm_egl_bind_api(void *data,
|
||||
|
||||
static void gfx_ctx_drm_egl_bind_hw_render(void *data, bool enable)
|
||||
{
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)driver.video_context_data;
|
||||
gfx_ctx_drm_egl_data_t *drm = (gfx_ctx_drm_egl_data_t*)
|
||||
driver.video_context_data;
|
||||
|
||||
if (!drm)
|
||||
return;
|
||||
@ -919,7 +924,8 @@ static void gfx_ctx_drm_egl_bind_hw_render(void *data, bool enable)
|
||||
drm->g_use_hw_ctx = enable;
|
||||
if (drm->g_egl_dpy && drm->g_egl_surf)
|
||||
eglMakeCurrent(drm->g_egl_dpy, drm->g_egl_surf,
|
||||
drm->g_egl_surf, enable ? drm->g_egl_hw_ctx : drm->g_egl_ctx);
|
||||
drm->g_egl_surf,
|
||||
enable ? drm->g_egl_hw_ctx : drm->g_egl_ctx);
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_drm_egl = {
|
||||
|
@ -14,8 +14,6 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// VideoCore context, for Rasperry Pi.
|
||||
|
||||
#include "../../driver.h"
|
||||
#include "../gfx_context.h"
|
||||
#include "../gl_common.h"
|
||||
@ -136,30 +134,30 @@ static bool gfx_ctx_emscripten_init(void *data)
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
// get an EGL display connection
|
||||
/* Get an EGL display connection. */
|
||||
g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (!g_egl_dpy)
|
||||
goto error;
|
||||
|
||||
// initialize the EGL display connection
|
||||
/* Initialize the EGL display connection. */
|
||||
if (!eglInitialize(g_egl_dpy, NULL, NULL))
|
||||
goto error;
|
||||
|
||||
// get an appropriate EGL frame buffer configuration
|
||||
/* Get an appropriate EGL frame buffer configuration. */
|
||||
if (!eglChooseConfig(g_egl_dpy, attribute_list, &g_config, 1, &num_config))
|
||||
goto error;
|
||||
|
||||
// create an EGL rendering context
|
||||
/* Create an EGL rendering context. */
|
||||
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, context_attributes);
|
||||
if (!g_egl_ctx)
|
||||
goto error;
|
||||
|
||||
// create an EGL window surface
|
||||
/* create an EGL window surface. */
|
||||
g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, 0, NULL);
|
||||
if (!g_egl_surf)
|
||||
goto error;
|
||||
|
||||
// connect the context to the surface
|
||||
/* Connect the context to the surface. */
|
||||
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
|
||||
goto error;
|
||||
|
||||
@ -208,7 +206,8 @@ static void gfx_ctx_emscripten_destroy(void *data)
|
||||
(void)data;
|
||||
if (g_egl_dpy)
|
||||
{
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
if (g_egl_ctx)
|
||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
||||
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// VideoCore context, for Rasperry Pi.
|
||||
/* VideoCore context, for Rasperry Pi. */
|
||||
|
||||
#include "../../driver.h"
|
||||
#include "../gfx_context.h"
|
||||
@ -81,9 +81,13 @@ static void sighandler(int sig)
|
||||
static void gfx_ctx_vc_swap_interval(void *data, unsigned interval)
|
||||
{
|
||||
(void)data;
|
||||
// Can be called before initialization.
|
||||
// Some contexts require that swap interval is known at startup time.
|
||||
|
||||
/* Can be called before initialization.
|
||||
* Some contexts require that swap interval
|
||||
* is known at startup time.
|
||||
*/
|
||||
g_interval = interval;
|
||||
|
||||
if (g_egl_dpy)
|
||||
eglSwapInterval(g_egl_dpy, interval);
|
||||
}
|
||||
@ -171,20 +175,20 @@ static bool gfx_ctx_vc_init(void *data)
|
||||
|
||||
bcm_host_init();
|
||||
|
||||
// get an EGL display connection
|
||||
/* Get an EGL display connection. */
|
||||
g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (!g_egl_dpy)
|
||||
goto error;
|
||||
|
||||
// initialize the EGL display connection
|
||||
/* Initialize the EGL display connection. */
|
||||
if (!eglInitialize(g_egl_dpy, NULL, NULL))
|
||||
goto error;
|
||||
|
||||
// get an appropriate EGL frame buffer configuration
|
||||
/* Get an appropriate EGL frame buffer configuration. */
|
||||
if (!eglChooseConfig(g_egl_dpy, attribute_list, &g_config, 1, &num_config))
|
||||
goto error;
|
||||
|
||||
// create an EGL rendering context
|
||||
/* Create an EGL rendering context. */
|
||||
g_egl_ctx = eglCreateContext(
|
||||
g_egl_dpy, g_config, EGL_NO_CONTEXT,
|
||||
(g_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL);
|
||||
@ -201,7 +205,7 @@ static bool gfx_ctx_vc_init(void *data)
|
||||
goto error;
|
||||
}
|
||||
|
||||
// create an EGL window surface
|
||||
/* Create an EGL window surface. */
|
||||
if (graphics_get_display_size(0 /* LCD */, &g_fb_width, &g_fb_height) < 0)
|
||||
goto error;
|
||||
|
||||
@ -237,7 +241,7 @@ static bool gfx_ctx_vc_init(void *data)
|
||||
if (!g_egl_surf)
|
||||
goto error;
|
||||
|
||||
// connect the context to the surface
|
||||
/* Connect the context to the surface. */
|
||||
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
|
||||
goto error;
|
||||
|
||||
@ -299,14 +303,16 @@ static void gfx_ctx_vc_destroy(void *data)
|
||||
if (eglBuffer[i] && peglDestroyImageKHR)
|
||||
{
|
||||
eglBindAPI(EGL_OPENVG_API);
|
||||
eglMakeCurrent(g_egl_dpy, g_pbuff_surf, g_pbuff_surf, g_eglimage_ctx);
|
||||
eglMakeCurrent(g_egl_dpy,
|
||||
g_pbuff_surf, g_pbuff_surf, g_eglimage_ctx);
|
||||
peglDestroyImageKHR(g_egl_dpy, eglBuffer[i]);
|
||||
}
|
||||
|
||||
if (g_egl_vgimage[i])
|
||||
{
|
||||
eglBindAPI(EGL_OPENVG_API);
|
||||
eglMakeCurrent(g_egl_dpy, g_pbuff_surf, g_pbuff_surf, g_eglimage_ctx);
|
||||
eglMakeCurrent(g_egl_dpy,
|
||||
g_pbuff_surf, g_pbuff_surf, g_eglimage_ctx);
|
||||
vgDestroyImage(g_egl_vgimage[i]);
|
||||
}
|
||||
}
|
||||
@ -314,7 +320,8 @@ static void gfx_ctx_vc_destroy(void *data)
|
||||
if (g_egl_ctx)
|
||||
{
|
||||
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglMakeCurrent(g_egl_dpy,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
||||
}
|
||||
|
||||
@ -324,7 +331,8 @@ static void gfx_ctx_vc_destroy(void *data)
|
||||
if (g_eglimage_ctx)
|
||||
{
|
||||
eglBindAPI(EGL_OPENVG_API);
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglMakeCurrent(g_egl_dpy,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroyContext(g_egl_dpy, g_eglimage_ctx);
|
||||
}
|
||||
|
||||
@ -341,9 +349,11 @@ static void gfx_ctx_vc_destroy(void *data)
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENVG_API);
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglMakeCurrent(g_egl_dpy,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
gfx_ctx_vc_bind_api(data, g_api, 0, 0);
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglMakeCurrent(g_egl_dpy,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglTerminate(g_egl_dpy);
|
||||
}
|
||||
|
||||
@ -392,7 +402,8 @@ static float gfx_ctx_vc_translate_aspect(void *data,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
(void)data;
|
||||
// check for SD televisions: they should always be 4:3.
|
||||
|
||||
/* Check for SD televisions: they should always be 4:3. */
|
||||
if ((width == 640 || width == 720) && (height == 480 || height == 576))
|
||||
return 4.0f / 3.0f;
|
||||
else
|
||||
@ -441,7 +452,7 @@ static bool gfx_ctx_vc_init_egl_image_buffer(void *data,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// test to make sure we can switch context
|
||||
/* Test to make sure we can switch context. */
|
||||
result = eglMakeCurrent(g_egl_dpy, g_pbuff_surf, g_pbuff_surf, g_eglimage_ctx);
|
||||
if (result == EGL_FALSE)
|
||||
{
|
||||
|
@ -102,8 +102,10 @@ static bool gfx_ctx_vivante_init(void *data)
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
|
||||
static const EGLint attribs[] = {
|
||||
//EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
//EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
#if 0
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
#endif
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 6,
|
||||
EGL_RED_SIZE, 5,
|
||||
@ -129,7 +131,8 @@ static bool gfx_ctx_vivante_init(void *data)
|
||||
goto error;
|
||||
}
|
||||
|
||||
RARCH_LOG("[Vivante fbdev]: EGL version: %d.%d\n", egl_version_major, egl_version_minor);
|
||||
RARCH_LOG("[Vivante fbdev]: EGL version: %d.%d\n",
|
||||
egl_version_major, egl_version_minor);
|
||||
|
||||
|
||||
if (!eglChooseConfig(g_egl_dpy, attribs, &g_config, 1, &num_config))
|
||||
@ -192,7 +195,7 @@ static bool gfx_ctx_vivante_set_video_mode(void *data,
|
||||
unsigned width, unsigned height,
|
||||
bool fullscreen)
|
||||
{
|
||||
// Pick some arbitrary default.
|
||||
/* Pick some arbitrary default. */
|
||||
if (!width || !fullscreen)
|
||||
width = 1280;
|
||||
if (!height || !fullscreen)
|
||||
@ -202,7 +205,7 @@ static bool gfx_ctx_vivante_set_video_mode(void *data,
|
||||
g_height = height;
|
||||
|
||||
static const EGLint attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2, // Use version 2, even for GLES3.
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2, /* Use version 2, even for GLES3. */
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,7 @@ static void sighandler(int sig)
|
||||
g_quit = 1;
|
||||
}
|
||||
|
||||
// Shell surface callbacks
|
||||
/* Shell surface callbacks. */
|
||||
static void shell_surface_handle_ping(void *data,
|
||||
struct wl_shell_surface *shell_surface,
|
||||
uint32_t serial)
|
||||
@ -108,7 +108,7 @@ static const struct wl_shell_surface_listener shell_surface_listener = {
|
||||
shell_surface_handle_popup_done,
|
||||
};
|
||||
|
||||
// Registry callbacks
|
||||
/* Registry callbacks. */
|
||||
static void registry_handle_global(void *data, struct wl_registry *reg,
|
||||
uint32_t id, const char *interface, uint32_t version)
|
||||
{
|
||||
@ -352,7 +352,7 @@ static void gfx_ctx_wl_get_video_size(void *data,
|
||||
#define DEFAULT_WINDOWED_WIDTH 640
|
||||
#define DEFAULT_WINDOWED_HEIGHT 480
|
||||
|
||||
#define EGL_ATTRIBS_BASE \
|
||||
#define WL_EGL_ATTRIBS_BASE \
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \
|
||||
EGL_RED_SIZE, 1, \
|
||||
EGL_GREEN_SIZE, 1, \
|
||||
@ -365,27 +365,27 @@ static bool gfx_ctx_wl_init(void *data)
|
||||
(void)data;
|
||||
|
||||
static const EGLint egl_attribs_gl[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
WL_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
static const EGLint egl_attribs_gles[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
WL_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
#ifdef EGL_KHR_create_context
|
||||
static const EGLint egl_attribs_gles3[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
WL_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
|
||||
EGL_NONE,
|
||||
};
|
||||
#endif
|
||||
|
||||
static const EGLint egl_attribs_vg[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
WL_EGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
@ -114,7 +114,9 @@ static void create_gl_context(HWND hwnd)
|
||||
if (!g_hrc)
|
||||
{
|
||||
g_hrc = wglCreateContext(g_hdc);
|
||||
if (g_hrc && !core_context && !debug) // We'll create shared context later if not.
|
||||
|
||||
/* We'll create shared context later if not. */
|
||||
if (g_hrc && !core_context && !debug)
|
||||
{
|
||||
g_hw_hrc = wglCreateContext(g_hdc);
|
||||
if (g_hw_hrc)
|
||||
@ -160,8 +162,10 @@ static void create_gl_context(HWND hwnd)
|
||||
*aptr++ = WGL_CONTEXT_MINOR_VERSION_ARB;
|
||||
*aptr++ = g_minor;
|
||||
|
||||
// Technically, we don't have core/compat until 3.2.
|
||||
// Version 3.1 is either compat or not depending on GL_ARB_compatibility.
|
||||
/* Technically, we don't have core/compat until 3.2.
|
||||
* Version 3.1 is either compat or not depending
|
||||
* on GL_ARB_compatibility.
|
||||
*/
|
||||
if ((g_major * 1000 + g_minor) >= 3002)
|
||||
{
|
||||
*aptr++ = WGL_CONTEXT_PROFILE_MASK_ARB;
|
||||
@ -178,7 +182,8 @@ static void create_gl_context(HWND hwnd)
|
||||
*aptr = 0;
|
||||
|
||||
if (!pcreate_context)
|
||||
pcreate_context = (wglCreateContextAttribsProc)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
pcreate_context = (wglCreateContextAttribsProc)
|
||||
wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
|
||||
if (pcreate_context)
|
||||
{
|
||||
@ -352,7 +357,8 @@ static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *he
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||
static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor,
|
||||
HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||
{
|
||||
g_all_hms[g_num_mons++] = hMonitor;
|
||||
return TRUE;
|
||||
@ -378,7 +384,8 @@ static bool gfx_ctx_wgl_init(void *data)
|
||||
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wndclass.lpszClassName = "RetroArch";
|
||||
wndclass.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON));
|
||||
wndclass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
|
||||
wndclass.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
|
||||
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
|
||||
|
||||
if (!RegisterClassEx(&wndclass))
|
||||
return false;
|
||||
|
@ -179,6 +179,7 @@ bool x11_enter_fullscreen(Display *dpy, unsigned width,
|
||||
unsigned height, XF86VidModeModeInfo *desktop_mode)
|
||||
{
|
||||
XF86VidModeModeInfo mode;
|
||||
|
||||
if (get_video_mode(dpy, width, height, &mode, desktop_mode))
|
||||
{
|
||||
if (XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &mode))
|
||||
@ -186,10 +187,8 @@ bool x11_enter_fullscreen(Display *dpy, unsigned width,
|
||||
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), 0, 0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,9 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// X/EGL context. Mostly used for testing GLES code paths.
|
||||
// Should be its own file as it has lots of X11 stuff baked into it as well.
|
||||
/* X/EGL context. Mostly used for testing GLES code paths.
|
||||
* Should be its own file as it has lots of X11 stuff baked into it as well.
|
||||
*/
|
||||
|
||||
#include "../../driver.h"
|
||||
#include "../gfx_context.h"
|
||||
@ -150,7 +151,7 @@ static void gfx_ctx_xegl_check_window(void *data, bool *quit,
|
||||
XEvent event;
|
||||
while (XPending(g_dpy))
|
||||
{
|
||||
// Can get events from older windows. Check this.
|
||||
/* Can get events from older windows. Check this. */
|
||||
XNextEvent(g_dpy, &event);
|
||||
bool filter = XFilterEvent(&event, g_win);
|
||||
|
||||
@ -244,14 +245,7 @@ static void gfx_ctx_xegl_get_video_size(void *data,
|
||||
}
|
||||
}
|
||||
|
||||
static bool gfx_ctx_xegl_init(void *data)
|
||||
{
|
||||
if (g_inited)
|
||||
return false;
|
||||
|
||||
XInitThreads();
|
||||
|
||||
#define EGL_ATTRIBS_BASE \
|
||||
#define XEGL_ATTRIBS_BASE \
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \
|
||||
EGL_RED_SIZE, 1, \
|
||||
EGL_GREEN_SIZE, 1, \
|
||||
@ -259,28 +253,35 @@ static bool gfx_ctx_xegl_init(void *data)
|
||||
EGL_ALPHA_SIZE, 0, \
|
||||
EGL_DEPTH_SIZE, 0
|
||||
|
||||
static bool gfx_ctx_xegl_init(void *data)
|
||||
{
|
||||
if (g_inited)
|
||||
return false;
|
||||
|
||||
XInitThreads();
|
||||
|
||||
static const EGLint egl_attribs_gl[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
XEGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
static const EGLint egl_attribs_gles[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
XEGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
#ifdef EGL_KHR_create_context
|
||||
static const EGLint egl_attribs_gles3[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
XEGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
|
||||
EGL_NONE,
|
||||
};
|
||||
#endif
|
||||
|
||||
static const EGLint egl_attribs_vg[] = {
|
||||
EGL_ATTRIBS_BASE,
|
||||
XEGL_ATTRIBS_BASE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE,
|
||||
};
|
||||
@ -308,8 +309,8 @@ static bool gfx_ctx_xegl_init(void *data)
|
||||
|
||||
g_quit = 0;
|
||||
|
||||
// Keep one g_dpy alive the entire process lifetime.
|
||||
// This is necessary for nVidia's EGL implementation for now.
|
||||
/* Keep one g_dpy alive the entire process lifetime.
|
||||
* This is necessary for nVidia's EGL implementation for now. */
|
||||
if (!g_dpy)
|
||||
{
|
||||
g_dpy = XOpenDisplay(NULL);
|
||||
@ -376,8 +377,11 @@ static EGLint *egl_fill_attribs(EGLint *attr)
|
||||
*attr++ = g_major;
|
||||
*attr++ = EGL_CONTEXT_MINOR_VERSION_KHR;
|
||||
*attr++ = g_minor;
|
||||
// Technically, we don't have core/compat until 3.2.
|
||||
// Version 3.1 is either compat or not depending on GL_ARB_compatibility.
|
||||
|
||||
/* Technically, we don't have core/compat until 3.2.
|
||||
* Version 3.1 is either compat or not depending
|
||||
* on GL_ARB_compatibility.
|
||||
*/
|
||||
if (version >= 3002)
|
||||
{
|
||||
*attr++ = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
||||
@ -396,7 +400,8 @@ static EGLint *egl_fill_attribs(EGLint *attr)
|
||||
#endif
|
||||
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
*attr++ = EGL_CONTEXT_CLIENT_VERSION; // Same as EGL_CONTEXT_MAJOR_VERSION
|
||||
/* Same as EGL_CONTEXT_MAJOR_VERSION. */
|
||||
*attr++ = EGL_CONTEXT_CLIENT_VERSION;
|
||||
*attr++ = g_major ? (EGLint)g_major : 2;
|
||||
#ifdef EGL_KHR_create_context
|
||||
if (g_minor > 0)
|
||||
@ -534,21 +539,30 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
|
||||
RARCH_LOG("[X/EGL]: Using true fullscreen.\n");
|
||||
XMapRaised(g_dpy, g_win);
|
||||
}
|
||||
else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen.
|
||||
else if (fullscreen)
|
||||
{
|
||||
/* We attempted true fullscreen, but failed.
|
||||
* Attempt using windowed fullscreen. */
|
||||
XMapRaised(g_dpy, g_win);
|
||||
RARCH_LOG("[X/EGL]: Using windowed fullscreen.\n");
|
||||
// We have to move the window to the screen we want to go fullscreen on first.
|
||||
// x_off and y_off usually get ignored in XCreateWindow().
|
||||
|
||||
/* We have to move the window to the screen we
|
||||
* want to go fullscreen on first.
|
||||
* x_off and y_off usually get ignored in XCreateWindow().
|
||||
*/
|
||||
x11_move_window(g_dpy, g_win, x_off, y_off, width, height);
|
||||
x11_windowed_fullscreen(g_dpy, g_win);
|
||||
}
|
||||
else
|
||||
{
|
||||
XMapWindow(g_dpy, g_win);
|
||||
// If we want to map the window on a different screen, we'll have to do it by force.
|
||||
// Otherwise, we should try to let the window manager sort it out.
|
||||
// x_off and y_off usually get ignored in XCreateWindow().
|
||||
|
||||
/* If we want to map the window on a different screen,
|
||||
* we'll have to do it by force.
|
||||
*
|
||||
* Otherwise, we should try to let the window manager sort it out.
|
||||
* x_off and y_off usually get ignored in XCreateWindow().
|
||||
*/
|
||||
if (g_screen)
|
||||
x11_move_window(g_dpy, g_win, x_off, y_off, width, height);
|
||||
}
|
||||
@ -562,7 +576,9 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
|
||||
|
||||
gfx_ctx_xegl_swap_interval(data, g_interval);
|
||||
|
||||
// This can blow up on some drivers. It's not fatal, so override errors for this call.
|
||||
/* This can blow up on some drivers. It's not fatal,
|
||||
* so override errors for this call.
|
||||
*/
|
||||
old_handler = XSetErrorHandler(nul_handler);
|
||||
XSetInputFocus(g_dpy, g_win, RevertToNone, CurrentTime);
|
||||
XSync(g_dpy, False);
|
||||
@ -598,7 +614,8 @@ static void gfx_ctx_xegl_destroy(void *data)
|
||||
{
|
||||
if (g_egl_ctx)
|
||||
{
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglDestroyContext(g_egl_dpy, g_egl_ctx);
|
||||
}
|
||||
|
||||
@ -618,7 +635,7 @@ static void gfx_ctx_xegl_destroy(void *data)
|
||||
|
||||
if (g_win)
|
||||
{
|
||||
// Save last used monitor for later.
|
||||
/* Save last used monitor for later. */
|
||||
#ifdef HAVE_XINERAMA
|
||||
XWindowAttributes target;
|
||||
Window child;
|
||||
@ -651,7 +668,9 @@ static void gfx_ctx_xegl_destroy(void *data)
|
||||
g_should_reset_mode = false;
|
||||
}
|
||||
|
||||
// Do not close g_dpy. We'll keep one for the entire application lifecycle to work-around nVidia EGL limitations.
|
||||
/* Do not close g_dpy. We'll keep one for the entire application
|
||||
* lifecycle to work-around nVidia EGL limitations.
|
||||
*/
|
||||
g_inited = false;
|
||||
}
|
||||
|
||||
@ -729,7 +748,8 @@ static void gfx_ctx_xegl_bind_hw_render(void *data, bool enable)
|
||||
(void)data;
|
||||
g_use_hw_ctx = enable;
|
||||
if (g_egl_dpy && g_egl_surf)
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx);
|
||||
eglMakeCurrent(g_egl_dpy, g_egl_surf,
|
||||
g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx);
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_x_egl = {
|
||||
|
Loading…
Reference in New Issue
Block a user