mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Merge pull request #3772 from aliaspider/master
(3DS) video driver updates.
This commit is contained in:
commit
679078ce01
@ -19,7 +19,7 @@ void dump_result_value(Result val);
|
||||
#define DEBUG_VAR(X) printf( "%-20s: 0x%08X\n", #X, (u32)(X))
|
||||
#define DEBUG_INT(X) printf( "%-20s: %10i\n", #X, (s32)(X))
|
||||
#define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016llX\n", (u64)(X))
|
||||
#define DEBUG_ERROR(X) do{if(X)dump_result_value(X)}while(0)
|
||||
#define DEBUG_ERROR(X) do{if(X)dump_result_value(X);}while(0)
|
||||
#define PRINTFPOS(X,Y) "\x1b["#X";"#Y"H"
|
||||
#define PRINTFPOS_STR(X,Y) "\x1b["X";"Y"H"
|
||||
#define PRINTF_LINE(X) "\x1b["X";0H"
|
||||
|
@ -137,7 +137,7 @@ extern const char* __system_arglist;
|
||||
char __argv_hmac[0x20] = {0x1d, 0x78, 0xff, 0xb9, 0xc5, 0xbc, 0x78, 0xb7, 0xac, 0x29, 0x1d, 0x3e, 0x16, 0xd0, 0xcf, 0x53,
|
||||
0xef, 0x12, 0x58, 0x83, 0xb6, 0x9e, 0x2f, 0x79, 0x47, 0xf9, 0x35, 0x61, 0xeb, 0x50, 0xd7, 0x67};
|
||||
|
||||
Result APT_ReceiveDeliverArg(void* param, size_t param_size, void* hmac, size_t hmac_size, u64* source_pid, bool* received)
|
||||
Result APT_ReceiveDeliverArg_(void* param, size_t param_size, void* hmac, size_t hmac_size, u64* source_pid, bool* received)
|
||||
{
|
||||
u32 cmdbuf[16];
|
||||
cmdbuf[0]=IPC_MakeHeader(0x35,2,0);
|
||||
@ -187,7 +187,7 @@ void __system_initArgv(void)
|
||||
bool received;
|
||||
|
||||
if(!__service_ptr
|
||||
&& R_SUCCEEDED(APT_ReceiveDeliverArg(¶m, sizeof(param), hmac, sizeof(hmac), NULL, &received))
|
||||
&& R_SUCCEEDED(APT_ReceiveDeliverArg_(¶m, sizeof(param), hmac, sizeof(hmac), NULL, &received))
|
||||
&& received
|
||||
&& !memcmp(hmac, __argv_hmac, sizeof(__argv_hmac)))
|
||||
arg_struct = (void*)param;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef CTR_COMMON_H__
|
||||
#define CTR_COMMON_H__
|
||||
|
||||
#include <retro_inline.h>
|
||||
|
||||
#define COLOR_ABGR(r, g, b, a) (((unsigned)(a) << 24) | ((b) << 16) | ((g) << 8) | ((r) << 0))
|
||||
|
||||
@ -89,6 +90,7 @@ typedef struct ctr_video
|
||||
|
||||
bool p3d_event_pending;
|
||||
bool ppf_event_pending;
|
||||
volatile bool vsync_event_pending;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -103,6 +105,9 @@ typedef struct ctr_texture
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int active_width;
|
||||
int active_height;
|
||||
|
||||
enum texture_filter_type type;
|
||||
void* data;
|
||||
} ctr_texture_t;
|
||||
|
@ -40,6 +40,9 @@
|
||||
#include "../../performance_counters.h"
|
||||
|
||||
#include "../common/ctr_common.h"
|
||||
#ifndef HAVE_THREADS
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#endif
|
||||
|
||||
static INLINE void ctr_check_3D_slider(ctr_video_t* ctr)
|
||||
{
|
||||
@ -269,6 +272,19 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ctr_vsync_hook(ctr_video_t* ctr)
|
||||
{
|
||||
ctr->vsync_event_pending = false;
|
||||
}
|
||||
#ifndef HAVE_THREADS
|
||||
static bool ctr_tasks_finder(retro_task_t *task,void *userdata)
|
||||
{
|
||||
return task;
|
||||
}
|
||||
task_finder_data_t ctr_tasks_finder_data = {ctr_tasks_finder, NULL};
|
||||
#endif
|
||||
|
||||
static void* ctr_init(const video_info_t* video,
|
||||
const input_driver_t** input, void** input_data)
|
||||
{
|
||||
@ -294,7 +310,7 @@ static void* ctr_init(const video_info_t* video,
|
||||
ctr->drawbuffers.top.left = vramAlloc(CTR_TOP_FRAMEBUFFER_WIDTH * CTR_TOP_FRAMEBUFFER_HEIGHT * 2 * sizeof(uint32_t));
|
||||
ctr->drawbuffers.top.right = (void*)((uint32_t*)ctr->drawbuffers.top.left + CTR_TOP_FRAMEBUFFER_WIDTH * CTR_TOP_FRAMEBUFFER_HEIGHT);
|
||||
|
||||
ctr->display_list_size = 0x10000;
|
||||
ctr->display_list_size = 0x4000;
|
||||
ctr->display_list = linearAlloc(ctr->display_list_size * sizeof(uint32_t));
|
||||
GPU_Reset(NULL, ctr->display_list, ctr->display_list_size);
|
||||
|
||||
@ -424,6 +440,8 @@ static void* ctr_init(const video_info_t* video,
|
||||
ctr->p3d_event_pending = false;
|
||||
ctr->ppf_event_pending = false;
|
||||
|
||||
gspSetEventCallback(GSPGPU_EVENT_VBlank0, (ThreadFunc)ctr_vsync_hook, ctr, false);
|
||||
|
||||
return ctr;
|
||||
}
|
||||
|
||||
@ -499,10 +517,23 @@ static bool ctr_frame(void* data, const void* frame,
|
||||
ctr->ppf_event_pending = false;
|
||||
}
|
||||
frames++;
|
||||
|
||||
#ifndef HAVE_THREADS
|
||||
if(task_queue_ctl(TASK_QUEUE_CTL_FIND, &ctr_tasks_finder_data))
|
||||
{
|
||||
// ctr->vsync_event_pending = true;
|
||||
while(ctr->vsync_event_pending)
|
||||
{
|
||||
task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL);
|
||||
svcSleepThread(0);
|
||||
// aptMainLoop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ctr->vsync)
|
||||
gspWaitForEvent(GSPGPU_EVENT_VBlank0, false);
|
||||
|
||||
ctr->vsync_event_pending = true;
|
||||
|
||||
currentTick = svcGetSystemTick();
|
||||
diff = currentTick - lastTick;
|
||||
if(diff > CTR_CPU_TICKS_PER_SECOND)
|
||||
@ -834,6 +865,7 @@ static void ctr_free(void* data)
|
||||
return;
|
||||
|
||||
aptUnhook(&ctr->lcd_aptHook);
|
||||
gspSetEventCallback(GSPGPU_EVENT_VBlank0, NULL, NULL, true);
|
||||
shaderProgramFree(&ctr->shader);
|
||||
DVLB_Free(ctr->dvlb);
|
||||
vramFree(ctr->drawbuffers.top.left);
|
||||
@ -849,7 +881,6 @@ static void ctr_free(void* data)
|
||||
linearFree(ctr);
|
||||
// gfxExit();
|
||||
}
|
||||
|
||||
static void ctr_set_texture_frame(void* data, const void* frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
@ -970,19 +1001,23 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
|
||||
{
|
||||
ctr_video_t* ctr = (ctr_video_t*)video_data;
|
||||
struct texture_image *image = (struct texture_image*)data;
|
||||
int size = image->width * image->height * sizeof(uint32_t);
|
||||
|
||||
if(!ctr || !image)
|
||||
if((size * 3) > linearSpaceFree())
|
||||
return 0;
|
||||
|
||||
if(!ctr || !image || image->width > 2048 || image->height > 2048)
|
||||
return 0;
|
||||
|
||||
ctr_texture_t* texture = calloc(1, sizeof(ctr_texture_t));
|
||||
uint32_t texsize = image->width * image->height * sizeof(uint32_t);
|
||||
|
||||
void* tmpdata;
|
||||
// texture->data = vramAlloc(image->width * image->height * sizeof(uint32_t));
|
||||
// if(!texture->data)
|
||||
texture->data = linearAlloc(image->width * image->height * sizeof(uint32_t));
|
||||
texture->width = next_pow2(image->width);
|
||||
texture->height = next_pow2(image->height);
|
||||
texture->active_width = image->width;
|
||||
texture->active_height = image->height;
|
||||
texture->data = linearAlloc(texture->width * texture->height * sizeof(uint32_t));
|
||||
texture->type = filter_type;
|
||||
texture->width = image->width;
|
||||
texture->height = image->height;
|
||||
|
||||
|
||||
if (!texture->data)
|
||||
@ -990,14 +1025,29 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
|
||||
free(texture);
|
||||
return 0;
|
||||
}
|
||||
if ((texture->width == 1) && (texture->height == 1))
|
||||
if ((image->width <= 32) || (image->height <= 32))
|
||||
{
|
||||
*(uint32_t*)texture->data = *image->pixels;
|
||||
int i, j;
|
||||
uint32_t* src = (uint32_t*)image->pixels;
|
||||
|
||||
for (j = 0; j < image->height; j++)
|
||||
for (i = 0; i < image->width; i++)
|
||||
{
|
||||
((uint32_t*)texture->data)[ctrgu_swizzle_coords(i, j, texture->width)] =
|
||||
((*src >> 8) & 0x00FF00) | ((*src >> 24) & 0xFF)| ((*src << 8) & 0xFF0000)| ((*src << 24) & 0xFF000000);
|
||||
src++;
|
||||
}
|
||||
GSPGPU_FlushDataCache(texture->data, texture->width * texture->height * sizeof(uint32_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpdata = linearAlloc(image->width * image->height * sizeof(uint32_t));
|
||||
// memcpy(tmpdata, image->pixels, image->width * image->height * sizeof(uint32_t));
|
||||
if (!tmpdata)
|
||||
{
|
||||
free(texture->data);
|
||||
free(texture);
|
||||
return 0;
|
||||
}
|
||||
int i;
|
||||
uint32_t* src = (uint32_t*)image->pixels;
|
||||
uint32_t* dst = (uint32_t*)tmpdata;
|
||||
@ -1010,7 +1060,6 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
|
||||
|
||||
|
||||
GSPGPU_FlushDataCache(tmpdata, image->width * image->height * sizeof(uint32_t));
|
||||
// printf("ctrGuCopyImage 0x%08X, %i, %i, 0x%08X, %i\n", tmpdata, image->width, image->height, texture->data, texture->width);
|
||||
ctrGuCopyImage(true, tmpdata, image->width, image->height, CTRGU_RGBA8, false,
|
||||
texture->data, texture->width, CTRGU_RGBA8, true);
|
||||
#if 0
|
||||
|
@ -237,4 +237,15 @@ static INLINE void ctrGuSetVshGsh(shaderProgram_s* sp, DVLB_s* dvlb, u32 vsh_out
|
||||
shaderProgramSetGsh(sp, &dvlb->DVLE[1], gsh_input_count);
|
||||
}
|
||||
|
||||
__attribute__((always_inline))
|
||||
static INLINE int ctrgu_swizzle_coords(int x, int y, int width)
|
||||
{
|
||||
int pos = (x & 0x1) << 0 | ((x & 0x2) << 1) | ((x & 0x4) << 2) |
|
||||
(y & 0x1) << 1 | ((y & 0x2) << 2) | ((y & 0x4) << 3);
|
||||
|
||||
|
||||
return ((x >> 3) << 6) + ((y >> 3) * ((width >> 3) << 6)) + pos;
|
||||
|
||||
}
|
||||
|
||||
#endif // CTR_GU_H
|
||||
|
@ -78,12 +78,7 @@ static void* ctr_font_init_font(void* data, const char* font_path, float font_si
|
||||
|
||||
for (j = 0; (j < atlas->height) && (j < font->texture.height); j++)
|
||||
for (i = 0; (i < atlas->width) && (i < font->texture.width); i++)
|
||||
{
|
||||
int pos = (i & 0x1) << 0 | ((i & 0x2) << 1) | ((i & 0x4) << 2) |
|
||||
(j & 0x1) << 1 | ((j & 0x2) << 2) | ((j & 0x4) << 3);
|
||||
|
||||
tmp[((i >> 3) << 6) + ((j >> 3) * ((font->texture.width >> 3) << 6)) + pos ] = src[i + j * atlas->width];
|
||||
}
|
||||
tmp[ctrgu_swizzle_coords(i, j, font->texture.width)] = src[i + j * atlas->width];
|
||||
|
||||
GSPGPU_FlushDataCache(tmp, font->texture.width * font->texture.height);
|
||||
|
||||
|
@ -2470,6 +2470,9 @@ static void xmb_layout_psp(xmb_handle_t *xmb, int width)
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
scale_factor = ((settings->menu.xmb.scale_factor * width) / (1920.0 * 100)) * 1.5;
|
||||
#ifdef _3DS
|
||||
scale_factor = settings->menu.xmb.scale_factor / 400.0;
|
||||
#endif
|
||||
|
||||
xmb->above_subitem_offset = 1.5;
|
||||
xmb->above_item_offset = -1.0;
|
||||
@ -2523,7 +2526,7 @@ static void xmb_layout(xmb_handle_t *xmb)
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
/* Mimic the layout of the PSP instead of the PS3 on tiny screens */
|
||||
if (width > 320)
|
||||
if (width > 320 && height > 240)
|
||||
xmb_layout_ps3(xmb, width);
|
||||
else
|
||||
xmb_layout_psp(xmb, width);
|
||||
|
@ -90,12 +90,12 @@ static void menu_display_ctr_draw(void *data)
|
||||
|
||||
v->x0 = draw->x;
|
||||
v->y0 = 240 - draw->height - draw->y;
|
||||
v->x1 = draw->x + draw->width;
|
||||
v->x1 = v->x0 + draw->width;
|
||||
v->y1 = v->y0 + draw->height;
|
||||
v->u0 = 0;
|
||||
v->v0 = 0;
|
||||
v->u1 = texture->width;
|
||||
v->v1 = texture->height;
|
||||
v->u1 = texture->active_width;
|
||||
v->v1 = texture->active_height;
|
||||
|
||||
ctrGuSetAttributeBuffers(2,
|
||||
VIRT_TO_PHYS(v),
|
||||
|
Loading…
x
Reference in New Issue
Block a user