Common.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Util/Logger.h>
  7. #include <AnKi/Util/String.h>
  8. #include <AnKi/Util/BitSet.h>
  9. #include <AnKi/Gr/Common.h>
  10. namespace anki {
  11. /// @addtogroup shader_compiler
  12. /// @{
  13. #define ANKI_SHADER_COMPILER_LOGI(...) ANKI_LOG("SHCO", kNormal, __VA_ARGS__)
  14. #define ANKI_SHADER_COMPILER_LOGE(...) ANKI_LOG("SHCO", kError, __VA_ARGS__)
  15. #define ANKI_SHADER_COMPILER_LOGW(...) ANKI_LOG("SHCO", kWarning, __VA_ARGS__)
  16. #define ANKI_SHADER_COMPILER_LOGF(...) ANKI_LOG("SHCO", kFatal, __VA_ARGS__)
  17. #define ANKI_SHADER_COMPILER_LOGV(...) ANKI_LOG("SHCO", kVerbose, __VA_ARGS__)
  18. class ShaderCompilerMemoryPool : public HeapMemoryPool, public MakeSingleton<ShaderCompilerMemoryPool>
  19. {
  20. template<typename>
  21. friend class MakeSingleton;
  22. private:
  23. ShaderCompilerMemoryPool(AllocAlignedCallback allocCb, void* allocCbUserData)
  24. : HeapMemoryPool(allocCb, allocCbUserData, "ShaderCompilerMemPool")
  25. {
  26. }
  27. ~ShaderCompilerMemoryPool() = default;
  28. };
  29. ANKI_DEFINE_SUBMODULE_UTIL_CONTAINERS(ShaderCompiler, ShaderCompilerMemoryPool)
  30. constexpr U32 kMaxShaderBinaryNameLength = 127;
  31. using MutatorValue = I32; ///< The type of the mutator value
  32. /// An interface used by the ShaderParser and compileShaderProgram to abstract file loading.
  33. class ShaderCompilerFilesystemInterface
  34. {
  35. public:
  36. virtual Error readAllText(CString filename, ShaderCompilerString& txt) = 0;
  37. };
  38. /// This controls if the compilation will continue after the parsing stage.
  39. class ShaderCompilerPostParseInterface
  40. {
  41. public:
  42. virtual Bool skipCompilation(U64 programHash) = 0;
  43. };
  44. /// An interface for asynchronous shader compilation.
  45. class ShaderCompilerAsyncTaskInterface
  46. {
  47. public:
  48. virtual void enqueueTask(void (*callback)(void* userData), void* userData) = 0;
  49. virtual Error joinTasks() = 0;
  50. };
  51. class ShaderCompilerDefine
  52. {
  53. public:
  54. CString m_name;
  55. I32 m_value;
  56. };
  57. enum class ShaderModel : U8
  58. {
  59. k6_7,
  60. k6_8
  61. };
  62. /// @}
  63. } // end namespace anki