Merge pull request #12429 from libretro/pstv720p

[VITA] Support for 720p on PSTV when using unlock framebuffer in Sharpscale plugin
This commit is contained in:
Autechre 2021-05-22 18:51:38 +02:00 committed by GitHub
commit 76f3d0c1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 148 additions and 66 deletions

View File

@ -113,16 +113,18 @@ LD := $(CXX)
LIBDIRS := -L. LIBDIRS := -L.
ARCHFLAGS := -march=armv7-a -mfpu=neon -mfloat-abi=hard -DVITA -DSCE_LIBC_SIZE=$(SCE_LIBC_SIZE) ARCHFLAGS := -march=armv7-a -mfpu=neon -mfloat-abi=hard -DVITA -DSCE_LIBC_SIZE=$(SCE_LIBC_SIZE)
CFLAGS += $(ARCHFLAGS) -mword-relocations -fno-optimize-sibling-calls -O2 CFLAGS += $(ARCHFLAGS) -mword-relocations -fno-optimize-sibling-calls
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
CFLAGS += -g CFLAGS += -g -Og
else
CFLAGS += -O2
endif endif
ASFLAGS := $(CFLAGS) ASFLAGS := $(CFLAGS)
LDFLAGS := -Wl,-q LDFLAGS := -Wl,-q
CFLAGS += -Wall -ffast-math -g CFLAGS += -Wall -ffast-math
CFLAGS += -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DRARCH_CONSOLE CFLAGS += -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DRARCH_CONSOLE
CFLAGS += -DHAVE_DSP_FILTER CFLAGS += -DHAVE_DSP_FILTER
CFLAGS += -DHAVE_VIDEO_FILTER CFLAGS += -DHAVE_VIDEO_FILTER

View File

