2016-10-27 00:34:10 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2014-2017 - Ali Bouhlel
|
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2016-10-27 00:34:10 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2017-01-18 21:20:47 +00:00
|
|
|
#include <string.h>
|
2017-01-23 14:59:44 +00:00
|
|
|
#include <wiiu/os.h>
|
|
|
|
#include <wiiu/gx2.h>
|
2017-05-22 00:45:40 +00:00
|
|
|
#include <formats/image.h>
|
2018-01-31 03:49:49 +00:00
|
|
|
#include <file/file_path.h>
|
2018-02-17 10:27:14 +00:00
|
|
|
#include <string/stdstring.h>
|
2017-01-18 21:20:47 +00:00
|
|
|
|
2016-10-27 00:34:10 +00:00
|
|
|
#include "../../driver.h"
|
|
|
|
#include "../../configuration.h"
|
|
|
|
#include "../../verbosity.h"
|
2018-01-31 14:45:26 +00:00
|
|
|
#include "../../retroarch.h"
|
2019-05-29 19:06:44 +00:00
|
|
|
#include "../../managers/state_manager.h"
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2017-01-18 21:20:47 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "../../menu/menu_driver.h"
|
2019-02-07 01:03:48 +00:00
|
|
|
#endif
|
2020-02-17 20:28:42 +00:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
|
|
|
#include "../gfx_widgets.h"
|
2017-01-18 21:20:47 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-21 02:05:41 +00:00
|
|
|
#include "gfx/common/gx2_common.h"
|
2018-01-06 02:39:53 +00:00
|
|
|
#include "gfx/video_shader_parse.h"
|
2019-08-18 16:55:22 +00:00
|
|
|
#include "gfx/drivers_shader/slang_process.h"
|
2016-10-27 00:34:10 +00:00
|
|
|
#include "system/memory.h"
|
|
|
|
|
|
|
|
#include "wiiu_dbg.h"
|
|
|
|
|
2017-01-19 16:20:42 +00:00
|
|
|
#include "../font_driver.h"
|
|
|
|
|
2019-06-19 16:05:21 +00:00
|
|
|
/* Temporary workaround for gx2 not being able to poll flags during init */
|
|
|
|
static gfx_ctx_driver_t wiiu_fake_context;
|
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
static const wiiu_render_mode_t wiiu_render_mode_map[] =
|
|
|
|
{
|
|
|
|
{0}, /* GX2_TV_SCAN_MODE_NONE */
|
|
|
|
{854, 480, GX2_TV_RENDER_MODE_WIDE_480P}, /* GX2_TV_SCAN_MODE_576I */
|
|
|
|
{854, 480, GX2_TV_RENDER_MODE_WIDE_480P}, /* GX2_TV_SCAN_MODE_480I */
|
|
|
|
{854, 480, GX2_TV_RENDER_MODE_WIDE_480P}, /* GX2_TV_SCAN_MODE_480P */
|
|
|
|
{1280, 720, GX2_TV_RENDER_MODE_WIDE_720P}, /* GX2_TV_SCAN_MODE_720P */
|
|
|
|
{0}, /* GX2_TV_SCAN_MODE_unk */
|
|
|
|
{1920, 1080, GX2_TV_RENDER_MODE_WIDE_1080P}, /* GX2_TV_SCAN_MODE_1080I */
|
|
|
|
{1920, 1080, GX2_TV_RENDER_MODE_WIDE_1080P} /* GX2_TV_SCAN_MODE_1080P */
|
|
|
|
};
|
|
|
|
|
2018-01-31 03:49:49 +00:00
|
|
|
static bool wiiu_gfx_set_shader(void *data,
|
2020-03-07 17:05:50 +00:00
|
|
|
enum rarch_shader_type type, const char *path);
|
2018-01-31 03:49:49 +00:00
|
|
|
|
2020-03-07 17:05:50 +00:00
|
|
|
static void wiiu_set_tex_coords(frame_vertex_t *v,
|
|
|
|
GX2Texture *texture, float u0, float v0,
|
|
|
|
float u1, float v1,
|
|
|
|
unsigned rotation)
|
2016-11-05 14:05:46 +00:00
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
v[0].coord.u = u0 / texture->surface.width;
|
|
|
|
v[0].coord.v = v0 / texture->surface.height;
|
|
|
|
v[1].coord.u = u1 / texture->surface.width;
|
|
|
|
v[1].coord.v = v0 / texture->surface.height;
|
|
|
|
v[2].coord.u = u1 / texture->surface.width;
|
|
|
|
v[2].coord.v = v1 / texture->surface.height;
|
|
|
|
v[3].coord.u = u0 / texture->surface.width;
|
|
|
|
v[3].coord.v = v1 / texture->surface.height;
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, v, 4 * sizeof(*v));
|
2016-11-05 14:05:46 +00:00
|
|
|
}
|
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
static void wiiu_set_projection(wiiu_video_t *wiiu)
|
2016-11-05 14:05:46 +00:00
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
math_matrix_4x4 proj, rot;
|
|
|
|
matrix_4x4_ortho(proj, 0, 1, 1, 0, -1, 1);
|
|
|
|
matrix_4x4_rotate_z(rot, wiiu->rotation * -M_PI_2);
|
|
|
|
matrix_4x4_multiply((*wiiu->ubo_mvp), rot, proj);
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->ubo_mvp, sizeof(*wiiu->ubo_mvp));
|
2016-11-05 14:05:46 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_update_viewport(wiiu_video_t *wiiu)
|
2016-11-13 17:43:22 +00:00
|
|
|
{
|
2020-03-02 19:24:00 +00:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
unsigned viewport_width = wiiu->color_buffer.surface.width;
|
|
|
|
unsigned viewport_height = wiiu->color_buffer.surface.height;
|
|
|
|
float device_aspect = (float)viewport_width / viewport_height;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
bool video_scale_integer = settings->bools.video_scale_integer;
|
|
|
|
unsigned video_aspect_ratio_idx = settings->uints.video_aspect_ratio_idx;
|
|
|
|
|
|
|
|
if (video_scale_integer)
|
2016-11-13 17:43:22 +00:00
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
video_viewport_get_scaled_integer(&wiiu->vp,
|
2019-08-13 10:33:09 +00:00
|
|
|
viewport_width, viewport_height,
|
|
|
|
video_driver_get_aspect_ratio(), wiiu->keep_aspect);
|
2018-01-05 12:18:55 +00:00
|
|
|
viewport_width = wiiu->vp.width;
|
|
|
|
viewport_height = wiiu->vp.height;
|
2016-11-13 17:43:22 +00:00
|
|
|
}
|
|
|
|
else if (wiiu->keep_aspect)
|
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
float desired_aspect = video_driver_get_aspect_ratio();
|
|
|
|
|
2016-11-13 17:43:22 +00:00
|
|
|
#if defined(HAVE_MENU)
|
2020-03-02 19:24:00 +00:00
|
|
|
if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM)
|
2016-11-13 17:43:22 +00:00
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
const struct video_viewport *custom = video_viewport_get_custom();
|
2016-11-13 17:43:22 +00:00
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
/* Vulkan has top-left origin viewport. */
|
|
|
|
x = custom->x;
|
|
|
|
y = custom->y;
|
|
|
|
viewport_width = custom->width;
|
|
|
|
viewport_height = custom->height;
|
2016-11-13 17:43:22 +00: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)
|
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
delta = (desired_aspect / device_aspect - 1.0f)
|
2018-01-06 02:39:53 +00:00
|
|
|
/ 2.0f + 0.5f;
|
2018-01-05 12:18:55 +00:00
|
|
|
x = (int)roundf(viewport_width * (0.5f - delta));
|
|
|
|
viewport_width = (unsigned)roundf(2.0f * viewport_width * delta);
|
2016-11-13 17:43:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
delta = (device_aspect / desired_aspect - 1.0f)
|
2018-01-06 02:39:53 +00:00
|
|
|
/ 2.0f + 0.5f;
|
2018-01-05 12:18:55 +00:00
|
|
|
y = (int)roundf(viewport_height * (0.5f - delta));
|
|
|
|
viewport_height = (unsigned)roundf(2.0f * viewport_height * delta);
|
2016-11-13 17:43:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wiiu->vp.x = x;
|
|
|
|
wiiu->vp.y = y;
|
2018-01-05 12:18:55 +00:00
|
|
|
wiiu->vp.width = viewport_width;
|
|
|
|
wiiu->vp.height = viewport_height;
|
2016-11-13 17:43:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-05 12:18:55 +00:00
|
|
|
wiiu->vp.x = 0;
|
|
|
|
wiiu->vp.y = 0;
|
|
|
|
wiiu->vp.width = viewport_width;
|
|
|
|
wiiu->vp.height = viewport_height;
|
2016-11-13 17:43:22 +00:00
|
|
|
}
|
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
wiiu_set_projection(wiiu);
|
2016-11-13 17:43:22 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
2016-11-13 17:43:22 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *)data;
|
2016-11-13 17:43:22 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (!wiiu)
|
2016-11-13 17:43:22 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
wiiu->keep_aspect = true;
|
|
|
|
wiiu->should_resize = true;
|
|
|
|
}
|
2016-11-05 14:05:46 +00:00
|
|
|
|
2019-06-20 19:10:07 +00:00
|
|
|
static uint32_t wiiu_gfx_get_flags(void *data);
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void *wiiu_gfx_init(const video_info_t *video,
|
2019-07-27 00:21:24 +00:00
|
|
|
input_driver_t **input, void **input_data)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
unsigned i;
|
2020-03-02 19:24:00 +00:00
|
|
|
float refresh_rate = 60.0f / 1.001f;
|
|
|
|
u32 size = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
void *wiiuinput = NULL;
|
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t*)calloc(1, sizeof(*wiiu));
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
const char *input_joypad_driver = settings->arrays.input_joypad_driver;
|
2016-10-27 22:02:40 +00:00
|
|
|
|
|
|
|
if (!wiiu)
|
2016-10-27 00:34:10 +00:00
|
|
|
return NULL;
|
|
|
|
|
2017-01-10 20:15:52 +00:00
|
|
|
*input = NULL;
|
|
|
|
*input_data = NULL;
|
|
|
|
|
2016-11-07 01:42:12 +00:00
|
|
|
if (input && input_data)
|
|
|
|
{
|
2020-03-02 19:24:00 +00:00
|
|
|
wiiuinput = input_wiiu.init(input_joypad_driver);
|
2017-01-10 20:15:52 +00:00
|
|
|
*input = wiiuinput ? &input_wiiu : NULL;
|
|
|
|
*input_data = wiiuinput;
|
2016-11-07 01:42:12 +00:00
|
|
|
}
|
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
/* video initialize */
|
2016-11-05 14:05:46 +00:00
|
|
|
wiiu->cmd_buffer = MEM2_alloc(0x400000, 0x40);
|
|
|
|
u32 init_attributes[] =
|
|
|
|
{
|
|
|
|
GX2_INIT_CMD_BUF_BASE, (u32)wiiu->cmd_buffer,
|
|
|
|
GX2_INIT_CMD_BUF_POOL_SIZE, 0x400000,
|
|
|
|
GX2_INIT_ARGC, 0,
|
|
|
|
GX2_INIT_ARGV, 0,
|
|
|
|
GX2_INIT_END
|
|
|
|
};
|
|
|
|
GX2Init(init_attributes);
|
|
|
|
|
2018-01-09 16:05:09 +00:00
|
|
|
wiiu->rgb32 = video->rgb32;
|
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
/* setup scanbuffers */
|
2019-08-08 12:54:21 +00:00
|
|
|
#if 0
|
|
|
|
wiiu->render_mode = wiiu_render_mode_map[GX2_TV_SCAN_MODE_480P];
|
|
|
|
#else
|
2016-11-05 14:05:46 +00:00
|
|
|
wiiu->render_mode = wiiu_render_mode_map[GX2GetSystemTVScanMode()];
|
2019-08-08 12:54:21 +00:00
|
|
|
#endif
|
2017-01-10 20:15:52 +00:00
|
|
|
GX2CalcTVSize(wiiu->render_mode.mode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8,
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2_BUFFERING_MODE_DOUBLE, &size, &tmp);
|
2017-01-10 20:15:52 +00:00
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
wiiu->tv_scan_buffer = MEMBucket_alloc(size, GX2_SCAN_BUFFER_ALIGNMENT);
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, wiiu->tv_scan_buffer, size);
|
2017-01-10 20:15:52 +00:00
|
|
|
GX2SetTVBuffer(wiiu->tv_scan_buffer, size, wiiu->render_mode.mode,
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8,
|
|
|
|
GX2_BUFFERING_MODE_DOUBLE);
|
2017-01-10 20:15:52 +00:00
|
|
|
|
|
|
|
GX2CalcDRCSize(GX2_DRC_RENDER_MODE_SINGLE, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8,
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2_BUFFERING_MODE_DOUBLE, &size,
|
|
|
|
&tmp);
|
2016-11-05 14:05:46 +00:00
|
|
|
|
|
|
|
wiiu->drc_scan_buffer = MEMBucket_alloc(size, GX2_SCAN_BUFFER_ALIGNMENT);
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, wiiu->drc_scan_buffer, size);
|
2017-01-10 20:15:52 +00:00
|
|
|
GX2SetDRCBuffer(wiiu->drc_scan_buffer, size, GX2_DRC_RENDER_MODE_SINGLE,
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8,
|
|
|
|
GX2_BUFFERING_MODE_DOUBLE);
|
2016-11-05 14:05:46 +00:00
|
|
|
|
|
|
|
memset(&wiiu->color_buffer, 0, sizeof(GX2ColorBuffer));
|
2017-01-10 20:15:52 +00:00
|
|
|
|
|
|
|
wiiu->color_buffer.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
|
|
|
wiiu->color_buffer.surface.width = wiiu->render_mode.width;
|
|
|
|
wiiu->color_buffer.surface.height = wiiu->render_mode.height;
|
|
|
|
wiiu->color_buffer.surface.depth = 1;
|
2016-11-05 14:05:46 +00:00
|
|
|
wiiu->color_buffer.surface.mipLevels = 1;
|
2017-01-10 20:15:52 +00:00
|
|
|
wiiu->color_buffer.surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
|
|
|
wiiu->color_buffer.surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV;
|
|
|
|
wiiu->color_buffer.viewNumSlices = 1;
|
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2CalcSurfaceSizeAndAlignment(&wiiu->color_buffer.surface);
|
|
|
|
GX2InitColorBufferRegs(&wiiu->color_buffer);
|
|
|
|
|
|
|
|
wiiu->color_buffer.surface.image = MEM1_alloc(wiiu->color_buffer.surface.imageSize,
|
|
|
|
wiiu->color_buffer.surface.alignment);
|
2017-01-10 20:15:52 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU, wiiu->color_buffer.surface.image,
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu->color_buffer.surface.imageSize);
|
2016-11-05 14:05:46 +00:00
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
wiiu->ctx_state = (GX2ContextState *)MEM2_alloc(sizeof(GX2ContextState),
|
|
|
|
GX2_CONTEXT_STATE_ALIGNMENT);
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2SetupContextStateEx(wiiu->ctx_state, GX2_TRUE);
|
|
|
|
|
|
|
|
GX2SetContextState(wiiu->ctx_state);
|
|
|
|
GX2SetColorBuffer(&wiiu->color_buffer, GX2_RENDER_TARGET_0);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetViewport(0.0f, 0.0f, wiiu->color_buffer.surface.width, wiiu->color_buffer.surface.height,
|
|
|
|
0.0f, 1.0f);
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2SetScissor(0, 0, wiiu->color_buffer.surface.width, wiiu->color_buffer.surface.height);
|
|
|
|
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS);
|
|
|
|
GX2SetColorControl(GX2_LOGIC_OP_COPY, 1, GX2_DISABLE, GX2_ENABLE);
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2SetBlendControl(GX2_RENDER_TARGET_0, GX2_BLEND_MODE_SRC_ALPHA, GX2_BLEND_MODE_INV_SRC_ALPHA,
|
|
|
|
GX2_BLEND_COMBINE_MODE_ADD,
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2_ENABLE, GX2_BLEND_MODE_SRC_ALPHA, GX2_BLEND_MODE_INV_SRC_ALPHA,
|
|
|
|
GX2_BLEND_COMBINE_MODE_ADD);
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2SetCullOnlyControl(GX2_FRONT_FACE_CCW, GX2_DISABLE, GX2_DISABLE);
|
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
GX2InitShader(&frame_shader);
|
2018-01-11 01:09:03 +00:00
|
|
|
GX2InitShader(&tex_shader);
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2InitShader(&sprite_shader);
|
2018-01-12 01:54:45 +00:00
|
|
|
GX2InitShader(&ribbon_simple_shader);
|
2018-01-11 01:09:03 +00:00
|
|
|
GX2InitShader(&ribbon_shader);
|
2018-01-12 01:54:45 +00:00
|
|
|
GX2InitShader(&bokeh_shader);
|
|
|
|
GX2InitShader(&snow_shader);
|
|
|
|
GX2InitShader(&snow_simple_shader);
|
|
|
|
GX2InitShader(&snowflake_shader);
|
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
GX2SetShader(&frame_shader);
|
2017-12-30 22:21:32 +00:00
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
wiiu->ubo_vp = MEM1_alloc(sizeof(*wiiu->ubo_vp), GX2_UNIFORM_BLOCK_ALIGNMENT);
|
|
|
|
wiiu->ubo_vp->width = wiiu->color_buffer.surface.width;
|
|
|
|
wiiu->ubo_vp->height = wiiu->color_buffer.surface.height;
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->ubo_vp, sizeof(*wiiu->ubo_vp));
|
2016-11-05 14:05:46 +00:00
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
wiiu->ubo_tex = MEM1_alloc(sizeof(*wiiu->ubo_tex), GX2_UNIFORM_BLOCK_ALIGNMENT);
|
2018-01-04 16:38:04 +00:00
|
|
|
wiiu->ubo_tex->width = 1.0;
|
|
|
|
wiiu->ubo_tex->height = 1.0;
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->ubo_tex, sizeof(*wiiu->ubo_tex));
|
2016-11-05 14:05:46 +00:00
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
wiiu->ubo_mvp = MEM1_alloc(sizeof(*wiiu->ubo_mvp), GX2_UNIFORM_BLOCK_ALIGNMENT);
|
|
|
|
wiiu_set_projection(wiiu);
|
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
wiiu->input_ring_buffer_size = GX2CalcGeometryShaderInputRingBufferSize(
|
|
|
|
sprite_shader.vs.ringItemSize);
|
|
|
|
wiiu->output_ring_buffer_size = GX2CalcGeometryShaderOutputRingBufferSize(
|
|
|
|
sprite_shader.gs.ringItemSize);
|
2018-01-04 16:38:04 +00:00
|
|
|
wiiu->input_ring_buffer = MEM1_alloc(wiiu->input_ring_buffer_size, 0x1000);
|
|
|
|
wiiu->output_ring_buffer = MEM1_alloc(wiiu->output_ring_buffer_size, 0x1000);
|
2017-12-30 22:21:32 +00:00
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
/* init menu texture */
|
|
|
|
memset(&wiiu->menu.texture, 0, sizeof(GX2Texture));
|
|
|
|
wiiu->menu.texture.surface.width = 512;
|
|
|
|
wiiu->menu.texture.surface.height = 512;
|
|
|
|
wiiu->menu.texture.surface.depth = 1;
|
|
|
|
wiiu->menu.texture.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
|
|
|
wiiu->menu.texture.surface.format = GX2_SURFACE_FORMAT_UNORM_R4_G4_B4_A4;
|
|
|
|
wiiu->menu.texture.surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
|
|
|
wiiu->menu.texture.viewNumSlices = 1;
|
2019-06-05 13:11:11 +00:00
|
|
|
/* Presumably an endian thing. RGBA, but swap R and G, then B and A. */
|
|
|
|
wiiu->menu.texture.compMap = GX2_COMP_SEL(_G, _R, _A, _B);
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2CalcSurfaceSizeAndAlignment(&wiiu->menu.texture.surface);
|
|
|
|
GX2InitTextureRegs(&wiiu->menu.texture);
|
|
|
|
|
|
|
|
wiiu->menu.texture.surface.image = MEM2_alloc(wiiu->menu.texture.surface.imageSize,
|
|
|
|
wiiu->menu.texture.surface.alignment);
|
|
|
|
|
2016-11-06 21:13:07 +00:00
|
|
|
memset(wiiu->menu.texture.surface.image, 0x0, wiiu->menu.texture.surface.imageSize);
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->menu.texture.surface.image,
|
|
|
|
wiiu->menu.texture.surface.imageSize);
|
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
wiiu->v = MEM2_alloc(4 * sizeof(*wiiu->v), GX2_VERTEX_BUFFER_ALIGNMENT);
|
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
wiiu->v[0].pos.x = 0.0f;
|
|
|
|
wiiu->v[0].pos.y = 0.0f;
|
|
|
|
wiiu->v[1].pos.x = 1.0f;
|
|
|
|
wiiu->v[1].pos.y = 0.0f;
|
|
|
|
wiiu->v[2].pos.x = 1.0f;
|
|
|
|
wiiu->v[2].pos.y = 1.0f;
|
|
|
|
wiiu->v[3].pos.x = 0.0f;
|
|
|
|
wiiu->v[3].pos.y = 1.0f;
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, wiiu->v, 4 * sizeof(*wiiu->v));
|
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
wiiu_set_tex_coords(wiiu->v, &wiiu->texture, 0, 0,
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu->texture.surface.width, wiiu->texture.surface.height, wiiu->rotation);
|
2018-01-04 16:38:04 +00:00
|
|
|
|
|
|
|
GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->v), sizeof(*wiiu->v), wiiu->v);
|
|
|
|
|
|
|
|
wiiu->menu.v = MEM2_alloc(4 * sizeof(*wiiu->menu.v), GX2_VERTEX_BUFFER_ALIGNMENT);
|
|
|
|
wiiu->menu.v->pos.x = 0.0f;
|
|
|
|
wiiu->menu.v->pos.y = 0.0f;
|
|
|
|
wiiu->menu.v->pos.width = wiiu->color_buffer.surface.width;
|
|
|
|
wiiu->menu.v->pos.height = wiiu->color_buffer.surface.height;
|
|
|
|
wiiu->menu.v->coord.u = 0.0f;
|
|
|
|
wiiu->menu.v->coord.v = 0.0f;
|
|
|
|
wiiu->menu.v->coord.width = 1.0f;
|
|
|
|
wiiu->menu.v->coord.height = 1.0f;
|
2019-06-05 13:19:35 +00:00
|
|
|
wiiu->menu.v->color = 0xFFFFFFFF;
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, wiiu->menu.v, 4 * sizeof(*wiiu->menu.v));
|
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
wiiu->vertex_cache.size = 0x1000;
|
|
|
|
wiiu->vertex_cache.current = 0;
|
2017-12-31 13:06:49 +00:00
|
|
|
wiiu->vertex_cache.v = MEM2_alloc(wiiu->vertex_cache.size
|
2018-01-06 02:39:53 +00:00
|
|
|
* sizeof(*wiiu->vertex_cache.v), GX2_VERTEX_BUFFER_ALIGNMENT);
|
2017-05-22 00:45:40 +00:00
|
|
|
|
2018-01-11 01:09:03 +00:00
|
|
|
wiiu->vertex_cache_tex.size = 0x1000;
|
|
|
|
wiiu->vertex_cache_tex.current = 0;
|
|
|
|
wiiu->vertex_cache_tex.v = MEM2_alloc(wiiu->vertex_cache_tex.size
|
|
|
|
* sizeof(*wiiu->vertex_cache_tex.v), GX2_VERTEX_BUFFER_ALIGNMENT);
|
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
/* Initialize samplers */
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < RARCH_WRAP_MAX; i++)
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
switch (i)
|
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
case RARCH_WRAP_BORDER:
|
|
|
|
GX2InitSampler(&wiiu->sampler_nearest[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_CLAMP_BORDER,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_POINT);
|
|
|
|
GX2InitSampler(&wiiu->sampler_linear[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_CLAMP_BORDER,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_LINEAR);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RARCH_WRAP_EDGE:
|
|
|
|
GX2InitSampler(&wiiu->sampler_nearest[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_CLAMP,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_POINT);
|
|
|
|
GX2InitSampler(&wiiu->sampler_linear[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_CLAMP,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_LINEAR);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RARCH_WRAP_REPEAT:
|
|
|
|
GX2InitSampler(&wiiu->sampler_nearest[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_WRAP,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_POINT);
|
|
|
|
GX2InitSampler(&wiiu->sampler_linear[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_WRAP,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_LINEAR);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RARCH_WRAP_MIRRORED_REPEAT:
|
|
|
|
GX2InitSampler(&wiiu->sampler_nearest[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_MIRROR,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_POINT);
|
|
|
|
GX2InitSampler(&wiiu->sampler_linear[i],
|
|
|
|
GX2_TEX_CLAMP_MODE_MIRROR,
|
|
|
|
GX2_TEX_XY_FILTER_MODE_LINEAR);
|
|
|
|
break;
|
2018-01-09 15:41:01 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-05 14:05:46 +00:00
|
|
|
|
|
|
|
/* set Texture and Sampler */
|
2018-01-05 12:18:55 +00:00
|
|
|
GX2SetPixelTexture(&wiiu->texture, frame_shader.ps.samplerVars[0].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
GX2SetPixelSampler(&wiiu->sampler_linear[RARCH_WRAP_DEFAULT],
|
|
|
|
frame_shader.ps.samplerVars[0].location);
|
2016-11-05 14:05:46 +00:00
|
|
|
|
2016-11-07 01:42:12 +00:00
|
|
|
/* clear leftover image */
|
|
|
|
GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_DRC);
|
|
|
|
GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_TV);
|
|
|
|
|
|
|
|
GX2SwapScanBuffers();
|
|
|
|
GX2Flush();
|
|
|
|
GX2WaitForVsync();
|
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2SetTVEnable(GX2_ENABLE);
|
|
|
|
GX2SetDRCEnable(GX2_ENABLE);
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
wiiu->keep_aspect = true;
|
|
|
|
wiiu->should_resize = true;
|
|
|
|
wiiu->smooth = video->smooth;
|
|
|
|
wiiu->vsync = video->vsync;
|
2016-11-10 14:11:33 +00:00
|
|
|
GX2SetSwapInterval(!!video->vsync);
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2016-11-13 17:43:22 +00:00
|
|
|
wiiu->vp.x = 0;
|
|
|
|
wiiu->vp.y = 0;
|
2017-02-17 14:06:48 +00:00
|
|
|
wiiu->vp.width = wiiu->render_mode.width;
|
|
|
|
wiiu->vp.height = wiiu->render_mode.height;
|
|
|
|
wiiu->vp.full_width = wiiu->render_mode.width;
|
|
|
|
wiiu->vp.full_height = wiiu->render_mode.height;
|
2020-01-31 02:47:50 +00:00
|
|
|
video_driver_set_size(wiiu->vp.width, wiiu->vp.height);
|
2016-11-13 17:43:22 +00:00
|
|
|
|
2016-11-22 21:47:06 +00:00
|
|
|
driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &refresh_rate);
|
|
|
|
|
2020-02-16 20:59:03 +00:00
|
|
|
font_driver_init_osd(wiiu,
|
|
|
|
video,
|
|
|
|
false,
|
|
|
|
video->is_threaded,
|
|
|
|
FONT_DRIVER_RENDER_WIIU);
|
2017-05-21 02:05:41 +00:00
|
|
|
|
2018-01-31 03:49:49 +00:00
|
|
|
{
|
2019-06-20 06:38:40 +00:00
|
|
|
enum rarch_shader_type type;
|
|
|
|
const char *shader_preset = NULL;
|
|
|
|
|
|
|
|
wiiu_fake_context.get_flags = wiiu_gfx_get_flags;
|
|
|
|
|
2019-06-19 16:05:21 +00:00
|
|
|
video_context_driver_set(&wiiu_fake_context);
|
2019-06-20 06:38:40 +00:00
|
|
|
|
|
|
|
shader_preset = retroarch_get_shader_preset();
|
|
|
|
type = video_shader_parse_type(shader_preset);
|
2019-06-04 19:52:58 +00:00
|
|
|
wiiu_gfx_set_shader(wiiu, type, shader_preset);
|
2018-01-31 03:49:49 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 00:34:10 +00:00
|
|
|
return wiiu;
|
|
|
|
}
|
2017-01-10 20:15:52 +00:00
|
|
|
|
2017-12-27 07:38:03 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
static void gx2_overlay_tex_geom(void *data, unsigned image,
|
2018-01-06 02:39:53 +00:00
|
|
|
float x, float y, float w, float h)
|
2017-12-27 07:38:03 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *gx2 = (wiiu_video_t *)data;
|
2017-12-27 07:38:03 +00:00
|
|
|
struct gx2_overlay_data *o = NULL;
|
|
|
|
|
|
|
|
if (gx2)
|
2018-01-06 02:39:53 +00:00
|
|
|
o = (struct gx2_overlay_data *)&gx2->overlay[image];
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
if (!o)
|
|
|
|
return;
|
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
o->v.coord.u = x;
|
|
|
|
o->v.coord.v = y;
|
|
|
|
o->v.coord.width = w;
|
|
|
|
o->v.coord.height = h;
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, &o->v, sizeof(o->v));
|
2017-12-27 07:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gx2_overlay_vertex_geom(void *data, unsigned image,
|
2018-01-06 02:39:53 +00:00
|
|
|
float x, float y, float w, float h)
|
2017-12-27 07:38:03 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *gx2 = (wiiu_video_t *)data;
|
2017-12-27 07:38:03 +00:00
|
|
|
struct gx2_overlay_data *o = NULL;
|
|
|
|
|
|
|
|
if (gx2)
|
2018-01-06 02:39:53 +00:00
|
|
|
o = (struct gx2_overlay_data *)&gx2->overlay[image];
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
if (!o)
|
|
|
|
return;
|
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
o->v.pos.x = x * gx2->color_buffer.surface.width;
|
|
|
|
o->v.pos.y = y * gx2->color_buffer.surface.height;
|
|
|
|
o->v.pos.width = w * gx2->color_buffer.surface.width;
|
|
|
|
o->v.pos.height = h * gx2->color_buffer.surface.height;
|
2017-12-27 07:38:03 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, &o->v, sizeof(o->v));
|
2017-12-27 07:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gx2_free_overlay(wiiu_video_t *gx2)
|
|
|
|
{
|
|
|
|
unsigned i;
|
2018-01-06 02:39:53 +00:00
|
|
|
|
2017-12-27 07:38:03 +00:00
|
|
|
for (i = 0; i < gx2->overlays; i++)
|
|
|
|
MEM2_free(gx2->overlay[i].tex.surface.image);
|
|
|
|
|
|
|
|
free(gx2->overlay);
|
|
|
|
gx2->overlay = NULL;
|
|
|
|
gx2->overlays = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool gx2_overlay_load(void *data,
|
2018-01-06 02:39:53 +00:00
|
|
|
const void *image_data, unsigned num_images)
|
2017-12-27 07:38:03 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
unsigned i, j;
|
|
|
|
wiiu_video_t *gx2 = (wiiu_video_t *)data;
|
|
|
|
const struct texture_image *images = (const struct texture_image *)image_data;
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
gx2_free_overlay(gx2);
|
2018-01-06 02:39:53 +00:00
|
|
|
gx2->overlay = (struct gx2_overlay_data *)calloc(num_images, sizeof(*gx2->overlay));
|
|
|
|
|
2017-12-27 07:38:03 +00:00
|
|
|
if (!gx2->overlay)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
gx2->overlays = num_images;
|
|
|
|
|
|
|
|
for (i = 0; i < num_images; i++)
|
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
struct gx2_overlay_data *o = (struct gx2_overlay_data *)&gx2->overlay[i];
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
memset(&o->tex, 0, sizeof(GX2Texture));
|
|
|
|
o->tex.surface.width = images[i].width;
|
|
|
|
o->tex.surface.height = images[i].height;
|
|
|
|
o->tex.surface.depth = 1;
|
|
|
|
o->tex.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
|
|
|
o->tex.surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
|
|
|
o->tex.surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
|
|
|
o->tex.viewNumSlices = 1;
|
|
|
|
o->tex.compMap = GX2_COMP_SEL(_G, _B, _A, _R);
|
|
|
|
GX2CalcSurfaceSizeAndAlignment(&o->tex.surface);
|
|
|
|
GX2InitTextureRegs(&o->tex);
|
|
|
|
|
|
|
|
o->tex.surface.image = MEM2_alloc(o->tex.surface.imageSize,
|
2018-01-06 02:39:53 +00:00
|
|
|
o->tex.surface.alignment);
|
2017-12-27 07:38:03 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
for (j = 0; (j < images[i].height) && (j < o->tex.surface.height); j++)
|
|
|
|
memcpy((uint32_t *)o->tex.surface.image + (j * o->tex.surface.pitch),
|
|
|
|
images[i].pixels + (j * images[i].width), images[i].width * sizeof(images[i].pixels));
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, o->tex.surface.image, o->tex.surface.imageSize);
|
|
|
|
|
|
|
|
/* Default. Stretch to whole screen. */
|
2018-01-06 02:39:53 +00:00
|
|
|
gx2_overlay_tex_geom(gx2, i, 0, 0, 1, 1);
|
2017-12-27 07:38:03 +00:00
|
|
|
gx2_overlay_vertex_geom(gx2, i, 0, 0, 1, 1);
|
|
|
|
gx2->overlay[i].alpha_mod = 1.0f;
|
2018-01-04 16:38:04 +00:00
|
|
|
gx2->overlay[i].v.color = 0xFFFFFFFF;
|
2017-12-27 07:38:03 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, &o->v, sizeof(o->v));
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gx2_overlay_enable(void *data, bool state)
|
|
|
|
{
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *gx2 = (wiiu_video_t *)data;
|
2017-12-27 07:38:03 +00:00
|
|
|
gx2->overlay_enable = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gx2_overlay_full_screen(void *data, bool enable)
|
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *gx2 = (wiiu_video_t *)data;
|
2017-12-27 07:38:03 +00:00
|
|
|
gx2->overlay_full_screen = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gx2_overlay_set_alpha(void *data, unsigned image, float mod)
|
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *gx2 = (wiiu_video_t *)data;
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
if (gx2)
|
2017-12-30 22:21:32 +00:00
|
|
|
{
|
2017-12-27 07:38:03 +00:00
|
|
|
gx2->overlay[image].alpha_mod = mod;
|
2018-01-04 16:38:04 +00:00
|
|
|
gx2->overlay[image].v.color = COLOR_RGBA(0xFF, 0xFF, 0xFF, 0xFF * gx2->overlay[image].alpha_mod);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, &gx2->overlay[image].v,
|
|
|
|
sizeof(gx2->overlay[image].v));
|
2017-12-30 22:21:32 +00:00
|
|
|
}
|
2017-12-27 07:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gx2_render_overlay(void *data)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *gx2 = (wiiu_video_t *)data;
|
2017-12-27 07:38:03 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
for (i = 0; i < gx2->overlays; i++)
|
|
|
|
{
|
2017-12-27 07:38:03 +00:00
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2SetAttribBuffer(0, sizeof(gx2->overlay[i].v), sizeof(gx2->overlay[i].v), &gx2->overlay[i].v);
|
2017-12-27 07:38:03 +00:00
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2SetPixelTexture(&gx2->overlay[i].tex, sprite_shader.ps.samplerVars[0].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
GX2SetPixelSampler(&gx2->sampler_linear[RARCH_WRAP_EDGE], sprite_shader.ps.samplerVars[0].location);
|
2017-12-27 07:38:03 +00:00
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, 1, 0, 1);
|
2017-12-27 07:38:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static const video_overlay_interface_t gx2_overlay_interface =
|
|
|
|
{
|
2017-12-27 07:38:03 +00:00
|
|
|
gx2_overlay_enable,
|
|
|
|
gx2_overlay_load,
|
|
|
|
gx2_overlay_tex_geom,
|
|
|
|
gx2_overlay_vertex_geom,
|
|
|
|
gx2_overlay_full_screen,
|
|
|
|
gx2_overlay_set_alpha,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void gx2_get_overlay_interface(void *data,
|
2018-01-06 02:39:53 +00:00
|
|
|
const video_overlay_interface_t **iface)
|
2017-12-27 07:38:03 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
*iface = &gx2_overlay_interface;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_free_shader_preset(wiiu_video_t *wiiu)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
unsigned i;
|
2018-01-06 02:39:53 +00:00
|
|
|
if (!wiiu->shader_preset)
|
|
|
|
return;
|
|
|
|
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
|
|
|
gfd_free(wiiu->pass[i].gfd);
|
2018-01-09 02:06:54 +00:00
|
|
|
MEM2_free(wiiu->pass[i].vs_ubos[0]);
|
|
|
|
MEM2_free(wiiu->pass[i].vs_ubos[1]);
|
|
|
|
MEM2_free(wiiu->pass[i].ps_ubos[0]);
|
|
|
|
MEM2_free(wiiu->pass[i].ps_ubos[1]);
|
2018-01-09 15:41:01 +00:00
|
|
|
if(wiiu->pass[i].mem1)
|
|
|
|
MEM1_free(wiiu->pass[i].texture.surface.image);
|
|
|
|
else
|
|
|
|
MEM2_free(wiiu->pass[i].texture.surface.image);
|
2018-01-06 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(wiiu->pass, 0, sizeof(wiiu->pass));
|
|
|
|
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->luts; i++)
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
MEM2_free(wiiu->luts[i].surface.image);
|
|
|
|
wiiu->luts[i].surface.image = NULL;
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
free(wiiu->shader_preset);
|
|
|
|
wiiu->shader_preset = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wiiu_gfx_free(void *data)
|
|
|
|
{
|
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2016-10-27 22:02:40 +00:00
|
|
|
if (!wiiu)
|
2016-10-27 00:34:10 +00:00
|
|
|
return;
|
|
|
|
|
2016-11-07 01:42:12 +00:00
|
|
|
/* clear leftover image */
|
|
|
|
GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_DRC);
|
|
|
|
GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_TV);
|
|
|
|
|
|
|
|
GX2SwapScanBuffers();
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2Flush();
|
|
|
|
GX2DrawDone();
|
2016-11-07 01:42:12 +00:00
|
|
|
GX2WaitForVsync();
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2Shutdown();
|
|
|
|
|
|
|
|
GX2SetTVEnable(GX2_DISABLE);
|
|
|
|
GX2SetDRCEnable(GX2_DISABLE);
|
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
GX2DestroyShader(&frame_shader);
|
2018-01-11 01:09:03 +00:00
|
|
|
GX2DestroyShader(&tex_shader);
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2DestroyShader(&sprite_shader);
|
2018-01-12 01:54:45 +00:00
|
|
|
GX2DestroyShader(&ribbon_simple_shader);
|
2018-01-11 01:09:03 +00:00
|
|
|
GX2DestroyShader(&ribbon_shader);
|
2018-01-12 01:54:45 +00:00
|
|
|
GX2DestroyShader(&bokeh_shader);
|
|
|
|
GX2DestroyShader(&snow_shader);
|
|
|
|
GX2DestroyShader(&snow_simple_shader);
|
|
|
|
GX2DestroyShader(&snowflake_shader);
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_free_shader_preset(wiiu);
|
|
|
|
|
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
gx2_free_overlay(wiiu);
|
|
|
|
#endif
|
2018-01-04 16:38:04 +00:00
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
MEM2_free(wiiu->ctx_state);
|
|
|
|
MEM2_free(wiiu->cmd_buffer);
|
|
|
|
MEM2_free(wiiu->texture.surface.image);
|
|
|
|
MEM2_free(wiiu->menu.texture.surface.image);
|
2018-01-04 16:38:04 +00:00
|
|
|
MEM2_free(wiiu->v);
|
|
|
|
MEM2_free(wiiu->menu.v);
|
2017-12-31 13:06:49 +00:00
|
|
|
MEM2_free(wiiu->vertex_cache.v);
|
2018-01-11 01:09:03 +00:00
|
|
|
MEM2_free(wiiu->vertex_cache_tex.v);
|
2018-01-12 01:54:45 +00:00
|
|
|
MEM2_free(wiiu->menu_shader_vbo);
|
|
|
|
MEM2_free(wiiu->menu_shader_ubo);
|
2016-11-05 14:05:46 +00:00
|
|
|
|
|
|
|
MEM1_free(wiiu->color_buffer.surface.image);
|
2018-01-04 16:38:04 +00:00
|
|
|
MEM1_free(wiiu->ubo_vp);
|
|
|
|
MEM1_free(wiiu->ubo_tex);
|
2018-01-05 12:18:55 +00:00
|
|
|
MEM1_free(wiiu->ubo_mvp);
|
2018-01-04 16:38:04 +00:00
|
|
|
MEM1_free(wiiu->input_ring_buffer);
|
|
|
|
MEM1_free(wiiu->output_ring_buffer);
|
2016-11-05 14:05:46 +00:00
|
|
|
|
|
|
|
MEMBucket_free(wiiu->tv_scan_buffer);
|
|
|
|
MEMBucket_free(wiiu->drc_scan_buffer);
|
|
|
|
|
2016-10-27 00:34:10 +00:00
|
|
|
free(wiiu);
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static bool wiiu_init_frame_textures(wiiu_video_t *wiiu, unsigned width, unsigned height)
|
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
unsigned i;
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
MEM2_free(wiiu->texture.surface.image);
|
2018-01-09 02:06:54 +00:00
|
|
|
|
|
|
|
if (wiiu->shader_preset)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
2018-01-09 15:41:01 +00:00
|
|
|
if(wiiu->pass[i].mem1)
|
|
|
|
MEM1_free(wiiu->pass[i].texture.surface.image);
|
|
|
|
else
|
|
|
|
MEM2_free(wiiu->pass[i].texture.surface.image);
|
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
wiiu->pass[i].texture.surface.image = NULL;
|
|
|
|
}
|
2018-01-06 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize frame texture */
|
|
|
|
memset(&wiiu->texture, 0, sizeof(GX2Texture));
|
|
|
|
wiiu->texture.surface.width = width;
|
|
|
|
wiiu->texture.surface.height = height;
|
|
|
|
wiiu->texture.surface.depth = 1;
|
|
|
|
wiiu->texture.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
|
|
|
wiiu->texture.surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
|
|
|
wiiu->texture.viewNumSlices = 1;
|
|
|
|
|
|
|
|
if (wiiu->rgb32)
|
|
|
|
{
|
|
|
|
wiiu->texture.surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
|
|
|
wiiu->texture.compMap = GX2_COMP_SEL(_G, _B, _A, _1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wiiu->texture.surface.format = GX2_SURFACE_FORMAT_UNORM_R5_G6_B5;
|
|
|
|
wiiu->texture.compMap = GX2_COMP_SEL(_B, _G, _R, _1);
|
|
|
|
}
|
|
|
|
|
|
|
|
GX2CalcSurfaceSizeAndAlignment(&wiiu->texture.surface);
|
|
|
|
GX2InitTextureRegs(&wiiu->texture);
|
|
|
|
|
|
|
|
wiiu->texture.surface.image = MEM2_alloc(wiiu->texture.surface.imageSize,
|
|
|
|
wiiu->texture.surface.alignment);
|
|
|
|
memset(wiiu->texture.surface.image, 0x0, wiiu->texture.surface.imageSize);
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->texture.surface.image,
|
|
|
|
wiiu->texture.surface.imageSize);
|
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
if (wiiu->shader_preset)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
|
|
|
struct video_shader_pass *pass = &wiiu->shader_preset->pass[i];
|
|
|
|
|
|
|
|
switch (pass->fbo.type_x)
|
|
|
|
{
|
|
|
|
case RARCH_SCALE_INPUT:
|
|
|
|
width *= pass->fbo.scale_x;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RARCH_SCALE_VIEWPORT:
|
|
|
|
width = wiiu->vp.width * pass->fbo.scale_x;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RARCH_SCALE_ABSOLUTE:
|
|
|
|
width = pass->fbo.abs_x;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pass->fbo.type_y)
|
|
|
|
{
|
|
|
|
case RARCH_SCALE_INPUT:
|
|
|
|
height *= pass->fbo.scale_y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RARCH_SCALE_VIEWPORT:
|
|
|
|
height = wiiu->vp.height * pass->fbo.scale_y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RARCH_SCALE_ABSOLUTE:
|
|
|
|
height = pass->fbo.abs_y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!width)
|
|
|
|
width = wiiu->color_buffer.surface.width;
|
|
|
|
|
|
|
|
if (!height)
|
|
|
|
height = wiiu->color_buffer.surface.height;
|
|
|
|
|
|
|
|
memset(&wiiu->pass[i].texture, 0, sizeof(wiiu->pass[i].texture));
|
|
|
|
wiiu->pass[i].texture.surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
|
|
|
wiiu->pass[i].texture.surface.width = width;
|
|
|
|
wiiu->pass[i].texture.surface.height = height;
|
|
|
|
wiiu->pass[i].texture.surface.depth = 1;
|
2019-08-08 12:54:21 +00:00
|
|
|
#if 0
|
|
|
|
wiiu->pass[i].texture.surface.mipLevels = 1;
|
|
|
|
#endif
|
2018-01-09 02:06:54 +00:00
|
|
|
wiiu->pass[i].texture.surface.format = pass->fbo.fp_fbo ?
|
|
|
|
GX2_SURFACE_FORMAT_FLOAT_R32_G32_B32_A32 :
|
|
|
|
pass->fbo.srgb_fbo ? GX2_SURFACE_FORMAT_SRGB_R8_G8_B8_A8 :
|
|
|
|
GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
|
|
|
wiiu->pass[i].texture.surface.use = (GX2_SURFACE_USE_TEXTURE |
|
|
|
|
GX2_SURFACE_USE_COLOR_BUFFER);
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu->pass[i].texture.viewNumSlices = 1;
|
|
|
|
wiiu->pass[i].texture.compMap = GX2_COMP_SEL(_R, _G, _B, _A);
|
|
|
|
|
|
|
|
GX2CalcSurfaceSizeAndAlignment(&wiiu->pass[i].texture.surface);
|
|
|
|
GX2InitTextureRegs(&wiiu->pass[i].texture);
|
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
if ((i != (wiiu->shader_preset->passes - 1)) || (width != wiiu->vp.width)
|
|
|
|
|| (height != wiiu->vp.height))
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2018-01-09 15:41:01 +00:00
|
|
|
wiiu->pass[i].mem1 = true;
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu->pass[i].texture.surface.image = MEM1_alloc(wiiu->pass[i].texture.surface.imageSize,
|
|
|
|
wiiu->pass[i].texture.surface.alignment);
|
|
|
|
|
|
|
|
if (!wiiu->pass[i].texture.surface.image)
|
|
|
|
{
|
2018-01-09 15:41:01 +00:00
|
|
|
printf("failed to allocate Render target memory from MEM1. trying MEM2.\n");
|
|
|
|
wiiu->pass[i].mem1 = false;
|
|
|
|
wiiu->pass[i].texture.surface.image = MEM2_alloc(wiiu->pass[i].texture.surface.imageSize,
|
|
|
|
wiiu->pass[i].texture.surface.alignment);
|
|
|
|
|
|
|
|
if (!wiiu->pass[i].texture.surface.image)
|
|
|
|
{
|
|
|
|
printf("failed to allocate Render target memory from MEM2. falling back to stock.\n");
|
|
|
|
|
|
|
|
wiiu_free_shader_preset(wiiu);
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-06 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(wiiu->pass[i].texture.surface.image, 0x00, wiiu->pass[i].texture.surface.imageSize);
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->pass[i].texture.surface.image,
|
|
|
|
wiiu->pass[i].texture.surface.imageSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&wiiu->pass[i].color_buffer, 0, sizeof(wiiu->pass[i].color_buffer));
|
|
|
|
wiiu->pass[i].color_buffer.surface = wiiu->pass[i].texture.surface;
|
|
|
|
GX2InitColorBufferRegs(&wiiu->pass[i].color_buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-08 12:54:21 +00:00
|
|
|
static void wiiu_gfx_update_uniform_block(wiiu_video_t *wiiu,
|
|
|
|
int pass, float *ubo, int id,
|
2019-05-29 19:06:44 +00:00
|
|
|
int size, int uniformVarCount, GX2UniformVar *uniformVars,
|
|
|
|
uint64_t frame_count, int32_t frame_direction)
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
unsigned i;
|
|
|
|
for (i = 0; i < uniformVarCount; i++)
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
|
|
|
if (uniformVars[i].block != id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const char *id = strrchr(uniformVars[i].name, '.');
|
|
|
|
|
|
|
|
if (!id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
id++;
|
|
|
|
|
|
|
|
float *dst = ubo + uniformVars[i].offset;
|
|
|
|
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(id, "OutputSize"))
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
|
|
|
((GX2_vec4 *)dst)->x = wiiu->pass[pass].color_buffer.surface.width;
|
|
|
|
((GX2_vec4 *)dst)->y = wiiu->pass[pass].color_buffer.surface.height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / wiiu->pass[pass].color_buffer.surface.width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / wiiu->pass[pass].color_buffer.surface.height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(id, "FinalViewportSize"))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
((GX2_vec4 *)dst)->x = wiiu->vp.width;
|
|
|
|
((GX2_vec4 *)dst)->y = wiiu->vp.height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / wiiu->vp.width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / wiiu->vp.height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(id, "FrameCount"))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
*dst = wiiu->shader_preset->pass[pass].frame_count_mod ?
|
|
|
|
frame_count % wiiu->shader_preset->pass[pass].frame_count_mod :
|
|
|
|
frame_count;
|
|
|
|
*(u32 *)dst = __builtin_bswap32(*(u32 *)dst);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-05-29 19:06:44 +00:00
|
|
|
if (string_is_equal(id, "FrameDirection"))
|
|
|
|
{
|
|
|
|
*dst = frame_direction;
|
|
|
|
*(u32 *)dst = __builtin_bswap32(*(u32 *)dst);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(id, "OriginalSize"))
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
|
|
|
((GX2_vec4 *)dst)->x = wiiu->texture.surface.width;
|
|
|
|
((GX2_vec4 *)dst)->y = wiiu->texture.surface.height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / wiiu->texture.surface.width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / wiiu->texture.surface.height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(id, "SourceSize"))
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
|
|
|
GX2Surface *source = (pass > 0) ? &wiiu->pass[pass - 1].texture.surface : &wiiu->texture.surface;
|
|
|
|
((GX2_vec4 *)dst)->x = source->width;
|
|
|
|
((GX2_vec4 *)dst)->y = source->height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / source->width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / source->height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-04-27 02:21:10 +00:00
|
|
|
if (!strncmp(id, "OriginalHistorySize",
|
|
|
|
STRLEN_CONST("OriginalHistorySize")))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
2019-04-27 02:21:10 +00:00
|
|
|
unsigned index = strtoul(id + STRLEN_CONST("OriginalHistorySize"),
|
|
|
|
NULL, 0);
|
2018-01-09 15:41:01 +00:00
|
|
|
if(index > pass)
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
if(index)
|
|
|
|
index = pass - index;
|
|
|
|
|
|
|
|
GX2Surface *source = (index > 0) ? &wiiu->pass[index - 1].texture.surface : &wiiu->texture.surface;
|
|
|
|
((GX2_vec4 *)dst)->x = source->width;
|
|
|
|
((GX2_vec4 *)dst)->y = source->height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / source->width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / source->height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-04-27 02:21:10 +00:00
|
|
|
if ((pass > 0 ) && !strncmp(id, "PassOutputSize",
|
|
|
|
STRLEN_CONST("PassOutputSize")))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
2019-04-27 02:21:10 +00:00
|
|
|
unsigned index = strtoul(id + STRLEN_CONST("PassOutputSize"), NULL, 0);
|
2018-01-09 15:41:01 +00:00
|
|
|
if(index > pass - 1)
|
|
|
|
index = pass - 1;
|
|
|
|
GX2Surface *output = &wiiu->pass[index].texture.surface;
|
|
|
|
((GX2_vec4 *)dst)->x = output->width;
|
|
|
|
((GX2_vec4 *)dst)->y = output->height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / output->width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / output->height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* feedback not supported yet */
|
2019-04-27 02:21:10 +00:00
|
|
|
if (!strncmp(id, "PassFeedbackSize", STRLEN_CONST("PassFeedbackSize")))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
2019-04-27 02:21:10 +00:00
|
|
|
unsigned index = strtoul(id + STRLEN_CONST("PassFeedbackSize"), NULL, 0);
|
2018-01-09 15:41:01 +00:00
|
|
|
if(index > wiiu->shader_preset->passes - 1)
|
|
|
|
index = wiiu->shader_preset->passes - 1;
|
|
|
|
GX2Surface *output = &wiiu->pass[index].texture.surface;
|
|
|
|
((GX2_vec4 *)dst)->x = output->width;
|
|
|
|
((GX2_vec4 *)dst)->y = output->height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / output->width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / output->height;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int k = 0; k < wiiu->shader_preset->luts; k++)
|
|
|
|
{
|
2019-04-27 02:21:10 +00:00
|
|
|
size_t lut_id_size = strlen(wiiu->shader_preset->lut[k].id);
|
|
|
|
if (!strncmp(id, wiiu->shader_preset->lut[k].id, lut_id_size)
|
|
|
|
&& !!strcmp(id + lut_id_size, "Size"))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
GX2Surface *surface = &wiiu->luts[k].surface;
|
|
|
|
((GX2_vec4 *)dst)->x = surface->width;
|
|
|
|
((GX2_vec4 *)dst)->y = surface->height;
|
|
|
|
((GX2_vec4 *)dst)->z = 1.0f / surface->width;
|
|
|
|
((GX2_vec4 *)dst)->w = 1.0f / surface->height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(id, "MVP"))
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
|
|
|
memcpy(dst, wiiu->ubo_mvp, sizeof(*wiiu->ubo_mvp));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int k = 0; k < wiiu->shader_preset->num_parameters; k++)
|
|
|
|
{
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(id, wiiu->shader_preset->parameters[k].id))
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
|
|
|
*dst = wiiu->shader_preset->parameters[k].current;
|
|
|
|
*(u32 *)dst = __builtin_bswap32(*(u32 *)dst);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, ubo, size);
|
|
|
|
}
|
2018-01-06 02:39:53 +00:00
|
|
|
|
|
|
|
static bool wiiu_gfx_frame(void *data, const void *frame,
|
2019-02-07 01:03:48 +00:00
|
|
|
unsigned width, unsigned height, uint64_t frame_count,
|
|
|
|
unsigned pitch, const char *msg, video_frame_info_t *video_info)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2017-11-04 06:58:04 +00:00
|
|
|
uint32_t i;
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
2020-05-20 21:34:23 +00:00
|
|
|
bool menu_is_alive = video_info->menu_is_alive;
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
(void)msg;
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (wiiu->vsync)
|
2016-11-10 13:24:20 +00:00
|
|
|
{
|
|
|
|
uint32_t swap_count;
|
|
|
|
uint32_t flip_count;
|
|
|
|
OSTime last_flip;
|
|
|
|
OSTime last_vsync;
|
|
|
|
|
|
|
|
GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync);
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (wiiu->last_vsync >= last_vsync)
|
2016-11-10 13:24:20 +00:00
|
|
|
{
|
|
|
|
GX2WaitForVsync();
|
|
|
|
wiiu->last_vsync = last_vsync + ms_to_ticks(17);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wiiu->last_vsync = last_vsync;
|
|
|
|
}
|
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
GX2WaitForFlip();
|
2017-05-22 10:19:26 +00:00
|
|
|
|
|
|
|
if (!width || !height)
|
|
|
|
return true;
|
|
|
|
|
2016-11-13 17:43:22 +00:00
|
|
|
if (wiiu->should_resize)
|
|
|
|
wiiu_gfx_update_viewport(wiiu);
|
|
|
|
|
2016-11-10 13:24:20 +00:00
|
|
|
GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
/* can't call GX2ClearColor after GX2SetContextState for whatever reason */
|
|
|
|
GX2SetContextState(wiiu->ctx_state);
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (frame)
|
2016-10-27 22:02:40 +00:00
|
|
|
{
|
2018-01-09 02:06:54 +00:00
|
|
|
if ((width != wiiu->texture.surface.width) ||
|
|
|
|
(height != wiiu->texture.surface.height))
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_init_frame_textures(wiiu, width, height);
|
2016-10-27 22:02:40 +00:00
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
wiiu->width = width;
|
2016-11-05 14:05:46 +00:00
|
|
|
wiiu->height = height;
|
2017-09-27 21:16:37 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (wiiu->rgb32)
|
2016-11-16 18:03:01 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
const uint32_t *src = frame;
|
|
|
|
uint32_t *dst = (uint32_t *)wiiu->texture.surface.image;
|
2016-10-27 22:02:40 +00:00
|
|
|
|
2016-11-16 18:03:01 +00:00
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
2017-11-04 06:58:04 +00:00
|
|
|
uint32_t j;
|
2018-01-06 02:39:53 +00:00
|
|
|
|
|
|
|
for (j = 0; j < width; j++)
|
2016-11-16 18:03:01 +00:00
|
|
|
dst[j] = src[j];
|
2018-01-06 02:39:53 +00:00
|
|
|
|
2016-11-16 18:03:01 +00:00
|
|
|
dst += wiiu->texture.surface.pitch;
|
|
|
|
src += pitch / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2016-10-27 22:02:40 +00:00
|
|
|
{
|
2017-09-27 21:16:37 +00:00
|
|
|
const uint16_t *src = frame;
|
2018-01-06 02:39:53 +00:00
|
|
|
uint16_t *dst = (uint16_t *)wiiu->texture.surface.image;
|
2016-11-16 18:03:01 +00:00
|
|
|
|
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
2017-09-27 21:16:37 +00:00
|
|
|
unsigned j;
|
2018-01-06 02:39:53 +00:00
|
|
|
|
|
|
|
for (j = 0; j < width; j++)
|
2016-11-16 18:03:01 +00:00
|
|
|
dst[j] = __builtin_bswap16(src[j]);
|
2018-01-06 02:39:53 +00:00
|
|
|
|
2016-11-16 18:03:01 +00:00
|
|
|
dst += wiiu->texture.surface.pitch;
|
|
|
|
src += pitch / 2;
|
|
|
|
}
|
2016-10-27 22:02:40 +00:00
|
|
|
}
|
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->texture.surface.image,
|
|
|
|
wiiu->texture.surface.imageSize);
|
2018-01-04 16:38:04 +00:00
|
|
|
|
2017-12-31 13:06:49 +00:00
|
|
|
wiiu_set_tex_coords(wiiu->v, &wiiu->texture, 0, 0, width, height, wiiu->rotation);
|
2016-10-27 22:02:40 +00:00
|
|
|
}
|
|
|
|
|
2018-01-05 12:18:55 +00:00
|
|
|
GX2SetShaderMode(GX2_SHADER_MODE_UNIFORM_BLOCK);
|
2016-10-27 22:02:40 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2SetFetchShader(&frame_shader.fs);
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->v), sizeof(*wiiu->v), wiiu->v);
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2Texture *texture = &wiiu->texture;
|
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
if (wiiu->shader_preset && !wiiu->pass[0].texture.surface.image)
|
|
|
|
wiiu_init_frame_textures(wiiu, width, height);
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (wiiu->shader_preset)
|
|
|
|
{
|
2020-05-19 14:20:43 +00:00
|
|
|
unsigned i;
|
2019-05-29 19:06:44 +00:00
|
|
|
int32_t frame_direction = state_manager_frame_is_reversed() ? -1 : 1;
|
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2020-05-19 14:20:43 +00:00
|
|
|
unsigned j;
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2SetVertexShader(wiiu->pass[i].gfd->vs);
|
2018-01-09 15:41:01 +00:00
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2018-01-09 02:06:54 +00:00
|
|
|
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].vs_ubos[j], j,
|
2020-05-19 14:20:43 +00:00
|
|
|
wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
|
|
|
|
wiiu->pass[i].gfd->vs->uniformVarCount, wiiu->pass[i].gfd->vs->uniformVars,
|
|
|
|
frame_count, frame_direction);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetVertexUniformBlock(wiiu->pass[i].gfd->vs->uniformBlocks[j].offset,
|
2020-05-19 14:20:43 +00:00
|
|
|
wiiu->pass[i].gfd->vs->uniformBlocks[j].size, wiiu->pass[i].vs_ubos[j]);
|
2018-01-06 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetPixelShader(wiiu->pass[i].gfd->ps);
|
2018-01-09 15:41:01 +00:00
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
|
2018-01-09 02:06:54 +00:00
|
|
|
{
|
|
|
|
wiiu_gfx_update_uniform_block(wiiu, i, wiiu->pass[i].ps_ubos[j], j,
|
2020-05-19 14:20:43 +00:00
|
|
|
wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
|
|
|
|
wiiu->pass[i].gfd->ps->uniformVarCount, wiiu->pass[i].gfd->ps->uniformVars,
|
|
|
|
frame_count, frame_direction);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetPixelUniformBlock(wiiu->pass[i].gfd->ps->uniformBlocks[j].offset,
|
2020-05-19 14:20:43 +00:00
|
|
|
wiiu->pass[i].gfd->ps->uniformBlocks[j].size, wiiu->pass[i].ps_ubos[j]);
|
2018-01-09 02:06:54 +00:00
|
|
|
}
|
2018-01-06 02:39:53 +00:00
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
for (j = 0; j < wiiu->pass[i].gfd->ps->samplerVarCount; j++)
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, "Source"))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
GX2SetPixelTexture(texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
|
|
|
GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ?
|
2020-05-19 14:20:43 +00:00
|
|
|
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
|
|
|
|
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
|
|
|
|
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-09-15 05:44:21 +00:00
|
|
|
if (string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, "Original"))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
GX2SetPixelTexture(&wiiu->texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
|
|
|
GX2SetPixelSampler(wiiu->shader_preset->pass[0].filter ?
|
2020-05-19 14:20:43 +00:00
|
|
|
&wiiu->sampler_linear[wiiu->shader_preset->pass[0].wrap] :
|
|
|
|
&wiiu->sampler_nearest[wiiu->shader_preset->pass[0].wrap],
|
|
|
|
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-04-27 02:21:10 +00:00
|
|
|
if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "OriginalHistory", STRLEN_CONST("OriginalHistory")))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
2019-04-27 02:21:10 +00:00
|
|
|
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("OriginalHistory"), NULL, 0);
|
2018-01-09 15:41:01 +00:00
|
|
|
if(index > i)
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
if(index)
|
|
|
|
index = i - index;
|
|
|
|
|
|
|
|
GX2Texture *source = (index > 0) ? &wiiu->pass[index - 1].texture : &wiiu->texture;
|
|
|
|
GX2SetPixelTexture(source, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
|
|
|
GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ?
|
2020-05-19 14:20:43 +00:00
|
|
|
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
|
|
|
|
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
|
|
|
|
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-04-27 02:21:10 +00:00
|
|
|
if ((i > 0) && !strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassOutput", STRLEN_CONST("PassOutput")))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
2019-04-27 02:21:10 +00:00
|
|
|
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("PassOutput"), NULL, 0);
|
2018-01-09 15:41:01 +00:00
|
|
|
if(index > i - 1)
|
|
|
|
index = i - 1;
|
|
|
|
GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
|
|
|
GX2SetPixelSampler(wiiu->shader_preset->pass[index].filter ?
|
2020-05-19 14:20:43 +00:00
|
|
|
&wiiu->sampler_linear[wiiu->shader_preset->pass[index].wrap] :
|
|
|
|
&wiiu->sampler_nearest[wiiu->shader_preset->pass[index].wrap],
|
|
|
|
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* feedback not supported yet */
|
2019-04-27 02:21:10 +00:00
|
|
|
if (!strncmp(wiiu->pass[i].gfd->ps->samplerVars[j].name, "PassFeedback", STRLEN_CONST("PassFeedback")))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
2019-04-27 02:21:10 +00:00
|
|
|
unsigned index = strtoul(wiiu->pass[i].gfd->ps->samplerVars[j].name + STRLEN_CONST("PassFeedback"), NULL, 0);
|
2018-01-09 15:41:01 +00:00
|
|
|
if(index > wiiu->shader_preset->passes - 1)
|
|
|
|
index = wiiu->shader_preset->passes - 1;
|
|
|
|
|
|
|
|
GX2SetPixelTexture(&wiiu->pass[index].texture, wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
|
|
|
GX2SetPixelSampler(wiiu->shader_preset->pass[i].filter ?
|
2020-05-19 14:20:43 +00:00
|
|
|
&wiiu->sampler_linear[wiiu->shader_preset->pass[i].wrap] :
|
|
|
|
&wiiu->sampler_nearest[wiiu->shader_preset->pass[i].wrap],
|
|
|
|
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int k = 0; k < wiiu->shader_preset->luts; k++)
|
|
|
|
{
|
|
|
|
if (wiiu->luts[k].surface.image
|
2018-09-15 05:44:21 +00:00
|
|
|
&& string_is_equal(wiiu->pass[i].gfd->ps->samplerVars[j].name, wiiu->shader_preset->lut[k].id))
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
GX2SetPixelTexture(&wiiu->luts[k], wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
|
|
|
GX2SetPixelSampler(wiiu->shader_preset->lut[k].filter ?
|
2020-05-19 14:20:43 +00:00
|
|
|
&wiiu->sampler_linear[wiiu->shader_preset->lut[k].wrap] :
|
|
|
|
&wiiu->sampler_nearest[wiiu->shader_preset->lut[k].wrap],
|
|
|
|
wiiu->pass[i].gfd->ps->samplerVars[j].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-01-06 02:39:53 +00:00
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
if (wiiu->pass[i].color_buffer.surface.image)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
|
|
|
GX2SetColorBuffer(&wiiu->pass[i].color_buffer, GX2_RENDER_TARGET_0);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetViewport(0.0f, 0.0f, wiiu->pass[i].color_buffer.surface.width,
|
|
|
|
wiiu->pass[i].color_buffer.surface.height, 0.0f,
|
2018-01-06 02:39:53 +00:00
|
|
|
1.0f);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetScissor(0, 0, wiiu->pass[i].color_buffer.surface.width,
|
|
|
|
wiiu->pass[i].color_buffer.surface.height);
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
|
|
|
|
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_TEXTURE, wiiu->pass[i].texture.surface.image,
|
|
|
|
wiiu->pass[i].texture.surface.imageSize);
|
|
|
|
texture = &wiiu->pass[i].texture;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
texture = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GX2SetColorBuffer(&wiiu->color_buffer, GX2_RENDER_TARGET_0);
|
|
|
|
}
|
|
|
|
|
2018-01-09 02:06:54 +00:00
|
|
|
if (texture)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
|
|
|
GX2SetVertexShader(&frame_shader.vs);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetVertexUniformBlock(frame_shader.vs.uniformBlocks[0].offset,
|
|
|
|
frame_shader.vs.uniformBlocks[0].size, wiiu->ubo_mvp);
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2SetPixelShader(&frame_shader.ps);
|
|
|
|
GX2SetPixelTexture(texture, frame_shader.ps.samplerVars[0].location);
|
2018-01-09 15:41:01 +00:00
|
|
|
GX2SetPixelSampler(wiiu->smooth ? &wiiu->sampler_linear[RARCH_WRAP_DEFAULT] :
|
|
|
|
&wiiu->sampler_nearest[RARCH_WRAP_DEFAULT],
|
2018-01-06 02:39:53 +00:00
|
|
|
frame_shader.ps.samplerVars[0].location);
|
|
|
|
}
|
|
|
|
|
|
|
|
GX2SetViewport(wiiu->vp.x, wiiu->vp.y, wiiu->vp.width, wiiu->vp.height, 0.0f, 1.0f);
|
2018-05-06 11:18:03 +00:00
|
|
|
GX2SetScissor(0, 0, wiiu->color_buffer.surface.width, wiiu->color_buffer.surface.height);
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2SetShaderMode(GX2_SHADER_MODE_GEOMETRY_SHADER);
|
|
|
|
GX2SetShader(&sprite_shader);
|
|
|
|
GX2SetGeometryShaderInputRingBuffer(wiiu->input_ring_buffer, wiiu->input_ring_buffer_size);
|
|
|
|
GX2SetGeometryShaderOutputRingBuffer(wiiu->output_ring_buffer, wiiu->output_ring_buffer_size);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetVertexUniformBlock(sprite_shader.vs.uniformBlocks[0].offset,
|
|
|
|
sprite_shader.vs.uniformBlocks[0].size,
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu->ubo_vp);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetVertexUniformBlock(sprite_shader.vs.uniformBlocks[1].offset,
|
|
|
|
sprite_shader.vs.uniformBlocks[1].size,
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu->ubo_tex);
|
2018-01-09 02:06:54 +00:00
|
|
|
GX2SetViewport(0.0f, 0.0f, wiiu->color_buffer.surface.width, wiiu->color_buffer.surface.height,
|
|
|
|
0.0f, 1.0f);
|
2018-01-04 16:38:04 +00:00
|
|
|
|
2017-12-27 07:38:03 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
if (wiiu->overlay_enable)
|
|
|
|
gx2_render_overlay(wiiu);
|
|
|
|
#endif
|
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
#ifdef HAVE_MENU
|
2016-11-05 14:05:46 +00:00
|
|
|
if (wiiu->menu.enable)
|
|
|
|
{
|
2017-12-31 13:06:49 +00:00
|
|
|
GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->menu.v), sizeof(*wiiu->menu.v), wiiu->menu.v);
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2SetPixelTexture(&wiiu->menu.texture, sprite_shader.ps.samplerVars[0].location);
|
2019-06-03 11:41:03 +00:00
|
|
|
GX2SetPixelSampler(wiiu->smooth ? &wiiu->sampler_linear[RARCH_WRAP_DEFAULT] :
|
|
|
|
&wiiu->sampler_nearest[RARCH_WRAP_DEFAULT],
|
2018-01-09 15:41:01 +00:00
|
|
|
sprite_shader.ps.samplerVars[0].location);
|
2016-11-05 14:05:46 +00:00
|
|
|
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2DrawEx(GX2_PRIMITIVE_MODE_POINTS, 1, 0, 1);
|
2016-11-05 14:05:46 +00:00
|
|
|
}
|
2020-05-19 14:20:43 +00:00
|
|
|
#endif
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2017-05-22 00:45:40 +00:00
|
|
|
wiiu->vertex_cache.current = 0;
|
2018-01-11 01:09:03 +00:00
|
|
|
wiiu->vertex_cache_tex.current = 0;
|
2017-12-31 13:06:49 +00:00
|
|
|
GX2SetAttribBuffer(0, wiiu->vertex_cache.size * sizeof(*wiiu->vertex_cache.v),
|
2018-01-06 02:39:53 +00:00
|
|
|
sizeof(*wiiu->vertex_cache.v), wiiu->vertex_cache.v);
|
2018-01-09 15:41:01 +00:00
|
|
|
GX2SetPixelSampler(&wiiu->sampler_linear[RARCH_WRAP_EDGE],
|
|
|
|
sprite_shader.ps.samplerVars[0].location);
|
2017-05-22 00:45:40 +00:00
|
|
|
|
2017-05-22 05:07:27 +00:00
|
|
|
wiiu->render_msg_enabled = true;
|
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
#ifdef HAVE_MENU
|
2017-05-22 00:45:40 +00:00
|
|
|
if (wiiu->menu.enable)
|
2020-05-19 14:20:43 +00:00
|
|
|
menu_driver_frame(menu_is_alive, video_info);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (video_info->statistics_show)
|
2018-03-23 16:43:49 +00:00
|
|
|
{
|
2018-03-24 10:59:01 +00:00
|
|
|
struct font_params *osd_params = (struct font_params*)
|
|
|
|
&video_info->osd_stat_params;
|
2018-03-23 16:43:49 +00:00
|
|
|
|
|
|
|
if (osd_params)
|
2020-03-10 02:24:59 +00:00
|
|
|
font_driver_render_msg(wiiu, video_info->stat_text,
|
2020-01-04 15:24:14 +00:00
|
|
|
(const struct font_params*)&video_info->osd_stat_params, NULL);
|
2018-03-23 16:43:49 +00:00
|
|
|
}
|
2017-05-22 00:45:40 +00:00
|
|
|
|
2020-02-17 20:28:42 +00:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
2020-03-11 11:35:01 +00:00
|
|
|
gfx_widgets_frame(video_info);
|
2019-02-07 01:03:48 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-21 02:05:41 +00:00
|
|
|
if (msg)
|
2020-03-10 02:24:59 +00:00
|
|
|
font_driver_render_msg(wiiu, msg, NULL, NULL);
|
2017-05-21 02:05:41 +00:00
|
|
|
|
2017-05-22 05:07:27 +00:00
|
|
|
wiiu->render_msg_enabled = false;
|
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER,
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu->vertex_cache.v, wiiu->vertex_cache.current * sizeof(*wiiu->vertex_cache.v));
|
2018-01-11 01:09:03 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER,
|
|
|
|
wiiu->vertex_cache_tex.v, wiiu->vertex_cache_tex.current * sizeof(*wiiu->vertex_cache_tex.v));
|
2018-01-06 02:39:53 +00:00
|
|
|
|
2017-05-21 02:05:41 +00:00
|
|
|
if (wiiu->menu.enable)
|
|
|
|
GX2DrawDone();
|
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_DRC);
|
|
|
|
GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_TV);
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
GX2SwapScanBuffers();
|
|
|
|
GX2Flush();
|
2016-10-27 00:34:10 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-16 21:26:07 +00:00
|
|
|
static void wiiu_gfx_set_nonblock_state(void *data, bool toggle,
|
|
|
|
bool adaptive_vsync_enabled, unsigned swap_interval)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
2016-11-06 22:29:54 +00:00
|
|
|
|
|
|
|
if (!wiiu)
|
|
|
|
return;
|
|
|
|
|
2016-11-14 14:09:53 +00:00
|
|
|
wiiu->vsync = !toggle;
|
2016-11-10 14:11:33 +00:00
|
|
|
GX2SetSwapInterval(!toggle); /* do we need this ? */
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static bool wiiu_gfx_alive(void *data)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static bool wiiu_gfx_focus(void *data)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static bool wiiu_gfx_suppress_screensaver(void *data, bool enable)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)enable;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static bool wiiu_gfx_set_shader(void *data,
|
2019-04-30 11:37:10 +00:00
|
|
|
enum rarch_shader_type type, const char *path)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2019-08-08 12:54:21 +00:00
|
|
|
unsigned i;
|
2019-04-30 11:37:10 +00:00
|
|
|
config_file_t *conf = NULL;
|
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *)data;
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (!wiiu)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
GX2DrawDone();
|
|
|
|
wiiu_free_shader_preset(wiiu);
|
|
|
|
|
2019-06-04 19:52:58 +00:00
|
|
|
if (string_is_empty(path))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (type != RARCH_SHADER_SLANG)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2019-06-04 19:52:58 +00:00
|
|
|
RARCH_WARN("[GX2] Only Slang shaders are supported. Falling back to stock.\n");
|
|
|
|
return false;
|
2018-01-06 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
2019-08-19 10:36:44 +00:00
|
|
|
if (!(conf = video_shader_read_preset(path)))
|
2018-01-06 02:39:53 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
wiiu->shader_preset = calloc(1, sizeof(*wiiu->shader_preset));
|
|
|
|
|
2019-07-21 14:40:14 +00:00
|
|
|
if (!video_shader_read_conf_preset(conf, wiiu->shader_preset))
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
|
|
|
free(wiiu->shader_preset);
|
|
|
|
wiiu->shader_preset = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
2019-06-04 19:52:58 +00:00
|
|
|
slang_preprocess_parse_parameters(wiiu->shader_preset->pass[i].source.path, wiiu->shader_preset);
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2019-06-04 19:52:58 +00:00
|
|
|
video_shader_resolve_current_parameters(conf, wiiu->shader_preset);
|
|
|
|
config_file_free(conf);
|
2018-01-06 02:39:53 +00:00
|
|
|
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->passes; i++)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2020-05-19 14:20:43 +00:00
|
|
|
unsigned j;
|
2018-01-06 02:39:53 +00:00
|
|
|
char gfdpath[PATH_MAX_LENGTH];
|
|
|
|
struct video_shader_pass *pass = &wiiu->shader_preset->pass[i];
|
|
|
|
|
|
|
|
strncpy(gfdpath, pass->source.path, PATH_MAX_LENGTH);
|
|
|
|
|
|
|
|
char *ptr = strrchr(gfdpath, '.');
|
|
|
|
|
|
|
|
if (!ptr)
|
|
|
|
ptr = gfdpath + strlen(gfdpath);
|
|
|
|
|
|
|
|
*ptr++ = '.';
|
|
|
|
*ptr++ = 'g';
|
|
|
|
*ptr++ = 's';
|
|
|
|
*ptr++ = 'h';
|
|
|
|
*ptr++ = '\0';
|
|
|
|
|
|
|
|
wiiu->pass[i].gfd = gfd_open(gfdpath);
|
|
|
|
|
|
|
|
if (!wiiu->pass[i].gfd)
|
|
|
|
{
|
|
|
|
wiiu_free_shader_preset(wiiu);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->vs->uniformBlockCount; j++)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2018-01-09 02:06:54 +00:00
|
|
|
wiiu->pass[i].vs_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->vs->uniformBlocks[j].size,
|
2020-05-19 14:20:43 +00:00
|
|
|
GX2_UNIFORM_BLOCK_ALIGNMENT);
|
2018-01-09 02:06:54 +00:00
|
|
|
memset(wiiu->pass[i].vs_ubos[j], 0, wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].vs_ubos[j],
|
2020-05-19 14:20:43 +00:00
|
|
|
wiiu->pass[i].gfd->vs->uniformBlocks[j].size);
|
2018-01-06 02:39:53 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
for (j = 0; j < 2 && j < wiiu->pass[i].gfd->ps->uniformBlockCount; j++)
|
2018-01-06 02:39:53 +00:00
|
|
|
{
|
2018-01-09 02:06:54 +00:00
|
|
|
wiiu->pass[i].ps_ubos[j] = MEM2_alloc(wiiu->pass[i].gfd->ps->uniformBlocks[j].size,
|
2020-05-19 14:20:43 +00:00
|
|
|
GX2_UNIFORM_BLOCK_ALIGNMENT);
|
2018-01-09 02:06:54 +00:00
|
|
|
memset(wiiu->pass[i].ps_ubos[j], 0, wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->pass[i].ps_ubos[j],
|
2020-05-19 14:20:43 +00:00
|
|
|
wiiu->pass[i].gfd->ps->uniformBlocks[j].size);
|
2018-01-06 02:39:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-08 12:54:21 +00:00
|
|
|
for (i = 0; i < wiiu->shader_preset->luts; i++)
|
2018-01-09 15:41:01 +00:00
|
|
|
{
|
|
|
|
struct texture_image image = {};
|
|
|
|
|
|
|
|
if (image_texture_load(&image, wiiu->shader_preset->lut[i].path))
|
|
|
|
{
|
2020-05-20 21:34:23 +00:00
|
|
|
unsigned j;
|
|
|
|
|
2018-01-09 15:41:01 +00:00
|
|
|
wiiu->luts[i].surface.width = image.width;
|
|
|
|
wiiu->luts[i].surface.height = image.height;
|
|
|
|
wiiu->luts[i].surface.depth = 1;
|
|
|
|
wiiu->luts[i].surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
|
|
|
wiiu->luts[i].surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
|
|
|
wiiu->luts[i].viewNumSlices = 1;
|
|
|
|
|
|
|
|
wiiu->luts[i].surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
|
|
|
wiiu->luts[i].compMap = GX2_COMP_SEL(_G, _B, _A, _R);
|
|
|
|
|
|
|
|
GX2CalcSurfaceSizeAndAlignment(&wiiu->luts[i].surface);
|
|
|
|
GX2InitTextureRegs(&wiiu->luts[i]);
|
|
|
|
wiiu->luts[i].surface.image = MEM2_alloc(wiiu->luts[i].surface.imageSize,
|
|
|
|
wiiu->luts[i].surface.alignment);
|
|
|
|
|
2020-05-19 14:20:43 +00:00
|
|
|
for (j = 0; (j < image.height) && (j < wiiu->luts[i].surface.height); j++)
|
2018-01-09 15:41:01 +00:00
|
|
|
memcpy((uint32_t *)wiiu->luts[i].surface.image + (j * wiiu->luts[i].surface.pitch),
|
|
|
|
image.pixels + (j * image.width), image.width * sizeof(image.pixels));
|
|
|
|
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->luts[i].surface.image,
|
|
|
|
wiiu->luts[i].surface.imageSize);
|
|
|
|
|
|
|
|
image_texture_free(&image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct video_shader *wiiu_gfx_get_current_shader(void *data)
|
|
|
|
{
|
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *)data;
|
|
|
|
|
|
|
|
if (!wiiu)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return wiiu->shader_preset;
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_set_rotation(void *data,
|
2016-10-27 22:02:40 +00:00
|
|
|
unsigned rotation)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
|
|
|
|
|
|
|
if (wiiu)
|
2018-01-04 16:38:04 +00:00
|
|
|
{
|
2016-11-14 14:09:53 +00:00
|
|
|
wiiu->rotation = rotation;
|
2018-01-05 12:18:55 +00:00
|
|
|
wiiu_set_projection(wiiu);
|
2018-01-04 16:38:04 +00:00
|
|
|
wiiu->should_resize = true;
|
|
|
|
}
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_viewport_info(void *data,
|
|
|
|
struct video_viewport *vp)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
|
|
|
|
|
|
|
if (wiiu)
|
2016-11-14 14:09:53 +00:00
|
|
|
*vp = wiiu->vp;
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static uintptr_t wiiu_gfx_load_texture(void *video_data, void *data,
|
|
|
|
bool threaded, enum texture_filter_type filter_type)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2017-11-04 06:58:04 +00:00
|
|
|
uint32_t i;
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) video_data;
|
|
|
|
struct texture_image *image = (struct texture_image *)data;
|
2017-05-22 00:45:40 +00:00
|
|
|
|
|
|
|
if (!wiiu)
|
|
|
|
return 0;
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2Texture *texture = calloc(1, sizeof(GX2Texture));
|
2017-05-22 00:45:40 +00:00
|
|
|
|
|
|
|
texture->surface.width = image->width;
|
|
|
|
texture->surface.height = image->height;
|
|
|
|
texture->surface.depth = 1;
|
|
|
|
texture->surface.dim = GX2_SURFACE_DIM_TEXTURE_2D;
|
|
|
|
texture->surface.tileMode = GX2_TILE_MODE_LINEAR_ALIGNED;
|
|
|
|
texture->viewNumSlices = 1;
|
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
texture->surface.format = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
|
|
|
texture->compMap = GX2_COMP_SEL(_G, _B, _A, _R);
|
2017-05-22 00:45:40 +00:00
|
|
|
|
|
|
|
GX2CalcSurfaceSizeAndAlignment(&texture->surface);
|
|
|
|
GX2InitTextureRegs(texture);
|
|
|
|
texture->surface.image = MEM2_alloc(texture->surface.imageSize, texture->surface.alignment);
|
|
|
|
|
|
|
|
for (i = 0; (i < image->height) && (i < texture->surface.height); i++)
|
2018-01-06 02:39:53 +00:00
|
|
|
memcpy((uint32_t *)texture->surface.image + (i * texture->surface.pitch),
|
2017-05-22 00:45:40 +00:00
|
|
|
image->pixels + (i * image->width), image->width * sizeof(image->pixels));
|
|
|
|
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, texture->surface.image, texture->surface.imageSize);
|
|
|
|
|
|
|
|
return (uintptr_t)texture;
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_unload_texture(void *data, uintptr_t handle)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
GX2Texture *texture = (GX2Texture *)handle;
|
2017-05-22 00:45:40 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
if (!texture)
|
2017-05-22 00:45:40 +00:00
|
|
|
return;
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2017-05-22 00:45:40 +00:00
|
|
|
MEM2_free(texture->surface.image);
|
|
|
|
free(texture);
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
2020-03-05 04:36:22 +00:00
|
|
|
static void wiiu_gfx_set_filtering(void *data, unsigned index, bool smooth, bool ctx_scaling)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
|
|
|
|
|
|
|
if (wiiu)
|
2016-11-14 14:09:53 +00:00
|
|
|
wiiu->smooth = smooth;
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_apply_state_changes(void *data)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *)data;
|
2016-11-13 17:43:22 +00:00
|
|
|
|
|
|
|
if (wiiu)
|
|
|
|
wiiu->should_resize = true;
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
2016-11-13 17:43:22 +00:00
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_set_texture_frame(void *data, const void *frame, bool rgb32,
|
|
|
|
unsigned width, unsigned height, float alpha)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2017-11-04 06:58:04 +00:00
|
|
|
uint32_t i;
|
2017-09-27 21:16:37 +00:00
|
|
|
const uint16_t *src = NULL;
|
|
|
|
uint16_t *dst = NULL;
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
2016-10-27 22:02:40 +00:00
|
|
|
|
|
|
|
if (!wiiu)
|
2016-10-27 00:34:10 +00:00
|
|
|
return;
|
|
|
|
|
2016-10-27 22:02:40 +00:00
|
|
|
if (!frame || !width || !height)
|
2016-10-27 00:34:10 +00:00
|
|
|
return;
|
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
if (width > wiiu->menu.texture.surface.width)
|
|
|
|
width = wiiu->menu.texture.surface.width;
|
2016-10-27 22:02:40 +00:00
|
|
|
|
2016-11-05 14:05:46 +00:00
|
|
|
if (height > wiiu->menu.texture.surface.height)
|
|
|
|
height = wiiu->menu.texture.surface.height;
|
2016-10-27 00:34:10 +00:00
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
wiiu->menu.width = width;
|
2016-10-27 00:34:10 +00:00
|
|
|
wiiu->menu.height = height;
|
|
|
|
|
2017-09-27 21:16:37 +00:00
|
|
|
src = frame;
|
2018-01-06 02:39:53 +00:00
|
|
|
dst = (uint16_t *)wiiu->menu.texture.surface.image;
|
2016-11-05 14:05:46 +00:00
|
|
|
|
2016-10-27 00:34:10 +00:00
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
|
|
|
memcpy(dst, src, width * sizeof(uint16_t));
|
2016-11-05 14:05:46 +00:00
|
|
|
dst += wiiu->menu.texture.surface.pitch;
|
2016-10-27 00:34:10 +00:00
|
|
|
src += width;
|
|
|
|
}
|
2016-11-05 14:05:46 +00:00
|
|
|
|
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, wiiu->menu.texture.surface.image,
|
|
|
|
wiiu->menu.texture.surface.imageSize);
|
|
|
|
|
2019-06-03 11:38:40 +00:00
|
|
|
wiiu->menu.v->pos.x = wiiu->vp.x;
|
|
|
|
wiiu->menu.v->pos.y = wiiu->vp.y;
|
|
|
|
wiiu->menu.v->pos.width = wiiu->vp.width;
|
|
|
|
wiiu->menu.v->pos.height = wiiu->vp.height;
|
2018-01-04 16:38:04 +00:00
|
|
|
wiiu->menu.v->coord.u = 0.0f;
|
|
|
|
wiiu->menu.v->coord.v = 0.0f;
|
2019-06-03 10:35:46 +00:00
|
|
|
wiiu->menu.v->coord.width = (float)width / wiiu->menu.texture.surface.width;
|
|
|
|
wiiu->menu.v->coord.height = (float)height / wiiu->menu.texture.surface.height;
|
2018-01-04 16:38:04 +00:00
|
|
|
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, wiiu->menu.v, 4 * sizeof(*wiiu->menu.v));
|
|
|
|
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_set_texture_enable(void *data, bool state, bool full_screen)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
|
|
|
(void) full_screen;
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *) data;
|
|
|
|
|
|
|
|
if (wiiu)
|
2016-11-14 14:09:53 +00:00
|
|
|
wiiu->menu.enable = state;
|
2016-10-27 00:34:10 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_set_osd_msg(void *data,
|
2020-03-10 02:24:59 +00:00
|
|
|
const char *msg,
|
|
|
|
const void *params, void *font)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_video_t *wiiu = (wiiu_video_t *)data;
|
2017-05-21 02:05:41 +00:00
|
|
|
|
|
|
|
if (wiiu)
|
2017-05-22 05:07:27 +00:00
|
|
|
{
|
|
|
|
if (wiiu->render_msg_enabled)
|
2020-03-10 02:24:59 +00:00
|
|
|
font_driver_render_msg(wiiu, msg, params, font);
|
2017-05-22 05:07:27 +00:00
|
|
|
}
|
2016-10-27 00:34:10 +00:00
|
|
|
}
|
|
|
|
|
2019-03-12 23:53:35 +00:00
|
|
|
static uint32_t wiiu_gfx_get_flags(void *data)
|
|
|
|
{
|
|
|
|
uint32_t flags = 0;
|
|
|
|
|
2019-05-05 11:46:26 +00:00
|
|
|
BIT32_SET(flags, GFX_CTX_FLAGS_SCREENSHOTS_SUPPORTED);
|
2019-06-19 01:18:28 +00:00
|
|
|
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
|
|
|
|
BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG);
|
|
|
|
#endif
|
2019-03-12 23:53:35 +00:00
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2018-04-23 11:34:30 +00:00
|
|
|
static const video_poke_interface_t wiiu_poke_interface = {
|
2019-03-12 23:53:35 +00:00
|
|
|
wiiu_gfx_get_flags,
|
2016-11-13 17:43:22 +00:00
|
|
|
wiiu_gfx_load_texture,
|
|
|
|
wiiu_gfx_unload_texture,
|
2017-11-04 06:58:04 +00:00
|
|
|
NULL, /* set_video_mode */
|
2018-04-15 16:12:56 +00:00
|
|
|
NULL, /* get_refresh_rate */
|
2016-11-13 17:43:22 +00:00
|
|
|
wiiu_gfx_set_filtering,
|
2016-10-27 00:34:10 +00:00
|
|
|
NULL, /* get_video_output_size */
|
|
|
|
NULL, /* get_video_output_prev */
|
|
|
|
NULL, /* get_video_output_next */
|
|
|
|
NULL, /* get_current_framebuffer */
|
2017-11-04 06:58:04 +00:00
|
|
|
NULL, /* get_proc_address */
|
2016-11-13 17:43:22 +00:00
|
|
|
wiiu_gfx_set_aspect_ratio,
|
|
|
|
wiiu_gfx_apply_state_changes,
|
|
|
|
wiiu_gfx_set_texture_frame,
|
|
|
|
wiiu_gfx_set_texture_enable,
|
|
|
|
wiiu_gfx_set_osd_msg,
|
2017-11-04 06:58:04 +00:00
|
|
|
NULL, /* show_mouse */
|
|
|
|
NULL, /* grab_mouse_toggle */
|
2018-01-06 02:39:53 +00:00
|
|
|
wiiu_gfx_get_current_shader,
|
2017-11-04 06:58:04 +00:00
|
|
|
NULL, /* get_current_software_framebuffer */
|
|
|
|
NULL, /* get_hw_render_interface */
|
2016-10-27 00:34:10 +00:00
|
|
|
};
|
|
|
|
|
2018-01-06 02:39:53 +00:00
|
|
|
static void wiiu_gfx_get_poke_interface(void *data,
|
|
|
|
const video_poke_interface_t **iface)
|
2016-10-27 00:34:10 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
*iface = &wiiu_poke_interface;
|
|
|
|
}
|
|
|
|
|
2020-02-17 20:28:42 +00:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
2020-02-17 00:43:40 +00:00
|
|
|
static bool wiiu_gfx_widgets_enabled(void *data)
|
2019-02-07 01:03:48 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-10-27 00:34:10 +00:00
|
|
|
video_driver_t video_wiiu =
|
|
|
|
{
|
|
|
|
wiiu_gfx_init,
|
|
|
|
wiiu_gfx_frame,
|
|
|
|
wiiu_gfx_set_nonblock_state,
|
|
|
|
wiiu_gfx_alive,
|
|
|
|
wiiu_gfx_focus,
|
|
|
|
wiiu_gfx_suppress_screensaver,
|
2017-05-13 17:11:32 +00:00
|
|
|
NULL, /* has_windowed */
|
2016-10-27 00:34:10 +00:00
|
|
|
wiiu_gfx_set_shader,
|
|
|
|
wiiu_gfx_free,
|
|
|
|
"gx2",
|
|
|
|
NULL, /* set_viewport */
|
|
|
|
wiiu_gfx_set_rotation,
|
|
|
|
wiiu_gfx_viewport_info,
|
2019-05-22 05:07:33 +00:00
|
|
|
NULL, /* read_viewport */
|
2016-10-27 00:34:10 +00:00
|
|
|
NULL, /* read_frame_raw */
|
|
|
|
#ifdef HAVE_OVERLAY
|
2017-12-27 07:38:03 +00:00
|
|
|
gx2_get_overlay_interface, /* overlay_interface */
|
2019-04-01 03:00:58 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VIDEO_LAYOUT
|
|
|
|
NULL,
|
2016-10-27 00:34:10 +00:00
|
|
|
#endif
|
2016-10-27 22:02:40 +00:00
|
|
|
wiiu_gfx_get_poke_interface,
|
2017-11-04 06:58:04 +00:00
|
|
|
NULL, /* wrap_type_to_enum */
|
2020-02-17 20:28:42 +00:00
|
|
|
#ifdef HAVE_GFX_WIDGETS
|
2020-02-17 00:43:40 +00:00
|
|
|
wiiu_gfx_widgets_enabled
|
2019-02-07 01:03:48 +00:00
|
|
|
#endif
|
2016-10-27 00:34:10 +00:00
|
|
|
};
|