1 // 2 // Copyright 2018 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 // RewriteAtomicFunctionExpressions rewrites the expressions that contain 7 // atomic function calls and cannot be directly translated into HLSL into 8 // several simple ones that can be easily handled in the HLSL translator. 9 // 10 // We need to rewite these expressions because: 11 // 1. All GLSL atomic functions have return values, which all represent the 12 // original value of the shared or ssbo variable; while all HLSL atomic 13 // functions don't, and the original value can be stored in the last 14 // parameter of the function call. 15 // 2. For HLSL atomic functions, the last parameter that stores the original 16 // value is optional except for InterlockedExchange and 17 // InterlockedCompareExchange. Missing original_value in the call of 18 // InterlockedExchange or InterlockedCompareExchange results in a compile 19 // error from HLSL compiler. 20 // 21 // RewriteAtomicFunctionExpressions is a function that can modify the AST 22 // to ensure all the expressions that contain atomic function calls can be 23 // directly translated into HLSL expressions. 24 25 #ifndef COMPILER_TRANSLATOR_TREEOPS_D3D_REWRITE_ATOMIC_FUNCTION_EXPRESSIONS_H_ 26 #define COMPILER_TRANSLATOR_TREEOPS_D3D_REWRITE_ATOMIC_FUNCTION_EXPRESSIONS_H_ 27 28 #include "common/angleutils.h" 29 30 namespace sh 31 { 32 class TCompiler; 33 class TIntermNode; 34 class TSymbolTable; 35 36 ANGLE_NO_DISCARD bool RewriteAtomicFunctionExpressions(TCompiler *compiler, 37 TIntermNode *root, 38 TSymbolTable *symbolTable, 39 int shaderVersion); 40 } // namespace sh 41 42 #endif // COMPILER_TRANSLATOR_TREEOPS_D3D_REWRITE_ATOMIC_FUNCTION_EXPRESSIONS_H_ 43