1//
2// Copyright (c) 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_REWRITE_ATOMIC_FUNCTION_EXPRESSIONS_H_
26#define COMPILER_TRANSLATOR_TREEOPS_REWRITE_ATOMIC_FUNCTION_EXPRESSIONS_H_
27
28namespace sh
29{
30class TIntermNode;
31class TSymbolTable;
32
33void RewriteAtomicFunctionExpressions(TIntermNode *root,
34 TSymbolTable *symbolTable,
35 int shaderVersion);
36} // namespace sh
37
38#endif // COMPILER_TRANSLATOR_TREEOPS_REWRITE_ATOMIC_FUNCTION_EXPRESSIONS_H_