knazarov / homebrew-qemu-virgl

A homebrew tap for qemu with support for 3d accelerated guests
415 stars 68 forks source link

Use OpenGL ES 3.0 in qemu_egl_init_ctx #35

Open rinsuki opened 3 years ago

rinsuki commented 3 years ago

in ANGLE Metal backend (you can enable with ANGLE_DEFAULT_PLATFORM=metal), qemu-system-x86_64 shows this error:

qemu_gl_create_compile_shader: compile vertex error
ERROR: unsupported shader version

qemu_gl_create_compile_shader: compile fragment error
ERROR: unsupported shader version

qemu_gl_create_compile_shader: compile vertex error
ERROR: unsupported shader version

qemu_gl_create_compile_shader: compile fragment error
ERROR: unsupported shader version

because these shaders (at https://github.com/qemu/qemu/tree/266469947161aa10b1d36843580d369d5aa38589/ui/shader ) are marked as #version 300 es, that means it requires OpenGL ES 3.0. but qemu_egl_init_ctx initializes EGL with OpenGL ES 2.0, then shader compile will fails.

in this pull-request, modify qemu_egl_init_ctx to use OpenGL ES 3.0.

but even after this patch applied, many parts are broken and not suitable for general-use currently. e.g. Android-x86 but text and other components are gone 😝

image

NOTE: this pull-request not adding patches to qemu-virgl.rb because I can't get https://raw.githubusercontent.com/knazarov/homebrew-qemu-virgl/... URL before merge it.

knazarov commented 3 years ago

Thanks for the patch! I’ll add it after I rebase the code to the latest version from Akihiko Odaki. I’m on my way to doing that, checking that it compiles.

And this is probably something you may want to let him know as well here: https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5

knazarov commented 3 years ago

The problems you see may also be because I use libangle from a few months ago. It’s possible that they’ve caught up with the metal backend.

DUOLabs333 commented 2 years ago

I'm going to build this today and see if it's been improved (need 3.0 for Dolphin-emu).

DUOLabs333 commented 2 years ago

Hmmm... after manually upgrading, I'm still on OpenGL 2.

DUOLabs333 commented 2 years ago

For some reason, the patch didn't apply. Is there a way to force it to apply?

rinsuki commented 2 years ago

you can test this patch with open /usr/local/Cellar/qemu-virgl/*/bin/qemu-system-(your arch) in hex editor (like Hex Fiend) and modify 98 30 00 00 02 00 00 00 to 98 30 00 00 03 00 00 00 (98 30 00 00 = 32bit little endian int of EGL_CONTEXT_CLIENT_VERSION a.k.a. 0x3098)

DUOLabs333 commented 2 years ago

I did, and it wouldn't boot anymore.

On Tue, Sep 28, 2021 at 6:56 PM rinsuki @.***> wrote:

you can test this patch with open /usr/local/Cellar/qemu-virgl/*/bin/qemu-system-(your arch) in hex editor (like Hex Fiend https://github.com/HexFiend/HexFiend) and modify 98 30 00 00 02 00 00 00 to 98 30 00 00 03 00 00 00 (98 30 00 00 = 32bit little endian int of EGL_CONTEXT_CLIENT_VERSION a.k.a. 0x3098)

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/knazarov/homebrew-qemu-virgl/pull/35#issuecomment-929682914, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXWUYCWUTKXSCFAICE4UNLUEJB2VANCNFSM5AWR2BCA .

rinsuki commented 2 years ago

humm, it should work... (you can retry with brew reinstall qemu-virgl)

btw, why you want to run Linux version of Dolphin Emulator in macOS? Dolphin Emulator already have a macOS native version (even arm64), and it works great for me.

DUOLabs333 commented 2 years ago

Oh, really? That's nice. But I do most of my work in Linux, so it would be nice to have integration.

On Tue, Sep 28, 2021 at 7:56 PM rinsuki @.***> wrote:

humm, it should work... (you can retry with brew reinstall qemu-virgl)

btw, why you want to running Linux version of Dolphin Emulator in macOS? Dolphin Emulator already have a macOS native version (even arm64), and it works great for me.

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

DUOLabs333 commented 2 years ago

The hex edit should work for the aarch64 binary compiled for the M1 chip, right?

On Tue, Sep 28, 2021 at 7:59 PM DUO Labs @.***> wrote:

Oh, really? That's nice. But I do most of my work in Linux, so it would be nice to have integration.

On Tue, Sep 28, 2021 at 7:56 PM rinsuki @.***> wrote:

humm, it should work... (you can retry with brew reinstall qemu-virgl)

btw, why you want to running Linux version of Dolphin Emulator in macOS? Dolphin Emulator already have a macOS native version (even arm64), and it works great for me.

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

DUOLabs333 commented 2 years ago

Oh, it seems that for the M1 chip, binaries must be signed, and editing it breaks the signature.

On Tue, Sep 28, 2021 at 8:03 PM DUO Labs @.***> wrote:

The hex edit should work for the aarch64 binary compiled for the M1 chip, right?

On Tue, Sep 28, 2021 at 7:59 PM DUO Labs @.***> wrote:

Oh, really? That's nice. But I do most of my work in Linux, so it would be nice to have integration.

On Tue, Sep 28, 2021 at 7:56 PM rinsuki @.***> wrote:

humm, it should work... (you can retry with brew reinstall qemu-virgl)

btw, why you want to running Linux version of Dolphin Emulator in macOS? Dolphin Emulator already have a macOS native version (even arm64), and it works great for me.

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

DUOLabs333 commented 2 years ago

I resigned it, but get an error: "Abort trap: 6"

On Tue, Sep 28, 2021 at 8:04 PM DUO Labs @.***> wrote:

Oh, it seems that for the M1 chip, binaries must be signed, and editing it breaks the signature.

On Tue, Sep 28, 2021 at 8:03 PM DUO Labs @.***> wrote:

The hex edit should work for the aarch64 binary compiled for the M1 chip, right?

On Tue, Sep 28, 2021 at 7:59 PM DUO Labs @.***> wrote:

Oh, really? That's nice. But I do most of my work in Linux, so it would be nice to have integration.

On Tue, Sep 28, 2021 at 7:56 PM rinsuki @.***> wrote:

humm, it should work... (you can retry with brew reinstall qemu-virgl)

btw, why you want to running Linux version of Dolphin Emulator in macOS? Dolphin Emulator already have a macOS native version (even arm64), and it works great for me.

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

rinsuki commented 2 years ago

humm, I'm still using Intel Mac, then I can't help problem about M1 Mac...

DUOLabs333 commented 2 years ago

Although my real question was how to apply the patch, which brew doesn't seem to be doing. If I change the file egl-helpers.c before it is compiled, ninja just hangs forever.

On Tue, Sep 28, 2021 at 8:24 PM rinsuki @.***> wrote:

humm, I'm still using Intel Mac, then I can't help problem about M1 Mac...

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/knazarov/homebrew-qemu-virgl/pull/35#issuecomment-929719442, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXWUYAZSCPIHFYATOBFCO3UEJMC7ANCNFSM5AWR2BCA .

rinsuki commented 2 years ago
  1. brew edit qemu-virgl
  2. Add new patch section with patch https://raw.githubusercontent.com/knazarov/homebrew-qemu-virgl/02464311b4cca56f400132f4993488f10e5928e7/Patches/qemu-usegles3-v01.diff
  3. brew reinstall --build-from-source qemu-virgl

it should work, but I'm not tested.

DUOLabs333 commented 2 years ago

It fails with "patch unexpectedly ends in middle of line Hunk #1 succeeded at 474 with fuzz 1 (offset 12 lines)".

On Tue, Sep 28, 2021 at 8:45 PM rinsuki @.***> wrote:

  1. brew edit qemu-virgl
  2. Add new patch section with patch https://raw.githubusercontent.com/knazarov/homebrew-qemu-virgl/02464311b4cca56f400132f4993488f10e5928e7/Patches/qemu-usegles3-v01.diff
  3. brew reinstall --build-from-source qemu-virgl

it should work, but I'm not tested.

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/knazarov/homebrew-qemu-virgl/pull/35#issuecomment-929729842, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXWUYCEU5SVQGXPX5K57MDUEJOTPANCNFSM5AWR2BCA .

rinsuki commented 2 years ago

uuh sorry, diff requires LF in last line of patch. can you retry with this patch https://raw.githubusercontent.com/knazarov/homebrew-qemu-virgl/ebbc42bb0c0ce8c4604d67ad28b40603c5b62507/Patches/qemu-usegles3-v01.diff ?

DUOLabs333 commented 2 years ago

Now it says, "Hunk #1 succeeded at 474 (offset 12 lines).", but the file didn't update.

DUOLabs333 commented 2 years ago

After building, it still says OpenGL 2.1.

rinsuki commented 2 years ago

what about OpenGL ES version? (OpenGL without ES and OpenGL ES is different things)

DUOLabs333 commented 2 years ago

"OpenGL ES profile version string: OpenGL ES 3.0 Mesa 21.2.1". So, I think it worked.

rinsuki commented 2 years ago

currently, OpenGL 3.0 backend for OpenGL ES 3.x is not exists (gl4es only supports OpenGL 2.x).

if you want to use OpenGL 3.x in VM, currently option are use gl=core instead of gl=es, but akihikodai says "Unstable" in gist, and I don't know it works or not.

and I think, for dolphin emulator, native macOS version are good choice, because it has a Metal support w/ MoltenVK.

DUOLabs333 commented 2 years ago

Yeah, but is there any way to share a MacOS window to Linux, so it could be more integrated?

DUOLabs333 commented 2 years ago

Also, gl=core just froze the VM.

rinsuki commented 2 years ago

in my knowledge, there is a no way to share macOS window to Linux in same machine.

If you can accept proprietary things, Parallels or VMware Fusion may good choice because they have hardware-accelerated OpenGL Desktop in VM even M1 Mac. VMware Fusion for M1 is currently Tech Preview and free for several months (but it requires register to VMware ID), also Parallels provides free-trial.

DUOLabs333 commented 2 years ago

Yeah, I've tried Parallels, very good (even provide camera and microphone), but the payment turned me off.

On Tue, Sep 28, 2021 at 10:48 PM rinsuki @.***> wrote:

in my knowledge, there is a no way to share macOS window to Linux in same machine.

If you can accept proprietary things, Parallels or VMware Fusion may good choice because they have hardware-accelerated OpenGL Desktop in VM even M1 Mac. VMware Fusion for M1 is currently Tech Preview and free for several months (but it requires register to VMware ID), also Parallels provides free-trial.

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/knazarov/homebrew-qemu-virgl/pull/35#issuecomment-929779549, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXWUYGOQ2JKHJ2FXEY74FLUEJ47DANCNFSM5AWR2BCA .

DUOLabs333 commented 2 years ago

Will this be merged soon?