cebix / macemu

Basilisk II and SheepShaver Macintosh emulators
1.38k stars 288 forks source link

linux: x11: enable upscaling #204

Closed buserror closed 4 years ago

buserror commented 4 years ago

Use the XRender extention to add basic x2 upscaling of the video.

On a 4K screen with HiDPI, the video window is tiny and completely
unreadable. This patch detects HiDPI screen and attempt to upscale by
x2.

To do that, I change the rendering path so the XImage (local image) is
drawn into a server XPixmap instead of the window directly (that doesn't
support scaling)

Then after the X*PutImage is/are done, I use XRenderComposite to draw
that offscreen pixmap into the window, having applied a Transform to the
pixmap so it scales up.

The code will only work with the VOSF drawing path at the minute,
however it /should/ be easy to adapt for the other rendering paths, the
other path are already compatible with drawing into an offscreen Pixmap
now (see previous patch).
rickyzhang82 commented 4 years ago

I want to give a try for System 6 where the resolution is limited to 512x342. Could you please share your configure setting?

buserror commented 4 years ago

What would you like? config.log? I haven't added anything to configure.ac, the patch is currently "automatic" -- but perhaps it could use an extra test for Xrender extension, altho that has been around since 2002 :-)

Right now the code does #define ENABLE_XRENDER and that in turn enable the x2 zoom when the DPI of your screen is >100...

rickyzhang82 commented 4 years ago

I'm talking about something like below:

./configure --enable-sdl-video --enable-sdl-audio --disable-vosf --disable-jit-compiler --with-x --with-gtk --with-mon;
buserror commented 4 years ago

According to config.log, I just did ./configure --enable-jit-compiler (however, I have found it's actually slower so i've disabled it in the prefs) but the exec has VOSF, X, GTK and MON -- but no SDL -- rest is default.

I'm including my config.h: https://gist.github.com/buserror/1dc5400d6fc293f7bc8a602f2c1a6dc0

rickyzhang82 commented 4 years ago

I bet your host OS still uses 32bit.

I have to disable JIT. I used the configure below:

./configure --enable-vosf --disable-jit-compiler --with-x --with-gtk --with-mon

...
Basilisk II configuration summary:

Mac OS X GUI ........................... : no
Mac OS X Sound ......................... : no
SDL support ............................ : none
BINCUE support ......................... : no
LIBVHD support ......................... : no
VDE support ............................ : no
XFree86 DGA support .................... : yes
XFree86 VidMode support ................ : yes
fbdev DGA support ...................... : no
Enable video on SEGV signals ........... : yes
ESD sound support ...................... : no
GTK user interface ..................... : gtk2
mon debugger support ................... : yes
Running m68k code natively ............. : no
Use JIT compiler ....................... : no
JIT debug mode ......................... : no
Floating-Point emulation core .......... : IEEE fpu core
Assembly optimizations ................. : x86-64
Addressing mode ........................ : direct
Bad memory access recovery type ........ : siginfo
..

I have linking problem in Linux Fedora 5.6.6-300.fc32.x86_64

g++ -o BasiliskII -Wl,-T,ldscripts/linux-x86_64.ld  obj/main.o obj/prefs.o obj/prefs_items.o obj/sys_unix.o obj/rom_patches.o obj/slot_rom.o obj/rsrc_patches.o obj/emul_op.o obj/macos_util.o obj/xpram.o obj/xpram_unix.o obj/timer.o obj/timer_unix.o obj/adb.o obj/serial.o obj/ether.o obj/sony.o obj/disk.o obj/cdrom.o obj/scsi.o obj/video.o obj/audio.o obj/extfs.o obj/disk_sparsebundle.o obj/tinyxml2.o obj/user_strings.o obj/user_strings_unix.o obj/sshpty.o obj/strlcpy.o obj/rpc_unix.o obj/vm_alloc.o obj/sigsegv.o obj/video_blit.o obj/video_x.o obj/extfs_unix.o obj/serial_unix.o obj/ether_unix.o obj/scsi_linux.o obj/audio_oss_esd.o obj/prefs_editor_gtk.o obj/mon.o obj/mon_6502.o obj/mon_z80.o obj/mon_cmd.o obj/mon_disass.o obj/mon_ppc.o obj/mon_lowmem.o obj/floatformat.o obj/i386-dis.o obj/m68k-dis.o obj/m68k-opc.o obj/main_unix.o obj/prefs_unix.o obj/clip_unix.o obj/basilisk_glue.o obj/memory.o obj/newcpu.o obj/readcpu.o obj/fpu_ieee.o obj/cpustbl.o obj/cpudefs.o obj/cpuemu1.o obj/cpuemu2.o obj/cpuemu3.o obj/cpuemu4.o obj/cpuemu5.o obj/cpuemu6.o obj/cpuemu7.o obj/cpuemu8.o obj/bootp.o obj/ip_output.o obj/tcp_input.o obj/cksum.o obj/mbuf.o obj/tcp_output.o obj/debug.o obj/misc.o obj/tcp_subr.o obj/if.o obj/sbuf.o obj/tcp_timer.o obj/ip_icmp.o obj/slirp.o obj/tftp.o obj/ip_input.o obj/socket.o obj/udp.o -lpthread -lm -lrt -lrt -lreadline -lncurses   -lSM -lICE  -lX11 -lXext  -lXxf86dga -lXxf86vm -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype 
/usr/bin/ld: obj/video_x.o: undefined reference to symbol 'XRenderSetPictureTransform'
/usr/bin/ld: /lib64/libXrender.so.1: error adding symbols: DSO missing from command line
buserror commented 4 years ago

