Skip to content

Commit

Permalink
Source: backport some patches from simple64 to mupen64plus-video-para…
Browse files Browse the repository at this point in the history
…llel
  • Loading branch information
Rosalie241 committed Feb 6, 2025
1 parent 002ec7a commit 4418e51
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Source/3rdParty/mupen64plus-video-parallel/gfx_m64p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include "m64p_types.h"
#include "m64p_config.h"
#include "m64p_plugin.h"

#include <string.h>
#include <stdint.h>
Expand Down Expand Up @@ -65,7 +66,7 @@ void (*render_callback)(int);
m64p_handle configVideoParallel = NULL;

#define PLUGIN_VERSION 0x000001
#define VIDEO_PLUGIN_API_VERSION 0x020200
#define VIDEO_PLUGIN_API_VERSION 0x020201
#define DP_INTERRUPT 0x20

uint32_t rdram_size;
Expand Down Expand Up @@ -288,6 +289,11 @@ EXPORT void CALL ProcessRDPList(void)
vk_process_commands();
}

EXPORT void CALL FullSync(void)
{
vk_full_sync();
}

EXPORT int CALL RomOpen(void)
{
window_fullscreen = false;
Expand Down
26 changes: 25 additions & 1 deletion Source/3rdParty/mupen64plus-video-parallel/parallel_imp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ bool vk_synchronous, vk_divot_filter, vk_gamma_dither;
bool vk_vi_aa, vk_vi_scale, vk_dither_filter;
bool vk_interlacing;

static uint64_t rdp_sync_signal;
static uint64_t last_frame_counter;
static uint64_t frame_counter;

static const unsigned cmd_len_lut[64] = {
1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 12, 14, 12, 14, 20, 22,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Expand Down Expand Up @@ -440,7 +444,17 @@ void vk_process_commands()

// For synchronous RDP:
if (vk_synchronous)
processor->signal_timeline();
{
if (frame_counter != last_frame_counter) // Only sync once per frame
{
rdp_sync_signal = processor->signal_timeline();
last_frame_counter = frame_counter;
}
else
{
rdp_sync_signal = 0;
}
}

*gfx.MI_INTR_REG |= DP_INTERRUPT;
*GET_GFX_INFO(DPC_STATUS_REG) &= ~(DP_STATUS_PIPE_BUSY | DP_STATUS_START_GCLK);
Expand All @@ -462,6 +476,13 @@ void vk_resize()
platform->do_resize();
}


void vk_full_sync()
{
if (vk_synchronous && rdp_sync_signal)
processor->wait_for_timeline(rdp_sync_signal);
}

void vk_destroy()
{
wsi->end_frame();
Expand Down Expand Up @@ -549,5 +570,8 @@ bool vk_init()
processor->set_quirks(quirks);

wsi->begin_frame();

last_frame_counter = 0;
frame_counter = 0;
return true;
}
1 change: 1 addition & 0 deletions Source/3rdParty/mupen64plus-video-parallel/parallel_imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern "C"
bool vk_init();
void vk_destroy();
void vk_resize();
void vk_full_sync();
void vk_read_screen(unsigned char* dest);

#ifdef __cplusplus
Expand Down

0 comments on commit 4418e51

Please sign in to comment.