tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RunAtTheBeginningOfShader.cpp (1002B)


      1 //
      2 // Copyright 2020 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 // RunAtTheBeginningOfShader.cpp: Add code to be run at the beginning of the shader.
      7 // void main() { body }
      8 // =>
      9 // void main()
     10 // {
     11 //     codeToRun
     12 //     body
     13 // }
     14 //
     15 
     16 #include "compiler/translator/tree_util/RunAtTheBeginningOfShader.h"
     17 
     18 #include "compiler/translator/Compiler.h"
     19 #include "compiler/translator/IntermNode.h"
     20 #include "compiler/translator/SymbolTable.h"
     21 #include "compiler/translator/tree_util/FindMain.h"
     22 #include "compiler/translator/tree_util/IntermNode_util.h"
     23 #include "compiler/translator/tree_util/IntermTraverse.h"
     24 
     25 namespace sh
     26 {
     27 
     28 bool RunAtTheBeginningOfShader(TCompiler *compiler, TIntermBlock *root, TIntermNode *codeToRun)
     29 {
     30    TIntermFunctionDefinition *main = FindMain(root);
     31    main->getBody()->insertStatement(0, codeToRun);
     32    return compiler->validateAST(root);
     33 }
     34 
     35 }  // namespace sh