Skip to content
Permalink
Browse files

Added parallel rendering compatibility modes

This allows users to choose between speed and compatibility when using parallel rendering.
The default medium profile is equal to the previously hardcoded settings.

This should help with issues #80 and #12
  • Loading branch information...
ata4 committed Jun 10, 2019
1 parent be22b10 commit 1f8e27b779e49041fd53cf4500e115b747f3cb89
@@ -79,72 +79,9 @@ static uint32_t rdp_cmd_pos;
static uint32_t rdp_cmd_id;
static uint32_t rdp_cmd_len;

static bool rdp_cmd_sync[] = {
false, // No_Op
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // Fill_Triangle
false, // Fill_ZBuffer_Triangle
false, // Texture_Triangle
false, // Texture_ZBuffer_Triangle
false, // Shade_Triangle
false, // Shade_ZBuffer_Triangle
false, // Shade_Texture_Triangle
false, // Shade_Texture_Z_Buffer_Triangle
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // ???
false, // Texture_Rectangle
false, // Texture_Rectangle_Flip
false, // Sync_Load
false, // Sync_Pipe
false, // Sync_Tile
true, // Sync_Full
false, // Set_Key_GB
false, // Set_Key_R
false, // Set_Convert
false, // Set_Scissor
false, // Set_Prim_Depth
false, // Set_Other_Modes
false, // Load_TLUT
false, // ???
false, // Set_Tile_Size
false, // Load_Block
false, // Load_Tile
false, // Set_Tile
false, // Fill_Rectangle
false, // Set_Fill_Color
false, // Set_Fog_Color
false, // Set_Blend_Color
false, // Set_Prim_Color
false, // Set_Env_Color
false, // Set_Combine
false, // Set_Texture_Image
true, // Set_Mask_Image
true, // Set_Color_Image
};
// table of commands that require thread synchronization in
// multithreaded mode
static bool rdp_cmd_sync[64];

static void cmd_run_buffered(uint32_t worker_id)
{
@@ -182,6 +119,7 @@ void n64video_config_init(struct n64video_config* config)
config->vi.hide_overscan = false;
config->vi.exclusive = false;
config->vi.vsync = true;
config->dp.compat = DP_COMPAT_MEDIUM;
}

void rdp_init_worker(uint32_t worker_id)
@@ -206,6 +144,18 @@ void n64video_init(struct n64video_config* _config)
init_lut = true;
}

// enable sync switches depending on compatibility mode
memset(rdp_cmd_sync, 0, sizeof(rdp_cmd_sync));
switch (config.dp.compat) {
case DP_COMPAT_HIGH:
rdp_cmd_sync[CMD_ID_SET_TEXTURE_IMAGE] = true;
case DP_COMPAT_MEDIUM:
rdp_cmd_sync[CMD_ID_SET_MASK_IMAGE] = true;
rdp_cmd_sync[CMD_ID_SET_COLOR_IMAGE] = true;
case DP_COMPAT_LOW:
rdp_cmd_sync[CMD_ID_SYNC_FULL] = true;
}

// init externals
screen_init(&config);
plugin_init();
@@ -5,6 +5,7 @@

#define RDRAM_MAX_SIZE 0x800000

// register enums
enum dp_register
{
DP_START,
@@ -37,6 +38,7 @@ enum vi_register
VI_NUM_REG
};

// config enums
enum vi_mode
{
VI_MODE_NORMAL, // color buffer with VI filter
@@ -53,6 +55,14 @@ enum vi_interp
VI_INTERP_NUM
};

enum dp_compat_profile
{
DP_COMPAT_LOW,
DP_COMPAT_MEDIUM,
DP_COMPAT_HIGH,
DP_COMPAT_NUM
};

struct n64video_config
{
struct {
@@ -63,6 +73,9 @@ struct n64video_config
bool vsync;
bool exclusive;
} vi;
struct {
enum dp_compat_profile compat;
} dp;
bool parallel;
uint32_t num_workers;
};
@@ -34,6 +34,8 @@
#define KEY_VI_WIDESCREEN "ViWidescreen"
#define KEY_VI_HIDE_OVERSCAN "ViHideOverscan"

#define KEY_DP_COMPAT "DpCompat"

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
@@ -110,6 +112,7 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle _CoreLibHandle, void *Co
ConfigSetDefaultInt(configVideoAngrylionPlus, KEY_VI_INTERP, config.vi.interp, "Scaling interpolation type (0=NN, 1=Linear)");
ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_WIDESCREEN, config.vi.widescreen, "Use anamorphic 16:9 output mode if True");
ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_VI_HIDE_OVERSCAN, config.vi.hide_overscan, "Hide overscan area in filteded mode if True");
ConfigSetDefaultBool(configVideoAngrylionPlus, KEY_DP_COMPAT, config.dp.compat, "Compatibility mode (0=Fast 1=Moderate 2=Slow");

ConfigSaveSection("Video-General");
ConfigSaveSection("Video-Angrylion-Plus");
@@ -195,6 +198,8 @@ EXPORT int CALL RomOpen (void)
config.vi.widescreen = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_WIDESCREEN);
config.vi.hide_overscan = ConfigGetParamBool(configVideoAngrylionPlus, KEY_VI_HIDE_OVERSCAN);

