VIDEO Patch for pixel-perfect scaling (SDL1)

Here you can discuss the development of patches.

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby pantercat » 2018-9-23 @ 17:14

It works!!

I've downloaded dosbox svn r4163, I've applied the last pixel-perfect patch [2018-09-22] Alpha 14 and I've compiled dosbox with

patch -p0 <pixel-perfect-alpha14-4163.patch && cd src && ./autogen.sh && ./configure && make

Now I can run dosbox with surfacepp :) Thank you
pantercat
Newbie
 
Posts: 7
Joined: 2018-9-06 @ 17:22

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby Ant_222 » 2018-9-23 @ 21:00

pantercat wrote:It works!!

I've downloaded dosbox svn r4163, I've applied the last pixel-perfect patch [2018-09-22] Alpha 14 and I've compiled dosbox with

patch -p0 <pixel-perfect-alpha14-4163.patch && cd src && ./autogen.sh && ./configure && make

Now I can run dosbox with surfacepp :) Thank you
I am glad it does, but we should thank aaronp for finding the bug and blame myself for introducing it :-)
Ant_222
Member
 
Posts: 377
Joined: 2010-7-24 @ 21:29

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby Yesterplay80 » 2018-9-25 @ 06:42

A new ECE build including the fixed patch is available as well, please check if it now works as it should.
My full-featured DOSBox SVN builds (without debugger) for Windows: Vanilla DOSBox and DOSBox ECE (Enhanced Community Edition)
User avatar
Yesterplay80
Member
 
Posts: 361
Joined: 2016-2-23 @ 11:02
Location: Germany

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby pantercat » 2018-9-25 @ 21:33

I've compiled ECE r4163 (Linux source) and it works for me. Thank you all!
pantercat
Newbie
 
Posts: 7
Joined: 2018-9-06 @ 17:22

Re: Patch for pixel-perfect scaling

Postby unther » 2018-11-13 @ 17:18

Ant_222 wrote:
unther wrote:Ant, would you expect your 5x5y algorithm to perform similarly to normal5x?
I know it doesn't, but I do not understand the implementation of the normalnx scalers so I cannot tell you now whence the difference. I will think about it.


Ant_222, just a follow-up to our performance discussion a year ago, I created patch (attached) that adds a normal4x5y scaler to dosbox, which uses this same scaling technique as the built-in normal2x/normal3x. Using this normal4x5y scaler along with 'output=surface' is much faster on an RPi3 versus using 'output=surfacepp', while have exactly the same pixel output @1080p. I don't have an effective way to benchmarch the two methods, but normal4x5y can handle the Wolf3D fade effect without stutter on the RPi3, even at 2 or 3 times the cycle count that surfacepp stutters at.

I'm not sure how the normalNx scalers differ from the way surfacepp does scaling, but maybe you'll be able to see something here that'll give you a hint.

Note: I actually created this patch a year ago again r4025, just never got around to posting it, but it still applies and works with r4163.
You do not have the required permissions to view the files attached to this post.
unther
Newbie
 
Posts: 8
Joined: 2017-9-05 @ 15:59

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby krcroft » 2018-11-13 @ 18:17

This is an excellent addition for those on single-Ghz systems (early Pentium 3's, Rpi3, etc..) to get as close to crisp pixels on modern displays. Thank you!
User avatar
krcroft
Member
 
Posts: 128
Joined: 2017-4-29 @ 15:07
Location: Ogden's Retreat

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby Ant_222 » 2018-11-13 @ 20:01

unther, I never understood how those built-in scalers worked. Can you explain, perhaps?
Ant_222
Member
 
Posts: 377
Joined: 2010-7-24 @ 21:29

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby unther » 2018-11-14 @ 00:47

krcroft wrote:This is an excellent addition for those on single-Ghz systems (early Pentium 3's, Rpi3, etc..) to get as close to crisp pixels on modern displays. Thank you!


Not a problem, but just to clarify for others, because 'normal4x5y' is a fixed scaler, it's only optimal for running 320x200 games on a display with a height of just over 1000 pixels (e.g. 1280x1024, 1680x1050, 1920x1080). For displays with a pixel height of 1200 or more, you'd want to create a patch to add a 'normal5x6y' scaler.

Since I run RetroPie on my RPI3, I just use game-specific configs to set the optimal scaler. I have my RPI3 connected to a 1280x1024 monitor, so for 320x200 games I'll use 'normal4x5y', and for 640x480 games I'll use 'normal2x'. (And I just use Ant's pixel perfect on my desktop connected to a 1920x1200 monitor.)
unther
Newbie
 
Posts: 8
Joined: 2017-9-05 @ 15:59

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby unther » 2018-11-14 @ 02:01

Ant_222 wrote:unther, I never understood how those built-in scalers worked. Can you explain, perhaps?


Unfortunately, I don't have any real understanding of how they work either (or really any familiarity with the dosbox code base). I just used the existing normalNx scalers as a template to create a normal4x5y without delving in to how these scalers actually push pixels to the display.

I just took a look now but the code is hard for me to follow due to the nested includes and conditional pre-processor directives being used to reduce code duplication. It looks like the actual scaling code is in render_simple.h, which itself in included multiple times by render_templates.h, once in each scaler definition. render_templates.h in included multiple times by render_scalers.cpp, looks like once for each variation of color bit depth.

At its heart, it looks like these scalers just copy a source pixel into a grid/block for output. Here's the definition from render_templates.h for the built-in normal3x and the normal4x5y that I created from it. Note that SCALERFUNC is then inserted into the code included from render_simple.h

Code: Select all
#define SCALERNAME              Normal3x
#define SCALERWIDTH             3
#define SCALERHEIGHT    3
#define SCALERFUNC                                                              \
        line0[0] = P;                                                           \
        line0[1] = P;                                                           \
        line0[2] = P;                                                           \
        line1[0] = P;                                                           \
        line1[1] = P;                                                           \
        line1[2] = P;                                                           \
        line2[0] = P;                                                           \
        line2[1] = P;                                                           \
        line2[2] = P;
#include "render_simple.h"
#undef SCALERNAME
#undef SCALERWIDTH
#undef SCALERHEIGHT
#undef SCALERFUNC

#define SCALERNAME              Normal4x5y
#define SCALERWIDTH             4
#define SCALERHEIGHT    5
#define SCALERFUNC                                                              \
        line0[0] = P;                                                           \
        line0[1] = P;                                                           \
        line0[2] = P;                                                           \
        line0[3] = P;                                                           \
        line1[0] = P;                                                           \
        line1[1] = P;                                                           \
        line1[2] = P;                                                           \
        line1[3] = P;                                                           \
        line2[0] = P;                                                           \
        line2[1] = P;                                                           \
        line2[2] = P;                                                           \
        line2[3] = P;                                                           \
        line3[0] = P;                                                           \
        line3[1] = P;                                                           \
        line3[2] = P;                                                           \
        line3[3] = P;                                                           \
        line4[0] = P;                                                           \
        line4[1] = P;                                                           \
        line4[2] = P;                                                           \
        line4[3] = P;
#include "render_simple.h"
#undef SCALERNAME
#undef SCALERWIDTH
#undef SCALERHEIGHT
#undef SCALERFUNC


That's as far as I went - hopefully that points you in the right direction.

BTW, if you can't figure out how to get your scaler to run as fast as these built-in ones, another approach might be to just patch in all the scaler variants you need (normal4x5y, normal5x6y, etc.) and just change to them on the fly after you've calculated the optimal one from the PAR. (You can change the scaler on the fly from the command line, should it might be doable - you might not even need surfacepp anymore?)
unther
Newbie
 
Posts: 8
Joined: 2017-9-05 @ 15:59

Re: VIDEO Patch for pixel-perfect scaling (SDL1)

Postby Ant_222 » 2018-11-14 @ 20:21

Thanks for the explanation, unther.
unther wrote:BTW, if you can't figure out how to get your scaler to run as fast as these built-in ones
I do have a couple ideas. One is to simplify my overcomplicated code by removing surfacenb (which is already available as openglnb) surfacenp (which is too slow and hardly different from nearest neighbor), and then carefully to analylse the simplified code. The second idea is to parallelise the scaling.
another approach might be to just patch in all the scaler variants you need (normal4x5y, normal5x6y, etc.) and just change to them on the fly after you've calculated the optimal one from the PAR. (You can change the scaler on the fly from the command line, should it might be doable - you might not even need surfacepp anymore?)
Indeed, but this is so ugly that I will let someone else it :-) I will help with the selection of the optimal scaling factors.
Ant_222
Member
 
Posts: 377
Joined: 2010-7-24 @ 21:29

Previous

Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 2 guests