mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-26 04:36:56 +00:00
[VITA] Add vita video driver context.
This commit is contained in:
parent
6b7673f806
commit
f3ca57e6f0
@ -1160,6 +1160,7 @@ ifeq ($(HAVE_VITAGL), 1)
|
||||
DEFINES += -DHAVE_OPENGL1
|
||||
OBJ += gfx/drivers/gl1.o \
|
||||
gfx/drivers_font/gl1_raster_font.o \
|
||||
gfx/drivers_context/vita_ctx.o \
|
||||
menu/drivers_display/menu_display_gl1.o
|
||||
endif
|
||||
|
||||
|
@ -595,7 +595,7 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
|
||||
frame = frame_rgba;
|
||||
}
|
||||
}
|
||||
RARCH_LOG("draw_tex\n");
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, pot_width, pot_height, 0, format, type, frame);
|
||||
if (frame_rgba)
|
||||
free(frame_rgba);
|
||||
@ -622,21 +622,6 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
/* stock coord set does not handle POT, disable for now */
|
||||
/*glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glColorPointer(4, GL_FLOAT, 0, gl1->coords.color);
|
||||
glVertexPointer(2, GL_FLOAT, 0, gl1->coords.vertex);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, gl1->coords.tex_coord);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, gl1->coords.vertices);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);*/
|
||||
|
||||
if (gl1->rotation && tex == gl1->tex)
|
||||
glRotatef(gl1->rotation, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
@ -660,8 +645,8 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
|
||||
float texcoords[] = {
|
||||
0.0f, norm_height,
|
||||
0.0f, 0.0f,
|
||||
norm_width, 1.0f,
|
||||
norm_width, norm_height
|
||||
norm_width, 1.0f,
|
||||
norm_width, norm_height
|
||||
};
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
@ -922,10 +907,7 @@ static bool gl1_gfx_frame(void *data, const void *frame,
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glFinish();
|
||||
}
|
||||
#ifdef VITA
|
||||
vglStopRendering();
|
||||
vglStartRendering();
|
||||
#endif
|
||||
|
||||
gl1_context_bind_hw_render(gl1, true);
|
||||
|
||||
return true;
|
||||
@ -1270,7 +1252,7 @@ static void gl1_load_texture_data(
|
||||
#ifndef VITA
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
||||
#endif
|
||||
RARCH_LOG("gl1_load_texture_data\n");
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL1_INTERNAL_FORMAT32,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2018 - M4xw
|
||||
* Copyright (C) 2011-2017 - 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-
|
||||
@ -14,308 +14,158 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
/* Vita context. */
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include "../../retroarch.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#include "../common/orbis_common.h"
|
||||
#include "../../frontend/frontend_driver.h"
|
||||
#include "../../configuration.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)
|
||||
static void vita_swap_interval(void *data, int interval)
|
||||
{
|
||||
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);
|
||||
}
|
||||
(void)data;
|
||||
(void)interval;
|
||||
}
|
||||
|
||||
static void orbis_ctx_get_video_size(void *data,
|
||||
unsigned *width, unsigned *height)
|
||||
static void vita_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height, bool is_shutdown)
|
||||
{
|
||||
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
|
||||
|
||||
*width = ATTR_ORBISGL_WIDTH;
|
||||
*height = ATTR_ORBISGL_HEIGHT;
|
||||
(void)data;
|
||||
(void)quit;
|
||||
(void)width;
|
||||
(void)height;
|
||||
(void)resize;
|
||||
}
|
||||
|
||||
static void *orbis_ctx_init(video_frame_info_t *video_info, void *video_driver)
|
||||
static void vita_swap_buffers(void *data, void *data2)
|
||||
{
|
||||
#ifdef HAVE_EGL
|
||||
int ret;
|
||||
EGLint n;
|
||||
EGLint major, minor;
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_STENCIL_SIZE, 0,
|
||||
EGL_SAMPLE_BUFFERS, 0,
|
||||
EGL_SAMPLES, 0,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_NONE};
|
||||
(void)data;
|
||||
#ifdef VITA
|
||||
vglStopRendering();
|
||||
vglStartRendering();
|
||||
#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)
|
||||
static void vita_get_video_size(void *data, unsigned *width, unsigned *height)
|
||||
{
|
||||
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;
|
||||
(void)data;
|
||||
*width = 960;
|
||||
*height = 544;
|
||||
}
|
||||
|
||||
static bool orbis_ctx_set_video_mode(void *data,
|
||||
video_frame_info_t *video_info,
|
||||
unsigned width, unsigned height,
|
||||
bool fullscreen)
|
||||
static bool vita_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};
|
||||
(void)data;
|
||||
(void)width;
|
||||
(void)height;
|
||||
(void)fullscreen;
|
||||
|
||||
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
|
||||
|
||||
ctx_orbis->width = ATTR_ORBISGL_WIDTH;
|
||||
ctx_orbis->height = ATTR_ORBISGL_HEIGHT;
|
||||
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void orbis_ctx_input_driver(void *data,
|
||||
static void vita_destroy(void *data)
|
||||
{
|
||||
(void)data;
|
||||
}
|
||||
|
||||
static void vita_input_driver(void *data,
|
||||
const char *name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
*input = NULL;
|
||||
*input_data = NULL;
|
||||
(void)data;
|
||||
(void)input;
|
||||
(void)input_data;
|
||||
}
|
||||
|
||||
static enum gfx_ctx_api orbis_ctx_get_api(void *data)
|
||||
static bool vita_has_focus(void *data)
|
||||
{
|
||||
return ctx_orbis_api;
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool orbis_ctx_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
static bool vita_suppress_screensaver(void *data, bool enable)
|
||||
{
|
||||
(void)data;
|
||||
ctx_orbis_api = api;
|
||||
|
||||
if (api == GFX_CTX_OPENGL_ES_API)
|
||||
if (eglBindAPI(EGL_OPENGL_ES_API) != EGL_FALSE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
(void)data;
|
||||
(void)enable;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool orbis_ctx_has_focus(void *data)
|
||||
static enum gfx_ctx_api vita_get_api(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
return GFX_CTX_NONE;
|
||||
}
|
||||
|
||||
static bool orbis_ctx_suppress_screensaver(void *data, bool enable)
|
||||
static bool vita_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
(void)data;
|
||||
(void)enable;
|
||||
return false;
|
||||
(void)data;
|
||||
(void)api;
|
||||
(void)major;
|
||||
(void)minor;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void orbis_ctx_set_swap_interval(void *data,
|
||||
int swap_interval)
|
||||
static void vita_show_mouse(void *data, bool state)
|
||||
{
|
||||
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
egl_set_swap_interval(&ctx_orbis->egl, 0);
|
||||
#endif
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static void orbis_ctx_swap_buffers(void *data, void *data2)
|
||||
static void vita_bind_hw_render(void *data, bool enable)
|
||||
{
|
||||
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
egl_swap_buffers(&ctx_orbis->egl);
|
||||
#endif
|
||||
(void)data;
|
||||
(void)enable;
|
||||
}
|
||||
|
||||
static gfx_ctx_proc_t orbis_ctx_get_proc_address(const char *symbol)
|
||||
static void *vita_init(video_frame_info_t *video_info, void *video_driver)
|
||||
{
|
||||
#ifdef HAVE_EGL
|
||||
return egl_get_proc_address(symbol);
|
||||
#endif
|
||||
(void)video_driver;
|
||||
|
||||
return (void*)"null";
|
||||
}
|
||||
|
||||
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)
|
||||
static uint32_t vita_get_flags(void *data)
|
||||
{
|
||||
uint32_t flags = 0;
|
||||
|
||||
if (string_is_equal(video_driver_get_ident(), "glcore"))
|
||||
{
|
||||
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_GLSL);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static void orbis_ctx_set_flags(void *data, uint32_t flags)
|
||||
static void vita_set_flags(void *data, uint32_t flags)
|
||||
{
|
||||
(void)data;
|
||||
(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,
|
||||
false, /* 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};
|
||||
const gfx_ctx_driver_t vita_ctx = {
|
||||
vita_init,
|
||||
vita_destroy,
|
||||
vita_get_api,
|
||||
vita_bind_api,
|
||||
vita_swap_interval,
|
||||
vita_set_video_mode,
|
||||
vita_get_video_size,
|
||||
NULL, /* 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 */
|
||||
vita_check_window,
|
||||
NULL, /* set_resize */
|
||||
vita_has_focus,
|
||||
vita_suppress_screensaver,
|
||||
false, /* has_windowed */
|
||||
vita_swap_buffers,
|
||||
vita_input_driver,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
vita_show_mouse,
|
||||
"vita",
|
||||
vita_get_flags,
|
||||
vita_set_flags,
|
||||
vita_bind_hw_render,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
@ -452,6 +452,9 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
|
||||
#if defined(ORBIS)
|
||||
&orbis_ctx,
|
||||
#endif
|
||||
#if defined(VITA)
|
||||
&vita_ctx,
|
||||
#endif
|
||||
#if defined(HAVE_LIBNX) && defined(HAVE_OPENGL)
|
||||
&switch_ctx,
|
||||
#endif
|
||||
|
@ -1980,6 +1980,7 @@ extern const gfx_ctx_driver_t gfx_ctx_sixel;
|
||||
extern const gfx_ctx_driver_t gfx_ctx_network;
|
||||
extern const gfx_ctx_driver_t switch_ctx;
|
||||
extern const gfx_ctx_driver_t orbis_ctx;
|
||||
extern const gfx_ctx_driver_t vita_ctx;
|
||||
extern const gfx_ctx_driver_t gfx_ctx_null;
|
||||
|
||||
extern const shader_backend_t gl_glsl_backend;
|
||||
|
Loading…
x
Reference in New Issue
Block a user