Search Issue Tracker
Won't Fix
Votes
0
Found in
2018.4
2018.4.23f1
2020.2
Issue ID
1281058
Regression
No
Using macros and Shader features at the same time causes Shader compile errors
How to reproduce:
1. Open the attached "ShaderVariantsProblem.zip" Project
2. Build and run it on windows, android, or iOS build target
3. Observe the cube in the app
Expected Behavior: The cube is black
Actual Behavior: The cube is white
Reproducible with: 2018.4.27f1, 2019.4.11f1, 2020.1.7f1, 2020.2.0b5
Reproducible devices:
VLNQA00015, Samsung Galaxy Note8 (SM-N950W), Android 8.0.0, CPU: Snapdragon 835 MSM8998, GPU: Adreno (TM) 540
VLNQA00286, Meizu - (PRO 5), Android 7.0, CPU: Exynos 7 Octa 7420, GPU: Mali-T760
VLNQA00285, Samsung Galaxy J4 Core (SM-J410F), Android 8.1.0, CPU: Snapdragon 425 MSM8917, GPU: Adreno (TM) 308
VLNQA00310 iPad Pro 12.9 1st gen (iOS 13.4.1)
Note:
- If the project does not build - it should print a compilation errors showing this issue
- "compile_error.png" Error image attached
- Not reproducible with Dx11
- On Android, it was reproducible both with Vulkan and Gles3
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Shader Graph Node information is briefly displayed in Graph Inspector when clicking on Category in the Blackboard
- Module installation fails with "Download failed: Validation Failed" errors when using beta.2 Hub version
- JsonConvert conversion fails trying to call GetCallbackMethodsForType when [OnDeserialized] is used in a class
- Shader Graph Category dropdown cannot be expanded/collapsed when clicking on the text
- Different text alignment in the column header in Entities "System" window
Resolution Note (2021.1.X):
Unfortunately the shader in this case is using undefined behaviour.
The preprocessors used for shader languages are based on the C and C++ standards. The C and C++ standards declare it is undefined behaviour to have preprocessor directives within macro arguments.
As such, the shader code within the bug is undefined behaviour and may have different results between different shader compilers, versions and platforms.
On some platforms this code will compile and on others it may cause an error and on others it could potentially lead to undesired behaviour.
It is recommended that you re-structure your shader code not to have preprocessor directives within macros arguments.