icculus / mojoshader

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

Metal: Set ctx to NULL after free #25

Closed TheSpydog closed 4 years ago

TheSpydog commented 4 years ago

This fixes a bug where FNA games that recreate their GraphicsDevice could trigger the assertion on line 345.

flibitijibibo commented 4 years ago

For Metal+D3D11, should we match the GL style here?

https://github.com/FNA-XNA/MojoShader/blob/fna/mojoshader_opengl.c#L2936

TheSpydog commented 4 years ago

What specifically are you referring to? D3D11/Metal are a bit different in that the context functions don't return or receive anything. There's just one global context, so the little ctx / _ctx switcheroo GL does probably isn't necessary here.

flibitijibibo commented 4 years ago

We should probably match GL here - it should take a ctx parameter, where it'll automatically set it to current as it's tearing the context down, but at the same time it should either pop the current ctx back (if there was another one set) or set ctx to NULL. Metal/D3D11 currently delete the active context only. (Also, I think Metal is missing MakeContextCurrent?)

flibitijibibo commented 4 years ago

Pushed to hg https://github.com/FNA-XNA/MojoShader/commit/4c48bffef88e9e2f42bea35be5539d2a3be05c6c