My DosBox fork. OpenGL 3 GLSL shaders, FluidSynth (SDL2)

Here you can discuss the development of patches.

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby dugan » 2017-3-06 @ 06:14

Here is the shader support as a numbered series of patches. Apply them in order against r4006.

The first patch ports DosBox to SDL2. It is the exact same patch I just posted in the SDL2 thread:

viewtopic.php?f=32&t=34770&start=80#p568128

The second patch ports DosBox's OpenGL output backend to OpenGL 3.3. Core profile.

One thing you might want to note about the OpenGL 3 patch that it drops PBO (Pixel Buffer Object) support. The reason is that DosBox's PBO's don't work properly; they're the cause of a screen corruption bug. Also, I simply can't imagine an OpenGL 3.3-supporting setup where dropping this optimization is going to make a difference. If you're incorporating this patch into your own fork, and you want them, you can easily add them back; you can probably find a working PBO-enabled version in my git history.

Another thing you might want to note about the OpenGL 3 patch is that it uses GLEW. I include GLEW (including its license file) right in the codebase. As far as I know, this isn't a problem.

The third patch adds support for loadable, external shaders. The shader format is of my own design, and the goals were: a) use OpenGL 3.3, and b) make RetroArch shaders easy to port. The uniforms (values passed from the CPU to the GPU) are passed to the shader in the following format:

Code: Select all
layout (std140) uniform program
{
   vec2 video_size;
   vec2 texture_size;
   vec2 output_size;
} IN;


If you're porting a bsnes shader, see here for how to match bsnes uniform names to DosBox (and RetroArch) uniform names:

https://forums.libretro.com/t/cg-vs-gls ... help/400/2

Here is a repository of compatible shaders that I've made available:

https://github.com/duganchen/dosbox_shaders

The fourth patch gets fullscreen working retina Macs. You should only apply this one if you actually intend to run it on a retina Mac and you find that you actually need it. What it does is documented here:

viewtopic.php?f=32&t=34770&start=80#p567484
You do not have the required permissions to view the files attached to this post.
dugan
Newbie
 
Posts: 46
Joined: 2015-4-04 @ 03:17

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Ant_222 » 2017-4-02 @ 14:47

Would you consider implementing pixel-perfect scaling in your SDL2 fork via the
SDL_RenderSetScale() function and the SDL_HINT_RENDER_SCALE_QUALITY set to 0 (nearest). You may take the scale-calculation routine from my patch:
Code: Select all
get_perfect_scale()
in src\gui\pixelscale.cpp
and let SDL2 do the rest. The only problem will be to bypass the standard scaling and aspect correction. This version should work much faster than mine, and with any output supported by SDL2.

Edit: Furthermore, all the standard modes of scaling and aspect-ratio correction may be delegated to SDL_RenderSetScale() and the scale quality hint.
Ant_222
Member
 
Posts: 375
Joined: 2010-7-24 @ 21:29

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby dugan » 2017-4-07 @ 01:49

Would you be open to to adding it yourself, and then submitting either a patch to Vogons or a pull request to my GitHub?
dugan
Newbie
 
Posts: 46
Joined: 2015-4-04 @ 03:17

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Ant_222 » 2017-4-07 @ 08:44

Yes, I can try, but not now. I shall ask you how to access the repository when I am ready.
Ant_222
Member
 
Posts: 375
Joined: 2010-7-24 @ 21:29

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Dominus » 2017-4-07 @ 09:26

You can just clone it from github and send a pull request once you are done
User avatar
Dominus
DOSBox Moderator
 
Posts: 7644
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Ant_222 » 2017-4-07 @ 09:34

I have never used neither Git nor Github, so I don't know what clone or pull request mean. When I have time, I shall ask for help.
Ant_222
Member
 
Posts: 375
Joined: 2010-7-24 @ 21:29

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Dominus » 2017-4-07 @ 10:16

It's pretty easy if you used any othe versioning system. Clone is just the term git uses and pull requests are well explained on github. Of course grabbing the source via git, changing stuff and then let git make diff/patch is easy as well. Pull requests are just easier for the project maintainer.
User avatar
Dominus
DOSBox Moderator
 
Posts: 7644
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby dugan » 2017-4-07 @ 18:38

If you're not familiar with git, I'd be happy with a patch that one can just apply after the first four.
dugan
Newbie
 
Posts: 46
Joined: 2015-4-04 @ 03:17

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Ant_222 » 2017-4-07 @ 20:12

I am not very comfortable with Unix and makefiles either, and had to follow these instructions to the letter in order to setup a working build environment on Windows in MinGW. Will those work for your fork, with the exception that I shall need to download and install SDL2 SDK?

If git can work from MinGW I will use it, but now I shall just download the patch, apply them to the source and see what is to be done.
Ant_222
Member
 
