Hash :
ac5a9c53
Author :
Date :
2022-10-26T00:00:00
Metal: Optimize ReplaceClipCullDistanceVariable The intermediate ANGLEClipDistance variable is not needed when generating MSL output directly. Bug: angleproject:6291 Change-Id: Ie3d32a903645be002f21c44a6233f9cd0155605a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3981716 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Kyle Piddington <kpiddington@apple.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ReplaceClipCullDistanceVariable.h: Find any references to gl_ClipDistance or gl_CullDistance and
// replace it with ANGLEClipDistance or ANGLECullDistance.
//
#ifndef COMPILER_TRANSLATOR_TREEUTIL_REPLACECLIPCULLDISTANCEVARIABLE_H_
#define COMPILER_TRANSLATOR_TREEUTIL_REPLACECLIPCULLDISTANCEVARIABLE_H_
#include "GLSLANG/ShaderLang.h"
#include "common/angleutils.h"
namespace sh
{
struct InterfaceBlock;
class TCompiler;
class TIntermBlock;
class TSymbolTable;
class TIntermTyped;
// Replace every gl_ClipDistance assignment with assignment to "ANGLEClipDistance",
// then at the end of shader re-assign the values of this global variable to gl_ClipDistance.
// This to solve some complex usages such as user passing gl_ClipDistance as output reference
// to a function.
// Furthermore, at the end shader, some disabled gl_ClipDistance[i] can be skipped from the
// assignment.
[[nodiscard]] bool ReplaceClipDistanceAssignments(TCompiler *compiler,
TIntermBlock *root,
TSymbolTable *symbolTable,
const GLenum shaderType,
const TIntermTyped *clipDistanceEnableFlags);
[[nodiscard]] bool ReplaceCullDistanceAssignments(TCompiler *compiler,
TIntermBlock *root,
TSymbolTable *symbolTable,
const GLenum shaderType);
[[nodiscard]] bool ZeroDisabledClipDistanceAssignments(TCompiler *compiler,
TIntermBlock *root,
TSymbolTable *symbolTable,
const GLenum shaderType,
const TIntermTyped *clipDistanceEnableFlags);
} // namespace sh
#endif