icculus / mojoshader

Use Direct3D shaders with other 3D rendering APIs.
https://icculus.org/mojoshader/
zlib License
150 stars 37 forks source link

Running with profile glspirv on mac results in unfriendly failure (crash) #67

Open mcclure opened 6 months ago

mcclure commented 6 months ago

We are developing with FNA in C#. In a particular situation, we had a reason to want to force Core profile. Our understanding is in order to run in Core profile, Mojoshader must run with profile "glspirv"

When we tried this, the application failed with a segfault (on one run, we were able to trap it in a debugger reading from a NULL pointer in what appeared to be a mojoshader stack; on repeat runs, I can only get dotnet to terminate with error code 139, indicating a segfault).

Expected behavior

If glspirv is unsupported on some platforms, failure should look like an error printout followed by an exit with error code, not an actual crash.

I am only mostly sure this is happening in mojoshader. If this is actually an FNA bug I could file over there.

Repro

The error may be easily reproduced by taking any FNA test program and adding these lines before creating the Game object.

SDL2.SDL.SDL_SetHint("FNA3D_FORCE_DRIVER", "OpenGL");
SDL2.SDL.SDL_SetHint("FNA3D_OPENGL_FORCE_CORE_PROFILE", "1");
SDL2.SDL.SDL_SetHint("FNA3D_MOJOSHADER_PROFILE", "glspirv");

However, here is the test program (courtesy Love Conquers All Games) I've been using:

test-core-profile.zip

This zip contains prebuilt binaries of FNA3D incorporating mojoshader 7b7e5fd6f3c.

To run this, unzip it, and then from the project directory:

rm -r external/FNA && git clone --depth 1 --branch 24.05 --recurse-submodules https://github.com/FNA-XNA/FNA.git external/FNA
cd helloworld
dotnet run

In our tests, this works fine on Linux, but results in the crash on Mac.