Open BorisShir opened 5 years ago
Yes, you need MTLFeatureSet_iOS_GPUFamily3_v1 to set compare sampler support in the objective-c api. https://developer.apple.com/documentation/metal/mtlsamplerdescriptor/1516001-comparefunction?language=objc
You can workaround this limitation by not using compare sampler and doing compare manually in shader (https://github.com/bkaradzic/bgfx/blob/master/examples/15-shadowmaps-simple/fs_sms_shadow.sh#L34)
or using constant sampler inside the shader.
constexpr sampler s(address::clamp_to_zero, filter::linear, compare_func::less);
I don't know if it is possible to generate this kind of sampler with shaderc (glslang/spirv-cross).
One thing that could be changed in renderer_mtl.mm to set BGFX_CAPS_TEXTURE_COMPARE_ALL and BGFX_CAPS_TEXTURE_COMPARE_LEQUAL caps only when api side setting is possible. @bkaradzic https://github.com/bkaradzic/bgfx/blob/master/src/renderer_mtl.mm#L490
I've tried to comment out both BGFX_CAPS_TEXTURE_COMPARE_ALL and BGFX_CAPS_TEXTURE_COMPARE_LEQUAL caps and this doesn't help. I'm still seeing the same error message and crash.
Commenting out caps does nothing inside bgfx. It is helpful for user to get info about what supported using bgfx::getCaps().
As these features are not supported by the metal api (for that feature level), there is no magic solution inside bgfx. You have to modify your shaders or at least shaderc to create a constexpr sampler. This could help: https://github.com/KhronosGroup/SPIRV-Cross/issues/533 It would require modification to shaderc and I am not sure how to pass info about to make a sampler constexpr, maybe some command line flag or naming convention?
Application crashes on iOS devices based on A7 and A8 CPU (iPhone 5S, iPhone 6, iPad Mini 2, iPad Mini 4 and so on).
The error code which I’m seeing is
Error Domain=AGXMetalA7 Code=1 "sampler argument for sample_compare must be known at compile time" UserInfo={NSLocalizedDescription=sampler argument for sample_compare must be known at compile time}
This happens in
bgfx/src/renderer_mtl.h
in methodid<MTLRenderPipelineState> newRenderPipelineStateWithDescriptor
as a result app crashes invoid setRenderPipelineState(id<MTLRenderPipelineState> _pipelineState)
I’ve tried to google and it appears that this message means that some features which require
MTLFeatureSet_iOS_GPUFamily3_v1
support are being used.