Direct3D output for Windows SDL2 builds

This commit is contained in:
Wengier
2021-01-23 07:41:08 -05:00
parent 9b702e8309
commit 850bf561c4
8 changed files with 110 additions and 36 deletions

View File

@@ -1,7 +1,16 @@
0.83.10 0.83.10
- dynamic_x86 now handles pagefaults non-recursively, - The dynamic_x86 CPU core can now handle page faults
which allows to use dynamic core with Windows 9x/ME non-recursively, so you can now run the dynamic_x86
without crashes. (koolkdev) core with Windows 9x/ME without crashes, although
this may slightly decrease the performance, and it
may be disabled by setting the config option "use
dynamic core with paging on" in [cpu] section to
"false". Also fixed incorrect behavior for handling
trap flags in the dynamic core and updated the MMX
code for improved performance. (koolkdev)
- Added support for Direct3D output on Windows SDL2
builds just like Windows SDL1 builds to become the
default output in all Windows builds. (Wengier)
- DOSBox-X now natively supports the pixel-perfect - DOSBox-X now natively supports the pixel-perfect
scaling! Set the option "output=openglpp" in [sdl] scaling! Set the option "output=openglpp" in [sdl]
section of the config file to enable this output. section of the config file to enable this output.
@@ -11,10 +20,9 @@
with some code cleanups by Wengier. with some code cleanups by Wengier.
- Updated the Windows installer to add a page for - Updated the Windows installer to add a page for
new users to select a video system output - the new users to select a video system output - the
default output (Direct3D on SDL1 builds / standard default Direct3D output, OpenGL with pixel-perfect
OpenGL on x86/x64 SDL2 builds), OpenGL output with scaling (openglpp) for improved image quality, and
pixel-perfect scaling for improved image quality, the TrueType font (TTF) output. (Wengier)
and the TrueType font (TTF) output. (Wengier)
- You can now supply a ZIP/7Z file as a parameter to - You can now supply a ZIP/7Z file as a parameter to
DOSBox-X directly so that it will be mounted as C: DOSBox-X directly so that it will be mounted as C:
drive when DOSBox-X starts. (Wengier) drive when DOSBox-X starts. (Wengier)
@@ -103,8 +111,6 @@
- Fixed an issue that the DOSBox-X window size may be - Fixed an issue that the DOSBox-X window size may be
incorrect when restoring from a maximized window in incorrect when restoring from a maximized window in
the SDL2 builds. (Wengier) the SDL2 builds. (Wengier)
- Fixed incorrect behavior for handling trap flags
in the dynamic core. (koolkdev)
- Fixed that the menu option "Select OpenGL (GLSL) - Fixed that the menu option "Select OpenGL (GLSL)
shader.." not working properly sometimes. (Wengier) shader.." not working properly sometimes. (Wengier)
- Fixed Ctrl+C not working in GNU ed. (Wengier) - Fixed Ctrl+C not working in GNU ed. (Wengier)

View File

