summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-05-18 15:16:30 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-05-26 15:11:40 +0200
commit752497910b67b2a1a80560840ca44548d8893434 (patch)
tree541501c9abfd97c3d2fa450d2e6abb60582c4420 /src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
parent7db527dbdd911c79f31425d099d1fc9c63e42453 (diff)
Remove ANGLE
This marks the end of EGL and OpenGL ES support on Windows. The concepts of -opengl dynamic, -opengl desktop, QT_OPENGL=software, etc. remain unchanged, with the exception of the disapperance of everything ANGLE related. CMake builds now work identically to qmake on Windows: they default to 'dynamic' OpenGL on Windows, unless -DINPUT_opengl=desktop is specified. On Windows, Qt 6 is expected to default to the "dynamic" OpenGL model by default, just like Qt 5.15. This can be changed by switching to "desktop" OpenGL, which will link to opengl32 (publicly, so other libs and applications will do so as well) and disallows using another OpenGL DLL. The "dynamic" mode is essential still because the fallback to a software rasterizer, such as the opengl32sw.dll we ship with the Qt packages, has to to work exactly like in Qt 5, the removal of ANGLE does not change this concept in any way (except of course that the middle option of using ANGLE is now gone) When it comes to the windows plugin's OpenGL blacklist feature, it works like before and accepts the ANGLE/D3D related keywords. They will then be ignored. Similarly, requesting QT_OPENGL=angle is ignored (but will show a warning). The D3D11 and DXGI configure time tests are removed: Qt 5.14 already depends on D3D 11.1 and DXGI 1.3 headers being available unconditionally on Win32 (in QRhi's D3D11 backend). No need to test for these. [ChangeLog][Windows] ANGLE is no longer included with Qt. Dynamic OpenGL builds work like before but ANGLE is no longer an option. OpenGL proper or an alternative opengl32 implementation are the two remaining options now. Attempting to set QT_OPENGL=angle or Qt::AA_UseOpenGLES will have no effect on Windows. Fixes: QTBUG-79103 Change-Id: Ia404e0d07f3fe191b27434d863c81180112ecb3b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp')
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp354
1 files changed, 0 insertions, 354 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
deleted file mode 100644
index 5d47308d67..0000000000
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-//
-// Copyright 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.
-//
-
-#include "libANGLE/renderer/d3d/HLSLCompiler.h"
-
-#include <sstream>
-
-#include "common/utilities.h"
-#include "libANGLE/Program.h"
-#include "libANGLE/features.h"
-#include "libANGLE/histogram_macros.h"
-#include "third_party/trace_event/trace_event.h"
-
-#ifndef QT_D3DCOMPILER_DLL
-#define QT_D3DCOMPILER_DLL D3DCOMPILER_DLL
-#endif
-
-#if ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
-namespace
-{
-#ifdef CREATE_COMPILER_FLAG_INFO
- #undef CREATE_COMPILER_FLAG_INFO
-#endif
-
-#define CREATE_COMPILER_FLAG_INFO(flag) { flag, #flag }
-
-struct CompilerFlagInfo
-{
- UINT mFlag;
- const char *mName;
-};
-
-CompilerFlagInfo CompilerFlagInfos[] =
-{
- // NOTE: The data below is copied from d3dcompiler.h
- // If something changes there it should be changed here as well
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_DEBUG), // (1 << 0)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_SKIP_VALIDATION), // (1 << 1)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_SKIP_OPTIMIZATION), // (1 << 2)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PACK_MATRIX_ROW_MAJOR), // (1 << 3)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR), // (1 << 4)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PARTIAL_PRECISION), // (1 << 5)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT), // (1 << 6)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT), // (1 << 7)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_NO_PRESHADER), // (1 << 8)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_AVOID_FLOW_CONTROL), // (1 << 9)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_PREFER_FLOW_CONTROL), // (1 << 10)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_ENABLE_STRICTNESS), // (1 << 11)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY), // (1 << 12)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_IEEE_STRICTNESS), // (1 << 13)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL0), // (1 << 14)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL1), // 0
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL2), // ((1 << 14) | (1 << 15))
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_OPTIMIZATION_LEVEL3), // (1 << 15)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_RESERVED16), // (1 << 16)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_RESERVED17), // (1 << 17)
- CREATE_COMPILER_FLAG_INFO(D3DCOMPILE_WARNINGS_ARE_ERRORS) // (1 << 18)
-};
-
-#undef CREATE_COMPILER_FLAG_INFO
-
-bool IsCompilerFlagSet(UINT mask, UINT flag)
-{
- bool isFlagSet = IsMaskFlagSet(mask, flag);
-
- switch(flag)
- {
- case D3DCOMPILE_OPTIMIZATION_LEVEL0:
- return isFlagSet && !IsMaskFlagSet(mask, UINT(D3DCOMPILE_OPTIMIZATION_LEVEL3));
-
- case D3DCOMPILE_OPTIMIZATION_LEVEL1:
- return (mask & D3DCOMPILE_OPTIMIZATION_LEVEL2) == UINT(0);
-
- case D3DCOMPILE_OPTIMIZATION_LEVEL3:
- return isFlagSet && !IsMaskFlagSet(mask, UINT(D3DCOMPILE_OPTIMIZATION_LEVEL0));
-
- default:
- return isFlagSet;
- }
-}
-} // anonymous namespace
-#endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
-
-namespace rx
-{
-
-CompileConfig::CompileConfig()
- : flags(0),
- name()
-{
-}
-
-CompileConfig::CompileConfig(UINT flags, const std::string &name)
- : flags(flags),
- name(name)
-{
-}
-
-HLSLCompiler::HLSLCompiler()
- : mInitialized(false),
- mD3DCompilerModule(nullptr),
- mD3DCompileFunc(nullptr),
- mD3DDisassembleFunc(nullptr)
-{
-}
-
-HLSLCompiler::~HLSLCompiler()
-{
- release();
-}
-
-gl::Error HLSLCompiler::ensureInitialized()
-{
- if (mInitialized)
- {
- return gl::NoError();
- }
-
- TRACE_EVENT0("gpu.angle", "HLSLCompiler::initialize");
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
-#if defined(ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES)
- // Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
- static const char *d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES;
-
- for (size_t i = 0; i < ArraySize(d3dCompilerNames); ++i)
- {
- if (GetModuleHandleExA(0, d3dCompilerNames[i], &mD3DCompilerModule))
- {
- break;
- }
- }
-#endif // ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES
-
- // Load the compiler DLL specified by the environment, or default to QT_D3DCOMPILER_DLL
- const wchar_t *defaultCompiler = _wgetenv(L"QT_D3DCOMPILER_DLL");
- if (!defaultCompiler)
- defaultCompiler = QT_D3DCOMPILER_DLL;
-
- const wchar_t *compilerDlls[] = {
- defaultCompiler,
- L"d3dcompiler_47.dll",
- L"d3dcompiler_46.dll",
- L"d3dcompiler_43.dll",
- 0
- };
-
- // Load the first available known compiler DLL
- for (int i = 0; compilerDlls[i]; ++i)
- {
- mD3DCompilerModule = LoadLibrary(compilerDlls[i]);
- if (mD3DCompilerModule)
- break;
- }
-
- if (!mD3DCompilerModule)
- {
- // Load the version of the D3DCompiler DLL associated with the Direct3D version ANGLE was built with.
- mD3DCompilerModule = LoadLibrary(D3DCOMPILER_DLL);
- }
-
- if (!mD3DCompilerModule)
- {
- ERR() << "D3D compiler module not found.";
- return gl::OutOfMemory() << "D3D compiler module not found.";
- }
-
- mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3DCompilerModule, "D3DCompile"));
- ASSERT(mD3DCompileFunc);
-
- mD3DDisassembleFunc = reinterpret_cast<pD3DDisassemble>(GetProcAddress(mD3DCompilerModule, "D3DDisassemble"));
- ASSERT(mD3DDisassembleFunc);
-
-#else
- // D3D Shader compiler is linked already into this module, so the export
- // can be directly assigned.
- mD3DCompilerModule = nullptr;
- mD3DCompileFunc = reinterpret_cast<pD3DCompile>(D3DCompile);
- mD3DDisassembleFunc = reinterpret_cast<pD3DDisassemble>(D3DDisassemble);
-#endif
-
- if (mD3DCompileFunc == nullptr)
- {
- return gl::OutOfMemory() << "Error finding D3DCompile entry point.";
- }
-
- mInitialized = true;
- return gl::NoError();
-}
-
-void HLSLCompiler::release()
-{
- if (mInitialized)
- {
- FreeLibrary(mD3DCompilerModule);
- mD3DCompilerModule = nullptr;
- mD3DCompileFunc = nullptr;
- mD3DDisassembleFunc = nullptr;
- mInitialized = false;
- }
-}
-
-gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string &hlsl, const std::string &profile,
- const std::vector<CompileConfig> &configs, const D3D_SHADER_MACRO *overrideMacros,
- ID3DBlob **outCompiledBlob, std::string *outDebugInfo)
-{
- ASSERT(mInitialized);
-
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- ASSERT(mD3DCompilerModule);
-#endif
- ASSERT(mD3DCompileFunc);
-
-#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
- if (gl::DebugAnnotationsActive())
- {
- std::string sourcePath = getTempPath();
- std::ostringstream stream;
- stream << "#line 2 \"" << sourcePath << "\"\n\n" << hlsl;
- std::string sourceText = stream.str();
- writeFile(sourcePath.c_str(), sourceText.c_str(), sourceText.size());
- }
-#endif
-
- const D3D_SHADER_MACRO *macros = overrideMacros ? overrideMacros : nullptr;
-
- for (size_t i = 0; i < configs.size(); ++i)
- {
- ID3DBlob *errorMessage = nullptr;
- ID3DBlob *binary = nullptr;
- HRESULT result = S_OK;
-
- {
- TRACE_EVENT0("gpu.angle", "D3DCompile");
- SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.D3DCompileMS");
- result = mD3DCompileFunc(hlsl.c_str(), hlsl.length(), gl::g_fakepath, macros, nullptr,
- "main", profile.c_str(), configs[i].flags, 0, &binary,
- &errorMessage);
- }
-
- if (errorMessage)
- {
- std::string message = reinterpret_cast<const char*>(errorMessage->GetBufferPointer());
- SafeRelease(errorMessage);
-
- infoLog.appendSanitized(message.c_str());
-
- // This produces unbelievable amounts of spam in about:gpu.
- // WARN() << std::endl << hlsl;
-
- WARN() << std::endl << message;
-
- if ((message.find("error X3531:") != std::string::npos || // "can't unroll loops marked with loop attribute"
- message.find("error X4014:") != std::string::npos) && // "cannot have gradient operations inside loops with divergent flow control",
- // even though it is counter-intuitive to disable unrolling for this error,
- // some very long shaders have trouble deciding which loops to unroll and
- // turning off forced unrolls allows them to compile properly.
- macros != nullptr)
- {
- macros = nullptr; // Disable [loop] and [flatten]
-
- // Retry without changing compiler flags
- i--;
- continue;
- }
- }
-
- if (SUCCEEDED(result))
- {
- *outCompiledBlob = binary;
-
- (*outDebugInfo) += "// COMPILER INPUT HLSL BEGIN\n\n" + hlsl + "\n// COMPILER INPUT HLSL END\n";
-
-#if ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
- (*outDebugInfo) += "\n\n// ASSEMBLY BEGIN\n\n";
- (*outDebugInfo) += "// Compiler configuration: " + configs[i].name + "\n// Flags:\n";
- for (size_t fIx = 0; fIx < ArraySize(CompilerFlagInfos); ++fIx)
- {
- if (IsCompilerFlagSet(configs[i].flags, CompilerFlagInfos[fIx].mFlag))
- {
- (*outDebugInfo) += std::string("// ") + CompilerFlagInfos[fIx].mName + "\n";
- }
- }
-
- (*outDebugInfo) += "// Macros:\n";
- if (macros == nullptr)
- {
- (*outDebugInfo) += "// - : -\n";
- }
- else
- {
- for (const D3D_SHADER_MACRO *mIt = macros; mIt->Name != nullptr; ++mIt)
- {
- (*outDebugInfo) += std::string("// ") + mIt->Name + " : " + mIt->Definition + "\n";
- }
- }
-
- std::string disassembly;
- ANGLE_TRY(disassembleBinary(binary, &disassembly));
- (*outDebugInfo) += "\n" + disassembly + "\n// ASSEMBLY END\n";
-#endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
- return gl::NoError();
- }
-
- if (result == E_OUTOFMEMORY)
- {
- *outCompiledBlob = nullptr;
- return gl::OutOfMemory()
- << "HLSL compiler had an unexpected failure, " << gl::FmtHR(result);
- }
-
- infoLog << "Warning: D3D shader compilation failed with " << configs[i].name << " flags. ("
- << profile << ")";
-
- if (i + 1 < configs.size())
- {
- infoLog << " Retrying with " << configs[i + 1].name;
- }
- }
-
- // None of the configurations succeeded in compiling this shader but the compiler is still intact
- *outCompiledBlob = nullptr;
- return gl::NoError();
-}
-
-gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *disassemblyOut)
-{
- ANGLE_TRY(ensureInitialized());
-
- // Retrieve disassembly
- UINT flags = D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS | D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING;
- ID3DBlob *disassembly = nullptr;
- pD3DDisassemble disassembleFunc = reinterpret_cast<pD3DDisassemble>(mD3DDisassembleFunc);
- LPCVOID buffer = shaderBinary->GetBufferPointer();
- SIZE_T bufSize = shaderBinary->GetBufferSize();
- HRESULT result = disassembleFunc(buffer, bufSize, flags, "", &disassembly);
-
- if (SUCCEEDED(result))
- {
- *disassemblyOut = std::string(reinterpret_cast<const char*>(disassembly->GetBufferPointer()));
- }
- else
- {
- *disassemblyOut = "";
- }
-
- SafeRelease(disassembly);
-
- return gl::NoError();
-}
-
-} // namespace rx