Posts: 375
Joined: 2010-7-24 @ 21:29

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Ant_222 » 2017-4-07 @ 20:15

dugan wrote:The fourth patch gets fullscreen working retina Macs. You should only apply this one if you actually intend to run it on a retina Mac and you find that you actually need it.
Does it have any harmful effects?
Ant_222
Member
 
Posts: 375
Joined: 2010-7-24 @ 21:29

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Ant_222 » 2017-4-07 @ 20:33

Notice that the second patch does not work with revision 4007. I am testing it with 4006 now.
Ant_222
Member
 
Posts: 375
Joined: 2010-7-24 @ 21:29

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby dugan » 2017-4-07 @ 21:59

Ant_222 wrote:
dugan wrote:The fourth patch gets fullscreen working retina Macs. You should only apply this one if you actually intend to run it on a retina Mac and you find that you actually need it.
Does it have any harmful effects?


Yes. It's been reported that it causes issues if you have two monitors.

viewtopic.php?f=32&t=34770&start=100#p571733
dugan
Newbie
 
Posts: 46
Joined: 2015-4-04 @ 03:17

Re: My DosBox fork. SDL2, OpenGL 3 GLSL shaders, FluidSynth

Postby Dominus » 2017-4-07 @ 22:17

But on Windows it will not have any effect at all ;)
User avatar
Dominus
DOSBox Moderator
 
Posts: 7644
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Force frame refresh with OpenGL for dugan's dosbox - Steam overlay fix

Postby _MagicMyth_ » 2017-9-30 @ 09:34

Hi all,

I would post a new topic for this but I'm either thick or new members cannot post a new topic in this forum section.

I wanted to get DOS games running well on Steam Linux and with the Steam Link but as has become known DOS games don't work well with the Steam overlay due to how frames are only rendered when something changes. On Windows this is worked around with DosBox builds supporting DirextX pixel shaders that force the frames to sync with the display. Unfortunately no such feature is available for the OpenGL output. As I soon found dugan's SDL2 fork was working best for me (much more reliable screen resolution handling) I decided to write a patch to solve this with my very limited C++ skills. I think its kind of hackish but it works well for me. You can find the branch over at:

https://github.com/magicmyth/dosbox/tree/force-frame-update

This patch adds a new configuration option to the render section: forceframeupdate. When set to true this will set a default minimal frame refresh rate. Only when the last frame render was below this minimum will a frame re-draw be forced. You can also set your own desired minimum refresh by setting it to a numeric value in milliseconds (e.g. 50 for roughly 20fps). The default is conservative (10fps) to be just good enough for a hooked in render overlay to work. Its disabled by default ("false") so make sure to add that config option.

The minimum config setup for this to work then is:
Code: Select all
fullresolution=desktop
output=openglnb
...

[render]
# Force minimum regular frame updates to fix overlay.
forceframeupdate=true


Combine this with dugan's shader support and you have a great streaming experience to your lounge's big screen :cool:

I've uploaded a build for Ubuntu 16.04 64bit (may work with later releases as well) to:
https://drive.google.com/open?id=0B4dD2fOx1XJyWUhBU2FZRWlVUDA

You'll need a few dependantcies installed so in the terminal just run:
Code: Select all
sudo apt install libsdl2-2.0-0 libsdl2-net-2.0-0 libfluidsynth1


There is a known issue with the build if you don't use fluidsynth. It takes a few extra seconds to start as for some reason it probes for Jack. It only takes a few seconds though or you can simply follow dugan's instruction and hook it into fluidsynth with a soundfont which bypasses the issue.

I've only tested a few games and I'm really interested to find out how well it works for others. It should work on Mac's but I've not tested that myself.
_MagicMyth_
Newbie
 
Posts: 1
Joined: 2017-9-30 @ 08:45

Re: My DosBox fork. OpenGL 3 GLSL shaders, FluidSynth (SDL2)

Postby Marty2dos » 2017-10-31 @ 04:19

Hello dugan,
I could succesfully build a Dosbox Fork from your Repository for Windows (using msys/mingw 32bit on Windows 7) but the sound doesnt work. Only "General Midi". No Soundblaster. No GUs etc. I hear only crackled Sound ?
If i capture to waveout, there is Sound.

Image


Edit: Sound Works, SDL2.dll mismatch ..... :blah:

Compiling with SDL2 v2.0.6+ the sound is cracled. With SDL2 2.0.4, sound works normal.
You do not have the required permissions to view the files attached to this post.
Last edited by Marty2dos on 2017-11-01 @ 06:35, edited 1 time in total.
Marty2dos
Newbie
 
Posts: 32
Joined: 2013-6-04 @ 01:43


Re: My DosBox fork. OpenGL 3 GLSL shaders, FluidSynth (SDL2)

Postby Marty2dos » 2017-10-31 @ 10:07