@@ -241,10 +241,10 @@ begin
else else
PageBuild.Values[4] := True; PageBuild.Values[4] := True;
CreateHelpButton(ScaleX(20), WizardForm.CancelButton.Top, WizardForm.CancelButton.Width, WizardForm.CancelButton.Height); CreateHelpButton(ScaleX(20), WizardForm.CancelButton.Top, WizardForm.CancelButton.Width, WizardForm.CancelButton.Height);
msg:='DOSBox-X supports different video output systems for different purposes.' #13#13 'By default it uses the Direct3D output on the SDL1 version and the standard OpenGL output on the SDL2 version. But you may want to select the OpenGL output with pixel-perfect scaling for improved image quality (not available if you had selected an ARM build). Also, if you use text-mode DOS applications you probably want to select the TrueType font (TTF) output to make the text screen look much better.' #13#13 'This setting can be later modified in the DOSBox-X''s configuration file (dosbox-x.conf), or from DOSBox-X''s Video menu.'; msg:='DOSBox-X supports different video output systems for different purposes.' #13#13 'By default it uses the Direct3D output, but you may want to select the OpenGL pixel-perfect scaling output for improved image quality (not available if you had selected an ARM build). Also, if you use text-mode DOS applications you probably want to select the TrueType font (TTF) output to make the text screen look much better.' #13#13 'This setting can be later modified in the DOSBox-X''s configuration file (dosbox-x.conf), or from DOSBox-X''s Video menu.';
PageOutput:=CreateInputOptionPage(100, 'Video output for DOSBox-X', 'Specify the DOSBox-X video output system', msg, True, False); PageOutput:=CreateInputOptionPage(100, 'Video output for DOSBox-X', 'Specify the DOSBox-X video output system', msg, True, False);
PageOutput.Add('Default output (SDL1: Direct3D / SDL2: OpenGL)'); PageOutput.Add('Default output (Direct3D)');
PageOutput.Add('OpenGL perfect: pixel-perfect scaling mode'); PageOutput.Add('OpenGL with pixel-perfect scaling');
PageOutput.Add('TrueType font output for text-mode applications'); PageOutput.Add('TrueType font output for text-mode applications');
PageOutput.Values[0] := True; PageOutput.Values[0] := True;
msg:='You can specify a default DOS version for DOSBox-X to report to itself and DOS programs. This can sometimes change the feature sets of DOSBox-X. For example, selecting 7.10 as the reported DOS version will enable support for Windows-style long filenames (LFN) and FAT32 disk images (>2GB disk images) by default.' #13#13 'If you are not sure about which DOS version to report, you can also leave this unselected, then a preset DOS version will be reported (usually 5.00).' #13#13 'This setting can be later modified in the DOSBox-X''s configuration file (dosbox-x.conf).'; msg:='You can specify a default DOS version for DOSBox-X to report to itself and DOS programs. This can sometimes change the feature sets of DOSBox-X. For example, selecting 7.10 as the reported DOS version will enable support for Windows-style long filenames (LFN) and FAT32 disk images (>2GB disk images) by default.' #13#13 'If you are not sure about which DOS version to report, you can also leave this unselected, then a preset DOS version will be reported (usually 5.00).' #13#13 'This setting can be later modified in the DOSBox-X''s configuration file (dosbox-x.conf).';
@@ -252,7 +252,7 @@ begin
PageVer.Add('DOS version 3.30'); PageVer.Add('DOS version 3.30');
PageVer.Add('DOS version 5.00'); PageVer.Add('DOS version 5.00');
PageVer.Add('DOS version 6.22'); PageVer.Add('DOS version 6.22');
PageVer.Add('DOS version 7.10'); PageVer.Add('DOS version 7.10 (for LFN and FAT32 support)');
end; end;
function NextButtonClick(CurPageID: Integer): Boolean; function NextButtonClick(CurPageID: Integer): Boolean;
begin begin
@@ -321,9 +321,9 @@ begin
begin begin
Wizardform.ReadyMemo.Lines.Add(''); Wizardform.ReadyMemo.Lines.Add('');
Wizardform.ReadyMemo.Lines.Add('Video output for DOSBox-X:'); Wizardform.ReadyMemo.Lines.Add('Video output for DOSBox-X:');
msg:='Default output (SDL1: Direct3D / SDL2: OpenGL)'; msg:='Default output (Direct3D)';
if (PageOutput.Values[1]) then if (PageOutput.Values[1]) then
msg:='OpenGL perfect: pixel-perfect scaling mode'; msg:='OpenGL with pixel-perfect scaling';
if (PageOutput.Values[2]) then if (PageOutput.Values[2]) then
msg:='TrueType font output for text-mode applications'; msg:='TrueType font output for text-mode applications';
Wizardform.ReadyMemo.Lines.Add(' '+msg); Wizardform.ReadyMemo.Lines.Add(' '+msg);

View File

