winport - preliminary work on binding HD rendering

This commit is contained in:
zeromus 2015-09-14 09:13:57 +00:00
parent 601b86c78a
commit 8c00e2c676
5 changed files with 127 additions and 57 deletions

View File

@ -480,6 +480,7 @@ extern struct TCommonSettings {
, GFX3D_Zelda_Shadow_Depth_Hack(0)
, GFX3D_Renderer_Multisample(false)
, GFX3D_TXTHack(false)
, GFX3D_PrescaleHD(1)
, jit_max_block_size(100)
, loadToMemory(false)
, UseExtBIOS(false)
@ -540,6 +541,9 @@ extern struct TCommonSettings {
bool GFX3D_Renderer_Multisample;
bool GFX3D_TXTHack;
//may not want this on OSX port
int GFX3D_PrescaleHD;
bool loadToMemory;
bool UseExtBIOS;

View File

@ -1857,7 +1857,17 @@ static void DD_DoDisplay()
}
//triple buffering logic
u16 displayBuffers[3][256*192*4];
struct DisplayBuffer
{
DisplayBuffer()
: buffer(NULL)
, size(0)
{
}
u16* buffer;
int size; //[256*192*4];
} displayBuffers[3];
volatile int currDisplayBuffer=-1;
volatile int newestDisplayBuffer=-2;
GMutex *display_mutex = NULL;
@ -1897,7 +1907,7 @@ static void DoDisplay(bool firstTime)
//convert pixel format to 32bpp for compositing
//why do we do this over and over? well, we are compositing to
//filteredbuffer32bpp, and it needs to get refreshed each frame..
const int size = video.size();
const int size = video.srcBufferSize/2;
u16* src = (u16*)video.srcBuffer;
for(int i=0;i<size;i++)
video.buffer[i] = RGB15TO24_REVERSE(src[i]);
@ -1967,7 +1977,8 @@ void displayProc()
if(!alreadyDisplayed) {
//start displaying a new buffer
currDisplayBuffer = todo;
video.srcBuffer = (u8*)displayBuffers[currDisplayBuffer];
video.srcBuffer = (u8*)displayBuffers[currDisplayBuffer].buffer;
video.srcBufferSize = displayBuffers[currDisplayBuffer].size;
DoDisplay(true);
}
@ -2000,6 +2011,7 @@ void Display()
if(CommonSettings.single_core())
{
video.srcBuffer = (u8*)GPU->GetNativeFramebuffer();
video.srcBufferSize = GPU->GetCustomFramebufferHeight()*GPU->GetCustomFramebufferWidth()*2*2;
DoDisplay(true);
}
else
@ -2019,7 +2031,15 @@ void Display()
newestDisplayBuffer += diff;
else newestDisplayBuffer = (currDisplayBuffer+2)%3;
memcpy(displayBuffers[newestDisplayBuffer],GPU->GetNativeFramebuffer(),256*192*4);
DisplayBuffer& db = displayBuffers[newestDisplayBuffer];
int targetSize = 256*192*4*video.prescaleHD*video.prescaleHD;
if(db.size != targetSize)
{
free_aligned(db.buffer);
db.buffer = (u16*)malloc_alignedCacheLine(targetSize);
db.size = targetSize;
}
memcpy(db.buffer,GPU->GetCustomFramebuffer(),targetSize);
g_mutex_unlock(display_mutex);
}
@ -3139,6 +3159,9 @@ int _main()
SetMinWindowSize();
CommonSettings.GFX3D_PrescaleHD = GetPrivateProfileInt("3D", "PrescaleHD", 0, IniName);
video.SetPrescale(CommonSettings.GFX3D_PrescaleHD,1);
ScaleScreen(windowSize, false);
DragAcceptFiles(MainWindow->getHWnd(), TRUE);
@ -3264,6 +3287,8 @@ int _main()
NDS_Init();
GPU->ClearWithColor(0xFFFF);
GPU->SetCustomFramebufferSize(256*video.prescaleHD,192*video.prescaleHD);
#ifdef GDB_STUB
gdbstub_mutex_init();
@ -3354,6 +3379,7 @@ int _main()
CommonSettings.GFX3D_TXTHack = GetPrivateProfileBool("3D", "EnableTXTHack", 0, IniName); //default is off.
Change3DCoreWithFallbackAndSave(cur3DCore);
#ifdef BETA_VERSION
EnableMenuItem (mainMenu, IDM_SUBMITBUGREPORT, MF_GRAYED);
#endif
@ -6362,6 +6388,9 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
SetDlgItemInt (hw,IDC_ZELDA_SHADOW_DEPTH_HACK,CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack,FALSE);
//CheckDlgButton(hw,IDC_ALTERNATEFLUSH,CommonSettings.gfx3d_flushMode);
SendDlgItemMessage(hw, IDC_NUD_PRESCALEHD, UDM_SETRANGE, 0, MAKELPARAM(5, 1));
SendDlgItemMessage(hw, IDC_NUD_PRESCALEHD, UDM_SETPOS, 0, CommonSettings.GFX3D_PrescaleHD);
for(i = 0; core3DList[i] != NULL; i++)
{
ComboBox_AddString(GetDlgItem(hw, IDC_3DCORE), core3DList[i]->name);
@ -6384,8 +6413,14 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
CommonSettings.GFX3D_Renderer_Multisample = IsDlgCheckboxChecked(hw,IDC_3DSETTINGS_ANTIALIASING);
CommonSettings.GFX3D_Zelda_Shadow_Depth_Hack = GetDlgItemInt(hw,IDC_ZELDA_SHADOW_DEPTH_HACK,NULL,FALSE);
CommonSettings.GFX3D_TXTHack = IsDlgCheckboxChecked(hw,IDC_TXTHACK);
CommonSettings.GFX3D_PrescaleHD = SendDlgItemMessage(hw, IDC_NUD_PRESCALEHD, UDM_GETPOS, 0, 0);
Change3DCoreWithFallbackAndSave(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE)));
video.SetPrescale(CommonSettings.GFX3D_PrescaleHD,1);
GPU->SetCustomFramebufferSize(256*video.prescaleHD,192*video.prescaleHD);
ScaleScreen(windowSize, false);
UpdateScreenRects();
WritePrivateProfileBool("3D", "HighResolutionInterpolateColor", CommonSettings.GFX3D_HighResolutionInterpolateColor, IniName);
WritePrivateProfileBool("3D", "EnableEdgeMark", CommonSettings.GFX3D_EdgeMark, IniName);
WritePrivateProfileBool("3D", "EnableFog", CommonSettings.GFX3D_Fog, IniName);
@ -6394,7 +6429,7 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
WritePrivateProfileInt ("3D", "EnableLineHack", CommonSettings.GFX3D_LineHack, IniName);
WritePrivateProfileInt ("3D", "EnableAntiAliasing", CommonSettings.GFX3D_Renderer_Multisample, IniName);
WritePrivateProfileInt ("3D", "EnableTXTHack", CommonSettings.GFX3D_TXTHack, IniName);
//WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName);
WritePrivateProfileInt ("3D", "PrescaleHD", CommonSettings.GFX3D_PrescaleHD, IniName);
}
case IDCANCEL:
{

View File

@ -464,7 +464,10 @@
#define IDC_FILE_QVIEW 1060
#define IDC_BEDIT 1061
#define IDC_STATIC_S1 1061
#define IDC_SPIN1 1061
#define IDC_NUD_PRESCALEHD 1061
#define IDC_STATIC_S2 1062
#define IDC_TEXT_PRESCALEHD 1062
#define IDC_STATIC_S3 1063
#define IDC_STATIC_S4 1064
#define IDC_EVALUE 1065
@ -1066,7 +1069,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 128
#define _APS_NEXT_COMMAND_VALUE 40126
#define _APS_NEXT_CONTROL_VALUE 1059
#define _APS_NEXT_CONTROL_VALUE 1063
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -13,13 +13,11 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
@ -31,7 +29,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTI
CAPTION "NITRO File System"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_FILES_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP | 0x800,7,7,359,294
CONTROL "",IDC_FILES_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_INFOTIP | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,359,294
PUSHBUTTON "Close",IDCANCEL,316,320,50,14
EDITTEXT IDC_FILE_INFO,8,322,306,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
LTEXT "Static",IDC_FILE_QVIEW,7,303,359,15,NOT WS_GROUP
@ -112,31 +110,35 @@ BEGIN
PUSHBUTTON "&Cancel",IDCANCEL,127,94,50,16
END
IDD_3DSETTINGS DIALOGEX 0, 0, 190, 252
IDD_3DSETTINGS DIALOGEX 0, 0, 390, 205
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "3D settings"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,83,234,50,14
PUSHBUTTON "Cancel",IDCANCEL,137,234,50,14
PUSHBUTTON "Default",IDC_DEFAULT,2,234,50,14
GROUPBOX "Renderer:",IDC_STATIC,7,7,174,39
COMBOBOX IDC_3DCORE,15,23,153,138,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Unrealistically High-Precision Color Interpolation",IDC_INTERPOLATECOLOR,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,64,165,10
GROUPBOX "SoftRasterizer Options",IDC_STATIC,7,52,176,114
CONTROL "Enable Edge Marking",IDC_3DSETTINGS_EDGEMARK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,76,84,10
CONTROL "Enable Fog",IDC_3DSETTINGS_FOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,88,52,10
CONTROL "Enable Textures",IDC_3DSETTINGS_TEXTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,100,67,10
LTEXT "Depth Comparison Threshold : \n -0=normal behavior (recommended) \n -bigger value can help Zelda PH/ST shadow issue",ID_LABEL_ZELDA_SHADOW_DEPTH_HACK,15,113,165,35
EDITTEXT IDC_ZELDA_SHADOW_DEPTH_HACK,109,109,44,12
LTEXT "Fixes some graphical bugs involving lines, but causes some other bugs. Not many games use lines.",ID_LABEL_ZELDA_SHADOW_DEPTH_HACK2,17,182,170,19
CONTROL "Enable Line Hack",IDC_3DSETTINGS_LINEHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,170,73,10
LTEXT "Fixes text bugs in some games.(e.g. Etrian Odyssey)",ID_LABEL_TXTHACK1,15,153,165,11
CONTROL "Enable TXT Hack",IDC_TXTHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,141,73,10
LTEXT "Reduces jagged edges on 3D objects. Only works in OpenGL renderer.",IDC_3DSETTINGS_ANTIALIASING1,17,211,169,19
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,62,165,10
CONTROL "Enable Edge Marking",IDC_3DSETTINGS_EDGEMARK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,74,84,10
CONTROL "Enable Fog",IDC_3DSETTINGS_FOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,86,52,10
CONTROL "Enable Textures",IDC_3DSETTINGS_TEXTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,98,67,10
LTEXT "Depth Comparison Threshold : \n -0=normal behavior (recommended) \n -bigger value can help Zelda PH/ST shadow issue",ID_LABEL_ZELDA_SHADOW_DEPTH_HACK,15,111,165,35
EDITTEXT IDC_ZELDA_SHADOW_DEPTH_HACK,113,106,44,12
CONTROL "Enable Anti-Aliasing",IDC_3DSETTINGS_ANTIALIASING,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,201,78,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,178,78,10
EDITTEXT IDC_TEXT_PRESCALEHD,245,61,20,14,ES_AUTOHSCROLL
CONTROL "",IDC_NUD_PRESCALEHD,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,264,61,11,14
PUSHBUTTON "Default",IDC_DEFAULT,204,187,50,14
DEFPUSHBUTTON "OK",IDOK,284,187,50,14
PUSHBUTTON "Cancel",IDCANCEL,340,187,50,14
GROUPBOX "Renderer:",IDC_STATIC,7,7,174,39
GROUPBOX "SoftRasterizer Options",IDC_STATIC,7,50,176,114
LTEXT "Fixes some graphical bugs involving lines, but causes some other bugs. Not many games use lines.",ID_LABEL_ZELDA_SHADOW_DEPTH_HACK2,197,31,160,24
CONTROL "Enable Line Hack",IDC_3DSETTINGS_LINEHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,193,19,73,10
LTEXT "Fixes text bugs in some games.(e.g. Etrian Odyssey)",ID_LABEL_TXTHACK1,15,151,165,11
CONTROL "Enable TXT Hack",IDC_TXTHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,138,73,10
GROUPBOX "OpenGL Renderer Options",IDC_STATIC,7,166,176,33
GROUPBOX "General Options",IDC_STATIC,189,6,176,114
LTEXT "HD Prescaling:",IDC_STATIC,195,64,48,8
END
IDD_ABOUT_BOX DIALOGEX 0, 0, 268, 198
@ -880,7 +882,7 @@ BEGIN
LTEXT "frames",IDC_STATIC,92,154,16,8
END
IDD_PROMPT DIALOG 0, 0, 186, 68
IDD_PROMPT DIALOG 0, 0, 186, 68
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Input Prompt"
FONT 8, "Ms Shell Dlg 2"
@ -1502,7 +1504,7 @@ END
// Menu
//
MENU_PRINCIPAL MENU
MENU_PRINCIPAL MENU
BEGIN
POPUP "&File"
BEGIN
@ -1764,7 +1766,7 @@ BEGIN
END
END
RAMWATCH_MENU MENU
RAMWATCH_MENU MENU
BEGIN
POPUP "File"
BEGIN
@ -1792,7 +1794,7 @@ BEGIN
END
END
RECENTROMS MENU
RECENTROMS MENU
BEGIN
POPUP "Recent ROMs"
BEGIN
@ -1802,7 +1804,7 @@ BEGIN
END
END
MENU_FSNITRO MENU
MENU_FSNITRO MENU
BEGIN
POPUP "FSNITRO"
BEGIN
@ -1821,7 +1823,7 @@ END
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
GUIDELINES DESIGNINFO
BEGIN
IDD_PATHSETTINGS, DIALOG
BEGIN
@ -1831,7 +1833,7 @@ BEGIN
IDD_3DSETTINGS, DIALOG
BEGIN
BOTTOMMARGIN, 248
BOTTOMMARGIN, 201
END
IDD_CHEAT_ADD, DIALOG
@ -1963,7 +1965,7 @@ END
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS
IDR_ACCELERATOR1 ACCELERATORS
BEGIN
"N", RAMMENU_FILE_NEW, VIRTKEY, CONTROL
"O", RAMMENU_FILE_OPEN, VIRTKEY, CONTROL
@ -2073,25 +2075,25 @@ IDI_FILE_BINARY ICON "bitmaps\\FileBinary.ico"
// String Table
//
STRINGTABLE
STRINGTABLE
BEGIN
IDM_FILE_STOPAVI "Stop AVI"
IDM_FILE_STOPWAV "Stop WAV"
IDM_FILE_RECORDAVI "Record AVI"
END
STRINGTABLE
STRINGTABLE
BEGIN
IDM_FILE_RECORDWAV "Record WAV"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_RAMSEARCH_CAPTIONTEXT " RAM Search"
ID_HOTKEYS_TITLE "Hotkey Configuration"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LABEL_HK1 "Open ROM"
ID_LABEL_HK2 "Reset"
@ -2110,12 +2112,12 @@ BEGIN
ID_LABEL_HK15 "Record AVI"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LABEL_HK8b "Limit Framerate Toggle"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LABEL_HK48 "Turbo A"
ID_LABEL_HK49 "Turbo Y"
@ -2135,7 +2137,7 @@ BEGIN
ID_LABEL_HK62 "Toggle Cursor"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LABEL_HK16 "Toggle Frame Display"
ID_LABEL_HK17 "Toggle FPS Display"
@ -2155,7 +2157,7 @@ BEGIN
ID_LABEL_HK31 "LCDs swap"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LABEL_HK32 "Increase Volume"
ID_LABEL_HK33 "Decrease Volume"
@ -2175,18 +2177,18 @@ BEGIN
ID_LABEL_HK47 "Turbo B"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LABEL_HK3b "CPU mode"
ID_LABEL_HK3c "Increase JIT block size"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LABEL_HK3d "Decrease JIT block size"
END
#endif // English (U.S.) resources
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -16,6 +16,7 @@
*/
#include "filter/filter.h"
#include "common.h"
class VideoInfo
{
@ -32,10 +33,31 @@ public:
int swap;
int currentfilter;
int prescaleHD;
int prescalePost; //not supported yet
int prescaleTotal;
u8* srcBuffer;
CACHE_ALIGN u32 buffer[5*5*256*192*2];
CACHE_ALIGN u32 filteredbuffer[5*5*256*192*2];
int srcBufferSize;
u32 *buffer;
u32 *filteredbuffer;
void SetPrescale(int prescaleHD, int prescalePost)
{
this->prescaleHD = prescaleHD;
this->prescalePost = prescalePost;
prescaleTotal = prescaleHD;
const int kInflationFactor = 5*5; //the largest filter is going up 5x in each dimension
int bufferSize = kInflationFactor * 256*192*2*prescaleHD * 4;
//why are these the same size, anyway?
buffer = (u32*)malloc_alignedCacheLine(bufferSize);
filteredbuffer = (u32*)malloc_alignedCacheLine(bufferSize);
setfilter(currentfilter);
}
enum {
NONE,
@ -75,6 +97,7 @@ public:
}
void reset() {
SetPrescale(1,1); //should i do this here?
width = 256;
height = 384;
}
@ -103,18 +126,18 @@ public:
case _5XBRZ:
width = 256*5;
height = 384*5;
break;
break;
case HQ4X:
case HQ4X:
case _4XBRZ:
width = 256*4;
height = 384*4;
break;
break;
case _3XBRZ:
width = 256*3;
height = 384*3;
break;
break;
case _2XBRZ:
default:
@ -122,6 +145,9 @@ public:
height = 384*2;
break;
}
width *= prescaleHD;
height *= prescaleHD;
}
SSurface src;
@ -136,9 +162,9 @@ public:
void filter() {
src.Height = 384;
src.Width = 256;
src.Pitch = 512;
src.Height = 384 * prescaleHD;
src.Width = 256 * prescaleHD;
src.Pitch = src.Width * 2;
src.Surface = (u8*)buffer;
dst.Height = height;
@ -285,6 +311,6 @@ public:
}
int scaledscreengap() {
return screengap * height / 384;
return screengap * height / (384 * prescaleHD);
}
};