mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-14 22:38:34 +00:00
(Vita) Update gfx driver
This commit is contained in:
parent
a1f4c80648
commit
94e893634d
48
config.def.h
48
config.def.h
@ -1,7 +1,7 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2015 - 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-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
@ -26,7 +26,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
enum
|
||||
enum
|
||||
{
|
||||
VIDEO_GL = 0,
|
||||
VIDEO_XVIDEO,
|
||||
@ -231,7 +231,7 @@ enum
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_DINPUT
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_PS3
|
||||
#elif (defined(SN_TARGET_PSP2) || defined(PSP))
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_PSP
|
||||
#elif defined(_3DS)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_CTR
|
||||
@ -265,7 +265,7 @@ enum
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_GX
|
||||
#elif defined(_XBOX)
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_XDK
|
||||
#elif defined(PSP)
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_PSP
|
||||
#elif defined(_3DS)
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_CTR
|
||||
@ -373,7 +373,7 @@ static const float scale = 3.0;
|
||||
static const bool fullscreen = false;
|
||||
|
||||
/* To use windowed mode or not when going fullscreen. */
|
||||
static const bool windowed_fullscreen = true;
|
||||
static const bool windowed_fullscreen = true;
|
||||
|
||||
/* Which monitor to prefer. 0 is any monitor, 1 and up selects
|
||||
* specific monitors, 1 being the first monitor. */
|
||||
@ -414,8 +414,8 @@ static const unsigned hard_sync_frames = 0;
|
||||
static const unsigned frame_delay = 0;
|
||||
|
||||
/* Inserts a black frame inbetween frames.
|
||||
* Useful for 120 Hz monitors who want to play 60 Hz material with eliminated
|
||||
* ghosting. video_refresh_rate should still be configured as if it
|
||||
* Useful for 120 Hz monitors who want to play 60 Hz material with eliminated
|
||||
* ghosting. video_refresh_rate should still be configured as if it
|
||||
* is a 60 Hz monitor (divide refresh rate by 2).
|
||||
*/
|
||||
static bool black_frame_insertion = false;
|
||||
@ -425,7 +425,7 @@ static bool black_frame_insertion = false;
|
||||
*/
|
||||
static unsigned swap_interval = 1;
|
||||
|
||||
/* Threaded video. Will possibly increase performance significantly
|
||||
/* Threaded video. Will possibly increase performance significantly
|
||||
* at the cost of worse synchronization and latency.
|
||||
*/
|
||||
static const bool video_threaded = false;
|
||||
@ -454,7 +454,7 @@ static const bool video_vfilter = true;
|
||||
static const bool video_smooth = true;
|
||||
|
||||
/* On resize and fullscreen, rendering area will stay 4:3 */
|
||||
static const bool force_aspect = true;
|
||||
static const bool force_aspect = true;
|
||||
|
||||
/* Enable use of shaders. */
|
||||
#ifdef RARCH_CONSOLE
|
||||
@ -546,7 +546,7 @@ static const float font_size = 1.0f;
|
||||
static const float font_size = 32;
|
||||
#endif
|
||||
|
||||
/* Offset for where messages will be placed on-screen.
|
||||
/* Offset for where messages will be placed on-screen.
|
||||
* Values are in range [0.0, 1.0]. */
|
||||
static const float message_pos_offset_x = 0.05;
|
||||
#if defined(_XBOX1)
|
||||
@ -574,21 +574,21 @@ static const bool font_enable = true;
|
||||
|
||||
/* The accurate refresh rate of your monitor (Hz).
|
||||
* This is used to calculate audio input rate with the formula:
|
||||
* audio_input_rate = game_input_rate * display_refresh_rate /
|
||||
* audio_input_rate = game_input_rate * display_refresh_rate /
|
||||
* game_refresh_rate.
|
||||
*
|
||||
* If the implementation does not report any values,
|
||||
* NTSC defaults will be assumed for compatibility.
|
||||
* This value should stay close to 60Hz to avoid large pitch changes.
|
||||
* If your monitor does not run at 60Hz, or something close to it,
|
||||
* If your monitor does not run at 60Hz, or something close to it,
|
||||
* disable VSync, and leave this at its default. */
|
||||
#if defined(RARCH_CONSOLE)
|
||||
static const float refresh_rate = 60/1.001;
|
||||
static const float refresh_rate = 60/1.001;
|
||||
#else
|
||||
static const float refresh_rate = 59.95;
|
||||
static const float refresh_rate = 59.95;
|
||||
#endif
|
||||
|
||||
/* Allow games to set rotation. If false, rotation requests are
|
||||
/* Allow games to set rotation. If false, rotation requests are
|
||||
* honored, but ignored.
|
||||
* Used for setups where one manually rotates the monitor. */
|
||||
static const bool allow_rotate = true;
|
||||
@ -604,7 +604,7 @@ static const unsigned out_rate = 48000;
|
||||
/* Audio device (e.g. hw:0,0 or /dev/audio). If NULL, will use defaults. */
|
||||
static const char *audio_device = NULL;
|
||||
|
||||
/* Desired audio latency in milliseconds. Might not be honored
|
||||
/* Desired audio latency in milliseconds. Might not be honored
|
||||
* if driver can't provide given latency. */
|
||||
static const int out_latency = 64;
|
||||
|
||||
@ -618,7 +618,7 @@ static const bool rate_control = true;
|
||||
static const bool rate_control = false;
|
||||
#endif
|
||||
|
||||
/* Rate control delta. Defines how much rate_control
|
||||
/* Rate control delta. Defines how much rate_control
|
||||
* is allowed to adjust input rate. */
|
||||
static const float rate_control_delta = 0.005;
|
||||
|
||||
@ -634,11 +634,11 @@ static const float audio_volume = 0.0;
|
||||
/* Enables displaying the current frames per second. */
|
||||
static const bool fps_show = false;
|
||||
|
||||
/* Enables use of rewind. This will incur some memory footprint
|
||||
/* Enables use of rewind. This will incur some memory footprint
|
||||
* depending on the save state buffer. */
|
||||
static const bool rewind_enable = false;
|
||||
|
||||
/* The buffer size for the rewind buffer. This needs to be about
|
||||
/* The buffer size for the rewind buffer. This needs to be about
|
||||
* 15-20MB per minute. Very game dependant. */
|
||||
static const unsigned rewind_buffer_size = 20 << 20; /* 20MiB */
|
||||
|
||||
@ -652,7 +652,7 @@ static const bool pause_nonactive = false;
|
||||
* It is measured in seconds. A value of 0 disables autosave. */
|
||||
static const unsigned autosave_interval = 0;
|
||||
|
||||
/* When being client over netplay, use keybinds for
|
||||
/* When being client over netplay, use keybinds for
|
||||
* user 1 rather than user 2. */
|
||||
static const bool netplay_client_swap_input = true;
|
||||
|
||||
@ -660,15 +660,15 @@ static const bool netplay_client_swap_input = true;
|
||||
* This could potentially lead to buggy games. */
|
||||
static const bool block_sram_overwrite = false;
|
||||
|
||||
/* When saving savestates, state index is automatically
|
||||
/* When saving savestates, state index is automatically
|
||||
* incremented before saving.
|
||||
* When the content is loaded, state index will be set
|
||||
* When the content is loaded, state index will be set
|
||||
* to the highest existing value. */
|
||||
static const bool savestate_auto_index = false;
|
||||
|
||||
/* Automatically saves a savestate at the end of RetroArch's lifetime.
|
||||
* The path is $SRAM_PATH.auto.
|
||||
* RetroArch will automatically load any savestate with this path on
|
||||
* RetroArch will automatically load any savestate with this path on
|
||||
* startup if savestate_auto_load is set. */
|
||||
static const bool savestate_auto_save = false;
|
||||
static const bool savestate_auto_load = false;
|
||||
@ -723,7 +723,7 @@ static const unsigned turbo_duty_cycle = 3;
|
||||
* gamepads, plug-and-play style. */
|
||||
static const bool input_autodetect_enable = true;
|
||||
|
||||
/* Show the input descriptors set by the core instead
|
||||
/* Show the input descriptors set by the core instead
|
||||
* of the default ones. */
|
||||
static const bool input_descriptor_label_show = true;
|
||||
|
||||
|
@ -13,18 +13,29 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include "../../defines/psp_defines.h"
|
||||
#include "../../general.h"
|
||||
#include "../../driver.h"
|
||||
#include "../video_viewport.h"
|
||||
#include "../video_monitor.h"
|
||||
|
||||
#include <vita2d.h>
|
||||
|
||||
#define SCREEN_W 960
|
||||
#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
|
||||
{
|
||||
vita2d_texture *texture;
|
||||
vita2d_texture *texture;
|
||||
|
||||
bool vsync;
|
||||
bool rgb32;
|
||||
@ -35,11 +46,14 @@ typedef struct vita_video
|
||||
bool vblank_not_reached;
|
||||
bool keep_aspect;
|
||||
bool should_resize;
|
||||
|
||||
vita_menu_frame_t menu;
|
||||
} vita_video_t;
|
||||
|
||||
static void *vita2d_gfx_init(const video_info_t *video,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *pspinput = NULL;
|
||||
*input = NULL;
|
||||
*input_data = NULL;
|
||||
(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_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->rgb32 = video->rgb32;
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
pspinput = input_psp.init();
|
||||
*input = pspinput ? &input_psp : NULL;
|
||||
*input_data = pspinput;
|
||||
}
|
||||
|
||||
return vita;
|
||||
}
|
||||
|
||||
@ -72,23 +107,32 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
|
||||
(void)pitch;
|
||||
(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);
|
||||
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_clear_screen();
|
||||
|
||||
int i, j;
|
||||
/* int i, j;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
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_swap_buffers();
|
||||
@ -136,6 +180,9 @@ static void vita2d_gfx_free(void *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_fini();
|
||||
@ -173,11 +220,129 @@ static bool vita2d_gfx_read_viewport(void *data, uint8_t *buffer)
|
||||
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,
|
||||
const video_poke_interface_t **iface)
|
||||
{
|
||||
(void)data;
|
||||
(void)iface;
|
||||
*iface = &vita_poke_interface;
|
||||
}
|
||||
|
||||
video_driver_t video_vita2d = {
|
||||
|
Loading…
Reference in New Issue
Block a user