o3de / o3de-extras

Other
63 stars 63 forks source link

Adreno-based XR devices: VkCreateGraphicsPipelines returns VK_ERROR_UNKNOWN for PBR shaders. #625

Open galibzon opened 1 year ago

galibzon commented 1 year ago

Describe the bug It was found that meshes with PBR materials don't render when the game project is deployed and executed natively on Meta Quest Pro devices.

Workaround: Use DXC 1.6.2112 instead of the current one DXC 1.7.2308. I'm working on a PR that would allow to customize DXC via a settings registry.

Assets required OpenXRTest game project.

Steps to reproduce Compile and deploy OpenXRTest game project on an Meta Quest Pro or Quest3 device.

Expected behavior The DefaultLevel has a SkyBox, a Grid, a Plane and a ShaderBall. All of them should be visible.

Actual behavior Only the SkyBox and the Grid are visible. The Plane and the ShaderBall are not visible.

Screenshots/Video If applicable, add screenshots and/or a video to help explain your problem.

Found in Branch o3de/development: commit e5a4c9482a2fee04d15584e7bdc5dd79297fbb60 o3de-extras/development: commit a30927eacedc73096599472c52f26828bf9ca67f

Desktop/Device (please complete the following information):

Additional context After noticing the missing meshes when running OpenXRTest on the Meta Quest Pro, I decided to debug with Android Studio.

The error occurred here, when executing VkCreateGraphicsPipelines, which returned VK_ERROR_UNKNOWN:
https://github.com/o3de/o3de/blob/1fea4bc55837d7ea0091b294dc3c17661806aeaa/Gems/Atom/RHI/Vulkan/Code/Source/RHI/GraphicsPipeline.cpp#L109
The shader name was: standardpbr_multiviewpipeline_forwardpass_standardlighting.

<12:25:26> [Error] (PipelineStateCache) - Failed to compile pipeline state. It will remain in an initialized state.
And then endless print outs of
<12:25:26> [Warning] (CommandList) - Failed to bind shader resources for draw item. Skipping.

Found a similar error as described here: https://developer.qualcomm.com/forum/qdn-forums/software/adreno-gpu-sdk/68860 They suggest as a solution to code the shaders directly in GLSL instead of HLSL to GLSL (which is not an option for us). That gave me the hint to revert to the older version of DXC and voila' everything worked again.

I also tried to use the Adreno Offline Compiler and compare the results between the same shader compiled with DXC 1.6.2112 vs DXC 1.7.2308. Unfortunately both versions of the shaders produced the following errors when using AOC:
Result for shaders compiled with DXC1.6.2112 (The good DXC):

    Adreno Offline Compiler (AOC)
    -----------------------------
    AOC Version     : 3.0
    Compiler Version: E031.42.19.00

Assertion failed: RegIndex == SHARED_CONST_BEGIN && "RegIndex is hard coded to c504.x during Metadata generation"
FATAL ERROR: Internal assertion error

Compilation failed.

Result for shaders compiled with DXC1.7.2308 (The "bad" DXC):

    Adreno Offline Compiler (AOC)
    -----------------------------
    AOC Version     : 3.0
    Compiler Version: E031.42.19.00

Assertion failed: false && "Unsupported Instruction in Fast Isel"
FATAL ERROR: Internal assertion error

Compilation failed.

As mentioned above the workaround is to use DXC1.6.2112 so I'm working on a feature to allow developers to customize which DXC version to use via a Settings Registry. This will buy us some time while I try to get help from Qualcomm.

galibzon commented 1 year ago

FYI @moudgils , @jhmueller-huawei