1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 00:38:44 +00:00

[ORBIS] Initial video context driver

This commit is contained in:
Francisco José García García 2018-12-28 01:27:13 +01:00
parent 19549ddccf
commit 48167d46bc
6 changed files with 342 additions and 2 deletions

View File

@ -869,6 +869,11 @@ ifeq ($(TARGET), retroarch_switch)
frontend/drivers/platform_switch.o
endif
ifeq ($(TARGET), retroarch_orbis)
OBJ += gfx/drivers_context/orbis_ctx.o \
frontend/drivers/platform_orbis.o
endif
ifeq ($(HAVE_WAYLAND), 1)
OBJ += gfx/drivers_context/wayland_ctx.o \
input/drivers/wayland_input.o \

View File

@ -1,4 +1,4 @@
TARGET := retroarch_ps4
TARGET := retroarch_orbis
DEBUG ?= 0
GRIFFIN_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
@ -61,7 +61,7 @@ else
#OBJ += input/drivers/psp_input.o
#OBJ += input/drivers_joypad/psp_joypad.o
#OBJ += audio/drivers/psp_audio.o
OBJ += frontend/drivers/platform_orbis.o
#OBJ += frontend/drivers/platform_orbis.o
endif

29
gfx/common/orbis_common.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef ORBIS_COMMON_H__
#define ORBIS_COMMON_H__
#ifdef HAVE_EGL
#include <piglet.h>
#include "../common/egl_common.h"
#endif
#define ATTR_ORBISGL_WIDTH 1920
#define ATTR_ORBISGL_HEIGHT 1080
typedef struct
{
#ifdef HAVE_EGL
egl_ctx_data_t egl;
ScePglConfig pgl_config;
#endif
struct
{
unsigned short width;
unsigned short height;
} native_window;
bool resize;
unsigned width, height;
float refresh_rate;
} orbis_ctx_data_t;
#endif

View File

