Path: blob/main_old/src/compiler/translator/ExtensionGLSL.cpp
1693 views
//1// Copyright 2015 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// ExtensionGLSL.cpp: Implements the TExtensionGLSL class that tracks GLSL extension requirements6// of shaders.78#include "compiler/translator/ExtensionGLSL.h"910#include "compiler/translator/VersionGLSL.h"1112namespace sh13{1415TExtensionGLSL::TExtensionGLSL(ShShaderOutput output)16: TIntermTraverser(true, false, false), mTargetVersion(ShaderOutputTypeToGLSLVersion(output))17{}1819const std::set<std::string> &TExtensionGLSL::getEnabledExtensions() const20{21return mEnabledExtensions;22}2324const std::set<std::string> &TExtensionGLSL::getRequiredExtensions() const25{26return mRequiredExtensions;27}2829bool TExtensionGLSL::visitUnary(Visit, TIntermUnary *node)30{31checkOperator(node);3233return true;34}3536bool TExtensionGLSL::visitAggregate(Visit, TIntermAggregate *node)37{38checkOperator(node);3940return true;41}4243void TExtensionGLSL::checkOperator(TIntermOperator *node)44{45if (mTargetVersion < GLSL_VERSION_130)46{47return;48}4950switch (node->getOp())51{52case EOpAbs:53break;5455case EOpSign:56break;5758case EOpMix:59break;6061case EOpFloatBitsToInt:62case EOpFloatBitsToUint:63case EOpIntBitsToFloat:64case EOpUintBitsToFloat:65if (mTargetVersion < GLSL_VERSION_330)66{67// Bit conversion functions cannot be emulated.68mRequiredExtensions.insert("GL_ARB_shader_bit_encoding");69}70break;7172case EOpPackSnorm2x16:73case EOpPackHalf2x16:74case EOpUnpackSnorm2x16:75case EOpUnpackHalf2x16:76if (mTargetVersion < GLSL_VERSION_420)77{78mEnabledExtensions.insert("GL_ARB_shading_language_packing");7980if (mTargetVersion < GLSL_VERSION_330)81{82// floatBitsToUint and uintBitsToFloat are needed to emulate83// packHalf2x16 and unpackHalf2x16 respectively and cannot be84// emulated themselves.85mRequiredExtensions.insert("GL_ARB_shader_bit_encoding");86}87}88break;8990case EOpPackUnorm2x16:91case EOpUnpackUnorm2x16:92if (mTargetVersion < GLSL_VERSION_410)93{94mEnabledExtensions.insert("GL_ARB_shading_language_packing");95}96break;9798default:99break;100}101}102103} // namespace sh104105106