config.dp.compat = ConfigGetParamInt(configVideoAngrylionPlus, KEY_DP_COMPAT);

n64video_init(&config);
return 1;
}
@@ -12,6 +12,7 @@

#define SECTION_GENERAL "General"
#define SECTION_VIDEO_INTERFACE "VideoInterface"
#define SECTION_DISPLAY_PROCESSOR "DisplayProcessor"

#define KEY_GEN_PARALLEL "parallel"
#define KEY_GEN_NUM_WORKERS "num_workers"
@@ -23,6 +24,8 @@
#define KEY_VI_EXCLUSIVE "exclusive"
#define KEY_VI_VSYNC "vsync"

#define KEY_DP_COMPAT "compat"

#define CONFIG_FILE_NAME CORE_SIMPLE_NAME "-config.ini"

#define CONFIG_DLG_INIT_CHECKBOX(id, var, config) \
@@ -42,6 +45,7 @@ static HWND dlg_check_vi_widescreen;
static HWND dlg_check_vi_overscan;
static HWND dlg_check_vi_exclusive;
static HWND dlg_check_vi_vsync;
static HWND dlg_combo_dp_compat;
static HWND dlg_spin_workers;
static HWND dlg_edit_workers;

@@ -50,6 +54,7 @@ static void config_dialog_update_multithread(void)
BOOL check = (BOOL)SendMessage(dlg_check_multithread, BM_GETCHECK, 0, 0);
EnableWindow(dlg_spin_workers, check);
EnableWindow(dlg_edit_workers, check);
EnableWindow(dlg_combo_dp_compat, check);
}

static void config_dialog_update_vi_mode(void)
@@ -93,6 +98,15 @@ INT_PTR CALLBACK config_dialog_proc(HWND hwnd, UINT iMessage, WPARAM wParam, LPA
dlg_combo_vi_interp = GetDlgItem(hwnd, IDC_COMBO_VI_INTERP);
config_dialog_fill_combo(dlg_combo_vi_interp, vi_interp_strings, VI_INTERP_NUM, config.vi.interp);

char* dp_compat_strings[] = {
"Fast, most glitches", // DP_COMPAT_LOW
"Moderate, some glitches", // DP_COMPAT_MEDIUM
"Slow, few glitches" // DP_COMPAT_HIGH
};

dlg_combo_dp_compat = GetDlgItem(hwnd, IDC_COMBO_DP_COMPAT);
config_dialog_fill_combo(dlg_combo_dp_compat, dp_compat_strings, DP_COMPAT_NUM, config.dp.compat);

CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_MULTITHREAD, dlg_check_multithread, config.parallel);
CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_VI_WIDESCREEN, dlg_check_vi_widescreen, config.vi.widescreen);
CONFIG_DLG_INIT_CHECKBOX(IDC_CHECK_VI_OVERSCAN, dlg_check_vi_overscan, config.vi.hide_overscan);
@@ -138,6 +152,7 @@ INT_PTR CALLBACK config_dialog_proc(HWND hwnd, UINT iMessage, WPARAM wParam, LPA
config.vi.hide_overscan = SendMessage(dlg_check_vi_overscan, BM_GETCHECK, 0, 0);
config.vi.exclusive = SendMessage(dlg_check_vi_exclusive, BM_GETCHECK, 0, 0);
config.vi.vsync = SendMessage(dlg_check_vi_vsync, BM_GETCHECK, 0, 0);
config.dp.compat = SendMessage(dlg_combo_dp_compat, CB_GETCURSEL, 0, 0);
config.parallel = SendMessage(dlg_check_multithread, BM_GETCHECK, 0, 0);
config.num_workers = GetDlgItemInt(hwnd, IDC_EDIT_WORKERS, FALSE, FALSE);
config_stale = true;
@@ -182,6 +197,10 @@ static void config_handle(const char* key, const char* value, const char* sectio
} else if (!_strcmpi(key, KEY_VI_VSYNC)) {
config.vi.vsync = strtol(value, NULL, 0) != 0;
}
} else if (!_strcmpi(section, SECTION_DISPLAY_PROCESSOR)) {
if (!_strcmpi(key, KEY_DP_COMPAT)) {
config.dp.compat = strtol(value, NULL, 0);
}
}
}

@@ -287,6 +306,9 @@ bool config_save(void)
config_write_int32(fp, KEY_VI_EXCLUSIVE, config.vi.exclusive);
config_write_int32(fp, KEY_VI_VSYNC, config.vi.vsync);

config_write_section(fp, SECTION_DISPLAY_PROCESSOR);
config_write_int32(fp, KEY_DP_COMPAT, config.dp.compat);

fclose(fp);

return true;
BIN +316 Bytes (100%) src/plugin/zilmar/config.rc
Binary file not shown.
BIN -276 Bytes (87%) src/plugin/zilmar/resource.h
Binary file not shown.

0 comments on commit 1f8e27b

Please sign in to comment.
You can’t perform that action at this time.