Put all glslang internals (but not the external interface) into the glslang namespace.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22882 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
23bdb29eac
commit
b603f918a4
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
#include "Public/ShaderLang.h"
|
#include "Public/ShaderLang.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||||
|
|
||||||
bool InitProcess()
|
bool InitProcess()
|
||||||
@ -144,3 +146,5 @@ bool DetachProcess()
|
|||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -37,11 +37,14 @@
|
|||||||
|
|
||||||
#include "osinclude.h"
|
#include "osinclude.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
bool InitProcess();
|
bool InitProcess();
|
||||||
bool InitThread();
|
bool InitThread();
|
||||||
bool DetachThread();
|
bool DetachThread();
|
||||||
bool DetachProcess();
|
bool DetachProcess();
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // __INITIALIZEDLL_H
|
#endif // __INITIALIZEDLL_H
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ ShBinding FixedAttributeBindings[] = {
|
|||||||
|
|
||||||
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
|
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
|
||||||
|
|
||||||
static EShLanguage FindLanguage(const std::string& name);
|
EShLanguage FindLanguage(const std::string& name);
|
||||||
bool CompileFile(const char *fileName, ShHandle, int options, const TBuiltInResource*);
|
bool CompileFile(const char *fileName, ShHandle, int options, const TBuiltInResource*);
|
||||||
void usage();
|
void usage();
|
||||||
void FreeFileData(char **data);
|
void FreeFileData(char **data);
|
||||||
@ -232,7 +232,7 @@ int C_DECL main(int argc, char* argv[])
|
|||||||
// .geom = geometry
|
// .geom = geometry
|
||||||
// .frag = fragment
|
// .frag = fragment
|
||||||
//
|
//
|
||||||
static EShLanguage FindLanguage(const std::string& name)
|
EShLanguage FindLanguage(const std::string& name)
|
||||||
{
|
{
|
||||||
size_t ext = name.rfind('.');
|
size_t ext = name.rfind('.');
|
||||||
if (ext == std::string::npos) {
|
if (ext == std::string::npos) {
|
||||||
|
@ -78,6 +78,6 @@ namespace glslang {
|
|||||||
std::list<std::string> worklist;
|
std::list<std::string> worklist;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // WORKLIST_H_INCLUDED
|
#endif // WORKLIST_H_INCLUDED
|
||||||
|
91
Todo.txt
91
Todo.txt
@ -9,40 +9,43 @@ Performance
|
|||||||
Testing
|
Testing
|
||||||
- thread safety
|
- thread safety
|
||||||
|
|
||||||
Interfacing
|
Link Validation
|
||||||
- finish putting into a glslang namespace
|
|
||||||
|
|
||||||
Shader Linking Validation
|
|
||||||
- ensure no static references thrown away
|
- ensure no static references thrown away
|
||||||
Cross-stage linking
|
Cross-stage linking
|
||||||
- type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching
|
- type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching
|
||||||
- location/binding/index check
|
- location/binding/index check
|
||||||
- matching initializers for uniforms
|
- matching initializers for uniforms
|
||||||
- mixed es/non-es profiles
|
- mixed es/non-es profiles
|
||||||
- statically consumed input not produced by previous stage
|
- statically consumed input not produced by previous stage
|
||||||
- matching between gl_PerVertex blocks and gl_PerFragment blocks
|
- matching between gl_PerVertex blocks and gl_PerFragment blocks
|
||||||
- compute shader not with other stages
|
- compute shader not with other stages
|
||||||
Intra-stage linking
|
- 1.3: deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
|
||||||
- exactly one main
|
- 4.3: remove cross-version linking restrictions.
|
||||||
- type consistency check of uniforms, globals, ins, and outs, both variables and blocks
|
- 4.3: Allow mismatches in interpolation and auxiliary qualification across stages.
|
||||||
- location/component/binding/index/offset match check
|
Intra-stage linking
|
||||||
- location/component aliasing (except desktop vertex shader inputs)
|
- exactly one main
|
||||||
- geometry shader input array sizes and input layout qualifier declaration
|
- type consistency check of uniforms, globals, ins, and outs, both variables and blocks
|
||||||
- compute shader layout(local_size_*) matching
|
- location/component/binding/index/offset match check
|
||||||
- mixed es/non-es profiles
|
- location/component aliasing (except desktop vertex shader inputs)
|
||||||
- matching initializers for globals
|
- geometry shader input array sizes and input layout qualifier declaration
|
||||||
- recursion for both functions and subroutines
|
- compute shader layout(local_size_*) matching
|
||||||
- matching redeclarations of interface blocks
|
- mixed es/non-es profiles
|
||||||
- read or write to both gl_ClipVertex and gl_ClipDistance
|
- matching initializers for globals
|
||||||
- write to only one of gl_FragColor, gl_FragData, or user-declared
|
- recursion for both functions and subroutines
|
||||||
- 4.4: overlapping transform/feedback offsets, offset/stride overflow checks, and stride matching
|
- Even the potential for recursion through subroutine uniforms is an error.
|
||||||
|
- matching redeclarations of interface blocks
|
||||||
|
- read or write to both gl_ClipVertex and gl_ClipDistance
|
||||||
|
- write to only one of gl_FragColor, gl_FragData, or user-declared
|
||||||
|
- 4.3: Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
|
||||||
|
- 4.3: Be clear that implicit array sizing is only within a stage, not cross stage.
|
||||||
|
- 4.4: overlapping transform/feedback offsets, offset/stride overflow checks, and stride matching
|
||||||
|
|
||||||
Functionality to Implement/Finish
|
Shader Functionality to Implement/Finish
|
||||||
ESSL 3.0
|
ESSL 3.0
|
||||||
- "const" compile-time constant propagation in the front-end has to be complete, for all built-in functions
|
- "const" compile-time constant propagation in the front-end has to be complete, for all built-in functions
|
||||||
GLSL 1.2
|
GLSL 1.2
|
||||||
- Handle multiple compilation units per stage
|
- Handle multiple compilation units per stage
|
||||||
- Allow initializers on uniform declarations. The value is set at link time.
|
- Allow initializers on uniform declarations
|
||||||
- signature matching takes type conversions into account, ambiguity is an error
|
- signature matching takes type conversions into account, ambiguity is an error
|
||||||
GLSL 1.3
|
GLSL 1.3
|
||||||
. flat is for both user and predeclared built-in in/out variables
|
. flat is for both user and predeclared built-in in/out variables
|
||||||
@ -51,7 +54,6 @@ Functionality to Implement/Finish
|
|||||||
- non-perspective (linear) interpolation (noperspective)
|
- non-perspective (linear) interpolation (noperspective)
|
||||||
- add gl_ClipDistance[] to both vertex and fragment shaders
|
- add gl_ClipDistance[] to both vertex and fragment shaders
|
||||||
- only statically used built-ins have to be redeclared as flat
|
- only statically used built-ins have to be redeclared as flat
|
||||||
- Link: Deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
|
|
||||||
- Deprecated gl_ClipVertex
|
- Deprecated gl_ClipVertex
|
||||||
- deprecate almost all built-in state
|
- deprecate almost all built-in state
|
||||||
- ftransform() is deprecated
|
- ftransform() is deprecated
|
||||||
@ -71,14 +73,13 @@ Functionality to Implement/Finish
|
|||||||
rather than relying on gl_MaxVaryingComponents. Also, corrected gl_MaxVaryingComponents to be 60 instead of 64.
|
rather than relying on gl_MaxVaryingComponents. Also, corrected gl_MaxVaryingComponents to be 60 instead of 64.
|
||||||
- Added gl_PrimitiveID as an input to fragment shaders.
|
- Added gl_PrimitiveID as an input to fragment shaders.
|
||||||
- Added gl_FragCoord qualifiers origin_upper_left, and pixel_center_integer to modify the values returned by gl_FragCoord (and have no affect on any other aspect of the pipeline or language).
|
- Added gl_FragCoord qualifiers origin_upper_left, and pixel_center_integer to modify the values returned by gl_FragCoord (and have no affect on any other aspect of the pipeline or language).
|
||||||
- including redeclaration of gl_FragCoord that adds nothing
|
- including redeclaration of gl_FragCoord that adds nothing
|
||||||
- Added support for multi-sample textures through sampler2DMS and sampler2DMSArray support in texelFetch() and textureSize().
|
- Added support for multi-sample textures through sampler2DMS and sampler2DMSArray support in texelFetch() and textureSize().
|
||||||
- Broadened interface blocks from just uniforms to in and out interfaces as well.
|
- Broadened interface blocks from just uniforms to in and out interfaces as well.
|
||||||
- Broaden array usage to include vertex shader inputs (vertex in).
|
- Broaden array usage to include vertex shader inputs (vertex in).
|
||||||
- Added geometry shaders. This includes targeting layers in FBO rendering.
|
- Added geometry shaders. This includes targeting layers in FBO rendering.
|
||||||
- geometry shader layouts: they must be declared, telling the system the primitive input and output types and maximum number of vertices.
|
- geometry shader layouts: they must be declared, telling the system the primitive input and output types and maximum number of vertices.
|
||||||
- Added geometry shader constants.
|
- Added geometry shader constants.
|
||||||
- gl_FragCoord qualifiers use the layout(): origin_upper_left and pixel_center_integer.
|
|
||||||
- Broaden structure usage to include geometry inputs and geometry outputs.
|
- Broaden structure usage to include geometry inputs and geometry outputs.
|
||||||
GLSL 4.0
|
GLSL 4.0
|
||||||
- tessellation control stage and tessellation evaluation stage. Includes barrier() built-in for synchronization.
|
- tessellation control stage and tessellation evaluation stage. Includes barrier() built-in for synchronization.
|
||||||
@ -93,7 +94,7 @@ Functionality to Implement/Finish
|
|||||||
- Sampler arrays can take a variable index now, as long as it's value is uniform for all uses.
|
- Sampler arrays can take a variable index now, as long as it's value is uniform for all uses.
|
||||||
- Per-sample shading. Including sample input mask gl_SampleMaskIn[] and per-sample interpolation, with explicit interpolation built-ins interpolateAtCentroid(), interpolateAtSample(), and interpolateAtOffset().
|
- Per-sample shading. Including sample input mask gl_SampleMaskIn[] and per-sample interpolation, with explicit interpolation built-ins interpolateAtCentroid(), interpolateAtSample(), and interpolateAtOffset().
|
||||||
- New precise qualifier to disallow optimizations that re-order operations or treat different instances of the same operator with different precision.
|
- New precise qualifier to disallow optimizations that re-order operations or treat different instances of the same operator with different precision.
|
||||||
- Add a fused multiply andadd built-in, fma(), in relation to the new precise qualifier. (Because “a * b + c” will require two operations under new rules for precise.)
|
- Add a fused multiply and add built-in, fma(), in relation to the new precise qualifier. (Because “a * b + c” will require two operations under new rules for precise.)
|
||||||
- Added new built-in floating-point functions
|
- Added new built-in floating-point functions
|
||||||
- frexp() and ldexp()
|
- frexp() and ldexp()
|
||||||
- packUnorm2x16(), packUnorm4x8(),packSnorm4x8(), and packDouble2x32()
|
- packUnorm2x16(), packUnorm4x8(),packSnorm4x8(), and packDouble2x32()
|
||||||
@ -115,13 +116,13 @@ Functionality to Implement/Finish
|
|||||||
GLSL 4.1
|
GLSL 4.1
|
||||||
- Support for partitioning shaders into multiple programs to provide light-weight mixing of different shader stages.
|
- Support for partitioning shaders into multiple programs to provide light-weight mixing of different shader stages.
|
||||||
(GL_ARB_separate_shader_objects)
|
(GL_ARB_separate_shader_objects)
|
||||||
- layout qualifiers
|
- layout qualifiers
|
||||||
- redeclaration of input/output blocks
|
- redeclaration of input/output blocks
|
||||||
- ...
|
- ...
|
||||||
- Add 64-bit floating-point attributes for vertex shader inputs.
|
- Add 64-bit floating-point attributes for vertex shader inputs.
|
||||||
- Support viewport arrays so where the geometry shader selects which viewport array will transform its output.
|
- Support viewport arrays so where the geometry shader selects which viewport array will transform its output.
|
||||||
GLSL 4.2
|
GLSL 4.2
|
||||||
- Add 420-style function signature matching rules
|
- Add 420-style function signature matching rules (or did this start in 4.0?)
|
||||||
+ Move these previously deprecated features to be only in the compatibility profile:
|
+ Move these previously deprecated features to be only in the compatibility profile:
|
||||||
+ The keyword attribute for vertex shader inputs. (Use in instead.)
|
+ The keyword attribute for vertex shader inputs. (Use in instead.)
|
||||||
+ The keyword varying for inputs and outputs. (Use in and out instead.)
|
+ The keyword varying for inputs and outputs. (Use in and out instead.)
|
||||||
@ -129,7 +130,7 @@ Functionality to Implement/Finish
|
|||||||
+ The built-in variables gl_FragColor and gl_FragData. (Use out instead.)
|
+ The built-in variables gl_FragColor and gl_FragData. (Use out instead.)
|
||||||
+ Built-in constants related to these.
|
+ Built-in constants related to these.
|
||||||
+ Change from ASCII to UTF-8 for the language character set and also allow any characters inside comments (except the byte value 0),
|
+ Change from ASCII to UTF-8 for the language character set and also allow any characters inside comments (except the byte value 0),
|
||||||
including '\'.
|
including '\'.
|
||||||
+ Add line-continuation using '\', as in C++.
|
+ Add line-continuation using '\', as in C++.
|
||||||
+ ES convergence
|
+ ES convergence
|
||||||
+ Clarify that .xyzwxy.xy is illegal, as it temporarily makes a “vec6”.
|
+ Clarify that .xyzwxy.xy is illegal, as it temporarily makes a “vec6”.
|
||||||
@ -140,7 +141,7 @@ Functionality to Implement/Finish
|
|||||||
- can read/write/modify images from a shader, through new built-in functions
|
- can read/write/modify images from a shader, through new built-in functions
|
||||||
- qualifiers can act independently on the opaque shader variable and the backing image, so extra qualifiers can be used to separately qualify these
|
- qualifiers can act independently on the opaque shader variable and the backing image, so extra qualifiers can be used to separately qualify these
|
||||||
+ Variables declared in if and else statements are scoped only to the end of those statements, especially for non-compound statements
|
+ Variables declared in if and else statements are scoped only to the end of those statements, especially for non-compound statements
|
||||||
Note, this is not backward compatible, it may depend on #version.
|
Note, this is not backward compatible, it may depend on #version.
|
||||||
- Allow implicit conversions of return values to the declared type of the function.
|
- Allow implicit conversions of return values to the declared type of the function.
|
||||||
- The const keyword can be used to declare variables within a function body with initializer expressions that are not constant expressions.
|
- The const keyword can be used to declare variables within a function body with initializer expressions that are not constant expressions.
|
||||||
+ Qualifiers on variable declarations no longer have to follow a strict order. The layout qualifier can be used multiple times, and multiple parameter qualifiers can be used.
|
+ Qualifiers on variable declarations no longer have to follow a strict order. The layout qualifier can be used multiple times, and multiple parameter qualifiers can be used.
|
||||||
@ -156,7 +157,6 @@ Functionality to Implement/Finish
|
|||||||
- Allow .length() to be applied to vectors and matrices, returning the number of components or columns.
|
- Allow .length() to be applied to vectors and matrices, returning the number of components or columns.
|
||||||
+ Clarify that .length() returns an int type and can be used as a constant integer expression.
|
+ Clarify that .length() returns an int type and can be used as a constant integer expression.
|
||||||
- Allow swizzle operations on scalars.
|
- Allow swizzle operations on scalars.
|
||||||
- Even the potential for recursion through subroutine uniforms is an error.
|
|
||||||
- Positive signed decimal literals, as well as octal and hexadecimal, can set all 32 bits. This includes setting the sign bit to create a negative value.
|
- Positive signed decimal literals, as well as octal and hexadecimal, can set all 32 bits. This includes setting the sign bit to create a negative value.
|
||||||
- Make GLSL consistent with the API regarding user clipping, by no longer referring to gl_Positionwhen gl_ClipVertex is not written. Rather, user clipping becomes undefined.
|
- Make GLSL consistent with the API regarding user clipping, by no longer referring to gl_Positionwhen gl_ClipVertex is not written. Rather, user clipping becomes undefined.
|
||||||
- Minor consistency fixes, corrections
|
- Minor consistency fixes, corrections
|
||||||
@ -188,38 +188,29 @@ Functionality to Implement/Finish
|
|||||||
GL_ARB_explicit_uniform_location extension.
|
GL_ARB_explicit_uniform_location extension.
|
||||||
- Accept ES GLSL shader #version statements, which will request ES functionality for ES GLSL
|
- Accept ES GLSL shader #version statements, which will request ES functionality for ES GLSL
|
||||||
versions 100 and 300, as per the GL_ARB_ES3_compatibility extension.
|
versions 100 and 300, as per the GL_ARB_ES3_compatibility extension.
|
||||||
- Clarified about 90 errors as being either compile time, link time, or either.
|
|
||||||
- Clarify and correct scoping rules to what would normally be expected and what was intended.
|
- Clarify and correct scoping rules to what would normally be expected and what was intended.
|
||||||
(Function parameters and body nest inside global space. Loop variables and body nest inside
|
(Function parameters and body nest inside global space. Loop variables and body nest inside
|
||||||
loop scope.)
|
loop scope.)
|
||||||
- There are no digraphs (trigraphs were already disallowed).
|
- There are no digraphs (trigraphs were already disallowed).
|
||||||
- Remove the CPP difference that it is a compile-time error to use #if or #elif on expressions
|
- Remove the CPP difference that it is a compile-time error to use #if or #elif on expressions
|
||||||
containing undefined macro names. This reverts back to following expected CPP behavior.
|
containing undefined macro names. This reverts back to following expected CPP behavior.
|
||||||
- Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniformsto 8.
|
- Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniforms to 8.
|
||||||
- Clarify textureSize() for cube map arrays.
|
- Clarify textureSize() for cube map arrays.
|
||||||
- For layout qualifiers,
|
- For layout qualifiers,
|
||||||
- make negative output locations a compile-time error, and
|
- make negative output locations a compile-time error, and
|
||||||
- make indexes outside the range [0,1] a compile-time error.
|
- make indexes outside the range [0,1] a compile-time error.
|
||||||
- Allow mismatches in interpolation and auxiliary qualification across stages.
|
|
||||||
- Remove cross-version linking restrictions.
|
|
||||||
- Add textureQueryLevels() built-ins to query the number of mipmap levels, as per the
|
- Add textureQueryLevels() built-ins to query the number of mipmap levels, as per the
|
||||||
GL_ARB_texture_query_levels extension.
|
GL_ARB_texture_query_levels extension.
|
||||||
- Make gl_Layer and gl_ViewportIndex also be inputs to the fragment shader, as per the
|
- Make gl_Layer and gl_ViewportIndex also be inputs to the fragment shader, as per the
|
||||||
GL_ARB_fragment_layer_viewport extension.
|
GL_ARB_fragment_layer_viewport extension.
|
||||||
- Be explicit that compile-time constant expressions evaluating on the host may get a different
|
|
||||||
value than the same expression on the target. Also reinforce that compile-time constant
|
|
||||||
expressions are evaluated as if precise and invariantwere used.
|
|
||||||
- Add more examples and rules to be more specific about the required behavior of the precise
|
- Add more examples and rules to be more specific about the required behavior of the precise
|
||||||
qualifier.
|
qualifier.
|
||||||
- Clarify fragment output variables cannot be double precision.
|
- Clarify fragment output variables cannot be double precision.
|
||||||
- Clarify that “floating-point” generally means both single- and double-precision and be more
|
|
||||||
consistent with that.
|
|
||||||
- Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
|
|
||||||
- Allow the new shared keyword to be in layout-qualifier-id, allowing backward compatibility
|
- Allow the new shared keyword to be in layout-qualifier-id, allowing backward compatibility
|
||||||
with the shared identifier that was previously used.
|
with the shared identifier that was previously used.
|
||||||
+ Added overlooked texture function float textureOffset (sampler2DArrayShadow sampler, vec4 P, vec2 offset [, float bias] ).
|
+ Added overlooked texture function float textureOffset (sampler2DArrayShadow sampler, vec4 P, vec2 offset [, float bias] ).
|
||||||
+ Add missing type in grammar, ATOMIC_UINT, and missing qualifiers COHERENT, VOLATILE, RESTRICT, READONLY, and WRITEONLY.
|
+ Add missing type in grammar, ATOMIC_UINT, and missing qualifiers COHERENT, VOLATILE, RESTRICT, READONLY, and WRITEONLY.
|
||||||
- do version checking for the above
|
- do version checking for the above
|
||||||
+ Add missing initializer lists to grammar.
|
+ Add missing initializer lists to grammar.
|
||||||
GLSL 4.4
|
GLSL 4.4
|
||||||
- Incorporate the ARB_enhanced_layouts extension, which adds
|
- Incorporate the ARB_enhanced_layouts extension, which adds
|
||||||
|
@ -188,7 +188,6 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test</Command>
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="glslang\MachineIndependent\glslang_tab.cpp.h" />
|
<ClInclude Include="glslang\MachineIndependent\glslang_tab.cpp.h" />
|
||||||
<ClInclude Include="glslang\MachineIndependent\Initialize.h" />
|
<ClInclude Include="glslang\MachineIndependent\Initialize.h" />
|
||||||
<ClInclude Include="glslang\MachineIndependent\MMap.h" />
|
|
||||||
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h" />
|
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h" />
|
||||||
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h" />
|
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h" />
|
||||||
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h" />
|
<ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h" />
|
||||||
|
@ -114,9 +114,6 @@
|
|||||||
<ClInclude Include="glslang\MachineIndependent\Initialize.h">
|
<ClInclude Include="glslang\MachineIndependent\Initialize.h">
|
||||||
<Filter>Machine Independent</Filter>
|
<Filter>Machine Independent</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="glslang\MachineIndependent\MMap.h">
|
|
||||||
<Filter>Machine Independent</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h">
|
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h">
|
||||||
<Filter>Machine Independent</Filter>
|
<Filter>Machine Independent</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
#ifndef _BASICTYPES_INCLUDED_
|
#ifndef _BASICTYPES_INCLUDED_
|
||||||
#define _BASICTYPES_INCLUDED_
|
#define _BASICTYPES_INCLUDED_
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this.
|
// Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this.
|
||||||
//
|
//
|
||||||
@ -97,7 +99,7 @@ enum TStorageQualifier {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// These will show up in error messages
|
// These will show up in error messages
|
||||||
__inline const char* getStorageQualifierString(TStorageQualifier q)
|
__inline const char* GetStorageQualifierString(TStorageQualifier q)
|
||||||
{
|
{
|
||||||
switch (q) {
|
switch (q) {
|
||||||
case EvqTemporary: return "temporary"; break;
|
case EvqTemporary: return "temporary"; break;
|
||||||
@ -133,7 +135,7 @@ enum TPrecisionQualifier {
|
|||||||
EpqHigh
|
EpqHigh
|
||||||
};
|
};
|
||||||
|
|
||||||
__inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
|
__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
|
||||||
{
|
{
|
||||||
switch(p) {
|
switch(p) {
|
||||||
case EpqNone: return ""; break;
|
case EpqNone: return ""; break;
|
||||||
@ -144,4 +146,6 @@ __inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _BASICTYPES_INCLUDED_
|
#endif // _BASICTYPES_INCLUDED_
|
||||||
|
@ -85,6 +85,8 @@
|
|||||||
#define TBaseList std::list
|
#define TBaseList std::list
|
||||||
#define TBaseSet std::set
|
#define TBaseSet std::set
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pool version of string.
|
// Pool version of string.
|
||||||
//
|
//
|
||||||
@ -170,4 +172,6 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
|
|||||||
|
|
||||||
const int GlslangMaxTokenLength = 1024;
|
const int GlslangMaxTokenLength = 1024;
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _COMMON_INCLUDED_
|
#endif // _COMMON_INCLUDED_
|
||||||
|
@ -37,8 +37,9 @@
|
|||||||
#ifndef _CONSTANT_UNION_INCLUDED_
|
#ifndef _CONSTANT_UNION_INCLUDED_
|
||||||
#define _CONSTANT_UNION_INCLUDED_
|
#define _CONSTANT_UNION_INCLUDED_
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
class constUnion {
|
class TConstUnion {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||||
@ -103,7 +104,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const constUnion& constant) const
|
bool operator==(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
if (constant.type != type)
|
if (constant.type != type)
|
||||||
return false;
|
return false;
|
||||||
@ -156,12 +157,12 @@ public:
|
|||||||
return !operator==(b);
|
return !operator==(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const constUnion& constant) const
|
bool operator!=(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
return !operator==(constant);
|
return !operator==(constant);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator>(const constUnion& constant) const
|
bool operator>(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -188,7 +189,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const constUnion& constant) const
|
bool operator<(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -215,9 +216,9 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator+(const constUnion& constant) const
|
TConstUnion operator+(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
|
||||||
@ -229,9 +230,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator-(const constUnion& constant) const
|
TConstUnion operator-(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
|
||||||
@ -243,9 +244,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator*(const constUnion& constant) const
|
TConstUnion operator*(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
|
||||||
@ -257,9 +258,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator%(const constUnion& constant) const
|
TConstUnion operator%(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
|
||||||
@ -270,9 +271,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator>>(const constUnion& constant) const
|
TConstUnion operator>>(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
switch (constant.type) {
|
switch (constant.type) {
|
||||||
@ -294,9 +295,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator<<(const constUnion& constant) const
|
TConstUnion operator<<(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
switch (constant.type) {
|
switch (constant.type) {
|
||||||
@ -318,9 +319,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator&(const constUnion& constant) const
|
TConstUnion operator&(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
|
||||||
@ -331,9 +332,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator|(const constUnion& constant) const
|
TConstUnion operator|(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
|
||||||
@ -344,9 +345,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator^(const constUnion& constant) const
|
TConstUnion operator^(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
|
||||||
@ -357,9 +358,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator~() const
|
TConstUnion operator~() const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(~iConst); break;
|
case EbtInt: returnValue.setIConst(~iConst); break;
|
||||||
case EbtUint: returnValue.setUConst(~uConst); break;
|
case EbtUint: returnValue.setUConst(~uConst); break;
|
||||||
@ -369,9 +370,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator&&(const constUnion& constant) const
|
TConstUnion operator&&(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
|
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
|
||||||
@ -381,9 +382,9 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion operator||(const constUnion& constant) const
|
TConstUnion operator||(const TConstUnion& constant) const
|
||||||
{
|
{
|
||||||
constUnion returnValue;
|
TConstUnion returnValue;
|
||||||
assert(type == constant.type);
|
assert(type == constant.type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
|
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
|
||||||
@ -406,4 +407,6 @@ private:
|
|||||||
TBasicType type;
|
TBasicType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _CONSTANT_UNION_INCLUDED_
|
#endif // _CONSTANT_UNION_INCLUDED_
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "../Include/Common.h"
|
#include "../Include/Common.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// TPrefixType is used to centralize how info log messages start.
|
// TPrefixType is used to centralize how info log messages start.
|
||||||
// See below.
|
// See below.
|
||||||
@ -131,10 +133,12 @@ protected:
|
|||||||
int outputStream;
|
int outputStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
class TInfoSink {
|
class TInfoSink {
|
||||||
public:
|
public:
|
||||||
TInfoSinkBase info;
|
glslang::TInfoSinkBase info;
|
||||||
TInfoSinkBase debug;
|
glslang::TInfoSinkBase debug;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _INFOSINK_INCLUDED_
|
#endif // _INFOSINK_INCLUDED_
|
||||||
|
@ -35,9 +35,13 @@
|
|||||||
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
|
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
|
||||||
#define __INITIALIZE_GLOBALS_INCLUDED_
|
#define __INITIALIZE_GLOBALS_INCLUDED_
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
void InitializeGlobalPools();
|
void InitializeGlobalPools();
|
||||||
void FreeGlobalPools();
|
void FreeGlobalPools();
|
||||||
bool InitializePoolIndex();
|
bool InitializePoolIndex();
|
||||||
void FreePoolIndex();
|
void FreePoolIndex();
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // __INITIALIZE_GLOBALS_INCLUDED_
|
#endif // __INITIALIZE_GLOBALS_INCLUDED_
|
||||||
|
@ -65,6 +65,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
// If we are using guard blocks, we must track each indivual
|
// If we are using guard blocks, we must track each indivual
|
||||||
// allocation. If we aren't using guard blocks, these
|
// allocation. If we aren't using guard blocks, these
|
||||||
// never get instantiated, so won't have any impact.
|
// never get instantiated, so won't have any impact.
|
||||||
@ -316,4 +318,6 @@ protected:
|
|||||||
TPoolAllocator& allocator;
|
TPoolAllocator& allocator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _POOLALLOC_INCLUDED_
|
#endif // _POOLALLOC_INCLUDED_
|
||||||
|
@ -58,4 +58,5 @@ struct TBuiltInResource {
|
|||||||
int minProgramTexelOffset;
|
int minProgramTexelOffset;
|
||||||
int maxProgramTexelOffset;
|
int maxProgramTexelOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _RESOURCE_LIMITS_INCLUDED_
|
#endif // _RESOURCE_LIMITS_INCLUDED_
|
||||||
|
@ -52,7 +52,6 @@ class TCompiler;
|
|||||||
class TLinker;
|
class TLinker;
|
||||||
class TUniformMap;
|
class TUniformMap;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The base class used to back handles returned to the driver.
|
// The base class used to back handles returned to the driver.
|
||||||
//
|
//
|
||||||
@ -78,6 +77,7 @@ public:
|
|||||||
virtual TInfoSink& getInfoSink() { return infoSink; }
|
virtual TInfoSink& getInfoSink() { return infoSink; }
|
||||||
TInfoSink infoSink;
|
TInfoSink infoSink;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TIntermNode;
|
class TIntermNode;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -105,8 +105,8 @@ protected:
|
|||||||
//
|
//
|
||||||
// Link operations are base on a list of compile results...
|
// Link operations are base on a list of compile results...
|
||||||
//
|
//
|
||||||
typedef TVector<TCompiler*> TCompilerList;
|
typedef glslang::TVector<TCompiler*> TCompilerList;
|
||||||
typedef TVector<TShHandleBase*> THandleList;
|
typedef glslang::TVector<TShHandleBase*> THandleList;
|
||||||
|
|
||||||
//
|
//
|
||||||
// The base class for the machine dependent linker to derive from
|
// The base class for the machine dependent linker to derive from
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include "../Include/Common.h"
|
#include "../Include/Common.h"
|
||||||
#include "../Include/BaseTypes.h"
|
#include "../Include/BaseTypes.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
const int GlslangMaxTypeLength = 200;
|
const int GlslangMaxTypeLength = 200;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -680,8 +682,8 @@ public:
|
|||||||
return getBasicString();
|
return getBasicString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getStorageQualifierString() const { return ::getStorageQualifierString(qualifier.storage); }
|
const char* getStorageQualifierString() const { return GetStorageQualifierString(qualifier.storage); }
|
||||||
const char* getPrecisionQualifierString() const { return ::getPrecisionQualifierString(qualifier.precision); }
|
const char* getPrecisionQualifierString() const { return GetPrecisionQualifierString(qualifier.precision); }
|
||||||
TTypeList* getStruct() { return structure; }
|
TTypeList* getStruct() { return structure; }
|
||||||
TTypeList* getStruct() const { return structure; }
|
TTypeList* getStruct() const { return structure; }
|
||||||
|
|
||||||
@ -753,4 +755,6 @@ protected:
|
|||||||
TString *typeName; // for structure field type name
|
TString *typeName; // for structure field type name
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _TYPES_INCLUDED_
|
#endif // _TYPES_INCLUDED_
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
#include "../Include/Types.h"
|
#include "../Include/Types.h"
|
||||||
#include "../Include/ConstantUnion.h"
|
#include "../Include/ConstantUnion.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Operators used by the high-level (parse tree) representation.
|
// Operators used by the high-level (parse tree) representation.
|
||||||
//
|
//
|
||||||
@ -324,34 +326,41 @@ class TIntermBranch;
|
|||||||
class TIntermTyped;
|
class TIntermTyped;
|
||||||
class TIntermMethod;
|
class TIntermMethod;
|
||||||
class TIntermSymbol;
|
class TIntermSymbol;
|
||||||
class TInfoSink;
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
//
|
//
|
||||||
// Base class for the tree nodes
|
// Base class for the tree nodes
|
||||||
//
|
//
|
||||||
|
// (Put outside the glslang namespace, as it's used as part of the external interface.)
|
||||||
|
//
|
||||||
class TIntermNode {
|
class TIntermNode {
|
||||||
public:
|
public:
|
||||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
POOL_ALLOCATOR_NEW_DELETE(glslang::GetThreadPoolAllocator())
|
||||||
|
|
||||||
TIntermNode() { loc.line = 0; loc.string = 0; }
|
TIntermNode() { loc.line = 0; loc.string = 0; }
|
||||||
virtual TSourceLoc getLoc() const { return loc; }
|
virtual glslang::TSourceLoc getLoc() const { return loc; }
|
||||||
virtual void setLoc(TSourceLoc l) { loc = l; }
|
virtual void setLoc(glslang::TSourceLoc l) { loc = l; }
|
||||||
virtual void traverse(TIntermTraverser*) = 0;
|
virtual void traverse(glslang::TIntermTraverser*) = 0;
|
||||||
virtual TIntermTyped* getAsTyped() { return 0; }
|
virtual glslang::TIntermTyped* getAsTyped() { return 0; }
|
||||||
virtual TIntermConstantUnion* getAsConstantUnion() { return 0; }
|
virtual glslang::TIntermConstantUnion* getAsConstantUnion() { return 0; }
|
||||||
virtual TIntermAggregate* getAsAggregate() { return 0; }
|
virtual glslang::TIntermAggregate* getAsAggregate() { return 0; }
|
||||||
virtual TIntermUnary* getAsUnaryNode() { return 0; }
|
virtual glslang::TIntermUnary* getAsUnaryNode() { return 0; }
|
||||||
virtual TIntermBinary* getAsBinaryNode() { return 0; }
|
virtual glslang::TIntermBinary* getAsBinaryNode() { return 0; }
|
||||||
virtual TIntermSelection* getAsSelectionNode() { return 0; }
|
virtual glslang::TIntermSelection* getAsSelectionNode() { return 0; }
|
||||||
virtual TIntermSwitch* getAsSwitchNode() { return 0; }
|
virtual glslang::TIntermSwitch* getAsSwitchNode() { return 0; }
|
||||||
virtual TIntermMethod* getAsMethodNode() { return 0; }
|
virtual glslang::TIntermMethod* getAsMethodNode() { return 0; }
|
||||||
virtual TIntermSymbol* getAsSymbolNode() { return 0; }
|
virtual glslang::TIntermSymbol* getAsSymbolNode() { return 0; }
|
||||||
virtual TIntermBranch* getAsBranchNode() { return 0; }
|
virtual glslang::TIntermBranch* getAsBranchNode() { return 0; }
|
||||||
virtual ~TIntermNode() { }
|
virtual ~TIntermNode() { }
|
||||||
protected:
|
protected:
|
||||||
TSourceLoc loc;
|
glslang::TSourceLoc loc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TInfoSink;
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is just to help yacc.
|
// This is just to help yacc.
|
||||||
//
|
//
|
||||||
@ -465,15 +474,15 @@ protected:
|
|||||||
|
|
||||||
class TIntermConstantUnion : public TIntermTyped {
|
class TIntermConstantUnion : public TIntermTyped {
|
||||||
public:
|
public:
|
||||||
TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
|
TIntermConstantUnion(TConstUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
|
||||||
constUnion* getUnionArrayPointer() const { return unionArrayPointer; }
|
TConstUnion* getUnionArrayPointer() const { return unionArrayPointer; }
|
||||||
void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; }
|
void setUnionArrayPointer(TConstUnion *c) { unionArrayPointer = c; }
|
||||||
virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
|
virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
|
||||||
virtual void traverse(TIntermTraverser* );
|
virtual void traverse(TIntermTraverser* );
|
||||||
virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
|
virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
|
||||||
virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&);
|
virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&);
|
||||||
protected:
|
protected:
|
||||||
constUnion *unionArrayPointer;
|
TConstUnion *unionArrayPointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -646,4 +655,6 @@ public:
|
|||||||
bool rightToLeft;
|
bool rightToLeft;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // __INTERMEDIATE_H
|
#endif // __INTERMEDIATE_H
|
||||||
|
@ -39,7 +39,11 @@
|
|||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace glslang {
|
namespace {
|
||||||
|
|
||||||
|
using namespace glslang;
|
||||||
|
|
||||||
|
// Some helper functions
|
||||||
|
|
||||||
bool isNan(double x)
|
bool isNan(double x)
|
||||||
{
|
{
|
||||||
@ -59,17 +63,12 @@ bool isInf(double x)
|
|||||||
(bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
|
(bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// Some helper functions
|
|
||||||
|
|
||||||
const double pi = 3.1415926535897932384626433832795;
|
const double pi = 3.1415926535897932384626433832795;
|
||||||
|
|
||||||
bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray);
|
// forward reference for mutual recursion
|
||||||
|
bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray);
|
||||||
|
|
||||||
bool CompareStructure(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray)
|
bool CompareStructure(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray)
|
||||||
{
|
{
|
||||||
if (leftNodeType.isArray()) {
|
if (leftNodeType.isArray()) {
|
||||||
TType typeWithoutArrayness(leftNodeType);
|
TType typeWithoutArrayness(leftNodeType);
|
||||||
@ -88,7 +87,7 @@ bool CompareStructure(const TType& leftNodeType, constUnion* rightUnionArray, co
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray)
|
bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray)
|
||||||
{
|
{
|
||||||
TTypeList* fields = leftNodeType.getStruct();
|
TTypeList* fields = leftNodeType.getStruct();
|
||||||
|
|
||||||
@ -112,7 +111,10 @@ bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// The fold functions see if an operation on a constant can be done in place,
|
// The fold functions see if an operation on a constant can be done in place,
|
||||||
@ -129,9 +131,9 @@ bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, const
|
|||||||
//
|
//
|
||||||
TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink)
|
TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink)
|
||||||
{
|
{
|
||||||
constUnion *unionArray = getUnionArrayPointer();
|
TConstUnion *unionArray = getUnionArrayPointer();
|
||||||
int objectSize = getType().getObjectSize();
|
int objectSize = getType().getObjectSize();
|
||||||
constUnion* newConstArray = 0;
|
TConstUnion* newConstArray = 0;
|
||||||
|
|
||||||
// For most cases, the return type matches the argument type, so set that
|
// For most cases, the return type matches the argument type, so set that
|
||||||
// up and just code to exceptions below.
|
// up and just code to exceptions below.
|
||||||
@ -142,17 +144,17 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
//
|
//
|
||||||
|
|
||||||
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
|
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
|
||||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||||
|
|
||||||
if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
|
if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
|
||||||
// for a case like float f = vec4(2,3,4,5) + 1.2;
|
// for a case like float f = vec4(2,3,4,5) + 1.2;
|
||||||
rightUnionArray = new constUnion[objectSize];
|
rightUnionArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; ++i)
|
for (int i = 0; i < objectSize; ++i)
|
||||||
rightUnionArray[i] = *node->getUnionArrayPointer();
|
rightUnionArray[i] = *node->getUnionArrayPointer();
|
||||||
} else if (constantNode->getType().getObjectSize() > 1 && objectSize == 1) {
|
} else if (constantNode->getType().getObjectSize() > 1 && objectSize == 1) {
|
||||||
// for a case like float f = 1.2 + vec4(2,3,4,5);
|
// for a case like float f = 1.2 + vec4(2,3,4,5);
|
||||||
rightUnionArray = node->getUnionArrayPointer();
|
rightUnionArray = node->getUnionArrayPointer();
|
||||||
unionArray = new constUnion[constantNode->getType().getObjectSize()];
|
unionArray = new TConstUnion[constantNode->getType().getObjectSize()];
|
||||||
for (int i = 0; i < constantNode->getType().getObjectSize(); ++i)
|
for (int i = 0; i < constantNode->getType().getObjectSize(); ++i)
|
||||||
unionArray[i] = *getUnionArrayPointer();
|
unionArray[i] = *getUnionArrayPointer();
|
||||||
returnType = node->getType();
|
returnType = node->getType();
|
||||||
@ -163,12 +165,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
bool boolNodeFlag = false;
|
bool boolNodeFlag = false;
|
||||||
switch(op) {
|
switch(op) {
|
||||||
case EOpAdd:
|
case EOpAdd:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] + rightUnionArray[i];
|
newConstArray[i] = unionArray[i] + rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
case EOpSub:
|
case EOpSub:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] - rightUnionArray[i];
|
newConstArray[i] = unionArray[i] - rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
@ -176,12 +178,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
case EOpMul:
|
case EOpMul:
|
||||||
case EOpVectorTimesScalar:
|
case EOpVectorTimesScalar:
|
||||||
case EOpMatrixTimesScalar:
|
case EOpMatrixTimesScalar:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] * rightUnionArray[i];
|
newConstArray[i] = unionArray[i] * rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
case EOpMatrixTimesMatrix:
|
case EOpMatrixTimesMatrix:
|
||||||
newConstArray = new constUnion[getMatrixRows() * node->getMatrixCols()];
|
newConstArray = new TConstUnion[getMatrixRows() * node->getMatrixCols()];
|
||||||
for (int row = 0; row < getMatrixRows(); row++) {
|
for (int row = 0; row < getMatrixRows(); row++) {
|
||||||
for (int column = 0; column < node->getMatrixCols(); column++) {
|
for (int column = 0; column < node->getMatrixCols(); column++) {
|
||||||
double sum = 0.0f;
|
double sum = 0.0f;
|
||||||
@ -193,7 +195,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
returnType = TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols());
|
returnType = TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols());
|
||||||
break;
|
break;
|
||||||
case EOpDiv:
|
case EOpDiv:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++) {
|
for (int i = 0; i < objectSize; i++) {
|
||||||
switch (getType().getBasicType()) {
|
switch (getType().getBasicType()) {
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
@ -221,7 +223,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpMatrixTimesVector:
|
case EOpMatrixTimesVector:
|
||||||
newConstArray = new constUnion[getMatrixRows()];
|
newConstArray = new TConstUnion[getMatrixRows()];
|
||||||
for (int i = 0; i < getMatrixRows(); i++) {
|
for (int i = 0; i < getMatrixRows(); i++) {
|
||||||
double sum = 0.0f;
|
double sum = 0.0f;
|
||||||
for (int j = 0; j < node->getVectorSize(); j++) {
|
for (int j = 0; j < node->getVectorSize(); j++) {
|
||||||
@ -234,7 +236,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpVectorTimesMatrix:
|
case EOpVectorTimesMatrix:
|
||||||
newConstArray = new constUnion[node->getMatrixCols()];
|
newConstArray = new TConstUnion[node->getMatrixCols()];
|
||||||
for (int i = 0; i < node->getMatrixCols(); i++) {
|
for (int i = 0; i < node->getMatrixCols(); i++) {
|
||||||
double sum = 0.0f;
|
double sum = 0.0f;
|
||||||
for (int j = 0; j < getVectorSize(); j++)
|
for (int j = 0; j < getVectorSize(); j++)
|
||||||
@ -246,53 +248,53 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpMod:
|
case EOpMod:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] % rightUnionArray[i];
|
newConstArray[i] = unionArray[i] % rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpRightShift:
|
case EOpRightShift:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] >> rightUnionArray[i];
|
newConstArray[i] = unionArray[i] >> rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLeftShift:
|
case EOpLeftShift:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] << rightUnionArray[i];
|
newConstArray[i] = unionArray[i] << rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpAnd:
|
case EOpAnd:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] & rightUnionArray[i];
|
newConstArray[i] = unionArray[i] & rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
case EOpInclusiveOr:
|
case EOpInclusiveOr:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] | rightUnionArray[i];
|
newConstArray[i] = unionArray[i] | rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
case EOpExclusiveOr:
|
case EOpExclusiveOr:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] ^ rightUnionArray[i];
|
newConstArray[i] = unionArray[i] ^ rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] && rightUnionArray[i];
|
newConstArray[i] = unionArray[i] && rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
|
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i] = unionArray[i] || rightUnionArray[i];
|
newConstArray[i] = unionArray[i] || rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLogicalXor:
|
case EOpLogicalXor:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
for (int i = 0; i < objectSize; i++) {
|
for (int i = 0; i < objectSize; i++) {
|
||||||
switch (getType().getBasicType()) {
|
switch (getType().getBasicType()) {
|
||||||
case EbtBool: newConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true); break;
|
case EbtBool: newConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true); break;
|
||||||
@ -303,22 +305,22 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
|
|
||||||
case EOpLessThan:
|
case EOpLessThan:
|
||||||
assert(objectSize == 1);
|
assert(objectSize == 1);
|
||||||
newConstArray = new constUnion[1];
|
newConstArray = new TConstUnion[1];
|
||||||
newConstArray->setBConst(*unionArray < *rightUnionArray);
|
newConstArray->setBConst(*unionArray < *rightUnionArray);
|
||||||
returnType = TType(EbtBool, EvqConst);
|
returnType = TType(EbtBool, EvqConst);
|
||||||
break;
|
break;
|
||||||
case EOpGreaterThan:
|
case EOpGreaterThan:
|
||||||
assert(objectSize == 1);
|
assert(objectSize == 1);
|
||||||
newConstArray = new constUnion[1];
|
newConstArray = new TConstUnion[1];
|
||||||
newConstArray->setBConst(*unionArray > *rightUnionArray);
|
newConstArray->setBConst(*unionArray > *rightUnionArray);
|
||||||
returnType = TType(EbtBool, EvqConst);
|
returnType = TType(EbtBool, EvqConst);
|
||||||
break;
|
break;
|
||||||
case EOpLessThanEqual:
|
case EOpLessThanEqual:
|
||||||
{
|
{
|
||||||
assert(objectSize == 1);
|
assert(objectSize == 1);
|
||||||
constUnion constant;
|
TConstUnion constant;
|
||||||
constant.setBConst(*unionArray > *rightUnionArray);
|
constant.setBConst(*unionArray > *rightUnionArray);
|
||||||
newConstArray = new constUnion[1];
|
newConstArray = new TConstUnion[1];
|
||||||
newConstArray->setBConst(!constant.getBConst());
|
newConstArray->setBConst(!constant.getBConst());
|
||||||
returnType = TType(EbtBool, EvqConst);
|
returnType = TType(EbtBool, EvqConst);
|
||||||
break;
|
break;
|
||||||
@ -326,9 +328,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
case EOpGreaterThanEqual:
|
case EOpGreaterThanEqual:
|
||||||
{
|
{
|
||||||
assert(objectSize == 1);
|
assert(objectSize == 1);
|
||||||
constUnion constant;
|
TConstUnion constant;
|
||||||
constant.setBConst(*unionArray < *rightUnionArray);
|
constant.setBConst(*unionArray < *rightUnionArray);
|
||||||
newConstArray = new constUnion[1];
|
newConstArray = new TConstUnion[1];
|
||||||
newConstArray->setBConst(!constant.getBConst());
|
newConstArray->setBConst(!constant.getBConst());
|
||||||
returnType = TType(EbtBool, EvqConst);
|
returnType = TType(EbtBool, EvqConst);
|
||||||
break;
|
break;
|
||||||
@ -347,7 +349,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newConstArray = new constUnion[1];
|
newConstArray = new TConstUnion[1];
|
||||||
newConstArray->setBConst(! boolNodeFlag);
|
newConstArray->setBConst(! boolNodeFlag);
|
||||||
returnType = TType(EbtBool, EvqConst);
|
returnType = TType(EbtBool, EvqConst);
|
||||||
break;
|
break;
|
||||||
@ -365,7 +367,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newConstArray = new constUnion[1];
|
newConstArray = new TConstUnion[1];
|
||||||
newConstArray->setBConst(! boolNodeFlag);
|
newConstArray->setBConst(! boolNodeFlag);
|
||||||
returnType = TType(EbtBool, EvqConst);
|
returnType = TType(EbtBool, EvqConst);
|
||||||
break;
|
break;
|
||||||
@ -387,19 +389,19 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
//
|
//
|
||||||
TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType, TInfoSink& infoSink)
|
TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType, TInfoSink& infoSink)
|
||||||
{
|
{
|
||||||
constUnion *unionArray = getUnionArrayPointer();
|
TConstUnion *unionArray = getUnionArrayPointer();
|
||||||
int objectSize = getType().getObjectSize();
|
int objectSize = getType().getObjectSize();
|
||||||
|
|
||||||
// First, size the result, which is mostly the same as the argument's size,
|
// First, size the result, which is mostly the same as the argument's size,
|
||||||
// but not always.
|
// but not always.
|
||||||
constUnion* newConstArray;
|
TConstUnion* newConstArray;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
// TODO: functionality: constant folding: finish listing exceptions to size here
|
// TODO: functionality: constant folding: finish listing exceptions to size here
|
||||||
case EOpDeterminant:
|
case EOpDeterminant:
|
||||||
case EOpAny:
|
case EOpAny:
|
||||||
case EOpAll:
|
case EOpAll:
|
||||||
case EOpLength:
|
case EOpLength:
|
||||||
newConstArray = new constUnion[1];
|
newConstArray = new TConstUnion[1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpEmitStreamVertex:
|
case EOpEmitStreamVertex:
|
||||||
@ -408,7 +410,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
newConstArray = new constUnion[objectSize];
|
newConstArray = new TConstUnion[objectSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process non-component-wise operations
|
// Process non-component-wise operations
|
||||||
@ -565,12 +567,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
|
|||||||
|
|
||||||
case EOpIsNan:
|
case EOpIsNan:
|
||||||
{
|
{
|
||||||
newConstArray[i].setBConst(glslang::isNan(unionArray[i].getDConst()));
|
newConstArray[i].setBConst(isNan(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EOpIsInf:
|
case EOpIsInf:
|
||||||
{
|
{
|
||||||
newConstArray[i].setBConst(glslang::isInf(unionArray[i].getDConst()));
|
newConstArray[i].setBConst(isInf(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,9 +666,9 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
|
|||||||
default:
|
default:
|
||||||
return aggrNode;
|
return aggrNode;
|
||||||
}
|
}
|
||||||
constUnion* newConstArray = new constUnion[objectSize];
|
TConstUnion* newConstArray = new TConstUnion[objectSize];
|
||||||
|
|
||||||
TVector<constUnion*> childConstUnions;
|
TVector<TConstUnion*> childConstUnions;
|
||||||
for (unsigned int i = 0; i < children.size(); ++i)
|
for (unsigned int i = 0; i < children.size(); ++i)
|
||||||
childConstUnions.push_back(children[i]->getAsConstantUnion()->getUnionArrayPointer());
|
childConstUnions.push_back(children[i]->getAsConstantUnion()->getUnionArrayPointer());
|
||||||
|
|
||||||
@ -736,7 +738,7 @@ TIntermTyped* TIntermediate::foldConstructor(TIntermAggregate* aggrNode)
|
|||||||
{
|
{
|
||||||
bool returnVal = false;
|
bool returnVal = false;
|
||||||
|
|
||||||
constUnion* unionArray = new constUnion[aggrNode->getType().getObjectSize()];
|
TConstUnion* unionArray = new TConstUnion[aggrNode->getType().getObjectSize()];
|
||||||
if (aggrNode->getSequence().size() == 1)
|
if (aggrNode->getSequence().size() == 1)
|
||||||
returnVal = parseConstTree(aggrNode->getLoc(), aggrNode, unionArray, aggrNode->getOp(), aggrNode->getType(), true);
|
returnVal = parseConstTree(aggrNode->getLoc(), aggrNode, unionArray, aggrNode->getOp(), aggrNode->getType(), true);
|
||||||
else
|
else
|
||||||
@ -747,3 +749,5 @@ TIntermTyped* TIntermediate::foldConstructor(TIntermAggregate* aggrNode)
|
|||||||
|
|
||||||
return addConstantUnion(unionArray, aggrNode->getType(), aggrNode->getLoc());
|
return addConstantUnion(unionArray, aggrNode->getType(), aggrNode->getLoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
void TInfoSinkBase::append(const char *s)
|
void TInfoSinkBase::append(const char *s)
|
||||||
{
|
{
|
||||||
if (outputStream & EString) {
|
if (outputStream & EString) {
|
||||||
@ -103,3 +105,5 @@ void TInfoSinkBase::append(const TString& t)
|
|||||||
if (outputStream & EStdOut)
|
if (outputStream & EStdOut)
|
||||||
fprintf(stdout, "%s", t.c_str());
|
fprintf(stdout, "%s", t.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
#include "../Include/intermediate.h"
|
#include "../Include/intermediate.h"
|
||||||
#include "Initialize.h"
|
#include "Initialize.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
const int FirstProfileVersion = 150;
|
const int FirstProfileVersion = 150;
|
||||||
const bool ForwardCompatibility = false;
|
const bool ForwardCompatibility = false;
|
||||||
|
|
||||||
@ -1663,3 +1665,5 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
#include "SymbolTable.h"
|
#include "SymbolTable.h"
|
||||||
#include "Versions.h"
|
#include "Versions.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
class TBuiltIns {
|
class TBuiltIns {
|
||||||
public:
|
public:
|
||||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||||
@ -71,4 +73,6 @@ protected:
|
|||||||
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&);
|
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&);
|
||||||
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
|
void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _INITIALIZE_INCLUDED_
|
#endif // _INITIALIZE_INCLUDED_
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include "../Include/intermediate.h"
|
#include "../Include/intermediate.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Traverse the intermediate representation tree, and
|
// Traverse the intermediate representation tree, and
|
||||||
// call a node type specific function for each node.
|
// call a node type specific function for each node.
|
||||||
@ -275,3 +277,5 @@ void TIntermSwitch::traverse(TIntermTraverser* it)
|
|||||||
if (visit && it->postVisit && it->visitSwitch)
|
if (visit && it->postVisit && it->visitSwitch)
|
||||||
it->visitSwitch(false, this, it);
|
it->visitSwitch(false, this, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
#include "RemoveTree.h"
|
#include "RemoveTree.h"
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// First set of functions are to help build the intermediate representation.
|
// First set of functions are to help build the intermediate representation.
|
||||||
@ -794,7 +796,7 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
|
|||||||
// Returns the constant union node created.
|
// Returns the constant union node created.
|
||||||
//
|
//
|
||||||
|
|
||||||
TIntermConstantUnion* TIntermediate::addConstantUnion(constUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
|
TIntermConstantUnion* TIntermediate::addConstantUnion(TConstUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
|
||||||
{
|
{
|
||||||
TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
|
TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
|
||||||
node->setLoc(loc);
|
node->setLoc(loc);
|
||||||
@ -810,10 +812,10 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc loc)
|
|||||||
node->setLoc(loc);
|
node->setLoc(loc);
|
||||||
TIntermConstantUnion* constIntNode;
|
TIntermConstantUnion* constIntNode;
|
||||||
TIntermSequence &sequenceVector = node->getSequence();
|
TIntermSequence &sequenceVector = node->getSequence();
|
||||||
constUnion* unionArray;
|
TConstUnion* unionArray;
|
||||||
|
|
||||||
for (int i = 0; i < fields.num; i++) {
|
for (int i = 0; i < fields.num; i++) {
|
||||||
unionArray = new constUnion[1];
|
unionArray = new TConstUnion[1];
|
||||||
unionArray->setIConst(fields.offsets[i]);
|
unionArray->setIConst(fields.offsets[i]);
|
||||||
constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
||||||
sequenceVector.push_back(constIntNode);
|
sequenceVector.push_back(constIntNode);
|
||||||
@ -1398,10 +1400,10 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||||||
if (node->getType().isArray())
|
if (node->getType().isArray())
|
||||||
infoSink.info.message(EPrefixInternalError, "Cannot promote array", node->getLoc());
|
infoSink.info.message(EPrefixInternalError, "Cannot promote array", node->getLoc());
|
||||||
|
|
||||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||||
int size = node->getType().getObjectSize();
|
int size = node->getType().getObjectSize();
|
||||||
|
|
||||||
constUnion *leftUnionArray = new constUnion[size];
|
TConstUnion *leftUnionArray = new TConstUnion[size];
|
||||||
|
|
||||||
for (int i=0; i < size; i++) {
|
for (int i=0; i < size; i++) {
|
||||||
switch (promoteTo) {
|
switch (promoteTo) {
|
||||||
@ -1526,3 +1528,4 @@ void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
|
|||||||
*pragmaTable = pTable;
|
*pragmaTable = pTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
//
|
|
||||||
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
|
|
||||||
//All rights reserved.
|
|
||||||
//
|
|
||||||
//Redistribution and use in source and binary forms, with or without
|
|
||||||
//modification, are permitted provided that the following conditions
|
|
||||||
//are met:
|
|
||||||
//
|
|
||||||
// Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following
|
|
||||||
// disclaimer in the documentation and/or other materials provided
|
|
||||||
// with the distribution.
|
|
||||||
//
|
|
||||||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
|
|
||||||
// contributors may be used to endorse or promote products derived
|
|
||||||
// from this software without specific prior written permission.
|
|
||||||
//
|
|
||||||
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
//POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _MMAP_INCLUDED_
|
|
||||||
#define _MMAP_INCLUDED_
|
|
||||||
|
|
||||||
//
|
|
||||||
// Encapsulate memory mapped files
|
|
||||||
//
|
|
||||||
|
|
||||||
class TMMap {
|
|
||||||
public:
|
|
||||||
TMMap(const char* fileName) :
|
|
||||||
fSize(-1), // -1 is the error value returned by GetFileSize()
|
|
||||||
fp(NULL),
|
|
||||||
fBuff(0) // 0 is the error value returned by MapViewOfFile()
|
|
||||||
{
|
|
||||||
if ((fp = fopen(fileName, "r")) == NULL)
|
|
||||||
return;
|
|
||||||
char c = getc(fp);
|
|
||||||
fSize = 0;
|
|
||||||
while (c != EOF) {
|
|
||||||
fSize++;
|
|
||||||
c = getc(fp);
|
|
||||||
}
|
|
||||||
if (c == EOF)
|
|
||||||
fSize++;
|
|
||||||
rewind(fp);
|
|
||||||
fBuff = (char*)malloc(sizeof(char) * fSize);
|
|
||||||
int count = 0;
|
|
||||||
c = getc(fp);
|
|
||||||
while (c != EOF) {
|
|
||||||
fBuff[count++] = c;
|
|
||||||
c = getc(fp);
|
|
||||||
}
|
|
||||||
fBuff[count++] = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* getData() { return fBuff; }
|
|
||||||
int getSize() { return fSize; }
|
|
||||||
|
|
||||||
~TMMap() {
|
|
||||||
if (fp != NULL)
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int fSize; // size of file to map in
|
|
||||||
FILE *fp;
|
|
||||||
char* fBuff; // the actual data;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _MMAP_INCLUDED_
|
|
@ -41,6 +41,10 @@
|
|||||||
|
|
||||||
#include "preprocessor/PpContext.h"
|
#include "preprocessor/PpContext.h"
|
||||||
|
|
||||||
|
extern int yyparse(void*);
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb, int v, EProfile p, EShLanguage L, TInfoSink& is,
|
TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb, int v, EProfile p, EShLanguage L, TInfoSink& is,
|
||||||
bool fc, EShMessages m) :
|
bool fc, EShMessages m) :
|
||||||
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), linkage(0),
|
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), linkage(0),
|
||||||
@ -104,8 +108,6 @@ const char* TParseContext::getPreamble()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int yyparse(void*);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse an array of strings using yyparse, going through the
|
// Parse an array of strings using yyparse, going through the
|
||||||
// preprocessor to tokenize the shader strings, then through
|
// preprocessor to tokenize the shader strings, then through
|
||||||
@ -458,7 +460,7 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TSt
|
|||||||
// it was a member of an anonymous container, have to insert its dereference
|
// it was a member of an anonymous container, have to insert its dereference
|
||||||
TVariable* variable = anon->getAnonContainer().getAsVariable();
|
TVariable* variable = anon->getAnonContainer().getAsVariable();
|
||||||
TIntermTyped* container = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), loc);
|
TIntermTyped* container = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), loc);
|
||||||
constUnion* unionArray = new constUnion[1];
|
TConstUnion* unionArray = new TConstUnion[1];
|
||||||
unionArray->setUConst(anon->getMemberNumber());
|
unionArray->setUConst(anon->getMemberNumber());
|
||||||
TIntermTyped* constNode = intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), loc);
|
TIntermTyped* constNode = intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), loc);
|
||||||
|
|
||||||
@ -478,7 +480,7 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TSt
|
|||||||
// pop will reclaim the memory
|
// pop will reclaim the memory
|
||||||
|
|
||||||
if (variable->getType().getQualifier().storage == EvqConst ) {
|
if (variable->getType().getQualifier().storage == EvqConst ) {
|
||||||
constUnion* constArray = variable->getConstUnionPointer();
|
TConstUnion* constArray = variable->getConstUnionPointer();
|
||||||
TType t(variable->getType());
|
TType t(variable->getType());
|
||||||
node = intermediate.addConstantUnion(constArray, t, loc);
|
node = intermediate.addConstantUnion(constArray, t, loc);
|
||||||
} else
|
} else
|
||||||
@ -547,7 +549,7 @@ TIntermTyped* TParseContext::handleBracketDereference(TSourceLoc loc, TIntermTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setDConst(0.0);
|
unionArray->setDConst(0.0);
|
||||||
result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
|
result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
|
||||||
} else {
|
} else {
|
||||||
@ -595,7 +597,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
|
|||||||
result->setType(TType(base->getBasicType(), EvqConst, (int) (field).size()));
|
result->setType(TType(base->getBasicType(), EvqConst, (int) (field).size()));
|
||||||
} else {
|
} else {
|
||||||
if (fields.num == 1) {
|
if (fields.num == 1) {
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setIConst(fields.offsets[0]);
|
unionArray->setIConst(fields.offsets[0]);
|
||||||
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
||||||
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
|
result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
|
||||||
@ -634,7 +636,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
|
|||||||
result->getTypePointer()->getQualifier().storage = EvqConst;
|
result->getTypePointer()->getQualifier().storage = EvqConst;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setIConst(i);
|
unionArray->setIConst(i);
|
||||||
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
||||||
result = intermediate.addIndex(EOpIndexDirectStruct, base, index, loc);
|
result = intermediate.addIndex(EOpIndexDirectStruct, base, index, loc);
|
||||||
@ -756,7 +758,7 @@ TIntermTyped* TParseContext::handleFunctionCall(TSourceLoc loc, TFunction* fnCal
|
|||||||
} else
|
} else
|
||||||
length = intermNode->getAsTyped()->getType().getArraySize();
|
length = intermNode->getAsTyped()->getType().getArraySize();
|
||||||
|
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setIConst(length);
|
unionArray->setIConst(length);
|
||||||
result = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
result = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
|
||||||
} else if (op != EOpNull) {
|
} else if (op != EOpNull) {
|
||||||
@ -831,7 +833,7 @@ TIntermTyped* TParseContext::handleFunctionCall(TSourceLoc loc, TFunction* fnCal
|
|||||||
} else {
|
} else {
|
||||||
// error message was put out by PaFindFunction()
|
// error message was put out by PaFindFunction()
|
||||||
// Put on a dummy node for error recovery
|
// Put on a dummy node for error recovery
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setDConst(0.0);
|
unionArray->setDConst(0.0);
|
||||||
result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
|
result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
|
||||||
}
|
}
|
||||||
@ -1408,14 +1410,14 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
|
|||||||
// now, knowing it is a shader in/out, do all the in/out semantic checks
|
// now, knowing it is a shader in/out, do all the in/out semantic checks
|
||||||
|
|
||||||
if (publicType.basicType == EbtBool) {
|
if (publicType.basicType == EbtBool) {
|
||||||
error(loc, "cannot be bool", getStorageQualifierString(qualifier.storage), "");
|
error(loc, "cannot be bool", GetStorageQualifierString(qualifier.storage), "");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (language == EShLangVertex && qualifier.storage == EvqVaryingIn) {
|
if (language == EShLangVertex && qualifier.storage == EvqVaryingIn) {
|
||||||
if (publicType.basicType == EbtStruct) {
|
if (publicType.basicType == EbtStruct) {
|
||||||
error(loc, "cannot be a structure or array", getStorageQualifierString(qualifier.storage), "");
|
error(loc, "cannot be a structure or array", GetStorageQualifierString(qualifier.storage), "");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1428,7 +1430,7 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
|
|||||||
if (language == EShLangFragment && qualifier.storage == EvqVaryingOut) {
|
if (language == EShLangFragment && qualifier.storage == EvqVaryingOut) {
|
||||||
profileRequires(loc, EEsProfile, 300, 0, "fragment shader output");
|
profileRequires(loc, EEsProfile, 300, 0, "fragment shader output");
|
||||||
if (publicType.basicType == EbtStruct) {
|
if (publicType.basicType == EbtStruct) {
|
||||||
error(loc, "cannot be a structure", getStorageQualifierString(qualifier.storage), "");
|
error(loc, "cannot be a structure", GetStorageQualifierString(qualifier.storage), "");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1438,7 +1440,7 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
|
|||||||
profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
|
profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
|
||||||
if (language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat ||
|
if (language != EShLangVertex && qualifier.storage == EvqVaryingIn && ! qualifier.flat ||
|
||||||
language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) {
|
language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) {
|
||||||
error(loc, "must be qualified as 'flat'", getStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
|
error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1498,11 +1500,11 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
|
|||||||
dst.storage == EvqConst && src.storage == EvqIn)
|
dst.storage == EvqConst && src.storage == EvqIn)
|
||||||
dst.storage = EvqConstReadOnly;
|
dst.storage = EvqConstReadOnly;
|
||||||
else if (src.storage != EvqTemporary)
|
else if (src.storage != EvqTemporary)
|
||||||
error(loc, "too many storage qualifiers", getStorageQualifierString(src.storage), "");
|
error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
|
||||||
|
|
||||||
// Precision qualifiers
|
// Precision qualifiers
|
||||||
if (! force && src.precision != EpqNone && dst.precision != EpqNone)
|
if (! force && src.precision != EpqNone && dst.precision != EpqNone)
|
||||||
error(loc, "only one precision qualifier allowed", getPrecisionQualifierString(src.precision), "");
|
error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), "");
|
||||||
if (dst.precision == EpqNone || force && src.precision != EpqNone)
|
if (dst.precision == EpqNone || force && src.precision != EpqNone)
|
||||||
dst.precision = src.precision;
|
dst.precision = src.precision;
|
||||||
|
|
||||||
@ -1882,7 +1884,7 @@ void TParseContext::paramCheck(TSourceLoc loc, TStorageQualifier qualifier, TTyp
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
type->getQualifier().storage = EvqIn;
|
type->getQualifier().storage = EvqIn;
|
||||||
error(loc, "qualifier not allowed on function parameter", getStorageQualifierString(qualifier), "");
|
error(loc, "qualifier not allowed on function parameter", GetStorageQualifierString(qualifier), "");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2050,7 +2052,7 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (initializer->getAsConstantUnion()) {
|
if (initializer->getAsConstantUnion()) {
|
||||||
constUnion* unionArray = variable->getConstUnionPointer();
|
TConstUnion* unionArray = variable->getConstUnionPointer();
|
||||||
|
|
||||||
if (type.getObjectSize() == 1 && type.getBasicType() != EbtStruct) {
|
if (type.getObjectSize() == 1 && type.getBasicType() != EbtStruct) {
|
||||||
*unionArray = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0];
|
*unionArray = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0];
|
||||||
@ -2060,7 +2062,7 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier,
|
|||||||
} else if (initializer->getAsSymbolNode()) {
|
} else if (initializer->getAsSymbolNode()) {
|
||||||
TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getName());
|
TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getName());
|
||||||
if (TVariable* tVar = symbol->getAsVariable()) {
|
if (TVariable* tVar = symbol->getAsVariable()) {
|
||||||
constUnion* constArray = tVar->getConstUnionPointer();
|
TConstUnion* constArray = tVar->getConstUnionPointer();
|
||||||
variable->shareConstPointer(constArray);
|
variable->shareConstPointer(constArray);
|
||||||
} else {
|
} else {
|
||||||
error(loc, "expected variable", initializer->getAsSymbolNode()->getName().c_str(), "");
|
error(loc, "expected variable", initializer->getAsSymbolNode()->getName().c_str(), "");
|
||||||
@ -2563,12 +2565,12 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
|
|||||||
TIntermTyped* typedNode;
|
TIntermTyped* typedNode;
|
||||||
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
|
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
|
||||||
|
|
||||||
constUnion *unionArray;
|
TConstUnion *unionArray;
|
||||||
if (tempConstantNode) {
|
if (tempConstantNode) {
|
||||||
unionArray = tempConstantNode->getUnionArrayPointer();
|
unionArray = tempConstantNode->getUnionArrayPointer();
|
||||||
|
|
||||||
if (!unionArray) { // this error message should never be raised
|
if (!unionArray) { // this error message should never be raised
|
||||||
infoSink.info.message(EPrefixInternalError, "constUnion not initialized in addConstVectorNode function", loc);
|
infoSink.info.message(EPrefixInternalError, "TConstUnion not initialized in addConstVectorNode function", loc);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@ -2578,7 +2580,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion* constArray = new constUnion[fields.num];
|
TConstUnion* constArray = new TConstUnion[fields.num];
|
||||||
|
|
||||||
for (int i = 0; i < fields.num; i++) {
|
for (int i = 0; i < fields.num; i++) {
|
||||||
if (fields.offsets[i] >= node->getType().getObjectSize()) {
|
if (fields.offsets[i] >= node->getType().getObjectSize()) {
|
||||||
@ -2610,7 +2612,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tempConstantNode) {
|
if (tempConstantNode) {
|
||||||
constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
|
TConstUnion* unionArray = tempConstantNode->getUnionArrayPointer();
|
||||||
int size = tempConstantNode->getType().getMatrixRows();
|
int size = tempConstantNode->getType().getMatrixRows();
|
||||||
// Note: the type is corrected (dereferenced) by the caller
|
// Note: the type is corrected (dereferenced) by the caller
|
||||||
typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), loc);
|
typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), loc);
|
||||||
@ -2646,7 +2648,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TS
|
|||||||
int arrayElementSize = arrayElementType.getObjectSize();
|
int arrayElementSize = arrayElementType.getObjectSize();
|
||||||
|
|
||||||
if (tempConstantNode) {
|
if (tempConstantNode) {
|
||||||
constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
|
TConstUnion* unionArray = tempConstantNode->getUnionArrayPointer();
|
||||||
typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), loc);
|
typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), loc);
|
||||||
} else {
|
} else {
|
||||||
error(loc, "Cannot offset into the array", "Error", "");
|
error(loc, "Cannot offset into the array", "Error", "");
|
||||||
@ -2680,7 +2682,7 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tempConstantNode) {
|
if (tempConstantNode) {
|
||||||
constUnion* constArray = tempConstantNode->getUnionArrayPointer();
|
TConstUnion* constArray = tempConstantNode->getUnionArrayPointer();
|
||||||
|
|
||||||
typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), loc); // type will be changed in the calling function
|
typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), loc); // type will be changed in the calling function
|
||||||
} else {
|
} else {
|
||||||
@ -2704,3 +2706,5 @@ void TParseContext::initializeExtensionBehavior()
|
|||||||
extensionBehavior["GL_ARB_texture_rectangle"] = EBhDisable;
|
extensionBehavior["GL_ARB_texture_rectangle"] = EBhDisable;
|
||||||
extensionBehavior["GL_3DL_array_objects"] = EBhDisable;
|
extensionBehavior["GL_3DL_array_objects"] = EBhDisable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
#include "SymbolTable.h"
|
#include "SymbolTable.h"
|
||||||
#include "localintermediate.h"
|
#include "localintermediate.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EBhRequire,
|
EBhRequire,
|
||||||
EBhEnable,
|
EBhEnable,
|
||||||
@ -55,12 +57,9 @@ struct TPragma {
|
|||||||
TPragmaTable pragmaTable;
|
TPragmaTable pragmaTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TScanContext;
|
||||||
class TPpContext;
|
class TPpContext;
|
||||||
|
|
||||||
namespace glslang {
|
|
||||||
class TScanContext;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The following are extra variables needed during parsing, grouped together so
|
// The following are extra variables needed during parsing, grouped together so
|
||||||
// they can be passed to the parser without needing a global.
|
// they can be passed to the parser without needing a global.
|
||||||
@ -70,7 +69,7 @@ public:
|
|||||||
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
|
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
|
||||||
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
|
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
|
||||||
|
|
||||||
glslang::TScanContext* scanContext;
|
TScanContext* scanContext;
|
||||||
TPpContext* ppContext;
|
TPpContext* ppContext;
|
||||||
TIntermediate& intermediate; // to hold and build a parse tree
|
TIntermediate& intermediate; // to hold and build a parse tree
|
||||||
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
|
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
|
||||||
@ -200,4 +199,6 @@ public:
|
|||||||
void doubleCheck(TSourceLoc, const char* op);
|
void doubleCheck(TSourceLoc, const char* op);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _PARSER_HELPER_INCLUDED_
|
#endif // _PARSER_HELPER_INCLUDED_
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "Include/InitializeGlobals.h"
|
#include "Include/InitializeGlobals.h"
|
||||||
#include "osinclude.h"
|
#include "osinclude.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
OS_TLSIndex PoolIndex;
|
OS_TLSIndex PoolIndex;
|
||||||
|
|
||||||
void InitializeGlobalPools()
|
void InitializeGlobalPools()
|
||||||
@ -333,3 +335,5 @@ void TAllocation::checkAllocList() const
|
|||||||
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
|
for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
|
||||||
alloc->check();
|
alloc->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include "../Include/intermediate.h"
|
#include "../Include/intermediate.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
class TAliveTraverser : public TIntermTraverser {
|
class TAliveTraverser : public TIntermTraverser {
|
||||||
public:
|
public:
|
||||||
TAliveTraverser(TStorageQualifier q) : TIntermTraverser(), found(false), qualifier(q)
|
TAliveTraverser(TStorageQualifier q) : TIntermTraverser(), found(false), qualifier(q)
|
||||||
@ -92,4 +94,6 @@ bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,4 +32,8 @@
|
|||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
bool QualifierWritten(TIntermNode* root, TStorageQualifier);
|
bool QualifierWritten(TIntermNode* root, TStorageQualifier);
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
|
|
||||||
#include "../Include/intermediate.h"
|
#include "../Include/intermediate.h"
|
||||||
#include "RemoveTree.h"
|
#include "RemoveTree.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Code to recursively delete the intermediate tree.
|
// Code to recursively delete the intermediate tree.
|
||||||
//
|
//
|
||||||
@ -106,3 +109,4 @@ void RemoveAllTreeNodes(TIntermNode* root)
|
|||||||
root->traverse(&it);
|
root->traverse(&it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -32,4 +32,8 @@
|
|||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
void RemoveAllTreeNodes(TIntermNode*);
|
void RemoveAllTreeNodes(TIntermNode*);
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -230,10 +230,6 @@ bool ScanVersion(TInputScanner& input, int& version, EProfile& profile)
|
|||||||
return foundNonSpaceTab;
|
return foundNonSpaceTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // end glslang namespace
|
|
||||||
|
|
||||||
namespace glslang {
|
|
||||||
|
|
||||||
// Fill this in when doing glslang-level scanning, to hand back to the parser.
|
// Fill this in when doing glslang-level scanning, to hand back to the parser.
|
||||||
class TParserToken {
|
class TParserToken {
|
||||||
public:
|
public:
|
||||||
@ -242,10 +238,10 @@ public:
|
|||||||
YYSTYPE& sType;
|
YYSTYPE& sType;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // end namespace glslang
|
} // end namespace glslang
|
||||||
|
|
||||||
// This is the function the glslang parser (i.e., bison) calls to get its next token
|
// This is the function the glslang parser (i.e., bison) calls to get its next token
|
||||||
int yylex(YYSTYPE* glslangTokenDesc, TParseContext& parseContext)
|
int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& parseContext)
|
||||||
{
|
{
|
||||||
glslang::TParserToken token(*glslangTokenDesc);
|
glslang::TParserToken token(*glslangTokenDesc);
|
||||||
|
|
||||||
@ -1012,4 +1008,4 @@ int TScanContext::secondGenerationImage()
|
|||||||
return identifierOrType();
|
return identifierOrType();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
} // end namespace glslang
|
||||||
|
@ -112,4 +112,4 @@ bool ConsumeComment(TInputScanner& input);
|
|||||||
void ConsumeWhitespaceComment(TInputScanner& input, bool& foundNonSpaceTab);
|
void ConsumeWhitespaceComment(TInputScanner& input, bool& foundNonSpaceTab);
|
||||||
bool ScanVersion(TInputScanner& input, int& version, EProfile& profile);
|
bool ScanVersion(TInputScanner& input, int& version, EProfile& profile);
|
||||||
|
|
||||||
}; // end glslang namespace
|
} // end namespace glslang
|
||||||
|
@ -40,11 +40,10 @@
|
|||||||
|
|
||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
|
|
||||||
class TPpContext;
|
|
||||||
class TPpToken;
|
|
||||||
|
|
||||||
namespace glslang {
|
namespace glslang {
|
||||||
|
|
||||||
|
class TPpContext;
|
||||||
|
class TPpToken;
|
||||||
class TParserToken;
|
class TParserToken;
|
||||||
|
|
||||||
class TScanContext {
|
class TScanContext {
|
||||||
@ -79,4 +78,4 @@ protected:
|
|||||||
int keyword;
|
int keyword;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
} // end namespace glslang
|
||||||
|
@ -57,6 +57,8 @@
|
|||||||
|
|
||||||
namespace { // anonymous namespace for file-local functions and symbols
|
namespace { // anonymous namespace for file-local functions and symbols
|
||||||
|
|
||||||
|
using namespace glslang;
|
||||||
|
|
||||||
int MapVersionToIndex(int version)
|
int MapVersionToIndex(int version)
|
||||||
{
|
{
|
||||||
switch(version) {
|
switch(version) {
|
||||||
@ -105,7 +107,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
|
|||||||
|
|
||||||
TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink);
|
TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink);
|
||||||
TPpContext ppContext(parseContext);
|
TPpContext ppContext(parseContext);
|
||||||
glslang::TScanContext scanContext(parseContext);
|
TScanContext scanContext(parseContext);
|
||||||
parseContext.scanContext = &scanContext;
|
parseContext.scanContext = &scanContext;
|
||||||
parseContext.ppContext = &ppContext;
|
parseContext.ppContext = &ppContext;
|
||||||
|
|
||||||
@ -310,7 +312,7 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // end anonymous namespace for local functions
|
} // end anonymous namespace for local functions
|
||||||
|
|
||||||
//
|
//
|
||||||
// ShInitialize() should be called exactly once per process, not per thread.
|
// ShInitialize() should be called exactly once per process, not per thread.
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
#include "SymbolTable.h"
|
#include "SymbolTable.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// TType helper function needs a place to live.
|
// TType helper function needs a place to live.
|
||||||
//
|
//
|
||||||
@ -222,7 +224,7 @@ TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol
|
|||||||
if (copyOf.unionArray) {
|
if (copyOf.unionArray) {
|
||||||
assert(!copyOf.type.getStruct());
|
assert(!copyOf.type.getStruct());
|
||||||
assert(copyOf.type.getObjectSize() == 1);
|
assert(copyOf.type.getObjectSize() == 1);
|
||||||
unionArray = new constUnion[1];
|
unionArray = new TConstUnion[1];
|
||||||
unionArray[0] = copyOf.unionArray[0];
|
unionArray[0] = copyOf.unionArray[0];
|
||||||
} else
|
} else
|
||||||
unionArray = 0;
|
unionArray = 0;
|
||||||
@ -283,3 +285,5 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf)
|
|||||||
for (unsigned int i = 0; i < copyOf.table.size(); ++i)
|
for (unsigned int i = 0; i < copyOf.table.size(); ++i)
|
||||||
table.push_back(copyOf.table[i]->clone(remapper));
|
table.push_back(copyOf.table[i]->clone(remapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -69,6 +69,8 @@
|
|||||||
#include "../Include/intermediate.h"
|
#include "../Include/intermediate.h"
|
||||||
#include "../Include/InfoSink.h"
|
#include "../Include/InfoSink.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Symbol base class. (Can build functions or variables out of these...)
|
// Symbol base class. (Can build functions or variables out of these...)
|
||||||
//
|
//
|
||||||
@ -126,16 +128,16 @@ public:
|
|||||||
|
|
||||||
virtual void dump(TInfoSink &infoSink) const;
|
virtual void dump(TInfoSink &infoSink) const;
|
||||||
|
|
||||||
constUnion* getConstUnionPointer() {
|
TConstUnion* getConstUnionPointer() {
|
||||||
if (!unionArray)
|
if (!unionArray)
|
||||||
unionArray = new constUnion[type.getObjectSize()];
|
unionArray = new TConstUnion[type.getObjectSize()];
|
||||||
|
|
||||||
return unionArray;
|
return unionArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
constUnion* getConstUnionPointer() const { return unionArray; }
|
TConstUnion* getConstUnionPointer() const { return unionArray; }
|
||||||
|
|
||||||
void shareConstPointer( constUnion *constArray)
|
void shareConstPointer( TConstUnion *constArray)
|
||||||
{
|
{
|
||||||
delete unionArray;
|
delete unionArray;
|
||||||
unionArray = constArray;
|
unionArray = constArray;
|
||||||
@ -150,7 +152,7 @@ protected:
|
|||||||
bool userType;
|
bool userType;
|
||||||
// we are assuming that Pool Allocator will free the memory allocated to unionArray
|
// we are assuming that Pool Allocator will free the memory allocated to unionArray
|
||||||
// when this object is destroyed
|
// when this object is destroyed
|
||||||
constUnion *unionArray;
|
TConstUnion *unionArray;
|
||||||
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
|
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -479,4 +481,6 @@ protected:
|
|||||||
unsigned int adoptedLevels;
|
unsigned int adoptedLevels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _SYMBOL_TABLE_INCLUDED_
|
#endif // _SYMBOL_TABLE_INCLUDED_
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
|
|
||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
const char* StageName[EShLangCount] = {
|
const char* StageName[EShLangCount] = {
|
||||||
"vertex",
|
"vertex",
|
||||||
"tessellation control",
|
"tessellation control",
|
||||||
@ -164,3 +166,5 @@ void TParseContext::doubleCheck(TSourceLoc loc, const char* op)
|
|||||||
profileRequires(loc, ECoreProfile, 400, 0, op);
|
profileRequires(loc, ECoreProfile, 400, 0, op);
|
||||||
profileRequires(loc, ECompatibilityProfile, 400, 0, op);
|
profileRequires(loc, ECompatibilityProfile, 400, 0, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is bison grammar and production code for parsing the OpenGL 2.0 shading
|
* This is bison grammar and productions for parsing all versions of the
|
||||||
* languages.
|
* GLSL shading languages.
|
||||||
*/
|
*/
|
||||||
%{
|
%{
|
||||||
|
|
||||||
@ -59,37 +59,39 @@ Jutta Degener, 1995
|
|||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
#include "../Public/ShaderLang.h"
|
#include "../Public/ShaderLang.h"
|
||||||
|
|
||||||
|
using namespace glslang;
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
struct {
|
struct {
|
||||||
TSourceLoc loc;
|
glslang::TSourceLoc loc;
|
||||||
union {
|
union {
|
||||||
TString *string;
|
glslang::TString *string;
|
||||||
int i;
|
int i;
|
||||||
unsigned int u;
|
unsigned int u;
|
||||||
bool b;
|
bool b;
|
||||||
double d;
|
double d;
|
||||||
};
|
};
|
||||||
TSymbol* symbol;
|
glslang::TSymbol* symbol;
|
||||||
} lex;
|
} lex;
|
||||||
struct {
|
struct {
|
||||||
TSourceLoc loc;
|
glslang::TSourceLoc loc;
|
||||||
TOperator op;
|
glslang::TOperator op;
|
||||||
union {
|
union {
|
||||||
TIntermNode* intermNode;
|
TIntermNode* intermNode;
|
||||||
TIntermNodePair nodePair;
|
glslang::TIntermNodePair nodePair;
|
||||||
TIntermTyped* intermTypedNode;
|
glslang::TIntermTyped* intermTypedNode;
|
||||||
TIntermAggregate* intermAggregate;
|
glslang::TIntermAggregate* intermAggregate;
|
||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
TPublicType type;
|
glslang::TPublicType type;
|
||||||
TFunction* function;
|
glslang::TFunction* function;
|
||||||
TParameter param;
|
glslang::TParameter param;
|
||||||
TTypeLoc typeLine;
|
glslang::TTypeLoc typeLine;
|
||||||
TTypeList* typeList;
|
glslang::TTypeList* typeList;
|
||||||
TArraySizes arraySizes;
|
glslang::TArraySizes arraySizes;
|
||||||
TIdentifierList* identifierList;
|
glslang::TIdentifierList* identifierList;
|
||||||
};
|
};
|
||||||
} interm;
|
} interm;
|
||||||
}
|
}
|
||||||
@ -224,29 +226,29 @@ primary_expression
|
|||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| INTCONSTANT {
|
| INTCONSTANT {
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setIConst($1.i);
|
unionArray->setIConst($1.i);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc);
|
||||||
}
|
}
|
||||||
| UINTCONSTANT {
|
| UINTCONSTANT {
|
||||||
parseContext.fullIntegerCheck($1.loc, "unsigned literal");
|
parseContext.fullIntegerCheck($1.loc, "unsigned literal");
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setUConst($1.u);
|
unionArray->setUConst($1.u);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc);
|
||||||
}
|
}
|
||||||
| FLOATCONSTANT {
|
| FLOATCONSTANT {
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setDConst($1.d);
|
unionArray->setDConst($1.d);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc);
|
||||||
}
|
}
|
||||||
| DOUBLECONSTANT {
|
| DOUBLECONSTANT {
|
||||||
parseContext.doubleCheck($1.loc, "double literal");
|
parseContext.doubleCheck($1.loc, "double literal");
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setDConst($1.d);
|
unionArray->setDConst($1.d);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc);
|
||||||
}
|
}
|
||||||
| BOOLCONSTANT {
|
| BOOLCONSTANT {
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst($1.b);
|
unionArray->setBConst($1.b);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc);
|
||||||
}
|
}
|
||||||
@ -511,7 +513,7 @@ relational_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, "<", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, "<", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
}
|
}
|
||||||
@ -520,7 +522,7 @@ relational_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, ">", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, ">", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
}
|
}
|
||||||
@ -529,7 +531,7 @@ relational_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, "<=", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, "<=", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
}
|
}
|
||||||
@ -538,7 +540,7 @@ relational_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, ">=", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, ">=", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
}
|
}
|
||||||
@ -551,7 +553,7 @@ equality_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, "==", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, "==", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
} else if (($1->isArray() || $3->isArray()))
|
} else if (($1->isArray() || $3->isArray()))
|
||||||
@ -561,7 +563,7 @@ equality_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, "!=", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, "!=", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
} else if (($1->isArray() || $3->isArray()))
|
} else if (($1->isArray() || $3->isArray()))
|
||||||
@ -611,7 +613,7 @@ logical_and_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, "&&", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, "&&", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
}
|
}
|
||||||
@ -624,7 +626,7 @@ logical_xor_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, "^^", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, "^^", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
}
|
}
|
||||||
@ -637,7 +639,7 @@ logical_or_expression
|
|||||||
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.loc);
|
$$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.loc);
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
parseContext.binaryOpError($2.loc, "||", $1->getCompleteString(), $3->getCompleteString());
|
parseContext.binaryOpError($2.loc, "||", $1->getCompleteString(), $3->getCompleteString());
|
||||||
constUnion *unionArray = new constUnion[1];
|
TConstUnion *unionArray = new TConstUnion[1];
|
||||||
unionArray->setBConst(false);
|
unionArray->setBConst(false);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);
|
||||||
}
|
}
|
||||||
@ -871,7 +873,7 @@ function_header
|
|||||||
: fully_specified_type IDENTIFIER LEFT_PAREN {
|
: fully_specified_type IDENTIFIER LEFT_PAREN {
|
||||||
if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) {
|
if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) {
|
||||||
parseContext.error($2.loc, "no qualifiers allowed for function return",
|
parseContext.error($2.loc, "no qualifiers allowed for function return",
|
||||||
getStorageQualifierString($1.qualifier.storage), "");
|
GetStorageQualifierString($1.qualifier.storage), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the function as a prototype after parsing it (we do not support recursion)
|
// Add the function as a prototype after parsing it (we do not support recursion)
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include "localintermediate.h"
|
#include "localintermediate.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Two purposes:
|
// Two purposes:
|
||||||
// 1. Show an example of how to iterate tree. Functions can
|
// 1. Show an example of how to iterate tree. Functions can
|
||||||
@ -584,3 +586,5 @@ void TIntermediate::outputTree(TIntermNode* root)
|
|||||||
|
|
||||||
root->traverse(&it);
|
root->traverse(&it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include "SymbolTable.h"
|
#include "SymbolTable.h"
|
||||||
#include "Versions.h"
|
#include "Versions.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
struct TVectorFields {
|
struct TVectorFields {
|
||||||
int offsets[4];
|
int offsets[4];
|
||||||
int num;
|
int num;
|
||||||
@ -48,7 +50,6 @@ struct TVectorFields {
|
|||||||
//
|
//
|
||||||
// Set of helper functions to help parse and build the tree.
|
// Set of helper functions to help parse and build the tree.
|
||||||
//
|
//
|
||||||
class TInfoSink;
|
|
||||||
class TIntermediate {
|
class TIntermediate {
|
||||||
public:
|
public:
|
||||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||||
@ -74,9 +75,9 @@ public:
|
|||||||
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
|
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
|
||||||
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||||
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
|
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
|
||||||
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
|
TIntermConstantUnion* addConstantUnion(TConstUnion*, const TType&, TSourceLoc);
|
||||||
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
|
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
|
||||||
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, const TType&, bool singleConstantParam = false);
|
bool parseConstTree(TSourceLoc, TIntermNode*, TConstUnion*, TOperator, const TType&, bool singleConstantParam = false);
|
||||||
TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
|
TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
|
||||||
TIntermBranch* addBranch(TOperator, TSourceLoc);
|
TIntermBranch* addBranch(TOperator, TSourceLoc);
|
||||||
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
|
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
|
||||||
@ -97,4 +98,6 @@ private:
|
|||||||
void operator=(TIntermediate&); // prevent assignments
|
void operator=(TIntermediate&); // prevent assignments
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // _LOCAL_INTERMEDIATE_INCLUDED_
|
#endif // _LOCAL_INTERMEDIATE_INCLUDED_
|
||||||
|
@ -34,17 +34,19 @@
|
|||||||
|
|
||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Use this class to carry along data from node to node in
|
// Use this class to carry along data from node to node in
|
||||||
// the traversal
|
// the traversal
|
||||||
//
|
//
|
||||||
class TConstTraverser : public TIntermTraverser {
|
class TConstTraverser : public TIntermTraverser {
|
||||||
public:
|
public:
|
||||||
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
|
TConstTraverser(TConstUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
|
||||||
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), error(false), isMatrix(false),
|
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), error(false), isMatrix(false),
|
||||||
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;}
|
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;}
|
||||||
int index ;
|
int index ;
|
||||||
constUnion *unionArray;
|
TConstUnion *unionArray;
|
||||||
TOperator tOp;
|
TOperator tOp;
|
||||||
const TType& type;
|
const TType& type;
|
||||||
TOperator constructorType;
|
TOperator constructorType;
|
||||||
@ -173,7 +175,7 @@ bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverse
|
|||||||
void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
||||||
{
|
{
|
||||||
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
TConstTraverser* oit = static_cast<TConstTraverser*>(it);
|
||||||
constUnion* leftUnionArray = oit->unionArray;
|
TConstUnion* leftUnionArray = oit->unionArray;
|
||||||
int instanceSize = oit->type.getObjectSize();
|
int instanceSize = oit->type.getObjectSize();
|
||||||
|
|
||||||
if (oit->index >= instanceSize)
|
if (oit->index >= instanceSize)
|
||||||
@ -182,7 +184,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
|||||||
if (!oit->singleConstantParam) {
|
if (!oit->singleConstantParam) {
|
||||||
int size = node->getType().getObjectSize();
|
int size = node->getType().getObjectSize();
|
||||||
|
|
||||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||||
for (int i=0; i < size; i++) {
|
for (int i=0; i < size; i++) {
|
||||||
if (oit->index >= instanceSize)
|
if (oit->index >= instanceSize)
|
||||||
return;
|
return;
|
||||||
@ -198,7 +200,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
|||||||
matrixRows = oit->matrixRows;
|
matrixRows = oit->matrixRows;
|
||||||
isMatrix = oit->isMatrix;
|
isMatrix = oit->isMatrix;
|
||||||
totalSize = oit->index + size;
|
totalSize = oit->index + size;
|
||||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
TConstUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||||
if (!isMatrix) {
|
if (!isMatrix) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = oit->index; i < totalSize; i++) {
|
for (int i = oit->index; i < totalSize; i++) {
|
||||||
@ -255,7 +257,7 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
|
|||||||
// Individual functions can be initialized to 0 to skip processing of that
|
// Individual functions can be initialized to 0 to skip processing of that
|
||||||
// type of node. It's children will still be processed.
|
// type of node. It's children will still be processed.
|
||||||
//
|
//
|
||||||
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
|
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, TConstUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
|
||||||
{
|
{
|
||||||
if (root == 0)
|
if (root == 0)
|
||||||
return false;
|
return false;
|
||||||
@ -277,3 +279,5 @@ bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnio
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -94,6 +94,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#undef malloc
|
#undef malloc
|
||||||
#undef free
|
#undef free
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
int TPpContext::InitCPP()
|
int TPpContext::InitCPP()
|
||||||
{
|
{
|
||||||
TPpContext::AtomTable* atable = &atomTable;
|
TPpContext::AtomTable* atable = &atomTable;
|
||||||
@ -821,8 +823,8 @@ void TPpContext::FreeMacro(MacroSymbol *s) {
|
|||||||
DeleteTokenStream(s->body);
|
DeleteTokenStream(s->body);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
|
int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
|
||||||
static void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
|
void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
|
||||||
|
|
||||||
void TPpContext::PushEofSrc()
|
void TPpContext::PushEofSrc()
|
||||||
{
|
{
|
||||||
@ -1074,3 +1076,5 @@ int TPpContext::ChkCorrectElseNesting()
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
@ -94,11 +94,15 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#undef realloc
|
#undef realloc
|
||||||
#undef free
|
#undef free
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using namespace glslang;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////// String table: //////////////////////////////////////
|
////////////////////////////////////////// String table: //////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static const struct {
|
const struct {
|
||||||
int val;
|
int val;
|
||||||
const char *str;
|
const char *str;
|
||||||
} tokens[] = {
|
} tokens[] = {
|
||||||
@ -135,7 +139,6 @@ static const struct {
|
|||||||
* InitStringTable() - Initialize the string table.
|
* InitStringTable() - Initialize the string table.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int InitStringTable(TPpContext::StringTable *stable)
|
int InitStringTable(TPpContext::StringTable *stable)
|
||||||
{
|
{
|
||||||
stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
|
stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
|
||||||
@ -151,7 +154,6 @@ int InitStringTable(TPpContext::StringTable *stable)
|
|||||||
* FreeStringTable() - Free the string table.
|
* FreeStringTable() - Free the string table.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void FreeStringTable(TPpContext::StringTable *stable)
|
void FreeStringTable(TPpContext::StringTable *stable)
|
||||||
{
|
{
|
||||||
if (stable->strings)
|
if (stable->strings)
|
||||||
@ -165,8 +167,7 @@ void FreeStringTable(TPpContext::StringTable *stable)
|
|||||||
* HashString() - Hash a string with the base hash function.
|
* HashString() - Hash a string with the base hash function.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int HashString(const char *s)
|
||||||
static int HashString(const char *s)
|
|
||||||
{
|
{
|
||||||
int hval = 0;
|
int hval = 0;
|
||||||
|
|
||||||
@ -181,8 +182,7 @@ static int HashString(const char *s)
|
|||||||
* HashString2() - Hash a string with the incrimenting hash function.
|
* HashString2() - Hash a string with the incrimenting hash function.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int HashString2(const char *s)
|
||||||
static int HashString2(const char *s)
|
|
||||||
{
|
{
|
||||||
int hval = 0;
|
int hval = 0;
|
||||||
|
|
||||||
@ -197,8 +197,7 @@ static int HashString2(const char *s)
|
|||||||
* AddString() - Add a string to a string table. Return it's offset.
|
* AddString() - Add a string to a string table. Return it's offset.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int AddString(TPpContext::StringTable *stable, const char *s)
|
||||||
static int AddString(TPpContext::StringTable *stable, const char *s)
|
|
||||||
{
|
{
|
||||||
int len, loc;
|
int len, loc;
|
||||||
char *str;
|
char *str;
|
||||||
@ -227,8 +226,7 @@ static int AddString(TPpContext::StringTable *stable, const char *s)
|
|||||||
* InitHashTable() - Initialize the hash table.
|
* InitHashTable() - Initialize the hash table.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int InitHashTable(TPpContext::HashTable *htable, int fsize)
|
||||||
static int InitHashTable(TPpContext::HashTable *htable, int fsize)
|
|
||||||
{
|
{
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
@ -250,8 +248,7 @@ static int InitHashTable(TPpContext::HashTable *htable, int fsize)
|
|||||||
* FreeHashTable() - Free the hash table.
|
* FreeHashTable() - Free the hash table.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
void FreeHashTable(TPpContext::HashTable *htable)
|
||||||
static void FreeHashTable(TPpContext::HashTable *htable)
|
|
||||||
{
|
{
|
||||||
if (htable->entry)
|
if (htable->entry)
|
||||||
free(htable->entry);
|
free(htable->entry);
|
||||||
@ -264,8 +261,7 @@ static void FreeHashTable(TPpContext::HashTable *htable)
|
|||||||
* Empty() - See if a hash table entry is empty.
|
* Empty() - See if a hash table entry is empty.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int Empty(TPpContext::HashTable *htable, int hashloc)
|
||||||
static int Empty(TPpContext::HashTable *htable, int hashloc)
|
|
||||||
{
|
{
|
||||||
assert(hashloc >= 0 && hashloc < htable->size);
|
assert(hashloc >= 0 && hashloc < htable->size);
|
||||||
if (htable->entry[hashloc].index == 0) {
|
if (htable->entry[hashloc].index == 0) {
|
||||||
@ -279,8 +275,7 @@ static int Empty(TPpContext::HashTable *htable, int hashloc)
|
|||||||
* Match() - See if a hash table entry is matches a string.
|
* Match() - See if a hash table entry is matches a string.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
|
||||||
static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
|
|
||||||
{
|
{
|
||||||
int strloc;
|
int strloc;
|
||||||
|
|
||||||
@ -302,7 +297,6 @@ static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable,
|
|||||||
* GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
|
* GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int GrowAtomTable(TPpContext::AtomTable *atable, int size)
|
int GrowAtomTable(TPpContext::AtomTable *atable, int size)
|
||||||
{
|
{
|
||||||
int *newmap, *newrev;
|
int *newmap, *newrev;
|
||||||
@ -337,8 +331,7 @@ int GrowAtomTable(TPpContext::AtomTable *atable, int size)
|
|||||||
* lReverse() - Reverse the bottom 20 bits of a 32 bit int.
|
* lReverse() - Reverse the bottom 20 bits of a 32 bit int.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int lReverse(int fval)
|
||||||
static int lReverse(int fval)
|
|
||||||
{
|
{
|
||||||
unsigned int in = fval;
|
unsigned int in = fval;
|
||||||
int result = 0, cnt = 0;
|
int result = 0, cnt = 0;
|
||||||
@ -362,7 +355,6 @@ static int lReverse(int fval)
|
|||||||
* AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
|
* AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int AllocateAtom(TPpContext::AtomTable *atable)
|
int AllocateAtom(TPpContext::AtomTable *atable)
|
||||||
{
|
{
|
||||||
if (atable->nextFree >= atable->size)
|
if (atable->nextFree >= atable->size)
|
||||||
@ -377,7 +369,6 @@ int AllocateAtom(TPpContext::AtomTable *atable)
|
|||||||
* SetAtomValue() - Allocate a new atom associated with "hashindex".
|
* SetAtomValue() - Allocate a new atom associated with "hashindex".
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
|
void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
|
||||||
{
|
{
|
||||||
atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
|
atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
|
||||||
@ -388,7 +379,6 @@ void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
|
|||||||
* FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
|
* FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
|
int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
|
||||||
{
|
{
|
||||||
int hashloc, hashdelta, count;
|
int hashloc, hashdelta, count;
|
||||||
@ -438,11 +428,14 @@ int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
|
|||||||
return hashloc;
|
return hashloc;
|
||||||
} // FindHashLoc
|
} // FindHashLoc
|
||||||
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IncreaseHashTableSize()
|
* IncreaseHashTableSize()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int TPpContext::IncreaseHashTableSize(AtomTable *atable)
|
int TPpContext::IncreaseHashTableSize(AtomTable *atable)
|
||||||
{
|
{
|
||||||
int ii, strloc, oldhashloc, value, size;
|
int ii, strloc, oldhashloc, value, size;
|
||||||
@ -705,7 +698,4 @@ void TPpContext::FreeAtomTable(AtomTable *atable)
|
|||||||
atable->size = 0;
|
atable->size = 0;
|
||||||
} // FreeAtomTable
|
} // FreeAtomTable
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
} // end namespace glslang
|
||||||
///////////////////////////////////////// End of atom.c ///////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include "PpContext.h"
|
#include "PpContext.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
TPpContext::TPpContext(TParseContext& pc) :
|
TPpContext::TPpContext(TParseContext& pc) :
|
||||||
parseContext(pc), preamble(0), strings(0), notAVersionToken(false),
|
parseContext(pc), preamble(0), strings(0), notAVersionToken(false),
|
||||||
ScopeList(0), CurrentScope(0), GlobalScope(0)
|
ScopeList(0), CurrentScope(0), GlobalScope(0)
|
||||||
@ -124,3 +126,5 @@ void TPpContext::setShaderStrings(char* s[], int l[], int n)
|
|||||||
currentString = 0;
|
currentString = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -80,6 +80,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include "../ParseHelper.h"
|
#include "../ParseHelper.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
class TPpToken {
|
class TPpToken {
|
||||||
public:
|
public:
|
||||||
static const int maxTokenLength = 1024;
|
static const int maxTokenLength = 1024;
|
||||||
@ -386,5 +388,6 @@ protected:
|
|||||||
int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
|
int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PPCONTEXT_H
|
} // end namespace glslang
|
||||||
|
|
||||||
|
#endif // PPCONTEXT_H
|
||||||
|
@ -91,6 +91,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#undef malloc
|
#undef malloc
|
||||||
#undef free
|
#undef free
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
struct chunk {
|
struct chunk {
|
||||||
struct chunk *next;
|
struct chunk *next;
|
||||||
};
|
};
|
||||||
@ -184,3 +186,5 @@ int TPpContext::mem_AddCleanup(MemoryPool *pool, void (*fn)(void *, void*), void
|
|||||||
pool->cleanup = cleanup;
|
pool->cleanup = cleanup;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -89,13 +89,24 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "PpContext.h"
|
#include "PpContext.h"
|
||||||
#include "PpTokens.h"
|
#include "PpTokens.h"
|
||||||
|
|
||||||
static int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
|
namespace {
|
||||||
|
|
||||||
|
using namespace glslang;
|
||||||
|
|
||||||
|
int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
|
||||||
{
|
{
|
||||||
return EOF;
|
return EOF;
|
||||||
} // eof_scan
|
}
|
||||||
|
|
||||||
static void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp) {}
|
void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp)
|
||||||
static TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
|
||||||
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
int TPpContext::InitScanner(TPpContext *cpp)
|
int TPpContext::InitScanner(TPpContext *cpp)
|
||||||
{
|
{
|
||||||
@ -831,7 +842,4 @@ int TPpContext::check_EOF(int token)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
} // end namespace glslang
|
||||||
/////////////////////////////////////// End of scanner.c //////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
@ -90,7 +90,11 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static void unlinkScope(void *_scope, void* scopeList)
|
namespace {
|
||||||
|
|
||||||
|
using namespace glslang;
|
||||||
|
|
||||||
|
void unlinkScope(void *_scope, void* scopeList)
|
||||||
{
|
{
|
||||||
TPpContext::Scope *scope = (TPpContext::Scope*)_scope;
|
TPpContext::Scope *scope = (TPpContext::Scope*)_scope;
|
||||||
|
|
||||||
@ -102,6 +106,10 @@ static void unlinkScope(void *_scope, void* scopeList)
|
|||||||
*(TPpContext::Scope**)scopeList = scope->next;
|
*(TPpContext::Scope**)scopeList = scope->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NewScope()
|
* NewScope()
|
||||||
*
|
*
|
||||||
@ -315,3 +323,4 @@ TPpContext::Symbol* TPpContext::LookUpSymbol(Scope *fScope, int atom)
|
|||||||
return NULL;
|
return NULL;
|
||||||
} // LookUpSymbol
|
} // LookUpSymbol
|
||||||
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -92,6 +92,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "PpContext.h"
|
#include "PpContext.h"
|
||||||
#include "PpTokens.h"
|
#include "PpTokens.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
|
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -488,6 +490,4 @@ void TPpContext::DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
} // end namespace glslang
|
||||||
/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
#define _vsnprintf vsnprintf
|
#define _vsnprintf vsnprintf
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
void DetachThreadLinux(void *);
|
void DetachThreadLinux(void *);
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
|
|||||||
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
||||||
|
|
||||||
|
|
||||||
inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// This function should return 0 if nIndex is invalid.
|
// This function should return 0 if nIndex is invalid.
|
||||||
@ -69,18 +70,18 @@ inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
|
|||||||
return pthread_getspecific(nIndex);
|
return pthread_getspecific(nIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace glslang {
|
void InitGlobalLock();
|
||||||
void InitGlobalLock();
|
void GetGlobalLock();
|
||||||
void GetGlobalLock();
|
void ReleaseGlobalLock();
|
||||||
void ReleaseGlobalLock();
|
|
||||||
|
|
||||||
typedef unsigned int (*TThreadEntrypoint)(void*);
|
typedef unsigned int (*TThreadEntrypoint)(void*);
|
||||||
void* OS_CreateThread(TThreadEntrypoint);
|
void* OS_CreateThread(TThreadEntrypoint);
|
||||||
void OS_WaitForAllThreads(void* threads, int numThreads);
|
void OS_WaitForAllThreads(void* threads, int numThreads);
|
||||||
|
|
||||||
void OS_Sleep(int milliseconds);
|
void OS_Sleep(int milliseconds);
|
||||||
|
|
||||||
void OS_DumpMemoryCounters();
|
void OS_DumpMemoryCounters();
|
||||||
};
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // __OSINCLUDE_H
|
#endif // __OSINCLUDE_H
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "osinclude.h"
|
#include "osinclude.h"
|
||||||
#include "InitializeDll.h"
|
#include "InitializeDll.h"
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Thread cleanup
|
// Thread cleanup
|
||||||
//
|
//
|
||||||
@ -135,25 +137,25 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace glslang {
|
// TODO: if we need these on linux, flesh them out
|
||||||
// TODO: if we need these on linux, flesh them out
|
void InitGlobalLock() { }
|
||||||
void InitGlobalLock() { }
|
void GetGlobalLock() { }
|
||||||
void GetGlobalLock() { }
|
void ReleaseGlobalLock() { }
|
||||||
void ReleaseGlobalLock() { }
|
|
||||||
|
|
||||||
void* OS_CreateThread(TThreadEntrypoint entry)
|
void* OS_CreateThread(TThreadEntrypoint entry)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_WaitForAllThreads(void* threads, int numThreads)
|
void OS_WaitForAllThreads(void* threads, int numThreads)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_Sleep(int milliseconds)
|
void OS_Sleep(int milliseconds)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_DumpMemoryCounters()
|
void OS_DumpMemoryCounters()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
} // end namespace glslang
|
||||||
|
@ -45,24 +45,24 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
|
|
||||||
if (!InitProcess())
|
if (! glslang::InitProcess())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
|
|
||||||
if (!InitThread())
|
if (! glslang::InitThread())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_DETACH:
|
||||||
|
|
||||||
if (!DetachThread())
|
if (! glslang::DetachThread())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
|
|
||||||
DetachProcess();
|
glslang::DetachProcess();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
#error Trying to include a windows specific file in a non windows build.
|
#error Trying to include a windows specific file in a non windows build.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Thread Local Storage Operations
|
// Thread Local Storage Operations
|
||||||
//
|
//
|
||||||
@ -56,18 +58,18 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
|
|||||||
|
|
||||||
void* OS_GetTLSValue(OS_TLSIndex nIndex);
|
void* OS_GetTLSValue(OS_TLSIndex nIndex);
|
||||||
|
|
||||||
namespace glslang {
|
void InitGlobalLock();
|
||||||
void InitGlobalLock();
|
void GetGlobalLock();
|
||||||
void GetGlobalLock();
|
void ReleaseGlobalLock();
|
||||||
void ReleaseGlobalLock();
|
|
||||||
|
|
||||||
typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
|
typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
|
||||||
void* OS_CreateThread(TThreadEntrypoint);
|
void* OS_CreateThread(TThreadEntrypoint);
|
||||||
void OS_WaitForAllThreads(void* threads, int numThreads);
|
void OS_WaitForAllThreads(void* threads, int numThreads);
|
||||||
|
|
||||||
void OS_Sleep(int milliseconds);
|
void OS_Sleep(int milliseconds);
|
||||||
|
|
||||||
void OS_DumpMemoryCounters();
|
void OS_DumpMemoryCounters();
|
||||||
};
|
|
||||||
|
} // end namespace glslang
|
||||||
|
|
||||||
#endif // __OSINCLUDE_H
|
#endif // __OSINCLUDE_H
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
#error Trying to build a windows specific file in a non windows build.
|
#error Trying to build a windows specific file in a non windows build.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace glslang {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Thread Local Storage Operations
|
// Thread Local Storage Operations
|
||||||
//
|
//
|
||||||
@ -97,44 +99,44 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace glslang {
|
HANDLE GlobalLock;
|
||||||
HANDLE GlobalLock;
|
|
||||||
|
|
||||||
void InitGlobalLock()
|
void InitGlobalLock()
|
||||||
{
|
{
|
||||||
GlobalLock = CreateMutex(0, false, 0);
|
GlobalLock = CreateMutex(0, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetGlobalLock()
|
void GetGlobalLock()
|
||||||
{
|
{
|
||||||
WaitForSingleObject(GlobalLock, INFINITE);
|
WaitForSingleObject(GlobalLock, INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseGlobalLock()
|
void ReleaseGlobalLock()
|
||||||
{
|
{
|
||||||
ReleaseMutex(GlobalLock);
|
ReleaseMutex(GlobalLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* OS_CreateThread(TThreadEntrypoint entry)
|
void* OS_CreateThread(TThreadEntrypoint entry)
|
||||||
{
|
{
|
||||||
return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
|
return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
|
||||||
//return CreateThread(0, 0, entry, 0, 0, 0);
|
//return CreateThread(0, 0, entry, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_WaitForAllThreads(void* threads, int numThreads)
|
void OS_WaitForAllThreads(void* threads, int numThreads)
|
||||||
{
|
{
|
||||||
WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
|
WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_Sleep(int milliseconds)
|
void OS_Sleep(int milliseconds)
|
||||||
{
|
{
|
||||||
Sleep(milliseconds);
|
Sleep(milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_DumpMemoryCounters()
|
void OS_DumpMemoryCounters()
|
||||||
{
|
{
|
||||||
PROCESS_MEMORY_COUNTERS counters;
|
PROCESS_MEMORY_COUNTERS counters;
|
||||||
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
|
GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
|
||||||
printf("Working set size: %d\n", counters.WorkingSetSize);
|
printf("Working set size: %d\n", counters.WorkingSetSize);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
} // namespace glslang
|
||||||
|
Loading…
x
Reference in New Issue
Block a user