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, getResources(), getOutputType());
24 attributes = outputHLSL.getAttributes();
25 outputVariables = outputHLSL.getOutputVariables();
26 uniforms = outputHLSL.getUniforms();
27 varyings = outputHLSL.getVaryings();
28 interfaceBlocks = outputHLSL.getInterfaceBlocks();
30 mInterfaceBlockRegisterMap = outputHLSL.getInterfaceBlockRegisterMap();
31 mUniformRegisterMap = outputHLSL.getUniformRegisterMap();
34 bool TranslatorHLSL::hasInterfaceBlock(const std::string &interfaceBlockName) const
36 return (mInterfaceBlockRegisterMap.count(interfaceBlockName) > 0);
39 unsigned int TranslatorHLSL::getInterfaceBlockRegister(const std::string &interfaceBlockName) const
41 ASSERT(hasInterfaceBlock(interfaceBlockName));
42 return mInterfaceBlockRegisterMap.find(interfaceBlockName)->second;
45 bool TranslatorHLSL::hasUniform(const std::string &uniformName) const
47 return (mUniformRegisterMap.count(uniformName) > 0);
50 unsigned int TranslatorHLSL::getUniformRegister(const std::string &uniformName) const
52 ASSERT(hasUniform(uniformName));
53 return mUniformRegisterMap.find(uniformName)->second;