-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uniform num broken on Mac OS 12.6 arm64/Vulkan by #2883/#2885 #2964
Comments
cc @cloudwu |
I think the reason is that the https://github.com/bkaradzic/bgfx/blob/master/tools/shaderc/shaderc_spirv.cpp#L655 It should be metal : https://github.com/bkaradzic/bgfx/blob/master/tools/shaderc/shaderc_metal.cpp#L455 I read the history, and found the PR #2421 changed this behavior. (It's strange that this PR changed Vulkan backend only) PR #2885 use But if you decalre an array of matrix |
Yeah, I need to get some better way of handling this reflection, and figure out how to unit test it. |
@jdah What changes you needed to add to bgfx to build with MoltenVK? |
None, IIRC - BGFX is set to target Vulkan and then you use the MoltenVK dynamic library (from (MoltenVK Path)/dylib/macOS/libMoltenVK.dylib) alongside the application |
Related to the uniform array size limitation, I think there's some slight inconsistent behavior between the Metal and Vulkan backend for predefined uniforms. In Metal, if your array is sized > 255, it is handled because the m_count value comes from the Metal reflection. In Vulkan, the value wraps around because it comes from regCount which is limited to uint8 here, since it is equal to Uniform::num. Just mentioning this because currently you will see predefined arrays sized > 255 work fine on Metal but break in Vulkan. This happens ie if you define BGFX_CONFIG_MAX_BONES to be 256. |
Describe the bug
Shaders which declare a uniform array
uniform vec4 u_array[3]
now report anum
(frombgfx::getUniformInfo
) of1
instead of3
as expected. I have tested in my own code (by reverting the change) and the issue came from #2883 (PR #2885) whereregCount
was replaced withnum
to fix array sizes.To Reproduce
vec4 ...[n]
somewherenum
withbgfx::getUniformUnfo
num != n
Expected behavior
num == n
Additional context
Tested on Mac OS Monterey/12.6, M1 Pro/arm64, MoltenVK (Vulkan backend!), latest bgfx
will hopefully come back with further details/proposed fix.
The text was updated successfully, but these errors were encountered: