#9573 closed defect (fixed)

SDL1/2: Different rendering/filtering?

Reported by: rootfather Owned by: criezy
Priority: normal Component: --Other--
Keywords: SDL, rendering Cc:
Game:

Description

I noticed that when using the SDL renderer on SDL2, the image looks far more "pixelated" than on SDL1, which is a bit sad, especially on games that use a higher resolution like 640x480.

I attached a screenshot of the SDL2 build. Between the tests, I made no modifications to my driver configuration. All graphics options are on default. The issue is most visible on fullscreen mode.

I tried to create a screenshot (using PrntScr) on SDL1 too, but you can't see the issue here, because the resulting image is not in 1600x900 (my laptop's native resolution) like the SDL2 image, but in 640x480.

The fact that SDL2 renders the image in the native resolution and doesn't use 640x480 plus relying on the upscaling capabilities of the video driver is probably the cause of the issue.

...or is that even wanted behaviour?

Attachments (3)

rendering on SDL2.png (93.3 KB) - added by rootfather 15 months ago.
scummvm_nearest.png (202.9 KB) - added by criezy 15 months ago.
ScummVM SDL2 fullscreen nearest (default)
scummvm_linear.png (1.1 MB) - added by criezy 15 months ago.
ScummVM SDL2 fullscreen linear

Download all attachments as: .zip

Change History (12)

Changed 15 months ago by rootfather

Attachment: rendering on SDL2.png added

comment:1 Changed 15 months ago by sev-

Could you also provide a screenshot from SDL1?

comment:2 Changed 15 months ago by rootfather

I tried to, but all I got is a screenshot with the resolution of the launcher/game without any scaling, so it won't help as the "real" fullscreen look is not visible in the screenshot. The screenshots in SDL1 look exactly like they were taken in windowed mode.

This is why I suspect that the pixelated image is caused by the fact that SDL2 scales the image to native resolution while SDL1 renders the fullscreen modes in 640x480 or whatever the resolution of the launcher/game is and leaves the scaling up to the video driver.

comment:3 Changed 15 months ago by criezy

Your suspicion is correct: with SDL we use the new SDL_WINDOW_FULLSCREEN_DESKTOP, which is documented as being a "fake" fullscreen that uses the size of the desktop. For SDL 1 we use SDL_WINDOW_FULLSCREEN which provide a "real" fullscreen. So for SDL2 the scaling is done by SDL. By default it uses a nearest algorithm, which is why it looks pixelated. You can however change this by adding the following in SurfaceSdlGraphicsManager::SDL_SetVideoMode:

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");

The possible values are "nearest" (or 0, the default), "linear" (or 1) and "anisotropic" (or 2). In my case "anisotropic" gives exactly the same result as "linear', probably because it is documented as working only with Direct3D and I am not on Windows.

So the question is what do we expect in fullscreen? Pixelated or interpolated scaling?

Changed 15 months ago by criezy

Attachment: scummvm_nearest.png added

ScummVM SDL2 fullscreen nearest (default)

Changed 15 months ago by criezy

Attachment: scummvm_linear.png added

ScummVM SDL2 fullscreen linear

comment:4 Changed 15 months ago by criezy

Sorry, I meant to write "best" (or 2) and not "anisotropic" in my previous message. It does provide an anisotropic scaling though :P

comment:5 Changed 15 months ago by wjp

FWIW, in the OpenGL backend we provide linear and nearest as two separate rendering modes. ("OpenGL" and "OpenGL (no filtering)", respectively.)

comment:6 Changed 15 months ago by criezy

Duplicating all the SDL scalers might be a bit too much though ;) I suppose we could however use nearest for some scalers (Normal, 2X, 3X) and linear for others (HQ2X, HQ3X, SuperEagle). I am not sure the split is obvious though (what about TV2X and DotMatrix?).

comment:7 Changed 15 months ago by wjp

Or maybe we can turn it into a separate option that would affect both SDL2 and OpenGL?

comment:8 Changed 15 months ago by rootfather

Thanks for all the feedback!

I like the idea of an seperate option (a checkbox called "Enable bilinear filtering" (or whatever is the best scaling method)) that works on all SDL2 modes and in OpenGL.

With a checkbox we only have to duplicate all scalers internally, but not visible on the frontend.

comment:9 Changed 14 months ago by criezy

Owner: set to criezy
Resolution: fixed
Status: newclosed

As suggested by wjp I have added a separate filtering option that affects both SDL2 and OpenGL.

Note: See TracTickets for help on using tickets.