DosFreak wrote:I hear that 2.0.6 has sound issues. Try 2.0.7

Yes i tried, 2.0.7 the same bad sound result.
Marty2dos
Newbie
 
Posts: 32
Joined: 2013-6-04 @ 01:43

Re: My DosBox fork. OpenGL 3 GLSL shaders, FluidSynth (SDL2)

Postby Marty2dos » 2017-10-31 @ 19:27

No idea how can i static link the Fluidsynth Depends. I have tried 2 Days. No Chance. If it fully static linked. Dosbox Say's:

Code: Select all
fluidsynth: error: FluidSynth hinstance not set, which is needed for DirectSound
Failed to create the audio driver


and can not load Soundfonts etc.... If it not static linked, also shared then it works with all the dlls. Damned.....
Marty2dos
Newbie
 
Posts: 32
Joined: 2013-6-04 @ 01:43

Re: My DosBox fork. OpenGL 3 GLSL shaders, FluidSynth (SDL2)

Postby Marty2dos » 2017-11-04 @ 06:08

First.. I have figured out.Second i not very familar with Mingw and c++. This was a hell. But the compild fluidsynth.exe in mingw/bin folder works too and now i can compie Dosbox as single exe (fully static linked)

Source File Chnages:
In the fluidsynth\include\fluidsynth.
Code: Select all
#if defined(WIN32)
#if defined(FLUIDSYNTH_DLL_EXPORTS)
#define FLUIDSYNTH_API __declspec(dllexport)
#elif defined(FLUIDSYNTH_NOT_A_DLL)
#define FLUIDSYNTH_API
#else
#define FLUIDSYNTH_API __declspec(dllimport)
#endif


to
Code: Select all
#if defined(WIN32)
#define FLUIDSYNTH_API

This tip comes from ScummVM

In the fluidsynth\src\drivers\fluid_dsound.c
Code: Select all
  /* check if the globals are initialized */
  if (FLUID_HINSTANCE == NULL) {
    FLUID_LOG(FLUID_ERR, "FluidSynth hinstance not set, which is needed for DirectSound");
    return NULL;
  }

/*
  if (fluid_wnd == NULL) {
    if (fluid_win32_create_window() != 0) {
      FLUID_LOG(FLUID_ERR, "Couldn't create window needed for DirectSound");
      return NULL;
    }
  }
*/


to
Code: Select all
  /* check if the globals are initialized */
  // if (FLUID_HINSTANCE == NULL) {
    // FLUID_LOG(FLUID_ERR, "FluidSynth hinstance not set, which is needed for DirectSound");
    // return NULL;
  // }


  if (FLUID_HINSTANCE == NULL) {
    if (fluid_win32_create_window() != 0) {
      FLUID_LOG(FLUID_ERR, "Couldn't create window needed for DirectSound");
      return NULL;
    }
  }


in the mingw32\lib\pkgconfig\fluidsynth.pc
Code: Select all
[code]prefix=D:/System_Development/Msys32Bit_ScummVm_Dosbox/mingw32
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include[/code]

Name: FluidSynth
Description: Software SoundFont synth
Version: 1.1.8
Libs: -L${libdir} -lfluidsynth
Cflags: -I${includedir}


to
Code: Select all
prefix=D:/System_Development/Msys32Bit_ScummVm_Dosbox/mingw32
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: FluidSynth
Description: Software SoundFont synth
Version: 1.1.8
Libs: -L${libdir} -lfluidsynth -lreadline -lncurses -L/mingw32/lib -lportaudio -ldsound -lsetupapi -luuid -lgthread-2.0 -lglib-2.0 -lws2_32 -lole32 -lwinmm -lshlwapi -lintl -lpcre -lsndfile -lFLAC -logg -lvorbis -lvorbisenc -lspeex -lpthread
Cflags: -I${includedir}


My cmake argument
Code: Select all
$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -G"MSYS Makefiles" -Dincludedir=$MINGW_PREFIX/include -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX -DBUILD_SHARED_LIBS=off -DLIB_SUFFIX= .
make -j4 && make install


SDL2 Static. In the bin\sdl2-config
Code: Select all
    --libs)
      echo -L${exec_prefix}/lib  -lmingw32
      ;;
    --static-libs)


to
Code: Select all
    --libs)
      echo -L${exec_prefix}/lib  -lmingw32 -lglew32 -lSDL2_net -lSDL2main -lSDL2  -mwindows  -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -static-libgcc  -liphlpapi
      ;;
    --static-libs)

I added the needed glew32.dll as "-lglew32" and "-lSDL2_net" before -lSDL2main and " -liphlpapi" at the end

