RetroArch/gfx/drivers/vita2d_gfx.c

1319 lines
38 KiB
C
Raw Normal View History

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/>.
*/
#include <vita2d.h>
2015-08-31 00:55:34 +02:00
#include <retro_inline.h>
#include <encodings/utf.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>
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"
#endif
#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"
#include "../../verbosity.h"
#include "../../configuration.h"
2017-01-17 18:12:23 +01:00
#include <defines/psp_defines.h>
#include <psp2/kernel/sysmem.h>
2016-09-11 14:46:53 +02:00
/*
* FORWARD DECLARATIONS
*/
2016-10-17 18:39:10 +02:00
extern void *memcpy_neon(void *dst, const void *src, size_t n);
static void vita2d_update_viewport(vita_video_t* vita,
video_frame_info_t *video_info);
static void vita2d_set_viewport_wrapper(void *data, unsigned viewport_width,
2016-08-23 02:49:53 +02:00
unsigned viewport_height, bool force_full, bool allow_rotate);
/*
* FONT DRIVER
*/
typedef struct
{
vita_video_t *vita;
vita2d_texture *texture;
const font_renderer_driver_t *font_driver;
void *font_data;
struct font_atlas *atlas;
} vita_font_t;
static void *vita2d_font_init(void *data,
const char *font_path, float font_size,
bool is_threaded)
{
unsigned int stride, pitch, j, k;
const uint8_t *frame32 = NULL;
uint8_t *tex32 = NULL;
const struct font_atlas *atlas = NULL;
vita_font_t *font = (vita_font_t*)calloc(1, sizeof(*font));
if (!font)
return NULL;
font->vita = (vita_video_t*)data;
if (!font_renderer_create_default(
&font->font_driver,
&font->font_data, font_path, font_size))
goto error;
font->atlas = font->font_driver->get_atlas(font->font_data);
atlas = font->atlas;
if (!atlas)
goto error;
font->texture = vita2d_create_empty_texture_format(
atlas->width,
atlas->height,
SCE_GXM_TEXTURE_FORMAT_U8_R111);
if (!font->texture)
goto error;
vita2d_texture_set_filters(font->texture,
SCE_GXM_TEXTURE_FILTER_POINT,
SCE_GXM_TEXTURE_FILTER_LINEAR);
stride = vita2d_texture_get_stride(font->texture);
tex32 = vita2d_texture_get_datap(font->texture);
frame32 = atlas->buffer;
pitch = atlas->width;
for (j = 0; j < atlas->height; j++)
for (k = 0; k < atlas->width; k++)
tex32[k + j * stride] = frame32[k + j*pitch];
font->atlas->dirty = false;
return font;
error:
free(font);
return NULL;
}
static void vita2d_font_free(void *data, bool is_threaded)
{
vita_font_t *font = (vita_font_t*)data;
if (!font)
return;
if (font->font_driver && font->font_data)
font->font_driver->free(font->font_data);
vita2d_wait_rendering_done();
vita2d_free_texture(font->texture);
free(font);
}
static int vita2d_font_get_message_width(void *data, const char *msg,
size_t msg_len, float scale)
{
int i;
const struct font_glyph* glyph_q = NULL;
int delta_x = 0;
vita_font_t *font = (vita_font_t*)data;
if (!font)
return 0;
glyph_q = font->font_driver->get_glyph(font->font_data, '?');
for (i = 0; i < msg_len; i++)
{
const struct font_glyph *glyph = NULL;
const char *msg_tmp = &msg[i];
unsigned code = utf8_walk(&msg_tmp);
unsigned skip = msg_tmp - &msg[i];
if (skip > 1)
i += skip - 1;
/* Do something smarter here ... */
if (!(glyph = font->font_driver->get_glyph(font->font_data, code)))
if (!(glyph = glyph_q))
continue;
delta_x += glyph->advance_x;
}
return delta_x * scale;
}
static void vita2d_font_render_line(
vita_font_t *font, const char *msg, size_t msg_len,
float scale, const unsigned int color, float pos_x,
float pos_y,
unsigned width, unsigned height, unsigned text_align)
{
int i;
const struct font_glyph* glyph_q = NULL;
int x = roundf(pos_x * width);
int y = roundf((1.0f - pos_y) * height);
int delta_x = 0;
int delta_y = 0;
switch (text_align)
{
case TEXT_ALIGN_RIGHT:
x -= vita2d_font_get_message_width(font, msg, msg_len, scale);
break;
case TEXT_ALIGN_CENTER:
x -= vita2d_font_get_message_width(font, msg, msg_len, scale) / 2;
break;
}
glyph_q = font->font_driver->get_glyph(font->font_data, '?');
for (i = 0; i < msg_len; i++)
{
int j, k;
int off_x, off_y, tex_x, tex_y, width, height;
const struct font_glyph *glyph = NULL;
const char *msg_tmp = &msg[i];
unsigned code = utf8_walk(&msg_tmp);
unsigned skip = msg_tmp - &msg[i];
if (skip > 1)
i += skip - 1;
/* Do something smarter here ... */
if (!(glyph = font->font_driver->get_glyph(font->font_data, code)))
if (!(glyph = glyph_q))
continue;
off_x = glyph->draw_offset_x;
off_y = glyph->draw_offset_y;
tex_x = glyph->atlas_offset_x;
tex_y = glyph->atlas_offset_y;
width = glyph->width;
height = glyph->height;
if (font->atlas->dirty)
{
unsigned int stride = vita2d_texture_get_stride(font->texture);
uint8_t *tex32 = vita2d_texture_get_datap(font->texture);
const uint8_t *frame32 = font->atlas->buffer;
unsigned int pitch = font->atlas->width;
for (j = 0; j < font->atlas->height; j++)
for (k = 0; k < font->atlas->width; k++)
tex32[k + j*stride] = frame32[k + j * pitch];
font->atlas->dirty = false;
}
vita2d_draw_texture_tint_part_scale(font->texture,
x + (off_x + delta_x) * scale,
y + (off_y + delta_y) * scale,
tex_x, tex_y, width, height,
scale,
scale,
color);
delta_x += glyph->advance_x;
delta_y += glyph->advance_y;
}
}
static void vita2d_font_render_message(
vita_font_t *font, const char *msg, float scale,
const unsigned int color, float pos_x, float pos_y,
unsigned width, unsigned height, unsigned text_align)
{
struct font_line_metrics *line_metrics = NULL;
int lines = 0;
float line_height;
if (!msg || !*msg)
return;
/* If font line metrics are not supported just draw as usual */
if (!font->font_driver->get_line_metrics ||
!font->font_driver->get_line_metrics(font->font_data, &line_metrics))
{
vita2d_font_render_line(font, msg, strlen(msg),
scale, color, pos_x, pos_y, width, height, text_align);
return;
}
line_height = line_metrics->height * scale / font->vita->vp.height;
for (;;)
{
const char *delim = strchr(msg, '\n');
size_t msg_len = (delim) ?
(delim - msg) : strlen(msg);
/* Draw the line */
vita2d_font_render_line(font, msg, msg_len,
scale, color, pos_x, pos_y - (float)lines * line_height,
width, height, text_align);
if (!delim)
break;
msg += msg_len + 1;
lines++;
}
}
static void vita2d_font_render_msg(
void *userdata,
void *data,
const char *msg,
const struct font_params *params)
{
int drop_x, drop_y;
unsigned color, r, g, b, alpha;
enum text_alignment text_align;
float x, y, scale, drop_mod, drop_alpha;
bool full_screen = false;
vita_video_t *vita = (vita_video_t *)userdata;
vita_font_t *font = (vita_font_t *)data;
unsigned width = vita->video_width;
unsigned height = vita->video_height;
if (!font || !msg || !*msg)
return;
if (params)
{
x = params->x;
y = params->y;
scale = params->scale;
full_screen = params->full_screen;
text_align = params->text_align;
drop_x = params->drop_x;
drop_y = params->drop_y;
drop_mod = params->drop_mod;
drop_alpha = params->drop_alpha;
r = FONT_COLOR_GET_RED(params->color);
g = FONT_COLOR_GET_GREEN(params->color);
b = FONT_COLOR_GET_BLUE(params->color);
alpha = FONT_COLOR_GET_ALPHA(params->color);
color = RGBA8(r,g,b,alpha);
}
else
{
settings_t *settings = config_get_ptr();
float video_msg_pos_x = settings->floats.video_msg_pos_x;
float video_msg_pos_y = settings->floats.video_msg_pos_y;
float video_msg_color_r = settings->floats.video_msg_color_r;
float video_msg_color_g = settings->floats.video_msg_color_g;
float video_msg_color_b = settings->floats.video_msg_color_b;
x = video_msg_pos_x;
y = video_msg_pos_y;
scale = 1.0f;
full_screen = true;
text_align = TEXT_ALIGN_LEFT;
r = (video_msg_color_r * 255);
g = (video_msg_color_g * 255);
b = (video_msg_color_b * 255);
alpha = 255;
color = RGBA8(r,g,b,alpha);
drop_x = -2;
drop_y = -2;
drop_mod = 0.3f;
drop_alpha = 1.0f;
}
vita2d_set_viewport_wrapper(font->vita, width, height, full_screen, false);
if (drop_x || drop_y)
{
unsigned r_dark = r * drop_mod;
unsigned g_dark = g * drop_mod;
unsigned b_dark = b * drop_mod;
unsigned alpha_dark = alpha * drop_alpha;
unsigned color_dark = RGBA8(r_dark,g_dark,b_dark,alpha_dark);
vita2d_font_render_message(font, msg, scale, color_dark,
x + scale * drop_x / width, y +
scale * drop_y / height, width, height, text_align);
}
vita2d_font_render_message(font, msg, scale,
color, x, y, width, height, text_align);
}
static const struct font_glyph *vita2d_font_get_glyph(
void *data, uint32_t code)
{
vita_font_t *font = (vita_font_t*)data;
if (font && font->font_driver && font->font_driver->ident)
return font->font_driver->get_glyph((void*)font->font_driver, code);
return NULL;
}
static bool vita2d_font_get_line_metrics(void* data, struct font_line_metrics **metrics)
{
vita_font_t *font = (vita_font_t*)data;
if (font && font->font_driver && font->font_data)
return font->font_driver->get_line_metrics(font->font_data, metrics);
return false;
}
font_renderer_t vita2d_vita_font = {
vita2d_font_init,
vita2d_font_free,
vita2d_font_render_msg,
"vita2d",
vita2d_font_get_glyph,
NULL, /* bind_block */
NULL, /* flush */
vita2d_font_get_message_width,
vita2d_font_get_line_metrics
};
/*
* VIDEO DRIVER
*/
static void *vita2d_init(const video_info_t *video,
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));
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;
*input = NULL;
*input_data = NULL;
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)
vita->format = SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB;
2015-08-31 00:55:34 +02:00
else
vita->format = SCE_GXM_TEXTURE_FORMAT_R5G6B5;
video_mode_data = vita2d_get_video_mode_data();
temp_width = video_mode_data.width;
temp_height = video_mode_data.height;
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
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;
video_driver_set_size(temp_width, temp_height);
vita2d_set_viewport_wrapper(vita, temp_width, temp_height, false, true);
2016-08-23 02:49:53 +02:00
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
vita->overlay_enable = false;
2015-09-29 20:01:13 +02:00
#endif
font_driver_init_osd(vita,
video,
false,
video->is_threaded,
FONT_DRIVER_RENDER_VITA2D);
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;
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
static bool vita2d_frame(void *data, const void *frame,
2015-08-30 20:04:52 +02:00
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
{
void *tex_p;
2020-08-03 16:33:54 +02:00
vita_video_t *vita = (vita_video_t *)data;
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
if (frame)
{
2023-02-23 13:15:14 +01:00
if (!(vita->texture&&vita2d_texture_get_datap(vita->texture)==frame))
2017-01-18 17:41:27 +01:00
{
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)
{
vita->width = width;
vita->height = height;
2017-01-18 17:41:27 +01:00
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-30 22:48:19 +02:00
2015-09-09 01:10:48 +02:00
if (vita->should_resize)
vita2d_update_viewport(vita, video_info);
2015-09-09 01:10:48 +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
vita2d_draw_rectangle(0,0,temp_width,temp_height,vita2d_get_clear_color());
2017-01-18 17:41:27 +01: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,
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
{
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
{
#ifdef HAVE_MENU
2020-05-19 16:20:43 +02:00
menu_driver_frame(menu_is_alive, video_info);
#endif
2017-01-18 17:41:27 +01:00
2023-02-23 13:15:14 +01:00
if (vita->menu.texture)
2017-01-24 14:08:28 +01:00
{
2017-01-18 17:41:27 +01:00
if (vita->fullscreen)
vita2d_draw_texture_scale(vita->menu.texture,
0, 0,
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)
{
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,
temp_width / 2.0f - w/2.0f, 0.0f,
2017-01-18 17:41:27 +01:00
scale, scale);
}
else
{
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,
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)
{
if (osd_params)
font_driver_render_msg(vita, video_info->stat_text,
2020-08-03 16:33:54 +02:00
osd_params, NULL);
}
2017-01-18 17:41:27 +01:00
2020-02-17 01:43:40 +01:00
#ifdef HAVE_OVERLAY
if (vita->overlay_enable)
vita2d_render_overlay(vita);
2020-02-17 01:43:40 +01:00
#endif
#ifdef HAVE_GFX_WIDGETS
2020-08-03 16:33:54 +02:00
if (widgets_active)
gfx_widgets_frame(video_info);
2020-02-17 01:43:40 +01:00
#endif
2023-02-23 13:15:14 +01:00
if (!string_is_empty(msg))
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;
}
static void vita2d_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_alive(void *data) { return true; }
static bool vita2d_focus(void *data) { return true; }
static bool vita2d_suppress_screensaver(void *a, bool b) { return false; }
2015-08-30 20:04:52 +02:00
static void vita2d_free(void *data)
2015-08-30 20:04:52 +02:00
{
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-02 18:56:24 +02:00
vita2d_free_texture(vita->menu.texture);
vita->menu.texture = NULL;
}
2015-08-31 00:55:34 +02:00
if (vita->texture)
{
vita2d_free_texture(vita->texture);
vita->texture = NULL;
}
2015-08-30 20:04:52 +02:00
font_driver_free_osd();
2015-08-30 20:04:52 +02:00
}
static bool vita2d_set_shader(void *data,
enum rarch_shader_type type, const char *path) { return false; }
2015-08-30 20:04:52 +02:00
2016-08-23 02:49:53 +02:00
static void vita2d_set_projection(vita_video_t *vita,
struct video_ortho *ortho, bool allow_rotate)
{
static math_matrix_4x4 rot = {
{ 0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 0.0f ,
0.0f, 0.0f, 0.0f, 1.0f }
};
float radians, cosine, sine;
2016-08-23 02:49:53 +02:00
/* Calculate projection. */
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;
}
radians = M_PI * vita->rotation / 180.0f;
cosine = cosf(radians);
sine = sinf(radians);
MAT_ELEM_4X4(rot, 0, 0) = cosine;
MAT_ELEM_4X4(rot, 0, 1) = -sine;
MAT_ELEM_4X4(rot, 1, 0) = sine;
MAT_ELEM_4X4(rot, 1, 1) = cosine;
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
}
static void vita2d_update_viewport(vita_video_t* vita,
video_frame_info_t *video_info)
2015-09-09 01:10:48 +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;
int x = 0;
int y = 0;
float device_aspect = ((float)temp_width) / temp_height;
float width = temp_width;
float height = temp_height;
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
{
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;
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)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
2015-09-09 01:10:48 +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
{
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)
)
{
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
{
vita->vp.x = 0;
vita->vp.y = 0;
vita->vp.width = width;
2015-09-09 01:10:48 +02:00
vita->vp.height = height;
}
vita->vp.width += vita->vp.width&0x1;
vita->vp.height += vita->vp.height&0x1;
2015-09-09 01:10:48 +02:00
vita->should_resize = false;
2015-09-09 01:10:48 +02:00
}
static void vita2d_set_viewport_wrapper(void *data, unsigned viewport_width,
2016-08-23 02:49:53 +02:00
unsigned viewport_height, bool force_full, bool allow_rotate)
{
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)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
2016-08-23 02:49:53 +02:00
{
2023-05-30 12:19:53 +02:00
video_viewport_t *custom_vp = &settings->video_viewport_custom;
x = custom_vp->x;
y = custom_vp->y;
viewport_width = custom_vp->width;
viewport_height = custom_vp->height;
2016-08-23 02:49:53 +02:00
}
else
#endif
{
float delta;
if (fabsf(device_aspect - desired_aspect) < 0.0001f)
{
/* 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)
{
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
{
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;
}
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;
}
}
static void vita2d_set_rotation(void *data,
2015-08-30 20:04:52 +02:00
unsigned rotation)
{
vita_video_t *vita = (vita_video_t*)data;
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;
vita2d_set_projection(vita, &ortho, true);
2015-08-30 20:04:52 +02:00
}
static void vita2d_viewport_info(void *data,
2015-08-30 20:04:52 +02:00
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
}
static void vita2d_set_filtering(void *data, unsigned index, bool smooth, bool ctx_scaling)
2015-08-31 00:55:34 +02:00
{
vita_video_t *vita = (vita_video_t *)data;
2015-09-08 20:40:38 +02:00
if (vita)
{
vita->tex_filter = smooth
? SCE_GXM_TEXTURE_FILTER_LINEAR
: SCE_GXM_TEXTURE_FILTER_POINT;
2017-01-24 14:08:28 +01:00
vita2d_texture_set_filters(vita->texture,vita->tex_filter,
vita->tex_filter);
}
2015-08-31 00:55:34 +02:00
}
static void vita2d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
2015-08-31 00:55:34 +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;
vita->keep_aspect = true;
2015-09-09 01:10:48 +02:00
vita->should_resize = true;
2015-08-31 00:55:34 +02:00
}
static void vita2d_apply_state_changes(void *data)
2015-08-31 00:55:34 +02:00
{
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 vita2d_set_texture_frame(void *data, const void *frame, bool rgb32,
2015-08-31 00:55:34 +02:00
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;
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);
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);
vita->menu.width = width;
vita->menu.height = height;
2015-08-31 00:55:34 +02:00
}
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;
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;
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 vita2d_set_texture_enable(void *data, bool state, bool full_screen)
2015-08-31 00:55:34 +02:00
{
2015-08-31 19:37:02 +02:00
vita_video_t *vita = (vita_video_t*)data;
vita->menu.active = state;
2015-08-31 00:55:34 +02:00
}
static uintptr_t vita2d_load_texture(void *video_data, void *data,
2016-08-23 02:49:53 +02:00
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;
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;
if ( (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR)
|| (filter_type == TEXTURE_FILTER_LINEAR))
2017-01-24 14:08:28 +01:00
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;
}
static void vita2d_unload_texture(void *data,
2020-07-27 10:15:28 +02:00
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
}
static bool vita2d_get_current_sw_framebuffer(void *data,
2016-09-27 23:39:24 +02:00
struct retro_framebuffer *framebuffer)
{
vita_video_t *vita = (vita_video_t*)data;
if ( !vita->texture
|| (vita->width != framebuffer->width)
|| (vita->height != framebuffer->height))
2016-09-27 23:39:24 +02:00
{
2023-02-23 13:15:14 +01:00
if (vita->texture)
2017-01-24 14:08:28 +01:00
{
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
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);
framebuffer->format = vita->rgb32
? RETRO_PIXEL_FORMAT_XRGB8888
: RETRO_PIXEL_FORMAT_RGB565;
2016-09-27 23:39:24 +02:00
framebuffer->memory_flags = 0;
return true;
}
static uint32_t vita2d_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 = {
vita2d_get_flags,
vita2d_load_texture,
vita2d_unload_texture,
2015-08-31 00:55:34 +02:00
NULL,
NULL, /* get_refresh_rate */
vita2d_set_filtering,
2015-08-31 00:55:34 +02:00
NULL, /* get_video_output_size */
NULL, /* get_video_output_prev */
NULL, /* get_video_output_next */
NULL, /* get_current_framebuffer */
NULL, /* get_proc_address */
vita2d_set_aspect_ratio,
vita2d_apply_state_changes,
vita2d_set_texture_frame,
vita2d_set_texture_enable,
font_driver_render_msg,
2017-12-31 17:42:07 +01:00
NULL,
NULL,
NULL,
vita2d_get_current_sw_framebuffer,
Add HDR support for D3D12 (rebased PR from MajorPainTheCactus) (#12917) * Add HDR support * Attempt to fix Mingw build and Metal builds * (D3D12) Fix relative header includes * Add missing hdr_sm5.hlsl.h * (d3d12_common.c) Some C89 build fixes * Fix MSVC build * - Attempt to fix build on mingw/msys unix with dirty hack - Fix shader compilation of hdr_sm5.hlsl.h on MSVC/Visual Studio - the define was seen as an error and was causing the first pipeline to error out - Make sure we manually set handle of backBuffer to NULL * Moving the release of the texture above the freeing of desc.srv_heap and desc.rtv_heap solves the hard crashes on teardown/setup in RA - it was crashing hard in d3d12_release_texture before * Add HAVE_D3D12_HDR ifdef - needs to be disabled for WinRT for now because of several things that are Windows desktop-specific right now (GetWindowRect) * Add dirty GUID hack - should work for both mingw/msys on Windows/Linux as well as MSVC/Visual Studio (hopefully) * Change HAVE_D3D12_HDR to HAVE_DXGI_HDR * Move away from camelcase named variables * Fix RARCH_ERR logs - they need a newline at the end * d3d12_check_display_hdr_support - make it return a bool on return and set d3d12->hdr.support and d3d12->hdr.enable outside of the function * (DXGI) Remove D3D12 dependencies from dxgi_check_display_hdr_support and move it to dxgi_common.c instead * (DXGI) move d3d12_swapchain_color_space over to dxgi_common.c and rename it dxgi_swapchain_color_space * (DXGI) move d3d12_set_hdr_metadata to dxgi_common.c and rename it dxgi_set_hdr_metadata * (DXGI) dxgi_check_display_hdr_support - better error handling? * Fix typo * Remove video_force_resolution * (D3D12) Address TODO/FIXME * (D3D12) Backport https://github.com/libretro/RetroArch/pull/12916/commits/c1b6c0bff2aa33cde035b43cb31ac7e78ff2a07a - Fixed resource transition for present when HDR is off Fixed cel shader displaying all black as blending was enabled when the hdr shader was being applied - turned off blending during this shader * Move d3d12_hdr_uniform_t to dxgi_common.h and rename it dxgi_hdr_uniform_t * (D3D11) Add HDR support * Add TODO/FIXME notes * Cache hdr_enable in video_frame_info_t * Update comment
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
static void vita2d_get_poke_interface(void *data,
2015-08-30 20:04:52 +02:00
const video_poke_interface_t **iface)
{
2015-08-31 00:55:34 +02:00
*iface = &vita_poke_interface;
2015-08-30 20:04:52 +02:00
}
#ifdef HAVE_GFX_WIDGETS
static bool vita2d_widgets_enabled(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++)
{
uint32_t *tex32;
const uint32_t *frame32;
2015-09-29 20:01:13 +02:00
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);
2015-09-29 20:01:13 +02:00
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;
tex32 = vita2d_texture_get_datap(o->tex);
frame32 = images[i].pixels;
pitch = o->width;
2015-09-29 20:01:13 +02:00
for (j = 0; j < o->height; j++)
for (k = 0; k < o->width; k++)
tex32[k + j*stride] = frame32[k + j*pitch];
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;
2015-09-29 20:01:13 +02:00
/* Flipped, so we preserve top-down semantics. */
/* y = 1.0f - y;
h = -h;
*/
2015-09-29 20:01:13 +02:00
if (vita)
o = (struct vita_overlay_data*)&vita->overlay[image];
if (o)
{
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;
2015-09-29 20:01:13 +02:00
vita->overlay_enable = state;
}
static void vita2d_overlay_full_screen(void *data, bool enable)
{
vita_video_t *vita = (vita_video_t*)data;
2015-09-29 20:01:13 +02:00
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;
2015-09-29 20:01:13 +02:00
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
{
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_init,
vita2d_frame,
vita2d_set_nonblock_state,
vita2d_alive,
vita2d_focus,
vita2d_suppress_screensaver,
NULL, /* has_windowed */
vita2d_set_shader,
vita2d_free,
2015-08-30 20:04:52 +02:00
"vita2d",
vita2d_set_viewport_wrapper,
vita2d_set_rotation,
vita2d_viewport_info,
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,
2015-08-30 20:04:52 +02:00
#endif
vita2d_get_poke_interface,
NULL,
#ifdef HAVE_GFX_WIDGETS
vita2d_widgets_enabled
#endif
2015-08-30 20:04:52 +02:00
};