diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-08-05 13:58:05 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-08-05 13:58:05 +0100 |
commit | 663b3925425a23852b2f18be032dd4601f9f479d (patch) | |
tree | 0083012bed0022595067fba22a770f80528e1f97 | |
parent | 4e77342e7c8ef3531bf01c0569d36655ab762ac2 (diff) | |
parent | 395cc9e8e9f4b00dfdf44217953e55188e53bbf8 (diff) | |
download | angle_dx11-663b3925425a23852b2f18be032dd4601f9f479d.tar.gz |
Merge from Chromium at DEPS revision r215573
This commit was generated by merge_to_master.py.
Change-Id: I7c4fbd5691ba418842ccac05df353d52d3817973
49 files changed, 816 insertions, 963 deletions
diff --git a/src/build_angle.gypi b/src/build_angle.gypi index 405c6710..c91cce1b 100644 --- a/src/build_angle.gypi +++ b/src/build_angle.gypi @@ -293,6 +293,8 @@ 'libGLESv2/renderer/IndexBuffer11.h', 'libGLESv2/renderer/IndexDataManager.cpp', 'libGLESv2/renderer/IndexDataManager.h', + 'libGLESv2/renderer/IndexRangeCache.cpp', + 'libGLESv2/renderer/IndexRangeCache.h', 'libGLESv2/renderer/InputLayoutCache.cpp', 'libGLESv2/renderer/InputLayoutCache.h', 'libGLESv2/renderer/QueryImpl.h', diff --git a/src/common/version.h b/src/common/version.h index 5ea84259..0353fb48 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -1,7 +1,7 @@ #define MAJOR_VERSION 1 #define MINOR_VERSION 2 #define BUILD_VERSION 0 -#define BUILD_REVISION 2425 +#define BUILD_REVISION 2431 #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) diff --git a/src/compiler/Common.h b/src/compiler/Common.h index 532486a9..46f9440f 100644 --- a/src/compiler/Common.h +++ b/src/compiler/Common.h @@ -24,14 +24,14 @@ struct TSourceLoc { // // Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme. // -#define POOL_ALLOCATOR_NEW_DELETE(A) \ - void* operator new(size_t s) { return (A).allocate(s); } \ - void* operator new(size_t, void *_Where) { return (_Where); } \ - void operator delete(void*) { } \ - void operator delete(void *, void *) { } \ - void* operator new[](size_t s) { return (A).allocate(s); } \ - void* operator new[](size_t, void *_Where) { return (_Where); } \ - void operator delete[](void*) { } \ +#define POOL_ALLOCATOR_NEW_DELETE() \ + void* operator new(size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \ + void* operator new(size_t, void *_Where) { return (_Where); } \ + void operator delete(void*) { } \ + void operator delete(void *, void *) { } \ + void* operator new[](size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \ + void* operator new[](size_t, void *_Where) { return (_Where); } \ + void operator delete[](void*) { } \ void operator delete[](void *, void *) { } // @@ -42,7 +42,7 @@ typedef std::basic_string <char, std::char_traits<char>, TStringAllocator> TStri typedef std::basic_ostringstream<char, std::char_traits<char>, TStringAllocator> TStringStream; inline TString* NewPoolTString(const char* s) { - void* memory = GlobalPoolAllocator.allocate(sizeof(TString)); + void* memory = GetGlobalPoolAllocator()->allocate(sizeof(TString)); return new(memory) TString(s); } diff --git a/src/compiler/Compiler.cpp b/src/compiler/Compiler.cpp index 4525cb92..3e80d96a 100644 --- a/src/compiler/Compiler.cpp +++ b/src/compiler/Compiler.cpp @@ -125,7 +125,7 @@ bool TCompiler::compile(const char* const shaderStrings[], shaderType, shaderSpec, compileOptions, true, sourcePath, infoSink); parseContext.fragmentPrecisionHigh = fragmentPrecisionHigh; - GlobalParseContext = &parseContext; + SetGlobalParseContext(&parseContext); // We preserve symbols at the built-in level from compile-to-compile. // Start pushing the user-defined symbols at global level. @@ -237,7 +237,7 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) default: assert(false && "Language not supported"); } - InsertBuiltInFunctions(shaderType, shaderSpec, resources, extensionBehavior, symbolTable); + InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable); IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable); diff --git a/src/compiler/ConstantUnion.h b/src/compiler/ConstantUnion.h index 32af4d38..b1e37885 100644 --- a/src/compiler/ConstantUnion.h +++ b/src/compiler/ConstantUnion.h @@ -11,13 +11,13 @@ class ConstantUnion { public: + POOL_ALLOCATOR_NEW_DELETE(); ConstantUnion() { iConst = 0; type = EbtVoid; } - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) void setIConst(int i) {iConst = i; type = EbtInt; } void setFConst(float f) {fConst = f; type = EbtFloat; } void setBConst(bool b) {bConst = b; type = EbtBool; } diff --git a/src/compiler/Initialize.cpp b/src/compiler/Initialize.cpp index 0ed3b8df..2cdbe17a 100644 --- a/src/compiler/Initialize.cpp +++ b/src/compiler/Initialize.cpp @@ -14,8 +14,7 @@ #include "compiler/intermediate.h" -void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, - const TExtensionBehavior &extensionBehavior, TSymbolTable &symbolTable) +void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) { TType *float1 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 1); TType *float2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2); @@ -29,211 +28,211 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI // // Angle and Trigonometric Functions. // - symbolTable.insertBuiltIn(float1, "radians", float1, "degrees"); - symbolTable.insertBuiltIn(float2, "radians", float2, "degrees"); - symbolTable.insertBuiltIn(float3, "radians", float3, "degrees"); - symbolTable.insertBuiltIn(float4, "radians", float4, "degrees"); - - symbolTable.insertBuiltIn(float1, "degrees", float1, "radians"); - symbolTable.insertBuiltIn(float2, "degrees", float2, "radians"); - symbolTable.insertBuiltIn(float3, "degrees", float3, "radians"); - symbolTable.insertBuiltIn(float4, "degrees", float4, "radians"); - - symbolTable.insertBuiltIn(float1, "sin", float1, "angle"); - symbolTable.insertBuiltIn(float2, "sin", float2, "angle"); - symbolTable.insertBuiltIn(float3, "sin", float3, "angle"); - symbolTable.insertBuiltIn(float4, "sin", float4, "angle"); - - symbolTable.insertBuiltIn(float1, "cos", float1, "angle"); - symbolTable.insertBuiltIn(float2, "cos", float2, "angle"); - symbolTable.insertBuiltIn(float3, "cos", float3, "angle"); - symbolTable.insertBuiltIn(float4, "cos", float4, "angle"); - - symbolTable.insertBuiltIn(float1, "tan", float1, "angle"); - symbolTable.insertBuiltIn(float2, "tan", float2, "angle"); - symbolTable.insertBuiltIn(float3, "tan", float3, "angle"); - symbolTable.insertBuiltIn(float4, "tan", float4, "angle"); - - symbolTable.insertBuiltIn(float1, "asin", float1, "x"); - symbolTable.insertBuiltIn(float2, "asin", float2, "x"); - symbolTable.insertBuiltIn(float3, "asin", float3, "x"); - symbolTable.insertBuiltIn(float4, "asin", float4, "x"); - - symbolTable.insertBuiltIn(float1, "acos", float1, "x"); - symbolTable.insertBuiltIn(float2, "acos", float2, "x"); - symbolTable.insertBuiltIn(float3, "acos", float3, "x"); - symbolTable.insertBuiltIn(float4, "acos", float4, "x"); - - symbolTable.insertBuiltIn(float1, "atan", float1, "y", float1, "x"); - symbolTable.insertBuiltIn(float2, "atan", float2, "y", float2, "x"); - symbolTable.insertBuiltIn(float3, "atan", float3, "y", float3, "x"); - symbolTable.insertBuiltIn(float4, "atan", float4, "y", float4, "x"); - - symbolTable.insertBuiltIn(float1, "atan", float1, "y_over_x"); - symbolTable.insertBuiltIn(float2, "atan", float2, "y_over_x"); - symbolTable.insertBuiltIn(float3, "atan", float3, "y_over_x"); - symbolTable.insertBuiltIn(float4, "atan", float4, "y_over_x"); + symbolTable.insertBuiltIn(float1, "radians", float1); + symbolTable.insertBuiltIn(float2, "radians", float2); + symbolTable.insertBuiltIn(float3, "radians", float3); + symbolTable.insertBuiltIn(float4, "radians", float4); + + symbolTable.insertBuiltIn(float1, "degrees", float1); + symbolTable.insertBuiltIn(float2, "degrees", float2); + symbolTable.insertBuiltIn(float3, "degrees", float3); + symbolTable.insertBuiltIn(float4, "degrees", float4); + + symbolTable.insertBuiltIn(float1, "sin", float1); + symbolTable.insertBuiltIn(float2, "sin", float2); + symbolTable.insertBuiltIn(float3, "sin", float3); + symbolTable.insertBuiltIn(float4, "sin", float4); + + symbolTable.insertBuiltIn(float1, "cos", float1); + symbolTable.insertBuiltIn(float2, "cos", float2); + symbolTable.insertBuiltIn(float3, "cos", float3); + symbolTable.insertBuiltIn(float4, "cos", float4); + + symbolTable.insertBuiltIn(float1, "tan", float1); + symbolTable.insertBuiltIn(float2, "tan", float2); + symbolTable.insertBuiltIn(float3, "tan", float3); + symbolTable.insertBuiltIn(float4, "tan", float4); + + symbolTable.insertBuiltIn(float1, "asin", float1); + symbolTable.insertBuiltIn(float2, "asin", float2); + symbolTable.insertBuiltIn(float3, "asin", float3); + symbolTable.insertBuiltIn(float4, "asin", float4); + + symbolTable.insertBuiltIn(float1, "acos", float1); + symbolTable.insertBuiltIn(float2, "acos", float2); + symbolTable.insertBuiltIn(float3, "acos", float3); + symbolTable.insertBuiltIn(float4, "acos", float4); + + symbolTable.insertBuiltIn(float1, "atan", float1, float1); + symbolTable.insertBuiltIn(float2, "atan", float2, float2); + symbolTable.insertBuiltIn(float3, "atan", float3, float3); + symbolTable.insertBuiltIn(float4, "atan", float4, float4); + + symbolTable.insertBuiltIn(float1, "atan", float1); + symbolTable.insertBuiltIn(float2, "atan", float2); + symbolTable.insertBuiltIn(float3, "atan", float3); + symbolTable.insertBuiltIn(float4, "atan", float4); // // Exponential Functions. // - symbolTable.insertBuiltIn(float1, "pow", float1, "x", float1, "y"); - symbolTable.insertBuiltIn(float2, "pow", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(float3, "pow", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(float4, "pow", float4, "x", float4, "y"); - - symbolTable.insertBuiltIn(float1, "exp", float1, "x"); - symbolTable.insertBuiltIn(float2, "exp", float2, "x"); - symbolTable.insertBuiltIn(float3, "exp", float3, "x"); - symbolTable.insertBuiltIn(float4, "exp", float4, "x"); - - symbolTable.insertBuiltIn(float1, "log", float1, "x"); - symbolTable.insertBuiltIn(float2, "log", float2, "x"); - symbolTable.insertBuiltIn(float3, "log", float3, "x"); - symbolTable.insertBuiltIn(float4, "log", float4, "x"); - - symbolTable.insertBuiltIn(float1, "exp2", float1, "x"); - symbolTable.insertBuiltIn(float2, "exp2", float2, "x"); - symbolTable.insertBuiltIn(float3, "exp2", float3, "x"); - symbolTable.insertBuiltIn(float4, "exp2", float4, "x"); - - symbolTable.insertBuiltIn(float1, "log2", float1, "x"); - symbolTable.insertBuiltIn(float2, "log2", float2, "x"); - symbolTable.insertBuiltIn(float3, "log2", float3, "x"); - symbolTable.insertBuiltIn(float4, "log2", float4, "x"); - - symbolTable.insertBuiltIn(float1, "sqrt", float1, "x"); - symbolTable.insertBuiltIn(float2, "sqrt", float2, "x"); - symbolTable.insertBuiltIn(float3, "sqrt", float3, "x"); - symbolTable.insertBuiltIn(float4, "sqrt", float4, "x"); - - symbolTable.insertBuiltIn(float1, "inversesqrt", float1, "x"); - symbolTable.insertBuiltIn(float2, "inversesqrt", float2, "x"); - symbolTable.insertBuiltIn(float3, "inversesqrt", float3, "x"); - symbolTable.insertBuiltIn(float4, "inversesqrt", float4, "x"); + symbolTable.insertBuiltIn(float1, "pow", float1, float1); + symbolTable.insertBuiltIn(float2, "pow", float2, float2); + symbolTable.insertBuiltIn(float3, "pow", float3, float3); + symbolTable.insertBuiltIn(float4, "pow", float4, float4); + + symbolTable.insertBuiltIn(float1, "exp", float1); + symbolTable.insertBuiltIn(float2, "exp", float2); + symbolTable.insertBuiltIn(float3, "exp", float3); + symbolTable.insertBuiltIn(float4, "exp", float4); + + symbolTable.insertBuiltIn(float1, "log", float1); + symbolTable.insertBuiltIn(float2, "log", float2); + symbolTable.insertBuiltIn(float3, "log", float3); + symbolTable.insertBuiltIn(float4, "log", float4); + + symbolTable.insertBuiltIn(float1, "exp2", float1); + symbolTable.insertBuiltIn(float2, "exp2", float2); + symbolTable.insertBuiltIn(float3, "exp2", float3); + symbolTable.insertBuiltIn(float4, "exp2", float4); + + symbolTable.insertBuiltIn(float1, "log2", float1); + symbolTable.insertBuiltIn(float2, "log2", float2); + symbolTable.insertBuiltIn(float3, "log2", float3); + symbolTable.insertBuiltIn(float4, "log2", float4); + + symbolTable.insertBuiltIn(float1, "sqrt", float1); + symbolTable.insertBuiltIn(float2, "sqrt", float2); + symbolTable.insertBuiltIn(float3, "sqrt", float3); + symbolTable.insertBuiltIn(float4, "sqrt", float4); + + symbolTable.insertBuiltIn(float1, "inversesqrt", float1); + symbolTable.insertBuiltIn(float2, "inversesqrt", float2); + symbolTable.insertBuiltIn(float3, "inversesqrt", float3); + symbolTable.insertBuiltIn(float4, "inversesqrt", float4); // // Common Functions. // - symbolTable.insertBuiltIn(float1, "abs", float1, "x"); - symbolTable.insertBuiltIn(float2, "abs", float2, "x"); - symbolTable.insertBuiltIn(float3, "abs", float3, "x"); - symbolTable.insertBuiltIn(float4, "abs", float4, "x"); - - symbolTable.insertBuiltIn(float1, "sign", float1, "x"); - symbolTable.insertBuiltIn(float2, "sign", float2, "x"); - symbolTable.insertBuiltIn(float3, "sign", float3, "x"); - symbolTable.insertBuiltIn(float4, "sign", float4, "x"); - - symbolTable.insertBuiltIn(float1, "floor", float1, "x"); - symbolTable.insertBuiltIn(float2, "floor", float2, "x"); - symbolTable.insertBuiltIn(float3, "floor", float3, "x"); - symbolTable.insertBuiltIn(float4, "floor", float4, "x"); - - symbolTable.insertBuiltIn(float1, "ceil", float1, "x"); - symbolTable.insertBuiltIn(float2, "ceil", float2, "x"); - symbolTable.insertBuiltIn(float3, "ceil", float3, "x"); - symbolTable.insertBuiltIn(float4, "ceil", float4, "x"); - - symbolTable.insertBuiltIn(float1, "fract", float1, "x"); - symbolTable.insertBuiltIn(float2, "fract", float2, "x"); - symbolTable.insertBuiltIn(float3, "fract", float3, "x"); - symbolTable.insertBuiltIn(float4, "fract", float4, "x"); - - symbolTable.insertBuiltIn(float1, "mod", float1, "x", float1, "y"); - symbolTable.insertBuiltIn(float2, "mod", float2, "x", float1, "y"); - symbolTable.insertBuiltIn(float3, "mod", float3, "x", float1, "y"); - symbolTable.insertBuiltIn(float4, "mod", float4, "x", float1, "y"); - symbolTable.insertBuiltIn(float2, "mod", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(float3, "mod", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(float4, "mod", float4, "x", float4, "y"); - - symbolTable.insertBuiltIn(float1, "min", float1, "x", float1, "y"); - symbolTable.insertBuiltIn(float2, "min", float2, "x", float1, "y"); - symbolTable.insertBuiltIn(float3, "min", float3, "x", float1, "y"); - symbolTable.insertBuiltIn(float4, "min", float4, "x", float1, "y"); - symbolTable.insertBuiltIn(float2, "min", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(float3, "min", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(float4, "min", float4, "x", float4, "y"); - - symbolTable.insertBuiltIn(float1, "max", float1, "x", float1, "y"); - symbolTable.insertBuiltIn(float2, "max", float2, "x", float1, "y"); - symbolTable.insertBuiltIn(float3, "max", float3, "x", float1, "y"); - symbolTable.insertBuiltIn(float4, "max", float4, "x", float1, "y"); - symbolTable.insertBuiltIn(float2, "max", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(float3, "max", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(float4, "max", float4, "x", float4, "y"); - - symbolTable.insertBuiltIn(float1, "clamp", float1, "x", float1, "minVal", float1, "maxVal"); - symbolTable.insertBuiltIn(float2, "clamp", float2, "x", float1, "minVal", float1, "maxVal"); - symbolTable.insertBuiltIn(float3, "clamp", float3, "x", float1, "minVal", float1, "maxVal"); - symbolTable.insertBuiltIn(float4, "clamp", float4, "x", float1, "minVal", float1, "maxVal"); - symbolTable.insertBuiltIn(float2, "clamp", float2, "x", float2, "minVal", float2, "maxVal"); - symbolTable.insertBuiltIn(float3, "clamp", float3, "x", float3, "minVal", float3, "maxVal"); - symbolTable.insertBuiltIn(float4, "clamp", float4, "x", float4, "minVal", float4, "maxVal"); - - symbolTable.insertBuiltIn(float1, "mix", float1, "x", float1, "y", float1, "a"); - symbolTable.insertBuiltIn(float2, "mix", float2, "x", float2, "y", float1, "a"); - symbolTable.insertBuiltIn(float3, "mix", float3, "x", float3, "y", float1, "a"); - symbolTable.insertBuiltIn(float4, "mix", float4, "x", float4, "y", float1, "a"); - symbolTable.insertBuiltIn(float2, "mix", float2, "x", float2, "y", float2, "a"); - symbolTable.insertBuiltIn(float3, "mix", float3, "x", float3, "y", float3, "a"); - symbolTable.insertBuiltIn(float4, "mix", float4, "x", float4, "y", float4, "a"); - - symbolTable.insertBuiltIn(float1, "step", float1, "edge", float1, "x"); - symbolTable.insertBuiltIn(float2, "step", float2, "edge", float2, "x"); - symbolTable.insertBuiltIn(float3, "step", float3, "edge", float3, "x"); - symbolTable.insertBuiltIn(float4, "step", float4, "edge", float4, "x"); - symbolTable.insertBuiltIn(float2, "step", float1, "edge", float2, "x"); - symbolTable.insertBuiltIn(float3, "step", float1, "edge", float3, "x"); - symbolTable.insertBuiltIn(float4, "step", float1, "edge", float4, "x"); - - symbolTable.insertBuiltIn(float1, "smoothstep", float1, "edge0", float1, "edge1", float1, "x"); - symbolTable.insertBuiltIn(float2, "smoothstep", float2, "edge0", float2, "edge1", float2, "x"); - symbolTable.insertBuiltIn(float3, "smoothstep", float3, "edge0", float3, "edge1", float3, "x"); - symbolTable.insertBuiltIn(float4, "smoothstep", float4, "edge0", float4, "edge1", float4, "x"); - symbolTable.insertBuiltIn(float2, "smoothstep", float1, "edge0", float1, "edge1", float2, "x"); - symbolTable.insertBuiltIn(float3, "smoothstep", float1, "edge0", float1, "edge1", float3, "x"); - symbolTable.insertBuiltIn(float4, "smoothstep", float1, "edge0", float1, "edge1", float4, "x"); + symbolTable.insertBuiltIn(float1, "abs", float1); + symbolTable.insertBuiltIn(float2, "abs", float2); + symbolTable.insertBuiltIn(float3, "abs", float3); + symbolTable.insertBuiltIn(float4, "abs", float4); + + symbolTable.insertBuiltIn(float1, "sign", float1); + symbolTable.insertBuiltIn(float2, "sign", float2); + symbolTable.insertBuiltIn(float3, "sign", float3); + symbolTable.insertBuiltIn(float4, "sign", float4); + + symbolTable.insertBuiltIn(float1, "floor", float1); + symbolTable.insertBuiltIn(float2, "floor", float2); + symbolTable.insertBuiltIn(float3, "floor", float3); + symbolTable.insertBuiltIn(float4, "floor", float4); + + symbolTable.insertBuiltIn(float1, "ceil", float1); + symbolTable.insertBuiltIn(float2, "ceil", float2); + symbolTable.insertBuiltIn(float3, "ceil", float3); + symbolTable.insertBuiltIn(float4, "ceil", float4); + + symbolTable.insertBuiltIn(float1, "fract", float1); + symbolTable.insertBuiltIn(float2, "fract", float2); + symbolTable.insertBuiltIn(float3, "fract", float3); + symbolTable.insertBuiltIn(float4, "fract", float4); + + symbolTable.insertBuiltIn(float1, "mod", float1, float1); + symbolTable.insertBuiltIn(float2, "mod", float2, float1); + symbolTable.insertBuiltIn(float3, "mod", float3, float1); + symbolTable.insertBuiltIn(float4, "mod", float4, float1); + symbolTable.insertBuiltIn(float2, "mod", float2, float2); + symbolTable.insertBuiltIn(float3, "mod", float3, float3); + symbolTable.insertBuiltIn(float4, "mod", float4, float4); + + symbolTable.insertBuiltIn(float1, "min", float1, float1); + symbolTable.insertBuiltIn(float2, "min", float2, float1); + symbolTable.insertBuiltIn(float3, "min", float3, float1); + symbolTable.insertBuiltIn(float4, "min", float4, float1); + symbolTable.insertBuiltIn(float2, "min", float2, float2); + symbolTable.insertBuiltIn(float3, "min", float3, float3); + symbolTable.insertBuiltIn(float4, "min", float4, float4); + + symbolTable.insertBuiltIn(float1, "max", float1, float1); + symbolTable.insertBuiltIn(float2, "max", float2, float1); + symbolTable.insertBuiltIn(float3, "max", float3, float1); + symbolTable.insertBuiltIn(float4, "max", float4, float1); + symbolTable.insertBuiltIn(float2, "max", float2, float2); + symbolTable.insertBuiltIn(float3, "max", float3, float3); + symbolTable.insertBuiltIn(float4, "max", float4, float4); + + symbolTable.insertBuiltIn(float1, "clamp", float1, float1, float1); + symbolTable.insertBuiltIn(float2, "clamp", float2, float1, float1); + symbolTable.insertBuiltIn(float3, "clamp", float3, float1, float1); + symbolTable.insertBuiltIn(float4, "clamp", float4, float1, float1); + symbolTable.insertBuiltIn(float2, "clamp", float2, float2, float2); + symbolTable.insertBuiltIn(float3, "clamp", float3, float3, float3); + symbolTable.insertBuiltIn(float4, "clamp", float4, float4, float4); + + symbolTable.insertBuiltIn(float1, "mix", float1, float1, float1); + symbolTable.insertBuiltIn(float2, "mix", float2, float2, float1); + symbolTable.insertBuiltIn(float3, "mix", float3, float3, float1); + symbolTable.insertBuiltIn(float4, "mix", float4, float4, float1); + symbolTable.insertBuiltIn(float2, "mix", float2, float2, float2); + symbolTable.insertBuiltIn(float3, "mix", float3, float3, float3); + symbolTable.insertBuiltIn(float4, "mix", float4, float4, float4); + + symbolTable.insertBuiltIn(float1, "step", float1, float1); + symbolTable.insertBuiltIn(float2, "step", float2, float2); + symbolTable.insertBuiltIn(float3, "step", float3, float3); + symbolTable.insertBuiltIn(float4, "step", float4, float4); + symbolTable.insertBuiltIn(float2, "step", float1, float2); + symbolTable.insertBuiltIn(float3, "step", float1, float3); + symbolTable.insertBuiltIn(float4, "step", float1, float4); + + symbolTable.insertBuiltIn(float1, "smoothstep", float1, float1, float1); + symbolTable.insertBuiltIn(float2, "smoothstep", float2, float2, float2); + symbolTable.insertBuiltIn(float3, "smoothstep", float3, float3, float3); + symbolTable.insertBuiltIn(float4, "smoothstep", float4, float4, float4); + symbolTable.insertBuiltIn(float2, "smoothstep", float1, float1, float2); + symbolTable.insertBuiltIn(float3, "smoothstep", float1, float1, float3); + symbolTable.insertBuiltIn(float4, "smoothstep", float1, float1, float4); // // Geometric Functions. // - symbolTable.insertBuiltIn(float1, "length", float1, "x"); - symbolTable.insertBuiltIn(float1, "length", float2, "x"); - symbolTable.insertBuiltIn(float1, "length", float3, "x"); - symbolTable.insertBuiltIn(float1, "length", float4, "x"); - - symbolTable.insertBuiltIn(float1, "distance", float1, "p0", float1, "p1"); - symbolTable.insertBuiltIn(float1, "distance", float2, "p0", float2, "p1"); - symbolTable.insertBuiltIn(float1, "distance", float3, "p0", float3, "p1"); - symbolTable.insertBuiltIn(float1, "distance", float4, "p0", float4, "p1"); - - symbolTable.insertBuiltIn(float1, "dot", float1, "x", float1, "y"); - symbolTable.insertBuiltIn(float1, "dot", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(float1, "dot", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(float1, "dot", float4, "x", float4, "y"); - - symbolTable.insertBuiltIn(float3, "cross", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(float1, "normalize", float1, "x"); - symbolTable.insertBuiltIn(float2, "normalize", float2, "x"); - symbolTable.insertBuiltIn(float3, "normalize", float3, "x"); - symbolTable.insertBuiltIn(float4, "normalize", float4, "x"); - - symbolTable.insertBuiltIn(float1, "faceforward", float1, "N", float1, "I", float1, "Nref"); - symbolTable.insertBuiltIn(float2, "faceforward", float2, "N", float2, "I", float2, "Nref"); - symbolTable.insertBuiltIn(float3, "faceforward", float3, "N", float3, "I", float3, "Nref"); - symbolTable.insertBuiltIn(float4, "faceforward", float4, "N", float4, "I", float4, "Nref"); - - symbolTable.insertBuiltIn(float1, "reflect", float1, "I", float1, "N"); - symbolTable.insertBuiltIn(float2, "reflect", float2, "I", float2, "N"); - symbolTable.insertBuiltIn(float3, "reflect", float3, "I", float3, "N"); - symbolTable.insertBuiltIn(float4, "reflect", float4, "I", float4, "N"); - - symbolTable.insertBuiltIn(float1, "refract", float1, "I", float1, "N", float1, "eta"); - symbolTable.insertBuiltIn(float2, "refract", float2, "I", float2, "N", float1, "eta"); - symbolTable.insertBuiltIn(float3, "refract", float3, "I", float3, "N", float1, "eta"); - symbolTable.insertBuiltIn(float4, "refract", float4, "I", float4, "N", float1, "eta"); + symbolTable.insertBuiltIn(float1, "length", float1); + symbolTable.insertBuiltIn(float1, "length", float2); + symbolTable.insertBuiltIn(float1, "length", float3); + symbolTable.insertBuiltIn(float1, "length", float4); + + symbolTable.insertBuiltIn(float1, "distance", float1, float1); + symbolTable.insertBuiltIn(float1, "distance", float2, float2); + symbolTable.insertBuiltIn(float1, "distance", float3, float3); + symbolTable.insertBuiltIn(float1, "distance", float4, float4); + + symbolTable.insertBuiltIn(float1, "dot", float1, float1); + symbolTable.insertBuiltIn(float1, "dot", float2, float2); + symbolTable.insertBuiltIn(float1, "dot", float3, float3); + symbolTable.insertBuiltIn(float1, "dot", float4, float4); + + symbolTable.insertBuiltIn(float3, "cross", float3, float3); + symbolTable.insertBuiltIn(float1, "normalize", float1); + symbolTable.insertBuiltIn(float2, "normalize", float2); + symbolTable.insertBuiltIn(float3, "normalize", float3); + symbolTable.insertBuiltIn(float4, "normalize", float4); + + symbolTable.insertBuiltIn(float1, "faceforward", float1, float1, float1); + symbolTable.insertBuiltIn(float2, "faceforward", float2, float2, float2); + symbolTable.insertBuiltIn(float3, "faceforward", float3, float3, float3); + symbolTable.insertBuiltIn(float4, "faceforward", float4, float4, float4); + + symbolTable.insertBuiltIn(float1, "reflect", float1, float1); + symbolTable.insertBuiltIn(float2, "reflect", float2, float2); + symbolTable.insertBuiltIn(float3, "reflect", float3, float3); + symbolTable.insertBuiltIn(float4, "reflect", float4, float4); + + symbolTable.insertBuiltIn(float1, "refract", float1, float1, float1); + symbolTable.insertBuiltIn(float2, "refract", float2, float2, float1); + symbolTable.insertBuiltIn(float3, "refract", float3, float3, float1); + symbolTable.insertBuiltIn(float4, "refract", float4, float4, float1); TType *mat2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2, true); TType *mat3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3, true); @@ -242,9 +241,9 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI // // Matrix Functions. // - symbolTable.insertBuiltIn(mat2, "matrixCompMult", mat2, "x", mat2, "y"); - symbolTable.insertBuiltIn(mat3, "matrixCompMult", mat3, "x", mat3, "y"); - symbolTable.insertBuiltIn(mat4, "matrixCompMult", mat4, "x", mat4, "y"); + symbolTable.insertBuiltIn(mat2, "matrixCompMult", mat2, mat2); + symbolTable.insertBuiltIn(mat3, "matrixCompMult", mat3, mat3); + symbolTable.insertBuiltIn(mat4, "matrixCompMult", mat4, mat4); TType *bool1 = new TType(EbtBool, EbpUndefined, EvqGlobal, 1); TType *bool2 = new TType(EbtBool, EbpUndefined, EvqGlobal, 2); @@ -254,135 +253,135 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI // // Vector relational functions. // - symbolTable.insertBuiltIn(bool2, "lessThan", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(bool3, "lessThan", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(bool4, "lessThan", float4, "x", float4, "y"); + symbolTable.insertBuiltIn(bool2, "lessThan", float2, float2); + symbolTable.insertBuiltIn(bool3, "lessThan", float3, float3); + symbolTable.insertBuiltIn(bool4, "lessThan", float4, float4); - symbolTable.insertBuiltIn(bool2, "lessThan", int2, "x", int2, "y"); - symbolTable.insertBuiltIn(bool3, "lessThan", int3, "x", int3, "y"); - symbolTable.insertBuiltIn(bool4, "lessThan", int4, "x", int4, "y"); + symbolTable.insertBuiltIn(bool2, "lessThan", int2, int2); + symbolTable.insertBuiltIn(bool3, "lessThan", int3, int3); + symbolTable.insertBuiltIn(bool4, "lessThan", int4, int4); - symbolTable.insertBuiltIn(bool2, "lessThanEqual", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(bool3, "lessThanEqual", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(bool4, "lessThanEqual", float4, "x", float4, "y"); + symbolTable.insertBuiltIn(bool2, "lessThanEqual", float2, float2); + symbolTable.insertBuiltIn(bool3, "lessThanEqual", float3, float3); + symbolTable.insertBuiltIn(bool4, "lessThanEqual", float4, float4); - symbolTable.insertBuiltIn(bool2, "lessThanEqual", int2, "x", int2, "y"); - symbolTable.insertBuiltIn(bool3, "lessThanEqual", int3, "x", int3, "y"); - symbolTable.insertBuiltIn(bool4, "lessThanEqual", int4, "x", int4, "y"); + symbolTable.insertBuiltIn(bool2, "lessThanEqual", int2, int2); + symbolTable.insertBuiltIn(bool3, "lessThanEqual", int3, int3); + symbolTable.insertBuiltIn(bool4, "lessThanEqual", int4, int4); - symbolTable.insertBuiltIn(bool2, "greaterThan", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(bool3, "greaterThan", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(bool4, "greaterThan", float4, "x", float4, "y"); + symbolTable.insertBuiltIn(bool2, "greaterThan", float2, float2); + symbolTable.insertBuiltIn(bool3, "greaterThan", float3, float3); + symbolTable.insertBuiltIn(bool4, "greaterThan", float4, float4); - symbolTable.insertBuiltIn(bool2, "greaterThan", int2, "x", int2, "y"); - symbolTable.insertBuiltIn(bool3, "greaterThan", int3, "x", int3, "y"); - symbolTable.insertBuiltIn(bool4, "greaterThan", int4, "x", int4, "y"); + symbolTable.insertBuiltIn(bool2, "greaterThan", int2, int2); + symbolTable.insertBuiltIn(bool3, "greaterThan", int3, int3); + symbolTable.insertBuiltIn(bool4, "greaterThan", int4, int4); - symbolTable.insertBuiltIn(bool2, "greaterThanEqual", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(bool3, "greaterThanEqual", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(bool4, "greaterThanEqual", float4, "x", float4, "y"); + symbolTable.insertBuiltIn(bool2, "greaterThanEqual", float2, float2); + symbolTable.insertBuiltIn(bool3, "greaterThanEqual", float3, float3); + symbolTable.insertBuiltIn(bool4, "greaterThanEqual", float4, float4); - symbolTable.insertBuiltIn(bool2, "greaterThanEqual", int2, "x", int2, "y"); - symbolTable.insertBuiltIn(bool3, "greaterThanEqual", int3, "x", int3, "y"); - symbolTable.insertBuiltIn(bool4, "greaterThanEqual", int4, "x", int4, "y"); + symbolTable.insertBuiltIn(bool2, "greaterThanEqual", int2, int2); + symbolTable.insertBuiltIn(bool3, "greaterThanEqual", int3, int3); + symbolTable.insertBuiltIn(bool4, "greaterThanEqual", int4, int4); - symbolTable.insertBuiltIn(bool2, "equal", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(bool3, "equal", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(bool4, "equal", float4, "x", float4, "y"); + symbolTable.insertBuiltIn(bool2, "equal", float2, float2); + symbolTable.insertBuiltIn(bool3, "equal", float3, float3); + symbolTable.insertBuiltIn(bool4, "equal", float4, float4); - symbolTable.insertBuiltIn(bool2, "equal", int2, "x", int2, "y"); - symbolTable.insertBuiltIn(bool3, "equal", int3, "x", int3, "y"); - symbolTable.insertBuiltIn(bool4, "equal", int4, "x", int4, "y"); + symbolTable.insertBuiltIn(bool2, "equal", int2, int2); + symbolTable.insertBuiltIn(bool3, "equal", int3, int3); + symbolTable.insertBuiltIn(bool4, "equal", int4, int4); - symbolTable.insertBuiltIn(bool2, "equal", bool2, "x", bool2, "y"); - symbolTable.insertBuiltIn(bool3, "equal", bool3, "x", bool3, "y"); - symbolTable.insertBuiltIn(bool4, "equal", bool4, "x", bool4, "y"); + symbolTable.insertBuiltIn(bool2, "equal", bool2, bool2); + symbolTable.insertBuiltIn(bool3, "equal", bool3, bool3); + symbolTable.insertBuiltIn(bool4, "equal", bool4, bool4); - symbolTable.insertBuiltIn(bool2, "notEqual", float2, "x", float2, "y"); - symbolTable.insertBuiltIn(bool3, "notEqual", float3, "x", float3, "y"); - symbolTable.insertBuiltIn(bool4, "notEqual", float4, "x", float4, "y"); + symbolTable.insertBuiltIn(bool2, "notEqual", float2, float2); + symbolTable.insertBuiltIn(bool3, "notEqual", float3, float3); + symbolTable.insertBuiltIn(bool4, "notEqual", float4, float4); - symbolTable.insertBuiltIn(bool2, "notEqual", int2, "x", int2, "y"); - symbolTable.insertBuiltIn(bool3, "notEqual", int3, "x", int3, "y"); - symbolTable.insertBuiltIn(bool4, "notEqual", int4, "x", int4, "y"); + symbolTable.insertBuiltIn(bool2, "notEqual", int2, int2); + symbolTable.insertBuiltIn(bool3, "notEqual", int3, int3); + symbolTable.insertBuiltIn(bool4, "notEqual", int4, int4); - symbolTable.insertBuiltIn(bool2, "notEqual", bool2, "x", bool2, "y"); - symbolTable.insertBuiltIn(bool3, "notEqual", bool3, "x", bool3, "y"); - symbolTable.insertBuiltIn(bool4, "notEqual", bool4, "x", bool4, "y"); + symbolTable.insertBuiltIn(bool2, "notEqual", bool2, bool2); + symbolTable.insertBuiltIn(bool3, "notEqual", bool3, bool3); + symbolTable.insertBuiltIn(bool4, "notEqual", bool4, bool4); - symbolTable.insertBuiltIn(bool1, "any", bool2, "x"); - symbolTable.insertBuiltIn(bool1, "any", bool3, "x"); - symbolTable.insertBuiltIn(bool1, "any", bool4, "x"); + symbolTable.insertBuiltIn(bool1, "any", bool2); + symbolTable.insertBuiltIn(bool1, "any", bool3); + symbolTable.insertBuiltIn(bool1, "any", bool4); - symbolTable.insertBuiltIn(bool1, "all", bool2, "x"); - symbolTable.insertBuiltIn(bool1, "all", bool3, "x"); - symbolTable.insertBuiltIn(bool1, "all", bool4, "x"); + symbolTable.insertBuiltIn(bool1, "all", bool2); + symbolTable.insertBuiltIn(bool1, "all", bool3); + symbolTable.insertBuiltIn(bool1, "all", bool4); - symbolTable.insertBuiltIn(bool2, "not", bool2, "x"); - symbolTable.insertBuiltIn(bool3, "not", bool3, "x"); - symbolTable.insertBuiltIn(bool4, "not", bool4, "x"); + symbolTable.insertBuiltIn(bool2, "not", bool2); + symbolTable.insertBuiltIn(bool3, "not", bool3); + symbolTable.insertBuiltIn(bool4, "not", bool4); TType *sampler2D = new TType(EbtSampler2D, EbpUndefined, EvqGlobal, 1); TType *samplerCube = new TType(EbtSamplerCube, EbpUndefined, EvqGlobal, 1); // - // Texture Functions + // Texture Functions for GLSL ES 1.0 // - symbolTable.insertBuiltIn(float4, "texture2D", sampler2D, "sampler", float2, "coord"); - symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, "sampler", float3, "coord"); - symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, "sampler", float4, "coord"); - symbolTable.insertBuiltIn(float4, "textureCube", samplerCube, "sampler", float3, "coord"); + symbolTable.insertBuiltIn(float4, "texture2D", sampler2D, float2); + symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float3); + symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float4); + symbolTable.insertBuiltIn(float4, "textureCube", samplerCube, float3); if (resources.OES_EGL_image_external) { TType *samplerExternalOES = new TType(EbtSamplerExternalOES, EbpUndefined, EvqGlobal, 1); - symbolTable.insertBuiltIn(float4, "texture2D", samplerExternalOES, "sampler", float2, "coord"); - symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, "sampler", float3, "coord"); - symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, "sampler", float4, "coord"); + symbolTable.insertBuiltIn(float4, "texture2D", samplerExternalOES, float2); + symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, float3); + symbolTable.insertBuiltIn(float4, "texture2DProj", samplerExternalOES, float4); } if (resources.ARB_texture_rectangle) { TType *sampler2DRect = new TType(EbtSampler2DRect, EbpUndefined, EvqGlobal, 1); - symbolTable.insertBuiltIn(float4, "texture2DRect", sampler2DRect, "sampler", float2, "coord"); - symbolTable.insertBuiltIn(float4, "texture2DRectProj", sampler2DRect, "sampler", float3, "coord"); - symbolTable.insertBuiltIn(float4, "texture2DRectProj", sampler2DRect, "sampler", float4, "coord"); + symbolTable.insertBuiltIn(float4, "texture2DRect", sampler2DRect, float2); + symbolTable.insertBuiltIn(float4, "texture2DRectProj", sampler2DRect, float3); + symbolTable.insertBuiltIn(float4, "texture2DRectProj", sampler2DRect, float4); } - if(type == SH_FRAGMENT_SHADER) + if (type == SH_FRAGMENT_SHADER) { - symbolTable.insertBuiltIn(float4, "texture2D", sampler2D, "sampler", float2, "coord", float1, "bias"); - symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, "sampler", float3, "coord", float1, "bias"); - symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, "sampler", float4, "coord", float1, "bias"); - symbolTable.insertBuiltIn(float4, "textureCube", samplerCube, "sampler", float3, "coord", float1, "bias"); + symbolTable.insertBuiltIn(float4, "texture2D", sampler2D, float2, float1); + symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float3, float1); + symbolTable.insertBuiltIn(float4, "texture2DProj", sampler2D, float4, float1); + symbolTable.insertBuiltIn(float4, "textureCube", samplerCube, float3, float1); if (resources.OES_standard_derivatives) { - symbolTable.insertBuiltIn(float1, "dFdx", float1, "p"); - symbolTable.insertBuiltIn(float2, "dFdx", float2, "p"); - symbolTable.insertBuiltIn(float3, "dFdx", float3, "p"); - symbolTable.insertBuiltIn(float4, "dFdx", float4, "p"); + symbolTable.insertBuiltIn(float1, "dFdx", float1); + symbolTable.insertBuiltIn(float2, "dFdx", float2); + symbolTable.insertBuiltIn(float3, "dFdx", float3); + symbolTable.insertBuiltIn(float4, "dFdx", float4); - symbolTable.insertBuiltIn(float1, "dFdy", float1, "p"); - symbolTable.insertBuiltIn(float2, "dFdy", float2, "p"); - symbolTable.insertBuiltIn(float3, "dFdy", float3, "p"); - symbolTable.insertBuiltIn(float4, "dFdy", float4, "p"); - - symbolTable.insertBuiltIn(float1, "fwidth", float1, "p"); - symbolTable.insertBuiltIn(float2, "fwidth", float2, "p"); - symbolTable.insertBuiltIn(float3, "fwidth", float3, "p"); - symbolTable.insertBuiltIn(float4, "fwidth", float4, "p"); + symbolTable.insertBuiltIn(float1, "dFdy", float1); + symbolTable.insertBuiltIn(float2, "dFdy", float2); + symbolTable.insertBuiltIn(float3, "dFdy", float3); + symbolTable.insertBuiltIn(float4, "dFdy", float4); + + symbolTable.insertBuiltIn(float1, "fwidth", float1); + symbolTable.insertBuiltIn(float2, "fwidth", float2); + symbolTable.insertBuiltIn(float3, "fwidth", float3); + symbolTable.insertBuiltIn(float4, "fwidth", float4); } } if(type == SH_VERTEX_SHADER) { - symbolTable.insertBuiltIn(float4, "texture2DLod", sampler2D, "sampler", float2, "coord", float1, "lod"); - symbolTable.insertBuiltIn(float4, "texture2DProjLod", sampler2D, "sampler", float3, "coord", float1, "lod"); - symbolTable.insertBuiltIn(float4, "texture2DProjLod", sampler2D, "sampler", float4, "coord", float1, "lod"); - symbolTable.insertBuiltIn(float4, "textureCubeLod", samplerCube, "sampler", float3, "coord", float1, "lod"); + symbolTable.insertBuiltIn(float4, "texture2DLod", sampler2D, float2, float1); + symbolTable.insertBuiltIn(float4, "texture2DProjLod", sampler2D, float3, float1); + symbolTable.insertBuiltIn(float4, "texture2DProjLod", sampler2D, float4, float1); + symbolTable.insertBuiltIn(float4, "textureCubeLod", samplerCube, float3, float1); } // @@ -415,11 +414,7 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI if (spec != SH_CSS_SHADERS_SPEC) { - TExtensionBehavior::const_iterator iter = extensionBehavior.find("GL_EXT_draw_buffers"); - const bool usingMRTExtension = (iter != extensionBehavior.end() && (iter->second == EBhEnable || iter->second == EBhRequire)); - const int maxDrawBuffers = (usingMRTExtension ? resources.MaxDrawBuffers : 1); - - symbolTable.insertConstInt("gl_MaxDrawBuffers", maxDrawBuffers); + symbolTable.insertConstInt("gl_MaxDrawBuffers", resources.MaxDrawBuffers); } } diff --git a/src/compiler/Initialize.h b/src/compiler/Initialize.h index d08700cc..4aa13466 100644 --- a/src/compiler/Initialize.h +++ b/src/compiler/Initialize.h @@ -11,8 +11,7 @@ #include "compiler/ShHandle.h" #include "compiler/SymbolTable.h" -void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, - const TExtensionBehavior &extensionBehavior, TSymbolTable &table); +void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table); void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources& resources, diff --git a/src/compiler/InitializeDll.cpp b/src/compiler/InitializeDll.cpp index 8763cfee..6c7f27fc 100644 --- a/src/compiler/InitializeDll.cpp +++ b/src/compiler/InitializeDll.cpp @@ -10,25 +10,8 @@ #include "compiler/InitializeParseContext.h" #include "compiler/osinclude.h" -OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX; - bool InitProcess() { - if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) { - // - // Function is re-entrant. - // - return true; - } - - ThreadInitializeIndex = OS_AllocTLSIndex(); - - if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) { - assert(0 && "InitProcess(): Failed to allocate TLS area for init flag"); - return false; - } - - if (!InitializePoolIndex()) { assert(0 && "InitProcess(): Failed to initalize global pool"); return false; @@ -39,77 +22,11 @@ bool InitProcess() return false; } - return InitThread(); -} - -bool DetachProcess() -{ - bool success = true; - - if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) - return true; - - success = DetachThread(); - - if (!FreeParseContextIndex()) - success = false; - - FreePoolIndex(); - - OS_FreeTLSIndex(ThreadInitializeIndex); - ThreadInitializeIndex = OS_INVALID_TLS_INDEX; - - return success; -} - -bool InitThread() -{ - // - // This function is re-entrant - // - if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) { - assert(0 && "InitThread(): Process hasn't been initalised."); - return false; - } - - if (OS_GetTLSValue(ThreadInitializeIndex) != 0) - return true; - - InitializeGlobalPools(); - - if (!InitializeGlobalParseContext()) - return false; - - if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) { - assert(0 && "InitThread(): Unable to set init flag."); - return false; - } - return true; } -bool DetachThread() +void DetachProcess() { - bool success = true; - - if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) - return true; - - // - // Function is re-entrant and this thread may not have been initalised. - // - if (OS_GetTLSValue(ThreadInitializeIndex) != 0) { - if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) { - assert(0 && "DetachThread(): Unable to clear init flag."); - success = false; - } - - if (!FreeParseContext()) - success = false; - - FreeGlobalPools(); - } - - return success; + FreeParseContextIndex(); + FreePoolIndex(); } - diff --git a/src/compiler/InitializeDll.h b/src/compiler/InitializeDll.h index 857238ee..43070cc3 100644 --- a/src/compiler/InitializeDll.h +++ b/src/compiler/InitializeDll.h @@ -7,10 +7,7 @@ #define __INITIALIZEDLL_H bool InitProcess(); -bool DetachProcess(); - -bool InitThread(); -bool DetachThread(); +void DetachProcess(); #endif // __INITIALIZEDLL_H diff --git a/src/compiler/InitializeGlobals.h b/src/compiler/InitializeGlobals.h index 842a4528..07159414 100644 --- a/src/compiler/InitializeGlobals.h +++ b/src/compiler/InitializeGlobals.h @@ -7,8 +7,6 @@ #ifndef __INITIALIZE_GLOBALS_INCLUDED_ #define __INITIALIZE_GLOBALS_INCLUDED_ -void InitializeGlobalPools(); -void FreeGlobalPools(); bool InitializePoolIndex(); void FreePoolIndex(); diff --git a/src/compiler/InitializeParseContext.cpp b/src/compiler/InitializeParseContext.cpp index 1f40cf58..dfab0273 100644 --- a/src/compiler/InitializeParseContext.cpp +++ b/src/compiler/InitializeParseContext.cpp @@ -12,85 +12,29 @@ OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX; bool InitializeParseContextIndex() { - if (GlobalParseContextIndex != OS_INVALID_TLS_INDEX) { - assert(0 && "InitializeParseContextIndex(): Parse Context already initalized"); - return false; - } + assert(GlobalParseContextIndex == OS_INVALID_TLS_INDEX); - // - // Allocate a TLS index. - // GlobalParseContextIndex = OS_AllocTLSIndex(); - - if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) { - assert(0 && "InitializeParseContextIndex(): Parse Context already initalized"); - return false; - } - - return true; + return GlobalParseContextIndex != OS_INVALID_TLS_INDEX; } -bool FreeParseContextIndex() +void FreeParseContextIndex() { - OS_TLSIndex tlsiIndex = GlobalParseContextIndex; - - if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) { - assert(0 && "FreeParseContextIndex(): Parse Context index not initalized"); - return false; - } + assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); + OS_FreeTLSIndex(GlobalParseContextIndex); GlobalParseContextIndex = OS_INVALID_TLS_INDEX; - - return OS_FreeTLSIndex(tlsiIndex); -} - -bool InitializeGlobalParseContext() -{ - if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) { - assert(0 && "InitializeGlobalParseContext(): Parse Context index not initalized"); - return false; - } - - TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex)); - if (lpParseContext != 0) { - assert(0 && "InitializeParseContextIndex(): Parse Context already initalized"); - return false; - } - - TThreadParseContext *lpThreadData = new TThreadParseContext(); - if (lpThreadData == 0) { - assert(0 && "InitializeGlobalParseContext(): Unable to create thread parse context"); - return false; - } - - lpThreadData->lpGlobalParseContext = 0; - OS_SetTLSValue(GlobalParseContextIndex, lpThreadData); - - return true; } -bool FreeParseContext() +void SetGlobalParseContext(TParseContext* context) { - if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) { - assert(0 && "FreeParseContext(): Parse Context index not initalized"); - return false; - } - - TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex)); - if (lpParseContext) - delete lpParseContext; - - return true; + assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); + OS_SetTLSValue(GlobalParseContextIndex, context); } -TParseContextPointer& GetGlobalParseContext() +TParseContext* GetGlobalParseContext() { - // - // Minimal error checking for speed - // - - TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex)); - - return lpParseContext->lpGlobalParseContext; + assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); + return static_cast<TParseContext*>(OS_GetTLSValue(GlobalParseContextIndex)); } diff --git a/src/compiler/InitializeParseContext.h b/src/compiler/InitializeParseContext.h index aa53b735..bffbab87 100644 --- a/src/compiler/InitializeParseContext.h +++ b/src/compiler/InitializeParseContext.h @@ -8,19 +8,10 @@ #define __INITIALIZE_PARSE_CONTEXT_INCLUDED_ bool InitializeParseContextIndex(); -bool FreeParseContextIndex(); - -bool InitializeGlobalParseContext(); -bool FreeParseContext(); +void FreeParseContextIndex(); struct TParseContext; -typedef TParseContext* TParseContextPointer; -extern TParseContextPointer& GetGlobalParseContext(); -#define GlobalParseContext GetGlobalParseContext() - -typedef struct TThreadParseContextRec -{ - TParseContext *lpGlobalParseContext; -} TThreadParseContext; +extern void SetGlobalParseContext(TParseContext* context); +extern TParseContext* GetGlobalParseContext(); #endif // __INITIALIZE_PARSE_CONTEXT_INCLUDED_ diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp index e0afe546..79a373eb 100644 --- a/src/compiler/OutputHLSL.cpp +++ b/src/compiler/OutputHLSL.cpp @@ -68,18 +68,6 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc mUsesFaceforward2 = false; mUsesFaceforward3 = false; mUsesFaceforward4 = false; - mUsesEqualMat2 = false; - mUsesEqualMat3 = false; - mUsesEqualMat4 = false; - mUsesEqualVec2 = false; - mUsesEqualVec3 = false; - mUsesEqualVec4 = false; - mUsesEqualIVec2 = false; - mUsesEqualIVec3 = false; - mUsesEqualIVec4 = false; - mUsesEqualBVec2 = false; - mUsesEqualBVec3 = false; - mUsesEqualBVec4 = false; mUsesAtan2_1 = false; mUsesAtan2_2 = false; mUsesAtan2_3 = false; @@ -996,108 +984,6 @@ void OutputHLSL::header() "\n"; } - if (mUsesEqualMat2) - { - out << "bool equal(float2x2 m, float2x2 n)\n" - "{\n" - " return m[0][0] == n[0][0] && m[0][1] == n[0][1] &&\n" - " m[1][0] == n[1][0] && m[1][1] == n[1][1];\n" - "}\n"; - } - - if (mUsesEqualMat3) - { - out << "bool equal(float3x3 m, float3x3 n)\n" - "{\n" - " return m[0][0] == n[0][0] && m[0][1] == n[0][1] && m[0][2] == n[0][2] &&\n" - " m[1][0] == n[1][0] && m[1][1] == n[1][1] && m[1][2] == n[1][2] &&\n" - " m[2][0] == n[2][0] && m[2][1] == n[2][1] && m[2][2] == n[2][2];\n" - "}\n"; - } - - if (mUsesEqualMat4) - { - out << "bool equal(float4x4 m, float4x4 n)\n" - "{\n" - " return m[0][0] == n[0][0] && m[0][1] == n[0][1] && m[0][2] == n[0][2] && m[0][3] == n[0][3] &&\n" - " m[1][0] == n[1][0] && m[1][1] == n[1][1] && m[1][2] == n[1][2] && m[1][3] == n[1][3] &&\n" - " m[2][0] == n[2][0] && m[2][1] == n[2][1] && m[2][2] == n[2][2] && m[2][3] == n[2][3] &&\n" - " m[3][0] == n[3][0] && m[3][1] == n[3][1] && m[3][2] == n[3][2] && m[3][3] == n[3][3];\n" - "}\n"; - } - - if (mUsesEqualVec2) - { - out << "bool equal(float2 v, float2 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y;\n" - "}\n"; - } - - if (mUsesEqualVec3) - { - out << "bool equal(float3 v, float3 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y && v.z == u.z;\n" - "}\n"; - } - - if (mUsesEqualVec4) - { - out << "bool equal(float4 v, float4 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\n" - "}\n"; - } - - if (mUsesEqualIVec2) - { - out << "bool equal(int2 v, int2 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y;\n" - "}\n"; - } - - if (mUsesEqualIVec3) - { - out << "bool equal(int3 v, int3 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y && v.z == u.z;\n" - "}\n"; - } - - if (mUsesEqualIVec4) - { - out << "bool equal(int4 v, int4 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\n" - "}\n"; - } - - if (mUsesEqualBVec2) - { - out << "bool equal(bool2 v, bool2 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y;\n" - "}\n"; - } - - if (mUsesEqualBVec3) - { - out << "bool equal(bool3 v, bool3 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y && v.z == u.z;\n" - "}\n"; - } - - if (mUsesEqualBVec4) - { - out << "bool equal(bool4 v, bool4 u)\n" - "{\n" - " return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;\n" - "}\n"; - } - if (mUsesAtan2_1) { out << "float atanyx(float y, float x)\n" @@ -1391,59 +1277,15 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) } else { - if (node->getLeft()->isMatrix()) - { - switch (node->getLeft()->getNominalSize()) - { - case 2: mUsesEqualMat2 = true; break; - case 3: mUsesEqualMat3 = true; break; - case 4: mUsesEqualMat4 = true; break; - default: UNREACHABLE(); - } - } - else if (node->getLeft()->isVector()) - { - switch (node->getLeft()->getBasicType()) - { - case EbtFloat: - switch (node->getLeft()->getNominalSize()) - { - case 2: mUsesEqualVec2 = true; break; - case 3: mUsesEqualVec3 = true; break; - case 4: mUsesEqualVec4 = true; break; - default: UNREACHABLE(); - } - break; - case EbtInt: - switch (node->getLeft()->getNominalSize()) - { - case 2: mUsesEqualIVec2 = true; break; - case 3: mUsesEqualIVec3 = true; break; - case 4: mUsesEqualIVec4 = true; break; - default: UNREACHABLE(); - } - break; - case EbtBool: - switch (node->getLeft()->getNominalSize()) - { - case 2: mUsesEqualBVec2 = true; break; - case 3: mUsesEqualBVec3 = true; break; - case 4: mUsesEqualBVec4 = true; break; - default: UNREACHABLE(); - } - break; - default: UNREACHABLE(); - } - } - else UNREACHABLE(); + ASSERT(node->getLeft()->isMatrix() || node->getLeft()->isVector()); if (node->getOp() == EOpEqual) { - outputTriplet(visit, "equal(", ", ", ")"); + outputTriplet(visit, "all(", " == ", ")"); } else { - outputTriplet(visit, "!equal(", ", ", ")"); + outputTriplet(visit, "!all(", " == ", ")"); } } break; diff --git a/src/compiler/OutputHLSL.h b/src/compiler/OutputHLSL.h index b33b1f5f..cde41207 100644 --- a/src/compiler/OutputHLSL.h +++ b/src/compiler/OutputHLSL.h @@ -121,18 +121,6 @@ class OutputHLSL : public TIntermTraverser bool mUsesFaceforward2; bool mUsesFaceforward3; bool mUsesFaceforward4; - bool mUsesEqualMat2; - bool mUsesEqualMat3; - bool mUsesEqualMat4; - bool mUsesEqualVec2; - bool mUsesEqualVec3; - bool mUsesEqualVec4; - bool mUsesEqualIVec2; - bool mUsesEqualIVec3; - bool mUsesEqualIVec4; - bool mUsesEqualBVec2; - bool mUsesEqualBVec3; - bool mUsesEqualBVec4; bool mUsesAtan2_1; bool mUsesAtan2_2; bool mUsesAtan2_3; diff --git a/src/compiler/ParseHelper.cpp b/src/compiler/ParseHelper.cpp index b84a1755..a4787a1c 100644 --- a/src/compiler/ParseHelper.cpp +++ b/src/compiler/ParseHelper.cpp @@ -892,6 +892,19 @@ bool TParseContext::supportsExtension(const char* extension) return (iter != extbehavior.end()); } +bool TParseContext::isExtensionEnabled(const char* extension) const +{ + const TExtensionBehavior& extbehavior = extensionBehavior(); + TExtensionBehavior::const_iterator iter = extbehavior.find(extension); + + if (iter == extbehavior.end()) + { + return false; + } + + return (iter->second == EBhEnable || iter->second == EBhRequire); +} + ///////////////////////////////////////////////////////////////////////////////// // // Non-Errors. @@ -907,8 +920,9 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& line, TFunction* { // First find by unmangled name to check whether the function name has been // hidden by a variable name or struct typename. + // If a function is found, check for one with a matching argument list. const TSymbol* symbol = symbolTable.find(call->getName(), builtIn); - if (symbol == 0) { + if (symbol == 0 || symbol->isFunction()) { symbol = symbolTable.find(call->getMangledName(), builtIn); } @@ -925,27 +939,6 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& line, TFunction* return static_cast<const TFunction*>(symbol); } -bool TParseContext::isVariableBuiltIn(const TVariable* var) -{ - bool builtIn = false; - // First find by unmangled name to check whether the function name has been - // hidden by a variable name or struct typename. - const TSymbol* symbol = symbolTable.find(var->getName(), &builtIn); - if (symbol == 0) { - symbol = symbolTable.find(var->getMangledName(), &builtIn); - } - - if (symbol == 0) { - return false; - } - - if (!symbol->isVariable()) { - return false; - } - - return builtIn; -} - // // Initializers show up in several places in the grammar. Have one set of // code to handle them here. @@ -1513,6 +1506,12 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co recover(); index = baseExpression->getType().getArraySize() - 1; } + else if (baseExpression->getQualifier() == EvqFragData && index > 0 && !isExtensionEnabled("GL_EXT_draw_buffers")) + { + error(location, "", "[", "array indexes for gl_FragData must be zero when GL_EXT_draw_buffers is disabled"); + recover(); + index = 0; + } } else if ((baseExpression->isVector() || baseExpression->isMatrix()) && baseExpression->getType().getNominalSize() <= index) { diff --git a/src/compiler/ParseHelper.h b/src/compiler/ParseHelper.h index 4b2f6c34..c2b3c3f7 100644 --- a/src/compiler/ParseHelper.h +++ b/src/compiler/ParseHelper.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. +// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -101,11 +101,11 @@ struct TParseContext { const TPragma& pragma() const { return directiveHandler.pragma(); } const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); } bool supportsExtension(const char* extension); + bool isExtensionEnabled(const char* extension) const; bool containsSampler(TType& type); bool areAllChildConst(TIntermAggregate* aggrNode); const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, bool *builtIn = 0); - bool isVariableBuiltIn(const TVariable* pVar); bool executeInitializer(const TSourceLoc& line, TString& identifier, TPublicType& pType, TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); diff --git a/src/compiler/PoolAlloc.cpp b/src/compiler/PoolAlloc.cpp index 3f0f5a63..eb993567 100644 --- a/src/compiler/PoolAlloc.cpp +++ b/src/compiler/PoolAlloc.cpp @@ -17,55 +17,32 @@ OS_TLSIndex PoolIndex = OS_INVALID_TLS_INDEX; -void InitializeGlobalPools() -{ - TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); - if (globalPools) - return; - - TThreadGlobalPools* threadData = new TThreadGlobalPools(); - threadData->globalPoolAllocator = 0; - - OS_SetTLSValue(PoolIndex, threadData); -} - -void FreeGlobalPools() -{ - // Release the allocated memory for this thread. - TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); - if (!globalPools) - return; - - delete globalPools; -} - bool InitializePoolIndex() { - // Allocate a TLS index. - if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX) - return false; + assert(PoolIndex == OS_INVALID_TLS_INDEX); - return true; + PoolIndex = OS_AllocTLSIndex(); + return PoolIndex != OS_INVALID_TLS_INDEX; } void FreePoolIndex() { - // Release the TLS index. + assert(PoolIndex != OS_INVALID_TLS_INDEX); + OS_FreeTLSIndex(PoolIndex); + PoolIndex = OS_INVALID_TLS_INDEX; } -TPoolAllocator& GetGlobalPoolAllocator() +TPoolAllocator* GetGlobalPoolAllocator() { - TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); - - return *threadData->globalPoolAllocator; + assert(PoolIndex != OS_INVALID_TLS_INDEX); + return static_cast<TPoolAllocator*>(OS_GetTLSValue(PoolIndex)); } void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator) { - TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex)); - - threadData->globalPoolAllocator = poolAllocator; + assert(PoolIndex != OS_INVALID_TLS_INDEX); + OS_SetTLSValue(PoolIndex, poolAllocator); } // diff --git a/src/compiler/PoolAlloc.h b/src/compiler/PoolAlloc.h index a8a59c69..edd249c4 100644 --- a/src/compiler/PoolAlloc.h +++ b/src/compiler/PoolAlloc.h @@ -219,14 +219,8 @@ private: // different times. But a simple use is to have a global pop // with everyone using the same global allocator. // -extern TPoolAllocator& GetGlobalPoolAllocator(); +extern TPoolAllocator* GetGlobalPoolAllocator(); extern void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator); -#define GlobalPoolAllocator GetGlobalPoolAllocator() - -struct TThreadGlobalPools -{ - TPoolAllocator* globalPoolAllocator; -}; // // This STL compatible allocator is intended to be used as the allocator @@ -253,7 +247,7 @@ public: pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } - pool_allocator() : allocator(&GlobalPoolAllocator) { } + pool_allocator() : allocator(GetGlobalPoolAllocator()) { } pool_allocator(TPoolAllocator& a) : allocator(&a) { } pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { } diff --git a/src/compiler/ShaderLang.cpp b/src/compiler/ShaderLang.cpp index 3f637038..147894e0 100644 --- a/src/compiler/ShaderLang.cpp +++ b/src/compiler/ShaderLang.cpp @@ -85,15 +85,13 @@ static void getVariableInfo(ShShaderInfo varType, } // -// Driver must call this first, once, before doing any other -// compiler operations. +// Driver must call this first, once, before doing any other compiler operations. +// Subsequent calls to this function are no-op. // int ShInitialize() { - if (!InitProcess()) - return 0; - - return 1; + static const bool kInitialized = InitProcess(); + return kInitialized ? 1 : 0; } // @@ -101,9 +99,7 @@ int ShInitialize() // int ShFinalize() { - if (!DetachProcess()) - return 0; - + DetachProcess(); return 1; } @@ -145,9 +141,6 @@ ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec, ShShaderOutput output, const ShBuiltInResources* resources) { - if (!InitThread()) - return 0; - TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output)); TCompiler* compiler = base->getAsCompiler(); if (compiler == 0) @@ -186,9 +179,6 @@ int ShCompile( size_t numStrings, int compileOptions) { - if (!InitThread()) - return 0; - if (handle == 0) return 0; diff --git a/src/compiler/SymbolTable.h b/src/compiler/SymbolTable.h index a5406027..f9a7948a 100644 --- a/src/compiler/SymbolTable.h +++ b/src/compiler/SymbolTable.h @@ -41,9 +41,10 @@ // class TSymbol { public: - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) + POOL_ALLOCATOR_NEW_DELETE(); TSymbol(const TString *n) : name(n) { } virtual ~TSymbol() { /* don't delete name, it's from the pool */ } + const TString& getName() const { return *name; } virtual const TString& getMangledName() const { return getName(); } virtual bool isFunction() const { return false; } @@ -186,21 +187,26 @@ public: typedef const tLevel::value_type tLevelPair; typedef std::pair<tLevel::iterator, bool> tInsertResult; - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) + POOL_ALLOCATOR_NEW_DELETE(); TSymbolTableLevel() { } ~TSymbolTableLevel(); - bool insert(TSymbol& symbol) + bool insert(const TString &name, TSymbol &symbol) { // // returning true means symbol was added to the table // tInsertResult result; - result = level.insert(tLevelPair(symbol.getMangledName(), &symbol)); + result = level.insert(tLevelPair(name, &symbol)); return result.second; } + bool insert(TSymbol &symbol) + { + return insert(symbol.getMangledName(), symbol); + } + TSymbol* find(const TString& name) const { tLevel::const_iterator it = level.find(name); @@ -280,22 +286,22 @@ public: return insert(*constant); } - bool insertBuiltIn(TType *rvalue, const char *name, TType *ptype1, const char *pname1, TType *ptype2 = 0, const char *pname2 = 0, TType *ptype3 = 0, const char *pname3 = 0) + bool insertBuiltIn(TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0) { TFunction *function = new TFunction(NewPoolTString(name), *rvalue); - TParameter param1 = {NewPoolTString(pname1), ptype1}; + TParameter param1 = {NULL, ptype1}; function->addParameter(param1); - if (pname2) + if(ptype2) { - TParameter param2 = {NewPoolTString(pname2), ptype2}; + TParameter param2 = {NULL, ptype2}; function->addParameter(param2); } - if (pname3) + if(ptype3) { - TParameter param3 = {NewPoolTString(pname3), ptype3}; + TParameter param3 = {NULL, ptype3}; function->addParameter(param3); } diff --git a/src/compiler/Types.h b/src/compiler/Types.h index 5946af04..505fa8e3 100644 --- a/src/compiler/Types.h +++ b/src/compiler/Types.h @@ -19,7 +19,7 @@ class TType; class TField { public: - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator); + POOL_ALLOCATOR_NEW_DELETE(); TField(TType* type, TString* name) : mType(type), mName(name) {} // TODO(alokp): We should only return const type. @@ -38,14 +38,14 @@ private: typedef TVector<TField*> TFieldList; inline TFieldList* NewPoolTFieldList() { - void* memory = GlobalPoolAllocator.allocate(sizeof(TFieldList)); + void* memory = GetGlobalPoolAllocator()->allocate(sizeof(TFieldList)); return new(memory) TFieldList; } class TStructure { public: - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator); + POOL_ALLOCATOR_NEW_DELETE(); TStructure(TString* name, TFieldList* fields) : mName(name), mFields(fields), @@ -93,7 +93,7 @@ private: class TType { public: - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) + POOL_ALLOCATOR_NEW_DELETE(); TType() {} TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) : type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0), structure(0) diff --git a/src/compiler/ValidateLimitations.cpp b/src/compiler/ValidateLimitations.cpp index a5562d09..736ceeae 100644 --- a/src/compiler/ValidateLimitations.cpp +++ b/src/compiler/ValidateLimitations.cpp @@ -435,7 +435,7 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node) return true; bool valid = true; - TSymbolTable& symbolTable = GlobalParseContext->symbolTable; + TSymbolTable& symbolTable = GetGlobalParseContext()->symbolTable; TSymbol* symbol = symbolTable.find(node->getName()); ASSERT(symbol && symbol->isFunction()); TFunction* function = static_cast<TFunction*>(symbol); diff --git a/src/compiler/glslang.y b/src/compiler/glslang.y index cbb66025..0e8c3c3b 100644 --- a/src/compiler/glslang.y +++ b/src/compiler/glslang.y @@ -200,7 +200,7 @@ variable_identifier variable = static_cast<const TVariable*>(symbol); - if (context->isVariableBuiltIn(variable) && + if (context->symbolTable.findBuiltIn(variable->getName()) && !variable->getExtension().empty() && context->extensionErrorCheck(@1, variable->getExtension())) { context->recover(); @@ -958,6 +958,24 @@ function_prototype } // + // Check for previously declared variables using the same name. + // + TSymbol *prevSym = context->symbolTable.find($1->getName()); + if (prevSym) + { + if (!prevSym->isFunction()) + { + context->error(@2, "redefinition", $1->getName().c_str(), "function"); + context->recover(); + } + } + else + { + // Insert the unmangled name to detect potential future redefinition as a variable. + context->symbolTable.getOuterLevel()->insert($1->getName(), *$1); + } + + // // If this is a redeclaration, it could also be a definition, // in which case, we want to use the variable names from this one, and not the one that's // being redeclared. So, pass back up this declaration, not the one in the symbol table. diff --git a/src/compiler/glslang_tab.cpp b/src/compiler/glslang_tab.cpp index 111198a8..7afd4ca8 100644 --- a/src/compiler/glslang_tab.cpp +++ b/src/compiler/glslang_tab.cpp @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.7.12-4996" +#define YYBISON_VERSION "2.7" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -400,14 +400,6 @@ typedef short int yytype_int16; # endif #endif -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -415,7 +407,6 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif - /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(N) (N) @@ -729,20 +720,20 @@ static const yytype_uint16 yyrline[] = 684, 692, 703, 707, 708, 718, 728, 738, 751, 752, 762, 775, 779, 783, 787, 788, 801, 802, 815, 816, 829, 830, 847, 848, 861, 862, 863, 864, 865, 869, - 872, 883, 891, 918, 923, 937, 974, 977, 984, 992, - 1013, 1034, 1044, 1072, 1077, 1087, 1092, 1102, 1105, 1108, - 1111, 1117, 1124, 1127, 1149, 1167, 1191, 1214, 1218, 1236, - 1244, 1276, 1296, 1317, 1326, 1349, 1352, 1358, 1366, 1374, - 1382, 1392, 1399, 1402, 1405, 1411, 1414, 1429, 1433, 1437, - 1441, 1445, 1450, 1455, 1460, 1465, 1470, 1475, 1480, 1485, - 1490, 1495, 1500, 1505, 1509, 1513, 1521, 1529, 1533, 1546, - 1546, 1560, 1560, 1569, 1572, 1588, 1621, 1625, 1631, 1638, - 1653, 1657, 1661, 1662, 1668, 1669, 1670, 1671, 1672, 1676, - 1677, 1677, 1677, 1687, 1688, 1692, 1692, 1693, 1693, 1698, - 1701, 1711, 1714, 1720, 1721, 1725, 1733, 1737, 1747, 1752, - 1769, 1769, 1774, 1774, 1781, 1781, 1789, 1792, 1798, 1801, - 1807, 1811, 1818, 1825, 1832, 1839, 1850, 1859, 1863, 1870, - 1873, 1879, 1879 + 872, 883, 891, 918, 923, 937, 992, 995, 1002, 1010, + 1031, 1052, 1062, 1090, 1095, 1105, 1110, 1120, 1123, 1126, + 1129, 1135, 1142, 1145, 1167, 1185, 1209, 1232, 1236, 1254, + 1262, 1294, 1314, 1335, 1344, 1367, 1370, 1376, 1384, 1392, + 1400, 1410, 1417, 1420, 1423, 1429, 1432, 1447, 1451, 1455, + 1459, 1463, 1468, 1473, 1478, 1483, 1488, 1493, 1498, 1503, + 1508, 1513, 1518, 1523, 1527, 1531, 1539, 1547, 1551, 1564, + 1564, 1578, 1578, 1587, 1590, 1606, 1639, 1643, 1649, 1656, + 1671, 1675, 1679, 1680, 1686, 1687, 1688, 1689, 1690, 1694, + 1695, 1695, 1695, 1705, 1706, 1710, 1710, 1711, 1711, 1716, + 1719, 1729, 1732, 1738, 1739, 1743, 1751, 1755, 1765, 1770, + 1787, 1787, 1792, 1792, 1799, 1799, 1807, 1810, 1816, 1819, + 1825, 1829, 1836, 1843, 1850, 1857, 1868, 1877, 1881, 1888, + 1891, 1897, 1897 }; #endif @@ -1520,7 +1511,11 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context) # else YYUSE (yyoutput); # endif - YYUSE (yytype); + switch (yytype) + { + default: + break; + } } @@ -1920,7 +1915,12 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, context) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - YYUSE (yytype); + switch (yytype) + { + + default: + break; + } } @@ -2265,7 +2265,7 @@ yyreduce: variable = static_cast<const TVariable*>(symbol); - if (context->isVariableBuiltIn(variable) && + if (context->symbolTable.findBuiltIn(variable->getName()) && !variable->getExtension().empty() && context->extensionErrorCheck((yylsp[(1) - (1)]), variable->getExtension())) { context->recover(); @@ -3213,6 +3213,24 @@ yyreduce: } // + // Check for previously declared variables using the same name. + // + TSymbol *prevSym = context->symbolTable.find((yyvsp[(1) - (2)].interm.function)->getName()); + if (prevSym) + { + if (!prevSym->isFunction()) + { + context->error((yylsp[(2) - (2)]), "redefinition", (yyvsp[(1) - (2)].interm.function)->getName().c_str(), "function"); + context->recover(); + } + } + else + { + // Insert the unmangled name to detect potential future redefinition as a variable. + context->symbolTable.getOuterLevel()->insert((yyvsp[(1) - (2)].interm.function)->getName(), *(yyvsp[(1) - (2)].interm.function)); + } + + // // If this is a redeclaration, it could also be a definition, // in which case, we want to use the variable names from this one, and not the one that's // being redeclared. So, pass back up this declaration, not the one in the symbol table. diff --git a/src/compiler/glslang_tab.h b/src/compiler/glslang_tab.h index ed3eda57..2f0f1106 100644 --- a/src/compiler/glslang_tab.h +++ b/src/compiler/glslang_tab.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/compiler/intermediate.h b/src/compiler/intermediate.h index b1d20f70..738621fe 100644 --- a/src/compiler/intermediate.h +++ b/src/compiler/intermediate.h @@ -205,8 +205,7 @@ class TInfoSink; // class TIntermNode { public: - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) - + POOL_ALLOCATOR_NEW_DELETE(); TIntermNode() { // TODO: Move this to TSourceLoc constructor // after getting rid of TPublicType. @@ -540,8 +539,7 @@ enum Visit class TIntermTraverser { public: - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) - + POOL_ALLOCATOR_NEW_DELETE(); TIntermTraverser(bool preVisit = true, bool inVisit = false, bool postVisit = false, bool rightToLeft = false) : preVisit(preVisit), inVisit(inVisit), diff --git a/src/compiler/localintermediate.h b/src/compiler/localintermediate.h index b6734070..ccbc4017 100644 --- a/src/compiler/localintermediate.h +++ b/src/compiler/localintermediate.h @@ -22,9 +22,9 @@ struct TVectorFields { class TInfoSink; class TIntermediate { public: - POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) - + POOL_ALLOCATOR_NEW_DELETE(); TIntermediate(TInfoSink& i) : infoSink(i) { } + TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&); TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*); TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&, TSymbolTable&); diff --git a/src/libEGL/libEGL.cpp b/src/libEGL/libEGL.cpp index bcba43f6..6e10c392 100644 --- a/src/libEGL/libEGL.cpp +++ b/src/libEGL/libEGL.cpp @@ -888,15 +888,18 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface return EGL_FALSE; } - rx::Renderer *renderer = display->getRenderer(); - if (renderer->testDeviceLost(true)) + if (dpy != EGL_NO_DISPLAY) { - return EGL_FALSE; - } + rx::Renderer *renderer = display->getRenderer(); + if (renderer->testDeviceLost(true)) + { + return EGL_FALSE; + } - if (renderer->isDeviceLost()) - { - return egl::error(EGL_CONTEXT_LOST, EGL_FALSE); + if (renderer->isDeviceLost()) + { + return egl::error(EGL_CONTEXT_LOST, EGL_FALSE); + } } if ((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) || diff --git a/src/libGLESv2/Buffer.cpp b/src/libGLESv2/Buffer.cpp index 8d5b4ef2..a64fbad4 100644 --- a/src/libGLESv2/Buffer.cpp +++ b/src/libGLESv2/Buffer.cpp @@ -40,6 +40,7 @@ Buffer::~Buffer() void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) { mBufferStorage->clear(); + mIndexRangeCache.clear(); mBufferStorage->setData(data, size, 0); mUsage = usage; @@ -56,6 +57,7 @@ void Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) void Buffer::bufferSubData(const void *data, GLsizeiptr size, GLintptr offset) { mBufferStorage->setData(data, size, offset); + mIndexRangeCache.invalidateRange(offset, size); if ((mStaticVertexBuffer && mStaticVertexBuffer->getBufferSize() != 0) || (mStaticIndexBuffer && mStaticIndexBuffer->getBufferSize() != 0)) { @@ -116,4 +118,9 @@ void Buffer::promoteStaticUsage(int dataSize) } } +rx::IndexRangeCache *Buffer::getIndexRangeCache() +{ + return &mIndexRangeCache; +} + } diff --git a/src/libGLESv2/Buffer.h b/src/libGLESv2/Buffer.h index 4376ada5..3f9fe8f8 100644 --- a/src/libGLESv2/Buffer.h +++ b/src/libGLESv2/Buffer.h @@ -13,6 +13,7 @@ #include "common/angleutils.h" #include "common/RefCountObject.h" +#include "libGLESv2/renderer/IndexRangeCache.h" namespace rx { @@ -45,6 +46,8 @@ class Buffer : public RefCountObject void invalidateStaticData(); void promoteStaticUsage(int dataSize); + rx::IndexRangeCache *getIndexRangeCache(); + private: DISALLOW_COPY_AND_ASSIGN(Buffer); @@ -53,6 +56,8 @@ class Buffer : public RefCountObject rx::BufferStorage *mBufferStorage; + rx::IndexRangeCache mIndexRangeCache; + rx::StaticVertexBufferInterface *mStaticVertexBuffer; rx::StaticIndexBufferInterface *mStaticIndexBuffer; unsigned int mUnmodifiedDataUse; diff --git a/src/libGLESv2/libGLESv2.vcxproj b/src/libGLESv2/libGLESv2.vcxproj index ca0d6b57..906707c9 100644 --- a/src/libGLESv2/libGLESv2.vcxproj +++ b/src/libGLESv2/libGLESv2.vcxproj @@ -273,6 +273,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" <ClCompile Include="renderer\IndexDataManager.cpp" />
<ClCompile Include="renderer\ImageSSE2.cpp" />
<ClCompile Include="renderer\Image11.cpp" />
+ <ClCompile Include="renderer\IndexRangeCache.cpp" />
<ClCompile Include="renderer\InputLayoutCache.cpp" />
<ClCompile Include="renderer\Query11.cpp" />
<ClCompile Include="renderer\Query9.cpp" />
@@ -340,6 +341,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" <ClInclude Include="renderer\IndexBuffer11.h" />
<ClInclude Include="renderer\IndexBuffer9.h" />
<ClInclude Include="renderer\IndexDataManager.h" />
+ <ClInclude Include="renderer\IndexRangeCache.h" />
<ClInclude Include="renderer\InputLayoutCache.h" />
<ClInclude Include="renderer\Query11.h" />
<ClInclude Include="renderer\QueryImpl.h" />
diff --git a/src/libGLESv2/libGLESv2.vcxproj.filters b/src/libGLESv2/libGLESv2.vcxproj.filters index 34f97044..187a46a9 100644 --- a/src/libGLESv2/libGLESv2.vcxproj.filters +++ b/src/libGLESv2/libGLESv2.vcxproj.filters @@ -218,6 +218,9 @@ <ClCompile Include="precompiled.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="renderer\IndexRangeCache.cpp">
+ <Filter>Source Files\Renderer</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BinaryStream.h">
@@ -484,6 +487,9 @@ <ClInclude Include="precompiled.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="renderer\IndexRangeCache.h">
+ <Filter>Header Files\Renderer</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="renderer\shaders\Blit.ps">
diff --git a/src/libGLESv2/renderer/Image11.cpp b/src/libGLESv2/renderer/Image11.cpp index 8c78c7d7..a46ad756 100644 --- a/src/libGLESv2/renderer/Image11.cpp +++ b/src/libGLESv2/renderer/Image11.cpp @@ -194,7 +194,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig loadAlphaFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); break; case GL_LUMINANCE32F_EXT: - loadLuminanceFloatDataToRGB(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); + loadLuminanceFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); break; case GL_ALPHA16F_EXT: loadAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); @@ -230,7 +230,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig loadBGRADataToBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); break; case GL_RGB32F_EXT: - loadRGBFloatDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); + loadRGBFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); break; case GL_RGB16F_EXT: loadRGBHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); diff --git a/src/libGLESv2/renderer/IndexBuffer.cpp b/src/libGLESv2/renderer/IndexBuffer.cpp index 3d5d7a7c..2ac94466 100644 --- a/src/libGLESv2/renderer/IndexBuffer.cpp +++ b/src/libGLESv2/renderer/IndexBuffer.cpp @@ -176,27 +176,9 @@ bool StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum in } } -unsigned int StaticIndexBufferInterface::lookupRange(intptr_t offset, GLsizei count, unsigned int *minIndex, unsigned int *maxIndex) +IndexRangeCache *StaticIndexBufferInterface::getIndexRangeCache() { - IndexRange range = {offset, count}; - - std::map<IndexRange, IndexResult>::iterator res = mCache.find(range); - - if (res == mCache.end()) - { - return -1; - } - - *minIndex = res->second.minIndex; - *maxIndex = res->second.maxIndex; - return res->second.streamOffset; -} - -void StaticIndexBufferInterface::addRange(intptr_t offset, GLsizei count, unsigned int minIndex, unsigned int maxIndex, unsigned int streamOffset) -{ - IndexRange indexRange = {offset, count}; - IndexResult indexResult = {minIndex, maxIndex, streamOffset}; - mCache[indexRange] = indexResult; + return &mIndexRangeCache; } } diff --git a/src/libGLESv2/renderer/IndexBuffer.h b/src/libGLESv2/renderer/IndexBuffer.h index 1afbd626..98fa5fe3 100644 --- a/src/libGLESv2/renderer/IndexBuffer.h +++ b/src/libGLESv2/renderer/IndexBuffer.h @@ -11,6 +11,7 @@ #define LIBGLESV2_RENDERER_INDEXBUFFER_H_ #include "common/angleutils.h" +#include "libGLESv2/renderer/IndexRangeCache.h" namespace rx { @@ -99,37 +100,10 @@ class StaticIndexBufferInterface : public IndexBufferInterface virtual bool reserveBufferSpace(unsigned int size, GLenum indexType); - unsigned int lookupRange(intptr_t offset, GLsizei count, unsigned int *minIndex, unsigned int *maxIndex); // Returns the offset into the index buffer, or -1 if not found - void addRange(intptr_t offset, GLsizei count, unsigned int minIndex, unsigned int maxIndex, unsigned int streamOffset); + IndexRangeCache *getIndexRangeCache(); private: - struct IndexRange - { - intptr_t offset; - GLsizei count; - - bool operator<(const IndexRange& rhs) const - { - if (offset != rhs.offset) - { - return offset < rhs.offset; - } - if (count != rhs.count) - { - return count < rhs.count; - } - return false; - } - }; - - struct IndexResult - { - unsigned int minIndex; - unsigned int maxIndex; - unsigned int streamOffset; - }; - - std::map<IndexRange, IndexResult> mCache; + IndexRangeCache mIndexRangeCache; }; } diff --git a/src/libGLESv2/renderer/IndexDataManager.cpp b/src/libGLESv2/renderer/IndexDataManager.cpp index 84b79b41..752d1fb4 100644 --- a/src/libGLESv2/renderer/IndexDataManager.cpp +++ b/src/libGLESv2/renderer/IndexDataManager.cpp @@ -13,6 +13,7 @@ #include "libGLESv2/Buffer.h" #include "libGLESv2/main.h" +#include "libGLESv2/utilities.h" #include "libGLESv2/renderer/IndexBuffer.h" namespace rx @@ -53,17 +54,6 @@ IndexDataManager::~IndexDataManager() delete mCountingBuffer; } -static unsigned int indexTypeSize(GLenum type) -{ - switch (type) - { - case GL_UNSIGNED_INT: return sizeof(GLuint); - case GL_UNSIGNED_SHORT: return sizeof(GLushort); - case GL_UNSIGNED_BYTE: return sizeof(GLubyte); - default: UNREACHABLE(); return sizeof(GLushort); - } -} - static void convertIndices(GLenum type, const void *input, GLsizei count, void *output) { if (type == GL_UNSIGNED_BYTE) @@ -142,7 +132,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer default: UNREACHABLE(); alignedOffset = false; } - if (indexTypeSize(type) * count + offset > storage->getSize()) + if (gl::ComputeTypeSize(type) * count + offset > static_cast<GLsizei>(storage->getSize())) { return GL_INVALID_OPERATION; } @@ -163,18 +153,25 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer indexBuffer = streamingBuffer; streamOffset = offset; storage->markBufferUsage(); - computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); + + if (!buffer->getIndexRangeCache()->findRange(type, offset, count, &translated->minIndex, + &translated->maxIndex, NULL)) + { + computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); + buffer->getIndexRangeCache()->addRange(type, offset, count, translated->minIndex, + translated->maxIndex, offset); + } } else if (staticBuffer && staticBuffer->getBufferSize() != 0 && staticBuffer->getIndexType() == type && alignedOffset) { indexBuffer = staticBuffer; - streamOffset = staticBuffer->lookupRange(offset, count, &translated->minIndex, &translated->maxIndex); - - if (streamOffset == -1) + if (!staticBuffer->getIndexRangeCache()->findRange(type, offset, count, &translated->minIndex, + &translated->maxIndex, &streamOffset)) { - streamOffset = (offset / indexTypeSize(type)) * indexTypeSize(destinationIndexType); + streamOffset = (offset / gl::ComputeTypeSize(type)) * gl::ComputeTypeSize(destinationIndexType); computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); - staticBuffer->addRange(offset, count, translated->minIndex, translated->maxIndex, streamOffset); + staticBuffer->getIndexRangeCache()->addRange(type, offset, count, translated->minIndex, + translated->maxIndex, streamOffset); } } else @@ -186,7 +183,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer if (staticBuffer->getBufferSize() == 0 && alignedOffset) { indexBuffer = staticBuffer; - convertCount = storage->getSize() / indexTypeSize(type); + convertCount = storage->getSize() / gl::ComputeTypeSize(type); } else { @@ -201,7 +198,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer return GL_INVALID_OPERATION; } - unsigned int bufferSizeRequired = convertCount * indexTypeSize(destinationIndexType); + unsigned int bufferSizeRequired = convertCount * gl::ComputeTypeSize(destinationIndexType); indexBuffer->reserveBufferSpace(bufferSizeRequired, type); void* output = NULL; @@ -224,20 +221,21 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer if (staticBuffer) { - streamOffset = (offset / indexTypeSize(type)) * indexTypeSize(destinationIndexType); - staticBuffer->addRange(offset, count, translated->minIndex, translated->maxIndex, streamOffset); + streamOffset = (offset / gl::ComputeTypeSize(type)) * gl::ComputeTypeSize(destinationIndexType); + staticBuffer->getIndexRangeCache()->addRange(type, offset, count, translated->minIndex, + translated->maxIndex, streamOffset); } } translated->storage = directStorage ? storage : NULL; translated->indexBuffer = indexBuffer->getIndexBuffer(); translated->serial = directStorage ? storage->getSerial() : indexBuffer->getSerial(); - translated->startIndex = streamOffset / indexTypeSize(destinationIndexType); + translated->startIndex = streamOffset / gl::ComputeTypeSize(destinationIndexType); translated->startOffset = streamOffset; if (buffer) { - buffer->promoteStaticUsage(count * indexTypeSize(type)); + buffer->promoteStaticUsage(count * gl::ComputeTypeSize(type)); } return GL_NO_ERROR; diff --git a/src/libGLESv2/renderer/IndexRangeCache.cpp b/src/libGLESv2/renderer/IndexRangeCache.cpp new file mode 100644 index 00000000..7630934a --- /dev/null +++ b/src/libGLESv2/renderer/IndexRangeCache.cpp @@ -0,0 +1,97 @@ +#include "precompiled.h" +// +// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// IndexRangeCache.cpp: Defines the rx::IndexRangeCache class which stores information about +// ranges of indices. + +#include "libGLESv2/renderer/IndexRangeCache.h" +#include "common/debug.h" +#include "libGLESv2/utilities.h" +#include <tuple> + +namespace rx +{ + +void IndexRangeCache::addRange(GLenum type, intptr_t offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx, + unsigned int streamOffset) +{ + mIndexRangeCache[IndexRange(type, offset, count)] = IndexBounds(minIdx, maxIdx, streamOffset); +} + +void IndexRangeCache::invalidateRange(unsigned int offset, unsigned int size) +{ + unsigned int invalidateStart = offset; + unsigned int invalidateEnd = offset + size; + + IndexRangeMap::iterator i = mIndexRangeCache.begin(); + while (i != mIndexRangeCache.end()) + { + unsigned int rangeStart = i->second.streamOffset; + unsigned int rangeEnd = i->second.streamOffset + (gl::ComputeTypeSize(i->first.type) * i->first.count); + + if (invalidateEnd < rangeStart || invalidateStart > rangeEnd) + { + ++i; + } + else + { + i = mIndexRangeCache.erase(i); + } + } +} + +bool IndexRangeCache::findRange(GLenum type, intptr_t offset, GLsizei count, unsigned int *outMinIndex, + unsigned int *outMaxIndex, unsigned int *outStreamOffset) const +{ + IndexRangeMap::const_iterator i = mIndexRangeCache.find(IndexRange(type, offset, count)); + if (i != mIndexRangeCache.end()) + { + if (outMinIndex) *outMinIndex = i->second.minIndex; + if (outMaxIndex) *outMaxIndex = i->second.maxIndex; + if (outStreamOffset) *outStreamOffset = i->second.streamOffset; + return true; + } + else + { + if (outMinIndex) *outMinIndex = 0; + if (outMaxIndex) *outMaxIndex = 0; + if (outStreamOffset) *outStreamOffset = 0; + return false; + } +} + +void IndexRangeCache::clear() +{ + mIndexRangeCache.clear(); +} + +IndexRangeCache::IndexRange::IndexRange() + : type(GL_NONE), offset(0), count(0) +{ +} + +IndexRangeCache::IndexRange::IndexRange(GLenum typ, intptr_t off, GLsizei c) + : type(typ), offset(off), count(c) +{ +} + +bool IndexRangeCache::IndexRange::operator<(const IndexRange& rhs) const +{ + return std::make_tuple(type, offset, count) < std::make_tuple(rhs.type, rhs.offset, rhs.count); +} + +IndexRangeCache::IndexBounds::IndexBounds() + : minIndex(0), maxIndex(0), streamOffset(0) +{ +} + +IndexRangeCache::IndexBounds::IndexBounds(unsigned int minIdx, unsigned int maxIdx, unsigned int offset) + : minIndex(minIdx), maxIndex(maxIdx), streamOffset(offset) +{ +} + +} diff --git a/src/libGLESv2/renderer/IndexRangeCache.h b/src/libGLESv2/renderer/IndexRangeCache.h new file mode 100644 index 00000000..5a5ade10 --- /dev/null +++ b/src/libGLESv2/renderer/IndexRangeCache.h @@ -0,0 +1,58 @@ +// +// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// IndexRangeCache.h: Defines the rx::IndexRangeCache class which stores information about +// ranges of indices. + +#ifndef LIBGLESV2_RENDERER_INDEXRANGECACHE_H_ +#define LIBGLESV2_RENDERER_INDEXRANGECACHE_H_ + +#include "common/angleutils.h" + +namespace rx +{ + +class IndexRangeCache +{ + public: + void addRange(GLenum type, intptr_t offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx, + unsigned int streamOffset); + bool findRange(GLenum type, intptr_t offset, GLsizei count, unsigned int *outMinIndex, + unsigned int *outMaxIndex, unsigned int *outStreamOffset) const; + + void invalidateRange(unsigned int offset, unsigned int size); + void clear(); + + private: + struct IndexRange + { + GLenum type; + intptr_t offset; + GLsizei count; + + IndexRange(); + IndexRange(GLenum type, intptr_t offset, GLsizei count); + + bool operator<(const IndexRange& rhs) const; + }; + + struct IndexBounds + { + unsigned int minIndex; + unsigned int maxIndex; + unsigned int streamOffset; + + IndexBounds(); + IndexBounds(unsigned int minIdx, unsigned int maxIdx, unsigned int offset); + }; + + typedef std::map<IndexRange, IndexBounds> IndexRangeMap; + IndexRangeMap mIndexRangeCache; +}; + +} + +#endif LIBGLESV2_RENDERER_INDEXRANGECACHE_H diff --git a/src/libGLESv2/renderer/InputLayoutCache.cpp b/src/libGLESv2/renderer/InputLayoutCache.cpp index 0402bb35..fcc6f7ce 100644 --- a/src/libGLESv2/renderer/InputLayoutCache.cpp +++ b/src/libGLESv2/renderer/InputLayoutCache.cpp @@ -28,6 +28,13 @@ InputLayoutCache::InputLayoutCache() : mInputLayoutMap(kMaxInputLayouts, hashInp mCounter = 0; mDevice = NULL; mDeviceContext = NULL; + mCurrentIL = NULL; + for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) + { + mCurrentBuffers[i] = -1; + mCurrentVertexStrides[i] = -1; + mCurrentVertexOffsets[i] = -1; + } } InputLayoutCache::~InputLayoutCache() @@ -49,6 +56,18 @@ void InputLayoutCache::clear() i->second.inputLayout->Release(); } mInputLayoutMap.clear(); + markDirty(); +} + +void InputLayoutCache::markDirty() +{ + mCurrentIL = NULL; + for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) + { + mCurrentBuffers[i] = -1; + mCurrentVertexStrides[i] = -1; + mCurrentVertexOffsets[i] = -1; + } } GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], @@ -66,6 +85,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M InputLayoutKey ilKey = { 0 }; ID3D11Buffer *vertexBuffers[gl::MAX_VERTEX_ATTRIBS] = { NULL }; + unsigned int vertexBufferSerials[gl::MAX_VERTEX_ATTRIBS] = { 0 }; UINT vertexStrides[gl::MAX_VERTEX_ATTRIBS] = { 0 }; UINT vertexOffsets[gl::MAX_VERTEX_ATTRIBS] = { 0 }; @@ -95,6 +115,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M ilKey.elementCount++; vertexBuffers[i] = bufferStorage ? bufferStorage->getBuffer() : vertexBuffer->getBuffer(); + vertexBufferSerials[i] = bufferStorage ? bufferStorage->getSerial() : vertexBuffer->getSerial(); vertexStrides[i] = attributes[i].stride; vertexOffsets[i] = attributes[i].offset; } @@ -143,8 +164,23 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M mInputLayoutMap.insert(std::make_pair(ilKey, inputCounterPair)); } - mDeviceContext->IASetInputLayout(inputLayout); - mDeviceContext->IASetVertexBuffers(0, gl::MAX_VERTEX_ATTRIBS, vertexBuffers, vertexStrides, vertexOffsets); + if (inputLayout != mCurrentIL) + { + mDeviceContext->IASetInputLayout(inputLayout); + mCurrentIL = inputLayout; + } + + for (unsigned int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++) + { + if (vertexBufferSerials[i] != mCurrentBuffers[i] || vertexStrides[i] != mCurrentVertexStrides[i] || + vertexOffsets[i] != mCurrentVertexOffsets[i]) + { + mDeviceContext->IASetVertexBuffers(i, 1, &vertexBuffers[i], &vertexStrides[i], &vertexOffsets[i]); + mCurrentBuffers[i] = vertexBufferSerials[i]; + mCurrentVertexStrides[i] = vertexStrides[i]; + mCurrentVertexOffsets[i] = vertexOffsets[i]; + } + } return GL_NO_ERROR; } diff --git a/src/libGLESv2/renderer/InputLayoutCache.h b/src/libGLESv2/renderer/InputLayoutCache.h index d95f39fa..797853de 100644 --- a/src/libGLESv2/renderer/InputLayoutCache.h +++ b/src/libGLESv2/renderer/InputLayoutCache.h @@ -30,6 +30,7 @@ class InputLayoutCache void initialize(ID3D11Device *device, ID3D11DeviceContext *context); void clear(); + void markDirty(); GLenum applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], gl::ProgramBinary *programBinary); @@ -50,6 +51,11 @@ class InputLayoutCache unsigned long long lastUsedTime; }; + ID3D11InputLayout *mCurrentIL; + unsigned int mCurrentBuffers[gl::MAX_VERTEX_ATTRIBS]; + UINT mCurrentVertexStrides[gl::MAX_VERTEX_ATTRIBS]; + UINT mCurrentVertexOffsets[gl::MAX_VERTEX_ATTRIBS]; + static std::size_t hashInputLayout(const InputLayoutKey &inputLayout); static bool compareInputLayouts(const InputLayoutKey &a, const InputLayoutKey &b); diff --git a/src/libGLESv2/renderer/RenderTarget11.cpp b/src/libGLESv2/renderer/RenderTarget11.cpp index cf226de1..2667cc6f 100644 --- a/src/libGLESv2/renderer/RenderTarget11.cpp +++ b/src/libGLESv2/renderer/RenderTarget11.cpp @@ -329,44 +329,21 @@ RenderTarget11 *RenderTarget11::makeRenderTarget11(RenderTarget *target) ID3D11Texture2D *RenderTarget11::getTexture() const { - if (mTexture) - { - mTexture->AddRef(); - } - return mTexture; } -// Adds reference, caller must call Release ID3D11RenderTargetView *RenderTarget11::getRenderTargetView() const { - if (mRenderTarget) - { - mRenderTarget->AddRef(); - } - return mRenderTarget; } -// Adds reference, caller must call Release ID3D11DepthStencilView *RenderTarget11::getDepthStencilView() const { - if (mDepthStencil) - { - mDepthStencil->AddRef(); - } - return mDepthStencil; } -// Adds reference, caller must call Release ID3D11ShaderResourceView *RenderTarget11::getShaderResourceView() const { - if (mShaderResource) - { - mShaderResource->AddRef(); - } - return mShaderResource; } diff --git a/src/libGLESv2/renderer/RenderTarget11.h b/src/libGLESv2/renderer/RenderTarget11.h index dc697cf0..97827f26 100644 --- a/src/libGLESv2/renderer/RenderTarget11.h +++ b/src/libGLESv2/renderer/RenderTarget11.h @@ -27,16 +27,9 @@ class RenderTarget11 : public RenderTarget static RenderTarget11 *makeRenderTarget11(RenderTarget *renderTarget); - // Adds reference, caller must call Release ID3D11Texture2D *getTexture() const; - - // Adds reference, caller must call Release ID3D11RenderTargetView *getRenderTargetView() const; - - // Adds reference, caller must call Release ID3D11DepthStencilView *getDepthStencilView() const; - - // Adds reference, caller must call Release ID3D11ShaderResourceView *getShaderResourceView() const; unsigned int getSubresourceIndex() const; diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp index e544b40c..9173fc8c 100644 --- a/src/libGLESv2/renderer/Renderer11.cpp +++ b/src/libGLESv2/renderer/Renderer11.cpp @@ -835,23 +835,29 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count) { D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; + GLsizei minCount = 0; + switch (mode) { - case GL_POINTS: primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; break; - case GL_LINES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINELIST; break; - case GL_LINE_LOOP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; break; - case GL_LINE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; break; - case GL_TRIANGLES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break; - case GL_TRIANGLE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break; + case GL_POINTS: primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; minCount = 1; break; + case GL_LINES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINELIST; minCount = 2; break; + case GL_LINE_LOOP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; minCount = 2; break; + case GL_LINE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; minCount = 2; break; + case GL_TRIANGLES: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break; + case GL_TRIANGLE_STRIP: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; minCount = 3; break; // emulate fans via rewriting index buffer - case GL_TRIANGLE_FAN: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break; + case GL_TRIANGLE_FAN: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break; default: return gl::error(GL_INVALID_ENUM, false); } - mDeviceContext->IASetPrimitiveTopology(primitiveTopology); + if (primitiveTopology != mCurrentPrimitiveTopology) + { + mDeviceContext->IASetPrimitiveTopology(primitiveTopology); + mCurrentPrimitiveTopology = primitiveTopology; + } - return count > 0; + return count >= minCount; } bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) @@ -1013,9 +1019,6 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) mDepthStencilInitialized = true; } - SafeRelease(framebufferRTVs); - SafeRelease(framebufferDSV); - return true; } @@ -1130,13 +1133,16 @@ void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, } } - if (static_cast<unsigned int>(count + 1) > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) + // Checked by Renderer11::applyPrimitiveType + ASSERT(count >= 0); + + if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) { ERR("Could not create a 32-bit looping index buffer for GL_LINE_LOOP, too many indices required."); return gl::error(GL_OUT_OF_MEMORY); } - const unsigned int spaceNeeded = (count + 1) * sizeof(unsigned int); + const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned int); if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT)) { ERR("Could not reserve enough space in looping index buffer for GL_LINE_LOOP."); @@ -1230,9 +1236,12 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic } } + // Checked by Renderer11::applyPrimitiveType + ASSERT(count >= 3); + const unsigned int numTris = count - 2; - if (numTris * 3 > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) + if (numTris > (std::numeric_limits<unsigned int>::max() / (sizeof(unsigned int) * 3))) { ERR("Could not create a scratch index buffer for GL_TRIANGLE_FAN, too many indices required."); return gl::error(GL_OUT_OF_MEMORY); @@ -1442,9 +1451,18 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra { mDeviceContext->Unmap(pixelConstantBuffer, 0); } - - mDeviceContext->VSSetConstantBuffers(0, 1, &vertexConstantBuffer); - mDeviceContext->PSSetConstantBuffers(0, 1, &pixelConstantBuffer); + + if (mCurrentVertexConstantBuffer != vertexConstantBuffer) + { + mDeviceContext->VSSetConstantBuffers(0, 1, &vertexConstantBuffer); + mCurrentVertexConstantBuffer = vertexConstantBuffer; + } + + if (mCurrentPixelConstantBuffer != pixelConstantBuffer) + { + mDeviceContext->PSSetConstantBuffers(0, 1, &pixelConstantBuffer); + mCurrentPixelConstantBuffer = pixelConstantBuffer; + } // Driver uniforms if (!mDriverConstantBufferVS) @@ -1492,7 +1510,11 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra } // needed for the point sprite geometry shader - mDeviceContext->GSSetConstantBuffers(0, 1, &mDriverConstantBufferPS); + if (mCurrentGeometryConstantBuffer != mDriverConstantBufferPS) + { + mDeviceContext->GSSetConstantBuffers(0, 1, &mDriverConstantBufferPS); + mCurrentGeometryConstantBuffer = mDriverConstantBufferPS; + } } void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) @@ -1549,8 +1571,6 @@ void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer * clearParams.colorClearValue.blue, clearParams.colorClearValue.alpha }; mDeviceContext->ClearRenderTargetView(framebufferRTV, clearValues); - - framebufferRTV->Release(); } } } @@ -1588,8 +1608,6 @@ void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer * UINT8 stencilClear = clearParams.stencilClearValue & 0x000000FF; mDeviceContext->ClearDepthStencilView(framebufferDSV, clearFlags, depthClear, stencilClear); - - framebufferDSV->Release(); } } } @@ -1797,6 +1815,14 @@ void Renderer11::markAllStateDirty() mAppliedProgramBinarySerial = 0; memset(&mAppliedVertexConstants, 0, sizeof(dx_VertexConstants)); memset(&mAppliedPixelConstants, 0, sizeof(dx_PixelConstants)); + + mInputLayoutCache.markDirty(); + + mCurrentVertexConstantBuffer = NULL; + mCurrentPixelConstantBuffer = NULL; + mCurrentGeometryConstantBuffer = NULL; + + mCurrentPrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; } void Renderer11::releaseDeviceResources() @@ -2424,7 +2450,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so TextureStorage11_2D *storage11 = TextureStorage11_2D::makeTextureStorage11_2D(storage->getStorageInstance()); if (!storage11) { - source->Release(); ERR("Failed to retrieve the texture storage from the destination."); return gl::error(GL_OUT_OF_MEMORY, false); } @@ -2432,7 +2457,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so RenderTarget11 *destRenderTarget = RenderTarget11::makeRenderTarget11(storage11->getRenderTarget(level)); if (!destRenderTarget) { - source->Release(); ERR("Failed to retrieve the render target from the destination storage."); return gl::error(GL_OUT_OF_MEMORY, false); } @@ -2440,7 +2464,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so ID3D11RenderTargetView *dest = destRenderTarget->getRenderTargetView(); if (!dest) { - source->Release(); ERR("Failed to retrieve the render target view from the destination render target."); return gl::error(GL_OUT_OF_MEMORY, false); } @@ -2454,9 +2477,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so bool ret = copyTexture(source, sourceRect, sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), dest, destRect, destRenderTarget->getWidth(), destRenderTarget->getHeight(), destFormat); - source->Release(); - dest->Release(); - return ret; } @@ -2487,7 +2507,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so TextureStorage11_Cube *storage11 = TextureStorage11_Cube::makeTextureStorage11_Cube(storage->getStorageInstance()); if (!storage11) { - source->Release(); ERR("Failed to retrieve the texture storage from the destination."); return gl::error(GL_OUT_OF_MEMORY, false); } @@ -2495,7 +2514,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so RenderTarget11 *destRenderTarget = RenderTarget11::makeRenderTarget11(storage11->getRenderTarget(target, level)); if (!destRenderTarget) { - source->Release(); ERR("Failed to retrieve the render target from the destination storage."); return gl::error(GL_OUT_OF_MEMORY, false); } @@ -2503,7 +2521,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so ID3D11RenderTargetView *dest = destRenderTarget->getRenderTargetView(); if (!dest) { - source->Release(); ERR("Failed to retrieve the render target view from the destination render target."); return gl::error(GL_OUT_OF_MEMORY, false); } @@ -2517,9 +2534,6 @@ bool Renderer11::copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &so bool ret = copyTexture(source, sourceRect, sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), dest, destRect, destRenderTarget->getWidth(), destRenderTarget->getHeight(), destFormat); - source->Release(); - dest->Release(); - return ret; } @@ -2869,7 +2883,6 @@ bool Renderer11::getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned { ID3D11Resource *textureResource = NULL; colorBufferRTV->GetResource(&textureResource); - colorBufferRTV->Release(); if (textureResource) { @@ -3404,6 +3417,16 @@ bool Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::R { ASSERT(readRect.width == drawRect.width && readRect.height == drawRect.height); + RenderTarget11 *drawRenderTarget11 = RenderTarget11::makeRenderTarget11(drawRenderTarget); + if (!drawRenderTarget) + { + ERR("Failed to retrieve the draw render target from the draw framebuffer."); + return gl::error(GL_OUT_OF_MEMORY, false); + } + + ID3D11Texture2D *drawTexture = drawRenderTarget11->getTexture(); + unsigned int drawSubresource = drawRenderTarget11->getSubresourceIndex(); + RenderTarget11 *readRenderTarget11 = RenderTarget11::makeRenderTarget11(readRenderTarget); if (!readRenderTarget) { @@ -3415,16 +3438,13 @@ bool Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::R unsigned int readSubresource = 0; if (readRenderTarget->getSamples() > 0) { - ID3D11Texture2D *unresolvedTexture = readRenderTarget11->getTexture(); - - readTexture = resolveMultisampledTexture(unresolvedTexture, readRenderTarget11->getSubresourceIndex()); + readTexture = resolveMultisampledTexture(readRenderTarget11->getTexture(), readRenderTarget11->getSubresourceIndex()); readSubresource = 0; - - unresolvedTexture->Release(); } else { readTexture = readRenderTarget11->getTexture(); + readTexture->AddRef(); readSubresource = readRenderTarget11->getSubresourceIndex(); } @@ -3434,17 +3454,6 @@ bool Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::R return gl::error(GL_OUT_OF_MEMORY, false); } - RenderTarget11 *drawRenderTarget11 = RenderTarget11::makeRenderTarget11(drawRenderTarget); - if (!drawRenderTarget) - { - readTexture->Release(); - ERR("Failed to retrieve the draw render target from the draw framebuffer."); - return gl::error(GL_OUT_OF_MEMORY, false); - } - - ID3D11Texture2D *drawTexture = drawRenderTarget11->getTexture(); - unsigned int drawSubresource = drawRenderTarget11->getSubresourceIndex(); - D3D11_BOX readBox; readBox.left = readRect.x; readBox.right = readRect.x + readRect.width; @@ -3460,8 +3469,7 @@ bool Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::R mDeviceContext->CopySubresourceRegion(drawTexture, drawSubresource, drawRect.x, drawRect.y, 0, readTexture, readSubresource, pSrcBox); - readTexture->Release(); - drawTexture->Release(); + SafeRelease(readTexture); return true; } diff --git a/src/libGLESv2/renderer/Renderer11.h b/src/libGLESv2/renderer/Renderer11.h index b3b742cd..f024855f 100644 --- a/src/libGLESv2/renderer/Renderer11.h +++ b/src/libGLESv2/renderer/Renderer11.h @@ -288,6 +288,9 @@ class Renderer11 : public Renderer float mCurNear; float mCurFar; + // Currently applied primitive topology + D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology; + unsigned int mAppliedIBSerial; unsigned int mAppliedStorageIBSerial; unsigned int mAppliedIBOffset; @@ -298,10 +301,14 @@ class Renderer11 : public Renderer dx_VertexConstants mVertexConstants; dx_VertexConstants mAppliedVertexConstants; ID3D11Buffer *mDriverConstantBufferVS; + ID3D11Buffer *mCurrentVertexConstantBuffer; dx_PixelConstants mPixelConstants; dx_PixelConstants mAppliedPixelConstants; ID3D11Buffer *mDriverConstantBufferPS; + ID3D11Buffer *mCurrentPixelConstantBuffer; + + ID3D11Buffer *mCurrentGeometryConstantBuffer; // Vertex, index and input layouts VertexDataManager *mVertexDataManager; diff --git a/src/libGLESv2/renderer/Renderer9.cpp b/src/libGLESv2/renderer/Renderer9.cpp index 4aecd4ae..240367d5 100644 --- a/src/libGLESv2/renderer/Renderer9.cpp +++ b/src/libGLESv2/renderer/Renderer9.cpp @@ -1471,13 +1471,16 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, } } - if (static_cast<unsigned int>(count + 1) > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) + if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned int>::max() / sizeof(unsigned int))) { ERR("Could not create a 32-bit looping index buffer for GL_LINE_LOOP, too many indices required."); return gl::error(GL_OUT_OF_MEMORY); } - const unsigned int spaceNeeded = (count + 1) * sizeof(unsigned int); + // Checked by Renderer9::applyPrimitiveType + ASSERT(count >= 0); + + const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned int); if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT)) { ERR("Could not reserve enough space in looping index buffer for GL_LINE_LOOP."); @@ -1549,13 +1552,16 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, } } - if (static_cast<unsigned int>(count + 1) > (std::numeric_limits<unsigned short>::max() / sizeof(unsigned short))) + // Checked by Renderer9::applyPrimitiveType + ASSERT(count >= 0); + + if (static_cast<unsigned int>(count) + 1 > (std::numeric_limits<unsigned short>::max() / sizeof(unsigned short))) { ERR("Could not create a 16-bit looping index buffer for GL_LINE_LOOP, too many indices required."); return gl::error(GL_OUT_OF_MEMORY); } - const int spaceNeeded = (count + 1) * sizeof(unsigned short); + const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned short); if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT)) { ERR("Could not reserve enough space in looping index buffer for GL_LINE_LOOP."); diff --git a/src/libGLESv2/renderer/TextureStorage11.cpp b/src/libGLESv2/renderer/TextureStorage11.cpp index 667dbff1..408b48eb 100644 --- a/src/libGLESv2/renderer/TextureStorage11.cpp +++ b/src/libGLESv2/renderer/TextureStorage11.cpp @@ -69,7 +69,6 @@ bool TextureStorage11::IsTextureFormatRenderable(DXGI_FORMAT format) case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_A8_UNORM: case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32_FLOAT: case DXGI_FORMAT_R16G16B16A16_FLOAT: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_R8_UNORM: @@ -80,6 +79,7 @@ bool TextureStorage11::IsTextureFormatRenderable(DXGI_FORMAT format) case DXGI_FORMAT_BC1_UNORM: case DXGI_FORMAT_BC2_UNORM: case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_R32G32B32_FLOAT: // not renderable on all devices return false; default: UNREACHABLE(); @@ -187,15 +187,6 @@ void TextureStorage11::generateMipmapLayer(RenderTarget11 *source, RenderTarget1 destRTV, destArea, dest->getWidth(), dest->getHeight(), GL_RGBA); } - - if (sourceSRV) - { - sourceSRV->Release(); - } - if (destRTV) - { - destRTV->Release(); - } } } diff --git a/src/libGLESv2/renderer/renderer11_utils.cpp b/src/libGLESv2/renderer/renderer11_utils.cpp index 5f01dc12..13800da2 100644 --- a/src/libGLESv2/renderer/renderer11_utils.cpp +++ b/src/libGLESv2/renderer/renderer11_utils.cpp @@ -356,7 +356,7 @@ DXGI_FORMAT ConvertTextureFormat(GLenum internalformat) return DXGI_FORMAT_R32G32B32A32_FLOAT; case GL_RGB32F_EXT: case GL_LUMINANCE32F_EXT: - return DXGI_FORMAT_R32G32B32_FLOAT; + return DXGI_FORMAT_R32G32B32A32_FLOAT; case GL_RGBA16F_EXT: case GL_ALPHA16F_EXT: case GL_LUMINANCE_ALPHA16F_EXT: diff --git a/src/libGLESv2/utilities.cpp b/src/libGLESv2/utilities.cpp index 9809b9d8..32df49e6 100644 --- a/src/libGLESv2/utilities.cpp +++ b/src/libGLESv2/utilities.cpp @@ -218,6 +218,29 @@ GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum internalform } } +GLsizei ComputeTypeSize(GLenum type) +{ + switch (type) + { + case GL_BYTE: return 1; + case GL_UNSIGNED_BYTE: return 1; + case GL_SHORT: return 2; + case GL_UNSIGNED_SHORT: return 2; + case GL_INT: return 4; + case GL_UNSIGNED_INT: return 4; + case GL_FLOAT: return 4; + case GL_HALF_FLOAT_OES: return 2; + case GL_UNSIGNED_SHORT_5_6_5: return 2; + case GL_UNSIGNED_SHORT_4_4_4_4: return 2; + case GL_UNSIGNED_SHORT_5_5_5_1: return 2; + case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: return 2; + case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: return 2; + case GL_UNSIGNED_INT_2_10_10_10_REV_EXT: return 4; + case GL_UNSIGNED_INT_24_8_OES: return 4; + default: UNREACHABLE(); return 0; + } +} + bool IsCompressed(GLenum format) { if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || diff --git a/src/libGLESv2/utilities.h b/src/libGLESv2/utilities.h index 7a107670..ed663ebc 100644 --- a/src/libGLESv2/utilities.h +++ b/src/libGLESv2/utilities.h @@ -34,6 +34,7 @@ int ComputePixelSize(GLint internalformat); GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment); GLsizei ComputeCompressedPitch(GLsizei width, GLenum format); GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format); +GLsizei ComputeTypeSize(GLenum type); bool IsCompressed(GLenum format); bool IsDepthTexture(GLenum format); bool IsStencilTexture(GLenum format); |