Skip to content

Improve downscale quality based on window size #692

@ruanformigoni

Description

@ruanformigoni

Greetings,

Would it be possible to implement something like RSR or DLDSR to improve image quality on down-scaling? I've tested gamescope with a virtual resolution in xorg, and it has better quality than the downscaling done by gamescope xrandr --output "HDMI-A-0" --mode 2560x1080 --panning 5120x2160 --scale 2x2. Here is an example with Need for speed pro street.

comparison-edit

Take the image below as an example, this was running at 10240x4320 (both window and internal resolution). The aliasing seems to not see much improvement over the 2560x1080 counterpart, in the power lines, light rails and the tower to the right.

10240-10240-downscaled

However, when zoomed in, one can see that the improvement was incredible, but the down-scaling process causes additional aliasing.
10240-10240-downscaled-zoomed

Edit:

I've done some research, and played around with the code. Here are some resources:

[1] https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSamplerCreateInfo.html
[2] https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFilter.html
[3] https://vulkan-tutorial.com/Texture_mapping/Image_view_and_sampler
[4] https://towardsdatascience.com/image-processing-image-scaling-algorithms-ae29aaa6b36c
[5] https://stackoverflow.com/questions/13501081/efficient-bicubic-filtering-code-in-glsl

Maybe it is possible to enable bilinear or bicubic interpolation with the samplerInfo.minFilter setting.

Also, is there a way to do something like xrandr --output "HDMI-A-0" --mode 2560x1080 --panning 5120x2160 --scale 2x2 in the nested X session? That would improve the final quality as shown in the first comparison.


I got close to make it compile today with the changes in panning:

auto const& ctx = this->ctx;
Window wind = ctx->ourWindow;
Display* disp = ctx->dpy;
XRRScreenResources* res = XRRGetScreenResourcesCurrent(disp,wind);
RRCrtc* crtcs = res->crtcs;
XRRPanning* panning = XRRGetPanning(disp, res, *crtcs);
panning->width = 10240;
panning->height = 4320;
Status st = XRRSetPanning(disp, res, *crtcs, panning);

But there are linking issues with the xrandr header #include <X11/extensions/Xrandr.h>:

Compile output FAILED: gamescope c++ -o gamescope gamescope.p/meson-generated_.._protocol_gamescope-xwayland-protocol.c.o gamescope.p/meson-generated_.._protocol_gamescope-pipewire-protocol.c.o gamescope.p/meson-generated_.._protocol_gamescope-input-method-protocol.c.o gamescope.p/meson-generated_.._protocol_gamescope-tearing-control-unstable-v1-protocol.c.o gamescope.p/src_steamcompmgr.cpp.o gamescope.p/src_main.cpp.o gamescope.p/src_wlserver.cpp.o gamescope.p/src_drm.cpp.o gamescope.p/src_modegen.cpp.o gamescope.p/src_sdlwindow.cpp.o gamescope.p/src_vblankmanager.cpp.o gamescope.p/src_rendervulkan.cpp.o gamescope.p/src_log.cpp.o gamescope.p/src_ime.cpp.o gamescope.p/src_mangoapp.cpp.o gamescope.p/src_pipewire.cpp.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group subprojects/wlroots/libwlroots.a subprojects/libliftoff/libliftoff.a /usr/lib/libX11.so /usr/lib/libXdamage.so /usr/lib/libXfixes.so /usr/lib/libXcomposite.so /usr/lib/libXrender.so /usr/lib/libXext.so /usr/lib/libXxf86vm.so /usr/lib/libXRes.so /usr/lib/libdrm.so /usr/lib/libwayland-server.so /usr/lib/libxkbcommon.so -pthread /usr/lib/libSDL2.so /usr/lib/libudev.so /usr/lib/libpixman-1.so -lm -lrt /usr/lib/libinput.so /usr/lib/libwayland-client.so /usr/lib/libseat.so /usr/lib/libxcb.so /usr/lib/libxcb-composite.so /usr/lib/libxcb-icccm.so /usr/lib/libxcb-render.so /usr/lib/libxcb-res.so /usr/lib/libxcb-xfixes.so /usr/lib/libxcb-errors.so /usr/lib/libvulkan.so /usr/lib/libXtst.so /usr/lib/libcap.so /usr/lib/libpipewire-0.3.so -Wl,--end-group /sbin/ld: gamescope.p/src_wlserver.cpp.o: in function `gamescope_xwayland_server_t::gamescope_xwayland_server_t(wl_display*)': /home/ruan/Repositories/gamescope/build/../src/wlserver.cpp:766: undefined reference to `XRRGetScreenResourcesCurrent' /sbin/ld: /home/ruan/Repositories/gamescope/build/../src/wlserver.cpp:768: undefined reference to `XRRGetPanning' /sbin/ld: /home/ruan/Repositories/gamescope/build/../src/wlserver.cpp:771: undefined reference to `XRRSetPanning' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

Managed to make it compile with dep_xrandr = dependency('xrandr'), however it segfaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions