mesa-dist-win icon indicating copy to clipboard operation
mesa-dist-win copied to clipboard

Support for OpenGL ES 3.1

Open guanzhangrtk opened this issue 3 years ago • 31 comments

Hi, I'm trying to run Android Emulators on my Windows 10 PC which has an old GPU that doesn't support newer versions of OpenGL and was wondering if this driver can help with this. I understand that performance won't be great but I'm just trying to test some stuff out.

I get the follow error message when loading some games and was wondering if OpenGL ES 3.1 is supported, thanks a lot for any feedback in advance!

image

guanzhangrtk avatar Mar 09 '21 09:03 guanzhangrtk

Try 21.0.0-rc5. If that doesn't help you'll have to wait for 21.1 series.

pal1000 avatar Mar 09 '21 15:03 pal1000

Hi, thanks for the quick response. Just to clarify, it turns out the screenshot I captured previously was using Federico Dossena's MesaForWindows-x64-20.1.8 and not your drivers. I had copied Federico's opengl32.dll to the application directory and had forgotten about it, so I was really confused when it kept saying the driver version was 20.1.8 when I actually installed version 20.3.4.

Anyways now that I got this sorted out, I actually have issues using your drivers with BlueStacks. I used the perappdeploy script and I get the following in BlueStacks log:

(PGA) ERROR: 00001FDC: ERROR: `anonymous-namespace'::WinEngine::WinEngine: Could not open opengl32.dll: A dynamic link library (DLL) initialization routine failed.

With Federico's driver I just copied over opengl32.dll and it worked out of the box. The logs look like this:

(PGA) INFO: 00001920: GL_VENDOR = VMware, Inc. (PGA) INFO: 00001920: GL_RENDERER = llvmpipe (LLVM 8.0, 128 bits) (PGA) INFO: 00001920: GL_VERSION = 3.1 Mesa 20.1.8 (PGA) INFO: 00001920: GL_SHADING_LANGUAGE_VERSION = 1.40 (PGA) INFO: 00001920: GL_EXTENSIONS = GL_AMD_conservative_depth

Any ideas how to resolve this issue?

Incidentally, BlueStacks seems to come with its own implementation of OpenGL ES drivers:

image

So I'm not exactly sure how this will work. As far as I understand BlueStacks just need you to have a "recent" version of OpenGL, then it probably does its own translation to OpenGL ES 3.1, so I'll just need to trick it to think that I do. I may actually not need to have OpenGL ES 3.1 support with the driver.

Anyways please let me know if you have any ideas on how to proceed, thanks again!

guanzhangrtk avatar Mar 10 '21 14:03 guanzhangrtk

Even if we sort out the problem you encountered with my package which may be due to Bluestacks having its own OpenGL ES implementation, it won't work due to Bluestacks using OpenGL compatibility profile which for Mesa3D is capped at OpenGL 3.1 until this lands.

I really hope you haven't deployed Mesa3D OpenGL ES over BlueStacks OpenGL ES or else a repair install is required. I don't know if BlueStacks comes with libEGL.dll, libGLESv1_CM.dll, or libGLESv2.dll or their translator copies or both which may clash with Mesa3D.

pal1000 avatar Mar 12 '21 20:03 pal1000

BlueStacks actually does come with their own OpenGL ES implementation, however when I setup Mesa3D I told it not to add OpenGL ES support so it didn't actually overwrite the files already in BlueStacks program directory. In fact it I only needed opengl32.dll and libglapi.dll but even after I copied those two files over the engine wouldn't start:

(PGA) ERROR: 00001284: ERROR: `anonymous-namespace'::WinEngine::WinEngine: Could not open opengl32.dll: The specified module could not be found.

It either shows this error message or the one in my previous comment and I tried both with symlinks + copying the files directly over. Do you happen to know what the issue is? As mentioned Federico's opengl32.dll worked fine out of the box, so I'm not sure how differently the drivers were compiled.

BTW I tried running Federico's driver with the following batch script:

@set MESA_GL_VERSION_OVERRIDE=4.5
@set MESA_GLSL_VERSION_OVERRIDE=450
@set MESA_GLES_VERSION_OVERRIDE=3.1
@cd "C:\Program Files\BlueStacks_bgp64"
@Bluestacks

And the logs look a bit differently:

2021-03-12 16:36:23.326 5328:00000004 (PGA) INFO: 000019D8: GL_VENDOR = VMware, Inc.
2021-03-12 16:36:23.326 5328:00000004 (PGA) INFO: 000019D8: GL_RENDERER = llvmpipe (LLVM 8.0, 128 bits)
2021-03-12 16:36:23.326 5328:00000004 (PGA) INFO: 000019D8: GL_VERSION = OpenGL ES 3.0 (4.5 (Core Profile) Mesa 20.1.8)
2021-03-12 16:36:23.326 5328:00000004 (PGA) INFO: 000019D8: GL_SHADING_LANGUAGE_VERSION = OpenGL ES GLSL ES 3.00
2021-03-12 16:36:23.326 5328:00000004 (PGA) INFO: 000019D8: GL_EXTENSIONS (GUEST): 
2021-03-12 16:36:23.326 5328:00000004 (PGA) INFO: 000019D8: GL_OES_EGL_image

And this is what the Android device thinks I have (according to AIDA64):

image

For now I would like to be able to get to this same place with your updated drivers, instead of Federico's outdated ones. I was wondering what I need to do to get there. Perhaps after that I may consider manually patching in support for OpenGL 3.1+ to see if I can get the game going...

Thanks again!

guanzhangrtk avatar Mar 13 '21 00:03 guanzhangrtk

I think I'll have to disable shared glapi for build to be like Federico's, but I am worried about #8 coming back.

You can try backing up all libEGL*.dll and libGLES*.dll from BlueStacks folder and then deploy Mesa3D OpenGL ES too.

pal1000 avatar Mar 13 '21 10:03 pal1000

I think I'll have to disable shared glapi for build to be like Federico's, but I am worried about #8 coming back.

I tested the release prior to this issue but it's still showing the following error in the logs. Just to confirm this is the version that doesn't have libglapi.dll and only has opengl32.dll (along with omesa.dll):

(PGA) ERROR: 00000F88: ERROR: `anonymous-namespace'::WinEngine::WinEngine: Could not open opengl32.dll: A dynamic link library (DLL) initialization routine failed.

So perhaps it's something else...?

You can try backing up all libEGL*.dll and libGLES*.dll from BlueStacks folder and then deploy Mesa3D OpenGL ES too.

Yeah I could try that, but first I'll need to get main opengl32.dll working first, thanks!

guanzhangrtk avatar Mar 13 '21 12:03 guanzhangrtk

@guanzhangrtk, are you using 64-bit opengl32.dll with Bluestacks? If so, what's your CPU? The problem may be swr driver leaking AVX usage into Mesa3D common code. Federico's build was done without swr. See these issue reports to learn more: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3860 https://gitlab.freedesktop.org/mesa/mesa/-/issues/4437 https://github.com/msys2/MINGW-packages/issues/7530#issuecomment-798209239

pal1000 avatar Mar 14 '21 09:03 pal1000

@pal1000 Yeah it's an Intel i7 920 so it doesn't look like it supports AVX. So what options do I have available? I don't mind trying to compile the driver myself but I have a feeling my potato computer won't be able to handle it. I also wonder if I have all the tools available, but I am willing to give it a shot... thanks!

guanzhangrtk avatar Mar 14 '21 09:03 guanzhangrtk

I don't mind trying to compile the driver myself but I have a feeling my potato computer won't be able to handle it.

It can handle it if you have 4GB RAM or more and the number of threads is throttled to 4 or less. Your CPU has 8. If you have 8GB RAM or more you can go without throttling.

I also wonder if I have all the tools available, but I am willing to give it a shot

MinGW build is easier to setup than MSVC. First prepare an empty folder. I'll call it c:\development.

Dependencies

  • Git for Windows is highly recommended as you won't have to download Mesa3D source tarball archive or this project source as zip. Download the standard Git-{version}-64-bit.exe installer. You can opt out of Windows Explorer integration and .git* files association. You can pick Notepad as text editor if you are on Windows 10 Version 1903 or newer. Leave everything else as default. You can install it anywhere as long as location path doesn't contain spaces or parenthesis.
  • Install MSYS2 in c:\development\msys64.

Getting mesa-dist-win source code

  • Open a Command Prompt and run this block:
cd /d c:\development
git clone https://github.com/pal1000/mesa-dist-win.git mesa-dist-win
  • Close Command Prompt.

Build Mesa3D part 1

  • Browse to c:\development\mesa-dist-win\buildscript in Explorer then run build.cmd;
  • Enter number for MSYS2 MinGW-W64 and press Enter;
  • Press y and Enter for 64-bit build;
  • Press Enter to use GCC when asked about Clang (it doesn't work most of times);
  • Enter number of CPU threads to use (remember what I said earlier about RAM requirements being proportional to number of CPU threads used);
  • Wait for MSYS2 packages to install;
  • If you have LunarG Vulkan SDK installed for whatever reason you'll be asked to choose between it and MSYS2 vulkan-devel, just choose at random as we won't be building zink, it can't even run on your PC;
  • Press Enter to skip build environment info dump;
  • Press y and Enter to start Mesa3D build;
  • Enter mesa-21.0.0 when asked about branch, then press Enter.

Workaround misbehaving AV

  • Browse in Explorer to c:\development\mesa and create a folder named build;
  • Add c:\development\mesa\build and subdirs to your AV exclusions.

Build Mesa3D part 2

  • Back to Command Prompt, press Enter to build with LLVM;
  • Press Enter repeatedly to skip zink, swr, shared glapi, osmesa, graw and unit tests build (this should make a build similar Federico's);
  • Wait for Meson configure to complete, then press Enter to execute the build;
  • Wait for build to complete (15min - 1h15min depending on number of CPU threads used);
  • Press y and Enter to create distribution package;
  • Press Enter to exit.

Deployment

  • Use per app deployment from c:\development\mesa-dist-win\bin.

pal1000 avatar Mar 14 '21 16:03 pal1000

@pal1000 Thanks for the detailed build instructions, I was able to build the drivers without much issues. So basically I was able to build a single opengl32.dll which I copied to BlueStacks' program directory and it is able to startup in OpenGL mode. This is what AIDA64 is showing me now:

image

And this is what BlueStacks' logs is showing:

2021-03-15 13:42:26.077 6020:00000004 (HD-Player) INFO: GlVendor: Mesa/X.org
2021-03-15 13:42:26.077 6020:00000004 (HD-Player) INFO: GlRenderer: llvmpipe (LLVM 11.0.0, 128 bits)
2021-03-15 13:42:26.077 6020:00000004 (HD-Player) INFO: GlVersion: OpenGL ES 3.0 (4.5 (Core Profile) Mesa 21.0.0 (git-1896a0674f))

At this point I'm pretty much stumped because the game still wouldn't start and I don't have any meaningful logs to troubleshoot. I guess I need some way of confirming that Android is indeed being told it has the capabilities to run the app and it's not failing due to some other issues. Do you have any ideas?

Incidentally I also built the driver from the mesa master branch because you said I needed the newer version that supports OpenGL 3.1+ but it didn't seem like it made a difference. Perhaps I'm missing something...

image

Just to close the loop on the issue with the default drivers not being able to be loaded, it was due to my CPU not supporting AVX and has nothing to do with split libglapi.dll build, so it will work as long as we don't build with swr support, thanks.

guanzhangrtk avatar Mar 15 '21 05:03 guanzhangrtk

So the only thing remotely useful from Android adb logcat are the following:

03-15 18:47:54.448  3734  3874 E EGL_emulation: tid 3874: eglSurfaceAttrib(1276): error 0x3004 (EGL_BAD_ATTRIBUTE)
03-15 18:47:55.913  3734  3874 E libEGL  : call to OpenGL ES API with no current context (logged once per thread)
03-15 18:47:55.920  3734  3874 E EGL_emulation: tid 3874: eglSurfaceAttrib(1276): error 0x3004 (EGL_BAD_ATTRIBUTE)
03-15 18:47:55.937  3734  3874 E libEGL  : called unimplemented OpenGL ES API

I did test another game which requires OpenGL ES 3.1 and somehow it managed to run with the drivers, just not this one so I'm not sure if there are some extensions that haven't been implemented/built yet with my build. Just to confirm there are no separate OpenGL ES 3.1 dynamically linked library like versions 1 and 2 right? Thanks!

guanzhangrtk avatar Mar 15 '21 09:03 guanzhangrtk

The only things left to try are:

  • update Bluestacks;
  • replace Bluestacks OpenGL ES with Mesa3D OpenGL ES (this implies a Mesa3D build with shared glapi and it's risky).

pal1000 avatar Mar 15 '21 15:03 pal1000

  • replace Bluestacks OpenGL ES with Mesa3D OpenGL ES (this implies a Mesa3D build with shared glapi and it's risky).

I did Mesa3D build with glapi and OpenGL ES support and it gave me 4 files, namely opengl32.dll libglapi.dll libGLESv1_CM.dll libGLESv2.dll, are there supposed to be anything else? If not I have already tried copying those over and it didn't make any difference. Incidentally does Mesa3D provide libEGL?

guanzhangrtk avatar Mar 15 '21 16:03 guanzhangrtk

I did Mesa3D build with glapi and OpenGL ES support and it gave me 4 files, namely opengl32.dll libglapi.dll libGLESv1_CM.dll libGLESv2.dll, are there supposed to be anything else?

No.

Incidentally does Mesa3D provide libEGL?

libglapi.dll is libEGL equivalent.

pal1000 avatar Mar 15 '21 18:03 pal1000

any progress?

caoli5288 avatar Oct 11 '21 20:10 caoli5288

This could finally work in 21.3. There are some things I have to take care of, like adding support for libEGL in per app deployment and it's also a good idea to wait for this to land upstream.

pal1000 avatar Oct 12 '21 07:10 pal1000

This could finally work in 21.3. There are some things I have to take care of, like adding support for libEGL in per app deployment and it's also a good idea to wait for this to land upstream.

@pal1000 👍

caoli5288 avatar Oct 12 '21 08:10 caoli5288

图片 @pal1000 Hi. It's still not works on 21.3.0-rc2

caoli5288 avatar Oct 25 '21 07:10 caoli5288

Hi I tried building it but it keeps saying hi not found

jezzyjax avatar Oct 01 '22 17:10 jezzyjax

Git not found for mesa3d

jezzyjax avatar Oct 01 '22 17:10 jezzyjax

You need to install Git for Windows to pull source code.

pal1000 avatar Oct 02 '22 10:10 pal1000

I tried that but it says repository not found

On Sun, Oct 2, 2022, 11:24 AM pal1000 @.***> wrote:

You need to install Git for Windows https://git-scm.com/download/win to pull source code.

— Reply to this email directly, view it on GitHub https://github.com/pal1000/mesa-dist-win/issues/52#issuecomment-1264606071, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5D4E64ICXTOXDWIVJSYK3WBFPE5ANCNFSM4Y3DKJFQ . You are receiving this because you commented.Message ID: @.***>

jezzyjax avatar Oct 03 '22 15:10 jezzyjax

I first used the prebuilt files but BlueStacks wouldn't even open, but I did notice that when I deleted the wgl_gallium dll, it would open but say unable to initialize graphics

jezzyjax avatar Oct 03 '22 15:10 jezzyjax

Hi, is Mesa3D currently still using OpenGL 3.1?

Can someone build the latest version of Mesa 3D, please?

Sam3740YT avatar Feb 13 '23 23:02 Sam3740YT

If you mean the compatibility profile that's used by default by most Windows programs, it got further. lllvmpipe supports OpenGL 4.5. zink and d3d12 might still be around OpenGL 3.1.

pal1000 avatar Feb 14 '23 02:02 pal1000

@guanzhangrtk Hello, do you still have the opengl32.dll file?

Sam3740YT avatar Feb 14 '23 19:02 Sam3740YT

@guanzhangrtk Hello, do you still have the opengl32.dll file?

You can just follow the instructions and build it yourself -- it's very easy.

guanzhangrtk avatar Feb 15 '23 03:02 guanzhangrtk

Hello, can you explain to me what I should do here?, please

Workaround misbehaving AV . Browse in Explorer to c:\development\mesa and create a folder named build; . Add c:\development\mesa\build and subdirs to your AV exclusions.

@guanzhangrtk Hello, do you still have the opengl32.dll file?

You can just follow the instructions and build it yourself -- it's very easy.

Hello, can you explain to me what I should do here?, please

Workaround misbehaving AV . Browse in Explorer to c:\development\mesa and create a folder named build; . Add c:\development\mesa\build and subdirs to your AV exclusions.

Sam3740YT avatar Feb 15 '23 06:02 Sam3740YT

How to proceed depends on your AV so I can't give precise instructions about that. Also the build script usage document has seriously bitrotted. I didn't have time to update it for Meson build days.

pal1000 avatar Feb 15 '23 11:02 pal1000

Hi everyone! We now have angleproject, which provides a translation layer from EGL / OpenGLES to D3D9, so it's HW accelerated.

MESA is still a good option. It can provide both WGL / Desktop OpenGL and EGL / OpenGLES, and comes with software renderers (swrast / llvmpipe) and hardware renderers (d3d12), but currently there are some issues like https://github.com/msys2/MINGW-packages/issues/16474

lb90 avatar Mar 27 '23 19:03 lb90