Open GrahamAsher opened 3 years ago
Yes, it’s fine. It was generated by shader translator to flip the fragcoords from glsl coordinates to metal coordinates. However, the actual flipping code is only inserted if gl_FragCoords is used in your glsl. Thus, if it is unused, the generated varible becomes unused and final metal compiler will complain.
i think this might be a bit irritated because it will generate a warning everytime. Will try to fix it. In the meantime, you can ignore this warning. It won’t cause any real problem.
fyi, there are two stages of glsl compilation:
This recent commit https://github.com/kakashidinho/metalangle/commit/0708a7506663916b0385192fbf12562cdfc193bb solves the unused variable warning. Could you check if it works for you?
I had this issue too, and I can confirm in the newest release the flipped warning no longer appears.
program_source:79:11: warning: unused variable '_uv_linesofar'
float _uv_linesofar = (floor(in._ua_data.z / 4.0) + (in._ua_data.w * 64.0)) * 2.0;
This message however remains.
The warning is due to Metal Clang Compiler compile the glsl source online, and the online compile option "MTLCompileOptions" doesn't have any flags to disable the compiler warning. So, based on "MTLCompileOptions", you cannot disable the warning of "unused variables.......". But , you can disable the warning by inject clang compiler directive "#pragma clang diagnostic ignored \"-Wunused\"" to the shader source string. All you need to do is modify the 3rdParty library "spirv-cross", find file "third_party/spirv-cross/spirv_msl.cpp", search "void CompilerMSL::emit_header()", add statement("#pragma clang diagnostic ignored \"-Wunused\""); in the first line of this function. ReCompile the MetalANGLE, Then all warning disappeared!
I got this warning several times in the debugger console when using the iOS build of MetalANGLE on my iPhone 11:
[Metal Compiler Warning] Warning: Compilation succeeded with:
program_source:59:12: warning: unused variable 'flippedFragCoord' float4 flippedFragCoord;
Otherwise everything worked perfectly, but I think the variable ought to be removed if possible.