2 // Copyright (c) 2002-2013 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.
7 #include "compiler/translator/TranslatorHLSL.h"
9 #include "compiler/translator/InitializeParseContext.h"
10 #include "compiler/translator/OutputHLSL.h"
12 TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
13 : TCompiler(type, spec, output)
17 void TranslatorHLSL::translate(TIntermNode *root)
19 TParseContext& parseContext = *GetGlobalParseContext();
20 sh::OutputHLSL outputHLSL(parseContext, this);
24 mInterfaceBlockRegisterMap = outputHLSL.getInterfaceBlockRegisterMap();
25 mUniformRegisterMap = outputHLSL.getUniformRegisterMap();
28 bool TranslatorHLSL::hasInterfaceBlock(const std::string &interfaceBlockName) const
30 return (mInterfaceBlockRegisterMap.count(interfaceBlockName) > 0);
33 unsigned int TranslatorHLSL::getInterfaceBlockRegister(const std::string &interfaceBlockName) const
35 ASSERT(hasInterfaceBlock(interfaceBlockName));
36 return mInterfaceBlockRegisterMap.find(interfaceBlockName)->second;
39 bool TranslatorHLSL::hasUniform(const std::string &uniformName) const
41 return (mUniformRegisterMap.count(uniformName) > 0);
44 unsigned int TranslatorHLSL::getUniformRegister(const std::string &uniformName) const
46 ASSERT(hasUniform(uniformName));
47 return mUniformRegisterMap.find(uniformName)->second;