1 // 2 // Copyright 2023 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 #ifndef COMPILER_TRANSLATOR_TREEOPS_MSL_REWRITEINTERPOLANTS_H_ 8 #define COMPILER_TRANSLATOR_TREEOPS_MSL_REWRITEINTERPOLANTS_H_ 9 10 #include "compiler/translator/msl/DriverUniformMetal.h" 11 #include "compiler/translator/tree_util/IntermTraverse.h" 12 13 namespace sh 14 { 15 16 // This transformation handles multisample interpolation semantics. 17 // 18 // 1. Types of all fragment inputs used with interpolation functions are adjusted with 19 // an interpolant flag because MSL treats them as a separate type (Section 2.18). 20 // 21 // 2. Offset origin (0, 0) is in the pixel's upper-left corner in Metal but 22 // in the pixel's center in OpenGL ES. Additionally, the Y direction may 23 // be flipped depending on the bound FBO. 24 // 25 // 3. When a fragment input is used with any interpolation function, its regular usages 26 // are wrapped with explicit interpolation functions based on the input's qualifier. 27 // 28 // 4. The outUsesSampleInterpolation variable is set to true if any fragment input 29 // uses sample qualifier. This flag limits gl_SampleMaskIn built-in variable to 30 // the current sample because Metal's [[sample_mask]] always contains all bits. 31 // 32 // 5. The outUsesSampleInterpolant variable is set to true if any fragment input that 33 // has sample qualifier and is used as an argument to an interpolation function is 34 // also used directly. This requires implicitly defining gl_SampleID. 35 [[nodiscard]] bool RewriteInterpolants(TCompiler &compiler, 36 TIntermBlock &root, 37 TSymbolTable &symbolTable, 38 const DriverUniformMetal *driverUniforms, 39 bool *outUsesSampleInterpolation, 40 bool *outUsesSampleInterpolant); 41 42 } // namespace sh 43 44 #endif // COMPILER_TRANSLATOR_TREEOPS_MSL_REWRITEINTERPOLANTS_H_ 45