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);
@ -3265,6 +3288,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
@ -1831,7 +1833,7 @@ BEGIN
IDD_3DSETTINGS, DIALOG
BEGIN
BOTTOMMARGIN, 248
BOTTOMMARGIN, 201
END
IDD_CHEAT_ADD, DIALOG
@ -2186,7 +2188,7 @@ 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;
}
@ -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);
}
};