mirror of
https://github.com/libretro/RetroArch
synced 2025-01-27 21:35:25 +00:00
First basic RSX driver for PSL1GHT
This commit is contained in:
parent
32ed7ed1d7
commit
89b46bc246
@ -66,7 +66,7 @@ endif
|
||||
SHARED_FLAGS :=
|
||||
|
||||
SHARED_FLAGS += -DHAVE_VIDEO_LAYOUT
|
||||
SHARED_FLAGS += -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_CHEATS -DRARCH_CONSOLE -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_GCMGL -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_MOUSE -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_GRIFFIN=1 -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -Wno-char-subscripts -DHAVE_CC_RESAMPLER -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_REWIND -DHAVE_MULTIMAN -DHAVE_RGUI
|
||||
SHARED_FLAGS += -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_CHEATS -DRARCH_CONSOLE -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_MOUSE -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_GRIFFIN=1 -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -Wno-char-subscripts -DHAVE_CC_RESAMPLER -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_REWIND -DHAVE_MULTIMAN -DHAVE_RGUI
|
||||
CFLAGS += -std=gnu99 $(SHARED_FLAGS)
|
||||
CXXFLAGS += $(SHARED_FLAGS)
|
||||
|
||||
|
@ -65,6 +65,10 @@
|
||||
|
||||
#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;
|
||||
@ -81,21 +85,20 @@ typedef struct
|
||||
float u;
|
||||
float y;
|
||||
float x;
|
||||
} gcm_scale_vector_t;
|
||||
} rsx_scale_vector_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s16 x0, y0, x1, y1;
|
||||
s16 u0, v0, u1, v1;
|
||||
} gcm_vertex_t;
|
||||
} rsx_vertex_t;
|
||||
|
||||
typedef struct gcm_video
|
||||
{
|
||||
typedef struct {
|
||||
video_viewport_t vp;
|
||||
rsxBuffer buffers[MAX_BUFFERS];
|
||||
rsxBuffer menuBuffers[MAX_BUFFERS];
|
||||
int currentBuffer, menuBuffer;
|
||||
gcmContextData *context;
|
||||
gcmContextData* context;
|
||||
u16 width;
|
||||
u16 height;
|
||||
bool menu_frame_enable;
|
||||
@ -103,24 +106,62 @@ typedef struct gcm_video
|
||||
bool vsync;
|
||||
u32 depth_pitch;
|
||||
u32 depth_offset;
|
||||
u32 *depth_buffer;
|
||||
u32* depth_buffer;
|
||||
|
||||
bool smooth;
|
||||
unsigned rotation;
|
||||
bool keep_aspect;
|
||||
bool should_resize;
|
||||
bool msg_rendering_enabled;
|
||||
} gcm_video_t;
|
||||
|
||||
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 const gfx_ctx_driver_t* rsx_get_context(rsx_t* rsx)
|
||||
{
|
||||
const gfx_ctx_driver_t* gfx_ctx = NULL;
|
||||
void* ctx_data = NULL;
|
||||
settings_t* settings = config_get_ptr();
|
||||
struct retro_hw_render_callback* hwr = video_driver_get_hw_context();
|
||||
|
||||
bool video_shared_context = settings->bools.video_shared_context;
|
||||
enum gfx_ctx_api api = GFX_CTX_RSX_API;
|
||||
|
||||
rsx->shared_context_use = video_shared_context && hwr->context_type != RETRO_HW_CONTEXT_NONE;
|
||||
|
||||
if ((libretro_get_shared_context())
|
||||
&& (hwr->context_type != RETRO_HW_CONTEXT_NONE))
|
||||
rsx->shared_context_use = true;
|
||||
|
||||
gfx_ctx = video_context_driver_init_first(rsx,
|
||||
settings->arrays.video_context_driver,
|
||||
api, 1, 0, rsx->shared_context_use, &ctx_data);
|
||||
|
||||
if (ctx_data)
|
||||
rsx->ctx_data = ctx_data;
|
||||
|
||||
return gfx_ctx;
|
||||
}
|
||||
|
||||
#ifndef HAVE_THREADS
|
||||
static bool gcm_tasks_finder(retro_task_t *task,void *userdata)
|
||||
static bool rsx_tasks_finder(retro_task_t *task,void *userdata)
|
||||
{
|
||||
return task;
|
||||
}
|
||||
task_finder_data_t gcm_tasks_finder_data = {gcm_tasks_finder, NULL};
|
||||
task_finder_data_t rsx_tasks_finder_data = {rsx_tasks_finder, NULL};
|
||||
#endif
|
||||
|
||||
static int gcm_make_buffer(rsxBuffer * buffer, u16 width, u16 height, int id)
|
||||
static int rsx_make_buffer(rsxBuffer * buffer, u16 width, u16 height, int id)
|
||||
{
|
||||
int depth = sizeof(u32);
|
||||
int pitch = depth * width;
|
||||
@ -150,7 +191,7 @@ error:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int gcm_flip(gcmContextData *context, s32 buffer)
|
||||
static int rsx_flip(gcmContextData *context, s32 buffer)
|
||||
{
|
||||
if (gcmSetFlip(context, buffer) == 0)
|
||||
{
|
||||
@ -165,16 +206,16 @@ static int gcm_flip(gcmContextData *context, s32 buffer)
|
||||
|
||||
#define GCM_LABEL_INDEX 255
|
||||
|
||||
static void gcm_wait_rsx_idle(gcmContextData *context);
|
||||
static void rsx_wait_rsx_idle(gcmContextData *context);
|
||||
|
||||
static void gcm_wait_flip(void)
|
||||
static void rsx_wait_flip(void)
|
||||
{
|
||||
while (gcmGetFlipStatus() != 0)
|
||||
usleep (200); /* Sleep, to not stress the cpu. */
|
||||
gcmResetFlipStatus();
|
||||
}
|
||||
|
||||
static gcmContextData *gcm_init_screen(gcm_video_t* gcm)
|
||||
static gcmContextData *rsx_init_screen(rsx_t* gcm)
|
||||
{
|
||||
/* Context to keep track of the RSX buffer. */
|
||||
gcmContextData *context = NULL;
|
||||
@ -230,7 +271,7 @@ static gcmContextData *gcm_init_screen(gcm_video_t* gcm)
|
||||
gcm->width = res.width;
|
||||
gcm->height = res.height;
|
||||
|
||||
gcm_wait_rsx_idle(context);
|
||||
rsx_wait_rsx_idle(context);
|
||||
|
||||
if (videoConfigure (0, &vconfig, NULL, 0) != 0)
|
||||
goto error;
|
||||
@ -241,7 +282,8 @@ static gcmContextData *gcm_init_screen(gcm_video_t* gcm)
|
||||
gcmSetFlipMode (GCM_FLIP_VSYNC); /* Wait for VSYNC to flip */
|
||||
|
||||
gcm->depth_pitch = res.width * sizeof(u32);
|
||||
gcm->depth_buffer = (u32 *) rsxMemalign (64, (res.height * gcm->depth_pitch)* 2);
|
||||
gcm->depth_buffer = (u32 *) rsxMemalign (64, (res.height * gcm->depth_pitch)); //Beware, if was (res.height * gcm->depth_pitch)*2
|
||||
|
||||
rsxAddressToOffset (gcm->depth_buffer, &gcm->depth_offset);
|
||||
|
||||
gcmResetFlipStatus();
|
||||
@ -273,7 +315,7 @@ static void waitFinish(gcmContextData *context, u32 sLabelVal)
|
||||
sLabelVal++;
|
||||
}
|
||||
|
||||
static void gcm_wait_rsx_idle(gcmContextData *context)
|
||||
static void rsx_wait_rsx_idle(gcmContextData *context)
|
||||
{
|
||||
u32 sLabelVal = 1;
|
||||
|
||||
@ -285,35 +327,43 @@ static void gcm_wait_rsx_idle(gcmContextData *context)
|
||||
waitFinish(context, sLabelVal);
|
||||
}
|
||||
|
||||
static void* gcm_init(const video_info_t* video,
|
||||
static void* rsx_init(const video_info_t* video,
|
||||
input_driver_t** input, void** input_data)
|
||||
{
|
||||
int i;
|
||||
gcm_video_t* gcm = malloc(sizeof(gcm_video_t));
|
||||
rsx_t* rsx = malloc(sizeof(rsx_t));
|
||||
|
||||
if (!gcm)
|
||||
if (!rsx)
|
||||
return NULL;
|
||||
|
||||
memset(gcm, 0, sizeof(gcm_video_t));
|
||||
memset(rsx, 0, sizeof(rsx_t));
|
||||
|
||||
gcm->context = gcm_init_screen(gcm);
|
||||
rsx->context = rsx_init_screen(rsx);
|
||||
const gfx_ctx_driver_t* ctx_driver = rsx_get_context(rsx);
|
||||
|
||||
if (!ctx_driver)
|
||||
return NULL;
|
||||
|
||||
video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver);
|
||||
rsx->ctx_driver = ctx_driver;
|
||||
rsx->video_info = *video;
|
||||
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
gcm_make_buffer(&gcm->buffers[i], gcm->width, gcm->height, i);
|
||||
rsx_make_buffer(&rsx->buffers[i], rsx->width, rsx->height, i);
|
||||
|
||||
for (i = 0; i < MAX_BUFFERS; i++)
|
||||
gcm_make_buffer(&gcm->menuBuffers[i], gcm->width, gcm->height, i + MAX_BUFFERS);
|
||||
rsx_make_buffer(&rsx->menuBuffers[i], rsx->width, rsx->height, i + MAX_BUFFERS);
|
||||
|
||||
gcm_flip(gcm->context, MAX_BUFFERS - 1);
|
||||
rsx_flip(rsx->context, MAX_BUFFERS - 1);
|
||||
|
||||
gcm->vp.x = 0;
|
||||
gcm->vp.y = 0;
|
||||
gcm->vp.width = gcm->width;
|
||||
gcm->vp.height = gcm->height;
|
||||
gcm->vp.full_width = gcm->width;
|
||||
gcm->vp.full_height = gcm->height;
|
||||
gcm->rgb32 = video->rgb32;
|
||||
video_driver_set_size(gcm->vp.width, gcm->vp.height);
|
||||
rsx->vp.x = 0;
|
||||
rsx->vp.y = 0;
|
||||
rsx->vp.width = rsx->width;
|
||||
rsx->vp.height = rsx->height;
|
||||
rsx->vp.full_width = rsx->width;
|
||||
rsx->vp.full_height = rsx->height;
|
||||
rsx->rgb32 = video->rgb32;
|
||||
video_driver_set_size(rsx->vp.width, rsx->vp.height);
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
@ -322,17 +372,19 @@ static void* gcm_init(const video_info_t* video,
|
||||
*input_data = ps3input;
|
||||
}
|
||||
|
||||
return gcm;
|
||||
rsx_context_bind_hw_render(rsx, true);
|
||||
|
||||
return rsx;
|
||||
}
|
||||
|
||||
static void gcm_fill_black(uint32_t *dst, uint32_t *dst_end, size_t sz)
|
||||
static void rsx_fill_black(uint32_t *dst, uint32_t *dst_end, size_t sz)
|
||||
{
|
||||
if (sz > dst_end - dst)
|
||||
sz = dst_end - dst;
|
||||
memset (dst, 0, sz * 4);
|
||||
}
|
||||
|
||||
static void gcm_blit_buffer(
|
||||
static void rsx_blit_buffer(
|
||||
rsxBuffer *buffer, const void *frame, unsigned width,
|
||||
unsigned height, unsigned pitch, int rgb32, bool do_scaling)
|
||||
{
|
||||
@ -379,7 +431,7 @@ static void gcm_blit_buffer(
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
memcpy(dst, src, width * 4);
|
||||
gcm_fill_black(dst + width, dst_end, buffer->width - width);
|
||||
rsx_fill_black(dst + width, dst_end, buffer->width - width);
|
||||
dst += buffer->width;
|
||||
src += pitch;
|
||||
}
|
||||
@ -397,7 +449,7 @@ static void gcm_blit_buffer(
|
||||
u8 b = ((rgb565 << 3) & 0xfc);
|
||||
*dst = (r<<16) | (g<<8) | b;
|
||||
}
|
||||
gcm_fill_black(dst, dst_end, buffer->width - width);
|
||||
rsx_fill_black(dst, dst_end, buffer->width - width);
|
||||
|
||||
dst += buffer->width - width;
|
||||
src += pitch / 2 - width;
|
||||
@ -419,7 +471,7 @@ static void gcm_blit_buffer(
|
||||
dst[l * buffer->width] = c;
|
||||
}
|
||||
for (int l = 0; l < scale; l++)
|
||||
gcm_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
rsx_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
|
||||
dst += buffer->width * scale - width * scale;
|
||||
src += pitch / 4 - width;
|
||||
@ -440,7 +492,7 @@ static void gcm_blit_buffer(
|
||||
dst[l * buffer->width] = c;
|
||||
}
|
||||
for (int l = 0; l < scale; l++)
|
||||
gcm_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
rsx_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
||||
|
||||
dst += buffer->width * scale - width * scale;
|
||||
src += pitch / 2 - width;
|
||||
@ -452,25 +504,25 @@ static void gcm_blit_buffer(
|
||||
memset(dst, 0, 4 * (dst_end - dst));
|
||||
}
|
||||
|
||||
static void gcm_update_screen(gcm_video_t *gcm)
|
||||
static void rsx_update_screen(rsx_t* gcm)
|
||||
{
|
||||
rsxBuffer *buffer = gcm->menu_frame_enable
|
||||
? &gcm->menuBuffers[gcm->menuBuffer]
|
||||
: &gcm->buffers[gcm->currentBuffer];
|
||||
gcm_flip(gcm->context, buffer->id);
|
||||
rsx_flip(gcm->context, buffer->id);
|
||||
if (gcm->vsync)
|
||||
gcm_wait_flip();
|
||||
rsx_wait_flip();
|
||||
#ifdef HAVE_SYSUTILS
|
||||
cellSysutilCheckCallback();
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool gcm_frame(void* data, const void* frame,
|
||||
static bool rsx_frame(void* data, const void* frame,
|
||||
unsigned width, unsigned height,
|
||||
uint64_t frame_count,
|
||||
unsigned pitch, const char* msg, video_frame_info_t *video_info)
|
||||
{
|
||||
gcm_video_t *gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
#ifdef HAVE_MENU
|
||||
bool statistics_show = video_info->statistics_show;
|
||||
struct font_params *osd_params = (struct font_params*)
|
||||
@ -482,13 +534,13 @@ static bool gcm_frame(void* data, const void* frame,
|
||||
gcm->currentBuffer++;
|
||||
if (gcm->currentBuffer >= MAX_BUFFERS)
|
||||
gcm->currentBuffer = 0;
|
||||
gcm_blit_buffer(
|
||||
rsx_blit_buffer(
|
||||
&gcm->buffers[gcm->currentBuffer], frame, width, height, pitch,
|
||||
gcm->rgb32, true);
|
||||
}
|
||||
|
||||
/* TODO: translucid menu */
|
||||
gcm_update_screen(gcm);
|
||||
rsx_update_screen(gcm);
|
||||
|
||||
return true;
|
||||
|
||||
@ -505,38 +557,38 @@ static bool gcm_frame(void* data, const void* frame,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gcm_set_nonblock_state(void* data, bool toggle,
|
||||
static void rsx_set_nonblock_state(void* data, bool toggle,
|
||||
bool a, unsigned b)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (gcm)
|
||||
gcm->vsync = !toggle;
|
||||
}
|
||||
|
||||
static bool gcm_alive(void* data)
|
||||
static bool rsx_alive(void* data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gcm_focus(void* data)
|
||||
static bool rsx_focus(void* data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gcm_suppress_screensaver(void* data, bool enable)
|
||||
static bool rsx_suppress_screensaver(void* data, bool enable)
|
||||
{
|
||||
(void)data;
|
||||
(void)enable;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gcm_free(void* data)
|
||||
static void rsx_free(void* data)
|
||||
{
|
||||
int i;
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (!gcm)
|
||||
return;
|
||||
@ -554,38 +606,38 @@ static void gcm_free(void* data)
|
||||
free (gcm);
|
||||
}
|
||||
|
||||
static void gcm_set_texture_frame(void* data, const void* frame, bool rgb32,
|
||||
static void rsx_set_texture_frame(void* data, const void* frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
int newBuffer = gcm->menuBuffer + 1;
|
||||
|
||||
if (newBuffer >= MAX_BUFFERS)
|
||||
newBuffer = 0;
|
||||
|
||||
/* TODO: respect alpha */
|
||||
gcm_blit_buffer(&gcm->menuBuffers[newBuffer], frame, width, height,
|
||||
rsx_blit_buffer(&gcm->menuBuffers[newBuffer], frame, width, height,
|
||||
width * (rgb32 ? 4 : 2), rgb32, true);
|
||||
gcm->menuBuffer = newBuffer;
|
||||
|
||||
gcm_update_screen(gcm);
|
||||
rsx_update_screen(gcm);
|
||||
}
|
||||
|
||||
static void gcm_set_texture_enable(void* data, bool state, bool full_screen)
|
||||
static void rsx_set_texture_enable(void* data, bool state, bool full_screen)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (!gcm)
|
||||
return;
|
||||
|
||||
gcm->menu_frame_enable = state;
|
||||
|
||||
gcm_update_screen(gcm);
|
||||
rsx_update_screen(gcm);
|
||||
}
|
||||
|
||||
static void gcm_set_rotation(void* data, unsigned rotation)
|
||||
static void rsx_set_rotation(void* data, unsigned rotation)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (!gcm)
|
||||
return;
|
||||
@ -593,17 +645,17 @@ static void gcm_set_rotation(void* data, unsigned rotation)
|
||||
gcm->rotation = rotation;
|
||||
gcm->should_resize = true;
|
||||
}
|
||||
static void gcm_set_filtering(void* data, unsigned index, bool smooth)
|
||||
static void rsx_set_filtering(void* data, unsigned index, bool smooth)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (gcm)
|
||||
gcm->smooth = smooth;
|
||||
}
|
||||
|
||||
static void gcm_set_aspect_ratio(void* data, unsigned aspect_ratio_idx)
|
||||
static void rsx_set_aspect_ratio(void* data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
gcm_video_t *gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if(!gcm)
|
||||
return;
|
||||
@ -612,58 +664,58 @@ static void gcm_set_aspect_ratio(void* data, unsigned aspect_ratio_idx)
|
||||
gcm->should_resize = true;
|
||||
}
|
||||
|
||||
static void gcm_apply_state_changes(void* data)
|
||||
static void rsx_apply_state_changes(void* data)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (gcm)
|
||||
gcm->should_resize = true;
|
||||
|
||||
}
|
||||
|
||||
static void gcm_viewport_info(void* data, struct video_viewport* vp)
|
||||
static void rsx_viewport_info(void* data, struct video_viewport* vp)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (gcm)
|
||||
*vp = gcm->vp;
|
||||
}
|
||||
|
||||
static void gcm_set_osd_msg(void *data,
|
||||
static void rsx_set_osd_msg(void *data,
|
||||
video_frame_info_t *video_info,
|
||||
const char *msg,
|
||||
const void *params, void *font)
|
||||
{
|
||||
gcm_video_t* gcm = (gcm_video_t*)data;
|
||||
rsx_t* gcm = (rsx_t*)data;
|
||||
|
||||
if (gcm && gcm->msg_rendering_enabled)
|
||||
font_driver_render_msg(data, msg, params, font);
|
||||
}
|
||||
|
||||
static uint32_t gcm_get_flags(void *data)
|
||||
static uint32_t rsx_get_flags(void *data)
|
||||
{
|
||||
uint32_t flags = 0;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static const video_poke_interface_t gcm_poke_interface = {
|
||||
gcm_get_flags,
|
||||
static const video_poke_interface_t rsx_poke_interface = {
|
||||
rsx_get_flags,
|
||||
NULL, /* load_texture */
|
||||
NULL, /* unload_texture */
|
||||
NULL,
|
||||
NULL,
|
||||
gcm_set_filtering,
|
||||
rsx_set_filtering,
|
||||
NULL, /* get_video_output_size */
|
||||
NULL, /* get_video_output_prev */
|
||||
NULL, /* get_video_output_next */
|
||||
NULL, /* get_current_framebuffer */
|
||||
NULL,
|
||||
gcm_set_aspect_ratio,
|
||||
gcm_apply_state_changes,
|
||||
gcm_set_texture_frame,
|
||||
gcm_set_texture_enable,
|
||||
gcm_set_osd_msg,
|
||||
rsx_set_aspect_ratio,
|
||||
rsx_apply_state_changes,
|
||||
rsx_set_texture_frame,
|
||||
rsx_set_texture_enable,
|
||||
rsx_set_osd_msg,
|
||||
NULL, /* show_mouse */
|
||||
NULL, /* grab_mouse_toggle */
|
||||
NULL, /* get_current_shader */
|
||||
@ -671,14 +723,14 @@ static const video_poke_interface_t gcm_poke_interface = {
|
||||
NULL /* get_hw_render_interface */
|
||||
};
|
||||
|
||||
static void gcm_get_poke_interface(void* data,
|
||||
static void rsx_get_poke_interface(void* data,
|
||||
const video_poke_interface_t** iface)
|
||||
{
|
||||
(void)data;
|
||||
*iface = &gcm_poke_interface;
|
||||
*iface = &rsx_poke_interface;
|
||||
}
|
||||
|
||||
static bool gcm_set_shader(void* data,
|
||||
static bool rsx_set_shader(void* data,
|
||||
enum rarch_shader_type type, const char* path)
|
||||
{
|
||||
(void)data;
|
||||
@ -690,19 +742,19 @@ static bool gcm_set_shader(void* data,
|
||||
|
||||
video_driver_t video_gcm =
|
||||
{
|
||||
gcm_init,
|
||||
gcm_frame,
|
||||
gcm_set_nonblock_state,
|
||||
gcm_alive,
|
||||
gcm_focus,
|
||||
gcm_suppress_screensaver,
|
||||
rsx_init,
|
||||
rsx_frame,
|
||||
rsx_set_nonblock_state,
|
||||
rsx_alive,
|
||||
rsx_focus,
|
||||
rsx_suppress_screensaver,
|
||||
NULL, /* has_windowed */
|
||||
gcm_set_shader,
|
||||
gcm_free,
|
||||
"gcm",
|
||||
rsx_set_shader,
|
||||
rsx_free,
|
||||
"rsx",
|
||||
NULL, /* set_viewport */
|
||||
gcm_set_rotation,
|
||||
gcm_viewport_info,
|
||||
rsx_set_rotation,
|
||||
rsx_viewport_info,
|
||||
NULL, /* read_viewport */
|
||||
NULL, /* read_frame_raw */
|
||||
#ifdef HAVE_OVERLAY
|
||||
@ -711,5 +763,5 @@ video_driver_t video_gcm =
|
||||
#ifdef HAVE_VIDEO_LAYOUT
|
||||
NULL,
|
||||
#endif
|
||||
gcm_get_poke_interface
|
||||
rsx_get_poke_interface
|
||||
};
|
||||
|
351
gfx/drivers_context/psl1ght_ctx.c
Executable file
351
gfx/drivers_context/psl1ght_ctx.c
Executable file
@ -0,0 +1,351 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <compat/strl.h>
|
||||
|
||||
#include "../../configuration.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
#include <defines/ps3_defines.h>
|
||||
#include "../../frontend/frontend_driver.h"
|
||||
#include <rsx/rsx.h>
|
||||
|
||||
typedef struct gfx_ctx_psl1ght_data
|
||||
{
|
||||
#if defined(HAVE_PSGL)
|
||||
PSGLdevice* gl_device;
|
||||
PSGLcontext* gl_context;
|
||||
#else
|
||||
gcmContextData *rx_context;
|
||||
#endif
|
||||
} gfx_ctx_psl1ght_data_t;
|
||||
|
||||
/* TODO/FIXME - static global */
|
||||
static enum gfx_ctx_api ps3_api = GFX_CTX_RSX_API;
|
||||
|
||||
static void gfx_ctx_psl1ght_get_resolution(unsigned idx,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
CellVideoOutResolution resolution;
|
||||
cellVideoOutGetResolution(idx, &resolution);
|
||||
|
||||
*width = resolution.width;
|
||||
*height = resolution.height;
|
||||
}
|
||||
|
||||
static float gfx_ctx_psl1ght_get_aspect_ratio(void *data)
|
||||
{
|
||||
CellVideoOutState videoState;
|
||||
|
||||
cellVideoOutGetState(CELL_VIDEO_OUT_PRIMARY, 0, &videoState);
|
||||
|
||||
switch (videoState.displayMode.aspect)
|
||||
{
|
||||
case CELL_VIDEO_OUT_ASPECT_4_3:
|
||||
return 4.0f/3.0f;
|
||||
case CELL_VIDEO_OUT_ASPECT_16_9:
|
||||
break;
|
||||
}
|
||||
|
||||
return 16.0f/9.0f;
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_get_available_resolutions(void)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t videomode[] = {
|
||||
CELL_VIDEO_OUT_RESOLUTION_480,
|
||||
CELL_VIDEO_OUT_RESOLUTION_576,
|
||||
CELL_VIDEO_OUT_RESOLUTION_960x1080,
|
||||
CELL_VIDEO_OUT_RESOLUTION_720,
|
||||
CELL_VIDEO_OUT_RESOLUTION_1280x1080,
|
||||
CELL_VIDEO_OUT_RESOLUTION_1440x1080,
|
||||
CELL_VIDEO_OUT_RESOLUTION_1600x1080,
|
||||
CELL_VIDEO_OUT_RESOLUTION_1080
|
||||
};
|
||||
uint32_t resolution_count = 0;
|
||||
bool defaultresolution = true;
|
||||
uint16_t num_videomodes = sizeof(videomode) / sizeof(uint32_t);
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (global->console.screen.resolutions.check)
|
||||
return;
|
||||
|
||||
for (i = 0; i < num_videomodes; i++)
|
||||
{
|
||||
if (cellVideoOutGetResolutionAvailability(
|
||||
CELL_VIDEO_OUT_PRIMARY, videomode[i],
|
||||
CELL_VIDEO_OUT_ASPECT_AUTO, 0))
|
||||
resolution_count++;
|
||||
}
|
||||
|
||||
global->console.screen.resolutions.count = 0;
|
||||
global->console.screen.resolutions.list =
|
||||
malloc(resolution_count * sizeof(uint32_t));
|
||||
|
||||
for (i = 0; i < num_videomodes; i++)
|
||||
{
|
||||
if (cellVideoOutGetResolutionAvailability(
|
||||
CELL_VIDEO_OUT_PRIMARY,
|
||||
videomode[i],
|
||||
CELL_VIDEO_OUT_ASPECT_AUTO, 0))
|
||||
{
|
||||
global->console.screen.resolutions.list[
|
||||
global->console.screen.resolutions.count++] = videomode[i];
|
||||
global->console.screen.resolutions.initial.id = videomode[i];
|
||||
|
||||
if (global->console.screen.resolutions.current.id == videomode[i])
|
||||
{
|
||||
defaultresolution = false;
|
||||
global->console.screen.resolutions.current.idx =
|
||||
global->console.screen.resolutions.count-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* In case we didn't specify a resolution -
|
||||
* make the last resolution
|
||||
that was added to the list (the highest resolution)
|
||||
the default resolution */
|
||||
if (global->console.screen.resolutions.current.id > num_videomodes || defaultresolution)
|
||||
{
|
||||
global->console.screen.resolutions.current.idx = resolution_count - 1;
|
||||
global->console.screen.resolutions.current.id = global->console.screen.resolutions.list[global->console.screen.resolutions.current.idx];
|
||||
}
|
||||
|
||||
global->console.screen.resolutions.check = true;
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_set_swap_interval(void *data, int interval)
|
||||
{
|
||||
#if defined(HAVE_PSGL)
|
||||
if (interval == 1)
|
||||
glEnable(GL_VSYNC_SCE);
|
||||
else
|
||||
glDisable(GL_VSYNC_SCE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static bool gfx_ctx_psl1ght_has_focus(void *data) { return true; }
|
||||
static bool gfx_ctx_psl1ght_suppress_screensaver(void *data, bool enable) { return false; }
|
||||
|
||||
static void gfx_ctx_psl1ght_swap_buffers(void *data)
|
||||
{
|
||||
#ifdef HAVE_PSGL
|
||||
psglSwap();
|
||||
#endif
|
||||
#ifdef HAVE_SYSUTILS
|
||||
cellSysutilCheckCallback();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_get_video_size(void *data,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
gfx_ctx_psl1ght_data_t *psl1ght = (gfx_ctx_psl1ght_data_t*)data;
|
||||
|
||||
#if defined(HAVE_PSGL)
|
||||
if (psl1ght)
|
||||
psglGetDeviceDimensions(ps3->gl_device, width, height);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *gfx_ctx_psl1ght_init(void *video_driver)
|
||||
{
|
||||
printf("gfx_ctx_psl1ght_init: %p\n", video_driver);
|
||||
global_t *global = global_get_ptr();
|
||||
gfx_ctx_psl1ght_data_t *psl1ght = (gfx_ctx_psl1ght_data_t*)
|
||||
calloc(1, sizeof(gfx_ctx_psl1ght_data_t));
|
||||
|
||||
if (!psl1ght)
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
global->console.screen.pal_enable =
|
||||
cellVideoOutGetResolutionAvailability(
|
||||
CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576,
|
||||
CELL_VIDEO_OUT_ASPECT_AUTO, 0);
|
||||
|
||||
gfx_ctx_psl1ght_get_available_resolutions();
|
||||
|
||||
return psl1ght;
|
||||
}
|
||||
|
||||
static bool gfx_ctx_psl1ght_set_video_mode(void *data,
|
||||
unsigned width, unsigned height,
|
||||
bool fullscreen) { return true; }
|
||||
|
||||
static void gfx_ctx_psl1ght_destroy_resources(gfx_ctx_psl1ght_data_t *ps3)
|
||||
{
|
||||
if (!ps3)
|
||||
return;
|
||||
|
||||
#if defined(HAVE_PSGL)
|
||||
psglDestroyContext(ps3->gl_context);
|
||||
psglDestroyDevice(ps3->gl_device);
|
||||
|
||||
psglExit();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_destroy(void *data)
|
||||
{
|
||||
gfx_ctx_psl1ght_data_t *ps3 = (gfx_ctx_psl1ght_data_t*)data;
|
||||
|
||||
if (!ps3)
|
||||
return;
|
||||
|
||||
gfx_ctx_psl1ght_destroy_resources(ps3);
|
||||
free(data);
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *ps3input = input_driver_init_wrap(&input_ps3, joypad_name);
|
||||
|
||||
*input = ps3input ? &input_ps3 : NULL;
|
||||
*input_data = ps3input;
|
||||
}
|
||||
|
||||
static enum gfx_ctx_api gfx_ctx_psl1ght_get_api(void *data) { return ps3_api; }
|
||||
|
||||
static bool gfx_ctx_psl1ght_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
ps3_api = api;
|
||||
|
||||
if (api == GFX_CTX_RSX_API)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_get_video_output_size(void *data,
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!global)
|
||||
return;
|
||||
|
||||
gfx_ctx_psl1ght_get_resolution(global->console.screen.resolutions.current.id,
|
||||
width, height);
|
||||
|
||||
if (*width == 720 && *height == 576)
|
||||
{
|
||||
if (global->console.screen.pal_enable)
|
||||
global->console.screen.pal60_enable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
global->console.screen.pal_enable = false;
|
||||
global->console.screen.pal60_enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_get_video_output_prev(void *data)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!global)
|
||||
return;
|
||||
|
||||
if (global->console.screen.resolutions.current.idx)
|
||||
{
|
||||
global->console.screen.resolutions.current.idx--;
|
||||
global->console.screen.resolutions.current.id =
|
||||
global->console.screen.resolutions.list
|
||||
[global->console.screen.resolutions.current.idx];
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_get_video_output_next(void *data)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!global)
|
||||
return;
|
||||
|
||||
if (global->console.screen.resolutions.current.idx + 1 <
|
||||
global->console.screen.resolutions.count)
|
||||
{
|
||||
global->console.screen.resolutions.current.idx++;
|
||||
global->console.screen.resolutions.current.id =
|
||||
global->console.screen.resolutions.list
|
||||
[global->console.screen.resolutions.current.idx];
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t gfx_ctx_psl1ght_get_flags(void *data)
|
||||
{
|
||||
uint32_t flags = 0;
|
||||
|
||||
#ifdef HAVE_CG
|
||||
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_CG);
|
||||
#endif
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static void gfx_ctx_psl1ght_set_flags(void *data, uint32_t flags) { }
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_psl1ght = {
|
||||
gfx_ctx_psl1ght_init,
|
||||
gfx_ctx_psl1ght_destroy,
|
||||
gfx_ctx_psl1ght_get_api,
|
||||
gfx_ctx_psl1ght_bind_api,
|
||||
gfx_ctx_psl1ght_set_swap_interval,
|
||||
gfx_ctx_psl1ght_set_video_mode,
|
||||
gfx_ctx_psl1ght_get_video_size,
|
||||
NULL, /* get_refresh_rate */
|
||||
gfx_ctx_psl1ght_get_video_output_size,
|
||||
gfx_ctx_psl1ght_get_video_output_prev,
|
||||
gfx_ctx_psl1ght_get_video_output_next,
|
||||
NULL, /* get_metrics */
|
||||
NULL,
|
||||
NULL, /* update_title */
|
||||
gfx_ctx_psl1ght_check_window,
|
||||
NULL, /* set_resize */
|
||||
gfx_ctx_psl1ght_has_focus,
|
||||
gfx_ctx_psl1ght_suppress_screensaver,
|
||||
false, /* has_windowed */
|
||||
gfx_ctx_psl1ght_swap_buffers,
|
||||
gfx_ctx_psl1ght_input_driver,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"psl1ght",
|
||||
gfx_ctx_psl1ght_get_flags,
|
||||
gfx_ctx_psl1ght_set_flags,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
@ -268,7 +268,9 @@ VIDEO CONTEXT
|
||||
#include "../gfx/drivers_context/qnx_ctx.c"
|
||||
#elif defined(EMSCRIPTEN)
|
||||
#include "../gfx/drivers_context/emscriptenegl_ctx.c"
|
||||
#elif defined(__PS3__) && !defined(__PSL1GHT__)
|
||||
#elif defined(__PSL1GHT__)
|
||||
#include "../gfx/drivers_context/psl1ght_ctx.c"
|
||||
#elif defined(__PS3__)
|
||||
#include "../gfx/drivers_context/ps3_ctx.c"
|
||||
#endif
|
||||
|
||||
|
@ -660,6 +660,9 @@ extern int audioAddData(uint32_t portNum, float *data,
|
||||
#define CELL_SYSMODULE_SYSUTIL_NP SYSMODULE_SYSUTIL_NP
|
||||
#define CELL_SYSMODULE_JPGDEC SYSMODULE_JPGDEC
|
||||
#define CELL_SYSMODULE_PNGDEC SYSMODULE_PNGDEC
|
||||
#define CELL_SYSMODULE_FONT SYSMODULE_FONT
|
||||
#define CELL_SYSMODULE_FREETYPE SYSMODULE_FREETYPE
|
||||
#define CELL_SYSMODULE_FONTFT SYSMODULE_FONTFT
|
||||
|
||||
#define cellSysmoduleLoadModule sysModuleLoad
|
||||
#define cellSysmoduleUnloadModule sysModuleUnload
|
||||
|
@ -32861,6 +32861,7 @@ const gfx_ctx_driver_t *video_context_driver_init_first(void *data,
|
||||
case GFX_CTX_OPENGL_ES_API:
|
||||
case GFX_CTX_OPENVG_API:
|
||||
case GFX_CTX_METAL_API:
|
||||
case GFX_CTX_RSX_API:
|
||||
return gl_context_driver_init_first(
|
||||
p_rarch, settings,
|
||||
data, ident, api, major, minor,
|
||||
|
@ -839,7 +839,8 @@ enum gfx_ctx_api
|
||||
GFX_CTX_DIRECT3D12_API,
|
||||
GFX_CTX_OPENVG_API,
|
||||
GFX_CTX_VULKAN_API,
|
||||
GFX_CTX_METAL_API
|
||||
GFX_CTX_METAL_API,
|
||||
GFX_CTX_RSX_API
|
||||
};
|
||||
|
||||
enum display_metric_types
|
||||
|
Loading…
x
Reference in New Issue
Block a user