2015-08-30 20:04:52 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 13:40:32 +01:00
|
|
|
* Copyright (C) 2015-2017 - Sergi Granell (xerpi)
|
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2015-08-30 20:04:52 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-09-14 03:50:34 +02:00
|
|
|
#include <vita2d.h>
|
|
|
|
|
2015-08-31 00:55:34 +02:00
|
|
|
#include <retro_inline.h>
|
2016-01-20 06:16:55 +01:00
|
|
|
#include <string/stdstring.h>
|
2017-01-17 18:12:23 +01:00
|
|
|
#include <formats/image.h>
|
2015-09-14 03:50:34 +02:00
|
|
|
|
2016-09-11 14:46:53 +02:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
2015-08-30 20:04:52 +02:00
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "../../menu/menu_driver.h"
|
2019-12-14 14:11:09 +01:00
|
|
|
#endif
|
2020-02-17 21:28:42 +01:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
#include "../gfx_widgets.h"
|
2015-09-29 20:01:13 +02:00
|
|
|
#endif
|
|
|
|
|
2017-01-19 17:20:42 +01:00
|
|
|
#include "../font_driver.h"
|
|
|
|
|
2016-09-11 14:46:53 +02:00
|
|
|
#include "../common/vita2d_common.h"
|
|
|
|
#include "../../driver.h"
|
|
|
|
#include "../video_coord_array.h"
|
2017-01-17 18:15:11 +01:00
|
|
|
#include "../../verbosity.h"
|
|
|
|
#include "../../configuration.h"
|
2017-01-17 18:12:23 +01:00
|
|
|
|
2021-05-18 22:15:04 +02:00
|
|
|
#include <defines/psp_defines.h>
|
2021-05-22 17:28:53 +02:00
|
|
|
#include <psp2/kernel/sysmem.h>
|
2016-09-11 14:46:53 +02:00
|
|
|
|
2016-10-17 18:39:10 +02:00
|
|
|
extern void *memcpy_neon(void *dst, const void *src, size_t n);
|
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width,
|
|
|
|
unsigned viewport_height, bool force_full, bool allow_rotate);
|
2017-12-11 23:55:31 -08:00
|
|
|
|
2017-04-24 12:25:14 +02:00
|
|
|
static void *vita2d_gfx_init(const video_info_t *video,
|
2019-07-27 02:21:24 +02:00
|
|
|
input_driver_t **input, void **input_data)
|
2015-08-30 20:04:52 +02:00
|
|
|
{
|
2015-12-05 12:50:56 +01:00
|
|
|
vita_video_t *vita = (vita_video_t *)calloc(1, sizeof(vita_video_t));
|
2021-05-22 17:28:53 +02:00
|
|
|
unsigned temp_width = PSP_FB_WIDTH;
|
|
|
|
unsigned temp_height = PSP_FB_HEIGHT;
|
|
|
|
vita2d_video_mode_data video_mode_data = {0};
|
2015-08-30 22:48:19 +02:00
|
|
|
|
|
|
|
if (!vita)
|
|
|
|
return NULL;
|
|
|
|
|
2015-09-29 17:35:28 +02:00
|
|
|
*input = NULL;
|
|
|
|
*input_data = NULL;
|
|
|
|
|
2015-09-01 01:35:29 +02:00
|
|
|
RARCH_LOG("vita2d_gfx_init: w: %i h: %i\n", video->width, video->height);
|
|
|
|
RARCH_LOG("RARCH_SCALE_BASE: %i input_scale: %i = %i\n",
|
2016-09-07 23:53:20 +02:00
|
|
|
RARCH_SCALE_BASE, video->input_scale, RARCH_SCALE_BASE * video->input_scale);
|
2015-09-01 01:35:29 +02:00
|
|
|
|
2021-05-22 17:28:53 +02:00
|
|
|
|
|
|
|
vita2d_init_advanced_with_msaa((1 * 1024 * 1024), SCE_GXM_MULTISAMPLE_4X,
|
|
|
|
sceKernelGetModelForCDialog() == SCE_KERNEL_MODEL_VITATV? VITA2D_VIDEO_MODE_1280x720 : VITA2D_VIDEO_MODE_960x544 );
|
2015-09-17 11:08:06 +02:00
|
|
|
vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
|
2015-08-30 22:48:19 +02:00
|
|
|
vita2d_set_vblank_wait(video->vsync);
|
|
|
|
|
2016-08-08 01:51:23 +02:00
|
|
|
if (video->rgb32)
|
2015-09-02 18:56:24 +02:00
|
|
|
{
|
|
|
|
RARCH_LOG("Format: SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB\n");
|
2015-08-31 15:26:37 +02:00
|
|
|
vita->format = SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB;
|
2015-09-02 18:56:24 +02:00
|
|
|
}
|
2015-08-31 00:55:34 +02:00
|
|
|
else
|
2015-09-02 18:56:24 +02:00
|
|
|
{
|
|
|
|
RARCH_LOG("Format: SCE_GXM_TEXTURE_FORMAT_R5G6B5\n");
|
2015-08-31 15:26:37 +02:00
|
|
|
vita->format = SCE_GXM_TEXTURE_FORMAT_R5G6B5;
|
2015-09-02 18:56:24 +02:00
|
|
|
}
|
2015-08-31 15:26:37 +02:00
|
|
|
|
2021-05-22 17:28:53 +02:00
|
|
|
video_mode_data = vita2d_get_video_mode_data();
|
|
|
|
temp_width = video_mode_data.width;
|
|
|
|
temp_height = video_mode_data.height;
|
|
|
|
|
2015-08-31 19:37:02 +02:00
|
|
|
vita->fullscreen = video->fullscreen;
|
2015-08-31 00:55:34 +02:00
|
|
|
|
2015-09-05 16:22:25 +02:00
|
|
|
vita->texture = NULL;
|
2015-09-02 18:56:24 +02:00
|
|
|
vita->menu.texture = NULL;
|
2015-09-05 16:22:25 +02:00
|
|
|
vita->menu.active = 0;
|
|
|
|
vita->menu.width = 0;
|
|
|
|
vita->menu.height = 0;
|
2015-08-30 20:04:52 +02:00
|
|
|
|
2015-09-05 16:22:25 +02:00
|
|
|
vita->vsync = video->vsync;
|
|
|
|
vita->rgb32 = video->rgb32;
|
2015-08-30 22:48:19 +02:00
|
|
|
|
2017-12-11 23:55:31 -08:00
|
|
|
vita->tex_filter = video->smooth
|
2016-05-05 01:59:05 +02:00
|
|
|
? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT;
|
2015-09-08 20:40:38 +02:00
|
|
|
|
2020-03-12 20:54:25 +01:00
|
|
|
vita->video_width = temp_width;
|
|
|
|
vita->video_height = temp_height;
|
2020-03-09 21:56:03 +01:00
|
|
|
|
2020-01-31 03:47:50 +01:00
|
|
|
video_driver_set_size(temp_width, temp_height);
|
2016-08-23 02:49:53 +02:00
|
|
|
vita2d_gfx_set_viewport(vita, temp_width, temp_height, false, true);
|
|
|
|
|
2015-08-31 00:55:34 +02:00
|
|
|
if (input && input_data)
|
|
|
|
{
|
2017-01-10 21:15:52 +01:00
|
|
|
settings_t *settings = config_get_ptr();
|
2020-08-30 05:29:32 +02:00
|
|
|
void *pspinput = input_driver_init_wrap(&input_psp,
|
|
|
|
settings->arrays.input_joypad_driver);
|
2017-01-10 21:15:52 +01:00
|
|
|
*input = pspinput ? &input_psp : NULL;
|
|
|
|
*input_data = pspinput;
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
|
2015-09-09 01:10:48 +02:00
|
|
|
vita->keep_aspect = true;
|
|
|
|
vita->should_resize = true;
|
2015-09-29 20:01:13 +02:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-12-05 10:33:50 +01:00
|
|
|
vita->overlay_enable = false;
|
2015-09-29 20:01:13 +02:00
|
|
|
#endif
|
2020-02-16 21:59:03 +01:00
|
|
|
font_driver_init_osd(vita,
|
|
|
|
video,
|
|
|
|
false,
|
2017-04-29 16:52:52 +02:00
|
|
|
video->is_threaded,
|
|
|
|
FONT_DRIVER_RENDER_VITA2D);
|
2016-10-18 20:07:00 -03:00
|
|
|
|
2015-08-30 22:48:19 +02:00
|
|
|
return vita;
|
2015-08-30 20:04:52 +02:00
|
|
|
}
|
|
|
|
|
2015-09-29 20:01:13 +02:00
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
static void vita2d_render_overlay(void *data);
|
|
|
|
static void vita2d_free_overlay(vita_video_t *vita)
|
|
|
|
{
|
2016-05-05 01:59:05 +02:00
|
|
|
unsigned i;
|
2016-10-10 19:35:14 +02:00
|
|
|
|
|
|
|
vita2d_wait_rendering_done();
|
|
|
|
|
2016-05-05 01:59:05 +02:00
|
|
|
for (i = 0; i < vita->overlays; i++)
|
2015-09-29 20:01:13 +02:00
|
|
|
vita2d_free_texture(vita->overlay[i].tex);
|
|
|
|
free(vita->overlay);
|
|
|
|
vita->overlay = NULL;
|
|
|
|
vita->overlays = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-04-29 17:52:16 +02:00
|
|
|
static void vita2d_gfx_update_viewport(vita_video_t* vita,
|
|
|
|
video_frame_info_t *video_info);
|
2015-09-09 01:10:48 +02:00
|
|
|
|
2015-08-30 20:04:52 +02:00
|
|
|
static bool vita2d_gfx_frame(void *data, const void *frame,
|
|
|
|
unsigned width, unsigned height, uint64_t frame_count,
|
2017-01-18 17:41:27 +01:00
|
|
|
unsigned pitch, const char *msg, video_frame_info_t *video_info)
|
2015-08-30 20:04:52 +02:00
|
|
|
{
|
2015-08-31 15:26:37 +02:00
|
|
|
void *tex_p;
|
2020-08-03 16:33:54 +02:00
|
|
|
vita_video_t *vita = (vita_video_t *)data;
|
2021-05-22 17:28:53 +02:00
|
|
|
unsigned temp_width = PSP_FB_WIDTH;
|
|
|
|
unsigned temp_height = PSP_FB_HEIGHT;
|
|
|
|
vita2d_video_mode_data video_mode_data = {0};
|
2020-08-03 16:33:54 +02:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
bool menu_is_alive = video_info->menu_is_alive;
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
bool widgets_active = video_info->widgets_active;
|
|
|
|
#endif
|
|
|
|
bool statistics_show = video_info->statistics_show;
|
|
|
|
struct font_params
|
|
|
|
*osd_params = (struct font_params*)
|
|
|
|
&video_info->osd_stat_params;
|
|
|
|
|
2017-01-18 17:41:27 +01:00
|
|
|
|
2015-08-31 15:26:37 +02:00
|
|
|
if (frame)
|
|
|
|
{
|
2017-01-18 17:41:27 +01:00
|
|
|
if(!(vita->texture&&vita2d_texture_get_datap(vita->texture)==frame))
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
unsigned int stride;
|
|
|
|
|
|
|
|
if ((width != vita->width || height != vita->height) && vita->texture)
|
|
|
|
{
|
2021-05-27 18:41:26 +02:00
|
|
|
vita2d_wait_rendering_done();
|
2017-01-18 17:41:27 +01:00
|
|
|
vita2d_free_texture(vita->texture);
|
|
|
|
vita->texture = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!vita->texture)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Creating texture: %ix%i\n", width, height);
|
|
|
|
vita->width = width;
|
|
|
|
vita->height = height;
|
|
|
|
vita->texture = vita2d_create_empty_texture_format(width, height, vita->format);
|
|
|
|
vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter);
|
|
|
|
}
|
|
|
|
tex_p = vita2d_texture_get_datap(vita->texture);
|
|
|
|
stride = vita2d_texture_get_stride(vita->texture);
|
|
|
|
|
|
|
|
if (vita->format == SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB)
|
|
|
|
{
|
|
|
|
stride /= 4;
|
|
|
|
pitch /= 4;
|
|
|
|
uint32_t *tex32 = tex_p;
|
|
|
|
const uint32_t *frame32 = frame;
|
|
|
|
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
memcpy_neon(&tex32[i*stride],&frame32[i*pitch],pitch*sizeof(uint32_t));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stride /= 2;
|
|
|
|
pitch /= 2;
|
|
|
|
uint16_t *tex16 = tex_p;
|
|
|
|
const uint16_t *frame16 = frame;
|
|
|
|
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
memcpy_neon(&tex16[i*stride],&frame16[i*pitch],width*sizeof(uint16_t));
|
|
|
|
}
|
2015-08-31 15:26:37 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-30 22:48:19 +02:00
|
|
|
|
2015-09-09 01:10:48 +02:00
|
|
|
if (vita->should_resize)
|
2017-04-29 16:11:31 +02:00
|
|
|
vita2d_gfx_update_viewport(vita, video_info);
|
2015-09-09 01:10:48 +02:00
|
|
|
|
2021-05-22 17:28:53 +02:00
|
|
|
video_mode_data = vita2d_get_video_mode_data();
|
|
|
|
temp_width = video_mode_data.width;
|
|
|
|
temp_height = video_mode_data.height;
|
|
|
|
|
2015-08-30 20:11:57 +02:00
|
|
|
vita2d_start_drawing();
|
2017-01-18 17:41:27 +01:00
|
|
|
|
2021-05-22 17:28:53 +02:00
|
|
|
vita2d_draw_rectangle(0,0,temp_width,temp_height,vita2d_get_clear_color());
|
2017-01-18 17:41:27 +01:00
|
|
|
|
2015-09-01 01:35:29 +02:00
|
|
|
if (vita->texture)
|
2015-08-31 19:37:02 +02:00
|
|
|
{
|
|
|
|
if (vita->fullscreen)
|
|
|
|
vita2d_draw_texture_scale(vita->texture,
|
2015-09-05 16:22:25 +02:00
|
|
|
0, 0,
|
2021-05-22 17:28:53 +02:00
|
|
|
temp_width / (float)vita->width,
|
|
|
|
temp_height / (float)vita->height);
|
2015-08-31 19:37:02 +02:00
|
|
|
else
|
2015-09-05 16:22:25 +02:00
|
|
|
{
|
2020-05-22 12:02:19 +02:00
|
|
|
const float radian = 270 * 0.0174532925f;
|
2015-09-11 18:02:59 +02:00
|
|
|
const float rad = vita->rotation * radian;
|
2015-09-09 01:10:48 +02:00
|
|
|
float scalex = vita->vp.width / (float)vita->width;
|
|
|
|
float scaley = vita->vp.height / (float)vita->height;
|
2016-08-01 20:26:29 +02:00
|
|
|
vita2d_draw_texture_scale_rotate(vita->texture,vita->vp.x,
|
2017-01-18 17:41:27 +01:00
|
|
|
vita->vp.y, scalex, scaley, rad);
|
2015-09-05 16:22:25 +02:00
|
|
|
}
|
2015-08-31 19:37:02 +02:00
|
|
|
}
|
2015-08-30 22:48:19 +02:00
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
if (vita->menu.active)
|
2015-08-31 19:37:02 +02:00
|
|
|
{
|
2017-01-18 22:20:47 +01:00
|
|
|
#ifdef HAVE_MENU
|
2020-05-19 16:20:43 +02:00
|
|
|
menu_driver_frame(menu_is_alive, video_info);
|
2017-01-18 22:20:47 +01:00
|
|
|
#endif
|
2017-01-18 17:41:27 +01:00
|
|
|
|
2017-01-24 14:08:28 +01:00
|
|
|
if(vita->menu.texture)
|
|
|
|
{
|
2017-01-18 17:41:27 +01:00
|
|
|
if (vita->fullscreen)
|
|
|
|
vita2d_draw_texture_scale(vita->menu.texture,
|
|
|
|
0, 0,
|
2021-05-22 17:28:53 +02:00
|
|
|
temp_width / (float)vita->menu.width,
|
|
|
|
temp_height / (float)vita->menu.height);
|
2017-01-18 17:41:27 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (vita->menu.width > vita->menu.height)
|
|
|
|
{
|
2021-05-22 17:28:53 +02:00
|
|
|
float scale = temp_height / (float)vita->menu.height;
|
2017-01-18 17:41:27 +01:00
|
|
|
float w = vita->menu.width * scale;
|
|
|
|
vita2d_draw_texture_scale(vita->menu.texture,
|
2021-05-22 17:28:53 +02:00
|
|
|
temp_width / 2.0f - w/2.0f, 0.0f,
|
2017-01-18 17:41:27 +01:00
|
|
|
scale, scale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-22 17:28:53 +02:00
|
|
|
float scale = temp_width / (float)vita->menu.width;
|
2017-01-18 17:41:27 +01:00
|
|
|
float h = vita->menu.height * scale;
|
|
|
|
vita2d_draw_texture_scale(vita->menu.texture,
|
2021-05-22 17:28:53 +02:00
|
|
|
0.0f, temp_height / 2.0f - h/2.0f,
|
2017-01-18 17:41:27 +01:00
|
|
|
scale, scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-31 19:37:02 +02:00
|
|
|
}
|
2020-08-03 16:33:54 +02:00
|
|
|
else if (statistics_show)
|
2018-03-23 17:43:49 +01:00
|
|
|
{
|
|
|
|
if (osd_params)
|
2020-03-10 03:24:59 +01:00
|
|
|
font_driver_render_msg(vita, video_info->stat_text,
|
2020-08-03 16:33:54 +02:00
|
|
|
osd_params, NULL);
|
2018-03-23 17:43:49 +01:00
|
|
|
}
|
2017-01-18 17:41:27 +01:00
|
|
|
|
2020-02-17 01:43:40 +01:00
|
|
|
#ifdef HAVE_OVERLAY
|
2019-12-14 14:11:09 +01:00
|
|
|
if (vita->overlay_enable)
|
|
|
|
vita2d_render_overlay(vita);
|
2020-02-17 01:43:40 +01:00
|
|
|
#endif
|
2019-12-14 14:11:09 +01:00
|
|
|
|
2020-02-17 21:28:42 +01:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
2020-08-03 16:33:54 +02:00
|
|
|
if (widgets_active)
|
2020-06-08 05:45:15 +02:00
|
|
|
gfx_widgets_frame(video_info);
|
2020-02-17 01:43:40 +01:00
|
|
|
#endif
|
2019-12-14 14:11:09 +01:00
|
|
|
|
2016-01-20 06:16:55 +01:00
|
|
|
if(!string_is_empty(msg))
|
2020-03-10 03:24:59 +01:00
|
|
|
font_driver_render_msg(vita, msg, NULL, NULL);
|
2017-01-18 17:41:27 +01:00
|
|
|
|
2015-08-30 20:11:57 +02:00
|
|
|
vita2d_end_drawing();
|
|
|
|
vita2d_swap_buffers();
|
|
|
|
|
2015-08-30 20:04:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-16 22:26:07 +01:00
|
|
|
static void vita2d_gfx_set_nonblock_state(void *data, bool toggle, bool c, unsigned d)
|
2015-08-30 20:04:52 +02:00
|
|
|
{
|
2015-08-30 22:48:19 +02:00
|
|
|
vita_video_t *vita = (vita_video_t *)data;
|
|
|
|
|
|
|
|
if (vita)
|
|
|
|
{
|
|
|
|
vita->vsync = !toggle;
|
|
|
|
vita2d_set_vblank_wait(vita->vsync);
|
|
|
|
}
|
2015-08-30 20:04:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool vita2d_gfx_alive(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool vita2d_gfx_focus(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool vita2d_gfx_suppress_screensaver(void *data, bool enable)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)enable;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_gfx_free(void *data)
|
|
|
|
{
|
2015-08-30 22:48:19 +02:00
|
|
|
vita_video_t *vita = (vita_video_t *)data;
|
|
|
|
|
2015-09-02 18:56:24 +02:00
|
|
|
vita2d_fini();
|
|
|
|
|
|
|
|
if (vita->menu.texture)
|
2015-09-01 01:35:29 +02:00
|
|
|
{
|
2015-09-02 18:56:24 +02:00
|
|
|
vita2d_free_texture(vita->menu.texture);
|
|
|
|
vita->menu.texture = NULL;
|
2015-09-01 01:35:29 +02:00
|
|
|
}
|
2015-08-31 00:55:34 +02:00
|
|
|
|
2015-08-31 21:41:45 +02:00
|
|
|
if (vita->texture)
|
2015-09-01 01:35:29 +02:00
|
|
|
{
|
2015-08-31 21:41:45 +02:00
|
|
|
vita2d_free_texture(vita->texture);
|
2015-09-01 01:35:29 +02:00
|
|
|
vita->texture = NULL;
|
|
|
|
}
|
2015-08-30 20:04:52 +02:00
|
|
|
|
2016-10-20 00:39:33 +02:00
|
|
|
font_driver_free_osd();
|
2015-08-30 20:04:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool vita2d_gfx_set_shader(void *data,
|
|
|
|
enum rarch_shader_type type, const char *path)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)type;
|
|
|
|
(void)path;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
static void vita2d_set_projection(vita_video_t *vita,
|
|
|
|
struct video_ortho *ortho, bool allow_rotate)
|
|
|
|
{
|
|
|
|
math_matrix_4x4 rot;
|
|
|
|
|
|
|
|
/* Calculate projection. */
|
2017-04-16 04:00:20 +02:00
|
|
|
matrix_4x4_ortho(vita->mvp_no_rot, ortho->left, ortho->right,
|
2016-08-23 02:49:53 +02:00
|
|
|
ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
|
|
|
|
|
|
|
if (!allow_rotate)
|
|
|
|
{
|
|
|
|
vita->mvp = vita->mvp_no_rot;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-16 03:53:07 +02:00
|
|
|
matrix_4x4_rotate_z(rot, M_PI * vita->rotation / 180.0f);
|
2017-04-16 07:55:02 +02:00
|
|
|
matrix_4x4_multiply(vita->mvp, rot, vita->mvp_no_rot);
|
2016-08-23 02:49:53 +02:00
|
|
|
}
|
|
|
|
|
2017-04-29 16:11:31 +02:00
|
|
|
static void vita2d_gfx_update_viewport(vita_video_t* vita,
|
|
|
|
video_frame_info_t *video_info)
|
2015-09-09 01:10:48 +02:00
|
|
|
{
|
2021-05-22 17:28:53 +02:00
|
|
|
|
|
|
|
vita2d_video_mode_data video_mode_data = vita2d_get_video_mode_data();
|
|
|
|
unsigned temp_width = video_mode_data.width;
|
|
|
|
unsigned temp_height = video_mode_data.height;
|
2020-02-18 14:51:40 +01:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
2021-05-22 17:28:53 +02:00
|
|
|
float device_aspect = ((float)temp_width) / temp_height;
|
|
|
|
float width = temp_width;
|
|
|
|
float height = temp_height;
|
2020-02-18 14:51:40 +01:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
bool video_scale_integer = settings->bools.video_scale_integer;
|
|
|
|
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
|
|
|
|
|
|
|
|
if (video_scale_integer)
|
2015-09-09 01:10:48 +02:00
|
|
|
{
|
2021-05-22 17:28:53 +02:00
|
|
|
video_viewport_get_scaled_integer(&vita->vp, temp_width,
|
|
|
|
temp_height, video_driver_get_aspect_ratio(), vita->keep_aspect);
|
2015-09-09 01:10:48 +02:00
|
|
|
width = vita->vp.width;
|
|
|
|
height = vita->vp.height;
|
|
|
|
}
|
|
|
|
else if (vita->keep_aspect)
|
|
|
|
{
|
|
|
|
float desired_aspect = video_driver_get_aspect_ratio();
|
2017-01-25 18:39:55 +01:00
|
|
|
if ( (vita->rotation == ORIENTATION_VERTICAL) ||
|
2017-01-24 14:08:28 +01:00
|
|
|
(vita->rotation == ORIENTATION_FLIPPED_ROTATED))
|
|
|
|
{
|
|
|
|
device_aspect = 1.0 / device_aspect;
|
2021-05-22 17:28:53 +02:00
|
|
|
width = temp_height;
|
|
|
|
height = temp_width;
|
2017-01-24 14:08:28 +01:00
|
|
|
}
|
2015-09-09 01:10:48 +02:00
|
|
|
#if defined(HAVE_MENU)
|
2020-02-18 14:51:40 +01:00
|
|
|
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
2015-09-09 01:10:48 +02:00
|
|
|
{
|
2017-04-29 16:11:31 +02:00
|
|
|
x = video_info->custom_vp_x;
|
|
|
|
y = video_info->custom_vp_y;
|
|
|
|
width = video_info->custom_vp_width;
|
|
|
|
height = video_info->custom_vp_height;
|
2015-09-09 01:10:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2015-09-28 18:12:02 +02:00
|
|
|
float delta;
|
|
|
|
|
2015-09-11 18:02:59 +02:00
|
|
|
if ((fabsf(device_aspect - desired_aspect) < 0.0001f))
|
2015-09-09 01:10:48 +02:00
|
|
|
{
|
|
|
|
/* If the aspect ratios of screen and desired aspect
|
|
|
|
* ratio are sufficiently equal (floating point stuff),
|
|
|
|
* assume they are actually equal.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
else if (device_aspect > desired_aspect)
|
|
|
|
{
|
|
|
|
delta = (desired_aspect / device_aspect - 1.0f)
|
|
|
|
/ 2.0f + 0.5f;
|
|
|
|
x = (int)roundf(width * (0.5f - delta));
|
|
|
|
width = (unsigned)roundf(2.0f * width * delta);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delta = (device_aspect / desired_aspect - 1.0f)
|
|
|
|
/ 2.0f + 0.5f;
|
|
|
|
y = (int)roundf(height * (0.5f - delta));
|
|
|
|
height = (unsigned)roundf(2.0f * height * delta);
|
|
|
|
}
|
2015-09-11 18:02:59 +02:00
|
|
|
|
2017-01-24 14:08:28 +01:00
|
|
|
if ( (vita->rotation == ORIENTATION_VERTICAL) ||
|
|
|
|
(vita->rotation == ORIENTATION_FLIPPED_ROTATED)
|
|
|
|
)
|
|
|
|
{
|
2021-05-22 17:28:53 +02:00
|
|
|
x = (temp_width - width) * 0.5f;
|
|
|
|
y = (temp_height - height) * 0.5f;
|
2017-01-24 14:08:28 +01:00
|
|
|
}
|
2015-09-09 01:10:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
vita->vp.x = x;
|
|
|
|
vita->vp.y = y;
|
|
|
|
vita->vp.width = width;
|
|
|
|
vita->vp.height = height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-18 14:51:40 +01:00
|
|
|
vita->vp.x = 0;
|
|
|
|
vita->vp.y = 0;
|
|
|
|
vita->vp.width = width;
|
2015-09-09 01:10:48 +02:00
|
|
|
vita->vp.height = height;
|
|
|
|
}
|
|
|
|
|
2020-02-18 14:51:40 +01:00
|
|
|
vita->vp.width += vita->vp.width&0x1;
|
|
|
|
vita->vp.height += vita->vp.height&0x1;
|
2015-09-09 01:10:48 +02:00
|
|
|
|
2020-02-18 14:51:40 +01:00
|
|
|
vita->should_resize = false;
|
2015-09-09 01:10:48 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width,
|
|
|
|
unsigned viewport_height, bool force_full, bool allow_rotate)
|
|
|
|
{
|
2020-02-18 14:51:40 +01:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
float device_aspect = (float)viewport_width / viewport_height;
|
|
|
|
struct video_ortho ortho = {0, 1, 0, 1, -1, 1};
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
bool video_scale_integer = settings->bools.video_scale_integer;
|
|
|
|
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
|
|
|
|
|
|
|
|
if (video_scale_integer && !force_full)
|
2016-08-23 02:49:53 +02:00
|
|
|
{
|
|
|
|
video_viewport_get_scaled_integer(&vita->vp,
|
|
|
|
viewport_width, viewport_height,
|
|
|
|
video_driver_get_aspect_ratio(), vita->keep_aspect);
|
|
|
|
viewport_width = vita->vp.width;
|
|
|
|
viewport_height = vita->vp.height;
|
|
|
|
}
|
|
|
|
else if (vita->keep_aspect && !force_full)
|
|
|
|
{
|
|
|
|
float desired_aspect = video_driver_get_aspect_ratio();
|
|
|
|
|
|
|
|
#if defined(HAVE_MENU)
|
2020-02-18 14:51:40 +01:00
|
|
|
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
2016-08-23 02:49:53 +02:00
|
|
|
{
|
|
|
|
const struct video_viewport *custom = video_viewport_get_custom();
|
|
|
|
|
|
|
|
x = custom->x;
|
|
|
|
y = custom->y;
|
|
|
|
viewport_width = custom->width;
|
|
|
|
viewport_height = custom->height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
float delta;
|
|
|
|
|
|
|
|
if (fabsf(device_aspect - desired_aspect) < 0.0001f)
|
|
|
|
{
|
2017-12-11 23:55:31 -08:00
|
|
|
/* If the aspect ratios of screen and desired aspect
|
|
|
|
* ratio are sufficiently equal (floating point stuff),
|
2016-08-23 02:49:53 +02:00
|
|
|
* assume they are actually equal.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
else if (device_aspect > desired_aspect)
|
|
|
|
{
|
2017-12-11 23:55:31 -08:00
|
|
|
delta = (desired_aspect / device_aspect - 1.0f)
|
2016-08-23 02:49:53 +02:00
|
|
|
/ 2.0f + 0.5f;
|
|
|
|
x = (int)roundf(viewport_width * (0.5f - delta));
|
|
|
|
viewport_width = (unsigned)roundf(2.0f * viewport_width * delta);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-11 23:55:31 -08:00
|
|
|
delta = (device_aspect / desired_aspect - 1.0f)
|
2016-08-23 02:49:53 +02:00
|
|
|
/ 2.0f + 0.5f;
|
|
|
|
y = (int)roundf(viewport_height * (0.5f - delta));
|
|
|
|
viewport_height = (unsigned)roundf(2.0f * viewport_height * delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vita->vp.x = x;
|
|
|
|
vita->vp.y = y;
|
|
|
|
vita->vp.width = viewport_width;
|
|
|
|
vita->vp.height = viewport_height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vita->vp.x = 0;
|
|
|
|
vita->vp.y = 0;
|
|
|
|
vita->vp.width = viewport_width;
|
|
|
|
vita->vp.height = viewport_height;
|
|
|
|
}
|
|
|
|
|
2019-12-14 14:11:09 +01:00
|
|
|
vita2d_set_viewport(vita->vp.x, vita->vp.y, vita->vp.width, vita->vp.height);
|
2016-08-23 02:49:53 +02:00
|
|
|
vita2d_set_projection(vita, &ortho, allow_rotate);
|
|
|
|
|
|
|
|
/* Set last backbuffer viewport. */
|
|
|
|
if (!force_full)
|
|
|
|
{
|
|
|
|
vita->vp.width = viewport_width;
|
|
|
|
vita->vp.height = viewport_height;
|
|
|
|
}
|
|
|
|
|
2017-01-24 14:08:28 +01:00
|
|
|
#if 0
|
|
|
|
vita->vp.x = (float)vita->vp.x;
|
2016-08-23 02:49:53 +02:00
|
|
|
vita->vp.y = (float)vita->vp.y;
|
|
|
|
vita->vp.width = (float)vita->vp.width;
|
|
|
|
vita->vp.height = (float)vita->vp.height;
|
|
|
|
vita->vp.minDepth = 0.0f;
|
2017-01-24 14:08:28 +01:00
|
|
|
vita->vp.maxDepth = 1.0f;
|
2016-08-23 02:49:53 +02:00
|
|
|
|
2017-01-24 14:08:28 +01:00
|
|
|
RARCH_LOG("Setting viewport @ %ux%u\n", viewport_width, viewport_height);
|
|
|
|
#endif
|
2016-08-23 02:49:53 +02:00
|
|
|
}
|
|
|
|
|
2015-08-30 20:04:52 +02:00
|
|
|
static void vita2d_gfx_set_rotation(void *data,
|
|
|
|
unsigned rotation)
|
|
|
|
{
|
2015-09-11 18:02:59 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
2019-12-14 14:11:09 +01:00
|
|
|
struct video_ortho ortho = {0, 1, 0, 1, -1, 1};
|
2015-09-11 18:02:59 +02:00
|
|
|
|
|
|
|
if (!vita)
|
|
|
|
return;
|
|
|
|
|
|
|
|
vita->rotation = rotation;
|
|
|
|
vita->should_resize = true;
|
2019-12-14 14:11:09 +01:00
|
|
|
vita2d_set_projection(vita, &ortho, true);
|
|
|
|
|
2015-08-30 20:04:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_gfx_viewport_info(void *data,
|
|
|
|
struct video_viewport *vp)
|
|
|
|
{
|
2015-09-09 01:10:48 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
|
|
|
|
if (vita)
|
|
|
|
*vp = vita->vp;
|
2015-08-30 20:04:52 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 23:36:22 -05:00
|
|
|
static void vita_set_filtering(void *data, unsigned index, bool smooth, bool ctx_scaling)
|
2015-08-31 00:55:34 +02:00
|
|
|
{
|
2015-09-14 03:50:34 +02:00
|
|
|
vita_video_t *vita = (vita_video_t *)data;
|
2015-09-08 20:40:38 +02:00
|
|
|
|
2015-09-14 03:50:34 +02:00
|
|
|
if (vita)
|
|
|
|
{
|
2017-12-11 23:55:31 -08:00
|
|
|
vita->tex_filter = smooth ?
|
2017-01-24 14:08:28 +01:00
|
|
|
SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT;
|
|
|
|
vita2d_texture_set_filters(vita->texture,vita->tex_filter,
|
|
|
|
vita->tex_filter);
|
2015-09-14 03:50:34 +02:00
|
|
|
}
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
|
2015-11-21 13:13:55 +01:00
|
|
|
static void vita_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
2015-08-31 00:55:34 +02:00
|
|
|
{
|
2016-05-05 01:59:05 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
2015-09-09 01:10:48 +02:00
|
|
|
|
2016-08-15 02:39:34 +02:00
|
|
|
if (!vita)
|
|
|
|
return;
|
2015-09-09 01:10:48 +02:00
|
|
|
vita->keep_aspect = true;
|
|
|
|
vita->should_resize = true;
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vita_apply_state_changes(void *data)
|
|
|
|
{
|
2015-09-09 01:10:48 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
|
|
|
|
if (vita)
|
|
|
|
vita->should_resize = true;
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2015-09-02 18:56:24 +02:00
|
|
|
unsigned int stride;
|
2015-08-31 00:55:34 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
|
|
|
|
(void)alpha;
|
|
|
|
|
2015-09-02 18:56:24 +02:00
|
|
|
if (width != vita->menu.width && height != vita->menu.height && vita->menu.texture)
|
2015-08-31 00:55:34 +02:00
|
|
|
{
|
2021-05-27 18:41:26 +02:00
|
|
|
vita2d_wait_rendering_done();
|
2015-09-02 18:56:24 +02:00
|
|
|
vita2d_free_texture(vita->menu.texture);
|
|
|
|
vita->menu.texture = NULL;
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
|
2015-09-02 18:56:24 +02:00
|
|
|
if (!vita->menu.texture)
|
2015-08-31 00:55:34 +02:00
|
|
|
{
|
|
|
|
if (rgb32)
|
|
|
|
{
|
2015-09-02 18:56:24 +02:00
|
|
|
vita->menu.texture = vita2d_create_empty_texture(width, height);
|
2017-01-24 14:08:28 +01:00
|
|
|
RARCH_LOG("Creating Frame RGBA8 texture: w: %i h: %i\n",
|
|
|
|
width, height);
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-24 14:08:28 +01:00
|
|
|
vita->menu.texture = vita2d_create_empty_texture_format(
|
|
|
|
width, height, SCE_GXM_TEXTURE_FORMAT_U4U4U4U4_RGBA);
|
|
|
|
RARCH_LOG("Creating Frame R5G6B5 texture: w: %i h: %i\n",
|
|
|
|
width, height);
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
2016-05-05 01:59:05 +02:00
|
|
|
vita->menu.width = width;
|
2015-08-31 00:55:34 +02:00
|
|
|
vita->menu.height = height;
|
|
|
|
}
|
2016-05-05 01:59:05 +02:00
|
|
|
|
2017-01-24 14:08:28 +01:00
|
|
|
vita2d_texture_set_filters(vita->menu.texture,
|
|
|
|
SCE_GXM_TEXTURE_FILTER_LINEAR,
|
|
|
|
SCE_GXM_TEXTURE_FILTER_LINEAR);
|
2016-05-05 01:59:05 +02:00
|
|
|
|
|
|
|
tex_p = vita2d_texture_get_datap(vita->menu.texture);
|
2015-09-02 18:56:24 +02:00
|
|
|
stride = vita2d_texture_get_stride(vita->menu.texture);
|
2015-08-31 00:55:34 +02:00
|
|
|
|
|
|
|
if (rgb32)
|
|
|
|
{
|
2015-09-05 16:22:25 +02:00
|
|
|
uint32_t *tex32 = tex_p;
|
|
|
|
const uint32_t *frame32 = frame;
|
|
|
|
|
2015-09-14 03:50:34 +02:00
|
|
|
stride /= 4;
|
|
|
|
|
2015-09-05 16:22:25 +02:00
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
tex32[j + i*stride] = frame32[j + i*width];
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-05 16:22:25 +02:00
|
|
|
uint16_t *tex16 = tex_p;
|
|
|
|
const uint16_t *frame16 = frame;
|
|
|
|
|
2015-09-14 03:50:34 +02:00
|
|
|
stride /= 2;
|
|
|
|
|
2015-09-05 16:22:25 +02:00
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
tex16[j + i*stride] = frame16[j + i*width];
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita_set_texture_enable(void *data, bool state, bool full_screen)
|
|
|
|
{
|
2015-08-31 19:37:02 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
2015-08-31 00:55:34 +02:00
|
|
|
(void)full_screen;
|
|
|
|
|
2015-08-31 19:37:02 +02:00
|
|
|
vita->menu.active = state;
|
2015-08-31 00:55:34 +02:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
static uintptr_t vita_load_texture(void *video_data, void *data,
|
|
|
|
bool threaded, enum texture_filter_type filter_type)
|
|
|
|
{
|
2016-10-17 18:39:10 +02:00
|
|
|
unsigned int stride, pitch, j;
|
2017-01-24 14:08:28 +01:00
|
|
|
uint32_t *tex32 = NULL;
|
|
|
|
const uint32_t *frame32 = NULL;
|
|
|
|
struct texture_image *image = (struct texture_image*)data;
|
2017-12-11 23:55:31 -08:00
|
|
|
struct vita2d_texture *texture = vita2d_create_empty_texture_format(image->width,
|
2016-08-23 02:49:53 +02:00
|
|
|
image->height,SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB);
|
2017-01-24 14:08:28 +01:00
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
if (!texture)
|
|
|
|
return 0;
|
|
|
|
|
2017-12-11 23:55:31 -08:00
|
|
|
if ((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) ||
|
2017-01-24 14:08:28 +01:00
|
|
|
(filter_type == TEXTURE_FILTER_LINEAR))
|
|
|
|
vita2d_texture_set_filters(texture,
|
|
|
|
SCE_GXM_TEXTURE_FILTER_LINEAR,
|
|
|
|
SCE_GXM_TEXTURE_FILTER_LINEAR);
|
2016-08-23 02:49:53 +02:00
|
|
|
|
2017-01-24 14:08:28 +01:00
|
|
|
stride = vita2d_texture_get_stride(texture);
|
2016-08-23 02:49:53 +02:00
|
|
|
stride /= 4;
|
2017-01-24 14:08:28 +01:00
|
|
|
|
|
|
|
tex32 = vita2d_texture_get_datap(texture);
|
|
|
|
frame32 = image->pixels;
|
|
|
|
pitch = image->width;
|
|
|
|
|
2016-08-23 02:49:53 +02:00
|
|
|
for (j = 0; j < image->height; j++)
|
2017-01-24 14:08:28 +01:00
|
|
|
memcpy_neon(
|
|
|
|
&tex32[j*stride],
|
|
|
|
&frame32[j*pitch],
|
|
|
|
pitch * sizeof(uint32_t));
|
2016-08-23 02:49:53 +02:00
|
|
|
|
|
|
|
return (uintptr_t)texture;
|
|
|
|
}
|
|
|
|
|
2020-07-27 10:15:28 +02:00
|
|
|
static void vita_unload_texture(void *data,
|
|
|
|
bool threaded, uintptr_t handle)
|
2016-08-23 02:49:53 +02:00
|
|
|
{
|
2017-01-24 14:08:28 +01:00
|
|
|
struct vita2d_texture *texture = (struct vita2d_texture*)handle;
|
2016-08-23 02:49:53 +02:00
|
|
|
if (!texture)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* TODO: We really want to defer this deletion instead,
|
|
|
|
* but this will do for now. */
|
|
|
|
vita2d_wait_rendering_done();
|
|
|
|
vita2d_free_texture(texture);
|
|
|
|
|
2020-07-27 10:15:28 +02:00
|
|
|
#if 0
|
|
|
|
free(texture);
|
|
|
|
#endif
|
2016-08-23 02:49:53 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 23:39:24 +02:00
|
|
|
static bool vita_get_current_sw_framebuffer(void *data,
|
|
|
|
struct retro_framebuffer *framebuffer)
|
|
|
|
{
|
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
|
|
|
|
if (!vita->texture || vita->width != framebuffer->width ||
|
|
|
|
vita->height != framebuffer->height)
|
|
|
|
{
|
2017-01-24 14:08:28 +01:00
|
|
|
if(vita->texture)
|
|
|
|
{
|
|
|
|
vita2d_wait_rendering_done();
|
|
|
|
vita2d_free_texture(vita->texture);
|
|
|
|
vita->texture = NULL;
|
2016-09-27 23:39:24 +02:00
|
|
|
}
|
2017-01-24 14:08:28 +01:00
|
|
|
|
2016-09-27 23:39:24 +02:00
|
|
|
vita->width = framebuffer->width;
|
|
|
|
vita->height = framebuffer->height;
|
2017-01-24 14:08:28 +01:00
|
|
|
vita->texture = vita2d_create_empty_texture_format(
|
|
|
|
vita->width, vita->height, vita->format);
|
|
|
|
vita2d_texture_set_filters(vita->texture,
|
|
|
|
vita->tex_filter,vita->tex_filter);
|
2016-09-27 23:39:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
framebuffer->data = vita2d_texture_get_datap(vita->texture);
|
|
|
|
framebuffer->pitch = vita2d_texture_get_stride(vita->texture);
|
2017-12-11 23:55:31 -08:00
|
|
|
framebuffer->format = vita->rgb32
|
2016-09-27 23:39:24 +02:00
|
|
|
? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565;
|
|
|
|
framebuffer->memory_flags = 0;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-05 13:46:26 +02:00
|
|
|
static uint32_t vita_get_flags(void *data)
|
|
|
|
{
|
|
|
|
uint32_t flags = 0;
|
|
|
|
|
|
|
|
BIT32_SET(flags, GFX_CTX_FLAGS_SCREENSHOTS_SUPPORTED);
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2015-08-31 00:55:34 +02:00
|
|
|
static const video_poke_interface_t vita_poke_interface = {
|
2019-05-05 13:46:26 +02:00
|
|
|
vita_get_flags,
|
2016-08-23 02:49:53 +02:00
|
|
|
vita_load_texture,
|
|
|
|
vita_unload_texture,
|
2015-08-31 00:55:34 +02:00
|
|
|
NULL,
|
2018-04-15 11:12:56 -05:00
|
|
|
NULL, /* get_refresh_rate */
|
2015-08-31 00:55:34 +02:00
|
|
|
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,
|
|
|
|
vita_set_texture_frame,
|
|
|
|
vita_set_texture_enable,
|
2020-01-04 16:24:14 +01:00
|
|
|
font_driver_render_msg,
|
2017-12-31 17:42:07 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
vita_get_current_sw_framebuffer,
|
2021-09-03 06:15:25 +02:00
|
|
|
NULL,
|
|
|
|
NULL, /* set_hdr_max_nits */
|
|
|
|
NULL, /* set_hdr_paper_white_nits */
|
|
|
|
NULL, /* set_hdr_contrast */
|
|
|
|
NULL /* set_hdr_expand_gamut */
|
2015-10-02 00:11:54 +02:00
|
|
|
};
|
2015-08-31 00:55:34 +02:00
|
|
|
|
2015-08-30 20:04:52 +02:00
|
|
|
static void vita2d_gfx_get_poke_interface(void *data,
|
|
|
|
const video_poke_interface_t **iface)
|
|
|
|
{
|
|
|
|
(void)data;
|
2015-08-31 00:55:34 +02:00
|
|
|
*iface = &vita_poke_interface;
|
2015-08-30 20:04:52 +02:00
|
|
|
}
|
|
|
|
|
2020-02-17 21:28:42 +01:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
2020-02-17 01:43:40 +01:00
|
|
|
static bool vita2d_gfx_gfx_widgets_enabled(void *data)
|
2019-12-14 14:11:09 +01:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-09-29 20:01:13 +02:00
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
static void vita2d_overlay_tex_geom(void *data, unsigned image, float x, float y, float w, float h);
|
|
|
|
static void vita2d_overlay_vertex_geom(void *data, unsigned image, float x, float y, float w, float h);
|
|
|
|
|
|
|
|
static bool vita2d_overlay_load(void *data, const void *image_data, unsigned num_images)
|
|
|
|
{
|
|
|
|
unsigned i,j,k;
|
|
|
|
unsigned int stride, pitch;
|
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
const struct texture_image *images = (const struct texture_image*)image_data;
|
|
|
|
|
|
|
|
vita2d_free_overlay(vita);
|
|
|
|
vita->overlay = (struct vita_overlay_data*)calloc(num_images, sizeof(*vita->overlay));
|
|
|
|
if (!vita->overlay)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
vita->overlays = num_images;
|
|
|
|
|
|
|
|
for (i = 0; i < num_images; i++)
|
|
|
|
{
|
|
|
|
struct vita_overlay_data *o = (struct vita_overlay_data*)&vita->overlay[i];
|
|
|
|
o->width = images[i].width;
|
|
|
|
o->height = images[i].height;
|
|
|
|
o->tex = vita2d_create_empty_texture_format(o->width , o->height, SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB);
|
|
|
|
vita2d_texture_set_filters(o->tex,SCE_GXM_TEXTURE_FILTER_LINEAR,SCE_GXM_TEXTURE_FILTER_LINEAR);
|
|
|
|
stride = vita2d_texture_get_stride(o->tex);
|
|
|
|
stride /= 4;
|
|
|
|
uint32_t *tex32 = vita2d_texture_get_datap(o->tex);
|
|
|
|
const uint32_t *frame32 = images[i].pixels;
|
|
|
|
pitch = o->width;
|
|
|
|
for (j = 0; j < o->height; j++)
|
|
|
|
for (k = 0; k < o->width; k++)
|
|
|
|
tex32[k + j*stride] = frame32[k + j*pitch];
|
2017-12-11 23:55:31 -08:00
|
|
|
|
2015-09-29 20:01:13 +02:00
|
|
|
vita2d_overlay_tex_geom(vita, i, 0, 0, 1, 1); /* Default. Stretch to whole screen. */
|
|
|
|
vita2d_overlay_vertex_geom(vita, i, 0, 0, 1, 1);
|
|
|
|
vita->overlay[i].alpha_mod = 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_overlay_tex_geom(void *data, unsigned image,
|
|
|
|
float x, float y, float w, float h)
|
|
|
|
{
|
2016-05-05 01:59:05 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
struct vita_overlay_data *o = NULL;
|
2015-09-29 20:01:13 +02:00
|
|
|
|
|
|
|
if (vita)
|
|
|
|
o = (struct vita_overlay_data*)&vita->overlay[image];
|
|
|
|
|
|
|
|
if (o)
|
|
|
|
{
|
|
|
|
o->tex_x = x;
|
|
|
|
o->tex_y = y;
|
|
|
|
o->tex_w = w*o->width;
|
|
|
|
o->tex_h = h*o->height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_overlay_vertex_geom(void *data, unsigned image,
|
|
|
|
float x, float y, float w, float h)
|
|
|
|
{
|
2016-05-05 01:59:05 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
struct vita_overlay_data *o = NULL;
|
2017-12-11 23:55:31 -08:00
|
|
|
|
2015-09-29 20:01:13 +02:00
|
|
|
/* Flipped, so we preserve top-down semantics. */
|
|
|
|
/*y = 1.0f - y;
|
|
|
|
h = -h;*/
|
|
|
|
|
|
|
|
if (vita)
|
|
|
|
o = (struct vita_overlay_data*)&vita->overlay[image];
|
|
|
|
|
|
|
|
if (o)
|
|
|
|
{
|
2021-05-22 17:28:53 +02:00
|
|
|
vita2d_video_mode_data video_mode_data = vita2d_get_video_mode_data();
|
|
|
|
o->w = w*video_mode_data.width/o->width;
|
|
|
|
o->h = h*video_mode_data.height/o->height;
|
|
|
|
o->x = video_mode_data.width*(1-w)/2+x;
|
|
|
|
o->y = video_mode_data.height*(1-h)/2+y;
|
2015-09-29 20:01:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_overlay_enable(void *data, bool state)
|
|
|
|
{
|
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
vita->overlay_enable = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_overlay_full_screen(void *data, bool enable)
|
|
|
|
{
|
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
vita->overlay_full_screen = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_overlay_set_alpha(void *data, unsigned image, float mod)
|
|
|
|
{
|
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
|
|
|
vita->overlay[image].alpha_mod = mod;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vita2d_render_overlay(void *data)
|
|
|
|
{
|
2016-05-05 01:59:05 +02:00
|
|
|
unsigned i;
|
2015-09-29 20:01:13 +02:00
|
|
|
vita_video_t *vita = (vita_video_t*)data;
|
2016-05-05 01:59:05 +02:00
|
|
|
|
|
|
|
for (i = 0; i < vita->overlays; i++)
|
2015-09-29 20:01:13 +02:00
|
|
|
{
|
2017-12-11 23:55:31 -08:00
|
|
|
vita2d_draw_texture_tint_part_scale(vita->overlay[i].tex,
|
|
|
|
vita->overlay[i].x,
|
|
|
|
vita->overlay[i].y,
|
|
|
|
vita->overlay[i].tex_x,
|
|
|
|
vita->overlay[i].tex_y,
|
|
|
|
vita->overlay[i].tex_w,
|
|
|
|
vita->overlay[i].tex_h,
|
|
|
|
vita->overlay[i].w,
|
2016-05-05 01:59:05 +02:00
|
|
|
vita->overlay[i].h,
|
|
|
|
RGBA8(0xFF,0xFF,0xFF,(uint8_t)(vita->overlay[i].alpha_mod * 255.0f)));
|
2015-09-29 20:01:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const video_overlay_interface_t vita2d_overlay_interface = {
|
|
|
|
vita2d_overlay_enable,
|
|
|
|
vita2d_overlay_load,
|
|
|
|
vita2d_overlay_tex_geom,
|
|
|
|
vita2d_overlay_vertex_geom,
|
|
|
|
vita2d_overlay_full_screen,
|
|
|
|
vita2d_overlay_set_alpha,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void vita2d_get_overlay_interface(void *data, const video_overlay_interface_t **iface)
|
|
|
|
{
|
|
|
|
*iface = &vita2d_overlay_interface;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-30 20:04:52 +02:00
|
|
|
video_driver_t video_vita2d = {
|
|
|
|
vita2d_gfx_init,
|
|
|
|
vita2d_gfx_frame,
|
|
|
|
vita2d_gfx_set_nonblock_state,
|
|
|
|
vita2d_gfx_alive,
|
|
|
|
vita2d_gfx_focus,
|
|
|
|
vita2d_gfx_suppress_screensaver,
|
2017-05-13 19:11:32 +02:00
|
|
|
NULL, /* has_windowed */
|
2015-08-30 20:04:52 +02:00
|
|
|
vita2d_gfx_set_shader,
|
|
|
|
vita2d_gfx_free,
|
|
|
|
"vita2d",
|
2016-08-23 02:49:53 +02:00
|
|
|
vita2d_gfx_set_viewport,
|
2015-08-30 20:04:52 +02:00
|
|
|
vita2d_gfx_set_rotation,
|
|
|
|
vita2d_gfx_viewport_info,
|
2019-05-22 07:07:33 +02:00
|
|
|
NULL, /* read_viewport */
|
2015-08-30 20:04:52 +02:00
|
|
|
NULL, /* read_frame_raw */
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-09-29 20:01:13 +02:00
|
|
|
vita2d_get_overlay_interface,
|
2019-04-01 04:00:58 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VIDEO_LAYOUT
|
|
|
|
NULL,
|
2015-08-30 20:04:52 +02:00
|
|
|
#endif
|
2015-08-31 15:26:37 +02:00
|
|
|
vita2d_gfx_get_poke_interface,
|
2019-12-14 14:11:09 +01:00
|
|
|
NULL,
|
2020-02-17 21:28:42 +01:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
2020-02-17 01:43:40 +01:00
|
|
|
vita2d_gfx_gfx_widgets_enabled
|
2019-12-14 14:11:09 +01:00
|
|
|
#endif
|
2015-08-30 20:04:52 +02:00
|
|
|
};
|