homebrew-qemu-virgl icon indicating copy to clipboard operation
homebrew-qemu-virgl copied to clipboard

Use OpenGL ES 3.0 in qemu_egl_init_ctx

Open rinsuki opened this issue 3 years ago • 27 comments

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.

rinsuki avatar Jul 20 '21 20:07 rinsuki

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 avatar Jul 20 '21 21:07 knazarov

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.

knazarov avatar Jul 20 '21 21:07 knazarov

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

DUOLabs333 avatar Sep 28 '21 21:09 DUOLabs333

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

DUOLabs333 avatar Sep 28 '21 21:09 DUOLabs333

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

DUOLabs333 avatar Sep 28 '21 21:09 DUOLabs333

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)

rinsuki avatar Sep 28 '21 22:09 rinsuki

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 .

DUOLabs333 avatar Sep 28 '21 23:09 DUOLabs333

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.

rinsuki avatar Sep 28 '21 23:09 rinsuki

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 avatar Sep 28 '21 23:09 DUOLabs333

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 avatar Sep 29 '21 00:09 DUOLabs333

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 avatar Sep 29 '21 00:09 DUOLabs333

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.

DUOLabs333 avatar Sep 29 '21 00:09 DUOLabs333

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

rinsuki avatar Sep 29 '21 00:09 rinsuki

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 .

DUOLabs333 avatar Sep 29 '21 00:09 DUOLabs333

  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.

rinsuki avatar Sep 29 '21 00:09 rinsuki

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 .

DUOLabs333 avatar Sep 29 '21 01:09 DUOLabs333

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 ?

rinsuki avatar Sep 29 '21 02:09 rinsuki

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

DUOLabs333 avatar Sep 29 '21 02:09 DUOLabs333

After building, it still says OpenGL 2.1.

DUOLabs333 avatar Sep 29 '21 02:09 DUOLabs333

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

rinsuki avatar Sep 29 '21 02:09 rinsuki

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

DUOLabs333 avatar Sep 29 '21 02:09 DUOLabs333

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.

rinsuki avatar Sep 29 '21 02:09 rinsuki

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

DUOLabs333 avatar Sep 29 '21 02:09 DUOLabs333

Also, gl=core just froze the VM.

DUOLabs333 avatar Sep 29 '21 02:09 DUOLabs333

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.

rinsuki avatar Sep 29 '21 02:09 rinsuki

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 avatar Sep 29 '21 10:09 DUOLabs333

Will this be merged soon?

DUOLabs333 avatar Jan 24 '22 23:01 DUOLabs333