1 / 7

GLSlang compiler

GLSlang compiler. GLSlang Front-End. GL Shading Language compiler front end developed by 3DLabs. Redistribution and use in source and binary forms, with or without modification, are permitted. Ready to build on Linux and Windows Windows → Requires Visual Studio .NET

nratliff
Download Presentation

GLSlang compiler

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GLSlang compiler

  2. GLSlang Front-End • GL Shading Language compiler front end developed by 3DLabs. • Redistribution and use in source and binary forms, with or without modification, are permitted. • Ready to build on Linux and Windows • Windows → Requires Visual Studio .NET • Linux → Compilation problems with libc versión in fargas • By now compiled in Visual Studio .NET

  3. GLSlang compiler source code • It´s completely machine independent code • Code is parsed by flex/bison, with the aid of a symbol table and an intermediate representation • The intermediate representation (IR) is very high-level, and represented as an in memory tree • No lose information from the original program • In the IR constants are propogated and folded... • ... and some dead code is eliminated.

  4. GLSlang compiler source code • The back-end compiler has to traverse the IR-tree and create an internal object code representation. • It has to derive from TCompiler: class TGenericCompiler : public TCompiler { public: TGenericCompiler(EShLanguage l, int dOptions) : TCompiler(l, infoSink), debugOptions(dOptions) { } virtual bool compile(TIntermNode* root); TInfoSink infoSink; int debugOptions; };

  5. GLSlang compiler source code • intermediate.hhas the definition of the IR tree. • Nodes in the IR tree are defined as a hierarchy of classes derived from TIntermNode. • Example: class TIntermLoop : public TIntermNode; represents a loop in the tree. class TIntermOperator : public TIntermTyped; represents an operator in the tree.

  6. GLSlang generic compiler output • A little back end is implemented • Only to print a brief description of the IR tree. • Example (the glslang code): varying vec3 color; void main() { color = vec3(1.0, 1.0, 1.0); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }

  7. GLSlang generic compiler output • The output: #### BEGIN COMPILER 0 INFO LOG #### 0:? Sequence 0:37 Function Definition: main( (void) 0:37 Function Parameters: 0:39 Sequence 0:39 move second child to first child (3-component vector of float) 0:39 'color' (varying 3-component vector of float) 0:39 Construct vec3 (const 3-component vector of float) 0:39 1.000000 (const float) 0:39 1.000000 (const float) 0:39 1.000000 (const float) 0:41 move second child to first child (4-component vector of float) 0:41 'gl_Position' (Position 4-component vector of float) 0:41 matrix-times-vector (4-component vector of float) 0:41 'gl_ModelViewProjectionMatrix' (uniform 4X4 matrix of float) 0:41 'gl_Vertex' (attribute 4-component vector of float) #### END COMPILER 0 INFO LOG #### #### BEGIN LINKER INFO LOG #### #### END LINKER INFO LOG ####

More Related