ShaderProgramReflection.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (C) 2009-2021, 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/ShaderCompiler/Common.h>
  7. #include <AnKi/Gr/Enums.h>
  8. #include <AnKi/Gr/Common.h>
  9. #include <AnKi/Util/WeakArray.h>
  10. namespace anki
  11. {
  12. /// @addtogroup shader_compiler
  13. /// @{
  14. /// A visitor class that will be used to populate reflection information.
  15. class ShaderReflectionVisitorInterface
  16. {
  17. public:
  18. virtual ANKI_USE_RESULT Error setWorkgroupSizes(U32 x, U32 y, U32 z, U32 specConstMask) = 0;
  19. virtual ANKI_USE_RESULT Error setCounts(U32 uniformBlockCount, U32 storageBlockCount, U32 opaqueCount,
  20. Bool pushConstantBlock, U32 constsCount) = 0;
  21. virtual ANKI_USE_RESULT Error visitUniformBlock(U32 idx, CString name, U32 set, U32 binding, U32 size,
  22. U32 varCount) = 0;
  23. virtual ANKI_USE_RESULT Error visitUniformVariable(U32 blockIdx, U32 idx, CString name, ShaderVariableDataType type,
  24. const ShaderVariableBlockInfo& blockInfo) = 0;
  25. virtual ANKI_USE_RESULT Error visitStorageBlock(U32 idx, CString name, U32 set, U32 binding, U32 size,
  26. U32 varCount) = 0;
  27. virtual ANKI_USE_RESULT Error visitStorageVariable(U32 blockIdx, U32 idx, CString name, ShaderVariableDataType type,
  28. const ShaderVariableBlockInfo& blockInfo) = 0;
  29. virtual ANKI_USE_RESULT Error visitPushConstantsBlock(CString name, U32 size, U32 varCount) = 0;
  30. virtual ANKI_USE_RESULT Error visitPushConstant(U32 idx, CString name, ShaderVariableDataType type,
  31. const ShaderVariableBlockInfo& blockInfo) = 0;
  32. virtual ANKI_USE_RESULT Error visitOpaque(U32 idx, CString name, ShaderVariableDataType type, U32 set, U32 binding,
  33. U32 arraySize) = 0;
  34. virtual ANKI_USE_RESULT Error visitConstant(U32 idx, CString name, ShaderVariableDataType type, U32 constantId) = 0;
  35. };
  36. /// Does reflection using SPIR-V.
  37. ANKI_USE_RESULT Error performSpirvReflection(Array<ConstWeakArray<U8>, U32(ShaderType::COUNT)> spirv,
  38. GenericMemoryPoolAllocator<U8> tmpAlloc,
  39. ShaderReflectionVisitorInterface& interface);
  40. /// @}
  41. } // end namespace anki