@@ -16,7 +16,7 @@ At the beginning you have got a Z:\> instead of a C:\> at the DOSBox-X prompt. S
To change to the drive mounted like above, type "C:". If everything went fine, DOSBox-X will display the prompt "C:\>". You do not have to manually mount drives after DOSBox-X starts. Click the "Main" menu, and select "Configuration tool". Then select the "AUTOEXEC.BAT" setting group, where you can change its contents. The commands present here are run when DOSBox-X starts, so you can use this section for the mounting and other purposes, such as launching a specific program you want to use, or a game you want to play. You can also quickly launch a DOS program or game in DOSBox-X by clicking "Quick launch program..." under "DOS" menu. To change to the drive mounted like above, type "C:". If everything went fine, DOSBox-X will display the prompt "C:\>". You do not have to manually mount drives after DOSBox-X starts. Click the "Main" menu, and select "Configuration tool". Then select the "AUTOEXEC.BAT" setting group, where you can change its contents. The commands present here are run when DOSBox-X starts, so you can use this section for the mounting and other purposes, such as launching a specific program you want to use, or a game you want to play. You can also quickly launch a DOS program or game in DOSBox-X by clicking "Quick launch program..." under "DOS" menu.
Hint: DOSBox-X supports different video output systems for different purposes. By default it uses the Direct3D output on the SDL1 version and the standard OpenGL output on the SDL2 version. But if you desire the pixel-perfect scaling feature for improved image quality you may want to select the openglpp output. Also, if you use text-mode DOS applications you probably want to select the TrueType font (TTF) output to make the text screen look much better. Hint: DOSBox-X supports different video output systems for different purposes. By default it uses the Direct3D output, but if you desire the pixel-perfect scaling feature for improved image quality you may want to select the openglpp output ("OpenGL perfect"). Also, if you use text-mode DOS applications and/or the DOS shell a lot you probably want to select the TrueType font (TTF) output to make the text screen look much better.
Further Information Further Information
=================== ===================

View File

