I'm working on a UE4 project. By default UE4 compile its shader to spirv binary by hlslcc + glslang, but in this way the generated spirv shader is suboptimal so I want to use shaderconductor(DXC) to compile hlsl directly to spirv (just like what UE5 does: Unreal Engine 5.0 Release Notes | Unreal Engine 5.0 Documentation)
After I use DXC, the project works pretty well on adreno devices, but it will crash on mali deviecs. I have tried these devices, the all failed to create pipeline (both compute ppl and graphics ppl) with VK_ERROR_INITIALIZATION_FAILED:
The khr spec states that create pipeline should only return the following errors:
and also adreno devices works well, so I guess this might be mali driver bugs.
I have no clue what's goes wrong with generated spirv binary and it seems I can't get enough error information from vulkan, so I need to ask help from mali experts.
I can send you the apk that can produce the failure so if you are interested please leave me a email address. Thanks in advance!
Hi Peter, thanks for your reply. I sent the apk and my mali devices/driver version to developer@arm.com
Thanks for the shader!
It appears the problem is with the SPV_GOOGLE_user_type extension, which we do not support, being used. Based on the DXC documentation they will add this if -fspv-reflect is passed -- which UE will pass by default. However, UE5 will also later strip out the use of the extension before passing the shader to the Vulkan driver. If you look in `Engine/Source/Developer/VulkanShaderFormat/Private/VulkanShaderCompiler.cpp` in UE5 you can find the code that does this (look for `bStripReflect`).
So, I think your best bet here might be to backport the stripping from UE5 to UE4 if you want to try to use DXC in UE4. Hope that helps :)
Thanks christian! Yes I'm aware the UE5 has extra pass to strip these extension and debug symbols, but I thought it's only used for mali offline compiler because the variable bStripReflect is defined by SupportsOfflineCompiler. Also I thought the "online" compiler in the driver can silently skip this unsupported extension because I saw the extension spec says "This has no semantic impact": SPIRV-Registry/SPV_GOOGLE_user_type.asciidoc at main · KhronosGroup/SPIRV-Registry (github.com) So it turns out I might be wrong. I can try add similiar pass in UE4 and check if it can fix the problem. I will reach you once I have some progress. Thanks for your important insights again!