ShaderProgramReflection.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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, U32 structCount) = 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. virtual ANKI_USE_RESULT Error visitStruct(U32 idx, CString name, U32 memberCount, U32 size) = 0;
  36. virtual ANKI_USE_RESULT Error visitStructMember(U32 structIdx, CString structName, U32 memberIdx,
  37. CString memberName, ShaderVariableDataType type,
  38. CString typeStructName, U32 offset, U32 arraySize) = 0;
  39. virtual ANKI_USE_RESULT Bool skipSymbol(CString symbol) const = 0;
  40. };
  41. /// Does reflection using SPIR-V.
  42. ANKI_USE_RESULT Error performSpirvReflection(Array<ConstWeakArray<U8>, U32(ShaderType::COUNT)> spirv,
  43. GenericMemoryPoolAllocator<U8> tmpAlloc,
  44. ShaderReflectionVisitorInterface& interface);
  45. /// @}
  46. } // end namespace anki