@@ -317,10 +317,8 @@ static const char *def_menu_video_scaler[] =
static const char *def_menu_video_output[] = static const char *def_menu_video_output[] =
{ {
"output_surface", "output_surface",
#if !defined(C_SDL2) && !defined(HX_DOS) #if (HAVE_D3D9_H) && defined(WIN32) && !defined(HX_DOS)
# if (HAVE_D3D9_H) && defined(WIN32)
"output_direct3d", "output_direct3d",
# endif
#endif #endif
#if defined(C_OPENGL) && !defined(HX_DOS) #if defined(C_OPENGL) && !defined(HX_DOS)
"output_opengl", "output_opengl",

View File

@@ -250,6 +250,9 @@ bool osx_detect_nstouchbar(void);
void osx_init_touchbar(void); void osx_init_touchbar(void);
#endif #endif
#if C_DIRECT3D
void d3d_init(void);
#endif
bool TTF_using(void); bool TTF_using(void);
void ShutDownMemHandles(Section * sec); void ShutDownMemHandles(Section * sec);
void resetFontSize(), decreaseFontSize(); void resetFontSize(), decreaseFontSize();
@@ -3710,9 +3713,10 @@ void change_output(int output) {
OUTPUT_OPENGL_Select(GLPerfect); OUTPUT_OPENGL_Select(GLPerfect);
#endif #endif
break; break;
#if C_DIRECT3D #if C_DIRECT3D
case 6: case 6:
OUTPUT_DIRECT3D_Select(); OUTPUT_DIRECT3D_Select();
d3d_init();
break; break;
#endif #endif
case 7: case 7:
@@ -3722,8 +3726,10 @@ void change_output(int output) {
break; break;
case 9: case 9:
#if C_DIRECT3D #if C_DIRECT3D
if (sdl.desktop.want_type == SCREEN_DIRECT3D) if (sdl.desktop.want_type == SCREEN_DIRECT3D) {
OUTPUT_DIRECT3D_Select(); OUTPUT_DIRECT3D_Select();
d3d_init();
}
#endif #endif
break; break;
#if defined(USE_TTF) #if defined(USE_TTF)
@@ -4081,7 +4087,6 @@ void GFX_RestoreMode(void) {
GFX_ResetScreen(); GFX_ResetScreen();
} }
#if !defined(C_SDL2)
static bool GFX_GetSurfacePtrLock = false; static bool GFX_GetSurfacePtrLock = false;
unsigned char *GFX_GetSurfacePtr(size_t *pitch, unsigned int x, unsigned int y) { unsigned char *GFX_GetSurfacePtr(size_t *pitch, unsigned int x, unsigned int y) {
@@ -4113,7 +4118,6 @@ void GFX_ReleaseSurfacePtr(void) {
GFX_GetSurfacePtrLock = false; GFX_GetSurfacePtrLock = false;
} }
} }
#endif
bool GFX_StartUpdate(uint8_t* &pixels,Bitu &pitch) bool GFX_StartUpdate(uint8_t* &pixels,Bitu &pitch)
{ {
@@ -5355,6 +5359,10 @@ static void GUI_StartUp() {
GFX_LogSDLState(); GFX_LogSDLState();
GFX_Stop(); GFX_Stop();
#if C_DIRECT3D
if (sdl.desktop.want_type == SCREEN_DIRECT3D)
d3d_init();
#endif
#if defined(C_SDL2) #if defined(C_SDL2)
SDL_SetWindowTitle(sdl.window,"DOSBox-X"); SDL_SetWindowTitle(sdl.window,"DOSBox-X");
@@ -10136,31 +10144,68 @@ bool output_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const menui
if (!strcmp(what,"surface")) { if (!strcmp(what,"surface")) {
if (sdl.desktop.want_type == SCREEN_SURFACE) return true; if (sdl.desktop.want_type == SCREEN_SURFACE) return true;
change_output(0); if (window_was_maximized&&!GFX_IsFullscreen()) {
change_output(5);
#if defined(WIN32)
ShowWindow(GetHWND(), SW_MAXIMIZE);
#endif
} else
change_output(0);
RENDER_Reset(); RENDER_Reset();
} }
else if (!strcmp(what,"opengl")) { else if (!strcmp(what,"opengl")) {
#if C_OPENGL #if C_OPENGL
if (sdl.desktop.want_type == SCREEN_OPENGL && sdl_opengl.kind == GLBilinear) return true; if (sdl.desktop.want_type == SCREEN_OPENGL && sdl_opengl.kind == GLBilinear) return true;
change_output(3); if (window_was_maximized&&!GFX_IsFullscreen()) {
change_output(3);
#if defined(WIN32)
ShowWindow(GetHWND(), SW_MAXIMIZE);
#endif
} else
change_output(3);
#endif #endif
} }
else if (!strcmp(what,"openglnb")) { else if (!strcmp(what,"openglnb")) {
#if C_OPENGL #if C_OPENGL
if (sdl.desktop.want_type == SCREEN_OPENGL && sdl_opengl.kind == GLNearest) return true; if (sdl.desktop.want_type == SCREEN_OPENGL && sdl_opengl.kind == GLNearest) return true;
change_output(4); if (window_was_maximized&&!GFX_IsFullscreen()) {
change_output(4);
#if defined(WIN32)
ShowWindow(GetHWND(), SW_MAXIMIZE);
#endif
} else
change_output(4);
#endif #endif
} }
else if (!strcmp(what,"openglpp")) { else if (!strcmp(what,"openglpp")) {
#if C_OPENGL #if C_OPENGL
if (sdl.desktop.want_type == SCREEN_OPENGL && sdl_opengl.kind == GLPerfect) return true; if (sdl.desktop.want_type == SCREEN_OPENGL && sdl_opengl.kind == GLPerfect) return true;
change_output(5); if (window_was_maximized&&!GFX_IsFullscreen()) {
change_output(5);
#if defined(WIN32)
ShowWindow(GetHWND(), SW_MAXIMIZE);
#endif
} else
change_output(5);
#endif #endif
} }
else if (!strcmp(what,"direct3d")) { else if (!strcmp(what,"direct3d")) {
#if C_DIRECT3D #if C_DIRECT3D
if (sdl.desktop.want_type == SCREEN_DIRECT3D) return true; if (sdl.desktop.want_type == SCREEN_DIRECT3D) return true;
change_output(6); #if C_OPENGL && defined(C_SDL2)
if (sdl.desktop.want_type == SCREEN_OPENGL) {
sdl.desktop.isperfect = false;
OUTPUT_SURFACE_Select();
RENDER_Reset();
}
#endif
if (window_was_maximized&&!GFX_IsFullscreen()) {
change_output(6);
#if defined(WIN32)
ShowWindow(GetHWND(), SW_MAXIMIZE);
#endif
} else
change_output(6);
#endif #endif
} }
else if (!strcmp(what,"ttf")) { else if (!strcmp(what,"ttf")) {

View File

@@ -123,7 +123,11 @@ HRESULT CDirect3D::InitializeDX(HWND wnd, bool triplebuf)
thread_run = true; thread_run = true;
thread_command = D3D_IDLE; thread_command = D3D_IDLE;
#if defined(C_SDL2)
thread = SDL_CreateThread(EntryPoint, "Direct3D", this);
#else
thread = SDL_CreateThread(EntryPoint, this); thread = SDL_CreateThread(EntryPoint, this);
#endif
SDL_SemWait(thread_ack); SDL_SemWait(thread_ack);
#endif #endif

View File

@@ -13,7 +13,7 @@ using namespace std;
CDirect3D* d3d = NULL; CDirect3D* d3d = NULL;
void ResolvePath(std::string& in); void ResolvePath(std::string& in);
static void d3d_init(void) void d3d_init(void)
{ {
sdl.desktop.want_type = SCREEN_DIRECT3D; sdl.desktop.want_type = SCREEN_DIRECT3D;
if (!sdl.using_windib) if (!sdl.using_windib)
@@ -30,7 +30,11 @@ static void d3d_init(void)
SDL_SysWMinfo wmi; SDL_SysWMinfo wmi;
SDL_VERSION(&wmi.version); SDL_VERSION(&wmi.version);
if (!SDL_GetWMInfo(&wmi)) #if defined(C_SDL2)
if (!SDL_GetWindowWMInfo(sdl.window, &wmi))
#else
if (!SDL_GetWMInfo(&wmi))
#endif
{ {
LOG_MSG("SDL:Error retrieving window information"); LOG_MSG("SDL:Error retrieving window information");
LOG_MSG("Failed to get window info"); LOG_MSG("Failed to get window info");
@@ -50,7 +54,11 @@ static void d3d_init(void)
OUTPUT_SURFACE_Select(); OUTPUT_SURFACE_Select();
return; return;
} }
else if (d3d->InitializeDX(wmi.child_window, sdl.desktop.doublebuf) != S_OK) #if defined(C_SDL2)
else if (d3d->InitializeDX(wmi.info.win.window, sdl.desktop.doublebuf) != S_OK)
#else
else if (d3d->InitializeDX(wmi.child_window, sdl.desktop.doublebuf) != S_OK)
#endif
{ {
LOG_MSG("Unable to initialize DirectX"); LOG_MSG("Unable to initialize DirectX");
OUTPUT_SURFACE_Select(); OUTPUT_SURFACE_Select();
@@ -83,7 +91,6 @@ void OUTPUT_DIRECT3D_Select()
{ {
sdl.desktop.want_type = SCREEN_DIRECT3D; sdl.desktop.want_type = SCREEN_DIRECT3D;
render.aspectOffload = true; render.aspectOffload = true;
d3d_init();
#if defined(WIN32) && !defined(C_SDL2) #if defined(WIN32) && !defined(C_SDL2)
SDL1_hax_inhibit_WM_PAINT = 1; SDL1_hax_inhibit_WM_PAINT = 1;
@@ -232,18 +239,35 @@ Bitu OUTPUT_DIRECT3D_SetSize()
// Create a dummy sdl surface // Create a dummy sdl surface
// D3D will hang or crash when using fullscreen with ddraw surface, therefore we hack SDL to provide // D3D will hang or crash when using fullscreen with ddraw surface, therefore we hack SDL to provide
// a GDI window with an additional 0x40 flag. If this fails or stock SDL is used, use WINDIB output // a GDI window with an additional 0x40 flag. If this fails or stock SDL is used, use WINDIB output
void GFX_SetResizeable(bool enable);
if (GCC_UNLIKELY(d3d->bpp16)) if (GCC_UNLIKELY(d3d->bpp16))
{ {
#if defined(C_SDL2)
GFX_SetResizeable(true);
sdl.window = GFX_SetSDLWindowMode(windowWidth, windowHeight, SCREEN_SURFACE);
if (sdl.window != NULL) sdl.surface = SDL_GetWindowSurface(sdl.window);
else sdl.surface = NULL;
sdl.desktop.pixelFormat = SDL_GetWindowPixelFormat(sdl.window);
#else
sdl.surface = SDL_SetVideoMode(windowWidth, windowHeight, 16, sdl.desktop.fullscreen ? SDL_FULLSCREEN | 0x40 : SDL_RESIZABLE | 0x40); sdl.surface = SDL_SetVideoMode(windowWidth, windowHeight, 16, sdl.desktop.fullscreen ? SDL_FULLSCREEN | 0x40 : SDL_RESIZABLE | 0x40);
sdl.deferred_resize = false; sdl.deferred_resize = false;
sdl.must_redraw_all = true; sdl.must_redraw_all = true;
#endif
retFlags = GFX_CAN_16 | GFX_SCALING; retFlags = GFX_CAN_16 | GFX_SCALING;
} }
else else
{ {
#if defined(C_SDL2)
GFX_SetResizeable(true);
sdl.window = GFX_SetSDLWindowMode(windowWidth, windowHeight, SCREEN_SURFACE);
if (sdl.window != NULL) sdl.surface = SDL_GetWindowSurface(sdl.window);
else sdl.surface = NULL;
sdl.desktop.pixelFormat = SDL_GetWindowPixelFormat(sdl.window);
#else
sdl.surface = SDL_SetVideoMode(windowWidth, windowHeight, 0, sdl.desktop.fullscreen ? SDL_FULLSCREEN | 0x40 : SDL_RESIZABLE | 0x40); sdl.surface = SDL_SetVideoMode(windowWidth, windowHeight, 0, sdl.desktop.fullscreen ? SDL_FULLSCREEN | 0x40 : SDL_RESIZABLE | 0x40);
sdl.deferred_resize = false; sdl.deferred_resize = false;
sdl.must_redraw_all = true; sdl.must_redraw_all = true;
#endif
retFlags = GFX_CAN_32 | GFX_SCALING; retFlags = GFX_CAN_32 | GFX_SCALING;
} }

View File

@@ -49,16 +49,13 @@
#define C_SDL_NET 1 #define C_SDL_NET 1
/* Define to 1 if you have the <d3d9.h> header file. */ /* Define to 1 if you have the <d3d9.h> header file. */
#if !defined(C_SDL2)
#define HAVE_D3D9_H 1 #define HAVE_D3D9_H 1
#endif
#if HAVE_D3D9_H
/* Define to 1 if you want to add Direct3D output to the list of available outputs */ /* Define to 1 if you want to add Direct3D output to the list of available outputs */
#define C_DIRECT3D 1 #define C_DIRECT3D 1
/* Define to 1 to use Direct3D shaders, requires d3d9.h and libd3dx9 */ /* Define to 1 to use Direct3D shaders, requires d3d9.h and libd3dx9 */
#define C_D3DSHADERS 1 #define C_D3DSHADERS 1
#endif
/* MT32 (munt) emulation */ /* MT32 (munt) emulation */
#define C_MT32 1 #define C_MT32 1