diff --git a/Makefile.griffin b/Makefile.griffin index f949327859..ffdc147432 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -202,7 +202,7 @@ else ifeq ($(platform), vita) EXT_TARGET := $(TARGET_NAME)_$(platform).velf EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf MACHDEP := -DVITA - PLATCFLAGS := -O3 + PLATCFLAGS := -O3 -U__ARM_NEON__ LIBS += -lSceKernel_stub -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub \ -lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub \ -lScePower_stub -lSceRtc_stub -lz -lm -lc diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index 98d786e5b7..78c45f3781 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -52,7 +52,8 @@ static int audioMainLoop(SceSize args, void* argp) psp_audio_t* psp = *((psp_audio_t**)argp); #ifdef VITA - int port = sceAudioOutOpenPort(PSP2_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT, psp->rate, 2); + int port = sceAudioOutOpenPort(PSP2_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT, + psp->rate, PSP2_AUDIO_OUT_MODE_STEREO); #else sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2); #endif @@ -65,7 +66,7 @@ static int audioMainLoop(SceSize args, void* argp) < (AUDIO_OUT_COUNT * 2); #ifdef VITA - sceAudioOutOutput(0, + sceAudioOutOutput(port, cond ? psp->zeroBuffer : (psp->buffer + readPos)); #else sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer) diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 1818fb1410..5b0abe578c 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -30,8 +30,8 @@ typedef struct vita_menu_frame bool active; int width; int height; - vita2d_texture *frame; -} vita_menu_frame_t; + vita2d_texture *texture; +} vita_menu_t; typedef struct vita_video { @@ -51,7 +51,7 @@ typedef struct vita_video bool keep_aspect; bool should_resize; - vita_menu_frame_t menu; + vita_menu_t menu; } vita_video_t; static void *vita2d_gfx_init(const video_info_t *video, @@ -77,14 +77,20 @@ static void *vita2d_gfx_init(const video_info_t *video, vita2d_set_vblank_wait(video->vsync); if (vita->rgb32) + { + RARCH_LOG("Format: SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB\n"); vita->format = SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB; + } else + { + RARCH_LOG("Format: SCE_GXM_TEXTURE_FORMAT_R5G6B5\n"); vita->format = SCE_GXM_TEXTURE_FORMAT_R5G6B5; + } vita->fullscreen = video->fullscreen; vita->texture = NULL; - vita->menu.frame = NULL; + vita->menu.texture = NULL; vita->menu.active = 0; vita->menu.width = 0; vita->menu.height = 0; @@ -108,6 +114,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, { int i, j; void *tex_p; + unsigned int stride; vita_video_t *vita = (vita_video_t *)data; (void)frame; (void)width; @@ -125,31 +132,37 @@ static bool vita2d_gfx_frame(void *data, const void *frame, 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); } tex_p = vita2d_texture_get_datap(vita->texture); + stride = vita2d_texture_get_stride(vita->texture); - if (vita->format == SCE_GXM_TEXTURE_FORMAT_A8B8G8R8) + if (vita->format == SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB) { + stride /= 4; + pitch /= 4; + unsigned int *tex32 = tex_p; + const unsigned int *frame32 = frame; for (i = 0; i < height; i++) - for (j = 0; j < width; j++) - *(unsigned int *)(tex_p + (j + i*height) * 4) = *(unsigned int *)(frame + (j + i*height) * 4); + for (j = 0; j < width; j++) + tex32[j + i*stride] = frame32[j + i*pitch]; } else { - /*for (i = 0; i < height; i++) - for (j = 0; j < width; j++) - *(unsigned short *)(tex_p + (j + i*height) * 2) = *(unsigned short *)(frame + (j + i*height) * 2);*/ - memcpy(tex_p, frame, width*height*2); + stride /= 2; + pitch /= 2; + unsigned short *tex16 = tex_p; + const unsigned short *frame16 = frame; + for (i = 0; i < height; i++) + for (j = 0; j < width; j++) + tex16[j + i*stride] = frame16[j + i*pitch]; } } - // RARCH_LOG("w: %i h: %i pitch: %i\n", width, height, pitch); - // RARCH_LOG("msg: %s\n", msg); - vita2d_start_drawing(); vita2d_clear_screen(); @@ -179,10 +192,10 @@ static bool vita2d_gfx_frame(void *data, const void *frame, } } - if (vita->menu.active && vita->menu.frame) + if (vita->menu.active && vita->menu.texture) { if (vita->fullscreen) - vita2d_draw_texture_scale(vita->menu.frame, + vita2d_draw_texture_scale(vita->menu.texture, 0, 0, SCREEN_W/(float)vita->menu.width, SCREEN_H/(float)vita->menu.height); @@ -191,7 +204,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, { float scale = SCREEN_H/(float)vita->menu.height; float w = vita->menu.width * scale; - vita2d_draw_texture_scale(vita->menu.frame, + vita2d_draw_texture_scale(vita->menu.texture, SCREEN_W/2.0f - w/2.0f, 0.0f, scale, scale); } @@ -199,7 +212,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, { float scale = SCREEN_W/(float)vita->menu.width; float h = vita->menu.height * scale; - vita2d_draw_texture_scale(vita->menu.frame, + vita2d_draw_texture_scale(vita->menu.texture, 0.0f, SCREEN_H/2.0f - h/2.0f, scale, scale); } @@ -253,10 +266,12 @@ static void vita2d_gfx_free(void *data) RARCH_LOG("vita2d_gfx_free()\n"); - if (vita->menu.frame) + vita2d_fini(); + + if (vita->menu.texture) { - vita2d_free_texture(vita->menu.frame); - vita->menu.frame = NULL; + vita2d_free_texture(vita->menu.texture); + vita->menu.texture = NULL; } if (vita->texture) @@ -265,7 +280,7 @@ static void vita2d_gfx_free(void *data) vita->texture = NULL; } - vita2d_fini(); + RARCH_LOG("vita2d_gfx_free() done\n"); } static bool vita2d_gfx_set_shader(void *data, @@ -345,46 +360,53 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32, { int i, j; void *tex_p; + unsigned int stride; vita_video_t *vita = (vita_video_t*)data; (void)alpha; - if (width != vita->menu.width && height != vita->menu.height && vita->menu.frame) + if (width != vita->menu.width && height != vita->menu.height && vita->menu.texture) { - vita2d_free_texture(vita->menu.frame); - vita->menu.frame = NULL; + vita2d_free_texture(vita->menu.texture); + vita->menu.texture = NULL; } - if (!vita->menu.frame) + if (!vita->menu.texture) { if (rgb32) { - vita->menu.frame = vita2d_create_empty_texture(width, height); + vita->menu.texture = vita2d_create_empty_texture(width, height); RARCH_LOG("Creating Frame RGBA8 texture: w: %i h: %i\n", width, height); } else { - vita->menu.frame = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_FORMAT_U4U4U4U4_RGBA); + 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); } vita->menu.width = width; vita->menu.height = height; } - tex_p = vita2d_texture_get_datap(vita->menu.frame); + tex_p = vita2d_texture_get_datap(vita->menu.texture); + stride = vita2d_texture_get_stride(vita->menu.texture); if (rgb32) { - for (i = 0; i < height; i++) - for (j = 0; j < width; j++) - *(unsigned int *)(tex_p + (j + i*height) * 4) = *(unsigned int *)(frame + (j + i*height) * 4); + stride /= 4; + unsigned int *tex32 = tex_p; + const unsigned int *frame32 = frame; + for (i = 0; i < height; i++) + for (j = 0; j < width; j++) + tex32[j + i*stride] = frame32[j + i*width]; } else { - /*for (i = 0; i < height; i++) - for (j = 0; j < width; j++) - *(unsigned short *)(tex_p + (j + i*height) * 2) = *(unsigned short *)(frame + (j + i*height) * 2);*/ - memcpy(tex_p, frame, width*height*2); + stride /= 2; + unsigned short *tex16 = tex_p; + const unsigned short *frame16 = frame; + for (i = 0; i < height; i++) + for (j = 0; j < width; j++) + tex16[j + i*stride] = frame16[j + i*width]; } }