@ -11,6 +11,18 @@ extern "C" {
#define RGBA8(r,g,b,a) ((((a)&0xFF)<<24) | (((b)&0xFF)<<16) | (((g)&0xFF)<<8) | (((r)&0xFF)<<0)) #define RGBA8(r,g,b,a) ((((a)&0xFF)<<24) | (((b)&0xFF)<<16) | (((g)&0xFF)<<8) | (((r)&0xFF)<<0))
typedef enum
{
VITA2D_VIDEO_MODE_960x544 = 0,
VITA2D_VIDEO_MODE_1280x720
} vita2d_video_mode;
typedef struct vita2d_video_mode_data {
int width;
int height;
int stride;
} vita2d_video_mode_data;
typedef struct vita2d_clear_vertex { typedef struct vita2d_clear_vertex {
float x; float x;
float y; float y;
@ -58,7 +70,7 @@ typedef struct vita2d_pgf vita2d_pgf;
int vita2d_init(); int vita2d_init();
int vita2d_init_advanced(unsigned int temp_pool_size); int vita2d_init_advanced(unsigned int temp_pool_size);
int vita2d_init_advanced_with_msaa(unsigned int temp_pool_size, SceGxmMultisampleMode msaa); int vita2d_init_advanced_with_msaa(unsigned int temp_pool_size, SceGxmMultisampleMode msaa, vita2d_video_mode video_mode);
void vita2d_wait_rendering_done(); void vita2d_wait_rendering_done();
int vita2d_fini(); int vita2d_fini();
@ -74,8 +86,8 @@ int vita2d_common_dialog_update();
void vita2d_set_clear_color(unsigned int color); void vita2d_set_clear_color(unsigned int color);
unsigned int vita2d_get_clear_color(); unsigned int vita2d_get_clear_color();
void vita2d_set_clear_color(unsigned int color); vita2d_video_mode_data vita2d_get_video_mode_data();
unsigned int vita2d_get_clear_color();
void vita2d_set_vblank_wait(int enable); void vita2d_set_vblank_wait(int enable);
void *vita2d_get_current_fb(); void *vita2d_get_current_fb();
SceGxmContext *vita2d_get_context(); SceGxmContext *vita2d_get_context();

View File

@ -18,9 +18,6 @@
/* Defines */ /* Defines */
#define DISPLAY_WIDTH 960
#define DISPLAY_HEIGHT 544
#define DISPLAY_STRIDE_IN_PIXELS 1024
#define DISPLAY_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8 #define DISPLAY_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
#define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 #define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
#define DISPLAY_BUFFER_COUNT 3 #define DISPLAY_BUFFER_COUNT 3
@ -44,6 +41,9 @@ extern const SceGxmProgram texture_tint_f_gxp;
/* Static variables */ /* Static variables */
static vita2d_video_mode_data video_mode_data;
static vita2d_video_mode video_mode_initial;
static int pgf_module_was_loaded = 0; static int pgf_module_was_loaded = 0;
static const SceGxmProgram *const clearVertexProgramGxp = &clear_v_gxp; static const SceGxmProgram *const clearVertexProgramGxp = &clear_v_gxp;
@ -60,8 +60,8 @@ static float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
static unsigned int clear_color_u = 0xFF000000; static unsigned int clear_color_u = 0xFF000000;
static int clip_rect_x_min = 0; static int clip_rect_x_min = 0;
static int clip_rect_y_min = 0; static int clip_rect_y_min = 0;
static int clip_rect_x_max = DISPLAY_WIDTH; static int clip_rect_x_max = 0;
static int clip_rect_y_max = DISPLAY_HEIGHT; static int clip_rect_y_max = 0;
static int vblank_wait = 1; static int vblank_wait = 1;
static int drawing = 0; static int drawing = 0;
static int clipping_enabled = 0; static int clipping_enabled = 0;
@ -152,6 +152,40 @@ static void patcher_host_free(void *user_data, void *mem)
free(mem); free(mem);
} }
vita2d_video_mode_data vita2d_get_video_mode_data(){
return video_mode_data;
}
static int vita2d_switch_video_mode(vita2d_video_mode video_mode){
if(video_mode > video_mode_initial)
return -1;
switch (video_mode)
{
case VITA2D_VIDEO_MODE_960x544:
video_mode_data.width = 960;
video_mode_data.height = 544;
video_mode_data.stride = 1280;
break;
case VITA2D_VIDEO_MODE_1280x720:
video_mode_data.width = 1280;
video_mode_data.height = 720;
video_mode_data.stride = 1280;
break;
default:
return -1;
break;
}
clip_rect_x_max = video_mode_data.width;
clip_rect_y_max = video_mode_data.height;
matrix_init_orthographic(_vita2d_ortho_matrix, 0.0f, video_mode_data.width, video_mode_data.height, 0.0f, 0.0f, 1.0f);
return 0;
}
static void display_callback(const void *callback_data) static void display_callback(const void *callback_data)
{ {
SceDisplayFrameBuf framebuf; SceDisplayFrameBuf framebuf;
@ -160,11 +194,14 @@ static void display_callback(const void *callback_data)
memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf));
framebuf.size = sizeof(SceDisplayFrameBuf); framebuf.size = sizeof(SceDisplayFrameBuf);
framebuf.base = display_data->address; framebuf.base = display_data->address;
framebuf.pitch = DISPLAY_STRIDE_IN_PIXELS; framebuf.pitch = video_mode_data.stride;
framebuf.pixelformat = DISPLAY_PIXEL_FORMAT; framebuf.pixelformat = DISPLAY_PIXEL_FORMAT;
framebuf.width = DISPLAY_WIDTH; framebuf.width = video_mode_data.width;
framebuf.height = DISPLAY_HEIGHT; framebuf.height = video_mode_data.height;
sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME); if(sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME)<0){
if(video_mode_initial)
vita2d_switch_video_mode(VITA2D_VIDEO_MODE_960x544);
}
if (vblank_wait) { if (vblank_wait) {
sceDisplayWaitVblankStart(); sceDisplayWaitVblankStart();
@ -218,7 +255,7 @@ static void _vita2d_make_fragment_programs(vita2d_fragment_programs *out,
VITA2D_DEBUG("texture_tint sceGxmShaderPatcherCreateFragmentProgram(): 0x%08X\n", err); VITA2D_DEBUG("texture_tint sceGxmShaderPatcherCreateFragmentProgram(): 0x%08X\n", err);
} }
static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMode msaa) static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMode msaa, vita2d_video_mode video_mode)
{ {
int err; int err;
unsigned int i, x, y; unsigned int i, x, y;
@ -229,6 +266,14 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
return 1; return 1;
} }
video_mode_initial = video_mode;
err = vita2d_switch_video_mode(video_mode);
if(err<0){
VITA2D_DEBUG("vita2d_switch_video_mode(): 0x%08X\n", err);
return err;
}
SceGxmInitializeParams initializeParams; SceGxmInitializeParams initializeParams;
memset(&initializeParams, 0, sizeof(SceGxmInitializeParams)); memset(&initializeParams, 0, sizeof(SceGxmInitializeParams));
initializeParams.flags = 0; initializeParams.flags = 0;
@ -288,8 +333,8 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
SceGxmRenderTargetParams renderTargetParams; SceGxmRenderTargetParams renderTargetParams;
memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
renderTargetParams.flags = 0; renderTargetParams.flags = 0;
renderTargetParams.width = DISPLAY_WIDTH; renderTargetParams.width = video_mode_data.width;
renderTargetParams.height = DISPLAY_HEIGHT; renderTargetParams.height = video_mode_data.height;
renderTargetParams.scenesPerFrame = 1; renderTargetParams.scenesPerFrame = 1;
renderTargetParams.multisampleMode = msaa; renderTargetParams.multisampleMode = msaa;
renderTargetParams.multisampleLocations = 0; renderTargetParams.multisampleLocations = 0;
@ -304,15 +349,15 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
// allocate memory for display // allocate memory for display
displayBufferData[i] = gpu_alloc( displayBufferData[i] = gpu_alloc(
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
4*DISPLAY_STRIDE_IN_PIXELS*DISPLAY_HEIGHT, 4*video_mode_data.stride*video_mode_data.height,
SCE_GXM_COLOR_SURFACE_ALIGNMENT, SCE_GXM_COLOR_SURFACE_ALIGNMENT,
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
&displayBufferUid[i]); &displayBufferUid[i]);
// memset the buffer to black // memset the buffer to black
for (y = 0; y < DISPLAY_HEIGHT; y++) { for (y = 0; y < video_mode_data.height; y++) {
unsigned int *row = (unsigned int *)displayBufferData[i] + y*DISPLAY_STRIDE_IN_PIXELS; unsigned int *row = (unsigned int *)displayBufferData[i] + y*video_mode_data.stride;
for (x = 0; x < DISPLAY_WIDTH; x++) { for (x = 0; x < video_mode_data.width; x++) {
row[x] = 0xff000000; row[x] = 0xff000000;
} }
} }
@ -324,9 +369,9 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
SCE_GXM_COLOR_SURFACE_LINEAR, SCE_GXM_COLOR_SURFACE_LINEAR,
(msaa == SCE_GXM_MULTISAMPLE_NONE) ? SCE_GXM_COLOR_SURFACE_SCALE_NONE : SCE_GXM_COLOR_SURFACE_SCALE_MSAA_DOWNSCALE, (msaa == SCE_GXM_MULTISAMPLE_NONE) ? SCE_GXM_COLOR_SURFACE_SCALE_NONE : SCE_GXM_COLOR_SURFACE_SCALE_MSAA_DOWNSCALE,
SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
DISPLAY_WIDTH, video_mode_data.width,
DISPLAY_HEIGHT, video_mode_data.height,
DISPLAY_STRIDE_IN_PIXELS, video_mode_data.stride,
displayBufferData[i]); displayBufferData[i]);
// create a sync object that we will associate with this buffer // create a sync object that we will associate with this buffer
@ -334,8 +379,8 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
} }
// compute the memory footprint of the depth buffer // compute the memory footprint of the depth buffer
const unsigned int alignedWidth = ALIGN(DISPLAY_WIDTH, SCE_GXM_TILE_SIZEX); const unsigned int alignedWidth = ALIGN(video_mode_data.width, SCE_GXM_TILE_SIZEX);
const unsigned int alignedHeight = ALIGN(DISPLAY_HEIGHT, SCE_GXM_TILE_SIZEY); const unsigned int alignedHeight = ALIGN(video_mode_data.height, SCE_GXM_TILE_SIZEY);
unsigned int sampleCount = alignedWidth*alignedHeight; unsigned int sampleCount = alignedWidth*alignedHeight;
unsigned int depthStrideInSamples = alignedWidth; unsigned int depthStrideInSamples = alignedWidth;
if (msaa == SCE_GXM_MULTISAMPLE_4X) { if (msaa == SCE_GXM_MULTISAMPLE_4X) {
@ -713,9 +758,9 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
sizeof(void *), sizeof(void *),
SCE_GXM_MEMORY_ATTRIB_READ, SCE_GXM_MEMORY_ATTRIB_READ,
&poolUid); &poolUid);
matrix_init_orthographic(_vita2d_ortho_matrix, 0.0f, DISPLAY_WIDTH, DISPLAY_HEIGHT, 0.0f, 0.0f, 1.0f);
matrix_init_orthographic(_vita2d_ortho_matrix, 0.0f, video_mode_data.width, video_mode_data.height, 0.0f, 0.0f, 1.0f);
backBufferIndex = 0; backBufferIndex = 0;
frontBufferIndex = 0; frontBufferIndex = 0;
@ -725,23 +770,27 @@ static int vita2d_init_internal(unsigned int temp_pool_size, SceGxmMultisampleMo
if (pgf_module_was_loaded != SCE_SYSMODULE_LOADED) if (pgf_module_was_loaded != SCE_SYSMODULE_LOADED)
sceSysmoduleLoadModule(SCE_SYSMODULE_PGF); sceSysmoduleLoadModule(SCE_SYSMODULE_PGF);
vita2d_display_data displayData;
displayData.address = displayBufferData[backBufferIndex];
display_callback(&displayData);
vita2d_initialized = 1; vita2d_initialized = 1;
return 1; return 1;
} }
int vita2d_init() int vita2d_init()
{ {
return vita2d_init_internal(DEFAULT_TEMP_POOL_SIZE, SCE_GXM_MULTISAMPLE_NONE); return vita2d_init_internal(DEFAULT_TEMP_POOL_SIZE, SCE_GXM_MULTISAMPLE_NONE, VITA2D_VIDEO_MODE_960x544);
} }
int vita2d_init_advanced(unsigned int temp_pool_size) int vita2d_init_advanced(unsigned int temp_pool_size)
{ {
return vita2d_init_internal(temp_pool_size, SCE_GXM_MULTISAMPLE_NONE); return vita2d_init_internal(temp_pool_size, SCE_GXM_MULTISAMPLE_NONE, VITA2D_VIDEO_MODE_960x544);
} }
int vita2d_init_advanced_with_msaa(unsigned int temp_pool_size, SceGxmMultisampleMode msaa) int vita2d_init_advanced_with_msaa(unsigned int temp_pool_size, SceGxmMultisampleMode msaa, vita2d_video_mode video_mode)
{ {
return vita2d_init_internal(temp_pool_size, msaa); return vita2d_init_internal(temp_pool_size, msaa, video_mode);
} }
void vita2d_wait_rendering_done() void vita2d_wait_rendering_done()
@ -780,7 +829,7 @@ int vita2d_fini()
gpu_free(depthBufferUid); gpu_free(depthBufferUid);
for (i = 0; i < DISPLAY_BUFFER_COUNT; i++) { for (i = 0; i < DISPLAY_BUFFER_COUNT; i++) {
// clear the buffer then deallocate // clear the buffer then deallocate
memset(displayBufferData[i], 0, DISPLAY_HEIGHT*DISPLAY_STRIDE_IN_PIXELS*4); memset(displayBufferData[i], 0, video_mode_data.height*video_mode_data.stride*4);
gpu_free(displayBufferUid[i]); gpu_free(displayBufferUid[i]);
// destroy the sync object // destroy the sync object
@ -933,7 +982,7 @@ int vita2d_get_clipping_enabled()
void vita2d_set_clip_rectangle(int x_min, int y_min, int x_max, int y_max) void vita2d_set_clip_rectangle(int x_min, int y_min, int x_max, int y_max)
{ {
vita2d_set_viewport(0,0,DISPLAY_WIDTH,DISPLAY_HEIGHT); vita2d_set_viewport(0,0,video_mode_data.width,video_mode_data.height);
clipping_enabled = 1; clipping_enabled = 1;
clip_rect_x_min = x_min; clip_rect_x_min = x_min;
clip_rect_y_min = y_min; clip_rect_y_min = y_min;
@ -952,7 +1001,7 @@ void vita2d_set_clip_rectangle(int x_min, int y_min, int x_max, int y_max)
SCE_GXM_STENCIL_OP_ZERO, SCE_GXM_STENCIL_OP_ZERO,
0xFF, 0xFF,
0xFF); 0xFF);
vita2d_draw_rectangle(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, 0); vita2d_draw_rectangle(0, 0, video_mode_data.width, video_mode_data.height, 0);
// set the stencil to 1 in the desired region // set the stencil to 1 in the desired region
sceGxmSetFrontStencilFunc( sceGxmSetFrontStencilFunc(
_vita2d_context, _vita2d_context,
@ -1003,9 +1052,9 @@ int vita2d_common_dialog_update()
updateParam.renderTarget.colorFormat = DISPLAY_COLOR_FORMAT; updateParam.renderTarget.colorFormat = DISPLAY_COLOR_FORMAT;
updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR;
updateParam.renderTarget.width = DISPLAY_WIDTH; updateParam.renderTarget.width = video_mode_data.width;
updateParam.renderTarget.height = DISPLAY_HEIGHT; updateParam.renderTarget.height = video_mode_data.height;
updateParam.renderTarget.strideInPixels = DISPLAY_STRIDE_IN_PIXELS; updateParam.renderTarget.strideInPixels = video_mode_data.stride;
updateParam.renderTarget.colorSurfaceData = displayBufferData[backBufferIndex]; updateParam.renderTarget.colorSurfaceData = displayBufferData[backBufferIndex];
updateParam.renderTarget.depthSurfaceData = depthBufferData; updateParam.renderTarget.depthSurfaceData = depthBufferData;
@ -1100,7 +1149,7 @@ void vita2d_set_blend_mode_add(int enable)
} }
void vita2d_set_viewport(int x, int y, int width, int height){ void vita2d_set_viewport(int x, int y, int width, int height){
static float vh = DISPLAY_HEIGHT; float vh = video_mode_data.height;
float sw = width / 2.; float sw = width / 2.;
float sh = height / 2.; float sh = height / 2.;
float x_scale = sw; float x_scale = sw;

View File

@ -40,6 +40,7 @@
#include "../../configuration.h" #include "../../configuration.h"
#include <defines/psp_defines.h> #include <defines/psp_defines.h>
#include <psp2/kernel/sysmem.h>
extern void *memcpy_neon(void *dst, const void *src, size_t n); extern void *memcpy_neon(void *dst, const void *src, size_t n);
@ -50,8 +51,9 @@ static void *vita2d_gfx_init(const video_info_t *video,
input_driver_t **input, void **input_data) input_driver_t **input, void **input_data)
{ {
vita_video_t *vita = (vita_video_t *)calloc(1, sizeof(vita_video_t)); vita_video_t *vita = (vita_video_t *)calloc(1, sizeof(vita_video_t));
unsigned temp_width = PSP_FB_WIDTH; unsigned temp_width = PSP_FB_WIDTH;
unsigned temp_height = PSP_FB_HEIGHT; unsigned temp_height = PSP_FB_HEIGHT;
vita2d_video_mode_data video_mode_data = {0};
if (!vita) if (!vita)
return NULL; return NULL;
@ -63,7 +65,9 @@ static void *vita2d_gfx_init(const video_info_t *video,
RARCH_LOG("RARCH_SCALE_BASE: %i input_scale: %i = %i\n", RARCH_LOG("RARCH_SCALE_BASE: %i input_scale: %i = %i\n",
RARCH_SCALE_BASE, video->input_scale, RARCH_SCALE_BASE * video->input_scale); RARCH_SCALE_BASE, video->input_scale, RARCH_SCALE_BASE * video->input_scale);
vita2d_init();
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 );
vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF)); vita2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
vita2d_set_vblank_wait(video->vsync); vita2d_set_vblank_wait(video->vsync);
@ -78,6 +82,10 @@ static void *vita2d_gfx_init(const video_info_t *video,
vita->format = SCE_GXM_TEXTURE_FORMAT_R5G6B5; 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; vita->fullscreen = video->fullscreen;
vita->texture = NULL; vita->texture = NULL;
@ -146,6 +154,9 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
{ {
void *tex_p; void *tex_p;
vita_video_t *vita = (vita_video_t *)data; 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};
#ifdef HAVE_MENU #ifdef HAVE_MENU
bool menu_is_alive = video_info->menu_is_alive; bool menu_is_alive = video_info->menu_is_alive;
#endif #endif
@ -208,17 +219,21 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
if (vita->should_resize) if (vita->should_resize)
vita2d_gfx_update_viewport(vita, video_info); vita2d_gfx_update_viewport(vita, video_info);
video_mode_data = vita2d_get_video_mode_data();
temp_width = video_mode_data.width;
temp_height = video_mode_data.height;
vita2d_start_drawing(); vita2d_start_drawing();
vita2d_draw_rectangle(0,0,PSP_FB_WIDTH,PSP_FB_HEIGHT,vita2d_get_clear_color()); vita2d_draw_rectangle(0,0,temp_width,temp_height,vita2d_get_clear_color());
if (vita->texture) if (vita->texture)
{ {
if (vita->fullscreen) if (vita->fullscreen)
vita2d_draw_texture_scale(vita->texture, vita2d_draw_texture_scale(vita->texture,
0, 0, 0, 0,
PSP_FB_WIDTH / (float)vita->width, temp_width / (float)vita->width,
PSP_FB_HEIGHT / (float)vita->height); temp_height / (float)vita->height);
else else
{ {
const float radian = 270 * 0.0174532925f; const float radian = 270 * 0.0174532925f;
@ -241,24 +256,24 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
if (vita->fullscreen) if (vita->fullscreen)
vita2d_draw_texture_scale(vita->menu.texture, vita2d_draw_texture_scale(vita->menu.texture,
0, 0, 0, 0,
PSP_FB_WIDTH / (float)vita->menu.width, temp_width / (float)vita->menu.width,
PSP_FB_HEIGHT / (float)vita->menu.height); temp_height / (float)vita->menu.height);
else else
{ {
if (vita->menu.width > vita->menu.height) if (vita->menu.width > vita->menu.height)
{ {
float scale = PSP_FB_HEIGHT / (float)vita->menu.height; float scale = temp_height / (float)vita->menu.height;
float w = vita->menu.width * scale; float w = vita->menu.width * scale;
vita2d_draw_texture_scale(vita->menu.texture, vita2d_draw_texture_scale(vita->menu.texture,
PSP_FB_WIDTH / 2.0f - w/2.0f, 0.0f, temp_width / 2.0f - w/2.0f, 0.0f,
scale, scale); scale, scale);
} }
else else
{ {
float scale = PSP_FB_WIDTH / (float)vita->menu.width; float scale = temp_width / (float)vita->menu.width;
float h = vita->menu.height * scale; float h = vita->menu.height * scale;
vita2d_draw_texture_scale(vita->menu.texture, vita2d_draw_texture_scale(vita->menu.texture,
0.0f, PSP_FB_HEIGHT / 2.0f - h/2.0f, 0.0f, temp_height / 2.0f - h/2.0f,
scale, scale); scale, scale);
} }
} }
@ -373,19 +388,23 @@ static void vita2d_set_projection(vita_video_t *vita,
static void vita2d_gfx_update_viewport(vita_video_t* vita, static void vita2d_gfx_update_viewport(vita_video_t* vita,
video_frame_info_t *video_info) video_frame_info_t *video_info)
{ {
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 x = 0;
int y = 0; int y = 0;
float device_aspect = ((float)PSP_FB_WIDTH) / PSP_FB_HEIGHT; float device_aspect = ((float)temp_width) / temp_height;
float width = PSP_FB_WIDTH; float width = temp_width;
float height = PSP_FB_HEIGHT; float height = temp_height;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
bool video_scale_integer = settings->bools.video_scale_integer; bool video_scale_integer = settings->bools.video_scale_integer;
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
if (video_scale_integer) if (video_scale_integer)
{ {
video_viewport_get_scaled_integer(&vita->vp, PSP_FB_WIDTH, video_viewport_get_scaled_integer(&vita->vp, temp_width,
PSP_FB_HEIGHT, video_driver_get_aspect_ratio(), vita->keep_aspect); temp_height, video_driver_get_aspect_ratio(), vita->keep_aspect);
width = vita->vp.width; width = vita->vp.width;
height = vita->vp.height; height = vita->vp.height;
} }
@ -396,8 +415,8 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita,
(vita->rotation == ORIENTATION_FLIPPED_ROTATED)) (vita->rotation == ORIENTATION_FLIPPED_ROTATED))
{ {
device_aspect = 1.0 / device_aspect; device_aspect = 1.0 / device_aspect;
width = PSP_FB_HEIGHT; width = temp_height;
height = PSP_FB_WIDTH; height = temp_width;
} }
#if defined(HAVE_MENU) #if defined(HAVE_MENU)
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
@ -438,8 +457,8 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita,
(vita->rotation == ORIENTATION_FLIPPED_ROTATED) (vita->rotation == ORIENTATION_FLIPPED_ROTATED)
) )
{ {
x = (PSP_FB_WIDTH - width) * 0.5f; x = (temp_width - width) * 0.5f;
y = (PSP_FB_HEIGHT - height) * 0.5f; y = (temp_height - height) * 0.5f;
} }
} }
@ -896,11 +915,11 @@ static void vita2d_overlay_vertex_geom(void *data, unsigned image,
if (o) if (o)
{ {
vita2d_video_mode_data video_mode_data = vita2d_get_video_mode_data();
o->w = w*PSP_FB_WIDTH/o->width; o->w = w*video_mode_data.width/o->width;
o->h = h*PSP_FB_HEIGHT/o->height; o->h = h*video_mode_data.height/o->height;
o->x = PSP_FB_WIDTH*(1-w)/2+x; o->x = video_mode_data.width*(1-w)/2+x;
o->y = PSP_FB_HEIGHT*(1-h)/2+y; o->y = video_mode_data.height*(1-h)/2+y;
} }
} }