Closed LukeUsher closed 7 months ago
Nice, thanks for this. It’s a little unfortunate that slangp shaders don’t work but I wonder if setting glsl_version to something lower may be able help with that… though I assume you’ve already tried that 😕
As an update to this, shaders work on macOS if I remove the following codeblock from compile_shaders.rs
for res in vertex_resources.stage_inputs {
let loc = glsl
.context
.artifact
.vertex
.get_decoration(res.id, Decoration::Location)?;
let mut name = res.name;
name.push('\0');
gl::BindAttribLocation(program, loc, name.as_str().as_ptr().cast())
}
Without removing this, all shaders fail to link with errors due to "Slot 0 unavailable for 'Position'"; removing this causes the layouts defined in the shaders to be used rather than bindings being set manually.
I'm not sure if this will cause any other issues down the line, so I'm reluctant to just commit it; but it allows all the shaders I have tested, including crt-royale actually function.
@chyyran any thoughts? I'm not massively familiar with modern OpenGL so I'm not sure what issues removing calls go glBindAttribLocation could cause.
I recently got access to a macOS laptop I can use for testing so I can do some investigation. Worst case I’ll be bumping the C API version next release to accommodate for new uniforms so I would be happy to expose not binding the vertex inputs explicitly as a filter chain option for OpenGL.
So it turns out the SPIRV-Cross GLSL reflection pipeline was removing attribute location decorations from vertex inputs, so it tried to set 0 as a default for both position
and texcoord
. After fixing that in #44 it seems to work on macOS.
This allows building librashader on macOS and other UNIX targets such as FreeBSD
Note that despite compiling for macOS, the OpenGL drivers on macOS do not seem to be compatible with the slangp shaders; even upstream retroarch only allows glsl shaders on macOS unless using metal.
It may be possible to utilise MoltenVK to use vulkan on macOS, which may be a decent middle ground; but my target project (ares) currently lacks both vulkan and metal driver backends, meaning this is as far as we can get for now.
Even so, this is a step in the right direction and at least allows librashader to load and (attempt) to compile shaders.