1 // 2 // Copyright 2016 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // HLSLCompiler: Wrapper for the D3DCompiler DLL. 7 // 8 9 #ifndef LIBANGLE_RENDERER_D3D_HLSLCOMPILER_H_ 10 #define LIBANGLE_RENDERER_D3D_HLSLCOMPILER_H_ 11 12 #include "libANGLE/Error.h" 13 14 #include "common/angleutils.h" 15 #include "common/platform.h" 16 17 #include <string> 18 #include <vector> 19 20 namespace gl 21 { 22 class InfoLog; 23 } // namespace gl 24 25 namespace rx 26 { 27 namespace d3d 28 { 29 class Context; 30 } // namespace d3d 31 32 struct CompileConfig 33 { 34 UINT flags; 35 std::string name; 36 37 CompileConfig(); 38 CompileConfig(UINT flags, const std::string &name); 39 }; 40 41 class HLSLCompiler : angle::NonCopyable 42 { 43 public: 44 HLSLCompiler(); 45 ~HLSLCompiler(); 46 47 void release(); 48 49 // Attempt to compile a HLSL shader using the supplied configurations, may output a NULL 50 // compiled blob even if no GL errors are returned. 51 angle::Result compileToBinary(d3d::Context *context, 52 gl::InfoLog &infoLog, 53 const std::string &hlsl, 54 const std::string &profile, 55 const std::vector<CompileConfig> &configs, 56 const D3D_SHADER_MACRO *overrideMacros, 57 ID3DBlob **outCompiledBlob, 58 std::string *outDebugInfo); 59 60 angle::Result disassembleBinary(d3d::Context *context, 61 ID3DBlob *shaderBinary, 62 std::string *disassemblyOut); 63 angle::Result ensureInitialized(d3d::Context *context); 64 65 private: 66 bool mInitialized; 67 HMODULE mD3DCompilerModule; 68 pD3DCompile mD3DCompileFunc; 69 pD3DDisassemble mD3DDisassembleFunc; 70 }; 71 72 } // namespace rx 73 74 #endif // LIBANGLE_RENDERER_D3D_HLSLCOMPILER_H_ 75