Host is Debian sid: ./configure --enable-vosf --disable-jit-compiler --with-x --with-gtk --with-mon X_EXTRA_LIBS=-lXrender

Basilisk II configuration summary:

Mac OS X GUI ........................... : no
Mac OS X Sound ......................... : no
SDL support ............................ : none
BINCUE support ......................... : no
LIBVHD support ......................... : no
VDE support ............................ : no
XFree86 DGA support .................... : no
XFree86 VidMode support ................ : yes
fbdev DGA support ...................... : yes
Enable video on SEGV signals ........... : yes
ESD sound support ...................... : no
GTK user interface ..................... : gtk2
mon debugger support ................... : yes
Running m68k code natively ............. : no
Use JIT compiler ....................... : no
JIT debug mode ......................... : no
Floating-Point emulation core .......... : IEEE fpu core
Assembly optimizations ................. : x86-64
Addressing mode ........................ : direct
Bad memory access recovery type ........ : siginfo
rickyzhang82 commented 4 years ago

Sorry, I don't mean to hijack your work. But it seems that we are chasing the same goal here.

It would be nice to have some other place to discuss how to implement this scale up/down feature.

buserror commented 4 years ago

Sorry, I don't mean to hijack your work. But it seems that we are chasing the same goal here.

It would be nice to have some other place to discuss how to implement this scale up/down feature.

Doesn't matter really -- one thing I know about "upstreaming" is that it takes a lot longer than writting code; and I have no time for that, WAY too many other interesting things to do! I wasted way too much of my life trying to upstream stuff -- now I give it a try, taste the water, and I'm definitely happy to bailout; AFAIK it works for my use case, and really, I don't know why I bother :-)

I DID try to give it 80% of the way without wasting more of my life dealing with autoshit stuff, but then again, too many project, too little time :-)

AFAIK you COULD have replied to the Issue I posted a while back about that problem, before I started to work, and perhaps that point we could have figured out something. See #199

rickyzhang82 commented 4 years ago

The reason of sending my change to a PR compulsively is that: I don't want to merge my private stuffs every time there are updates I want from upstream.

I agree writing autoconf is a time-consuming task. But you will be surprised to find that it works magically in my two decade old Power PC Tiger 10.4, latest Linux and Mac OS X.

I will re-post my instruction in #199 and keep you guys updated on my change.

I bet you will like SDL2 better due to the performance boost from hardware. I can tell my son's game running much way more smoothly in SDL2 metal back end under Mac OS X.

juanpc2018 commented 4 years ago

I have a 40" UHD 4K TV, at 1.8meters looks too small, any OS. Closer, the edges look weird because its Not curved.. A friend has a 50" same problem, 4k is too small for 50" Usually looks best at 2500x1440

All 4K Tvs have Upscaling built-in... Otherwise FullHD will look too pixelated. FHD at 32" looks pixelated with No upscaling. FHD 55" at 3meters looks impossible to read for a person with small myopia.

Windows8.1 has built-in upscaling in OS, but has severe conflict with some softwares... For example Air Plugins for ProToolsHD. Upscaling in OS is Not recommended.

Buy a bigget TV or lower the resolution.

buserror commented 4 years ago

My use case is Linux x64 with a good video card, I don't care about SDL (ESPECIALLY if SDL tries to make my 2*4K screen "fullscreen" to display a stupid emulator) because I launch it the wrong way.

I just want a 2* zoom WINDOW under X11. The code I made would /certainly/ support fractional scaling it's' a transform matrix, but I don't see why you would want that as all the moiring is dreadful (regardless of the filter). So x2 is great.

That's what I did. Some people seemed interested by it on the bug report, otherwise, quite frankly, I wouldn't have bothered even pushing it. Instead, you lead me into a small chase of "ho, how do you configure this" knowing very where (well I hope) how to add a stupid library to a link process.

Anyway, case closed AFAIK.

rickyzhang82 commented 4 years ago

@buserror

Go check out my new improvement that I made for SDL2:

Screen Cast