diff --git a/gfx/angle/AUTHORS b/gfx/angle/AUTHORS index d7ecb4af98ea..6b93e4cc4d36 100644 --- a/gfx/angle/AUTHORS +++ b/gfx/angle/AUTHORS @@ -15,3 +15,4 @@ Google Inc. Cloud Party, Inc. +Jacek Caban diff --git a/gfx/angle/README.mozilla b/gfx/angle/README.mozilla index 5ffba8c56ce5..410ce1328b5a 100644 --- a/gfx/angle/README.mozilla +++ b/gfx/angle/README.mozilla @@ -1,6 +1,6 @@ This is the ANGLE project, from http://code.google.com/p/angleproject/ -Current revision: r1242 +Current revision: r1267 == Applied local patches == diff --git a/gfx/angle/build/common.gypi b/gfx/angle/build/common.gypi index e7ba4249a792..541e914e4a9a 100644 --- a/gfx/angle/build/common.gypi +++ b/gfx/angle/build/common.gypi @@ -5,6 +5,10 @@ { 'variables': { 'component%': 'static_library', + # angle_code is set to 1 for the core ANGLE targets defined in src/build_angle.gyp. + # angle_code is set to 0 for test code, sample code, and third party code. + # When angle_code is 1, we build with additional warning flags on Mac and Linux. + 'angle_code%': 0, 'gcc_or_clang_warnings': [ '-Wall', '-Wchar-subscripts', @@ -146,6 +150,20 @@ }, }, }], + ['angle_code==1', { + 'target_defaults': { + 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': { + 'WARNING_CFLAGS': ['<@(gcc_or_clang_warnings)'] + }, + }], + ['OS!="win" and OS!="mac"', { + 'cflags': ['<@(gcc_or_clang_warnings)'] + }], + ] + } + }], ], } diff --git a/gfx/angle/src/build_angle.gyp b/gfx/angle/src/build_angle.gyp index cb8aa4d93eaf..aa7fbc659b07 100644 --- a/gfx/angle/src/build_angle.gyp +++ b/gfx/angle/src/build_angle.gyp @@ -3,6 +3,9 @@ # found in the LICENSE file. { + 'variables': { + 'angle_code': 1, + }, 'target_defaults': { 'defines': [ 'ANGLE_DISABLE_TRACE', @@ -43,16 +46,6 @@ 'compiler/preprocessor/new/Tokenizer.cpp', 'compiler/preprocessor/new/Tokenizer.h', ], - 'conditions': [ - ['OS=="mac"', { - 'xcode_settings': { - 'WARNING_CFLAGS': ['<@(gcc_or_clang_warnings)'] - }, - }], - ['OS=="linux"', { - 'cflags': ['<@(gcc_or_clang_warnings)'] - }], - ], }, { 'target_name': 'translator_common', @@ -164,14 +157,6 @@ }, { # else: posix 'sources': ['compiler/ossource_posix.cpp'], }], - ['OS=="mac"', { - 'xcode_settings': { - 'WARNING_CFLAGS': ['<@(gcc_or_clang_warnings)'] - }, - }], - ['OS=="linux"', { - 'cflags': ['<@(gcc_or_clang_warnings)'] - }], ], }, { @@ -201,16 +186,6 @@ 'compiler/VersionGLSL.cpp', 'compiler/VersionGLSL.h', ], - 'conditions': [ - ['OS=="mac"', { - 'xcode_settings': { - 'WARNING_CFLAGS': ['<@(gcc_or_clang_warnings)'] - }, - }], - ['OS=="linux"', { - 'cflags': ['<@(gcc_or_clang_warnings)'] - }], - ], }, ], 'conditions': [ @@ -295,6 +270,7 @@ 'libGLESv2/Shader.cpp', 'libGLESv2/Shader.h', 'libGLESv2/Texture.cpp', + 'libGLESv2/TextureSSE2.cpp', 'libGLESv2/Texture.h', 'libGLESv2/utilities.cpp', 'libGLESv2/utilities.h', diff --git a/gfx/angle/src/common/angleutils.h b/gfx/angle/src/common/angleutils.h index 7d9349a4dfd9..ff9730c4da7a 100644 --- a/gfx/angle/src/common/angleutils.h +++ b/gfx/angle/src/common/angleutils.h @@ -19,4 +19,8 @@ #define snprintf _snprintf #endif +#define VENDOR_ID_AMD 0x1002 +#define VENDOR_ID_INTEL 0x8086 +#define VENDOR_ID_NVIDIA 0x10DE + #endif // COMMON_ANGLEUTILS_H_ diff --git a/gfx/angle/src/common/debug.h b/gfx/angle/src/common/debug.h index 9828ecf0389e..5f8f60fe6111 100644 --- a/gfx/angle/src/common/debug.h +++ b/gfx/angle/src/common/debug.h @@ -42,28 +42,30 @@ namespace gl #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF) #define TRACE(message, ...) (void(0)) #else -#define TRACE(message, ...) gl::trace(true, "trace: %s(%d): "message"\n", __FUNCTION__, __LINE__, __VA_ARGS__) +#define TRACE(message, ...) gl::trace(true, "trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) #endif // A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing. #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF) #define FIXME(message, ...) (void(0)) #else -#define FIXME(message, ...) gl::trace(false, "fixme: %s(%d): "message"\n", __FUNCTION__, __LINE__, __VA_ARGS__) +#define FIXME(message, ...) gl::trace(false, "fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) #endif // A macro to output a function call and its arguments to the debugging log, in case of error. #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF) #define ERR(message, ...) (void(0)) #else -#define ERR(message, ...) gl::trace(false, "err: %s(%d): "message"\n", __FUNCTION__, __LINE__, __VA_ARGS__) +#define ERR(message, ...) gl::trace(false, "err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) #endif // A macro to log a performance event around a scope. #if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF) #define EVENT(message, ...) (void(0)) -#else +#elif defined(_MSC_VER) #define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper ## __LINE__(__FUNCTION__ message "\n", __VA_ARGS__); +#else +#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper(message "\n", ##__VA_ARGS__); #endif // A macro asserting a condition and outputting failures to the debug log diff --git a/gfx/angle/src/common/version.h b/gfx/angle/src/common/version.h index 162b2b275a56..ce0c2c0cd24d 100644 --- a/gfx/angle/src/common/version.h +++ b/gfx/angle/src/common/version.h @@ -1,7 +1,7 @@ #define MAJOR_VERSION 1 #define MINOR_VERSION 0 #define BUILD_VERSION 0 -#define BUILD_REVISION 1242 +#define BUILD_REVISION 1267 #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) diff --git a/gfx/angle/src/compiler/RenameFunction.h b/gfx/angle/src/compiler/RenameFunction.h index cfdb40da9285..3908bfddb820 100644 --- a/gfx/angle/src/compiler/RenameFunction.h +++ b/gfx/angle/src/compiler/RenameFunction.h @@ -29,8 +29,8 @@ public: } private: - const TString& mOldFunctionName; - const TString& mNewFunctionName; + const TString mOldFunctionName; + const TString mNewFunctionName; }; #endif // COMPILER_RENAME_FUNCTION diff --git a/gfx/angle/src/compiler/glslang.y b/gfx/angle/src/compiler/glslang.y index 8224f5a9478b..081a6990981a 100644 --- a/gfx/angle/src/compiler/glslang.y +++ b/gfx/angle/src/compiler/glslang.y @@ -337,18 +337,10 @@ postfix_expression else $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqConst, (int) (*$3.string).size())); } else { - if (fields.num == 1) { - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setIConst(fields.offsets[0]); - TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line); - $$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line); - $$->setType(TType($1->getBasicType(), $1->getPrecision())); - } else { - TString vectorString = *$3.string; - TIntermTyped* index = context->intermediate.addSwizzle(fields, $3.line); - $$ = context->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line); - $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, (int) vectorString.size())); - } + TString vectorString = *$3.string; + TIntermTyped* index = context->intermediate.addSwizzle(fields, $3.line); + $$ = context->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line); + $$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, (int) vectorString.size())); } } else if ($1->isMatrix()) { TMatrixFields fields; diff --git a/gfx/angle/src/compiler/glslang_tab.cpp b/gfx/angle/src/compiler/glslang_tab.cpp index f1f55c0b6788..2de25dfbd42c 100644 --- a/gfx/angle/src/compiler/glslang_tab.cpp +++ b/gfx/angle/src/compiler/glslang_tab.cpp @@ -658,26 +658,26 @@ static const yytype_int16 yyrhs[] = static const yytype_uint16 yyrline[] = { 0, 165, 165, 200, 203, 216, 221, 226, 232, 235, - 314, 317, 426, 436, 449, 457, 557, 560, 568, 572, - 579, 583, 590, 596, 605, 613, 668, 675, 685, 688, - 698, 708, 729, 730, 731, 736, 737, 746, 758, 759, - 767, 778, 782, 783, 793, 803, 813, 826, 827, 837, - 850, 854, 858, 862, 863, 876, 877, 890, 891, 904, - 905, 922, 923, 936, 937, 938, 939, 940, 944, 947, - 958, 966, 993, 998, 1005, 1043, 1046, 1053, 1061, 1082, - 1103, 1114, 1143, 1148, 1158, 1163, 1173, 1176, 1179, 1182, - 1188, 1195, 1198, 1220, 1238, 1262, 1285, 1289, 1307, 1315, - 1347, 1367, 1456, 1465, 1488, 1491, 1497, 1505, 1513, 1521, - 1531, 1538, 1541, 1544, 1550, 1553, 1568, 1572, 1576, 1580, - 1589, 1594, 1599, 1604, 1609, 1614, 1619, 1624, 1629, 1634, - 1640, 1646, 1652, 1657, 1662, 1671, 1680, 1685, 1698, 1698, - 1712, 1712, 1721, 1724, 1739, 1775, 1779, 1785, 1793, 1809, - 1813, 1817, 1818, 1824, 1825, 1826, 1827, 1828, 1832, 1833, - 1833, 1833, 1843, 1844, 1848, 1848, 1849, 1849, 1854, 1857, - 1867, 1870, 1876, 1877, 1881, 1889, 1893, 1903, 1908, 1925, - 1925, 1930, 1930, 1937, 1937, 1945, 1948, 1954, 1957, 1963, - 1967, 1974, 1981, 1988, 1995, 2006, 2015, 2019, 2026, 2029, - 2035, 2035 + 314, 317, 418, 428, 441, 449, 549, 552, 560, 564, + 571, 575, 582, 588, 597, 605, 660, 667, 677, 680, + 690, 700, 721, 722, 723, 728, 729, 738, 750, 751, + 759, 770, 774, 775, 785, 795, 805, 818, 819, 829, + 842, 846, 850, 854, 855, 868, 869, 882, 883, 896, + 897, 914, 915, 928, 929, 930, 931, 932, 936, 939, + 950, 958, 985, 990, 997, 1035, 1038, 1045, 1053, 1074, + 1095, 1106, 1135, 1140, 1150, 1155, 1165, 1168, 1171, 1174, + 1180, 1187, 1190, 1212, 1230, 1254, 1277, 1281, 1299, 1307, + 1339, 1359, 1448, 1457, 1480, 1483, 1489, 1497, 1505, 1513, + 1523, 1530, 1533, 1536, 1542, 1545, 1560, 1564, 1568, 1572, + 1581, 1586, 1591, 1596, 1601, 1606, 1611, 1616, 1621, 1626, + 1632, 1638, 1644, 1649, 1654, 1663, 1672, 1677, 1690, 1690, + 1704, 1704, 1713, 1716, 1731, 1767, 1771, 1777, 1785, 1801, + 1805, 1809, 1810, 1816, 1817, 1818, 1819, 1820, 1824, 1825, + 1825, 1825, 1835, 1836, 1840, 1840, 1841, 1841, 1846, 1849, + 1859, 1862, 1868, 1869, 1873, 1881, 1885, 1895, 1900, 1917, + 1917, 1922, 1922, 1929, 1929, 1937, 1940, 1946, 1949, 1955, + 1959, 1966, 1973, 1980, 1987, 1998, 2007, 2011, 2018, 2021, + 2027, 2027 }; #endif @@ -2271,18 +2271,10 @@ yyreduce: else (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(), EvqConst, (int) (*(yyvsp[(3) - (3)].lex).string).size())); } else { - if (fields.num == 1) { - ConstantUnion *unionArray = new ConstantUnion[1]; - unionArray->setIConst(fields.offsets[0]); - TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yyvsp[(3) - (3)].lex).line); - (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpIndexDirect, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); - (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision())); - } else { - TString vectorString = *(yyvsp[(3) - (3)].lex).string; - TIntermTyped* index = context->intermediate.addSwizzle(fields, (yyvsp[(3) - (3)].lex).line); - (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpVectorSwizzle, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); - (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (int) vectorString.size())); - } + TString vectorString = *(yyvsp[(3) - (3)].lex).string; + TIntermTyped* index = context->intermediate.addSwizzle(fields, (yyvsp[(3) - (3)].lex).line); + (yyval.interm.intermTypedNode) = context->intermediate.addIndex(EOpVectorSwizzle, (yyvsp[(1) - (3)].interm.intermTypedNode), index, (yyvsp[(2) - (3)].lex).line); + (yyval.interm.intermTypedNode)->setType(TType((yyvsp[(1) - (3)].interm.intermTypedNode)->getBasicType(), (yyvsp[(1) - (3)].interm.intermTypedNode)->getPrecision(), EvqTemporary, (int) vectorString.size())); } } else if ((yyvsp[(1) - (3)].interm.intermTypedNode)->isMatrix()) { TMatrixFields fields; diff --git a/gfx/angle/src/libEGL/Display.cpp b/gfx/angle/src/libEGL/Display.cpp index 3c59cffe246b..a2dee6d96483 100644 --- a/gfx/angle/src/libEGL/Display.cpp +++ b/gfx/angle/src/libEGL/Display.cpp @@ -196,6 +196,12 @@ bool Display::initialize() mD3d9->GetAdapterIdentifier(mAdapter, 0, &mAdapterIdentifier); + // ATI cards on XP have problems with non-power-of-two textures. + mSupportsNonPower2Textures = !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) && + !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) && + !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) && + !(getComparableOSVersion() < versionWindowsVista && mAdapterIdentifier.VendorId == VENDOR_ID_AMD); + const D3DFORMAT renderTargetFormats[] = { D3DFMT_A1R5G5B5, @@ -1254,9 +1260,7 @@ bool Display::getVertexTextureSupport() const bool Display::getNonPower2TextureSupport() const { - return !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) && - !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) && - !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL); + return mSupportsNonPower2Textures; } bool Display::getOcclusionQuerySupport() const diff --git a/gfx/angle/src/libEGL/Display.h b/gfx/angle/src/libEGL/Display.h index 41d5b92ea377..23b57b74c66f 100644 --- a/gfx/angle/src/libEGL/Display.h +++ b/gfx/angle/src/libEGL/Display.h @@ -26,6 +26,19 @@ #include "libEGL/ShaderCache.h" #include "libEGL/Surface.h" +const int versionWindowsVista = MAKEWORD(0x00, 0x06); +const int versionWindows7 = MAKEWORD(0x01, 0x06); + +// Return the version of the operating system in a format suitable for ordering +// comparison. +inline int getComparableOSVersion() +{ + DWORD version = GetVersion(); + int majorVersion = LOBYTE(LOWORD(version)); + int minorVersion = HIBYTE(LOWORD(version)); + return MAKEWORD(minorVersion, majorVersion); +} + namespace egl { class Display @@ -131,6 +144,7 @@ class Display EGLint mMaxSwapInterval; EGLint mMinSwapInterval; bool mSoftwareDevice; + bool mSupportsNonPower2Textures; typedef std::set SurfaceSet; SurfaceSet mSurfaceSet; diff --git a/gfx/angle/src/libEGL/ShaderCache.h b/gfx/angle/src/libEGL/ShaderCache.h index ee1c3bd32a82..cfe523ba09fd 100644 --- a/gfx/angle/src/libEGL/ShaderCache.h +++ b/gfx/angle/src/libEGL/ShaderCache.h @@ -11,7 +11,12 @@ #define LIBEGL_SHADER_CACHE_H_ #include + +#ifdef _MSC_VER #include +#else +#include +#endif namespace egl { @@ -37,7 +42,7 @@ class ShaderCache ShaderObject *create(const DWORD *function, size_t length) { std::string key(reinterpret_cast(function), length); - Map::iterator it = mMap.find(key); + typename Map::iterator it = mMap.find(key); if (it != mMap.end()) { it->second->AddRef(); @@ -66,7 +71,7 @@ class ShaderCache void clear() { - for (Map::iterator it = mMap.begin(); it != mMap.end(); ++it) + for (typename Map::iterator it = mMap.begin(); it != mMap.end(); ++it) { it->second->Release(); } @@ -89,7 +94,15 @@ class ShaderCache return mDevice->CreatePixelShader(function, shader); } - typedef stdext::hash_map Map; +#ifndef HASH_MAP +# ifdef _MSC_VER +# define HASH_MAP stdext::hash_map +# else +# define HASH_MAP std::unordered_map +# endif +#endif + + typedef HASH_MAP Map; Map mMap; IDirect3DDevice9 *mDevice; diff --git a/gfx/angle/src/libEGL/Surface.cpp b/gfx/angle/src/libEGL/Surface.cpp index 899b7791e518..732c404b10bf 100644 --- a/gfx/angle/src/libEGL/Surface.cpp +++ b/gfx/angle/src/libEGL/Surface.cpp @@ -23,22 +23,6 @@ namespace egl { -namespace -{ -const int versionWindowsVista = MAKEWORD(0x00, 0x06); -const int versionWindows7 = MAKEWORD(0x01, 0x06); - -// Return the version of the operating system in a format suitable for ordering -// comparison. -int getComparableOSVersion() -{ - DWORD version = GetVersion(); - int majorVersion = LOBYTE(LOWORD(version)); - int minorVersion = HIBYTE(LOWORD(version)); - return MAKEWORD(minorVersion, majorVersion); -} -} - Surface::Surface(Display *display, const Config *config, HWND window, EGLint postSubBufferSupported) : mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported) { @@ -188,28 +172,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) // before reallocating them to free up as much video memory as possible. device->EvictManagedResources(); - D3DPRESENT_PARAMETERS presentParameters = {0}; HRESULT result; - presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat; - // We set BackBufferCount = 1 even when we use D3DSWAPEFFECT_FLIPEX. - // We do this because DirectX docs are a bit vague whether to set this to 1 - // or 2. The runtime seems to accept 1, so we speculate that either it is - // forcing it to 2 without telling us, or better, doing something smart - // behind the scenes knowing that we don't need more. - presentParameters.BackBufferCount = 1; - presentParameters.BackBufferFormat = mConfig->mRenderTargetFormat; - presentParameters.EnableAutoDepthStencil = FALSE; - presentParameters.Flags = 0; - presentParameters.hDeviceWindow = getWindowHandle(); - presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented - presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented - presentParameters.PresentationInterval = mPresentInterval; - presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; - presentParameters.Windowed = TRUE; - presentParameters.BackBufferWidth = backbufferWidth; - presentParameters.BackBufferHeight = backbufferHeight; - // Release specific resources to free up memory for the new render target, while the // old render target still exists for the purpose of preserving its contents. if (mSwapChain) @@ -243,8 +207,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) pShareHandle = &mShareHandle; } - result = device->CreateTexture(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, 1, D3DUSAGE_RENDERTARGET, - presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle); + result = device->CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET, + mConfig->mRenderTargetFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle); if (FAILED(result)) { ERR("Could not create offscreen texture: %08lX", result); @@ -274,14 +238,14 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) mWidth, mHeight }; - if (rect.right > static_cast(presentParameters.BackBufferWidth)) + if (rect.right > static_cast(backbufferWidth)) { - rect.right = presentParameters.BackBufferWidth; + rect.right = backbufferWidth; } - if (rect.bottom > static_cast(presentParameters.BackBufferHeight)) + if (rect.bottom > static_cast(backbufferHeight)) { - rect.bottom = presentParameters.BackBufferHeight; + rect.bottom = backbufferHeight; } mDisplay->endScene(); @@ -294,6 +258,35 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) if (mWindow) { + D3DPRESENT_PARAMETERS presentParameters = {0}; + presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat; + presentParameters.BackBufferCount = 1; + presentParameters.BackBufferFormat = mConfig->mRenderTargetFormat; + presentParameters.EnableAutoDepthStencil = FALSE; + presentParameters.Flags = 0; + presentParameters.hDeviceWindow = getWindowHandle(); + presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented + presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented + presentParameters.PresentationInterval = mPresentInterval; + presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + presentParameters.Windowed = TRUE; + presentParameters.BackBufferWidth = backbufferWidth; + presentParameters.BackBufferHeight = backbufferHeight; + + // http://crbug.com/140239 + // http://crbug.com/143434 + // + // Some AMD/Intel switchable systems / drivers appear to round swap chain surfaces to a multiple of 64 pixels in width + // when using the integrated Intel. This rounds the width up rather than down. + // + // Some non-switchable AMD GPUs / drivers do not respect the source rectangle to Present. Therefore, when the vendor ID + // is not Intel, the back buffer width must be exactly the same width as the window or horizontal scaling will occur. + D3DADAPTER_IDENTIFIER9* adapterIdentifier = mDisplay->getAdapterIdentifier(); + if (adapterIdentifier->VendorId == VENDOR_ID_INTEL) + { + presentParameters.BackBufferWidth = (presentParameters.BackBufferWidth + 63) / 64 * 64; + } + result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain); if (FAILED(result)) @@ -320,9 +313,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN) { - result = device->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, - presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType, - presentParameters.MultiSampleQuality, FALSE, &mDepthStencil, NULL); + result = device->CreateDepthStencilSurface(backbufferWidth, backbufferHeight, mConfig->mDepthStencilFormat, D3DMULTISAMPLE_NONE, + 0, FALSE, &mDepthStencil, NULL); if (FAILED(result)) { @@ -343,8 +335,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) } } - mWidth = presentParameters.BackBufferWidth; - mHeight = presentParameters.BackBufferHeight; + mWidth = backbufferWidth; + mHeight = backbufferHeight; mPresentIntervalDirty = false; return true; diff --git a/gfx/angle/src/libEGL/libEGL.cpp b/gfx/angle/src/libEGL/libEGL.cpp index 5089d2c7500a..25df1c8c245a 100644 --- a/gfx/angle/src/libEGL/libEGL.cpp +++ b/gfx/angle/src/libEGL/libEGL.cpp @@ -182,7 +182,7 @@ const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name) case EGL_VENDOR: return success("Google Inc."); case EGL_VERSION: - return success("1.4 (ANGLE "VERSION_STRING")"); + return success("1.4 (ANGLE " VERSION_STRING ")"); } return error(EGL_BAD_PARAMETER, (const char*)NULL); diff --git a/gfx/angle/src/libGLESv2/Context.cpp b/gfx/angle/src/libGLESv2/Context.cpp index d70116dbe5fd..c854478184d2 100644 --- a/gfx/angle/src/libGLESv2/Context.cpp +++ b/gfx/angle/src/libGLESv2/Context.cpp @@ -20,11 +20,11 @@ #include "libGLESv2/ResourceManager.h" #include "libGLESv2/Buffer.h" #include "libGLESv2/Fence.h" -#include "libGLESv2/FrameBuffer.h" +#include "libGLESv2/Framebuffer.h" #include "libGLESv2/Program.h" #include "libGLESv2/ProgramBinary.h" #include "libGLESv2/Query.h" -#include "libGLESv2/RenderBuffer.h" +#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/Shader.h" #include "libGLESv2/Texture.h" #include "libGLESv2/VertexDataManager.h" @@ -369,6 +369,10 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) { depthStencil->Release(); } + + // Reset pixel shader to null to work around a bug that only happens with Intel GPUs. + // http://crbug.com/110343 + mDevice->SetPixelShader(NULL); markAllStateDirty(); } diff --git a/gfx/angle/src/libGLESv2/Context.h b/gfx/angle/src/libGLESv2/Context.h index ba4b4718b590..6fa24caacd9d 100644 --- a/gfx/angle/src/libGLESv2/Context.h +++ b/gfx/angle/src/libGLESv2/Context.h @@ -17,8 +17,13 @@ #include #include +#include #include +#ifdef _MSC_VER #include +#else +#include +#endif #include "common/angleutils.h" #include "common/RefCountObject.h" @@ -548,15 +553,23 @@ class Context BindingPointer mTexture2DZero; BindingPointer mTextureCubeMapZero; - typedef stdext::hash_map FramebufferMap; +#ifndef HASH_MAP +# ifdef _MSC_VER +# define HASH_MAP stdext::hash_map +# else +# define HASH_MAP std::unordered_map +# endif +#endif + + typedef HASH_MAP FramebufferMap; FramebufferMap mFramebufferMap; HandleAllocator mFramebufferHandleAllocator; - typedef stdext::hash_map FenceMap; + typedef HASH_MAP FenceMap; FenceMap mFenceMap; HandleAllocator mFenceHandleAllocator; - typedef stdext::hash_map QueryMap; + typedef HASH_MAP QueryMap; QueryMap mQueryMap; HandleAllocator mQueryHandleAllocator; diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in index 7a8c5e5ef147..ba4716d270fe 100644 --- a/gfx/angle/src/libGLESv2/Makefile.in +++ b/gfx/angle/src/libGLESv2/Makefile.in @@ -153,6 +153,7 @@ CPPSRCS += \ ResourceManager.cpp \ Shader.cpp \ Texture.cpp \ + TextureSSE2.cpp \ utilities.cpp \ HandleAllocator.cpp \ IndexDataManager.cpp \ diff --git a/gfx/angle/src/libGLESv2/ProgramBinary.cpp b/gfx/angle/src/libGLESv2/ProgramBinary.cpp index df2f0fe7a071..61a272f8294c 100644 --- a/gfx/angle/src/libGLESv2/ProgramBinary.cpp +++ b/gfx/angle/src/libGLESv2/ProgramBinary.cpp @@ -2109,9 +2109,11 @@ bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const D3DXHAN { for (unsigned int arrayIndex = 0; arrayIndex < constantDescription.Elements; arrayIndex++) { + D3DXHANDLE elementHandle = mConstantTablePS->GetConstantElement(constantHandle, arrayIndex); + for (unsigned int field = 0; field < constantDescription.StructMembers; field++) { - D3DXHANDLE fieldHandle = mConstantTablePS->GetConstant(constantHandle, field); + D3DXHANDLE fieldHandle = mConstantTablePS->GetConstant(elementHandle, field); D3DXCONSTANT_DESC fieldDescription; UINT descriptionCount = 1; diff --git a/gfx/angle/src/libGLESv2/ProgramBinary.h b/gfx/angle/src/libGLESv2/ProgramBinary.h index 7746e2c3b25b..5443ccae8f4b 100644 --- a/gfx/angle/src/libGLESv2/ProgramBinary.h +++ b/gfx/angle/src/libGLESv2/ProgramBinary.h @@ -11,8 +11,8 @@ #define LIBGLESV2_PROGRAM_BINARY_H_ #define GL_APICALL -#include -#include +#include +#include #include #include diff --git a/gfx/angle/src/libGLESv2/ResourceManager.cpp b/gfx/angle/src/libGLESv2/ResourceManager.cpp index ae26352e058e..4b97e9c113be 100644 --- a/gfx/angle/src/libGLESv2/ResourceManager.cpp +++ b/gfx/angle/src/libGLESv2/ResourceManager.cpp @@ -11,7 +11,7 @@ #include "libGLESv2/Buffer.h" #include "libGLESv2/Program.h" -#include "libGLESv2/RenderBuffer.h" +#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/Shader.h" #include "libGLESv2/Texture.h" diff --git a/gfx/angle/src/libGLESv2/ResourceManager.h b/gfx/angle/src/libGLESv2/ResourceManager.h index 5185fc9dbe93..ae4f1b04a52b 100644 --- a/gfx/angle/src/libGLESv2/ResourceManager.h +++ b/gfx/angle/src/libGLESv2/ResourceManager.h @@ -13,7 +13,11 @@ #define GL_APICALL #include +#ifdef _MSC_VER #include +#else +#include +#endif #include "common/angleutils.h" #include "libGLESv2/HandleAllocator.h" @@ -79,22 +83,30 @@ class ResourceManager std::size_t mRefCount; - typedef stdext::hash_map BufferMap; +#ifndef HASH_MAP +# ifdef _MSC_VER +# define HASH_MAP stdext::hash_map +# else +# define HASH_MAP std::unordered_map +# endif +#endif + + typedef HASH_MAP BufferMap; BufferMap mBufferMap; HandleAllocator mBufferHandleAllocator; - typedef stdext::hash_map ShaderMap; + typedef HASH_MAP ShaderMap; ShaderMap mShaderMap; - typedef stdext::hash_map ProgramMap; + typedef HASH_MAP ProgramMap; ProgramMap mProgramMap; HandleAllocator mProgramShaderHandleAllocator; - typedef stdext::hash_map TextureMap; + typedef HASH_MAP TextureMap; TextureMap mTextureMap; HandleAllocator mTextureHandleAllocator; - typedef stdext::hash_map RenderbufferMap; + typedef HASH_MAP RenderbufferMap; RenderbufferMap mRenderbufferMap; HandleAllocator mRenderbufferHandleAllocator; }; diff --git a/gfx/angle/src/libGLESv2/Shader.cpp b/gfx/angle/src/libGLESv2/Shader.cpp index 57fd3d5794ce..1087f11b4af9 100644 --- a/gfx/angle/src/libGLESv2/Shader.cpp +++ b/gfx/angle/src/libGLESv2/Shader.cpp @@ -12,7 +12,7 @@ #include -#include "GLSLANG/Shaderlang.h" +#include "GLSLANG/ShaderLang.h" #include "libGLESv2/main.h" #include "libGLESv2/utilities.h" diff --git a/gfx/angle/src/libGLESv2/Shader.h b/gfx/angle/src/libGLESv2/Shader.h index 43083ec42f08..4e1ac4c77696 100644 --- a/gfx/angle/src/libGLESv2/Shader.h +++ b/gfx/angle/src/libGLESv2/Shader.h @@ -15,6 +15,7 @@ #define GL_APICALL #include #include +#include #include #include diff --git a/gfx/angle/src/libGLESv2/Texture.cpp b/gfx/angle/src/libGLESv2/Texture.cpp index 9cb9c989a17a..2d644f62f7dc 100644 --- a/gfx/angle/src/libGLESv2/Texture.cpp +++ b/gfx/angle/src/libGLESv2/Texture.cpp @@ -13,7 +13,6 @@ #include #include -#include #include "common/debug.h" @@ -474,46 +473,6 @@ void Image::loadAlphaData(GLsizei width, GLsizei height, } } -void Image::loadAlphaDataSSE2(GLsizei width, GLsizei height, - int inputPitch, const void *input, size_t outputPitch, void *output) const -{ - const unsigned char *source = NULL; - unsigned int *dest = NULL; - __m128i zeroWide = _mm_setzero_si128(); - - for (int y = 0; y < height; y++) - { - source = static_cast(input) + y * inputPitch; - dest = reinterpret_cast(static_cast(output) + y * outputPitch); - - int x; - // Make output writes aligned - for (x = 0; ((reinterpret_cast(&dest[x]) & 0xF) != 0 && x < width); x++) - { - dest[x] = static_cast(source[x]) << 24; - } - - for (; x + 7 < width; x += 8) - { - __m128i sourceData = _mm_loadl_epi64(reinterpret_cast(&source[x])); - // Interleave each byte to 16bit, make the lower byte to zero - sourceData = _mm_unpacklo_epi8(zeroWide, sourceData); - // Interleave each 16bit to 32bit, make the lower 16bit to zero - __m128i lo = _mm_unpacklo_epi16(zeroWide, sourceData); - __m128i hi = _mm_unpackhi_epi16(zeroWide, sourceData); - - _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), lo); - _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x + 4]), hi); - } - - // Handle the remainder - for (; x < width; x++) - { - dest[x] = static_cast(source[x]) << 24; - } - } -} - void Image::loadAlphaFloatData(GLsizei width, GLsizei height, int inputPitch, const void *input, size_t outputPitch, void *output) const { @@ -771,48 +730,6 @@ void Image::loadRGBHalfFloatData(GLsizei width, GLsizei height, } } -void Image::loadRGBAUByteDataSSE2(GLsizei width, GLsizei height, - int inputPitch, const void *input, size_t outputPitch, void *output) const -{ - const unsigned int *source = NULL; - unsigned int *dest = NULL; - __m128i brMask = _mm_set1_epi32(0x00ff00ff); - - for (int y = 0; y < height; y++) - { - source = reinterpret_cast(static_cast(input) + y * inputPitch); - dest = reinterpret_cast(static_cast(output) + y * outputPitch); - int x = 0; - - // Make output writes aligned - for (x = 0; ((reinterpret_cast(&dest[x]) & 15) != 0) && x < width; x++) - { - unsigned int rgba = source[x]; - dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); - } - - for (; x + 3 < width; x += 4) - { - __m128i sourceData = _mm_loadu_si128(reinterpret_cast(&source[x])); - // Mask out g and a, which don't change - __m128i gaComponents = _mm_andnot_si128(brMask, sourceData); - // Mask out b and r - __m128i brComponents = _mm_and_si128(sourceData, brMask); - // Swap b and r - __m128i brSwapped = _mm_shufflehi_epi16(_mm_shufflelo_epi16(brComponents, _MM_SHUFFLE(2, 3, 0, 1)), _MM_SHUFFLE(2, 3, 0, 1)); - __m128i result = _mm_or_si128(gaComponents, brSwapped); - _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), result); - } - - // Perform leftover writes - for (; x < width; x++) - { - unsigned int rgba = source[x]; - dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); - } - } -} - void Image::loadRGBAUByteData(GLsizei width, GLsizei height, int inputPitch, const void *input, size_t outputPitch, void *output) const { diff --git a/gfx/angle/src/libGLESv2/TextureSSE2.cpp b/gfx/angle/src/libGLESv2/TextureSSE2.cpp new file mode 100644 index 000000000000..48ea6643bca2 --- /dev/null +++ b/gfx/angle/src/libGLESv2/TextureSSE2.cpp @@ -0,0 +1,100 @@ +// +// Copyright (c) 2002-2010 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. +// + +// TextureSSE2.cpp: Implements SSE2-based functions of gl::Image class. It's +// in a separated file for GCC, which can enable SSE usage only per-file, +// not for code blocks that use SSE2 explicitly. + +#include "libGLESv2/Texture.h" + +#include + +namespace gl +{ + +void Image::loadRGBAUByteDataSSE2(GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const unsigned int *source = NULL; + unsigned int *dest = NULL; + __m128i brMask = _mm_set1_epi32(0x00ff00ff); + + for (int y = 0; y < height; y++) + { + source = reinterpret_cast(static_cast(input) + y * inputPitch); + dest = reinterpret_cast(static_cast(output) + y * outputPitch); + int x = 0; + + // Make output writes aligned + for (x = 0; ((reinterpret_cast(&dest[x]) & 15) != 0) && x < width; x++) + { + unsigned int rgba = source[x]; + dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); + } + + for (; x + 3 < width; x += 4) + { + __m128i sourceData = _mm_loadu_si128(reinterpret_cast(&source[x])); + // Mask out g and a, which don't change + __m128i gaComponents = _mm_andnot_si128(brMask, sourceData); + // Mask out b and r + __m128i brComponents = _mm_and_si128(sourceData, brMask); + // Swap b and r + __m128i brSwapped = _mm_shufflehi_epi16(_mm_shufflelo_epi16(brComponents, _MM_SHUFFLE(2, 3, 0, 1)), _MM_SHUFFLE(2, 3, 0, 1)); + __m128i result = _mm_or_si128(gaComponents, brSwapped); + _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), result); + } + + // Perform leftover writes + for (; x < width; x++) + { + unsigned int rgba = source[x]; + dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); + } + } +} + +void Image::loadAlphaDataSSE2(GLsizei width, GLsizei height, + int inputPitch, const void *input, size_t outputPitch, void *output) const +{ + const unsigned char *source = NULL; + unsigned int *dest = NULL; + __m128i zeroWide = _mm_setzero_si128(); + + for (int y = 0; y < height; y++) + { + source = static_cast(input) + y * inputPitch; + dest = reinterpret_cast(static_cast(output) + y * outputPitch); + + int x; + // Make output writes aligned + for (x = 0; ((reinterpret_cast(&dest[x]) & 0xF) != 0 && x < width); x++) + { + dest[x] = static_cast(source[x]) << 24; + } + + for (; x + 7 < width; x += 8) + { + __m128i sourceData = _mm_loadl_epi64(reinterpret_cast(&source[x])); + // Interleave each byte to 16bit, make the lower byte to zero + sourceData = _mm_unpacklo_epi8(zeroWide, sourceData); + // Interleave each 16bit to 32bit, make the lower 16bit to zero + __m128i lo = _mm_unpacklo_epi16(zeroWide, sourceData); + __m128i hi = _mm_unpackhi_epi16(zeroWide, sourceData); + + _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), lo); + _mm_store_si128(reinterpret_cast<__m128i*>(&dest[x + 4]), hi); + } + + // Handle the remainder + for (; x < width; x++) + { + dest[x] = static_cast(source[x]) << 24; + } + } +} + +} diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp index a95275fccf7d..32c40182d3db 100644 --- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp +++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp @@ -390,11 +390,11 @@ struct VertexTypeFlags { }; -template +template struct VertexTypeFlagsHelper { - enum { capflag = capflag }; - enum { declflag = declflag }; + enum { capflag = _capflag }; + enum { declflag = _declflag }; }; template <> struct VertexTypeFlags : VertexTypeFlagsHelper<0, D3DDECLTYPE_FLOAT1> { }; diff --git a/gfx/angle/src/libGLESv2/libGLESv2.cpp b/gfx/angle/src/libGLESv2/libGLESv2.cpp index 2debe567b559..90df3c90080c 100644 --- a/gfx/angle/src/libGLESv2/libGLESv2.cpp +++ b/gfx/angle/src/libGLESv2/libGLESv2.cpp @@ -3790,9 +3790,9 @@ const GLubyte* __stdcall glGetString(GLenum name) case GL_RENDERER: return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); case GL_VERSION: - return (GLubyte*)"OpenGL ES 2.0 (ANGLE "VERSION_STRING")"; + return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; case GL_SHADING_LANGUAGE_VERSION: - return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE "VERSION_STRING")"; + return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; case GL_EXTENSIONS: return (GLubyte*)((context != NULL) ? context->getExtensionString() : ""); default: diff --git a/gfx/angle/src/libGLESv2/libGLESv2.vcproj b/gfx/angle/src/libGLESv2/libGLESv2.vcproj index 7cf038d848ff..3528e570ed1f 100644 --- a/gfx/angle/src/libGLESv2/libGLESv2.vcproj +++ b/gfx/angle/src/libGLESv2/libGLESv2.vcproj @@ -428,6 +428,10 @@ RelativePath=".\Texture.cpp" > + +