[VITA] Add gl1 video driver support through vitaGL.

This commit is contained in:
Rinnegatamante 2019-11-12 11:52:04 +01:00
parent a0486c3cd7
commit 6394342b9c
5 changed files with 41 additions and 7 deletions

View File

@ -1156,6 +1156,13 @@ ifeq ($(HAVE_PLAIN_DRM), 1)
LIBS += -ldrm
endif
ifeq ($(HAVE_VITAGL), 1)
DEFINES += -DHAVE_OPENGL1
OBJ += gfx/drivers/gl1.o \
gfx/drivers_font/gl1_raster_font.o \
menu/drivers_display/menu_display_gl1.o
endif
ifeq ($(HAVE_GL_CONTEXT), 1)
ifeq ($(HAVE_GL_MODERN), 1)
DEFINES += -DHAVE_OPENGL

View File

@ -35,6 +35,7 @@ else
HAVE_ZLIB := 1
HAVE_7ZIP := 1
HAVE_VITA2D := 1
HAVE_VITAGL := 1
HAVE_NETWORKING := 1
HAVE_SOCKET_LEGACY := 1
HAVE_MENU := 1
@ -115,7 +116,8 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
VITA_LIBS := -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub -lSceAppUtil_stub \
-lSceSysmodule_stub -lSceCtrl_stub -lSceHid_stub -lSceTouch_stub -lSceAudio_stub \
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub -lSceMotion_stub \
-lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lpthread -lpng -lz
-lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lpthread -lpng -lz -lvitagl \
-lmathneon
LIBS := $(WHOLE_START) -lretro_vita $(WHOLE_END) $(VITA_LIBS) -lm -lc

View File

@ -6,8 +6,8 @@
#define RAM_THRESHOLD 0xA00000 // Memory left to the system for threads and other internal stuffs
static int _newlib_heap_memblock;
static unsigned _newlib_heap_size;
int _newlib_heap_memblock;
unsigned _newlib_heap_size;
char *_newlib_heap_base, *_newlib_heap_end, *_newlib_heap_cur;
static char _newlib_sbrk_mutex[32] __attribute__ ((aligned (8)));

View File

@ -30,12 +30,23 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#ifdef VITA
#include <vitaGL.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#endif
#include "../../retroarch.h"
#ifdef VITA
#define GL_RGBA8 GL_RGBA
#define GL_RGB8 GL_RGB
#define GL_BGRA_EXT GL_RGBA // Currently unsupported in vitaGL
#define GL_CLAMP GL_CLAMP_TO_EDGE
#endif
#define RARCH_GL1_INTERNAL_FORMAT32 GL_RGBA8
#define RARCH_GL1_TEXTURE_TYPE32 GL_BGRA_EXT
#define RARCH_GL1_FORMAT32 GL_UNSIGNED_BYTE

View File

@ -285,7 +285,9 @@ static void *gl1_gfx_init(const video_info_t *video,
full_y = mode.height;
mode.width = 0;
mode.height = 0;
#ifdef VITA
vglInitExtended(0x100000, 960, 544, 0x1000000, SCE_GXM_MULTISAMPLE_4X);
#endif
/* Clear out potential error flags in case we use cached context. */
glGetError();
@ -395,7 +397,9 @@ static void *gl1_gfx_init(const video_info_t *video,
glDisable(GL_CULL_FACE);
glDisable(GL_STENCIL_TEST);
glDisable(GL_SCISSOR_TEST);
#ifndef VITA
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
#endif
glGenTextures(1, &gl1->tex);
glGenTextures(1, &gl1->menu_tex);
@ -562,10 +566,13 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
/* Multi-texture not part of GL 1.1 */
/*glActiveTexture(GL_TEXTURE0);*/
#ifndef VITA
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pot_width);
#endif
glBindTexture(GL_TEXTURE_2D, tex);
/* For whatever reason you can't send NULL in GLDirect,
so we send the frame as dummy data */
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, pot_width, pot_height, 0, format, type, frame_to_copy);
@ -686,10 +693,11 @@ static void gl1_readback(
unsigned fmt, unsigned type,
void *src)
{
#ifndef VITA
glPixelStorei(GL_PACK_ALIGNMENT, alignment);
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glReadBuffer(GL_BACK);
#endif
glReadPixels(gl1->vp.x, gl1->vp.y,
gl1->vp.width, gl1->vp.height,
(GLenum)fmt, (GLenum)type, (GLvoid*)src);
@ -710,7 +718,9 @@ static bool gl1_gfx_frame(void *data, const void *frame,
unsigned pot_height = 0;
gl1_context_bind_hw_render(gl1, false);
#ifdef VITA
vglStartRendering();
#endif
/* FIXME: Force these settings off as they interfere with the rendering */
video_info->xmb_shadows_enable = false;
video_info->menu_shader_pipeline = 0;
@ -917,7 +927,9 @@ static bool gl1_gfx_frame(void *data, const void *frame,
glClear(GL_COLOR_BUFFER_BIT);
glFinish();
}
#ifdef VITA
vglStopRendering();
#endif
gl1_context_bind_hw_render(gl1, true);
return true;
@ -1259,7 +1271,9 @@ static void gl1_load_texture_data(
gl1_bind_texture(id, wrap, mag_filter, min_filter);
#ifndef VITA
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
#endif
glTexImage2D(GL_TEXTURE_2D,
0,
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL1_INTERNAL_FORMAT32,