2020-03-07 21:27:38 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2020 Google
|
|
|
|
*
|
|
|
|
* 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 <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <malloc.h>
|
2023-02-23 16:11:01 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
#include <math.h>
|
2020-03-07 21:27:38 +01:00
|
|
|
|
|
|
|
#include <retro_inline.h>
|
|
|
|
#include <retro_math.h>
|
|
|
|
#include <formats/image.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "../../menu/menu_driver.h"
|
|
|
|
#endif
|
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
#include "../gfx_widgets.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "../common/rsx_common.h"
|
2020-03-07 21:27:38 +01:00
|
|
|
#include "../font_driver.h"
|
|
|
|
|
|
|
|
#include "../../configuration.h"
|
|
|
|
#include "../../command.h"
|
|
|
|
#include "../../driver.h"
|
|
|
|
|
|
|
|
#include "../../retroarch.h"
|
2022-10-10 04:37:17 +02:00
|
|
|
#include "../../runloop.h"
|
2020-03-07 21:27:38 +01:00
|
|
|
#include "../../verbosity.h"
|
|
|
|
|
|
|
|
#ifndef HAVE_THREADS
|
|
|
|
#include "../../tasks/tasks_internal.h"
|
|
|
|
#endif
|
|
|
|
|
2021-05-18 22:15:04 +02:00
|
|
|
#include <defines/ps3_defines.h>
|
2020-03-07 21:27:38 +01:00
|
|
|
|
|
|
|
#define CB_SIZE 0x100000
|
|
|
|
#define HOST_SIZE (32*1024*1024)
|
|
|
|
|
2023-02-23 16:11:01 +01:00
|
|
|
#ifdef __PSL1GHT__
|
|
|
|
#include <rsx/rsx.h>
|
|
|
|
#include <rsx/nv40.h>
|
|
|
|
#include <ppu-types.h>
|
2020-03-07 21:27:38 +01:00
|
|
|
#include <ppu-lv2.h>
|
|
|
|
#include <sysutil/video.h>
|
|
|
|
#include <rsx/gcm_sys.h>
|
|
|
|
#include <rsx/rsx.h>
|
|
|
|
#include <io/pad.h>
|
2023-02-23 16:11:01 +01:00
|
|
|
#endif
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
#define rsx_context_bind_hw_render(rsx, enable) \
|
|
|
|
if (rsx->shared_context_use) \
|
|
|
|
rsx->ctx_driver->bind_hw_render(rsx->ctx_data, enable)
|
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
static void rsx_load_texture_data(rsx_t* rsx, rsx_texture_t *texture,
|
|
|
|
const void *frame, unsigned width, unsigned height, unsigned pitch,
|
2023-02-20 18:32:40 +01:00
|
|
|
bool rgb32, bool menu, enum texture_filter_type filter_type)
|
|
|
|
{
|
|
|
|
u8 *texbuffer;
|
|
|
|
u32 mag_filter, min_filter;
|
|
|
|
const u8 *data = (u8*)frame;
|
|
|
|
|
|
|
|
if (!texture->data)
|
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
texture->data = (u32*)rsxMemalign(128, texture->height * pitch);
|
2023-02-20 18:32:40 +01:00
|
|
|
rsxAddressToOffset(texture->data, &texture->offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
texbuffer = (u8*)texture->data;
|
|
|
|
memcpy(texbuffer, data, height * pitch);
|
|
|
|
|
2023-02-23 16:11:01 +01:00
|
|
|
texture->tex.format = (rgb32
|
|
|
|
? GCM_TEXTURE_FORMAT_A8R8G8B8 :
|
|
|
|
(menu)
|
|
|
|
? GCM_TEXTURE_FORMAT_A4R4G4B4
|
|
|
|
: GCM_TEXTURE_FORMAT_R5G6B5)
|
|
|
|
| GCM_TEXTURE_FORMAT_LIN;
|
2023-02-20 18:32:40 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-02-20 18:45:54 +01:00
|
|
|
static void rsx_set_projection(rsx_t *rsx,
|
|
|
|
struct video_ortho *ortho, bool allow_rotate)
|
|
|
|
{
|
|
|
|
static math_matrix_4x4 rot = {
|
|
|
|
{ 0.0f, 0.0f, 0.0f, 0.0f ,
|
|
|
|
0.0f, 0.0f, 0.0f, 0.0f ,
|
|
|
|
0.0f, 0.0f, 0.0f, 0.0f ,
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f }
|
|
|
|
};
|
|
|
|
float radians, cosine, sine;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
radians = M_PI * rsx->rotation / 180.0f;
|
|
|
|
cosine = cosf(radians);
|
|
|
|
sine = sinf(radians);
|
|
|
|
MAT_ELEM_4X4(rot, 0, 0) = cosine;
|
|
|
|
MAT_ELEM_4X4(rot, 0, 1) = -sine;
|
|
|
|
MAT_ELEM_4X4(rot, 1, 0) = sine;
|
|
|
|
MAT_ELEM_4X4(rot, 1, 1) = cosine;
|
|
|
|
matrix_4x4_multiply(rsx->mvp, rot, rsx->mvp_no_rot);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
static void rsx_set_viewport(void *data, unsigned viewport_width,
|
|
|
|
unsigned viewport_height, bool force_full, bool allow_rotate)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
rsx_viewport_t vp;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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 (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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static const gfx_ctx_driver_t* rsx_get_context(rsx_t* rsx)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
const gfx_ctx_driver_t* gfx_ctx = NULL;
|
|
|
|
void* ctx_data = NULL;
|
|
|
|
settings_t* settings = config_get_ptr();
|
2021-07-12 09:35:44 +02:00
|
|
|
struct retro_hw_render_callback* hwr = video_driver_get_hw_context();
|
2023-02-20 16:13:23 +01:00
|
|
|
bool video_shared_context = settings->bools.video_shared_context;
|
|
|
|
enum gfx_ctx_api api = GFX_CTX_RSX_API;
|
2021-07-12 09:35:44 +02:00
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->shared_context_use = video_shared_context && hwr->context_type != RETRO_HW_CONTEXT_NONE;
|
2021-07-12 09:35:44 +02:00
|
|
|
|
2022-10-10 04:37:17 +02:00
|
|
|
if ((runloop_get_flags() & RUNLOOP_FLAG_CORE_SET_SHARED_CONTEXT)
|
2021-07-12 09:35:44 +02:00
|
|
|
&& (hwr->context_type != RETRO_HW_CONTEXT_NONE))
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->shared_context_use = true;
|
2021-07-12 09:35:44 +02:00
|
|
|
|
|
|
|
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)
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->ctx_data = ctx_data;
|
2021-07-12 09:35:44 +02:00
|
|
|
|
|
|
|
return gfx_ctx;
|
|
|
|
}
|
2020-03-07 21:27:38 +01:00
|
|
|
|
|
|
|
#ifndef HAVE_THREADS
|
2023-01-24 01:18:39 +01:00
|
|
|
static bool rsx_tasks_finder(retro_task_t *task,void *userdata) { return task; }
|
2021-07-12 09:35:44 +02:00
|
|
|
task_finder_data_t rsx_tasks_finder_data = {rsx_tasks_finder, NULL};
|
2020-03-07 21:27:38 +01:00
|
|
|
#endif
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static int rsx_make_buffer(rsxBuffer * buffer, u16 width, u16 height, int id)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
int depth = sizeof(u32);
|
|
|
|
int pitch = depth * width;
|
|
|
|
int size = depth * width * height;
|
2023-02-20 16:13:23 +01:00
|
|
|
if (!(buffer->ptr = (uint32_t*)rsxMemalign (64, size)))
|
2020-05-12 15:10:15 +02:00
|
|
|
goto error;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
if (rsxAddressToOffset(buffer->ptr, &buffer->offset) != 0)
|
2020-05-12 15:10:15 +02:00
|
|
|
goto error;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
/* Register the display buffer with the RSX */
|
2023-02-20 18:32:40 +01:00
|
|
|
if (gcmSetDisplayBuffer(id, buffer->offset, pitch, width, height) != 0)
|
2020-05-12 15:10:15 +02:00
|
|
|
goto error;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-01-24 01:18:39 +01:00
|
|
|
buffer->width = width;
|
2020-05-12 15:10:15 +02:00
|
|
|
buffer->height = height;
|
2023-01-24 01:18:39 +01:00
|
|
|
buffer->id = id;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-01-24 01:18:39 +01:00
|
|
|
return 1;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
error:
|
|
|
|
if (buffer->ptr)
|
|
|
|
rsxFree (buffer->ptr);
|
2023-01-24 01:18:39 +01:00
|
|
|
return 0;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static int rsx_flip(gcmContextData *context, s32 buffer)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2020-05-12 15:10:15 +02:00
|
|
|
if (gcmSetFlip(context, buffer) == 0)
|
|
|
|
{
|
|
|
|
rsxFlushBuffer (context);
|
|
|
|
/* Prevent the RSX from continuing until the flip has finished. */
|
|
|
|
gcmSetWaitFlip (context);
|
2023-01-24 01:18:39 +01:00
|
|
|
return 1;
|
2020-05-12 15:10:15 +02:00
|
|
|
}
|
2023-01-24 01:18:39 +01:00
|
|
|
return 0;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GCM_LABEL_INDEX 255
|
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
static void rsx_wait_finish(gcmContextData *context, u32 sLabelVal)
|
|
|
|
{
|
2023-02-20 18:32:40 +01:00
|
|
|
rsxSetWriteBackendLabel(context, GCM_LABEL_INDEX, sLabelVal);
|
2023-02-20 16:13:23 +01:00
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
rsxFlushBuffer(context);
|
2023-02-20 16:13:23 +01:00
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
while(*(vu32 *)gcmGetLabelAddress(GCM_LABEL_INDEX) != sLabelVal)
|
2023-02-20 16:13:23 +01:00
|
|
|
usleep(30);
|
|
|
|
|
|
|
|
sLabelVal++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rsx_wait_rsx_idle(gcmContextData *context)
|
|
|
|
{
|
|
|
|
u32 sLabelVal = 1;
|
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
rsxSetWriteBackendLabel(context, GCM_LABEL_INDEX, sLabelVal);
|
|
|
|
rsxSetWaitLabel(context, GCM_LABEL_INDEX, sLabelVal);
|
2023-02-20 16:13:23 +01:00
|
|
|
|
|
|
|
sLabelVal++;
|
|
|
|
|
|
|
|
rsx_wait_finish(context, sLabelVal);
|
|
|
|
}
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_wait_flip(void)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
while(gcmGetFlipStatus() != 0)
|
2023-02-20 18:32:40 +01:00
|
|
|
usleep(200); /* Sleep, to not stress the cpu. */
|
2020-05-12 15:10:15 +02:00
|
|
|
gcmResetFlipStatus();
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static gcmContextData *rsx_init_screen(rsx_t* gcm)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2020-05-12 15:10:15 +02:00
|
|
|
videoState state;
|
|
|
|
videoConfiguration vconfig;
|
|
|
|
videoResolution res; /* Screen Resolution */
|
2023-02-20 16:13:23 +01:00
|
|
|
/* Context to keep track of the RSX buffer. */
|
|
|
|
gcmContextData *context = NULL;
|
|
|
|
static gcmContextData *saved_context = NULL;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
if (!saved_context)
|
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
/* Allocate a 1MB buffer, alligned to a 1MB boundary
|
|
|
|
* to be our shared I/O memory with the RSX. */
|
2023-02-20 18:32:40 +01:00
|
|
|
void *host_addr = memalign(1024*1024, HOST_SIZE);
|
2020-05-12 15:10:15 +02:00
|
|
|
|
|
|
|
if (!host_addr)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Initialise Reality, which sets up the
|
|
|
|
* command buffer and shared I/O memory */
|
2020-07-24 18:39:00 +02:00
|
|
|
#ifdef NV40TCL_RENDER_ENABLE
|
2023-02-23 16:11:01 +01:00
|
|
|
/* There was an API breakage on 2020-07-10, let's
|
2020-07-24 18:39:00 +02:00
|
|
|
* workaround this by using one of the new defines */
|
2023-02-20 18:32:40 +01:00
|
|
|
rsxInit(&context, CB_SIZE, HOST_SIZE, host_addr);
|
2020-07-24 18:39:00 +02:00
|
|
|
#else
|
2023-02-20 18:32:40 +01:00
|
|
|
context = rsxInit(CB_SIZE, HOST_SIZE, host_addr);
|
2020-07-24 18:39:00 +02:00
|
|
|
#endif
|
2020-05-12 15:10:15 +02:00
|
|
|
if (!context)
|
|
|
|
goto error;
|
|
|
|
saved_context = context;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
context = saved_context;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
/* Get the state of the display */
|
2023-02-20 18:32:40 +01:00
|
|
|
if (videoGetState(0, 0, &state) != 0)
|
2020-03-07 21:27:38 +01:00
|
|
|
goto error;
|
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
/* Make sure display is enabled */
|
|
|
|
if (state.state != 0)
|
2020-03-07 21:27:38 +01:00
|
|
|
goto error;
|
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
/* Get the current resolution */
|
2023-02-20 18:32:40 +01:00
|
|
|
if (videoGetResolution(state.displayMode.resolution, &res) != 0)
|
2020-05-12 15:10:15 +02:00
|
|
|
goto error;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
/* Configure the buffer format to xRGB */
|
2023-02-20 16:13:23 +01:00
|
|
|
memset(&vconfig, 0, sizeof(videoConfiguration));
|
2020-05-12 15:10:15 +02:00
|
|
|
vconfig.resolution = state.displayMode.resolution;
|
|
|
|
vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
|
|
|
|
vconfig.pitch = res.width * sizeof(u32);
|
|
|
|
vconfig.aspect = state.displayMode.aspect;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
gcm->width = res.width;
|
|
|
|
gcm->height = res.height;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_wait_rsx_idle(context);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
if (videoConfigure(0, &vconfig, NULL, 0) != 0)
|
2020-05-12 15:10:15 +02:00
|
|
|
goto error;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
if (videoGetState(0, 0, &state) != 0)
|
2020-05-12 15:10:15 +02:00
|
|
|
goto error;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
gcmSetFlipMode(GCM_FLIP_VSYNC); /* Wait for VSYNC to flip */
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
gcm->depth_pitch = res.width * sizeof(u32);
|
2023-02-20 18:32:40 +01:00
|
|
|
gcm->depth_buffer = (u32 *)rsxMemalign(64, (res.height * gcm->depth_pitch)); /* Beware, if was (res.height * gcm->depth_pitch) * 2 */
|
2021-07-12 09:35:44 +02:00
|
|
|
|
2023-02-20 18:32:40 +01:00
|
|
|
rsxAddressToOffset(gcm->depth_buffer, &gcm->depth_offset);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
gcmResetFlipStatus();
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
return context;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
error:
|
|
|
|
#if 0
|
|
|
|
if (context)
|
2023-02-20 18:32:40 +01:00
|
|
|
rsxFinish(context, 0);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
if (gcm->host_addr)
|
2023-02-20 18:32:40 +01:00
|
|
|
free(gcm->host_addr);
|
2020-05-12 15:10:15 +02:00
|
|
|
#endif
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
return NULL;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
static void rsx_init_render_target(rsx_t *rsx, rsxBuffer * buffer, int id)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
u32 i;
|
2022-03-26 18:51:33 -07:00
|
|
|
memset(&rsx->surface[id], 0, sizeof(gcmSurface));
|
2023-02-20 16:13:23 +01:00
|
|
|
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 (i = 1; i < GCM_MAX_MRT_COUNT; i++)
|
|
|
|
{
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx->surface[id].colorLocation[i] = GCM_LOCATION_RSX;
|
|
|
|
rsx->surface[id].colorOffset[i] = buffer->offset;
|
|
|
|
rsx->surface[id].colorPitch[i] = 64;
|
|
|
|
}
|
2023-02-20 16:13:23 +01:00
|
|
|
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;
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rsx_init_vertices(rsx_t *rsx)
|
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
rsx->vertices = (rsx_vertex_t *)rsxMemalign(128, sizeof(rsx_vertex_t) * RSX_MAX_VERTICES); /* vertices for menu and core */
|
|
|
|
rsx->vert_idx = 0;
|
|
|
|
|
|
|
|
rsx->vertices[0].x = 0.0f;
|
|
|
|
rsx->vertices[0].y = 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].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].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].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;
|
2022-03-26 18:51:33 -07:00
|
|
|
|
2023-02-09 23:29:45 -08:00
|
|
|
#if RSX_MAX_TEXTURE_VERTICES > 0
|
|
|
|
/* Using preallocated texture vertices */
|
|
|
|
rsx->texture_vertices = (rsx_vertex_t *)rsxMemalign(128, sizeof(rsx_vertex_t) * RSX_MAX_TEXTURE_VERTICES);
|
|
|
|
rsx->texture_vert_idx = 0;
|
|
|
|
#endif
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rsx_init_shader(rsx_t *rsx)
|
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
u32 fpsize = 0;
|
|
|
|
u32 vpsize = 0;
|
2023-02-21 23:14:38 -08:00
|
|
|
rsx->vp_ucode[RSX_SHADER_MENU] = NULL;
|
|
|
|
rsx->fp_ucode[RSX_SHADER_MENU] = NULL;
|
2023-02-23 16:11:01 +01:00
|
|
|
rsx->vpo[RSX_SHADER_MENU] = (rsxVertexProgram*)modern_opaque_vpo;
|
|
|
|
rsx->fpo[RSX_SHADER_MENU] = (rsxFragmentProgram*)modern_opaque_fpo;
|
|
|
|
rsxVertexProgramGetUCode( rsx->vpo[RSX_SHADER_MENU], &rsx->vp_ucode[RSX_SHADER_MENU], &vpsize);
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxFragmentProgramGetUCode(rsx->fpo[RSX_SHADER_MENU], &rsx->fp_ucode[RSX_SHADER_MENU], &fpsize);
|
2023-02-23 16:11:01 +01:00
|
|
|
rsx->fp_buffer[RSX_SHADER_MENU] = (u32*)rsxMemalign(64, fpsize);
|
2023-02-21 23:14:38 -08:00
|
|
|
if (!rsx->fp_buffer[RSX_SHADER_MENU])
|
2023-02-09 23:29:45 -08:00
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
RARCH_ERR("failed to allocate fp_buffer\n");
|
2023-02-09 23:29:45 -08:00
|
|
|
return;
|
|
|
|
}
|
2023-02-21 23:14:38 -08:00
|
|
|
memcpy(rsx->fp_buffer[RSX_SHADER_MENU], rsx->fp_ucode[RSX_SHADER_MENU], fpsize);
|
|
|
|
rsxAddressToOffset(rsx->fp_buffer[RSX_SHADER_MENU], &rsx->fp_offset[RSX_SHADER_MENU]);
|
|
|
|
rsx->proj_matrix[RSX_SHADER_MENU] = rsxVertexProgramGetConst(rsx->vpo[RSX_SHADER_MENU], "modelViewProj");
|
|
|
|
rsx->pos_index[RSX_SHADER_MENU] = rsxVertexProgramGetAttrib(rsx->vpo[RSX_SHADER_MENU], "position");
|
|
|
|
rsx->col_index[RSX_SHADER_MENU] = rsxVertexProgramGetAttrib(rsx->vpo[RSX_SHADER_MENU], "color");
|
|
|
|
rsx->uv_index[RSX_SHADER_MENU] = rsxVertexProgramGetAttrib(rsx->vpo[RSX_SHADER_MENU], "texcoord");
|
|
|
|
rsx->tex_unit[RSX_SHADER_MENU] = rsxFragmentProgramGetAttrib(rsx->fpo[RSX_SHADER_MENU], "texture");
|
|
|
|
|
|
|
|
rsx->vp_ucode[RSX_SHADER_STOCK_BLEND] = NULL;
|
|
|
|
rsx->fp_ucode[RSX_SHADER_STOCK_BLEND] = NULL;
|
|
|
|
rsx->vpo[RSX_SHADER_STOCK_BLEND] = (rsxVertexProgram *)modern_alpha_blend_vpo;
|
|
|
|
rsx->fpo[RSX_SHADER_STOCK_BLEND] = (rsxFragmentProgram *)modern_alpha_blend_fpo;
|
|
|
|
rsxVertexProgramGetUCode(rsx->vpo[RSX_SHADER_STOCK_BLEND], &rsx->vp_ucode[RSX_SHADER_STOCK_BLEND], &vpsize);
|
|
|
|
rsxFragmentProgramGetUCode(rsx->fpo[RSX_SHADER_STOCK_BLEND], &rsx->fp_ucode[RSX_SHADER_STOCK_BLEND], &fpsize);
|
|
|
|
rsx->fp_buffer[RSX_SHADER_STOCK_BLEND] = (u32 *)rsxMemalign(64, fpsize);
|
|
|
|
if (!rsx->fp_buffer[RSX_SHADER_STOCK_BLEND])
|
2022-03-26 18:51:33 -07:00
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
RARCH_ERR("failed to allocate fp_buffer\n");
|
2022-03-26 18:51:33 -07:00
|
|
|
return;
|
|
|
|
}
|
2023-02-21 23:14:38 -08:00
|
|
|
memcpy(rsx->fp_buffer[RSX_SHADER_STOCK_BLEND], rsx->fp_ucode[RSX_SHADER_STOCK_BLEND], fpsize);
|
|
|
|
rsxAddressToOffset(rsx->fp_buffer[RSX_SHADER_STOCK_BLEND], &rsx->fp_offset[RSX_SHADER_STOCK_BLEND]);
|
|
|
|
rsx->proj_matrix[RSX_SHADER_STOCK_BLEND] = rsxVertexProgramGetConst(rsx->vpo[RSX_SHADER_STOCK_BLEND], "modelViewProj");
|
|
|
|
rsx->pos_index[RSX_SHADER_STOCK_BLEND] = rsxVertexProgramGetAttrib(rsx->vpo[RSX_SHADER_STOCK_BLEND], "position");
|
|
|
|
rsx->col_index[RSX_SHADER_STOCK_BLEND] = rsxVertexProgramGetAttrib(rsx->vpo[RSX_SHADER_STOCK_BLEND], "color");
|
|
|
|
rsx->uv_index[RSX_SHADER_STOCK_BLEND] = rsxVertexProgramGetAttrib(rsx->vpo[RSX_SHADER_STOCK_BLEND], "texcoord");
|
|
|
|
rsx->tex_unit[RSX_SHADER_STOCK_BLEND] = rsxFragmentProgramGetAttrib(rsx->fpo[RSX_SHADER_STOCK_BLEND], "texture");
|
|
|
|
rsx->bgcolor[RSX_SHADER_STOCK_BLEND] = rsxFragmentProgramGetConst(rsx->fpo[RSX_SHADER_STOCK_BLEND], "bgcolor");
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void* rsx_init(const video_info_t* video,
|
2020-03-07 21:27:38 +01:00
|
|
|
input_driver_t** input, void** input_data)
|
|
|
|
{
|
2020-05-12 15:10:15 +02:00
|
|
|
int i;
|
2023-02-23 16:11:01 +01:00
|
|
|
const gfx_ctx_driver_t* ctx_driver = NULL;
|
|
|
|
rsx_t* rsx = (rsx_t*)malloc(sizeof(rsx_t));
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
if (!rsx)
|
2020-03-07 21:27:38 +01:00
|
|
|
return NULL;
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
memset(rsx, 0, sizeof(rsx_t));
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx->context = rsx_init_screen(rsx);
|
|
|
|
|
2023-02-23 16:11:01 +01:00
|
|
|
if (!(ctx_driver = rsx_get_context(rsx)))
|
|
|
|
{
|
|
|
|
free(rsx);
|
2021-07-12 09:35:44 +02:00
|
|
|
return NULL;
|
2023-02-23 16:11:01 +01:00
|
|
|
}
|
2021-07-12 09:35:44 +02:00
|
|
|
|
|
|
|
video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver);
|
|
|
|
rsx->ctx_driver = ctx_driver;
|
|
|
|
rsx->video_info = *video;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-09 23:29:45 -08:00
|
|
|
for (i = 0; i < RSX_MAX_BUFFERS; i++)
|
2022-03-26 18:51:33 -07:00
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_make_buffer(&rsx->buffers[i], rsx->width, rsx->height, i);
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_init_render_target(rsx, &rsx->buffers[i], i);
|
|
|
|
}
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
#if defined(HAVE_MENU_BUFFER)
|
2023-02-09 23:29:45 -08:00
|
|
|
for (i = 0; i < RSX_MAX_MENU_BUFFERS; i++)
|
2022-03-26 18:51:33 -07:00
|
|
|
{
|
2023-02-09 23:29:45 -08:00
|
|
|
rsx_make_buffer(&rsx->menuBuffers[i], rsx->width, rsx->height, i+RSX_MAX_BUFFERS);
|
|
|
|
rsx_init_render_target(rsx, &rsx->menuBuffers[i], i+RSX_MAX_BUFFERS);
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-02-09 23:29:45 -08:00
|
|
|
for (i = 0; i < RSX_MAX_TEXTURES; i++)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->texture[i].data = NULL;
|
2023-02-09 23:29:45 -08:00
|
|
|
rsx->texture[i].height = rsx->height;
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->texture[i].width = rsx->width;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->menu_texture.data = NULL;
|
|
|
|
rsx->menu_texture.height = rsx->height;
|
|
|
|
rsx->menu_texture.width = rsx->width;
|
2022-03-26 18:51:33 -07:00
|
|
|
|
|
|
|
rsx_init_shader(rsx);
|
|
|
|
rsx_init_vertices(rsx);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-09 23:29:45 -08:00
|
|
|
rsx_flip(rsx->context, RSX_MAX_BUFFERS - 1);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
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;
|
2021-07-12 09:35:44 +02:00
|
|
|
video_driver_set_size(rsx->vp.width, rsx->vp.height);
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_set_viewport(rsx, rsx->vp.width, rsx->vp.height, false, true);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
|
|
|
if (input && input_data)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
void *ps3input = input_driver_init_wrap(&input_ps3, ps3_joypad.ident);
|
|
|
|
*input = ps3input ? &input_ps3 : NULL;
|
|
|
|
*input_data = ps3input;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_context_bind_hw_render(rsx, true);
|
|
|
|
|
2022-07-04 15:28:08 +02:00
|
|
|
if (video->font_enable)
|
|
|
|
{
|
2022-03-26 18:51:33 -07:00
|
|
|
font_driver_init_osd(rsx,
|
|
|
|
video,
|
|
|
|
false,
|
|
|
|
video->is_threaded,
|
|
|
|
FONT_DRIVER_RENDER_RSX);
|
|
|
|
rsx->msg_rendering_enabled = true;
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
return rsx;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2023-02-18 01:44:58 -08:00
|
|
|
static void rsx_update_viewport(rsx_t* rsx)
|
2023-02-09 23:29:45 -08:00
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
2023-02-18 01:44:58 -08:00
|
|
|
unsigned viewport_width = rsx->width;
|
|
|
|
unsigned viewport_height = rsx->height;
|
|
|
|
float device_aspect = ((float)viewport_width) / viewport_height;
|
2023-02-09 23:29:45 -08:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
bool video_scale_integer = settings->bools.video_scale_integer;
|
|
|
|
unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
|
|
|
|
|
|
|
|
if (video_scale_integer)
|
|
|
|
{
|
2023-02-18 01:44:58 -08:00
|
|
|
video_viewport_get_scaled_integer(&rsx->vp, viewport_width,
|
|
|
|
viewport_height, video_driver_get_aspect_ratio(), rsx->keep_aspect);
|
2023-02-20 16:13:23 +01:00
|
|
|
viewport_width = rsx->vp.width;
|
|
|
|
viewport_height = rsx->vp.height;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
else if (rsx->keep_aspect)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
float desired_aspect = video_driver_get_aspect_ratio();
|
2023-02-18 01:44:58 -08:00
|
|
|
|
2023-02-09 23:29:45 -08:00
|
|
|
#if defined(HAVE_MENU)
|
|
|
|
if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
|
|
|
{
|
2023-02-18 01:44:58 -08:00
|
|
|
const struct video_viewport *custom = video_viewport_get_custom();
|
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
x = custom->x;
|
|
|
|
y = custom->y;
|
|
|
|
viewport_width = custom->width;
|
|
|
|
viewport_height = custom->height;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
delta = (desired_aspect / device_aspect - 1.0f)
|
2023-02-09 23:29:45 -08:00
|
|
|
/ 2.0f + 0.5f;
|
2023-02-20 16:13:23 +01:00
|
|
|
x = (int)roundf(viewport_width * (0.5f - delta));
|
|
|
|
viewport_width = (unsigned)roundf(2.0f * viewport_width * delta);
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-02-18 01:44:58 -08:00
|
|
|
delta = (device_aspect / desired_aspect - 1.0f)
|
2023-02-09 23:29:45 -08:00
|
|
|
/ 2.0f + 0.5f;
|
2023-02-18 01:44:58 -08:00
|
|
|
y = (int)roundf(viewport_height * (0.5f - delta));
|
|
|
|
viewport_height = (unsigned)roundf(2.0f * viewport_height * delta);
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->vp.x = x;
|
|
|
|
rsx->vp.y = y;
|
|
|
|
rsx->vp.width = viewport_width;
|
|
|
|
rsx->vp.height = viewport_height;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->vp.x = 0;
|
|
|
|
rsx->vp.y = 0;
|
|
|
|
rsx->vp.width = viewport_width;
|
|
|
|
rsx->vp.height = viewport_height;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->should_resize = false;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
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)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx_t *rsx = (rsx_t *)video_data;
|
2022-03-26 18:51:33 -07:00
|
|
|
struct texture_image *image = (struct texture_image*)data;
|
2023-02-20 16:13:23 +01:00
|
|
|
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);
|
2022-03-26 18:51:33 -07:00
|
|
|
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_texture_t *texture = (rsx_texture_t *)handle;
|
2023-02-09 23:29:45 -08:00
|
|
|
if (texture)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
/* TODO fix crash on loading core */
|
2023-02-23 13:15:14 +01:00
|
|
|
if (texture->data)
|
2022-03-26 18:51:33 -07:00
|
|
|
rsxFree(texture->data);
|
2023-02-09 23:29:45 -08:00
|
|
|
#endif
|
2022-03-26 18:51:33 -07:00
|
|
|
free(texture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-20 15:33:54 +01:00
|
|
|
#if 0
|
|
|
|
/* TODO/FIXME - commenting this code out for now until it gets used */
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_fill_black(uint32_t *dst, uint32_t *dst_end, size_t sz)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
|
|
|
if (sz > dst_end - dst)
|
|
|
|
sz = dst_end - dst;
|
2023-02-20 16:13:23 +01:00
|
|
|
memset(dst, 0, sz * 4);
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_blit_buffer(
|
2020-05-12 15:10:15 +02:00
|
|
|
rsxBuffer *buffer, const void *frame, unsigned width,
|
|
|
|
unsigned height, unsigned pitch, int rgb32, bool do_scaling)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2020-12-20 16:48:52 +01:00
|
|
|
int i;
|
|
|
|
uint32_t *dst;
|
|
|
|
uint32_t *dst_end;
|
|
|
|
int pre_clean;
|
2020-05-12 15:10:15 +02:00
|
|
|
int scale = 1, xofs = 0, yofs = 0;
|
|
|
|
if (width > buffer->width)
|
2020-03-07 21:27:38 +01:00
|
|
|
width = buffer->width;
|
|
|
|
if (height > buffer->height)
|
|
|
|
height = buffer->height;
|
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
if (do_scaling)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
scale = buffer->width / width;
|
2020-05-12 15:10:15 +02:00
|
|
|
if (scale > buffer->height / height)
|
|
|
|
scale = buffer->height / height;
|
|
|
|
if (scale >= 10)
|
|
|
|
scale = 10;
|
|
|
|
if (scale >= 1)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
xofs = (buffer->width - width * scale) / 2;
|
|
|
|
yofs = (buffer->height - height * scale) / 2;
|
2020-05-12 15:10:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
scale = 1;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2020-12-20 16:48:52 +01:00
|
|
|
/* TODO/FIXME: let RSX do the copy */
|
2023-02-20 16:13:23 +01:00
|
|
|
pre_clean = xofs + buffer->width * yofs;
|
|
|
|
dst = buffer->ptr;
|
|
|
|
dst_end = buffer->ptr + buffer->width * buffer->height;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-12-20 16:48:52 +01:00
|
|
|
memset(dst, 0, pre_clean * 4);
|
2023-02-20 16:13:23 +01:00
|
|
|
dst += pre_clean;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
if (scale == 1)
|
|
|
|
{
|
|
|
|
if (rgb32)
|
|
|
|
{
|
|
|
|
const uint8_t *src = frame;
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
|
|
|
memcpy(dst, src, width * 4);
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_fill_black(dst + width, dst_end, buffer->width - width);
|
2020-05-12 15:10:15 +02:00
|
|
|
dst += buffer->width;
|
|
|
|
src += pitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const uint16_t *src = frame;
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
int j;
|
|
|
|
for (j = 0; j < width; j++, src++, dst++)
|
2020-05-12 15:10:15 +02:00
|
|
|
{
|
|
|
|
u16 rgb565 = *src;
|
2023-02-20 16:13:23 +01:00
|
|
|
u8 r = ((rgb565 >> 8) & 0xf8);
|
|
|
|
u8 g = ((rgb565 >> 3) & 0xfc);
|
|
|
|
u8 b = ((rgb565 << 3) & 0xfc);
|
|
|
|
*dst = (r<<16) | (g<<8) | b;
|
2020-05-12 15:10:15 +02:00
|
|
|
}
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_fill_black(dst, dst_end, buffer->width - width);
|
2020-05-12 15:10:15 +02:00
|
|
|
|
|
|
|
dst += buffer->width - width;
|
|
|
|
src += pitch / 2 - width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (rgb32)
|
|
|
|
{
|
|
|
|
const uint32_t *src = frame;
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
int j, l;
|
|
|
|
for (j = 0; j < width; j++, src++)
|
2020-05-12 15:10:15 +02:00
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
int k;
|
2020-05-12 15:10:15 +02:00
|
|
|
u32 c = *src;
|
2023-02-23 16:11:01 +01:00
|
|
|
for (k = 0; k < scale; k++, dst++)
|
|
|
|
for (l = 0; l < scale; l++)
|
2020-05-12 15:10:15 +02:00
|
|
|
dst[l * buffer->width] = c;
|
|
|
|
}
|
2023-02-20 16:13:23 +01:00
|
|
|
for (l = 0; l < scale; l++)
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
2020-05-12 15:10:15 +02:00
|
|
|
|
|
|
|
dst += buffer->width * scale - width * scale;
|
|
|
|
src += pitch / 4 - width;
|
|
|
|
}
|
2023-02-23 16:11:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-12 15:10:15 +02:00
|
|
|
const uint16_t *src = frame;
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
int j, l;
|
|
|
|
for (j = 0; j < width; j++, src++)
|
2020-05-12 15:10:15 +02:00
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
int k;
|
2020-05-12 15:10:15 +02:00
|
|
|
u16 rgb565 = *src;
|
2023-02-20 16:13:23 +01:00
|
|
|
u8 r = ((rgb565 >> 8) & 0xf8);
|
|
|
|
u8 g = ((rgb565 >> 3) & 0xfc);
|
|
|
|
u8 b = ((rgb565 << 3) & 0xfc);
|
|
|
|
u32 c = (r<<16) | (g<<8) | b;
|
|
|
|
for (k = 0; k < scale; k++, dst++)
|
|
|
|
for (l = 0; l < scale; l++)
|
2020-05-12 15:10:15 +02:00
|
|
|
dst[l * buffer->width] = c;
|
|
|
|
}
|
2023-02-23 16:11:01 +01:00
|
|
|
for (l = 0; l < scale; l++)
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_fill_black(dst + l * buffer->width, dst_end, buffer->width - width * scale);
|
2020-05-12 15:10:15 +02:00
|
|
|
|
|
|
|
dst += buffer->width * scale - width * scale;
|
|
|
|
src += pitch / 2 - width;
|
|
|
|
}
|
|
|
|
}
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
2020-12-20 16:48:52 +01:00
|
|
|
|
2020-03-07 21:27:38 +01:00
|
|
|
if (dst < dst_end)
|
2020-05-12 15:10:15 +02:00
|
|
|
memset(dst, 0, 4 * (dst_end - dst));
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
2023-02-20 15:33:54 +01:00
|
|
|
#endif
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
static void rsx_set_texture(rsx_t* rsx, rsx_texture_t *texture)
|
|
|
|
{
|
|
|
|
rsxInvalidateTextureCache(rsx->context, GCM_INVALIDATE_TEXTURE);
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxLoadTexture(rsx->context, rsx->tex_unit[RSX_SHADER_MENU]->index, &texture->tex);
|
|
|
|
rsxTextureControl(rsx->context, rsx->tex_unit[RSX_SHADER_MENU]->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
|
|
|
rsxTextureFilter(rsx->context, rsx->tex_unit[RSX_SHADER_MENU]->index, 0, texture->min_filter, texture->mag_filter, GCM_TEXTURE_CONVOLUTION_QUINCUNX);
|
|
|
|
rsxTextureWrapMode(rsx->context, rsx->tex_unit[RSX_SHADER_MENU]->index, texture->wrap_s, texture->wrap_t, GCM_TEXTURE_CLAMP_TO_EDGE,
|
2023-02-20 16:13:23 +01:00
|
|
|
0, GCM_TEXTURE_ZFUNC_LESS, 0);
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rsx_set_menu_texture(rsx_t* rsx, rsx_texture_t *texture)
|
|
|
|
{
|
|
|
|
rsxInvalidateTextureCache(rsx->context, GCM_INVALIDATE_TEXTURE);
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxLoadTexture(rsx->context, rsx->tex_unit[RSX_SHADER_STOCK_BLEND]->index, &texture->tex);
|
|
|
|
rsxTextureControl(rsx->context, rsx->tex_unit[RSX_SHADER_STOCK_BLEND]->index, GCM_TRUE, 0 << 8, 12 << 8, GCM_TEXTURE_MAX_ANISO_1);
|
|
|
|
rsxTextureFilter(rsx->context, rsx->tex_unit[RSX_SHADER_STOCK_BLEND]->index, 0, texture->min_filter,
|
2023-02-20 16:13:23 +01:00
|
|
|
texture->mag_filter, GCM_TEXTURE_CONVOLUTION_QUINCUNX);
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxTextureWrapMode(rsx->context, rsx->tex_unit[RSX_SHADER_STOCK_BLEND]->index, texture->wrap_s,
|
2023-02-20 16:13:23 +01:00
|
|
|
texture->wrap_t, GCM_TEXTURE_CLAMP_TO_EDGE, 0, GCM_TEXTURE_ZFUNC_LESS, 0);
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rsx_clear_surface(rsx_t* rsx)
|
|
|
|
{
|
|
|
|
rsxSetColorMask(rsx->context,
|
2023-01-24 01:18:39 +01:00
|
|
|
GCM_COLOR_MASK_R
|
|
|
|
| GCM_COLOR_MASK_G
|
|
|
|
| GCM_COLOR_MASK_B
|
|
|
|
| GCM_COLOR_MASK_A);
|
2022-03-26 18:51:33 -07:00
|
|
|
|
|
|
|
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,
|
2023-01-24 01:18:39 +01:00
|
|
|
GCM_CLEAR_R
|
|
|
|
| GCM_CLEAR_G
|
|
|
|
| GCM_CLEAR_B
|
|
|
|
| GCM_CLEAR_A
|
|
|
|
| GCM_CLEAR_S
|
|
|
|
| GCM_CLEAR_Z);
|
2023-02-20 14:58:09 +01:00
|
|
|
rsxSetZMinMaxControl(rsx->context, 0, 1, 1);
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rsx_draw_vertices(rsx_t* rsx)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx_vertex_t *vertices = NULL;
|
|
|
|
int end_vert_idx = rsx->vert_idx + 4;
|
2023-02-09 23:29:45 -08:00
|
|
|
if (end_vert_idx > RSX_MAX_VERTICES)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->vert_idx = 0;
|
|
|
|
end_vert_idx = rsx->vert_idx + 4;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
2023-02-20 16:13:23 +01:00
|
|
|
vertices = &rsx->vertices[rsx->vert_idx];
|
2023-02-09 23:29:45 -08:00
|
|
|
|
|
|
|
vertices[rsx->vert_idx+0].x = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+0].y = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+0].u = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+0].v = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].a = 1.0f;
|
|
|
|
|
|
|
|
vertices[rsx->vert_idx+1].x = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].y = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+1].u = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].v = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].a = 1.0f;
|
|
|
|
|
|
|
|
vertices[rsx->vert_idx+2].x = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+2].y = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].u = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+2].v = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+2].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].a = 1.0f;
|
|
|
|
|
|
|
|
vertices[rsx->vert_idx+3].x = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].y = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].u = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].v = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+3].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].a = 1.0f;
|
|
|
|
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxAddressToOffset(&vertices[rsx->vert_idx].x, &rsx->pos_offset[RSX_SHADER_MENU]);
|
|
|
|
rsxAddressToOffset(&vertices[rsx->vert_idx].u, &rsx->uv_offset[RSX_SHADER_MENU]);
|
|
|
|
rsxAddressToOffset(&vertices[rsx->vert_idx].r, &rsx->col_offset[RSX_SHADER_MENU]);
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->vert_idx = end_vert_idx;
|
2023-02-09 23:29:45 -08:00
|
|
|
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxBindVertexArrayAttrib(rsx->context, rsx->pos_index[RSX_SHADER_MENU]->index, 0,
|
|
|
|
rsx->pos_offset[RSX_SHADER_MENU], sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
|
|
|
rsxBindVertexArrayAttrib(rsx->context, rsx->uv_index[RSX_SHADER_MENU]->index, 0,
|
|
|
|
rsx->uv_offset[RSX_SHADER_MENU], sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
|
|
|
rsxBindVertexArrayAttrib(rsx->context, rsx->col_index[RSX_SHADER_MENU]->index, 0,
|
|
|
|
rsx->col_offset[RSX_SHADER_MENU], sizeof(rsx_vertex_t), 4, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
2023-02-09 23:29:45 -08:00
|
|
|
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxLoadVertexProgram(rsx->context, rsx->vpo[RSX_SHADER_MENU], rsx->vp_ucode[RSX_SHADER_MENU]);
|
|
|
|
rsxSetVertexProgramParameter(rsx->context, rsx->vpo[RSX_SHADER_MENU], rsx->proj_matrix[RSX_SHADER_MENU], (float *)&rsx->mvp);
|
|
|
|
rsxLoadFragmentProgramLocation(rsx->context, rsx->fpo[RSX_SHADER_MENU], rsx->fp_offset[RSX_SHADER_MENU], GCM_LOCATION_RSX);
|
2022-03-26 18:51:33 -07:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx_vertex_t *vertices = NULL;
|
|
|
|
int end_vert_idx = rsx->vert_idx + 4;
|
2023-02-09 23:29:45 -08:00
|
|
|
if (end_vert_idx > RSX_MAX_VERTICES)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx->vert_idx = 0;
|
|
|
|
end_vert_idx = rsx->vert_idx + 4;
|
2023-02-09 23:29:45 -08:00
|
|
|
}
|
2023-02-20 16:13:23 +01:00
|
|
|
vertices = &rsx->vertices[rsx->vert_idx];
|
2023-02-09 23:29:45 -08:00
|
|
|
|
|
|
|
vertices[rsx->vert_idx+0].x = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+0].y = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+0].u = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+0].v = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+0].a = rsx->menu_texture_alpha;
|
|
|
|
|
|
|
|
vertices[rsx->vert_idx+1].x = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].y = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+1].u = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].v = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+1].a = rsx->menu_texture_alpha;
|
|
|
|
|
|
|
|
vertices[rsx->vert_idx+2].x = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+2].y = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].u = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+2].v = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+2].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+2].a = rsx->menu_texture_alpha;
|
|
|
|
|
|
|
|
vertices[rsx->vert_idx+3].x = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].y = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].u = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].v = 0.0f;
|
|
|
|
vertices[rsx->vert_idx+3].r = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].g = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].b = 1.0f;
|
|
|
|
vertices[rsx->vert_idx+3].a = rsx->menu_texture_alpha;
|
|
|
|
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxAddressToOffset(&vertices[rsx->vert_idx].x, &rsx->pos_offset[RSX_SHADER_STOCK_BLEND]);
|
|
|
|
rsxAddressToOffset(&vertices[rsx->vert_idx].u, &rsx->uv_offset[RSX_SHADER_STOCK_BLEND]);
|
|
|
|
rsxAddressToOffset(&vertices[rsx->vert_idx].r, &rsx->col_offset[RSX_SHADER_STOCK_BLEND]);
|
2023-02-23 16:11:01 +01:00
|
|
|
rsx->vert_idx = end_vert_idx;
|
2023-02-09 23:29:45 -08:00
|
|
|
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxBindVertexArrayAttrib(rsx->context, rsx->pos_index[RSX_SHADER_STOCK_BLEND]->index, 0,
|
|
|
|
rsx->pos_offset[RSX_SHADER_STOCK_BLEND], sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
|
|
|
rsxBindVertexArrayAttrib(rsx->context, rsx->uv_index[RSX_SHADER_STOCK_BLEND]->index, 0,
|
|
|
|
rsx->uv_offset[RSX_SHADER_STOCK_BLEND], sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
|
|
|
rsxBindVertexArrayAttrib(rsx->context, rsx->col_index[RSX_SHADER_STOCK_BLEND]->index, 0,
|
|
|
|
rsx->col_offset[RSX_SHADER_STOCK_BLEND], sizeof(rsx_vertex_t), 4, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX);
|
2023-02-09 23:29:45 -08:00
|
|
|
|
2023-02-21 23:14:38 -08:00
|
|
|
rsxLoadVertexProgram(rsx->context, rsx->vpo[RSX_SHADER_STOCK_BLEND], rsx->vp_ucode[RSX_SHADER_STOCK_BLEND]);
|
|
|
|
rsxSetVertexProgramParameter(rsx->context, rsx->vpo[RSX_SHADER_STOCK_BLEND], rsx->proj_matrix[RSX_SHADER_STOCK_BLEND], (float *)&rsx->mvp_no_rot);
|
|
|
|
rsxLoadFragmentProgramLocation(rsx->context, rsx->fpo[RSX_SHADER_STOCK_BLEND], rsx->fp_offset[RSX_SHADER_STOCK_BLEND], GCM_LOCATION_RSX);
|
2022-03-26 18:51:33 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_update_screen(rsx_t* gcm)
|
2020-05-12 15:10:15 +02:00
|
|
|
{
|
2023-01-24 01:18:39 +01:00
|
|
|
rsxBuffer *buffer = NULL;
|
2022-03-26 18:51:33 -07:00
|
|
|
#if defined(HAVE_MENU_BUFFER)
|
2023-01-24 01:18:39 +01:00
|
|
|
if (gcm->menu_frame_enable)
|
|
|
|
{
|
|
|
|
buffer = &gcm->menuBuffers[gcm->menuBuffer];
|
2023-02-23 16:11:01 +01:00
|
|
|
gcm->menuBuffer = (gcm->menuBuffer + 1) % RSX_MAX_MENU_BUFFERS;
|
2023-02-20 16:13:23 +01:00
|
|
|
gcm->nextBuffer = RSX_MAX_BUFFERS + gcm->menuBuffer;
|
2023-01-24 01:18:39 +01:00
|
|
|
}
|
|
|
|
else
|
2023-02-23 16:11:01 +01:00
|
|
|
#endif
|
2023-01-24 01:18:39 +01:00
|
|
|
{
|
|
|
|
buffer = &gcm->buffers[gcm->currentBuffer];
|
2023-02-23 16:11:01 +01:00
|
|
|
gcm->currentBuffer = (gcm->currentBuffer + 1) % RSX_MAX_BUFFERS;
|
2023-01-24 01:18:39 +01:00
|
|
|
gcm->nextBuffer = gcm->currentBuffer;
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_flip(gcm->context, buffer->id);
|
2020-05-12 15:10:15 +02:00
|
|
|
if (gcm->vsync)
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_wait_flip();
|
2022-03-26 18:51:33 -07:00
|
|
|
rsxSetSurface(gcm->context, &gcm->surface[gcm->nextBuffer]);
|
2020-03-07 21:27:38 +01:00
|
|
|
#ifdef HAVE_SYSUTILS
|
|
|
|
cellSysutilCheckCallback();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static bool rsx_frame(void* data, const void* frame,
|
2020-03-07 21:27:38 +01:00
|
|
|
unsigned width, unsigned height,
|
|
|
|
uint64_t frame_count,
|
|
|
|
unsigned pitch, const char* msg, video_frame_info_t *video_info)
|
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
rsx_viewport_t vp;
|
2023-01-24 01:18:39 +01:00
|
|
|
rsx_t *gcm = (rsx_t*)data;
|
2020-08-03 16:33:54 +02:00
|
|
|
#ifdef HAVE_MENU
|
2023-01-24 01:18:39 +01:00
|
|
|
bool statistics_show = video_info->statistics_show;
|
|
|
|
struct font_params *osd_params = (struct font_params*)
|
2020-08-03 16:33:54 +02:00
|
|
|
&video_info->osd_stat_params;
|
2022-03-26 18:51:33 -07:00
|
|
|
bool menu_is_alive = video_info->menu_is_alive;
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
bool widgets_active = video_info->widgets_active;
|
2020-08-03 16:33:54 +02:00
|
|
|
#endif
|
2023-02-20 16:13:23 +01:00
|
|
|
bool draw = false;
|
2023-02-09 23:29:45 -08:00
|
|
|
|
|
|
|
if (gcm->should_resize)
|
2023-02-18 01:44:58 -08:00
|
|
|
rsx_update_viewport(gcm);
|
2023-02-09 23:29:45 -08:00
|
|
|
|
2023-02-20 16:13:23 +01:00
|
|
|
vp.min = 0.0f;
|
|
|
|
vp.max = 1.0f;
|
|
|
|
vp.x = gcm->vp.x;
|
|
|
|
vp.y = gcm->height - gcm->vp.y - gcm->vp.height;
|
|
|
|
vp.w = gcm->vp.width;
|
|
|
|
vp.h = gcm->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;
|
2023-02-09 23:29:45 -08:00
|
|
|
rsxSetViewport(gcm->context, vp.x, vp.y, vp.w, vp.h, vp.min, vp.max, vp.scale, vp.offset);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-23 13:15:14 +01:00
|
|
|
if (frame && width && height)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2023-02-20 16:13:23 +01:00
|
|
|
gcm->tex_index = ((gcm->tex_index + 1) % RSX_MAX_TEXTURES);
|
2023-02-09 23:29:45 -08:00
|
|
|
rsx_load_texture_data(gcm, &gcm->texture[gcm->tex_index], frame, width, height, pitch, gcm->rgb32, false,
|
2022-03-26 18:51:33 -07:00
|
|
|
gcm->smooth ? TEXTURE_FILTER_LINEAR : TEXTURE_FILTER_NEAREST);
|
2023-02-23 16:11:01 +01:00
|
|
|
/* TODO/FIXME - pipeline ID being used here is RSX_SHADER_MENU, shouldn't
|
|
|
|
* this be RSX_SHADER_STOCK_BLEND instead? */
|
2023-02-09 23:29:45 -08:00
|
|
|
rsx_set_texture(gcm, &gcm->texture[gcm->tex_index]);
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_draw_vertices(gcm);
|
2023-02-09 23:29:45 -08:00
|
|
|
draw = true;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
2022-03-26 18:51:33 -07:00
|
|
|
if (gcm->menu_frame_enable && menu_is_alive)
|
|
|
|
{
|
|
|
|
menu_driver_frame(menu_is_alive, video_info);
|
|
|
|
if (gcm->menu_texture.data)
|
|
|
|
{
|
2023-02-23 16:11:01 +01:00
|
|
|
/* TODO/FIXME - pipeline ID being used here is RSX_SHADER_STOCK_BLEND, shouldn't
|
|
|
|
* this be RSX_SHADER_MENU instead? */
|
2023-02-09 23:29:45 -08:00
|
|
|
rsx_set_menu_texture(gcm, &gcm->menu_texture);
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_draw_menu_vertices(gcm);
|
2023-02-09 23:29:45 -08:00
|
|
|
draw = true;
|
2022-03-26 18:51:33 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-03 16:33:54 +02:00
|
|
|
if (statistics_show)
|
2020-03-07 21:27:38 +01:00
|
|
|
if (osd_params)
|
2020-08-03 16:33:54 +02:00
|
|
|
font_driver_render_msg(gcm,
|
|
|
|
video_info->stat_text,
|
|
|
|
osd_params, NULL);
|
2020-03-07 21:27:38 +01:00
|
|
|
#endif
|
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
if (widgets_active)
|
|
|
|
gfx_widgets_frame(video_info);
|
|
|
|
#endif
|
|
|
|
|
2020-03-07 21:27:38 +01:00
|
|
|
if (msg)
|
|
|
|
font_driver_render_msg(gcm, msg, NULL, NULL);
|
2022-03-26 18:51:33 -07:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* TODO: translucid menu */
|
|
|
|
#endif
|
2023-02-09 23:29:45 -08:00
|
|
|
if (draw)
|
|
|
|
{
|
|
|
|
/* Only update when we draw to prevent flickering when core frame duping is enabled */
|
|
|
|
rsx_update_screen(gcm);
|
|
|
|
rsx_clear_surface(gcm);
|
|
|
|
}
|
2023-02-20 16:13:23 +01:00
|
|
|
gcm->vert_idx = 0;
|
2023-02-09 23:29:45 -08:00
|
|
|
gcm->texture_vert_idx = 0;
|
2023-02-20 16:13:23 +01:00
|
|
|
gcm->font_vert_idx = 0;
|
2022-03-26 18:51:33 -07:00
|
|
|
|
2020-03-07 21:27:38 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_set_nonblock_state(void* data, bool toggle,
|
2020-03-07 21:27:38 +01:00
|
|
|
bool a, unsigned b)
|
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2020-03-07 21:27:38 +01:00
|
|
|
if (gcm)
|
|
|
|
gcm->vsync = !toggle;
|
|
|
|
}
|
|
|
|
|
2023-01-24 01:18:39 +01:00
|
|
|
static bool rsx_alive(void* data) { return true; }
|
|
|
|
static bool rsx_focus(void* data) { return true; }
|
|
|
|
static bool rsx_suppress_screensaver(void* data, bool enable) { return false; }
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_free(void* data)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
|
|
|
if (!gcm)
|
|
|
|
return;
|
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
rsxClearSurface(gcm->context, GCM_CLEAR_Z);
|
2020-03-07 21:27:38 +01:00
|
|
|
gcmSetWaitFlip(gcm->context);
|
2023-02-09 23:29:45 -08:00
|
|
|
#if 0
|
|
|
|
/* TODO fix crash on loading core */
|
2022-03-26 18:51:33 -07:00
|
|
|
if (gcm->vertices)
|
|
|
|
rsxFree(gcm->vertices);
|
2023-02-09 23:29:45 -08:00
|
|
|
if (gcm->texture_vertices)
|
|
|
|
rsxFree(gcm->texture_vertices);
|
|
|
|
for (i = 0; i < RSX_MAX_TEXTURES; i++)
|
|
|
|
{
|
|
|
|
if (gcm->texture[i].data)
|
|
|
|
rsxFree(gcm->texture[i].data);
|
|
|
|
}
|
2022-03-26 18:51:33 -07:00
|
|
|
if (gcm->menu_texture.data)
|
|
|
|
rsxFree(gcm->menu_texture.data);
|
2023-02-09 23:29:45 -08:00
|
|
|
for (i = 0; i < RSX_MAX_BUFFERS; i++)
|
|
|
|
rsxFree(gcm->buffers[i].ptr);
|
|
|
|
#if defined(HAVE_MENU_BUFFER)
|
|
|
|
for (i = 0; i < RSX_MAX_MENU_BUFFERS; i++)
|
|
|
|
rsxFree(gcm->menuBuffers[i].ptr);
|
|
|
|
#endif
|
2022-03-26 18:51:33 -07:00
|
|
|
if (gcm->depth_buffer)
|
|
|
|
rsxFree(gcm->depth_buffer);
|
|
|
|
if (gcm->fp_buffer)
|
|
|
|
rsxFree(gcm->fp_buffer);
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2020-05-12 15:10:15 +02:00
|
|
|
rsxFinish(gcm->context, 1);
|
|
|
|
free(gcm->host_addr);
|
|
|
|
#endif
|
2020-03-07 21:27:38 +01:00
|
|
|
free (gcm);
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_set_texture_frame(void* data, const void* frame, bool rgb32,
|
2020-05-12 15:10:15 +02:00
|
|
|
unsigned width, unsigned height, float alpha)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2023-01-24 01:18:39 +01:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2022-03-26 18:51:33 -07:00
|
|
|
gcm->menu_texture_alpha = alpha;
|
2023-01-24 01:18:39 +01:00
|
|
|
gcm->menu_width = width;
|
|
|
|
gcm->menu_height = height;
|
2022-03-26 18:51:33 -07:00
|
|
|
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);
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_set_texture_enable(void* data, bool state, bool full_screen)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2023-01-24 01:18:39 +01:00
|
|
|
if (gcm)
|
|
|
|
gcm->menu_frame_enable = state;
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_set_rotation(void* data, unsigned rotation)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2023-01-24 01:18:39 +01:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2022-03-26 18:51:33 -07:00
|
|
|
struct video_ortho ortho = {0, 1, 0, 1, -1, 1};
|
2020-03-07 21:27:38 +01:00
|
|
|
|
|
|
|
if (!gcm)
|
|
|
|
return;
|
|
|
|
|
2023-01-24 01:18:39 +01:00
|
|
|
gcm->rotation = 90 * rotation;
|
|
|
|
gcm->should_resize = true;
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_set_projection(gcm, &ortho, true);
|
2020-03-07 21:27:38 +01:00
|
|
|
}
|
2022-03-26 18:51:33 -07:00
|
|
|
|
2022-07-03 14:20:10 +02:00
|
|
|
static void rsx_set_filtering(void* data, unsigned index, bool smooth, bool ctx_scaling)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
|
|
|
if (gcm)
|
|
|
|
gcm->smooth = smooth;
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_set_aspect_ratio(void* data, unsigned aspect_ratio_idx)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2023-01-24 01:18:39 +01:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-02-23 13:15:14 +01:00
|
|
|
if (!gcm)
|
2020-03-07 21:27:38 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
gcm->keep_aspect = true;
|
|
|
|
gcm->should_resize = true;
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_apply_state_changes(void* data)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2020-03-07 21:27:38 +01:00
|
|
|
if (gcm)
|
|
|
|
gcm->should_resize = true;
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_viewport_info(void* data, struct video_viewport* vp)
|
2020-03-07 21:27:38 +01:00
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2020-03-07 21:27:38 +01:00
|
|
|
if (gcm)
|
|
|
|
*vp = gcm->vp;
|
|
|
|
}
|
|
|
|
|
2023-02-20 15:33:54 +01:00
|
|
|
#if 0
|
|
|
|
/* TODO/FIXME - does this function have to be hooked up as a function callback
|
|
|
|
* or can it be removed? */
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_set_osd_msg(void *data,
|
2020-03-07 21:27:38 +01:00
|
|
|
video_frame_info_t *video_info,
|
|
|
|
const char *msg,
|
|
|
|
const void *params, void *font)
|
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_t* gcm = (rsx_t*)data;
|
2020-03-07 21:27:38 +01:00
|
|
|
if (gcm && gcm->msg_rendering_enabled)
|
|
|
|
font_driver_render_msg(data, msg, params, font);
|
|
|
|
}
|
2023-02-20 15:33:54 +01:00
|
|
|
#endif
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2023-01-24 01:18:39 +01:00
|
|
|
static uint32_t rsx_get_flags(void *data) { return 0; }
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static const video_poke_interface_t rsx_poke_interface = {
|
|
|
|
rsx_get_flags,
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_load_texture,
|
|
|
|
rsx_unload_texture,
|
2023-02-20 15:33:54 +01:00
|
|
|
NULL, /* set_video_mode */
|
|
|
|
NULL, /* get_refresh_rate */
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_set_filtering,
|
2020-03-07 21:27:38 +01:00
|
|
|
NULL, /* get_video_output_size */
|
|
|
|
NULL, /* get_video_output_prev */
|
|
|
|
NULL, /* get_video_output_next */
|
|
|
|
NULL, /* get_current_framebuffer */
|
2023-02-20 15:33:54 +01:00
|
|
|
NULL, /* get_proc_address */
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_set_aspect_ratio,
|
|
|
|
rsx_apply_state_changes,
|
|
|
|
rsx_set_texture_frame,
|
|
|
|
rsx_set_texture_enable,
|
2022-03-26 18:51:33 -07:00
|
|
|
font_driver_render_msg,
|
2023-02-20 15:33:54 +01:00
|
|
|
NULL, /* show_mouse */
|
|
|
|
NULL, /* grab_mouse_toggle */
|
|
|
|
NULL, /* get_current_shader */
|
|
|
|
NULL, /* get_current_software_framebuffer */
|
|
|
|
NULL, /* get_hw_render_interface */
|
|
|
|
NULL, /* set_hdr_max_nits */
|
|
|
|
NULL, /* set_hdr_paper_white_nits */
|
|
|
|
NULL, /* set_hdr_contrast */
|
|
|
|
NULL /* set_hdr_expand_gamut */
|
2020-03-07 21:27:38 +01:00
|
|
|
};
|
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static void rsx_get_poke_interface(void* data,
|
2023-01-24 01:18:39 +01:00
|
|
|
const video_poke_interface_t** iface) { *iface = &rsx_poke_interface; }
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2021-07-12 09:35:44 +02:00
|
|
|
static bool rsx_set_shader(void* data,
|
2023-01-24 01:18:39 +01:00
|
|
|
enum rarch_shader_type type, const char* path) { return false; }
|
2020-03-07 21:27:38 +01:00
|
|
|
|
2022-03-26 18:51:33 -07:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
2023-01-24 01:18:39 +01:00
|
|
|
static bool rsx_widgets_enabled(void *data) { return true; }
|
2022-03-26 18:51:33 -07:00
|
|
|
#endif
|
|
|
|
|
2020-03-07 21:27:38 +01:00
|
|
|
video_driver_t video_gcm =
|
|
|
|
{
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_init,
|
|
|
|
rsx_frame,
|
|
|
|
rsx_set_nonblock_state,
|
|
|
|
rsx_alive,
|
|
|
|
rsx_focus,
|
|
|
|
rsx_suppress_screensaver,
|
2020-03-07 21:27:38 +01:00
|
|
|
NULL, /* has_windowed */
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_set_shader,
|
|
|
|
rsx_free,
|
|
|
|
"rsx",
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_set_viewport,
|
2021-07-12 09:35:44 +02:00
|
|
|
rsx_set_rotation,
|
|
|
|
rsx_viewport_info,
|
2020-03-07 21:27:38 +01:00
|
|
|
NULL, /* read_viewport */
|
|
|
|
NULL, /* read_frame_raw */
|
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
NULL,
|
|
|
|
#endif
|
2022-03-26 18:51:33 -07:00
|
|
|
rsx_get_poke_interface,
|
|
|
|
rsx_wrap_type_to_enum,
|
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
rsx_widgets_enabled
|
|
|
|
#endif
|
2020-03-07 21:27:38 +01:00
|
|
|
};
|