diff options
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp')
-rw-r--r-- | src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp | 86 |
1 files changed, 24 insertions, 62 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp index df0257e370..b38765070b 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/HLSLCompiler.cpp @@ -6,16 +6,14 @@ #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 { @@ -25,15 +23,6 @@ namespace #define CREATE_COMPILER_FLAG_INFO(flag) { flag, #flag } -#if defined(ANGLE_MINGW32_COMPAT) -#ifndef D3DCOMPILE_RESERVED16 -#define D3DCOMPILE_RESERVED16 0x10000 -#endif -#ifndef D3DCOMPILE_RESERVED17 -#define D3DCOMPILE_RESERVED17 0x20000 -#endif -#endif - struct CompilerFlagInfo { UINT mFlag; @@ -119,11 +108,11 @@ HLSLCompiler::~HLSLCompiler() release(); } -gl::Error HLSLCompiler::initialize() +gl::Error HLSLCompiler::ensureInitialized() { if (mInitialized) { - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } TRACE_EVENT0("gpu.angle", "HLSLCompiler::initialize"); @@ -141,28 +130,6 @@ gl::Error HLSLCompiler::initialize() } #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. @@ -171,7 +138,8 @@ gl::Error HLSLCompiler::initialize() if (!mD3DCompilerModule) { - return gl::Error(GL_INVALID_OPERATION, "No D3D compiler module found - aborting!\n"); + ERR() << "D3D compiler module not found."; + return gl::OutOfMemory() << "D3D compiler module not found."; } mD3DCompileFunc = reinterpret_cast<pD3DCompile>(GetProcAddress(mD3DCompilerModule, "D3DCompile")); @@ -190,11 +158,11 @@ gl::Error HLSLCompiler::initialize() if (mD3DCompileFunc == nullptr) { - return gl::Error(GL_INVALID_OPERATION, "Error finding D3DCompile entry point"); + return gl::OutOfMemory() << "Error finding D3DCompile entry point."; } mInitialized = true; - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } void HLSLCompiler::release() @@ -213,11 +181,7 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string const std::vector<CompileConfig> &configs, const D3D_SHADER_MACRO *overrideMacros, ID3DBlob **outCompiledBlob, std::string *outDebugInfo) { - gl::Error error = initialize(); - if (error.isError()) - { - return error; - } + ASSERT(mInitialized); #if !defined(ANGLE_ENABLE_WINDOWS_STORE) ASSERT(mD3DCompilerModule); @@ -228,7 +192,9 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string if (gl::DebugAnnotationsActive()) { std::string sourcePath = getTempPath(); - std::string sourceText = FormatString("#line 2 \"%s\"\n\n%s", sourcePath.c_str(), hlsl.c_str()); + 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 @@ -255,8 +221,11 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string SafeRelease(errorMessage); infoLog.appendSanitized(message.c_str()); - TRACE("\n%s", hlsl.c_str()); - TRACE("\n%s", 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", @@ -304,20 +273,17 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string } std::string disassembly; - error = disassembleBinary(binary, &disassembly); - if (error.isError()) - { - return error; - } + ANGLE_TRY(disassembleBinary(binary, &disassembly)); (*outDebugInfo) += "\n" + disassembly + "\n// ASSEMBLY END\n"; #endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } if (result == E_OUTOFMEMORY) { *outCompiledBlob = nullptr; - return gl::Error(GL_OUT_OF_MEMORY, "HLSL compiler had an unexpected failure, result: 0x%X.", result); + return gl::OutOfMemory() + << "HLSL compiler had an unexpected failure, " << gl::FmtHR(result); } infoLog << "Warning: D3D shader compilation failed with " << configs[i].name << " flags. (" @@ -331,16 +297,12 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string // None of the configurations succeeded in compiling this shader but the compiler is still intact *outCompiledBlob = nullptr; - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *disassemblyOut) { - gl::Error error = initialize(); - if (error.isError()) - { - return error; - } + ANGLE_TRY(ensureInitialized()); // Retrieve disassembly UINT flags = D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS | D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING; @@ -361,7 +323,7 @@ gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *d SafeRelease(disassembly); - return gl::Error(GL_NO_ERROR); + return gl::NoError(); } } // namespace rx |