@ -0,0 +1,302 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2018 - M4xw
*
* 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 <stdlib.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include "../common/orbis_common.h"
#include "../../frontend/frontend_driver.h"
static enum gfx_ctx_api ctx_orbis_api = GFX_CTX_OPENGL_API;
orbis_ctx_data_t *nx_ctx_ptr = NULL;
extern bool platform_orbis_has_focus;
void orbis_ctx_destroy(void *data)
{
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
if (ctx_orbis)
{
#ifdef HAVE_EGL
egl_destroy(&ctx_orbis->egl);
#endif
ctx_orbis->resize = false;
free(ctx_orbis);
}
}
static void orbis_ctx_get_video_size(void *data,
unsigned *width, unsigned *height)
{
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
*width = ATTR_ORBISGL_WIDTH;
*height = ATTR_ORBISGL_HEIGHT;
}
static void *orbis_ctx_init(video_frame_info_t *video_info, void *video_driver)
{
#ifdef HAVE_EGL
int ret;
EGLint n;
EGLint major, minor;
static const EGLint attribs[] = {
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_NONE};
#endif
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)calloc(1, sizeof(*ctx_orbis));
if (!ctx_orbis)
return NULL;
nx_ctx_ptr = ctx_orbis;
#ifdef HAVE_EGL
memset(&ctx_orbis->pgl_config, 0, sizeof(ctx_orbis->pgl_config));
{
ctx_orbis->pgl_config.size=sizeof(ctx_orbis->pgl_config);
ctx_orbis->pgl_config.flags=SCE_PGL_FLAGS_USE_COMPOSITE_EXT | SCE_PGL_FLAGS_USE_FLEXIBLE_MEMORY | 0x60;
ctx_orbis->pgl_config.processOrder=1;
ctx_orbis->pgl_config.systemSharedMemorySize=0x200000;
ctx_orbis->pgl_config.videoSharedMemorySize=0x2400000;
ctx_orbis->pgl_config.maxMappedFlexibleMemory=0xAA00000;
ctx_orbis->pgl_config.drawCommandBufferSize=0xC0000;
ctx_orbis->pgl_config.lcueResourceBufferSize=0x10000;
ctx_orbis->pgl_config.dbgPosCmd_0x40=ATTR_ORBISGL_WIDTH;
ctx_orbis->pgl_config.dbgPosCmd_0x44=ATTR_ORBISGL_HEIGHT;
ctx_orbis->pgl_config.dbgPosCmd_0x48=0;
ctx_orbis->pgl_config.dbgPosCmd_0x4C=0;
ctx_orbis->pgl_config.unk_0x5C=2;
}
ret = scePigletSetConfigurationVSH(&ctx_orbis->pgl_config);
if (!ret)
{
printf("[ORBISGL] scePigletSetConfigurationVSH failed 0x%08X.\n",ret);
goto error;
}
if (!egl_init_context(&ctx_orbis->egl, EGL_NONE, EGL_DEFAULT_DISPLAY,
&major, &minor, &n, attribs, NULL))
{
egl_report_error();
printf("[ORBIS]: EGL error: %d.\n", eglGetError());
goto error;
}
#endif
return ctx_orbis;
error:
orbis_ctx_destroy(video_driver);
return NULL;
}
static void orbis_ctx_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height, bool is_shutdown)
{
unsigned new_width, new_height;
orbis_ctx_get_video_size(data, &new_width, &new_height);
if (new_width != *width || new_height != *height)
{
*width = new_width;
*height = new_height;
*resize = true;
}
*quit = (bool)false;
}
static bool orbis_ctx_set_video_mode(void *data,
video_frame_info_t *video_info,
unsigned width, unsigned height,
bool fullscreen)
{
/* Create an EGL rendering context */
static const EGLint contextAttributeList[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE};
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
ctx_orbis->width = ATTR_ORBISGL_HEIGHT;
ctx_orbis->height = ATTR_ORBISGL_WIDTH;
ctx_orbis->native_window.width = ctx_orbis->width;
ctx_orbis->native_window.height = ctx_orbis->height;
ctx_orbis->refresh_rate = 60;
#ifdef HAVE_EGL
if (!egl_create_context(&ctx_orbis->egl, contextAttributeList))
{
egl_report_error();
goto error;
}
#endif
#ifdef HAVE_EGL
if (!egl_create_surface(&ctx_orbis->egl, &ctx_orbis->native_window))
goto error;
#endif
return true;
error:
printf("[ctx_orbis]: EGL error: %d.\n", eglGetError());
orbis_ctx_destroy(data);
return false;
}
static void orbis_ctx_input_driver(void *data,
const char *name,
const input_driver_t **input, void **input_data)
{
*input = NULL;
*input_data = NULL;
}
static enum gfx_ctx_api orbis_ctx_get_api(void *data)
{
return ctx_orbis_api;
}
static bool orbis_ctx_bind_api(void *data,
enum gfx_ctx_api api, unsigned major, unsigned minor)
{
(void)data;
ctx_orbis_api = api;
if (api == GFX_CTX_OPENGL_API)
if (eglBindAPI(EGL_OPENGL_API) != EGL_FALSE)
return true;
return false;
}
static bool orbis_ctx_has_focus(void *data)
{
(void)data;
return true;
}
static bool orbis_ctx_suppress_screensaver(void *data, bool enable)
{
(void)data;
(void)enable;
return false;
}
static void orbis_ctx_set_swap_interval(void *data,
int swap_interval)
{
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
#ifdef HAVE_EGL
egl_set_swap_interval(&ctx_orbis->egl, swap_interval);
#endif
}
static void orbis_ctx_swap_buffers(void *data, void *data2)
{
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
#ifdef HAVE_EGL
egl_swap_buffers(&ctx_orbis->egl);
#endif
}
static gfx_ctx_proc_t orbis_ctx_get_proc_address(const char *symbol)
{
#ifdef HAVE_EGL
return egl_get_proc_address(symbol);
#endif
}
static void orbis_ctx_bind_hw_render(void *data, bool enable)
{
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
#ifdef HAVE_EGL
egl_bind_hw_render(&ctx_orbis->egl, enable);
#endif
}
static uint32_t orbis_ctx_get_flags(void *data)
{
uint32_t flags = 0;
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
return flags;
}
static void orbis_ctx_set_flags(void *data, uint32_t flags)
{
(void)data;
}
static float orbis_ctx_get_refresh_rate(void *data)
{
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
return ctx_orbis->refresh_rate;
}
const gfx_ctx_driver_t orbis_ctx = {
orbis_ctx_init,
orbis_ctx_destroy,
orbis_ctx_get_api,
orbis_ctx_bind_api,
orbis_ctx_set_swap_interval,
orbis_ctx_set_video_mode,
orbis_ctx_get_video_size,
orbis_ctx_get_refresh_rate,
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
NULL, /* update_title */
orbis_ctx_check_window,
NULL, /* set_resize */
orbis_ctx_has_focus,
orbis_ctx_suppress_screensaver,
NULL, /* has_windowed */
orbis_ctx_swap_buffers,
orbis_ctx_input_driver,
orbis_ctx_get_proc_address,
NULL,
NULL,
NULL,
"orbis",
orbis_ctx_get_flags,
orbis_ctx_set_flags,
orbis_ctx_bind_hw_render,
NULL,
NULL};

View File

@ -357,6 +357,9 @@ static const video_driver_t *video_drivers[] = {
};
static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
#if defined(ORBIS)
&orbis_ctx,
#endif
#if defined(HAVE_LIBNX) && defined(HAVE_OPENGL)
&switch_ctx,
#endif

View File

@ -1299,6 +1299,7 @@ extern const gfx_ctx_driver_t gfx_ctx_khr_display;
extern const gfx_ctx_driver_t gfx_ctx_gdi;
extern const gfx_ctx_driver_t gfx_ctx_sixel;
extern const gfx_ctx_driver_t switch_ctx;
extern const gfx_ctx_driver_t orbis_ctx;
extern const gfx_ctx_driver_t gfx_ctx_null;