mirror of
https://github.com/libretro/RetroArch
synced 2025-04-24 15:02:35 +00:00
(Vita) Update gfx driver
This commit is contained in:
parent
a1f4c80648
commit
94e893634d
@ -231,7 +231,7 @@ enum
|
|||||||
#define INPUT_DEFAULT_DRIVER INPUT_DINPUT
|
#define INPUT_DEFAULT_DRIVER INPUT_DINPUT
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
#define INPUT_DEFAULT_DRIVER INPUT_PS3
|
#define INPUT_DEFAULT_DRIVER INPUT_PS3
|
||||||
#elif (defined(SN_TARGET_PSP2) || defined(PSP))
|
#elif defined(PSP) || defined(VITA)
|
||||||
#define INPUT_DEFAULT_DRIVER INPUT_PSP
|
#define INPUT_DEFAULT_DRIVER INPUT_PSP
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
#define INPUT_DEFAULT_DRIVER INPUT_CTR
|
#define INPUT_DEFAULT_DRIVER INPUT_CTR
|
||||||
@ -265,7 +265,7 @@ enum
|
|||||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_GX
|
#define JOYPAD_DEFAULT_DRIVER JOYPAD_GX
|
||||||
#elif defined(_XBOX)
|
#elif defined(_XBOX)
|
||||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_XDK
|
#define JOYPAD_DEFAULT_DRIVER JOYPAD_XDK
|
||||||
#elif defined(PSP)
|
#elif defined(PSP) || defined(VITA)
|
||||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_PSP
|
#define JOYPAD_DEFAULT_DRIVER JOYPAD_PSP
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_CTR
|
#define JOYPAD_DEFAULT_DRIVER JOYPAD_CTR
|
||||||
|
@ -13,18 +13,29 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <retro_inline.h>
|
||||||
|
#include "../../defines/psp_defines.h"
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../driver.h"
|
#include "../../driver.h"
|
||||||
#include "../video_viewport.h"
|
#include "../video_viewport.h"
|
||||||
|
#include "../video_monitor.h"
|
||||||
|
|
||||||
#include <vita2d.h>
|
#include <vita2d.h>
|
||||||
|
|
||||||
#define SCREEN_W 960
|
#define SCREEN_W 960
|
||||||
#define SCREEN_H 544
|
#define SCREEN_H 544
|
||||||
|
|
||||||
|
typedef struct vita_menu_frame
|
||||||
|
{
|
||||||
|
bool active;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
vita2d_texture *frame;
|
||||||
|
} vita_menu_frame_t;
|
||||||
|
|
||||||
typedef struct vita_video
|
typedef struct vita_video
|
||||||
{
|
{
|
||||||
vita2d_texture *texture;
|
vita2d_texture *texture;
|
||||||
|
|
||||||
bool vsync;
|
bool vsync;
|
||||||
bool rgb32;
|
bool rgb32;
|
||||||
@ -35,11 +46,14 @@ typedef struct vita_video
|
|||||||
bool vblank_not_reached;
|
bool vblank_not_reached;
|
||||||
bool keep_aspect;
|
bool keep_aspect;
|
||||||
bool should_resize;
|
bool should_resize;
|
||||||
|
|
||||||
|
vita_menu_frame_t menu;
|
||||||
} vita_video_t;
|
} vita_video_t;
|
||||||
|
|
||||||
static void *vita2d_gfx_init(const video_info_t *video,
|
static void *vita2d_gfx_init(const video_info_t *video,
|
||||||
const input_driver_t **input, void **input_data)
|
const input_driver_t **input, void **input_data)
|
||||||
{
|
{
|
||||||
|
void *pspinput = NULL;
|
||||||
*input = NULL;
|
*input = NULL;
|
||||||
*input_data = NULL;
|
*input_data = NULL;
|
||||||
(void)video;
|
(void)video;
|
||||||
@ -53,11 +67,32 @@ static void *vita2d_gfx_init(const video_info_t *video,
|
|||||||
vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
|
vita2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
|
||||||
vita2d_set_vblank_wait(video->vsync);
|
vita2d_set_vblank_wait(video->vsync);
|
||||||
|
|
||||||
vita->texture = vita2d_create_empty_texture(SCREEN_W, SCREEN_H);
|
if (vita->rgb32)
|
||||||
|
{
|
||||||
|
vita->texture = vita2d_create_empty_texture(video->width, video->height);
|
||||||
|
RARCH_LOG("Creating RGBA8 texture: w: %i h: %i\n", video->width, video->height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vita->texture = vita2d_create_empty_texture_format(video->width, video->height, SCE_GXM_TEXTURE_FORMAT_R5G6B5);
|
||||||
|
RARCH_LOG("Creating R5G6B5 texture: w: %i h: %i\n", video->width, video->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
vita->menu.frame = NULL;
|
||||||
|
vita->menu.active = 0;
|
||||||
|
vita->menu.width = 0;
|
||||||
|
vita->menu.height = 0;
|
||||||
|
|
||||||
vita->vsync = video->vsync;
|
vita->vsync = video->vsync;
|
||||||
vita->rgb32 = video->rgb32;
|
vita->rgb32 = video->rgb32;
|
||||||
|
|
||||||
|
if (input && input_data)
|
||||||
|
{
|
||||||
|
pspinput = input_psp.init();
|
||||||
|
*input = pspinput ? &input_psp : NULL;
|
||||||
|
*input_data = pspinput;
|
||||||
|
}
|
||||||
|
|
||||||
return vita;
|
return vita;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,23 +107,32 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
|
|||||||
(void)pitch;
|
(void)pitch;
|
||||||
(void)msg;
|
(void)msg;
|
||||||
|
|
||||||
unsigned int *tex_p = vita2d_texture_get_datap(vita->texture);
|
void *tex_p = vita2d_texture_get_datap(vita->texture);
|
||||||
unsigned int tex_stride = vita2d_texture_get_stride(vita->texture);
|
unsigned int tex_stride = vita2d_texture_get_stride(vita->texture);
|
||||||
const unsigned int *frame_p = frame;
|
const unsigned int *frame_p = frame;
|
||||||
|
|
||||||
|
// RARCH_LOG("w: %i h: %i pitch: %i\n", width, height, pitch);
|
||||||
|
// RARCH_LOG("msg: %s\n", msg);
|
||||||
|
|
||||||
vita2d_start_drawing();
|
vita2d_start_drawing();
|
||||||
vita2d_clear_screen();
|
vita2d_clear_screen();
|
||||||
|
|
||||||
int i, j;
|
/* int i, j;
|
||||||
for (i = 0; i < height; i++)
|
for (i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < width; j++)
|
for (j = 0; j < width; j++)
|
||||||
{
|
{
|
||||||
tex_p[i + j * tex_stride] = frame_p[i + j * pitch];
|
*(unsigned int *)(tex_p + i*4 + j * tex_stride) = frame_p[i + j * width];
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
// memcpy(tex_p, frame, height*pitch);
|
||||||
|
|
||||||
vita2d_draw_texture(vita->texture, 0, 0);
|
// vita2d_draw_texture(vita->texture, 0, 0);
|
||||||
|
|
||||||
|
if (vita->menu.active && vita->menu.frame)
|
||||||
|
vita2d_draw_texture(vita->menu.frame,
|
||||||
|
SCREEN_W/2 - vita->menu.width/2,
|
||||||
|
SCREEN_H/2 - vita->menu.height/2);
|
||||||
|
|
||||||
vita2d_end_drawing();
|
vita2d_end_drawing();
|
||||||
vita2d_swap_buffers();
|
vita2d_swap_buffers();
|
||||||
@ -136,6 +180,9 @@ static void vita2d_gfx_free(void *data)
|
|||||||
{
|
{
|
||||||
vita_video_t *vita = (vita_video_t *)data;
|
vita_video_t *vita = (vita_video_t *)data;
|
||||||
|
|
||||||
|
if (vita->menu.frame)
|
||||||
|
vita2d_free_texture(vita->menu.frame);
|
||||||
|
|
||||||
vita2d_free_texture(vita->texture);
|
vita2d_free_texture(vita->texture);
|
||||||
|
|
||||||
vita2d_fini();
|
vita2d_fini();
|
||||||
@ -173,11 +220,129 @@ static bool vita2d_gfx_read_viewport(void *data, uint8_t *buffer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vita_set_filtering(void *data, unsigned index, bool smooth)
|
||||||
|
{
|
||||||
|
vita_video_t *psp = (vita_video_t*)data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vita_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||||
|
{
|
||||||
|
vita_video_t *vid = (vita_video_t*)data;
|
||||||
|
struct retro_system_av_info *av_info =
|
||||||
|
video_viewport_get_system_av_info();
|
||||||
|
|
||||||
|
switch (aspectratio_index)
|
||||||
|
{
|
||||||
|
case ASPECT_RATIO_SQUARE:
|
||||||
|
video_viewport_set_square_pixel(
|
||||||
|
av_info->geometry.base_width,
|
||||||
|
av_info->geometry.base_height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ASPECT_RATIO_CORE:
|
||||||
|
video_viewport_set_core();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ASPECT_RATIO_CONFIG:
|
||||||
|
video_viewport_set_config();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
video_driver_set_aspect_ratio_value(aspectratio_lut[aspectratio_index].value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vita_apply_state_changes(void *data)
|
||||||
|
{
|
||||||
|
(void)data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vita_set_texture_frame(void *data, const void *frame, bool rgb32,
|
||||||
|
unsigned width, unsigned height, float alpha)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
void *tex_p;
|
||||||
|
unsigned int stride;
|
||||||
|
vita_video_t *vita = (vita_video_t*)data;
|
||||||
|
|
||||||
|
(void)alpha;
|
||||||
|
|
||||||
|
if (width != vita->menu.width && height != vita->menu.height && vita->menu.frame)
|
||||||
|
{
|
||||||
|
vita2d_free_texture(vita->menu.frame);
|
||||||
|
vita->menu.frame = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!vita->menu.frame)
|
||||||
|
{
|
||||||
|
if (rgb32)
|
||||||
|
{
|
||||||
|
vita->menu.frame = vita2d_create_empty_texture(width, height);
|
||||||
|
RARCH_LOG("Creating Frame RGBA8 texture: w: %i h: %i\n", width, height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vita->menu.frame = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_FORMAT_R5G6B5);
|
||||||
|
RARCH_LOG("Creating Frame R5G6B5 texture: w: %i h: %i\n", width, height);
|
||||||
|
}
|
||||||
|
vita->menu.width = width;
|
||||||
|
vita->menu.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
tex_p = vita2d_texture_get_datap(vita->menu.frame);
|
||||||
|
stride = vita2d_texture_get_stride(vita->menu.frame);
|
||||||
|
|
||||||
|
if (rgb32)
|
||||||
|
{
|
||||||
|
for (i = 0; i < height; i++)
|
||||||
|
for (j = 0; j < width; j++)
|
||||||
|
*(unsigned int *)(tex_p + (j + i*height) * 4) = *(unsigned int *)(frame + (j + i*height) * 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*for (i = 0; i < height; i++)
|
||||||
|
for (j = 0; j < width; j++)
|
||||||
|
*(unsigned short *)(tex_p + (j + i*height) * 2) = *(unsigned short *)(frame + (j + i*height) * 2);*/
|
||||||
|
memcpy(tex_p, frame, width*height*2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vita_set_texture_enable(void *data, bool state, bool full_screen)
|
||||||
|
{
|
||||||
|
vita_video_t *vid = (vita_video_t*)data;
|
||||||
|
|
||||||
|
(void)full_screen;
|
||||||
|
|
||||||
|
vid->menu.active = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const video_poke_interface_t vita_poke_interface = {
|
||||||
|
NULL,
|
||||||
|
vita_set_filtering,
|
||||||
|
NULL, /* get_video_output_size */
|
||||||
|
NULL, /* get_video_output_prev */
|
||||||
|
NULL, /* get_video_output_next */
|
||||||
|
NULL, /* get_current_framebuffer */
|
||||||
|
NULL, /* get_proc_address */
|
||||||
|
vita_set_aspect_ratio,
|
||||||
|
vita_apply_state_changes,
|
||||||
|
#ifdef HAVE_MENU
|
||||||
|
vita_set_texture_frame,
|
||||||
|
vita_set_texture_enable,
|
||||||
|
#endif
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
static void vita2d_gfx_get_poke_interface(void *data,
|
static void vita2d_gfx_get_poke_interface(void *data,
|
||||||
const video_poke_interface_t **iface)
|
const video_poke_interface_t **iface)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
(void)iface;
|
*iface = &vita_poke_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
video_driver_t video_vita2d = {
|
video_driver_t video_vita2d = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user