ShaderImpl.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/Gr/Shader.h>
  7. #include <AnKi/Gr/Vulkan/VulkanObject.h>
  8. #include <AnKi/Gr/Vulkan/DescriptorSet.h>
  9. #include <AnKi/Util/BitSet.h>
  10. namespace anki
  11. {
  12. /// @addtogroup vulkan
  13. /// @{
  14. /// Shader vulkan implementation.
  15. class ShaderImpl final : public Shader, public VulkanObject<Shader, ShaderImpl>
  16. {
  17. public:
  18. VkShaderModule m_handle = VK_NULL_HANDLE;
  19. Array<DynamicArray<DescriptorBinding>, MAX_DESCRIPTOR_SETS> m_bindings;
  20. BitSet<MAX_COLOR_ATTACHMENTS, U8> m_colorAttachmentWritemask = {false};
  21. BitSet<MAX_VERTEX_ATTRIBUTES, U8> m_attributeMask = {false};
  22. BitSet<MAX_DESCRIPTOR_SETS, U8> m_descriptorSetMask = {false};
  23. Array<BitSet<MAX_BINDINGS_PER_DESCRIPTOR_SET, U8>, MAX_DESCRIPTOR_SETS> m_activeBindingMask = {{{false}, {false}}};
  24. U32 m_pushConstantsSize = 0;
  25. ShaderImpl(GrManager* manager, CString name)
  26. : Shader(manager, name)
  27. {
  28. }
  29. ~ShaderImpl();
  30. ANKI_USE_RESULT Error init(const ShaderInitInfo& init);
  31. const VkSpecializationInfo* getSpecConstInfo() const
  32. {
  33. return (m_specConstInfo.mapEntryCount) ? &m_specConstInfo : nullptr;
  34. }
  35. private:
  36. VkSpecializationInfo m_specConstInfo = {};
  37. class SpecConstsVector; ///< Wrap this into a class to avoid forward declarations of std::vector and spirv_cross.
  38. void doReflection(ConstWeakArray<U8> spirv, SpecConstsVector& specConstIds);
  39. };
  40. /// @}
  41. } // end namespace anki