• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
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.
5 //
6 
7 #include "compiler/translator/TranslatorHLSL.h"
8 
9 #include "compiler/translator/InitializeParseContext.h"
10 #include "compiler/translator/OutputHLSL.h"
11 
TranslatorHLSL(sh::GLenum type,ShShaderSpec spec,ShShaderOutput output)12 TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
13     : TCompiler(type, spec, output)
14 {
15 }
16 
translate(TIntermNode * root)17 void TranslatorHLSL::translate(TIntermNode *root)
18 {
19     TParseContext& parseContext = *GetGlobalParseContext();
20     sh::OutputHLSL outputHLSL(parseContext, this);
21 
22     outputHLSL.output();
23 
24     mInterfaceBlockRegisterMap = outputHLSL.getInterfaceBlockRegisterMap();
25     mUniformRegisterMap = outputHLSL.getUniformRegisterMap();
26 }
27 
hasInterfaceBlock(const std::string & interfaceBlockName) const28 bool TranslatorHLSL::hasInterfaceBlock(const std::string &interfaceBlockName) const
29 {
30     return (mInterfaceBlockRegisterMap.count(interfaceBlockName) > 0);
31 }
32 
getInterfaceBlockRegister(const std::string & interfaceBlockName) const33 unsigned int TranslatorHLSL::getInterfaceBlockRegister(const std::string &interfaceBlockName) const
34 {
35     ASSERT(hasInterfaceBlock(interfaceBlockName));
36     return mInterfaceBlockRegisterMap.find(interfaceBlockName)->second;
37 }
38 
hasUniform(const std::string & uniformName) const39 bool TranslatorHLSL::hasUniform(const std::string &uniformName) const
40 {
41     return (mUniformRegisterMap.count(uniformName) > 0);
42 }
43 
getUniformRegister(const std::string & uniformName) const44 unsigned int TranslatorHLSL::getUniformRegister(const std::string &uniformName) const
45 {
46     ASSERT(hasUniform(uniformName));
47     return mUniformRegisterMap.find(uniformName)->second;
48 }
49