mirror of
https://github.com/libretro/RetroArch
synced 2025-02-08 15:40:14 +00:00
[PSL1GHT] Add RSX graphics support for ps3
This commit is contained in:
parent
1250ecbc46
commit
4d367a2b59
@ -73,6 +73,18 @@ SYS_PROCESS_PARAM(1001, 0x200000)
|
||||
static bool multiman_detected = false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMINFO
|
||||
typedef struct {
|
||||
uint32_t total;
|
||||
uint32_t avail;
|
||||
} sys_memory_info_t;
|
||||
#ifdef __PSL1GHT__
|
||||
#define sys_memory_get_user_memory_size(x) lv2syscall1(352, x)
|
||||
#else
|
||||
#define sys_memory_get_user_memory_size(x) system_call_1(352, x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
static enum frontend_fork ps3_fork_mode = FRONTEND_FORK_NONE;
|
||||
|
||||
@ -365,6 +377,11 @@ static void frontend_ps3_init(void *data)
|
||||
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIGHTGUN
|
||||
cellSysmoduleLoadModule(SYSMODULE_GEM);
|
||||
cellSysmoduleLoadModule(SYSMODULE_CAMERA);
|
||||
#endif
|
||||
|
||||
#ifndef __PSL1GHT__
|
||||
sys_net_initialize_network();
|
||||
sceNpInit(NP_POOL_SIZE, np_pool);
|
||||
@ -674,6 +691,22 @@ static void frontend_ps3_process_args(int *argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_MEMINFO
|
||||
static size_t frontend_ps3_get_mem_total(void)
|
||||
{
|
||||
sys_memory_info_t mem_info;
|
||||
sys_memory_get_user_memory_size(&mem_info);
|
||||
return mem_info.total;
|
||||
}
|
||||
|
||||
static size_t frontend_ps3_get_mem_used(void)
|
||||
{
|
||||
sys_memory_info_t mem_info;
|
||||
sys_memory_get_user_memory_size(&mem_info);
|
||||
return mem_info.avail;
|
||||
}
|
||||
#endif
|
||||
|
||||
frontend_ctx_driver_t frontend_ctx_ps3 = {
|
||||
frontend_ps3_get_env,
|
||||
frontend_ps3_init,
|
||||
@ -694,8 +727,13 @@ frontend_ctx_driver_t frontend_ctx_ps3 = {
|
||||
frontend_ps3_get_arch, /* get_architecture */
|
||||
NULL, /* get_powerstate */
|
||||
frontend_ps3_parse_drive_list,/* parse_drive_list */
|
||||
#ifdef HAVE_MEMINFO
|
||||
frontend_ps3_get_mem_total,
|
||||
frontend_ps3_get_mem_used,
|
||||
#else
|
||||
NULL, /* get_total_mem */
|
||||
NULL, /* get_free_mem */
|
||||
#endif
|
||||
NULL, /* install_signal_handler */
|
||||
NULL, /* get_sighandler_state */
|
||||
NULL, /* set_sighandler_state */
|
||||
|
149
gfx/common/rsx_common.h
Normal file
149
gfx/common/rsx_common.h
Normal file
@ -0,0 +1,149 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef RSX_COMMON_H__
|
||||
#define RSX_COMMON_H__
|
||||
|
||||
#include <rsx/rsx.h>
|
||||
#include <rsx/nv40.h>
|
||||
#include <ppu-types.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <gfx/math/matrix_4x4.h>
|
||||
|
||||
#include <defines/ps3_defines.h>
|
||||
#include "../../driver.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../video_coord_array.h"
|
||||
|
||||
#define MAX_BUFFERS 2
|
||||
#define MAX_MENU_BUFFERS 2
|
||||
|
||||
/* Shader objects */
|
||||
extern const u8 vpshader_basic_vpo_end[];
|
||||
extern const u8 vpshader_basic_vpo[];
|
||||
extern const u32 vpshader_basic_vpo_size;
|
||||
|
||||
extern const u8 fpshader_basic_fpo_end[];
|
||||
extern const u8 fpshader_basic_fpo[];
|
||||
extern const u32 fpshader_basic_fpo_size;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x, y;
|
||||
float w, h;
|
||||
float min, max;
|
||||
float scale[4];
|
||||
float offset[4];
|
||||
} rsx_viewport_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x, y, z;
|
||||
float nx, ny, nz;
|
||||
float u, v;
|
||||
float r, g, b, a;
|
||||
} rsx_vertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gcmTexture tex;
|
||||
u32 *data;
|
||||
u32 offset;
|
||||
u32 wrap_s;
|
||||
u32 wrap_t;
|
||||
u32 min_filter;
|
||||
u32 mag_filter;
|
||||
u32 width;
|
||||
u32 height;
|
||||
} rsx_texture_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int height;
|
||||
int width;
|
||||
int id;
|
||||
uint32_t *ptr;
|
||||
/* Internal stuff */
|
||||
uint32_t offset;
|
||||
} rsxBuffer;
|
||||
|
||||
typedef struct {
|
||||
video_viewport_t vp;
|
||||
rsxBuffer buffers[MAX_BUFFERS];
|
||||
#if defined(HAVE_MENU_BUFFER)
|
||||
rsxBuffer menuBuffers[MAX_MENU_BUFFERS];
|
||||
int menuBuffer;
|
||||
#endif
|
||||
int currentBuffer, nextBuffer;
|
||||
gcmContextData* context;
|
||||
u16 width;
|
||||
u16 height;
|
||||
u16 menu_width;
|
||||
u16 menu_height;
|
||||
bool menu_frame_enable;
|
||||
bool rgb32;
|
||||
bool vsync;
|
||||
u32 depth_pitch;
|
||||
u32 depth_offset;
|
||||
u32* depth_buffer;
|
||||
|
||||
#if defined(HAVE_MENU_BUFFER)
|
||||
gcmSurface surface[MAX_BUFFERS+MAX_MENU_BUFFERS];
|
||||
#else
|
||||
gcmSurface surface[MAX_BUFFERS];
|
||||
#endif
|
||||
rsx_texture_t texture;
|
||||
rsx_texture_t menu_texture;
|
||||
rsx_vertex_t *vertices;
|
||||
u32 pos_offset;
|
||||
u32 uv_offset;
|
||||
u32 col_offset;
|
||||
rsxProgramConst *proj_matrix;
|
||||
rsxProgramAttrib* pos_index;
|
||||
rsxProgramAttrib* col_index;
|
||||
rsxProgramAttrib* uv_index;
|
||||
rsxProgramAttrib* tex_unit;
|
||||
void *vp_ucode;
|
||||
void *fp_ucode;
|
||||
rsxVertexProgram *vpo;
|
||||
rsxFragmentProgram *fpo;
|
||||
u32 *fp_buffer;
|
||||
u32 fp_offset;
|
||||
math_matrix_4x4 mvp, mvp_no_rot;
|
||||
float menu_texture_alpha;
|
||||
|
||||
bool smooth;
|
||||
unsigned rotation;
|
||||
bool keep_aspect;
|
||||
bool should_resize;
|
||||
bool msg_rendering_enabled;
|
||||
|
||||
const shader_backend_t* shader;
|
||||
void* shader_data;
|
||||
void* renderchain_data;
|
||||
void* ctx_data;
|
||||
const gfx_ctx_driver_t* ctx_driver;
|
||||
bool shared_context_use;
|
||||
|
||||
video_info_t video_info;
|
||||
struct video_tex_info tex_info; /* unsigned int alignment */
|
||||
struct video_tex_info prev_info[GFX_MAX_TEXTURES]; /* unsigned alignment */
|
||||
struct video_fbo_rect fbo_rect[GFX_MAX_SHADERS]; /* unsigned alignment */
|
||||
} rsx_t;
|
||||
|
||||
#endif
|
@ -29,6 +29,11 @@
|
||||
#include "../../menu/menu_driver.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
#include "../gfx_widgets.h"
|
||||
#endif
|
||||
|
||||
#include "../common/rsx_common.h"
|
||||
#include "../font_driver.h"
|
||||
|
||||
#include "../../configuration.h"
|
||||
@ -63,69 +68,15 @@
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#define MAX_BUFFERS 2
|
||||
|
||||
#define rsx_context_bind_hw_render(rsx, enable) \
|
||||
if (rsx->shared_context_use) \
|
||||
rsx->ctx_driver->bind_hw_render(rsx->ctx_data, enable)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int height;
|
||||
int width;
|
||||
int id;
|
||||
uint32_t *ptr;
|
||||
/* Internal stuff */
|
||||
uint32_t offset;
|
||||
} rsxBuffer;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float v;
|
||||
float u;
|
||||
float y;
|
||||
float x;
|
||||
} rsx_scale_vector_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s16 x0, y0, x1, y1;
|
||||
s16 u0, v0, u1, v1;
|
||||
} rsx_vertex_t;
|
||||
|
||||
typedef struct {
|
||||
video_viewport_t vp;
|
||||
rsxBuffer buffers[MAX_BUFFERS];
|
||||
rsxBuffer menuBuffers[MAX_BUFFERS];
|
||||
int currentBuffer, menuBuffer;
|
||||
gcmContextData* context;
|
||||
u16 width;
|
||||
u16 height;
|
||||
bool menu_frame_enable;
|
||||
bool rgb32;
|
||||
bool vsync;
|
||||
u32 depth_pitch;
|
||||
u32 depth_offset;
|
||||
u32* depth_buffer;
|
||||
|
||||
bool smooth;
|
||||
unsigned rotation;
|
||||
bool keep_aspect;
|
||||
bool should_resize;
|
||||
bool msg_rendering_enabled;
|
||||
|
||||
const shader_backend_t* shader;
|
||||
void* shader_data;
|
||||
void* renderchain_data;
|
||||
void* ctx_data;
|
||||
const gfx_ctx_driver_t* ctx_driver;
|
||||
bool shared_context_use;
|
||||
|
||||
video_info_t video_info;
|
||||
struct video_tex_info tex_info; /* unsigned int alignment */
|
||||
struct video_tex_info prev_info[GFX_MAX_TEXTURES]; /* unsigned alignment */
|
||||
struct video_fbo_rect fbo_rect[GFX_MAX_SHADERS]; /* unsigned alignment */
|
||||
} rsx_t;
|
||||
static void rsx_set_viewport(void *data, unsigned viewport_width,
|
||||
unsigned viewport_height, bool force_full, bool allow_rotate);
|
||||
static void rsx_load_texture_data(rsx_t* rsx, rsx_texture_t *texture,
|
||||
const void *frame, unsigned width, unsigned height, unsigned pitch,
|
||||
bool rgb32, bool menu, enum texture_filter_type filter_type);
|
||||
|
||||
static const gfx_ctx_driver_t* rsx_get_context(rsx_t* rsx)
|
||||
{
|
||||
@ -327,6 +278,106 @@ static void rsx_wait_rsx_idle(gcmContextData *context)
|
||||
waitFinish(context, sLabelVal);
|
||||
}
|
||||
|
||||
static void rsx_init_render_target(rsx_t *rsx, rsxBuffer * buffer, int id)
|
||||
{
|
||||
memset(&rsx->surface[id], 0, sizeof(gcmSurface));
|
||||
rsx->surface[id].colorFormat = GCM_SURFACE_X8R8G8B8;
|
||||
rsx->surface[id].colorTarget = GCM_SURFACE_TARGET_0;
|
||||
rsx->surface[id].colorLocation[0] = GCM_LOCATION_RSX;
|
||||
rsx->surface[id].colorOffset[0] = buffer->offset;
|
||||
rsx->surface[id].colorPitch[0] = rsx->width * 4;
|
||||
for(u32 i=1; i < GCM_MAX_MRT_COUNT; i++) {
|
||||
rsx->surface[id].colorLocation[i] = GCM_LOCATION_RSX;
|
||||
rsx->surface[id].colorOffset[i] = buffer->offset;
|
||||
rsx->surface[id].colorPitch[i] = 64;
|
||||
}
|
||||
rsx->surface[id].depthFormat = GCM_SURFACE_ZETA_Z24S8;
|
||||
rsx->surface[id].depthLocation = GCM_LOCATION_RSX;
|
||||
rsx->surface[id].depthOffset = rsx->depth_offset;
|
||||
rsx->surface[id].depthPitch = rsx->width * 4;
|
||||
rsx->surface[id].type = GCM_SURFACE_TYPE_LINEAR;
|
||||
rsx->surface[id].antiAlias = GCM_SURFACE_CENTER_1;
|
||||
rsx->surface[id].width = rsx->width;
|
||||
rsx->surface[id].height = rsx->height;
|
||||
rsx->surface[id].x = 0;
|
||||
rsx->surface[id].y = 0;
|
||||
}
|
||||
|
||||
static void rsx_init_vertices(rsx_t *rsx)
|
||||
{
|
||||
rsx->vertices = (rsx_vertex_t *)rsxMemalign(128, sizeof(rsx_vertex_t) * 4);
|
||||
|
||||
rsx->vertices[0].x = 0.0f;
|
||||
rsx->vertices[0].y = 0.0f;
|
||||
rsx->vertices[0].z = 0.0f;
|
||||
rsx->vertices[0].u = 0.0f;
|
||||
rsx->vertices[0].v = 1.0f;
|
||||
rsx->vertices[0].r = 1.0f;
|
||||
rsx->vertices[0].g = 1.0f;
|
||||
rsx->vertices[0].b = 1.0f;
|
||||
rsx->vertices[0].a = 1.0f;
|
||||
|
||||
rsx->vertices[1].x = 1.0f;
|
||||
rsx->vertices[1].y = 0.0f;
|
||||
rsx->vertices[1].z = 0.0f;
|
||||
rsx->vertices[1].u = 1.0f;
|
||||
rsx->vertices[1].v = 1.0f;
|
||||
rsx->vertices[1].r = 1.0f;
|
||||
rsx->vertices[1].g = 1.0f;
|
||||
rsx->vertices[1].b = 1.0f;
|
||||
rsx->vertices[1].a = 1.0f;
|
||||
|
||||
rsx->vertices[2].x = 0.0f;
|
||||
rsx->vertices[2].y = 1.0f;
|
||||
rsx->vertices[2].z = 0.0f;
|
||||
rsx->vertices[2].u = 0.0f;
|
||||
rsx->vertices[2].v = 0.0f;
|
||||
rsx->vertices[2].r = 1.0f;
|
||||
rsx->vertices[2].g = 1.0f;
|
||||
rsx->vertices[2].b = 1.0f;
|
||||
rsx->vertices[2].a = 1.0f;
|
||||
|
||||
rsx->vertices[3].x = 1.0f;
|
||||
rsx->vertices[3].y = 1.0f;
|
||||
rsx->vertices[3].z = 0.0f;
|
||||
rsx->vertices[3].u = 1.0f;
|
||||
rsx->vertices[3].v = 0.0f;
|
||||
rsx->vertices[3].r = 1.0f;
|
||||
rsx->vertices[3].g = 1.0f;
|
||||
rsx->vertices[3].b = 1.0f;
|
||||
rsx->vertices[3].a = 1.0f;
|
||||
|
||||
rsxAddressToOffset(&rsx->vertices[0].x, &rsx->pos_offset);
|
||||
rsxAddressToOffset(&rsx->vertices[0].u, &rsx->uv_offset);
|
||||
rsxAddressToOffset(&rsx->vertices[0].r, &rsx->col_offset);
|
||||
}
|
||||
|
||||
static void rsx_init_shader(rsx_t *rsx)
|
||||
{
|
||||
u32 fpsize = 0;
|
||||
u32 vpsize = 0;
|
||||
rsx->vp_ucode = NULL;
|
||||
rsx->fp_ucode = NULL;
|
||||
rsx->vpo = (rsxVertexProgram *)vpshader_basic_vpo;
|
||||
rsx->fpo = (rsxFragmentProgram *)fpshader_basic_fpo;
|
||||
rsxVertexProgramGetUCode(rsx->vpo, &rsx->vp_ucode, &vpsize);
|
||||
rsxFragmentProgramGetUCode(rsx->fpo, &rsx->fp_ucode, &fpsize);
|
||||
rsx->fp_buffer = (u32 *)rsxMemalign(64, fpsize);
|
||||
if (!rsx->fp_buffer)
|
||||
{
|
||||
RARCH_LOG("failed to allocate fp_buffer\n");
|
||||
return;
|
||||
}
|
||||
memcpy(rsx->fp_buffer, rsx->fp_ucode, fpsize);
|
||||
rsxAddressToOffset(rsx->fp_buffer ,&rsx->fp_offset);
|
||||
|
||||
rsx->proj_matrix = rsxVertexProgramGetConst(rsx->vpo, "modelViewProj");
|
||||
rsx->pos_index = rsxVertexProgramGetAttrib(rsx->vpo, "position");
|
||||
rsx->col_index = rsxVertexProgramGetAttrib(rsx->vpo, "color");
|
||||
rsx->uv_index = rsxVertexProgramGetAttrib(rsx->vpo, "texcoord");
|
||||
rsx->tex_unit = rsxFragmentProgramGetAttrib(rsx->fpo, "texture");
|
||||
}
|
||||
|
||||
static void* rsx_init(const video_info_t* video,
|
||||
input_driver_t** input, void** input_data)
|
||||
{
|
||||
@ -338,6 +389,9 @@ static void* rsx_init(const video_info_t* video,
|
||||
|
||||
memset(rsx, 0, sizeof(rsx_t));
|
||||
|
||||
rsx->texture.data = NULL;
|
||||
rsx->menu_texture.data = NULL;
|
||||
|
||||
rsx->context = rsx_init_screen(rsx);
|
||||
const gfx_ctx_driver_t* ctx_driver = rsx_get_context(rsx);
|
||||
|
||||
@ -349,10 +403,26 @@ static void* rsx_init(const video_info_t* video,
|
||||
rsx->video_info = *video;
|
||||
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
{
|
||||
rsx_make_buffer(&rsx->buffers[i], rsx->width, rsx->height, i);
|
||||
rsx_init_render_target(rsx, &rsx->buffers[i], i);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
rsx_make_buffer(&rsx->menuBuffers[i], rsx->width, rsx->height, i + MAX_BUFFERS);
|
||||
#if defined(HAVE_MENU_BUFFER)
|
||||
for (i = 0; i < MAX_MENU_BUFFERS; i++)
|
||||
{
|
||||
rsx_make_buffer(&rsx->menuBuffers[i], rsx->width, rsx->height, i+MAX_BUFFERS);
|
||||
rsx_init_render_target(rsx, &rsx->menuBuffers[i], i+MAX_BUFFERS);
|
||||
}
|
||||
#endif
|
||||
|
||||
rsx->texture.height = rsx->height;
|
||||
rsx->texture.width = rsx->width;
|
||||
rsx->menu_texture.height = rsx->height;
|
||||
rsx->menu_texture.width = rsx->width;
|
||||
|
||||
rsx_init_shader(rsx);
|
||||
rsx_init_vertices(rsx);
|
||||
|
||||
rsx_flip(rsx->context, MAX_BUFFERS - 1);
|
||||
|
||||
@ -364,6 +434,7 @@ static void* rsx_init(const video_info_t* video,
|
||||
rsx->vp.full_height = rsx->height;
|
||||
rsx->rgb32 = video->rgb32;
|
||||
video_driver_set_size(rsx->vp.width, rsx->vp.height);
|
||||
rsx_set_viewport(rsx, rsx->vp.width, rsx->vp.height, false, true);
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
@ -374,9 +445,194 @@ static void* rsx_init(const video_info_t* video,
|
||||
|
||||
rsx_context_bind_hw_render(rsx, true);
|
||||
|
||||
if (video->font_enable) {
|
||||
font_driver_init_osd(rsx,
|
||||
video,
|
||||
false,
|
||||
video->is_threaded,
|
||||
FONT_DRIVER_RENDER_RSX);
|
||||
rsx->msg_rendering_enabled = true;
|
||||
}
|
||||
|
||||
return rsx;
|
||||
}
|
||||
|
||||
static void rsx_set_projection(rsx_t *rsx,
|
||||
struct video_ortho *ortho, bool allow_rotate)
|
||||
{
|
||||
math_matrix_4x4 rot;
|
||||
|
||||
/* Calculate projection. */
|
||||
matrix_4x4_ortho(rsx->mvp_no_rot, ortho->left, ortho->right,
|
||||
ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
||||
|
||||
if (!allow_rotate)
|
||||
{
|
||||
rsx->mvp = rsx->mvp_no_rot;
|
||||
return;
|
||||
}
|
||||
|
||||
matrix_4x4_rotate_z(rot, M_PI * rsx->rotation / 180.0f);
|
||||
matrix_4x4_multiply(rsx->mvp, rot, rsx->mvp_no_rot);
|
||||
}
|
||||
|
||||
static void rsx_set_viewport(void *data, unsigned viewport_width,
|
||||
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();
|
||||
rsx_t *rsx = (rsx_t*)data;
|
||||
bool video_scale_integer = settings->bools.video_scale_integer;
|
||||
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
|
||||
rsx_viewport_t vp;
|
||||
|
||||
if (video_scale_integer && !force_full)
|
||||
{
|
||||
video_viewport_get_scaled_integer(&rsx->vp,
|
||||
viewport_width, viewport_height,
|
||||
video_driver_get_aspect_ratio(), rsx->keep_aspect);
|
||||
viewport_width = rsx->vp.width;
|
||||
viewport_height = rsx->vp.height;
|
||||
}
|
||||
else if (rsx->keep_aspect && !force_full)
|
||||
{
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
||||
{
|
||||
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)
|
||||
{
|
||||
/* 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(viewport_width * (0.5f - delta));
|
||||
viewport_width = (unsigned)roundf(2.0f * viewport_width * delta);
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = (device_aspect / desired_aspect - 1.0f)
|
||||
/ 2.0f + 0.5f;
|
||||
y = (int)roundf(viewport_height * (0.5f - delta));
|
||||
viewport_height = (unsigned)roundf(2.0f * viewport_height * delta);
|
||||
}
|
||||
}
|
||||
|
||||
rsx->vp.x = x;
|
||||
rsx->vp.y = y;
|
||||
rsx->vp.width = viewport_width;
|
||||
rsx->vp.height = viewport_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
rsx->vp.x = 0;
|
||||
rsx->vp.y = 0;
|
||||
rsx->vp.width = viewport_width;
|
||||
rsx->vp.height = viewport_height;
|
||||
}
|
||||
|
||||
vp.min = 0.0f;
|
||||
vp.max = 1.0f;
|
||||
vp.x = rsx->vp.x;
|
||||
vp.y = rsx->height - rsx->vp.y - rsx->vp.height;
|
||||
vp.w = rsx->vp.width;
|
||||
vp.h = rsx->vp.height;
|
||||
vp.scale[0] = vp.w*0.5f;
|
||||
vp.scale[1] = vp.h*-0.5f;
|
||||
vp.scale[2] = (vp.max - vp.min)*0.5f;
|
||||
vp.scale[3] = 0.0f;
|
||||
vp.offset[0] = vp.x + vp.w*0.5f;
|
||||
vp.offset[1] = vp.y + vp.h*0.5f;
|
||||
vp.offset[2] = (vp.max + vp.min)*0.5f;
|
||||
vp.offset[3] = 0.0f;
|
||||
|
||||
rsxSetViewport(rsx->context, vp.x, vp.y, vp.w, vp.h, vp.min, vp.max, vp.scale, vp.offset);
|
||||
for(int i = 0; i < 8; i++)
|
||||
rsxSetViewportClip(rsx->context, i, rsx->width, rsx->height);
|
||||
rsxSetScissor(rsx->context, vp.x, vp.y, vp.w, vp.h);
|
||||
|
||||
rsx_set_projection(rsx, &ortho, allow_rotate);
|
||||
|
||||
/* Set last backbuffer viewport. */
|
||||
if (!force_full)
|
||||
{
|
||||
rsx->vp.width = viewport_width;
|
||||
rsx->vp.height = viewport_height;
|
||||
}
|
||||
|
||||
#if 0
|
||||
RARCH_LOG("Setting viewport @ %ux%u\n", viewport_width, viewport_height);
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned rsx_wrap_type_to_enum(enum gfx_wrap_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case RARCH_WRAP_BORDER:
|
||||
case RARCH_WRAP_EDGE:
|
||||
return GCM_TEXTURE_CLAMP_TO_EDGE;
|
||||
case RARCH_WRAP_REPEAT:
|
||||
return GCM_TEXTURE_REPEAT;
|
||||
case RARCH_WRAP_MIRRORED_REPEAT:
|
||||
return GCM_TEXTURE_MIRRORED_REPEAT;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uintptr_t rsx_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
rsx_t *rsx = (rsx_t *)video_data;
|
||||
struct texture_image *image = (struct texture_image*)data;
|
||||
|
||||
rsx_texture_t *texture = (rsx_texture_t *)malloc(sizeof(rsx_texture_t));
|
||||
|
||||
texture->width = image->width;
|
||||
texture->height = image->height;
|
||||
texture->data = (u32*)rsxMemalign(128, (image->height * image->width*4));
|
||||
rsxAddressToOffset(texture->data, &texture->offset);
|
||||
rsx_load_texture_data(rsx, texture, image->pixels, image->width, image->height, image->width*4, true, false, filter_type);
|
||||
|
||||
return (uintptr_t)texture;;
|
||||
}
|
||||
|
||||
static void rsx_unload_texture(void *data,
|
||||
bool threaded, uintptr_t handle)
|
||||
{
|
||||
rsx_t *rsx = (rsx_t *)data;
|
||||
rsx_texture_t *texture = (rsx_texture_t *)handle;
|
||||
if (texture) {
|
||||
if(texture->data)
|
||||
rsxFree(texture->data);
|
||||
free(texture);
|
||||
}
|
||||
}
|
||||
|
||||
static void rsx_fill_black(uint32_t *dst, uint32_t *dst_end, size_t sz)
|
||||
{
|
||||
if (sz > dst_end - dst)
|
||||
@ -504,14 +760,202 @@ static void rsx_blit_buffer(
|
||||
memset(dst, 0, 4 * (dst_end - dst));
|
||||
}
|
||||
|
||||
static void rsx_load_texture_data(rsx_t* rsx, rsx_texture_t *texture,
|
||||
const void *frame, unsigned width, unsigned height, unsigned pitch,
|
||||
bool rgb32, bool menu, enum texture_filter_type filter_type)
|
||||
{
|
||||
u32 mag_filter, min_filter;
|
||||
|
||||
if (!texture->data)
|
||||
{
|
||||
texture->data = (u32 *)rsxMemalign(128, texture->height * pitch);
|
||||
rsxAddressToOffset(texture->data, &texture->offset);
|
||||
}
|
||||
|
||||
u8 *texbuffer = (u8 *)texture->data;
|
||||
const u8 *data = (u8 *)frame;
|
||||
memcpy(texbuffer, data, height * pitch);
|
||||
|
||||
texture->tex.format = (rgb32 ? GCM_TEXTURE_FORMAT_A8R8G8B8 :
|
||||
menu ? GCM_TEXTURE_FORMAT_A4R4G4B4 : GCM_TEXTURE_FORMAT_R5G6B5) | GCM_TEXTURE_FORMAT_LIN;
|
||||
texture->tex.mipmap = 1;
|
||||
texture->tex.dimension = GCM_TEXTURE_DIMS_2D;
|
||||
texture->tex.cubemap = GCM_FALSE;
|
||||
texture->tex.remap = ((GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_B_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_G_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_R_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_A_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_B << GCM_TEXTURE_REMAP_COLOR_B_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_G << GCM_TEXTURE_REMAP_COLOR_G_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_R << GCM_TEXTURE_REMAP_COLOR_R_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_A << GCM_TEXTURE_REMAP_COLOR_A_SHIFT));
|
||||
texture->tex.width = width;
|
||||
texture->tex.height = height;
|
||||
texture->tex.depth = 1;
|
||||
texture->tex.location = GCM_LOCATION_RSX;
|
||||
texture->tex.pitch = pitch;
|
||||
texture->tex.offset = texture->offset;
|
||||
|
||||
switch (filter_type)
|
||||
{
|
||||
case TEXTURE_FILTER_MIPMAP_NEAREST:
|
||||
case TEXTURE_FILTER_NEAREST:
|
||||
min_filter = GCM_TEXTURE_NEAREST;
|
||||
mag_filter = GCM_TEXTURE_NEAREST;
|
||||
break;
|
||||
case TEXTURE_FILTER_MIPMAP_LINEAR:
|
||||
case TEXTURE_FILTER_LINEAR:
|
||||
default:
|
||||
min_filter = GCM_TEXTURE_LINEAR;
|
||||
mag_filter = GCM_TEXTURE_LINEAR;
|
||||
break;
|
||||
}
|
||||
texture->min_filter = min_filter;
|
||||
texture->mag_filter = mag_filter;
|
||||
texture->wrap_s = GCM_TEXTURE_CLAMP_TO_EDGE;
|
||||
texture->wrap_t = GCM_TEXTURE_CLAMP_TO_EDGE;
|
||||
}
|
||||
|
||||
static void rsx_set_texture(rsx_t* rsx, rsx_texture_t *texture)
|
||||
{
|
||||
rsxInvalidateTextureCache(rsx->context, GCM_INVALIDATE_TEXTURE);
|
||||
rsxLoadTexture(rsx->context, rsx->tex_unit->index, &texture->tex);
|
||||
rsxTextureControl(rsx->context, rsx->tex_unit->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
||||
rsxTextureFilter(rsx->context, rsx->tex_unit->index, 0, texture->min_filter, texture->mag_filter, GCM_TEXTURE_CONVOLUTION_QUINCUNX);
|
||||
rsxTextureWrapMode(rsx->context, rsx->tex_unit->index, texture->wrap_s, texture->wrap_t, GCM_TEXTURE_CLAMP_TO_EDGE, 0, GCM_TEXTURE_ZFUNC_LESS, 0);
|
||||
}
|
||||
|
||||
static void rsx_clear_surface(rsx_t* rsx)
|
||||
{
|
||||
rsxSetColorMask(rsx->context,
|
||||
GCM_COLOR_MASK_R |
|
||||
GCM_COLOR_MASK_G |
|
||||
GCM_COLOR_MASK_B |
|
||||
GCM_COLOR_MASK_A);
|
||||
|
||||
rsxSetColorMaskMrt(rsx->context, 0);
|
||||
|
||||
rsxSetUserClipPlaneControl(rsx->context,
|
||||
GCM_USER_CLIP_PLANE_DISABLE,
|
||||
GCM_USER_CLIP_PLANE_DISABLE,
|
||||
GCM_USER_CLIP_PLANE_DISABLE,
|
||||
GCM_USER_CLIP_PLANE_DISABLE,
|
||||
GCM_USER_CLIP_PLANE_DISABLE,
|
||||
GCM_USER_CLIP_PLANE_DISABLE);
|
||||
|
||||
rsxSetClearColor(rsx->context, 0);
|
||||
rsxSetClearDepthStencil(rsx->context, 0xffffff00);
|
||||
rsxClearSurface(rsx->context,
|
||||
GCM_CLEAR_R |
|
||||
GCM_CLEAR_G |
|
||||
GCM_CLEAR_B |
|
||||
GCM_CLEAR_A |
|
||||
GCM_CLEAR_S |
|
||||
GCM_CLEAR_Z);
|
||||
rsxSetZControl(rsx->context, 0, 1, 1);
|
||||
}
|
||||
|
||||
static void rsx_draw_vertices(rsx_t* rsx)
|
||||
{
|
||||
if (rsx->should_resize)
|
||||
rsx_set_viewport(rsx, rsx->width, rsx->height, false, true);
|
||||
|
||||
rsx->vertices[0].r = 1.0f;
|
||||
rsx->vertices[0].g = 1.0f;
|
||||
rsx->vertices[0].b = 1.0f;
|
||||
rsx->vertices[0].a = 1.0f;
|
||||
rsx->vertices[1].r = 1.0f;
|
||||
rsx->vertices[1].g = 1.0f;
|
||||
rsx->vertices[1].b = 1.0f;
|
||||
rsx->vertices[1].a = 1.0f;
|
||||
rsx->vertices[2].r = 1.0f;
|
||||
rsx->vertices[2].g = 1.0f;
|
||||
rsx->vertices[2].b = 1.0f;
|
||||
rsx->vertices[2].a = 1.0f;
|
||||
rsx->vertices[3].r = 1.0f;
|
||||
rsx->vertices[3].g = 1.0f;
|
||||
rsx->vertices[3].b = 1.0f;
|
||||
rsx->vertices[3].a = 1.0f;
|
||||
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->pos_index->index, 0, rsx->pos_offset, sizeof(rsx_vertex_t), 3, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->uv_index->index, 0, rsx->uv_offset, sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->col_index->index, 0, rsx->col_offset, sizeof(rsx_vertex_t), 4, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
|
||||
rsxLoadVertexProgram(rsx->context, rsx->vpo, rsx->vp_ucode);
|
||||
rsxSetVertexProgramParameter(rsx->context, rsx->vpo, rsx->proj_matrix, (float *)&rsx->mvp_no_rot);
|
||||
rsxLoadFragmentProgramLocation(rsx->context, rsx->fpo, rsx->fp_offset, GCM_LOCATION_RSX);
|
||||
|
||||
rsxClearSurface(rsx->context, GCM_CLEAR_Z);
|
||||
rsxDrawVertexArray(rsx->context, GCM_TYPE_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
static void rsx_draw_menu_vertices(rsx_t* rsx)
|
||||
{
|
||||
if (rsx->should_resize)
|
||||
rsx_set_viewport(rsx, rsx->width, rsx->height, false, true);
|
||||
|
||||
rsx->vertices[0].r = 1.0f;
|
||||
rsx->vertices[0].g = 1.0f;
|
||||
rsx->vertices[0].b = 1.0f;
|
||||
rsx->vertices[0].a = rsx->menu_texture_alpha;
|
||||
rsx->vertices[1].r = 1.0f;
|
||||
rsx->vertices[1].g = 1.0f;
|
||||
rsx->vertices[1].b = 1.0f;
|
||||
rsx->vertices[1].a = rsx->menu_texture_alpha;
|
||||
rsx->vertices[2].r = 1.0f;
|
||||
rsx->vertices[2].g = 1.0f;
|
||||
rsx->vertices[2].b = 1.0f;
|
||||
rsx->vertices[2].a = rsx->menu_texture_alpha;
|
||||
rsx->vertices[3].r = 1.0f;
|
||||
rsx->vertices[3].g = 1.0f;
|
||||
rsx->vertices[3].b = 1.0f;
|
||||
rsx->vertices[3].a = rsx->menu_texture_alpha;
|
||||
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->pos_index->index, 0, rsx->pos_offset, sizeof(rsx_vertex_t), 3, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->uv_index->index, 0, rsx->uv_offset, sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->col_index->index, 0, rsx->col_offset, sizeof(rsx_vertex_t), 4, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
|
||||
rsxLoadVertexProgram(rsx->context, rsx->vpo, rsx->vp_ucode);
|
||||
rsxSetVertexProgramParameter(rsx->context, rsx->vpo, rsx->proj_matrix, (float *)&rsx->mvp_no_rot);
|
||||
rsxLoadFragmentProgramLocation(rsx->context, rsx->fpo, rsx->fp_offset, GCM_LOCATION_RSX);
|
||||
|
||||
rsxSetBlendEnable(rsx->context, GCM_TRUE);
|
||||
rsxSetBlendFunc(rsx->context, GCM_SRC_ALPHA, GCM_ONE_MINUS_SRC_ALPHA, GCM_SRC_ALPHA, GCM_ONE_MINUS_SRC_ALPHA);
|
||||
rsxSetBlendEquation(rsx->context, GCM_FUNC_ADD, GCM_FUNC_ADD);
|
||||
|
||||
rsxClearSurface(rsx->context, GCM_CLEAR_Z);
|
||||
rsxDrawVertexArray(rsx->context, GCM_TYPE_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
rsxSetBlendEnable(rsx->context, GCM_FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void rsx_update_screen(rsx_t* gcm)
|
||||
{
|
||||
rsxBuffer *buffer = gcm->menu_frame_enable
|
||||
? &gcm->menuBuffers[gcm->menuBuffer]
|
||||
: &gcm->buffers[gcm->currentBuffer];
|
||||
rsxBuffer *buffer;
|
||||
|
||||
#if defined(HAVE_MENU_BUFFER)
|
||||
if (gcm->menu_frame_enable) {
|
||||
buffer = &gcm->menuBuffers[gcm->menuBuffer];
|
||||
gcm->menuBuffer = (gcm->menuBuffer+1)%MAX_MENU_BUFFERS;
|
||||
gcm->nextBuffer = MAX_BUFFERS + gcm->menuBuffer;
|
||||
} else {
|
||||
buffer = &gcm->buffers[gcm->currentBuffer];
|
||||
gcm->currentBuffer = (gcm->currentBuffer+1)%MAX_BUFFERS;
|
||||
gcm->nextBuffer = gcm->currentBuffer;
|
||||
}
|
||||
#else
|
||||
buffer = &gcm->buffers[gcm->currentBuffer];
|
||||
gcm->currentBuffer = (gcm->currentBuffer+1)%MAX_BUFFERS;
|
||||
gcm->nextBuffer = gcm->currentBuffer;
|
||||
#endif
|
||||
|
||||
|
||||
rsx_flip(gcm->context, buffer->id);
|
||||
if (gcm->vsync)
|
||||
rsx_wait_flip();
|
||||
rsxSetSurface(gcm->context, &gcm->surface[gcm->nextBuffer]);
|
||||
#ifdef HAVE_SYSUTILS
|
||||
cellSysutilCheckCallback();
|
||||
#endif
|
||||
@ -527,24 +971,31 @@ static bool rsx_frame(void* data, const void* frame,
|
||||
bool statistics_show = video_info->statistics_show;
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
&video_info->osd_stat_params;
|
||||
bool menu_is_alive = video_info->menu_is_alive;
|
||||
#endif
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
bool widgets_active = video_info->widgets_active;
|
||||
#endif
|
||||
|
||||
if(frame && width && height)
|
||||
{
|
||||
gcm->currentBuffer++;
|
||||
if (gcm->currentBuffer >= MAX_BUFFERS)
|
||||
gcm->currentBuffer = 0;
|
||||
rsx_blit_buffer(
|
||||
&gcm->buffers[gcm->currentBuffer], frame, width, height, pitch,
|
||||
gcm->rgb32, true);
|
||||
rsx_load_texture_data(gcm, &gcm->texture, frame, width, height, pitch, gcm->rgb32, false,
|
||||
gcm->smooth ? TEXTURE_FILTER_LINEAR : TEXTURE_FILTER_NEAREST);
|
||||
rsx_set_texture(gcm, &gcm->texture);
|
||||
rsx_draw_vertices(gcm);
|
||||
}
|
||||
|
||||
/* TODO: translucid menu */
|
||||
rsx_update_screen(gcm);
|
||||
|
||||
return true;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (gcm->menu_frame_enable && menu_is_alive)
|
||||
{
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
if (gcm->menu_texture.data)
|
||||
{
|
||||
rsx_set_texture(gcm, &gcm->menu_texture);
|
||||
rsx_draw_menu_vertices(gcm);
|
||||
}
|
||||
};
|
||||
|
||||
if (statistics_show)
|
||||
if (osd_params)
|
||||
font_driver_render_msg(gcm,
|
||||
@ -552,8 +1003,20 @@ static bool rsx_frame(void* data, const void* frame,
|
||||
osd_params, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
if (widgets_active)
|
||||
gfx_widgets_frame(video_info);
|
||||
#endif
|
||||
|
||||
if (msg)
|
||||
font_driver_render_msg(gcm, msg, NULL, NULL);
|
||||
|
||||
#if 0
|
||||
/* TODO: translucid menu */
|
||||
#endif
|
||||
rsx_update_screen(gcm);
|
||||
rsx_clear_surface(gcm);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -593,11 +1056,25 @@ static void rsx_free(void* data)
|
||||
if (!gcm)
|
||||
return;
|
||||
|
||||
rsxClearSurface(gcm->context, GCM_CLEAR_Z);
|
||||
gcmSetWaitFlip(gcm->context);
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
rsxFree(gcm->buffers[i].ptr);
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
#if defined(HAVE_MENU_BUFFER)
|
||||
for (i = 0; i < MAX_MENU_BUFFERS; i++)
|
||||
rsxFree(gcm->menuBuffers[i].ptr);
|
||||
#endif
|
||||
|
||||
if (gcm->vertices)
|
||||
rsxFree(gcm->vertices);
|
||||
if (gcm->texture.data)
|
||||
rsxFree(gcm->texture.data);
|
||||
if (gcm->menu_texture.data)
|
||||
rsxFree(gcm->menu_texture.data);
|
||||
if (gcm->depth_buffer)
|
||||
rsxFree(gcm->depth_buffer);
|
||||
if (gcm->fp_buffer)
|
||||
rsxFree(gcm->fp_buffer);
|
||||
|
||||
#if 0
|
||||
rsxFinish(gcm->context, 1);
|
||||
@ -610,17 +1087,12 @@ static void rsx_set_texture_frame(void* data, const void* frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
int newBuffer = gcm->menuBuffer + 1;
|
||||
|
||||
if (newBuffer >= MAX_BUFFERS)
|
||||
newBuffer = 0;
|
||||
|
||||
/* TODO: respect alpha */
|
||||
rsx_blit_buffer(&gcm->menuBuffers[newBuffer], frame, width, height,
|
||||
width * (rgb32 ? 4 : 2), rgb32, true);
|
||||
gcm->menuBuffer = newBuffer;
|
||||
|
||||
rsx_update_screen(gcm);
|
||||
gcm->menu_texture_alpha = alpha;
|
||||
gcm->menu_width = width;
|
||||
gcm->menu_height = height;
|
||||
rsx_load_texture_data(gcm, &gcm->menu_texture, frame, width, height, width * (rgb32 ? 4 : 2),
|
||||
rgb32, true, gcm->smooth ? TEXTURE_FILTER_LINEAR : TEXTURE_FILTER_NEAREST);
|
||||
}
|
||||
|
||||
static void rsx_set_texture_enable(void* data, bool state, bool full_screen)
|
||||
@ -629,22 +1101,23 @@ static void rsx_set_texture_enable(void* data, bool state, bool full_screen)
|
||||
|
||||
if (!gcm)
|
||||
return;
|
||||
|
||||
gcm->menu_frame_enable = state;
|
||||
|
||||
rsx_update_screen(gcm);
|
||||
gcm->menu_frame_enable = state;
|
||||
}
|
||||
|
||||
static void rsx_set_rotation(void* data, unsigned rotation)
|
||||
{
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
struct video_ortho ortho = {0, 1, 0, 1, -1, 1};
|
||||
|
||||
if (!gcm)
|
||||
return;
|
||||
|
||||
gcm->rotation = rotation;
|
||||
gcm->rotation = 90 * rotation;
|
||||
gcm->should_resize = true;
|
||||
rsx_set_projection(gcm, &ortho, true);
|
||||
}
|
||||
|
||||
static void rsx_set_filtering(void* data, unsigned index, bool smooth)
|
||||
{
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
@ -701,8 +1174,8 @@ static uint32_t rsx_get_flags(void *data)
|
||||
|
||||
static const video_poke_interface_t rsx_poke_interface = {
|
||||
rsx_get_flags,
|
||||
NULL, /* load_texture */
|
||||
NULL, /* unload_texture */
|
||||
rsx_load_texture,
|
||||
rsx_unload_texture,
|
||||
NULL,
|
||||
NULL,
|
||||
rsx_set_filtering,
|
||||
@ -715,7 +1188,7 @@ static const video_poke_interface_t rsx_poke_interface = {
|
||||
rsx_apply_state_changes,
|
||||
rsx_set_texture_frame,
|
||||
rsx_set_texture_enable,
|
||||
rsx_set_osd_msg,
|
||||
font_driver_render_msg,
|
||||
NULL, /* show_mouse */
|
||||
NULL, /* grab_mouse_toggle */
|
||||
NULL, /* get_current_shader */
|
||||
@ -744,6 +1217,14 @@ static bool rsx_set_shader(void* data,
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
static bool rsx_widgets_enabled(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
video_driver_t video_gcm =
|
||||
{
|
||||
rsx_init,
|
||||
@ -756,7 +1237,7 @@ video_driver_t video_gcm =
|
||||
rsx_set_shader,
|
||||
rsx_free,
|
||||
"rsx",
|
||||
NULL, /* set_viewport */
|
||||
rsx_set_viewport,
|
||||
rsx_set_rotation,
|
||||
rsx_viewport_info,
|
||||
NULL, /* read_viewport */
|
||||
@ -767,5 +1248,9 @@ video_driver_t video_gcm =
|
||||
#ifdef HAVE_VIDEO_LAYOUT
|
||||
NULL,
|
||||
#endif
|
||||
rsx_get_poke_interface
|
||||
rsx_get_poke_interface,
|
||||
rsx_wrap_type_to_enum,
|
||||
#ifdef HAVE_GFX_WIDGETS
|
||||
rsx_widgets_enabled
|
||||
#endif
|
||||
};
|
||||
|
11
gfx/drivers/rsx_shaders/fpshader_basic.fcg
Normal file
11
gfx/drivers/rsx_shaders/fpshader_basic.fcg
Normal file
@ -0,0 +1,11 @@
|
||||
void main
|
||||
(
|
||||
float2 texcoord : TEXCOORD0,
|
||||
float4 color : COLOR,
|
||||
uniform sampler2D texture,
|
||||
out float4 oColor : COLOR
|
||||
)
|
||||
{
|
||||
oColor = color * tex2D(texture, texcoord);
|
||||
}
|
||||
|
15
gfx/drivers/rsx_shaders/vpshader_basic.vcg
Normal file
15
gfx/drivers/rsx_shaders/vpshader_basic.vcg
Normal file
@ -0,0 +1,15 @@
|
||||
void main
|
||||
(
|
||||
float4 position : POSITION,
|
||||
float4 color : COLOR0,
|
||||
float2 texcoord : TEXCOORD0,
|
||||
uniform float4x4 modelViewProj,
|
||||
out float4 oPosition : POSITION,
|
||||
out float4 oColor : COLOR0,
|
||||
out float2 oTexCoord : TEXCOORD0
|
||||
)
|
||||
{
|
||||
oPosition = mul(position, modelViewProj);
|
||||
oColor = color;
|
||||
oTexCoord = texcoord;
|
||||
}
|
205
gfx/drivers_display/gfx_display_rsx.c
Normal file
205
gfx/drivers_display/gfx_display_rsx.c
Normal file
@ -0,0 +1,205 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* 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 <retro_miscellaneous.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#include "../gfx_display.h"
|
||||
|
||||
#include "../../retroarch.h"
|
||||
#include "../common/rsx_common.h"
|
||||
#include "../font_driver.h"
|
||||
|
||||
static const float rsx_vertexes[] = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
0, 1,
|
||||
1, 1
|
||||
};
|
||||
|
||||
static const float rsx_tex_coords[] = {
|
||||
0, 1,
|
||||
1, 1,
|
||||
0, 0,
|
||||
1, 0
|
||||
};
|
||||
|
||||
static const float *gfx_display_rsx_get_default_vertices(void)
|
||||
{
|
||||
return &rsx_vertexes[0];
|
||||
}
|
||||
|
||||
static const float *gfx_display_rsx_get_default_tex_coords(void)
|
||||
{
|
||||
return &rsx_tex_coords[0];
|
||||
}
|
||||
|
||||
static void *gfx_display_rsx_get_default_mvp(void *data)
|
||||
{
|
||||
rsx_t *rsx = (rsx_t*)data;
|
||||
|
||||
if (!rsx)
|
||||
return NULL;
|
||||
|
||||
return &rsx->mvp_no_rot;
|
||||
}
|
||||
|
||||
static void gfx_display_rsx_draw(gfx_display_ctx_draw_t *draw,
|
||||
void *data, unsigned video_width, unsigned video_height)
|
||||
{
|
||||
unsigned i;
|
||||
rsx_texture_t *texture = NULL;
|
||||
const float *vertex = NULL;
|
||||
const float *tex_coord = NULL;
|
||||
const float *color = NULL;
|
||||
rsx_t *rsx = (rsx_t*)data;
|
||||
rsx_viewport_t vp;
|
||||
video_shader_ctx_mvp_t mvp;
|
||||
|
||||
if (!rsx || !draw)
|
||||
return;
|
||||
|
||||
texture = (rsx_texture_t *)draw->texture;
|
||||
vertex = draw->coords->vertex;
|
||||
tex_coord = draw->coords->tex_coord;
|
||||
color = draw->coords->color;
|
||||
|
||||
if (!vertex)
|
||||
vertex = &rsx_vertexes[0];
|
||||
if (!tex_coord)
|
||||
tex_coord = &rsx_tex_coords[0];
|
||||
if (!draw->coords->lut_tex_coord)
|
||||
draw->coords->lut_tex_coord = &rsx_tex_coords[0];
|
||||
if (!draw->texture)
|
||||
return;
|
||||
|
||||
vp.x = fabs(draw->x);
|
||||
vp.y = fabs(rsx->height - draw->y - draw->height);
|
||||
vp.w = draw->width <= rsx->width ? draw->width : rsx->width;
|
||||
vp.h = draw->height <= rsx->height ? draw->height : rsx->height;
|
||||
vp.min = 0.0f;
|
||||
vp.max = 1.0f;
|
||||
vp.scale[0] = vp.w*0.5f;
|
||||
vp.scale[1] = vp.h*-0.5f;
|
||||
vp.scale[2] = (vp.max - vp.min)*0.5f;
|
||||
vp.scale[3] = 0.0f;
|
||||
vp.offset[0] = vp.x + vp.w*0.5f;
|
||||
vp.offset[1] = vp.y + vp.h*0.5f;
|
||||
vp.offset[2] = (vp.max + vp.min)*0.5f;
|
||||
vp.offset[3] = 0.0f;
|
||||
|
||||
rsxSetViewport(rsx->context, vp.x, vp.y, vp.w, vp.h, vp.min, vp.max, vp.scale, vp.offset);
|
||||
|
||||
rsxInvalidateTextureCache(rsx->context, GCM_INVALIDATE_TEXTURE);
|
||||
rsxLoadTexture(rsx->context, rsx->tex_unit->index, &texture->tex);
|
||||
rsxTextureControl(rsx->context, rsx->tex_unit->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
||||
rsxTextureFilter(rsx->context, rsx->tex_unit->index, 0, texture->min_filter, texture->mag_filter, GCM_TEXTURE_CONVOLUTION_QUINCUNX);
|
||||
rsxTextureWrapMode(rsx->context, rsx->tex_unit->index, texture->wrap_s, texture->wrap_t, GCM_TEXTURE_CLAMP_TO_EDGE, 0, GCM_TEXTURE_ZFUNC_LESS, 0);
|
||||
|
||||
for (i = 0; i < draw->coords->vertices; i++)
|
||||
{
|
||||
rsx->vertices[i].x = *vertex++;
|
||||
rsx->vertices[i].y = *vertex++;
|
||||
rsx->vertices[i].z = 0.0f;
|
||||
rsx->vertices[i].u = *tex_coord++;
|
||||
rsx->vertices[i].v = *tex_coord++;
|
||||
rsx->vertices[i].r = *color++;
|
||||
rsx->vertices[i].g = *color++;
|
||||
rsx->vertices[i].b = *color++;
|
||||
rsx->vertices[i].a = *color++;
|
||||
}
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->pos_index->index, 0, rsx->pos_offset, sizeof(rsx_vertex_t), 3, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->uv_index->index, 0, rsx->uv_offset, sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(rsx->context, rsx->col_index->index, 0, rsx->col_offset, sizeof(rsx_vertex_t), 4, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
|
||||
rsxSetVertexProgramParameter(rsx->context, rsx->vpo, rsx->proj_matrix, (float *)&rsx->mvp_no_rot);
|
||||
rsxClearSurface(rsx->context, GCM_CLEAR_Z);
|
||||
rsxDrawVertexArray(rsx->context, GCM_TYPE_TRIANGLE_STRIP, 0, draw->coords->vertices);
|
||||
}
|
||||
|
||||
static bool gfx_display_rsx_font_init_first(
|
||||
void **font_handle, void *video_data,
|
||||
const char *font_path, float font_size,
|
||||
bool is_threaded)
|
||||
{
|
||||
font_data_t **handle = (font_data_t**)font_handle;
|
||||
*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true,
|
||||
is_threaded,
|
||||
FONT_DRIVER_RENDER_RSX);
|
||||
return *handle;
|
||||
}
|
||||
|
||||
static void gfx_display_rsx_scissor_begin(void *data,
|
||||
unsigned video_width,
|
||||
unsigned video_height,
|
||||
int x, int y,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
rsx_t *rsx = (rsx_t *)data;
|
||||
rsxSetScissor(rsx->context, x, video_height - y - height, width, height);
|
||||
}
|
||||
|
||||
static void gfx_display_rsx_scissor_end(
|
||||
void *data,
|
||||
unsigned video_width,
|
||||
unsigned video_height)
|
||||
{
|
||||
rsx_t *rsx = (rsx_t *)data;
|
||||
rsxSetScissor(rsx->context, 0, 0, video_width, video_height);
|
||||
}
|
||||
|
||||
static void gfx_display_rsx_blend_begin(void *data)
|
||||
{
|
||||
rsx_t *rsx = (rsx_t *)data;
|
||||
rsxSetBlendEnable(rsx->context, GCM_TRUE);
|
||||
rsxSetBlendFunc(rsx->context, GCM_SRC_ALPHA, GCM_ONE_MINUS_SRC_ALPHA, GCM_SRC_ALPHA, GCM_ONE_MINUS_SRC_ALPHA);
|
||||
rsxSetBlendEquation(rsx->context, GCM_FUNC_ADD, GCM_FUNC_ADD);
|
||||
#if 0
|
||||
rsxSetBlendEnableMrt(rsx->context, GCM_TRUE, GCM_TRUE, GCM_TRUE);
|
||||
rsxSetDepthFunc(rsx->context, GCM_LESS);
|
||||
rsxSetDepthTestEnable(rsx->context, GCM_FALSE);
|
||||
rsxSetAlphaFunc(rsx->context, GCM_ALWAYS, 0);
|
||||
rsxSetAlphaTestEnable(rsx->context, GCM_TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gfx_display_rsx_blend_end(void *data)
|
||||
{
|
||||
rsx_t *rsx = (rsx_t *)data;
|
||||
rsxSetBlendEnable(rsx->context, GCM_FALSE);
|
||||
#if 0
|
||||
rsxSetBlendEnableMrt(rsx->context, GCM_FALSE, GCM_FALSE, GCM_FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
gfx_display_ctx_driver_t gfx_display_ctx_rsx = {
|
||||
gfx_display_rsx_draw,
|
||||
NULL, /* draw_pipeline */
|
||||
gfx_display_rsx_blend_begin,
|
||||
gfx_display_rsx_blend_end,
|
||||
gfx_display_rsx_get_default_mvp,
|
||||
gfx_display_rsx_get_default_vertices,
|
||||
gfx_display_rsx_get_default_tex_coords,
|
||||
gfx_display_rsx_font_init_first,
|
||||
GFX_VIDEO_DRIVER_RSX,
|
||||
"rsx",
|
||||
true,
|
||||
gfx_display_rsx_scissor_begin,
|
||||
gfx_display_rsx_scissor_end
|
||||
};
|
565
gfx/drivers_font/rsx_font.c
Normal file
565
gfx/drivers_font/rsx_font.c
Normal file
@ -0,0 +1,565 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* 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 <defines/ps3_defines.h>
|
||||
#include <rsx/rsx.h>
|
||||
#include <rsx/nv40.h>
|
||||
#include <ppu-types.h>
|
||||
|
||||
#include <encodings/utf.h>
|
||||
|
||||
#include "../common/rsx_common.h"
|
||||
|
||||
#include "../font_driver.h"
|
||||
|
||||
#include "../../configuration.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
#define RSX_FONT_EMIT(c, vx, vy) \
|
||||
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
|
||||
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
|
||||
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
|
||||
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
|
||||
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
|
||||
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
|
||||
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
|
||||
font_color[ 4 * (6 * i + c) + 3] = color[3]
|
||||
|
||||
#define MAX_MSG_LEN_CHUNK 64
|
||||
|
||||
typedef struct
|
||||
{
|
||||
rsx_t *rsx;
|
||||
rsx_vertex_t *vertices;
|
||||
rsx_texture_t texture;
|
||||
u32 tex_width;
|
||||
u32 tex_height;
|
||||
rsxProgramAttrib *proj_matrix;
|
||||
rsxProgramAttrib *pos_index;
|
||||
rsxProgramAttrib *uv_index;
|
||||
rsxProgramAttrib *col_index;
|
||||
rsxProgramAttrib *tex_unit;
|
||||
rsxVertexProgram* vpo;
|
||||
rsxFragmentProgram* fpo;
|
||||
u32 fp_offset;
|
||||
u32 pos_offset;
|
||||
u32 uv_offset;
|
||||
u32 col_offset;
|
||||
void *vp_ucode;
|
||||
void *fp_ucode;
|
||||
const font_renderer_driver_t *font_driver;
|
||||
void *font_data;
|
||||
struct font_atlas *atlas;
|
||||
video_font_raster_block_t *block;
|
||||
} rsx_font_t;
|
||||
|
||||
static void rsx_font_free_font(void *data,
|
||||
bool is_threaded)
|
||||
{
|
||||
rsx_font_t *font = (rsx_font_t*)data;
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
if (font->font_driver && font->font_data)
|
||||
font->font_driver->free(font->font_data);
|
||||
|
||||
if (is_threaded) {
|
||||
if (
|
||||
font->rsx &&
|
||||
font->rsx->ctx_driver &&
|
||||
font->rsx->ctx_driver->make_current)
|
||||
font->rsx->ctx_driver->make_current(true);
|
||||
}
|
||||
|
||||
rsxClearSurface(font->rsx->context, GCM_CLEAR_Z);
|
||||
gcmSetWaitFlip(font->rsx->context);
|
||||
if (font->texture.data)
|
||||
rsxFree(font->texture.data);
|
||||
if (font->vertices)
|
||||
rsxFree(font->vertices);
|
||||
|
||||
free(font);
|
||||
}
|
||||
|
||||
static bool rsx_font_upload_atlas(rsx_font_t *font)
|
||||
{
|
||||
u8 *texbuffer = (u8 *)font->texture.data;
|
||||
const u8 *atlas_data = (u8 *)font->atlas->buffer;
|
||||
memcpy(texbuffer, atlas_data, font->atlas->height * font->atlas->width);
|
||||
|
||||
font->texture.tex.format = GCM_TEXTURE_FORMAT_B8 | GCM_TEXTURE_FORMAT_LIN;
|
||||
font->texture.tex.mipmap = 1;
|
||||
font->texture.tex.dimension = GCM_TEXTURE_DIMS_2D;
|
||||
font->texture.tex.cubemap = GCM_FALSE;
|
||||
font->texture.tex.remap = ((GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_B_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_G_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_R_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_TYPE_REMAP << GCM_TEXTURE_REMAP_TYPE_A_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_B << GCM_TEXTURE_REMAP_COLOR_B_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_B << GCM_TEXTURE_REMAP_COLOR_G_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_B << GCM_TEXTURE_REMAP_COLOR_R_SHIFT) |
|
||||
(GCM_TEXTURE_REMAP_COLOR_B << GCM_TEXTURE_REMAP_COLOR_A_SHIFT));
|
||||
font->texture.tex.width = font->tex_width;
|
||||
font->texture.tex.height = font->tex_height;
|
||||
font->texture.tex.depth = 1;
|
||||
font->texture.tex.pitch = font->tex_width;
|
||||
font->texture.tex.location = GCM_LOCATION_RSX;
|
||||
font->texture.tex.offset = font->texture.offset;
|
||||
font->texture.wrap_s = GCM_TEXTURE_CLAMP_TO_EDGE;
|
||||
font->texture.wrap_t = GCM_TEXTURE_CLAMP_TO_EDGE;
|
||||
font->texture.min_filter = GCM_TEXTURE_LINEAR;
|
||||
font->texture.mag_filter = GCM_TEXTURE_LINEAR;
|
||||
|
||||
rsxInvalidateTextureCache(font->rsx->context, GCM_INVALIDATE_TEXTURE);
|
||||
rsxLoadTexture(font->rsx->context, font->tex_unit->index, &font->texture.tex);
|
||||
rsxTextureControl(font->rsx->context, font->tex_unit->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
||||
rsxTextureFilter(font->rsx->context, font->tex_unit->index, 0, font->texture.min_filter, font->texture.mag_filter, GCM_TEXTURE_CONVOLUTION_QUINCUNX);
|
||||
rsxTextureWrapMode(font->rsx->context, font->tex_unit->index, font->texture.wrap_s, font->texture.wrap_t, GCM_TEXTURE_CLAMP_TO_EDGE, 0, GCM_TEXTURE_ZFUNC_LESS, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void *rsx_font_init_font(void *data,
|
||||
const char *font_path, float font_size,
|
||||
bool is_threaded)
|
||||
{
|
||||
rsx_font_t *font = (rsx_font_t*)calloc(1, sizeof(*font));
|
||||
|
||||
if (!font)
|
||||
return NULL;
|
||||
|
||||
font->rsx = (rsx_t *)data;
|
||||
|
||||
if (!font_renderer_create_default(
|
||||
&font->font_driver,
|
||||
&font->font_data, font_path, font_size))
|
||||
{
|
||||
RARCH_WARN("Couldn't initialize font renderer.\n");
|
||||
free(font);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (is_threaded)
|
||||
if (
|
||||
font->rsx &&
|
||||
font->rsx->ctx_driver &&
|
||||
font->rsx->ctx_driver->make_current)
|
||||
font->rsx->ctx_driver->make_current(false);
|
||||
|
||||
font->atlas = font->font_driver->get_atlas(font->font_data);
|
||||
|
||||
font->vpo = font->rsx->vpo;
|
||||
font->fpo = font->rsx->fpo;
|
||||
font->fp_ucode = font->rsx->fp_ucode;
|
||||
font->vp_ucode = font->rsx->vp_ucode;
|
||||
font->fp_offset = font->rsx->fp_offset;
|
||||
|
||||
font->proj_matrix = font->rsx->proj_matrix;
|
||||
font->pos_index = font->rsx->pos_index;
|
||||
font->uv_index = font->rsx->uv_index;
|
||||
font->col_index = font->rsx->col_index;
|
||||
font->tex_unit = font->rsx->tex_unit;
|
||||
|
||||
font->vertices = (rsx_vertex_t *)rsxMemalign(128, MAX_MSG_LEN_CHUNK*sizeof(rsx_vertex_t)*6);
|
||||
|
||||
rsxAddressToOffset(&font->vertices[0].x, &font->pos_offset);
|
||||
rsxAddressToOffset(&font->vertices[0].u, &font->uv_offset);
|
||||
rsxAddressToOffset(&font->vertices[0].r, &font->col_offset);
|
||||
|
||||
font->tex_width = font->atlas->width;
|
||||
font->tex_height = font->atlas->height;
|
||||
font->texture.data = (u8 *)rsxMemalign(128, (font->tex_height * font->tex_width));
|
||||
rsxAddressToOffset(font->texture.data, &font->texture.offset);
|
||||
|
||||
if (!font->texture.data)
|
||||
goto error;
|
||||
|
||||
if (!rsx_font_upload_atlas(font))
|
||||
goto error;
|
||||
|
||||
font->atlas->dirty = false;
|
||||
|
||||
rsxTextureControl(font->rsx->context, font->tex_unit->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
||||
return font;
|
||||
|
||||
error:
|
||||
rsx_font_free_font(font, is_threaded);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int rsx_font_get_message_width(void *data, const char *msg,
|
||||
unsigned msg_len, float scale)
|
||||
{
|
||||
rsx_font_t *font = (rsx_font_t*)data;
|
||||
const char* msg_end = msg + msg_len;
|
||||
int delta_x = 0;
|
||||
|
||||
if ( !font
|
||||
|| !font->font_driver
|
||||
|| !font->font_driver->get_glyph
|
||||
|| !font->font_data )
|
||||
return 0;
|
||||
|
||||
while (msg < msg_end)
|
||||
{
|
||||
unsigned code = utf8_walk(&msg);
|
||||
const struct font_glyph *glyph = font->font_driver->get_glyph(
|
||||
font->font_data, code);
|
||||
|
||||
if (!glyph) /* Do something smarter here ... */
|
||||
glyph = font->font_driver->get_glyph(font->font_data, '?');
|
||||
if (!glyph)
|
||||
continue;
|
||||
|
||||
delta_x += glyph->advance_x;
|
||||
}
|
||||
|
||||
return delta_x * scale;
|
||||
}
|
||||
|
||||
static void rsx_font_draw_vertices(rsx_font_t *font,
|
||||
const video_coords_t *coords)
|
||||
{
|
||||
if (font->atlas->dirty)
|
||||
{
|
||||
rsx_font_upload_atlas(font);
|
||||
font->atlas->dirty = false;
|
||||
}
|
||||
|
||||
const float *vertex = coords->vertex;
|
||||
const float *tex_coord = coords->tex_coord;
|
||||
const float *color = coords->color;
|
||||
|
||||
for (u32 i = 0; i < coords->vertices; i++) {
|
||||
font->vertices[i].x = *vertex++;
|
||||
font->vertices[i].y = *vertex++;
|
||||
font->vertices[i].z = 0.0f;
|
||||
font->vertices[i].u = *tex_coord++;
|
||||
font->vertices[i].v = *tex_coord++;
|
||||
font->vertices[i].r = *color++;
|
||||
font->vertices[i].g = *color++;
|
||||
font->vertices[i].b = *color++;
|
||||
font->vertices[i].a = *color++;
|
||||
}
|
||||
|
||||
rsxBindVertexArrayAttrib(font->rsx->context, font->pos_index->index, 0, font->pos_offset, sizeof(rsx_vertex_t), 3, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(font->rsx->context, font->uv_index->index, 0, font->uv_offset, sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
rsxBindVertexArrayAttrib(font->rsx->context, font->col_index->index, 0, font->col_offset, sizeof(rsx_vertex_t), 4, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
||||
|
||||
rsxSetVertexProgramParameter(font->rsx->context, font->vpo, font->proj_matrix, (float*)&font->rsx->mvp_no_rot);
|
||||
rsxClearSurface(font->rsx->context, GCM_CLEAR_Z);
|
||||
rsxDrawVertexArray(font->rsx->context, GCM_TYPE_TRIANGLES, 0, coords->vertices);
|
||||
}
|
||||
|
||||
static void rsx_font_render_line(
|
||||
rsx_font_t *font, const char *msg, unsigned msg_len,
|
||||
float scale, const float color[4], float pos_x,
|
||||
float pos_y,unsigned text_align)
|
||||
{
|
||||
unsigned i;
|
||||
struct video_coords coords;
|
||||
float font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
|
||||
float font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK];
|
||||
float font_color[4 * 6 * MAX_MSG_LEN_CHUNK];
|
||||
rsx_t *rsx = font->rsx;
|
||||
const char* msg_end = msg + msg_len;
|
||||
int x = roundf(pos_x * rsx->vp.width);
|
||||
int y = roundf(pos_y * rsx->vp.height);
|
||||
int delta_x = 0;
|
||||
int delta_y = 0;
|
||||
float inv_tex_size_x = 1.0f / font->tex_width;
|
||||
float inv_tex_size_y = 1.0f / font->tex_height;
|
||||
float inv_win_width = 1.0f / font->rsx->vp.width;
|
||||
float inv_win_height = 1.0f / font->rsx->vp.height;
|
||||
|
||||
switch (text_align)
|
||||
{
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
x -= rsx_font_get_message_width(font, msg, msg_len, scale);
|
||||
break;
|
||||
case TEXT_ALIGN_CENTER:
|
||||
x -= rsx_font_get_message_width(font, msg, msg_len, scale) / 2.0;
|
||||
break;
|
||||
}
|
||||
|
||||
while (msg < msg_end)
|
||||
{
|
||||
i = 0;
|
||||
while ((i < MAX_MSG_LEN_CHUNK) && (msg < msg_end))
|
||||
{
|
||||
int off_x, off_y, tex_x, tex_y, width, height;
|
||||
unsigned code = utf8_walk(&msg);
|
||||
const struct font_glyph *glyph = font->font_driver->get_glyph(
|
||||
font->font_data, code);
|
||||
|
||||
if (!glyph) /* Do something smarter here ... */
|
||||
glyph = font->font_driver->get_glyph(font->font_data, '?');
|
||||
|
||||
if (!glyph)
|
||||
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;
|
||||
|
||||
RSX_FONT_EMIT(0, 0, 1); /* Bottom-left */
|
||||
RSX_FONT_EMIT(1, 1, 1); /* Bottom-right */
|
||||
RSX_FONT_EMIT(2, 0, 0); /* Top-left */
|
||||
|
||||
RSX_FONT_EMIT(3, 1, 0); /* Top-right */
|
||||
RSX_FONT_EMIT(4, 0, 0); /* Top-left */
|
||||
RSX_FONT_EMIT(5, 1, 1); /* Bottom-right */
|
||||
|
||||
i++;
|
||||
|
||||
delta_x += glyph->advance_x;
|
||||
delta_y -= glyph->advance_y;
|
||||
}
|
||||
|
||||
coords.tex_coord = font_tex_coords;
|
||||
coords.vertex = font_vertex;
|
||||
coords.color = font_color;
|
||||
coords.vertices = i * 6;
|
||||
coords.lut_tex_coord = font_tex_coords;
|
||||
|
||||
if (font->block)
|
||||
video_coord_array_append(&font->block->carr, &coords, coords.vertices);
|
||||
else
|
||||
rsx_font_draw_vertices(font, &coords);
|
||||
}
|
||||
}
|
||||
|
||||
static void rsx_font_render_message(
|
||||
rsx_font_t *font, const char *msg, float scale,
|
||||
const float color[4], float pos_x, float pos_y,
|
||||
unsigned text_align)
|
||||
{
|
||||
struct font_line_metrics *line_metrics = NULL;
|
||||
int lines = 0;
|
||||
float line_height;
|
||||
|
||||
/* 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))
|
||||
{
|
||||
rsx_font_render_line(font,
|
||||
msg, (unsigned)strlen(msg), scale, color, pos_x,
|
||||
pos_y, text_align);
|
||||
return;
|
||||
}
|
||||
|
||||
line_height = line_metrics->height * scale / font->rsx->vp.height;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const char *delim = strchr(msg, '\n');
|
||||
unsigned msg_len = delim
|
||||
? (unsigned)(delim - msg) : (unsigned)strlen(msg);
|
||||
|
||||
/* Draw the line */
|
||||
rsx_font_render_line(font,
|
||||
msg, msg_len, scale, color, pos_x,
|
||||
pos_y - (float)lines*line_height, text_align);
|
||||
|
||||
if (!delim)
|
||||
break;
|
||||
|
||||
msg += msg_len + 1;
|
||||
lines++;
|
||||
}
|
||||
}
|
||||
|
||||
static void rsx_font_setup_viewport(unsigned width, unsigned height,
|
||||
rsx_font_t *font, bool full_screen)
|
||||
{
|
||||
video_driver_set_viewport(width, height, full_screen, false);
|
||||
|
||||
if (font->rsx) {
|
||||
rsxSetBlendFunc(font->rsx->context, GCM_SRC_ALPHA, GCM_ONE_MINUS_SRC_ALPHA, GCM_SRC_ALPHA, GCM_ONE_MINUS_SRC_ALPHA);
|
||||
rsxSetBlendEquation(font->rsx->context, GCM_FUNC_ADD, GCM_FUNC_ADD);
|
||||
rsxSetBlendEnable(font->rsx->context, GCM_TRUE);
|
||||
|
||||
rsxLoadVertexProgram(font->rsx->context, font->vpo, font->vp_ucode);
|
||||
rsxLoadFragmentProgramLocation(font->rsx->context, font->fpo, font->fp_offset, GCM_LOCATION_RSX);
|
||||
|
||||
rsxLoadTexture(font->rsx->context, font->tex_unit->index, &font->texture.tex);
|
||||
rsxTextureControl(font->rsx->context, font->tex_unit->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
||||
}
|
||||
}
|
||||
|
||||
static void rsx_font_render_msg(
|
||||
void *userdata,
|
||||
void *data,
|
||||
const char *msg,
|
||||
const struct font_params *params)
|
||||
{
|
||||
float color[4];
|
||||
int drop_x, drop_y;
|
||||
float x, y, scale, drop_mod, drop_alpha;
|
||||
enum text_alignment text_align = TEXT_ALIGN_LEFT;
|
||||
bool full_screen = false ;
|
||||
rsx_font_t *font = (rsx_font_t*)data;
|
||||
unsigned width = font->rsx->width;
|
||||
unsigned height = font->rsx->height;
|
||||
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;
|
||||
|
||||
if (!font || string_is_empty(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;
|
||||
|
||||
color[0] = FONT_COLOR_GET_RED(params->color) / 255.0f;
|
||||
color[1] = FONT_COLOR_GET_GREEN(params->color) / 255.0f;
|
||||
color[2] = FONT_COLOR_GET_BLUE(params->color) / 255.0f;
|
||||
color[3] = FONT_COLOR_GET_ALPHA(params->color) / 255.0f;
|
||||
|
||||
/* If alpha is 0.0f, turn it into default 1.0f */
|
||||
if (color[3] <= 0.0f)
|
||||
color[3] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = video_msg_pos_x;
|
||||
y = video_msg_pos_y;
|
||||
scale = 1.0f;
|
||||
full_screen = true;
|
||||
text_align = TEXT_ALIGN_LEFT;
|
||||
|
||||
color[0] = video_msg_color_r;
|
||||
color[1] = video_msg_color_g;
|
||||
color[2] = video_msg_color_b;
|
||||
color[3] = 1.0f;
|
||||
|
||||
drop_x = -2;
|
||||
drop_y = -2;
|
||||
drop_mod = 0.3f;
|
||||
drop_alpha = 1.0f;
|
||||
}
|
||||
|
||||
if (font->block)
|
||||
font->block->fullscreen = full_screen;
|
||||
else
|
||||
rsx_font_setup_viewport(width, height, font, full_screen);
|
||||
|
||||
if (font->rsx)
|
||||
{
|
||||
if (!string_is_empty(msg)
|
||||
&& font->font_data && font->font_driver)
|
||||
{
|
||||
if (drop_x || drop_y)
|
||||
{
|
||||
float color_dark[4];
|
||||
|
||||
color_dark[0] = color[0] * drop_mod;
|
||||
color_dark[1] = color[1] * drop_mod;
|
||||
color_dark[2] = color[2] * drop_mod;
|
||||
color_dark[3] = color[3] * drop_alpha;
|
||||
|
||||
rsx_font_render_message(font, msg, scale, color_dark,
|
||||
x + scale * drop_x / font->rsx->vp.width, y +
|
||||
scale * drop_y / font->rsx->vp.height, text_align);
|
||||
}
|
||||
|
||||
rsx_font_render_message(font, msg, scale, color,
|
||||
x, y, text_align);
|
||||
}
|
||||
|
||||
if (!font->block)
|
||||
{
|
||||
rsxTextureControl(font->rsx->context, font->rsx->tex_unit->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
||||
rsxSetBlendEnable(font->rsx->context, GCM_FALSE);
|
||||
video_driver_set_viewport(width, height, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const struct font_glyph *rsx_font_get_glyph(
|
||||
void *data, uint32_t code)
|
||||
{
|
||||
rsx_font_t *font = (rsx_font_t*)data;
|
||||
|
||||
if (!font || !font->font_driver || !font->font_driver->ident)
|
||||
return NULL;
|
||||
return font->font_driver->get_glyph((void*)font->font_driver, code);
|
||||
}
|
||||
|
||||
static void rsx_font_flush_block(unsigned width, unsigned height,
|
||||
void *data)
|
||||
{
|
||||
rsx_font_t *font = (rsx_font_t*)data;
|
||||
video_font_raster_block_t *block = font ? font->block : NULL;
|
||||
|
||||
if (!font || !block || !block->carr.coords.vertices)
|
||||
return;
|
||||
|
||||
rsx_font_setup_viewport(width, height, font, block->fullscreen);
|
||||
rsx_font_draw_vertices(font, (video_coords_t*)&block->carr.coords);
|
||||
|
||||
if (font->rsx)
|
||||
{
|
||||
rsxTextureControl(font->rsx->context, font->rsx->tex_unit->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
||||
rsxSetBlendEnable(font->rsx->context, GCM_FALSE);
|
||||
video_driver_set_viewport(width, height, block->fullscreen, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void rsx_font_bind_block(void *data, void *userdata)
|
||||
{
|
||||
rsx_font_t *font = (rsx_font_t*)data;
|
||||
video_font_raster_block_t *block = (video_font_raster_block_t*)userdata;
|
||||
|
||||
if (font)
|
||||
font->block = block;
|
||||
}
|
||||
|
||||
static bool rsx_font_get_line_metrics(void* data, struct font_line_metrics **metrics)
|
||||
{
|
||||
rsx_font_t *font = (rsx_font_t*)data;
|
||||
|
||||
if (!font || !font->font_driver || !font->font_data)
|
||||
return -1;
|
||||
|
||||
return font->font_driver->get_line_metrics(font->font_data, metrics);
|
||||
}
|
||||
|
||||
font_renderer_t rsx_font = {
|
||||
rsx_font_init_font,
|
||||
rsx_font_free_font,
|
||||
rsx_font_render_msg,
|
||||
"rsxfont",
|
||||
rsx_font_get_glyph,
|
||||
rsx_font_bind_block,
|
||||
rsx_font_flush_block,
|
||||
rsx_font_get_message_width,
|
||||
rsx_font_get_line_metrics
|
||||
};
|
@ -678,6 +678,37 @@ static bool wiiu_font_init_first(
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __PSL1GHT__
|
||||
static const font_renderer_t *rsx_font_backends[] = {
|
||||
&rsx_font,
|
||||
NULL
|
||||
};
|
||||
|
||||
static bool rsx_font_init_first(
|
||||
const void **font_driver, void **font_handle,
|
||||
void *video_data, const char *font_path,
|
||||
float font_size, bool is_threaded)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; rsx_font_backends[i]; i++)
|
||||
{
|
||||
void *data = rsx_font_backends[i]->init(
|
||||
video_data, font_path, font_size,
|
||||
is_threaded);
|
||||
|
||||
if (!data)
|
||||
continue;
|
||||
|
||||
*font_driver = rsx_font_backends[i];
|
||||
*font_handle = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool font_init_first(
|
||||
const void **font_driver, void **font_handle,
|
||||
void *video_data, const char *font_path, float font_size,
|
||||
@ -773,6 +804,11 @@ static bool font_init_first(
|
||||
return switch_font_init_first(font_driver, font_handle,
|
||||
video_data, font_path, font_size, is_threaded);
|
||||
#endif
|
||||
#ifdef __PSL1GHT__
|
||||
case FONT_DRIVER_RENDER_RSX:
|
||||
return rsx_font_init_first(font_driver, font_handle,
|
||||
video_data, font_path, font_size, is_threaded);
|
||||
#endif
|
||||
#ifdef HAVE_GDI
|
||||
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
|
||||
case FONT_DRIVER_RENDER_GDI:
|
||||
|
@ -193,6 +193,7 @@ extern font_renderer_t gdi_font;
|
||||
extern font_renderer_t vga_font;
|
||||
extern font_renderer_t sixel_font;
|
||||
extern font_renderer_t switch_font;
|
||||
extern font_renderer_t rsx_font;
|
||||
|
||||
extern font_renderer_driver_t stb_font_renderer;
|
||||
extern font_renderer_driver_t stb_unicode_font_renderer;
|
||||
|
@ -120,6 +120,9 @@ static gfx_display_ctx_driver_t *gfx_display_ctx_drivers[] = {
|
||||
#ifdef WIIU
|
||||
&gfx_display_ctx_wiiu,
|
||||
#endif
|
||||
#ifdef __PSL1GHT__
|
||||
&gfx_display_ctx_rsx,
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
|
||||
#ifdef HAVE_GDI
|
||||
&gfx_display_ctx_gdi,
|
||||
@ -224,6 +227,10 @@ static bool gfx_display_check_compatibility(
|
||||
if (string_is_equal(video_driver, "switch"))
|
||||
return true;
|
||||
break;
|
||||
case GFX_VIDEO_DRIVER_RSX:
|
||||
if (string_is_equal(video_driver, "rsx"))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -102,7 +102,8 @@ enum gfx_display_driver_type
|
||||
GFX_VIDEO_DRIVER_CTR,
|
||||
GFX_VIDEO_DRIVER_WIIU,
|
||||
GFX_VIDEO_DRIVER_GDI,
|
||||
GFX_VIDEO_DRIVER_SWITCH
|
||||
GFX_VIDEO_DRIVER_SWITCH,
|
||||
GFX_VIDEO_DRIVER_RSX
|
||||
};
|
||||
|
||||
typedef struct gfx_display_frame_info
|
||||
@ -358,6 +359,7 @@ extern gfx_display_ctx_driver_t gfx_display_ctx_ctr;
|
||||
extern gfx_display_ctx_driver_t gfx_display_ctx_wiiu;
|
||||
extern gfx_display_ctx_driver_t gfx_display_ctx_gdi;
|
||||
extern gfx_display_ctx_driver_t gfx_display_ctx_switch;
|
||||
extern gfx_display_ctx_driver_t gfx_display_ctx_rsx;
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -109,7 +109,8 @@ enum font_driver_render_api
|
||||
FONT_DRIVER_RENDER_NETWORK_VIDEO,
|
||||
FONT_DRIVER_RENDER_GDI,
|
||||
FONT_DRIVER_RENDER_VGA,
|
||||
FONT_DRIVER_RENDER_SWITCH
|
||||
FONT_DRIVER_RENDER_SWITCH,
|
||||
FONT_DRIVER_RENDER_RSX
|
||||
};
|
||||
|
||||
enum text_alignment
|
||||
|
@ -536,6 +536,7 @@ VIDEO DRIVER
|
||||
|
||||
#if defined(__PSL1GHT__)
|
||||
#include "../gfx/drivers/rsx_gfx.c"
|
||||
#include "../gfx/drivers_display/gfx_display_rsx.c"
|
||||
#elif defined(GEKKO)
|
||||
#include "../gfx/drivers/gx_gfx.c"
|
||||
#elif defined(PSP)
|
||||
@ -640,6 +641,10 @@ FONTS
|
||||
#include "../gfx/drivers_font/wiiu_font.c"
|
||||
#endif
|
||||
|
||||
#if defined(__PSL1GHT__)
|
||||
#include "../gfx/drivers_font/rsx_font.c"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CACA)
|
||||
#include "../gfx/drivers_font/caca_font.c"
|
||||
#endif
|
||||
@ -709,7 +714,10 @@ INPUT
|
||||
#elif defined(PS2)
|
||||
#include "../input/drivers/ps2_input.c"
|
||||
#include "../input/drivers_joypad/ps2_joypad.c"
|
||||
#elif defined(__PS3__) || defined(__PSL1GHT__)
|
||||
#elif defined(__PSL1GHT__)
|
||||
#include "../input/drivers/psl1ght_input.c"
|
||||
#include "../input/drivers_joypad/ps3_joypad.c"
|
||||
#elif defined(__PS3__)
|
||||
#include "../input/drivers/ps3_input.c"
|
||||
#include "../input/drivers_joypad/ps3_joypad.c"
|
||||
#elif defined(ORBIS)
|
||||
|
@ -1515,6 +1515,16 @@ static uint16_t argb32_to_abgr4444(uint32_t col)
|
||||
return (a << 12) | (b << 8) | (g << 4) | r;
|
||||
}
|
||||
|
||||
/* PS3 */
|
||||
static uint16_t argb32_to_argb4444(uint32_t col)
|
||||
{
|
||||
unsigned a = ((col >> 24) & 0xFF) >> 4;
|
||||
unsigned r = ((col >> 16) & 0xFF) >> 4;
|
||||
unsigned g = ((col >> 8) & 0xFF) >> 4;
|
||||
unsigned b = ( col & 0xFF) >> 4;
|
||||
return (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
|
||||
/* D3D10/11/12 */
|
||||
static uint16_t argb32_to_bgra4444(uint32_t col)
|
||||
{
|
||||
@ -1586,6 +1596,8 @@ static bool rgui_set_pixel_format_function(void)
|
||||
argb32_to_pixel_platform_format = argb32_to_rgb5a3;
|
||||
else if (string_is_equal(driver_ident, "psp1")) /* PSP */
|
||||
argb32_to_pixel_platform_format = argb32_to_abgr4444;
|
||||
else if (string_is_equal(driver_ident, "rsx")) /* PS3 */
|
||||
argb32_to_pixel_platform_format = argb32_to_argb4444;
|
||||
else if (string_is_equal(driver_ident, "d3d10") || /* D3D10/11/12 */
|
||||
string_is_equal(driver_ident, "d3d11") ||
|
||||
string_is_equal(driver_ident, "d3d12"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user