summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-08-05 12:59:44 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-08-05 16:43:22 +0200
commita6a12d8c0fc918972c15268f749ecc7c90b95d6c (patch)
treecb6d986d30ef97e932ab51768854d5d9b46729d3 /src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
parent14f9c09542bd6cc19430473da9ce4c68f239ec7d (diff)
ANGLE: upgrade to 2.1~07d49ef5350a
This version of ANGLE provides partial ES3 support, numerous bug fixes, and several potentially useful vendor extensions. All patches have been rebased. The following changes are noted: 0000-General-fixes-for-ANGLE-2.1.patch contains compile fixes for the new ANGLE 0004-Make-it-possible-to-link-ANGLE-statically-for-single.patch has incorporated patch 0015. 0007-Make-DX9-DX11-mutually-exclusive.patch has been removed as it was fixed upstream. 0007-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch has been moved up to fill the patch number gap. 0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch now contains patch 0014 and 0017. 0013-ANGLE-Allow-for-universal-program-binaries.patch has been removed as it is no longer relevant. 0014-ANGLE-D3D11-Fix-internal-index-buffer-for-level-9-ha.patch has been merged with patch 0010. 0015-ANGLE-Don-t-export-DLLMain-functions-for-static-buil.patch has been merged with patch 0004. 0016-ANGLE-WinRT-Call-Trim-when-application-suspends.patch has been removed and will be replaced by a follow-up patch using a different technique. 0017-ANGLE-D3D11-Don-t-use-mipmaps-in-level-9-textures.patch has been merged with patch 0010. 0018-ANGLE-WinRT-Create-swap-chain-using-physical-resolut.patch has been removed and will be replaced by a follow-up patch extending the EGL_ANGLE_window_fixed_size extension. 0019-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch is now patch 0007. [ChangeLog][Third-party libraries] ANGLE has been upgraded to version 2.1, bringing partial support for OpenGL ES3 over Direct3D 11, numerous bug fixes, and several new vendor extensions. Change-Id: I6d95ce1480462d67228d83c1e5c74a1706b5b21c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp297
1 files changed, 85 insertions, 212 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
index 5278113811..590004ac9b 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/Renderer.cpp
@@ -1,6 +1,6 @@
#include "precompiled.h"
//
-// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2012-2014 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.
//
@@ -11,212 +11,77 @@
#include "libGLESv2/main.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/renderer/Renderer.h"
-#if defined(ANGLE_ENABLE_D3D9)
-# include "libGLESv2/renderer/d3d9/Renderer9.h"
-#endif
-#if defined(ANGLE_ENABLE_D3D11)
-# include "libGLESv2/renderer/d3d11/Renderer11.h"
-#endif
-#include "libGLESv2/utilities.h"
+#include "common/utilities.h"
#include "third_party/trace_event/trace_event.h"
+#include "libGLESv2/Shader.h"
-#ifndef D3DERR_OUTOFVIDEOMEMORY
-#define D3DERR_OUTOFVIDEOMEMORY MAKE_HRESULT(1, 0x876, 380)
-#endif
-
-#if defined(__MINGW32__) || defined(ANGLE_OS_WINPHONE)
-
-#ifndef D3DCOMPILER_DLL
-
-// Add define + typedefs for older MinGW-w64 headers (pre 5783)
-
-#define D3DCOMPILER_DLL L"d3dcompiler_43.dll"
-
-HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename,
- const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
- const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages);
-typedef HRESULT (WINAPI *pD3DCompile)(const void *data, SIZE_T data_size, const char *filename,
- const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
- const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages);
-
-#endif // D3DCOMPILER_DLL
+#if defined (ANGLE_ENABLE_D3D9)
+#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
+#endif // ANGLE_ENABLE_D3D9
-#endif // __MINGW32__ || ANGLE_OS_WINPHONE
+#if defined (ANGLE_ENABLE_D3D11)
+#include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
+#endif // ANGLE_ENABLE_D3D11
-#ifndef QT_D3DCOMPILER_DLL
-#define QT_D3DCOMPILER_DLL D3DCOMPILER_DLL
+#if !defined(ANGLE_DEFAULT_D3D11)
+// Enables use of the Direct3D 11 API for a default display, when available
+#define ANGLE_DEFAULT_D3D11 0
#endif
namespace rx
{
-Renderer::Renderer(egl::Display *display) : mDisplay(display)
+Renderer::Renderer(egl::Display *display)
+ : mDisplay(display),
+ mCapsInitialized(false),
+ mCurrentClientVersion(2)
{
- mD3dCompilerModule = NULL;
- mD3DCompileFunc = NULL;
}
Renderer::~Renderer()
{
- if (mD3dCompilerModule)
- {
- FreeLibrary(mD3dCompilerModule);
- mD3dCompilerModule = NULL;
- }
+ gl::Shader::releaseCompiler();
}
-bool Renderer::initializeCompiler()
+const gl::Caps &Renderer::getRendererCaps() const
{
- TRACE_EVENT0("gpu", "initializeCompiler");
-#if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES)
- // Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
- static TCHAR* d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES;
-
- for (size_t i = 0; i < ArraySize(d3dCompilerNames); ++i)
+ if (!mCapsInitialized)
{
- if (GetModuleHandleEx(0, d3dCompilerNames[i], &mD3dCompilerModule))
- {
- break;
- }
+ generateCaps(&mCaps, &mTextureCaps, &mExtensions);
+ mCapsInitialized = true;
}
-#endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
-
- // Load the compiler DLL specified by the environment, or default to QT_D3DCOMPILER_DLL
-#if !defined(ANGLE_OS_WINRT)
- const wchar_t *defaultCompiler = _wgetenv(L"QT_D3DCOMPILER_DLL");
- if (!defaultCompiler)
- defaultCompiler = QT_D3DCOMPILER_DLL;
-#else // !ANGLE_OS_WINRT
-# ifdef _DEBUG
- const wchar_t *defaultCompiler = L"d3dcompiler_qtd.dll";
-# else
- const wchar_t *defaultCompiler = L"d3dcompiler_qt.dll";
-# endif
-#endif // ANGLE_OS_WINRT
-
- const wchar_t *compilerDlls[] = {
- defaultCompiler,
- L"d3dcompiler_47.dll",
- L"d3dcompiler_46.dll",
- L"d3dcompiler_45.dll",
- L"d3dcompiler_44.dll",
- L"d3dcompiler_43.dll",
- 0
- };
- // Load the first available known compiler DLL
- for (int i = 0; compilerDlls[i]; ++i)
- {
- // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with.
- mD3dCompilerModule = LoadLibrary(compilerDlls[i]);
- if (mD3dCompilerModule)
- break;
- }
-
- if (!mD3dCompilerModule)
- {
- ERR("No D3D compiler module found - aborting!\n");
- return false;
- }
-
- mD3DCompileFunc = reinterpret_cast<pCompileFunc>(GetProcAddress(mD3dCompilerModule, "D3DCompile"));
- ASSERT(mD3DCompileFunc);
-
- return mD3DCompileFunc != NULL;
+ return mCaps;
}
-// Compiles HLSL code into executable binaries
-ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, UINT optimizationFlags, bool alternateFlags)
+const gl::TextureCapsMap &Renderer::getRendererTextureCaps() const
{
- if (!hlsl)
+ if (!mCapsInitialized)
{
- return NULL;
+ generateCaps(&mCaps, &mTextureCaps, &mExtensions);
+ mCapsInitialized = true;
}
- HRESULT result = S_OK;
- UINT flags = 0;
- std::string sourceText;
- if (gl::perfActive())
- {
- flags |= D3DCOMPILE_DEBUG;
-
-#ifdef NDEBUG
- flags |= optimizationFlags;
-#else
- flags |= D3DCOMPILE_SKIP_OPTIMIZATION;
-#endif
+ return mTextureCaps;
+}
- std::string sourcePath = getTempPath();
- sourceText = std::string("#line 2 \"") + sourcePath + std::string("\"\n\n") + std::string(hlsl);
- writeFile(sourcePath.c_str(), sourceText.c_str(), sourceText.size());
- }
- else
+const gl::Extensions &Renderer::getRendererExtensions() const
+{
+ if (!mCapsInitialized)
{
- flags |= optimizationFlags;
- sourceText = hlsl;
+ generateCaps(&mCaps, &mTextureCaps, &mExtensions);
+ mCapsInitialized = true;
}
- // Sometimes D3DCompile will fail with the default compilation flags for complicated shaders when it would otherwise pass with alternative options.
- // Try the default flags first and if compilation fails, try some alternatives.
- const static UINT extraFlags[] =
- {
- 0,
- D3DCOMPILE_AVOID_FLOW_CONTROL,
- D3DCOMPILE_PREFER_FLOW_CONTROL
- };
-
- const static char * const extraFlagNames[] =
- {
- "default",
- "avoid flow control",
- "prefer flow control"
- };
-
- int attempts = alternateFlags ? ArraySize(extraFlags) : 1;
- pD3DCompile compileFunc = reinterpret_cast<pD3DCompile>(mD3DCompileFunc);
- for (int i = 0; i < attempts; ++i)
- {
- ID3DBlob *errorMessage = NULL;
- ID3DBlob *binary = NULL;
-
- result = compileFunc(hlsl, strlen(hlsl), gl::g_fakepath, NULL, NULL,
- "main", profile, flags | extraFlags[i], 0, &binary, &errorMessage);
- if (errorMessage)
- {
- const char *message = (const char*)errorMessage->GetBufferPointer();
-
- infoLog.appendSanitized(message);
- TRACE("\n%s", hlsl);
- TRACE("\n%s", message);
-
- errorMessage->Release();
- errorMessage = NULL;
- }
-
- if (SUCCEEDED(result))
- {
- return (ShaderBlob*)binary;
- }
- else
- {
- if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
- {
- return gl::error(GL_OUT_OF_MEMORY, (ShaderBlob*) NULL);
- }
+ return mExtensions;
+}
- infoLog.append("Warning: D3D shader compilation failed with ");
- infoLog.append(extraFlagNames[i]);
- infoLog.append(" flags.");
- if (i + 1 < attempts)
- {
- infoLog.append(" Retrying with ");
- infoLog.append(extraFlagNames[i + 1]);
- infoLog.append(".\n");
- }
- }
- }
+typedef Renderer *(*CreateRendererFunction)(egl::Display*, EGLNativeDisplayType, EGLint);
- return NULL;
+template <typename RendererType>
+Renderer *CreateRenderer(egl::Display *display, EGLNativeDisplayType nativeDisplay, EGLint requestedDisplayType)
+{
+ return new RendererType(display, nativeDisplay, requestedDisplayType);
}
}
@@ -224,56 +89,64 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co
extern "C"
{
-rx::Renderer *glCreateRenderer(egl::Display *display, EGLNativeDisplayType displayId)
+rx::Renderer *glCreateRenderer(egl::Display *display, EGLNativeDisplayType nativeDisplay, EGLint requestedDisplayType)
{
- rx::Renderer *renderer = NULL;
- EGLint status = EGL_BAD_ALLOC;
-
-#if defined(ANGLE_OS_WINRT)
- if (displayId == EGL_DEFAULT_DISPLAY)
- displayId = EGL_D3D11_ONLY_DISPLAY_ANGLE;
-#endif
-
-#if defined(ANGLE_ENABLE_D3D11)
- if (displayId == EGL_DEFAULT_DISPLAY ||
- displayId == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
- displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
- {
- renderer = new rx::Renderer11(display);
+ std::vector<rx::CreateRendererFunction> rendererCreationFunctions;
- if (renderer)
+# if defined(ANGLE_ENABLE_D3D11)
+ if (nativeDisplay == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
+ nativeDisplay == EGL_D3D11_ONLY_DISPLAY_ANGLE ||
+ requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE ||
+ requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE)
{
- status = renderer->initialize();
+ rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer11>);
}
+# endif
- if (status == EGL_SUCCESS)
+# if defined(ANGLE_ENABLE_D3D9)
+ if (nativeDisplay == EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ||
+ requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
{
- return renderer;
+ rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer9>);
}
- else if (displayId == EGL_D3D11_ONLY_DISPLAY_ANGLE)
- {
- return NULL;
- }
-
- // Failed to create a D3D11 renderer, try creating a D3D9 renderer
- delete renderer;
- }
-#endif // ANGLE_ENABLE_D3D11
+# endif
-#if defined(ANGLE_ENABLE_D3D9)
- bool softwareDevice = (displayId == EGL_SOFTWARE_DISPLAY_ANGLE);
- renderer = new rx::Renderer9(display, displayId, softwareDevice);
-
- if (renderer)
+ if (nativeDisplay != EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE &&
+ nativeDisplay != EGL_D3D11_ONLY_DISPLAY_ANGLE &&
+ requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE)
{
- status = renderer->initialize();
+ // The default display is requested, try the D3D9 and D3D11 renderers, order them using
+ // the definition of ANGLE_DEFAULT_D3D11
+# if ANGLE_DEFAULT_D3D11
+# if defined(ANGLE_ENABLE_D3D11)
+ rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer11>);
+# endif
+# if defined(ANGLE_ENABLE_D3D9)
+ rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer9>);
+# endif
+# else
+# if defined(ANGLE_ENABLE_D3D9)
+ rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer9>);
+# endif
+# if defined(ANGLE_ENABLE_D3D11)
+ rendererCreationFunctions.push_back(rx::CreateRenderer<rx::Renderer11>);
+# endif
+# endif
}
- if (status == EGL_SUCCESS)
+ for (size_t i = 0; i < rendererCreationFunctions.size(); i++)
{
- return renderer;
+ rx::Renderer *renderer = rendererCreationFunctions[i](display, nativeDisplay, requestedDisplayType);
+ if (renderer->initialize() == EGL_SUCCESS)
+ {
+ return renderer;
+ }
+ else
+ {
+ // Failed to create the renderer, try the next
+ SafeDelete(renderer);
+ }
}
-#endif // ANGLE_ENABLE_D3D9
return NULL;
}