Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / compiler / translator / TranslatorHLSL.cpp
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
12 TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
13     : TCompiler(type, spec, output)
14 {
15 }
16
17 void TranslatorHLSL::translate(TIntermNode *root)
18 {
19     TParseContext& parseContext = *GetGlobalParseContext();
20     sh::OutputHLSL outputHLSL(parseContext, getResources(), getOutputType());
21
22     outputHLSL.output();
23
24     attributes      = outputHLSL.getAttributes();
25     outputVariables = outputHLSL.getOutputVariables();
26     uniforms        = outputHLSL.getUniforms();
27     varyings        = outputHLSL.getVaryings();
28     interfaceBlocks = outputHLSL.getInterfaceBlocks();
29
30     mInterfaceBlockRegisterMap = outputHLSL.getInterfaceBlockRegisterMap();
31     mUniformRegisterMap = outputHLSL.getUniformRegisterMap();
32 }
33
34 bool TranslatorHLSL::hasInterfaceBlock(const std::string &interfaceBlockName) const
35 {
36     return (mInterfaceBlockRegisterMap.count(interfaceBlockName) > 0);
37 }
38
39 unsigned int TranslatorHLSL::getInterfaceBlockRegister(const std::string &interfaceBlockName) const
40 {
41     ASSERT(hasInterfaceBlock(interfaceBlockName));
42     return mInterfaceBlockRegisterMap.find(interfaceBlockName)->second;
43 }
44
45 bool TranslatorHLSL::hasUniform(const std::string &uniformName) const
46 {
47     return (mUniformRegisterMap.count(uniformName) > 0);
48 }
49
50 unsigned int TranslatorHLSL::getUniformRegister(const std::string &uniformName) const
51 {
52     ASSERT(hasUniform(uniformName));
53     return mUniformRegisterMap.find(uniformName)->second;
54 }