In the Dosbox configure.ac
Code: Select all
AH_TEMPLATE(C_FLUIDSYNTH,[Define to 1 to enable fluidsynth MIDI synthesis])
AC_CHECK_HEADER(fluidsynth.h,have_fluidsynth_h=yes,)
AC_CHECK_LIB(fluidsynth, new_fluid_synth, have_fluidsynth_lib=yes,,)
if test x$have_fluidsynth_lib = xyes -a x$have_fluidsynth_h = xyes ; then
  LIBS="$LIBS -lfluidsynth"
  AC_DEFINE(C_FLUIDSYNTH,1)
else
  AC_MSG_WARN([fluidsynth MIDI synthesis not available])
fi


to
Code: Select all
AH_TEMPLATE(C_FLUIDSYNTH,[Define to 1 to enable fluidsynth MIDI synthesis])
#AC_CHECK_HEADER(fluidsynth.h,have_fluidsynth_h=yes,)
#AC_CHECK_LIB(fluidsynth, new_fluid_synth, have_fluidsynth_lib=yes,,)
#if test x$have_fluidsynth_lib = xyes -a x$have_fluidsynth_h = xyes ; then
  LIBS="$LIBS -lfluidsynth -lreadline -lncurses -L/mingw32/lib -lportaudio -ldsound -lsetupapi -luuid -lgthread-2.0 -lglib-2.0 -lws2_32 -lole32 -lwinmm -lshlwapi -lintl -lpcre -lsndfile -lFLAC -logg -lvorbis -lvorbisenc -lspeex -lpthread -liconv"
  AC_DEFINE(C_FLUIDSYNTH,1)
#else
#  AC_MSG_WARN([fluidsynth MIDI synthesis not available])
#fi

I comment out the checks. With the command "-static" via configure. This test is always negative.. no idea ...

For libsdl2_net to avoid a "undefined reference to `GetAdaptersInfo@8". I have copied from \mingw32\i686-w64-mingw32\lib\libiphlpapi.a to \mingw32\lib\
Code: Select all
#if test x$have_sdl_net_lib = xyes -a x$have_sdl_net_h = xyes ; then
  #LIBS="$LIBS -l${LIBSDL_HEADER}_net"
   AC_DEFINE(C_MODEM,1)
   AC_DEFINE(C_IPX,1)
#else
#   AC_MSG_WARN([Can't find ${LIBSDL_HEADER}_net, internal modem and ipx disabled])
#fi

I comment the five lines out.

My Build command
Code: Select all
./configure --disable-debug --enable-core-inline --prefix=$MINGW_PREFIX CFLAGS="" LDFLAGS="-static -s" LIBS="" CXXFLAGS="-m32 -O3 -fomit-frame-pointer -march=i586 -mtune=i686 -fexpensive-optimizations"


Voila.. i can compile Dosbox as a single exe. All stuff is linked.

Edit: sdl2_net linkes in Dosbox exe. Adding a new Private Windows build Version to this thread to show what i mean.
And .. i would say
My thanks go to the DOSBox Team, dungan (for this Fork from Dosbox, i love the shader), nukeykt (Nuked OPL3 emulator), VileRancour (CGA w/ Monochrome Monitor Support), D_Skywalk (Multi-Floppy-Images), Michał Kępień (Volume Up/Down hotkeys ), TaeWoong Yoo (Various Patches), `Moe` (Speed Meter), Vasyl Tsvirkunov (Innovation SSI-2001 emulation ), kekko (3dfx voodoo emulation)
Marty2dos
Newbie
 
Posts: 32
Joined: 2013-6-04 @ 01:43

Re: My DosBox fork. OpenGL 3 GLSL shaders, FluidSynth (SDL2)

Postby Marty2dos » 2017-11-19 @ 21:36

This Dosbox Fork and the modified Source for windows is now on my blog. I hope its OK? I did not want to write all the changes again.

DOSBox SVN r4063 (Optionals) Build on (Nov 18 2017 02:40:08)
Features Compiled:
32Bit DynamicX68 FpuCoreX68 OpenGL3 3DFX CGA-Extension PNG Fluidsynth MT32 SSI2001
M.A.M.E.-Sound Nuked-OPL3 DirectSerial IPX Modem
https://aeronextedit.wordpress.com/dosboxscummvm-ports/

greetings Marty

And thanks to the DOSBox Team, dungan (for this Fork from Dosbox, i love the shader), nukeykt (Nuked OPL3 emulator), VileRancour (CGA w/ Monochrome Monitor Support), D_Skywalk (Multi-Floppy-Images), Michał Kępień (Volume Up/Down hotkeys ), TaeWoong Yoo (Various Patches), `Moe` (Speed Meter), Vasyl Tsvirkunov (Innovation SSI-2001 emulation ), kekko (3dfx voodoo emulation).
Marty2dos
Newbie
 
Posts: 32
Joined: 2013-6-04 @ 01:43

PreviousNext

Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 0 guests