GteHLSLShaderFactory.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.1 (2016/09/12)
7 
8 #pragma once
9 
12 
13 namespace gte
14 {
15 
17 {
18 public:
19  // Create a shader from an HLSL program in a file.
20  static HLSLShader CreateFromFile(
21  std::string const& filename,
22  std::string const& entry,
23  std::string const& target,
24  ProgramDefines const& defines,
25  unsigned int compileFlags);
26 
27  // Create a shader from an HLSL represented as a string.
28  static HLSLShader CreateFromString(
29  std::string const& name,
30  std::string const& source,
31  std::string const& entry,
32  std::string const& target,
33  ProgramDefines const& defines,
34  unsigned int compileFlags);
35 
36  // Create a shader from an HLSL bytecode blob.
37  static HLSLShader CreateFromBytecode(
38  std::string const& name,
39  std::string const& entry,
40  std::string const& target,
41  size_t numBytes,
42  unsigned char const* bytecode);
43 
44 private:
45  // Common code for CreateFromFile and CreateFromString.
46  static HLSLShader CompileAndReflect(
47  std::string const& name,
48  std::string const& source,
49  std::string const& entry,
50  std::string const& target,
51  ProgramDefines const& defines,
52  unsigned int compileFlags);
53 
54  // Wrapper for the D3DCompile call.
55  static ID3DBlob* CompileShader(
56  std::string const& name,
57  std::string const& source,
58  std::string const& entry,
59  std::string const& target,
60  unsigned int compileFlags,
61  ProgramDefines const& defines);
62 
63  // Support for shader reflection to obtain information about the HLSL
64  // program.
65  static bool ReflectShader(
66  std::string const& name,
67  std::string const& entry,
68  std::string const& target,
69  ID3DBlob* compiledCode,
71 
72  static bool GetDescription(ID3DShaderReflection* reflector, HLSLShader& shader);
73  static bool GetInputs(ID3DShaderReflection* reflector, HLSLShader& shader);
74  static bool GetOutputs(ID3DShaderReflection* reflector, HLSLShader& shader);
75  static bool GetCBuffers(ID3DShaderReflection* reflector, HLSLShader& shader);
76  static bool GetBoundResources(ID3DShaderReflection* reflector, HLSLShader& shader);
77 
78  static bool GetVariables(ID3DShaderReflectionConstantBuffer* cbuffer,
79  unsigned int numVariables, std::vector<HLSLBaseBuffer::Member>& members);
80 
81  static bool GetTypes(ID3DShaderReflectionType* rtype,
82  unsigned int numMembers, HLSLShaderType& stype);
83 
84  static bool IsTextureArray(D3D_SRV_DIMENSION dim);
85 
86  // Support for logging warnings and errors to a file.
87  static void WriteLog(std::string const& message);
88 };
89 
90 }
#define ID3DShaderReflectionType
GLuint const GLchar * name
Definition: glcorearb.h:781
GLenum target
Definition: glcorearb.h:1662
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:798
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2538
#define ID3DShaderReflectionConstantBuffer
GLuint shader
Definition: glcorearb.h:780
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
#define ID3DShaderReflection


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00