Diligent Engine  v.2.4.g
HLSL2GLSLConverterImpl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
30 #include <list>
31 #include <unordered_set>
32 #include <unordered_map>
33 #include <vector>
34 #include <array>
35 
36 #include "HLSL2GLSLConverter.h"
37 #include "ObjectBase.hpp"
38 #include "HLSLKeywords.h"
39 #include "Shader.h"
40 #include "HashUtils.hpp"
41 #include "HLSLKeywords.h"
42 #include "Constants.h"
43 
44 namespace Diligent
45 {
46 
48 {
49  // clang-format off
50  FunctionStubHashKey(const String& _Obj, const String& _Func, Uint32 _NumArgs) :
51  Object {_Obj },
52  Function {_Func },
53  NumArguments{_NumArgs}
54  {
55  }
56 
57  FunctionStubHashKey(const Char* _Obj, const Char* _Func, Uint32 _NumArgs) :
58  Object {_Obj },
59  Function {_Func },
60  NumArguments{_NumArgs}
61  {
62  }
63 
65  Object {std::move(Key.Object) },
66  Function {std::move(Key.Function)},
67  NumArguments{Key.NumArguments }
68  {
69  }
70  // clang-format on
71 
72  bool operator==(const FunctionStubHashKey& rhs) const
73  {
74  return Object == rhs.Object &&
75  Function == rhs.Function &&
77  }
78 
82 
83  struct Hasher
84  {
85  size_t operator()(const FunctionStubHashKey& Key) const
86  {
87  return ComputeHash(Key.Object.GetHash(), Key.Function.GetHash(), Key.NumArguments);
88  }
89  };
90 };
91 
94 {
95 public:
96  static const HLSL2GLSLConverterImpl& GetInstance();
97 
98  // clang-format off
99 
102  {
106 
109 
112  const Char* HLSLSource = nullptr;
113 
115  size_t NumSymbols = 0;
116 
118  const Char* EntryPoint = nullptr;
119 
122 
124  bool IncludeDefinitions = false;
125 
129  const Char* InputFileName = nullptr;
130 
132  const Char* SamplerSuffix = "_sampler";
133 
138  };
139 
140  // clang-format on
141 
143 
146  String Convert(ConversionAttribs& Attribs) const;
147 
149 
160  void CreateStream(const Char* InputFileName,
161  IShaderSourceInputStreamFactory* pSourceStreamFactory,
162  const Char* HLSLSource,
163  size_t NumSymbols,
164  IHLSL2GLSLConversionStream** ppStream) const;
165 
166 private:
168 
169  struct HLSLObjectInfo
170  {
171  const String GLSLType; // sampler2D, sampler2DShadow, image2D, etc.
172 
173  const Uint32 NumComponents; // 0, 1, 2, 3 or 4
174  // Texture2D<float4> -> 4
175  // Texture2D<uint> -> 1
176  // Texture2D -> 0
177 
178  const Uint32 ArrayDim; // Array dimensionality
179  // Texture2D g_Tex -> 0
180  // Texture2D g_Tex[8] -> 1
181  // Texture2D g_Tex[8][2] -> 2
182  HLSLObjectInfo(const String& Type, Uint32 NComp, Uint32 ArrDim) :
183  GLSLType{Type},
184  NumComponents{NComp},
185  ArrayDim{ArrDim}
186  {}
187  };
188  struct ObjectsTypeHashType
189  {
190  // This is only required to make the code compile on paranoid MSVC 2017 compiler (19.10.25017):
191  // https://stackoverflow.com/questions/47604029/move-constructors-of-stl-containers-in-msvc-2017-are-not-marked-as-noexcept
192  ObjectsTypeHashType() noexcept {}
193  ObjectsTypeHashType(ObjectsTypeHashType&& rhs) noexcept :
194  m{std::move(rhs.m)}
195  {}
196  // clang-format off
197  ObjectsTypeHashType& operator = (ObjectsTypeHashType&&) = delete;
198  ObjectsTypeHashType (ObjectsTypeHashType&) = delete;
199  ObjectsTypeHashType& operator = (ObjectsTypeHashType&) = delete;
200  // clang-format on
201 
202  std::unordered_map<HashMapStringKey, HLSLObjectInfo, HashMapStringKey::Hasher> m;
203  };
204 
205  struct GLSLStubInfo
206  {
207  String Name;
208  String Swizzle;
209  GLSLStubInfo(const String& _Name, const char* _Swizzle) :
210  Name{_Name},
211  Swizzle{_Swizzle}
212  {}
213  };
214  // Hash map that maps GLSL object, method and number of arguments
215  // passed to the original function, to the GLSL stub function
216  // Example: {"sampler2D", "Sample", 2} -> {"Sample_2", "_SWIZZLE"}
217  std::unordered_map<FunctionStubHashKey, GLSLStubInfo, FunctionStubHashKey::Hasher> m_GLSLStubs;
218 
219  // clang-format off
220  enum class TokenType
221  {
222  Undefined,
223 #define ADD_KEYWORD(keyword)kw_##keyword,
224  ITERATE_KEYWORDS(ADD_KEYWORD)
225 #undef ADD_KEYWORD
226  PreprocessorDirective,
227  Operator,
228  OpenBrace,
229  ClosingBrace,
230  OpenBracket,
231  ClosingBracket,
232  OpenStaple,
233  ClosingStaple,
234  OpenAngleBracket,
235  ClosingAngleBracket,
236  Identifier,
237  NumericConstant,
238  SrtingConstant,
239  Semicolon,
240  Comma,
241  TextBlock,
242  Assignment,
243  ComparisonOp,
244  BooleanOp,
245  BitwiseOp,
246  IncDecOp,
247  MathOp
248  };
249  // clang-format on
250 
251  struct TokenInfo
252  {
253  TokenType Type;
254  String Literal;
255  String Delimiter;
256 
257  bool IsBuiltInType() const
258  {
259  static_assert(static_cast<int>(TokenType::kw_bool) == 1 && static_cast<int>(TokenType::kw_void) == 191,
260  "If you updated built-in types, double check that all types are defined between bool and void");
261  return Type >= TokenType::kw_bool && Type <= TokenType::kw_void;
262  }
263 
264  bool IsFlowControl() const
265  {
266  static_assert(static_cast<int>(TokenType::kw_break) == 192 && static_cast<int>(TokenType::kw_while) == 202,
267  "If you updated control flow keywords, double check that all keywords are defined between break and while");
268  return Type >= TokenType::kw_break && Type <= TokenType::kw_while;
269  }
270 
271  TokenInfo(TokenType _Type = TokenType::Undefined,
272  const Char* _Literal = "",
273  const Char* _Delimiter = "") :
274  Type{_Type},
275  Literal{_Literal},
276  Delimiter{_Delimiter}
277  {}
278  };
279  typedef std::list<TokenInfo> TokenListType;
280 
281 
282  class ConversionStream : public ObjectBase<IHLSL2GLSLConversionStream>
283  {
284  public:
285  using TBase = ObjectBase<IHLSL2GLSLConversionStream>;
286 
288 
302  ConversionStream(IReferenceCounters* pRefCounters,
303  const HLSL2GLSLConverterImpl& Converter,
304  const char* InputFileName,
305  IShaderSourceInputStreamFactory* pInputStreamFactory,
306  const Char* HLSLSource,
307  size_t NumSymbols,
308  bool bPreserveTokens);
309 
310  String Convert(const Char* EntryPoint,
312  bool IncludeDefintions,
313  const char* SamplerSuffix,
314  bool UseInOutLocationQualifiers);
315 
316  virtual void DILIGENT_CALL_TYPE Convert(const Char* EntryPoint,
318  bool IncludeDefintions,
319  const char* SamplerSuffix,
320  bool UseInOutLocationQualifiers,
321  IDataBlob** ppGLSLSource) override final;
322 
323  IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_HLSL2GLSLConversionStream, TBase)
324 
325  const String& GetInputFileName() const { return m_InputFileName; }
326 
327  private:
328  void InsertIncludes(String& GLSLSource, IShaderSourceInputStreamFactory* pSourceStreamFactory);
329  void Tokenize(const String& Source);
330 
331  typedef std::unordered_map<String, bool> SamplerHashType;
332 
333  const HLSLObjectInfo* FindHLSLObject(const String& Name);
334 
335  void ProcessShaderDeclaration(TokenListType::iterator EntryPointToken, SHADER_TYPE ShaderType);
336 
337  void ProcessObjectMethods(const TokenListType::iterator& ScopeStart, const TokenListType::iterator& ScopeEnd);
338 
339  void ProcessRWTextures(const TokenListType::iterator& ScopeStart, const TokenListType::iterator& ScopeEnd);
340 
341  void ProcessAtomics(const TokenListType::iterator& ScopeStart,
342  const TokenListType::iterator& ScopeEnd);
343 
344  void RegisterStruct(TokenListType::iterator& Token);
345 
346  void ProcessConstantBuffer(TokenListType::iterator& Token);
347  void ProcessStructuredBuffer(TokenListType::iterator& Token, Uint32& ShaderStorageBlockBinding);
348  void ParseSamplers(TokenListType::iterator& ScopeStart, SamplerHashType& SamplersHash);
349 
350  void ProcessTextureDeclaration(TokenListType::iterator& Token,
351  const std::vector<SamplerHashType>& SamplersHash,
352  ObjectsTypeHashType& Objects,
353  const char* SamplerSuffix,
354  Uint32& ImageBinding);
355 
356  bool ProcessObjectMethod(TokenListType::iterator& Token,
357  const TokenListType::iterator& ScopeStart,
358  const TokenListType::iterator& ScopeEnd);
359 
360  Uint32 CountFunctionArguments(TokenListType::iterator& Token, const TokenListType::iterator& ScopeEnd);
361  bool ProcessRWTextureStore(TokenListType::iterator& Token, const TokenListType::iterator& ScopeEnd, Uint32 ArrayDim);
362  bool ProcessRWTextureLoad(TokenListType::iterator& Token, const TokenListType::iterator& ScopeEnd, Uint32 ArrayDim);
363  void RemoveFlowControlAttribute(TokenListType::iterator& Token);
364  void RemoveSemantics();
365  void RemoveSpecialShaderAttributes();
366  void RemoveSemanticsFromBlock(TokenListType::iterator& Token, TokenType OpenBracketType, TokenType ClosingBracketType);
367  void RemoveSamplerRegister(TokenListType::iterator& Token);
368 
369  // IteratorType may be String::iterator or String::const_iterator.
370  // While iterator is convertible to const_iterator,
371  // iterator& cannot be converted to const_iterator& (Microsoft compiler allows
372  // such conversion, while gcc does not)
373  template <typename IteratorType>
374  String PrintTokenContext(IteratorType& TargetToken, Int32 NumAdjacentLines);
375 
376  struct ShaderParameterInfo
377  {
378  enum class StorageQualifier : Int8
379  {
380  Unknown = 0,
381  In = 1,
382  Out = 2,
383  InOut = 3,
384  Ret = 4
385  } storageQualifier;
386 
388  {
389  enum class PrimitiveType : Int8
390  {
391  Undefined = 0,
392  Point = 1,
393  Line = 2,
394  Triangle = 3,
395  LineAdj = 4,
396  TriangleAdj = 5
397  };
398  enum class StreamType : Int8
399  {
400  Undefined = 0,
401  Point = 1,
402  Line = 2,
403  Triangle = 3
404  };
410  {}
411  } GSAttribs;
412 
414  {
415  enum class InOutPatchType : Int8
416  {
417  Undefined = 0,
418  InputPatch = 1,
419  OutputPatch = 2
420  } PatchType;
423  {}
424  } HSAttribs;
425 
426  String ArraySize;
427  String Type;
428  String Name;
429  String Semantic;
430 
431  std::vector<ShaderParameterInfo> members;
432 
433  ShaderParameterInfo() :
434  storageQualifier{StorageQualifier::Unknown}
435  {}
436  };
437  void ParseShaderParameter(TokenListType::iterator& Token,
438  ShaderParameterInfo& ParamInfo);
439  void ProcessFunctionParameters(TokenListType::iterator& Token,
440  std::vector<ShaderParameterInfo>& Params,
441  bool& bIsVoid);
442  bool RequiresFlatQualifier(const String& Type);
443  void ProcessFragmentShaderArguments(std::vector<ShaderParameterInfo>& Params,
444  String& GlobalVariables,
445  std::stringstream& ReturnHandlerSS,
446  String& Prologue);
447 
448  String BuildParameterName(const std::vector<const ShaderParameterInfo*>& MemberStack,
449  Char Separator,
450  const Char* Prefix = "",
451  const Char* SubstituteInstName = "",
452  const Char* Index = "");
453 
454  template <typename THandler>
455  void ProcessScope(TokenListType::iterator& Token,
456  TokenListType::iterator ScopeEnd,
457  TokenType OpenParenType,
458  TokenType ClosingParenType,
459  THandler Handler);
460 
461  template <typename TArgHandler>
462  void ProcessShaderArgument(const ShaderParameterInfo& Param,
463  int ShaderInd,
464  int IsOutVar,
465  std::stringstream& PrologueSS,
466  TArgHandler ArgHandler);
467 
468  void ProcessVertexShaderArguments(std::vector<ShaderParameterInfo>& Params,
469  String& Globals,
470  std::stringstream& ReturnHandlerSS,
471  String& Prologue);
472 
473  void ProcessGeometryShaderArguments(TokenListType::iterator& TypeToken,
474  std::vector<ShaderParameterInfo>& Params,
475  String& Globals,
476  String& Prologue);
477 
478  void ProcessHullShaderConstantFunction(const Char* FuncName, bool& bTakesInputPatch);
479 
480  void ProcessShaderAttributes(TokenListType::iterator& TypeToken,
481  std::unordered_map<HashMapStringKey, String, HashMapStringKey::Hasher>& Attributes);
482 
483  void ProcessHullShaderArguments(TokenListType::iterator& TypeToken,
484  std::vector<ShaderParameterInfo>& Params,
485  String& Globals,
486  std::stringstream& ReturnHandlerSS,
487  String& Prologue);
488  void ProcessDomainShaderArguments(TokenListType::iterator& TypeToken,
489  std::vector<ShaderParameterInfo>& Params,
490  String& Globals,
491  std::stringstream& ReturnHandlerSS,
492  String& Prologue);
493  void ProcessComputeShaderArguments(TokenListType::iterator& TypeToken,
494  std::vector<ShaderParameterInfo>& Params,
495  String& Globals,
496  String& Prologue);
497 
498  void FindMatchingBracket(TokenListType::iterator& Token,
499  const TokenListType::iterator& ScopeEnd,
500  TokenType OpenBracketType);
501 
502  void ProcessReturnStatements(TokenListType::iterator& Token,
503  bool IsVoid,
504  const Char* EntryPoint,
505  const Char* MacroName);
506 
507  void ProcessGSOutStreamOperations(TokenListType::iterator& Token,
508  const String& OutStreamName,
509  const char* EntryPoint);
510 
511  String BuildGLSLSource();
512 
513  // Tokenized source code
514  TokenListType m_Tokens;
515 
516  // List of tokens defining structs
517  std::unordered_map<HashMapStringKey, TokenListType::iterator, HashMapStringKey::Hasher> m_StructDefinitions;
518 
519  // Stack of parsed objects, for every scope level.
520  // There are currently only two levels:
521  // level 0 - global scope, contains all global objects
522  // (textures, buffers)
523  // level 1 - function body, contains all objects
524  // defined as function arguments
525  std::vector<ObjectsTypeHashType> m_Objects;
526 
527  const bool m_bPreserveTokens;
528  bool m_bUseInOutLocationQualifiers = true;
529 
530  const HLSL2GLSLConverterImpl& m_Converter;
531 
532  // This member is only used to compare input name
533  // when subsequent shaders are converted from already tokenized source
534  const String m_InputFileName;
535  };
536 
537  // HLSL keyword->token info hash map
538  // Example: "Texture2D" -> TokenInfo(TokenType::Texture2D, "Texture2D")
539  std::unordered_map<HashMapStringKey, TokenInfo, HashMapStringKey::Hasher> m_HLSLKeywords;
540 
541  // Set of all GLSL image types (image1D, uimage1D, iimage1D, image2D, ... )
542  std::unordered_set<HashMapStringKey, HashMapStringKey::Hasher> m_ImageTypes;
543 
544  // Set of all HLSL atomic operations (InterlockedAdd, InterlockedOr, ...)
545  std::unordered_set<HashMapStringKey, HashMapStringKey::Hasher> m_AtomicOperations;
546 
547  // HLSL semantic -> glsl variable, for every shader stage and input/output type (in == 0, out == 1)
548  // Example: [vertex, output] SV_Position -> gl_Position
549  // [fragment, input] SV_Position -> gl_FragCoord
550  static constexpr int InVar = 0;
551  static constexpr int OutVar = 1;
552  static constexpr int MaxShaderStages = 6; // Maximum supported shader stages: VS, GS, PS, DS, HS, CS
553 
554  std::array<std::array<std::unordered_map<HashMapStringKey, String, HashMapStringKey::Hasher>, 2>, MaxShaderStages> m_HLSLSemanticToGLSLVar;
555 };
556 
557 } // namespace Diligent
558 
559 // Intro
560 // DirectX and OpenGL use different shading languages. While mostly being very similar,
561 // the language syntax differs substantially sometimes. Having two versions of each
562 // shader is clearly not an option for real projects. Maintaining intermediate representation
563 // that translates to both languages is one solution, but it might complicate shader development
564 // and debugging.
565 //
566 // HLSL converter allows HLSL shader files to be converted into GLSL source.
567 // The entire shader development can thus be performed using HLSL tools. Since no intermediate
568 // representation is used, shader files can be directly compiled by the HLSL compiler.
569 // All tools available for HLSL shader devlopment, analysis and optimization can be
570 // used. The source can then be transaprently converted to GLSL.
571 //
572 //
573 // Using HLSL Converter
574 // * The following rules are used to convert HLSL texture declaration into GLSL sampler:
575 // - HLSL texture dimension defines GLSL sampler dimension:
576 // - Texture2D -> sampler2D
577 // - TextureCube -> samplerCube
578 // - HLSL texture component type defines GLSL sampler type. If no type is specified, float4 is assumed:
579 // - Texture2D<float> -> sampler2D
580 // - Texture3D<uint4> -> usampler3D
581 // - Texture2DArray<int2> -> isampler2DArray
582 // - Texture2D -> sampler2D
583 // - To distinguish if sampler should be shadow or not, the converter tries to find <Texture Name>_sampler
584 // among samplers (global variables and function arguments). If the sampler type is comparison,
585 // the texture is converted to shadow sampler. If sampler state is either not comparison or not found,
586 // regular sampler is used.
587 // Examples:
588 // - Texture2D g_ShadowMap; -> sampler2DShadow g_ShadowMap;
589 // SamplerComparisonState g_ShadowMap_sampler;
590 // - Texture2D g_Tex2D; -> sampler2D g_Tex2D;
591 // SamplerState g_Tex2D_sampler;
592 // Texture3D g_Tex3D; -> sampler3D g_Tex3D;
593 //
594 // * GLSL requires format to be specified for all images allowing writes. HLSL converter allows GLSL image
595 // format specification inside the special comment block:
596 // Example:
597 // RWTexture2D<float /* format=r32f */ > Tex2D;
598 // * In OpenGL tessellation, domain, partitioning, and topology are properties of tessellation evaluation
599 // shader rather than tessellation control shader. The following specially formatted comment should be placed
600 // on top of domain shader declararion to specify the attributes
601 // /* partitioning = {integer|fractional_even|fractional_odd}, outputtopology = {triangle_cw|triangle_ccw} */
602 // Example:
603 // /* partitioning = fractional_even, outputtopology = triangle_cw */
604 
605 
606 // Requirements:
607 // * GLSL allows samplers to be declared as global variables or function arguments only.
608 // It does not allow local variables of sampler type.
609 //
610 // Important notes/known issues:
611 //
612 // * GLSL compiler does not handle float3 structure members correctly. It is
613 // strongly suggested not to use this type in structure definitions
614 //
615 // * At least NVidia GLSL compiler does not apply layout(row_major) to
616 // structure members. By default, all matrices in both HLSL and GLSL
617 // are column major
618 //
619 // * GLSL compiler does not properly handle structs passed as function arguments!!!!
620 // struct MyStruct
621 // {
622 // matrix Matr;
623 // }
624 // void Func(in MyStruct S)
625 // {
626 // ...
627 // mul(f4PosWS, S.Matr); <--- This will not work!!!
628 // }
629 // DO NOT pass structs to functions, use only built-in types!!!
630 //
631 // * GLSL does not support most of the implicit type conversions. The following are some
632 // examples of required modifications to HLSL code:
633 // ** float4 vec = 0; -> float4 vec = float4(0.0, 0.0, 0.0, 0.0);
634 // ** float x = 0; -> float x = 0.0;
635 // ** uint x = 0; -> uint x = 0u;
636 // ** GLES is immensely strict about type conversions. For instance,
637 // this code will produce compiler error: float4(0, 0, 0, 0)
638 // It must be written as float4(0.0, 0.0, 0.0, 0.0)
639 // * GLSL does not support relational and boolean operations on vector types:
640 // ** float2 p = float2(1.0,2.0), q = float2(3.0,4.0);
641 // bool2 b = x < y; -> Error
642 // all(p<q) -> Error
643 // ** To facilitate relational and boolean operations on vector types, the following
644 // functions are predefined:
645 // - Less
646 // - LessEqual
647 // - Greater
648 // - GreaterEqual
649 // - Equal
650 // - NotEqual
651 // - Not
652 // - And
653 // - Or
654 // - BoolToFloat
655 // ** Examples:
656 // bool2 b = x < y; -> bool2 b = Less(x, y);
657 // all(p>=q) -> all( GreaterEqual(p,q) )
658 //
659 // * When accessing elements of an HLSL matrix, the first index is always row:
660 // mat[row][column]
661 // In GLSL, the first index is always column:
662 // mat[column][row]
663 // MATRIX_ELEMENT(mat, row, col) macros is provided to facilitate matrix element retrieval
664 
665 // * The following functions do not have counterparts in GLSL and should be avoided:
666 // ** Texture2DArray.SampleCmpLevelZero()
667 // ** TextureCube.SampleCmpLevelZero()
668 // ** TextureCubeArray.SampleCmpLevelZero()
669 
670 
671 // * Input variables to a shader stage must be listed in exact same order as outputs from
672 // the previous stage. Function return value counts as the first output argument.
Diligent::HLSL2GLSLConverterImpl
HLSL to GLSL shader source code converter implementation.
Definition: HLSL2GLSLConverterImpl.hpp:93
Diligent::IShaderSourceInputStreamFactory
Shader source stream factory interface.
Definition: Shader.h:134
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::StreamType::Undefined
@ Undefined
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::Stream
StreamType Stream
Definition: HLSL2GLSLConverterImpl.hpp:406
ObjectBase.hpp
Diligent::FunctionStubHashKey::FunctionStubHashKey
FunctionStubHashKey(const Char *_Obj, const Char *_Func, Uint32 _NumArgs)
Definition: HLSL2GLSLConverterImpl.hpp:57
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes
Definition: HLSL2GLSLConverterImpl.hpp:413
Diligent::FunctionStubHashKey::Hasher
Definition: HLSL2GLSLConverterImpl.hpp:83
Diligent::Char
char Char
Definition: BasicTypes.h:64
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::EntryPoint
const Char * EntryPoint
Shader entry point.
Definition: HLSL2GLSLConverterImpl.hpp:118
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::HLSLSource
const Char * HLSLSource
HLSL source code. Can be null, in which case the source code will be loaded from the input stream fac...
Definition: HLSL2GLSLConverterImpl.hpp:112
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimitiveType::Line
@ Line
Diligent::SHADER_TYPE
SHADER_TYPE
Describes the shader type.
Definition: GraphicsTypes.h:65
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::ppConversionStream
IHLSL2GLSLConversionStream ** ppConversionStream
Optional pointer to a conversion stream.
Definition: HLSL2GLSLConverterImpl.hpp:108
Shader.h
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes::HSAttributes
HSAttributes()
Definition: HLSL2GLSLConverterImpl.hpp:421
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimType
PrimitiveType PrimType
Definition: HLSL2GLSLConverterImpl.hpp:405
Diligent::IHLSL2GLSLConversionStream
Definition: HLSL2GLSLConverter.h:52
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimitiveType::LineAdj
@ LineAdj
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::UseInOutLocationQualifiers
bool UseInOutLocationQualifiers
Whether to use in-out location qualifiers. This requires separate shader objects extension: https://w...
Definition: HLSL2GLSLConverterImpl.hpp:137
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs
Conversion attributes.
Definition: HLSL2GLSLConverterImpl.hpp:101
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimitiveType::Point
@ Point
Diligent::FunctionStubHashKey::operator==
bool operator==(const FunctionStubHashKey &rhs) const
Definition: HLSL2GLSLConverterImpl.hpp:72
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::StreamType::Line
@ Line
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::StreamType::Triangle
@ Triangle
Diligent::FunctionStubHashKey::NumArguments
Uint32 NumArguments
Definition: HLSL2GLSLConverterImpl.hpp:81
Constants.h
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimitiveType::TriangleAdj
@ TriangleAdj
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes::InOutPatchType::OutputPatch
@ OutputPatch
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimitiveType::Triangle
@ Triangle
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimitiveType
PrimitiveType
Definition: HLSL2GLSLConverterImpl.hpp:389
Diligent::Int32
int32_t Int32
32-bit signed integer
Definition: BasicTypes.h:46
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::ShaderType
SHADER_TYPE ShaderType
Shader type. See Diligent::SHADER_TYPE.
Definition: HLSL2GLSLConverterImpl.hpp:121
Diligent::FunctionStubHashKey
Definition: HLSL2GLSLConverterImpl.hpp:47
Diligent::FunctionStubHashKey::Function
HashMapStringKey Function
Definition: HLSL2GLSLConverterImpl.hpp:80
ITERATE_KEYWORDS
#define ITERATE_KEYWORDS(KEYWORD_HANDLER)
Definition: HLSLKeywords.h:55
Diligent::Int8
int8_t Int8
8-bit signed integer
Definition: BasicTypes.h:48
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::GSAttributes
GSAttributes()
Definition: HLSL2GLSLConverterImpl.hpp:407
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::PrimitiveType::Undefined
@ Undefined
HLSL2GLSLConverter.h
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes::PatchType
enum Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes::InOutPatchType PatchType
Diligent::FunctionStubHashKey::FunctionStubHashKey
FunctionStubHashKey(const String &_Obj, const String &_Func, Uint32 _NumArgs)
Definition: HLSL2GLSLConverterImpl.hpp:50
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes
Definition: HLSL2GLSLConverterImpl.hpp:387
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::pSourceStreamFactory
IShaderSourceInputStreamFactory * pSourceStreamFactory
Shader source input stream factory. Used to load shader source when HLSLSource is null as well as to ...
Definition: HLSL2GLSLConverterImpl.hpp:105
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Diligent::DescriptorType::Unknown
@ Unknown
Diligent::HLSL2GLSLConverterImpl::GetInstance
static const HLSL2GLSLConverterImpl & GetInstance()
Definition: HLSL2GLSLConverterImpl.cpp:514
NumComponents
D3D10_SB_OPERAND_NUM_COMPONENTS NumComponents
Definition: DXBCUtils.cpp:519
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::InputFileName
const Char * InputFileName
Input file name. If HLSLSource is not null, this name will only be used for information purposes....
Definition: HLSL2GLSLConverterImpl.hpp:129
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Type
const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type
Definition: PipelineStateD3D12Impl.cpp:69
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::ComputeHash
std::size_t ComputeHash(const ArgsType &... Args)
Definition: HashUtils.hpp:57
Diligent::SHADER_TYPE_UNKNOWN
@ SHADER_TYPE_UNKNOWN
Unknown shader type.
Definition: GraphicsTypes.h:67
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes::InOutPatchType::Undefined
@ Undefined
Diligent::FunctionStubHashKey::Object
HashMapStringKey Object
Definition: HLSL2GLSLConverterImpl.hpp:79
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::SamplerSuffix
const Char * SamplerSuffix
Combined texture sampler suffix.
Definition: HLSL2GLSLConverterImpl.hpp:132
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes::InOutPatchType::InputPatch
@ InputPatch
Diligent::FunctionStubHashKey::Hasher::operator()
size_t operator()(const FunctionStubHashKey &Key) const
Definition: HLSL2GLSLConverterImpl.hpp:85
HashUtils.hpp
Diligent::HashMapStringKey
This helper structure is intended to facilitate using strings as a hash table key....
Definition: HashUtils.hpp:100
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::HSAttributes::InOutPatchType
InOutPatchType
Definition: HLSL2GLSLConverterImpl.hpp:415
Diligent::String
std::basic_string< Char > String
String variable.
Definition: BasicTypes.h:66
HLSLKeywords.h
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::NumSymbols
size_t NumSymbols
Number of symbols in HLSLSource string. Ignored if HLSLSource is null.
Definition: HLSL2GLSLConverterImpl.hpp:115
Diligent::FunctionStubHashKey::FunctionStubHashKey
FunctionStubHashKey(FunctionStubHashKey &&Key)
Definition: HLSL2GLSLConverterImpl.hpp:64
Diligent::HLSL2GLSLConverterImpl::ConversionAttribs::IncludeDefinitions
bool IncludeDefinitions
Whether to include GLSL definitions supporting HLSL->GLSL conversion.
Definition: HLSL2GLSLConverterImpl.hpp:124
ShaderType
Uint16 ShaderType
Definition: DXBCUtils.cpp:70
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::StreamType
StreamType
Definition: HLSL2GLSLConverterImpl.hpp:398
Diligent::HLSL2GLSLConverterImpl::ConversionStream::ShaderParameterInfo::GSAttributes::StreamType::Point
@ Point
Diligent::HashMapStringKey::GetHash
size_t GetHash() const
Definition: HashUtils.hpp:193
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::HLSL2GLSLConverterImpl::CreateStream
void CreateStream(const Char *InputFileName, IShaderSourceInputStreamFactory *pSourceStreamFactory, const Char *HLSLSource, size_t NumSymbols, IHLSL2GLSLConversionStream **ppStream) const
Creates a conversion stream.
Definition: HLSL2GLSLConverterImpl.cpp:4866
Diligent::HLSL2GLSLConverterImpl::Convert
String Convert(ConversionAttribs &Attribs) const
Converts HLSL source to GLSL.
Definition: HLSL2GLSLConverterImpl.cpp:4826