2
0

ShaderImpl.h 1.5 KB

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