BsVulkanGpuParams.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsVulkanPrerequisites.h"
  5. #include "BsGpuParams.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Vulkan
  9. * @{
  10. */
  11. /** Vulkan implementation of GpuParams, containing resource descriptors for all shader stages. */
  12. class VulkanGpuParams : public GpuParamsCore
  13. {
  14. public:
  15. ~VulkanGpuParams();
  16. /** @copydoc GpuParamsCore::setParamBlockBuffer(UINT32, UINT32, const ParamsBufferType&) */
  17. void setParamBlockBuffer(UINT32 set, UINT32 slot, const SPtr<GpuParamBlockBufferCore>& paramBlockBuffer) override;
  18. /** @copydoc GpuParamsCore::setTexture */
  19. void setTexture(UINT32 set, UINT32 slot, const SPtr<TextureCore>& texture) override;
  20. /** @copydoc GpuParamsCore::setLoadStoreTexture */
  21. void setLoadStoreTexture(UINT32 set, UINT32 slot, const SPtr<TextureCore>& texture,
  22. const TextureSurface& surface) override;
  23. /** @copydoc GpuParamsCore::setBuffer */
  24. void setBuffer(UINT32 set, UINT32 slot, const SPtr<GpuBufferCore>& buffer) override;
  25. /** @copydoc GpuParamsCore::setSamplerState */
  26. void setSamplerState(UINT32 set, UINT32 slot, const SPtr<SamplerStateCore>& sampler) override;
  27. /** @copydoc GpuParamsCore::setLoadStoreSurface */
  28. void setLoadStoreSurface(UINT32 set, UINT32 slot, const TextureSurface& surface) override;
  29. /**
  30. * Binds the internal descriptor sets to the provided command buffer. Caller must perform external locking if
  31. * some other thread could write to this object while it is being bound. The same applies to any resources
  32. * held by this object.
  33. *
  34. * @note Thread safe.
  35. */
  36. void bind(VulkanCommandBuffer& buffer);
  37. protected:
  38. /** Contains data about writing to either buffer or a texture descriptor. */
  39. union WriteInfo
  40. {
  41. VkDescriptorImageInfo image;
  42. VkDescriptorBufferInfo buffer;
  43. VkBufferView bufferView;
  44. };
  45. /** All GPU param data related to a single descriptor set. */
  46. struct PerSetData
  47. {
  48. VulkanDescriptorSet* latestSet;
  49. Vector<VulkanDescriptorSet*> sets;
  50. VkWriteDescriptorSet* writeSetInfos;
  51. WriteInfo* writeInfos;
  52. UINT32 numElements;
  53. };
  54. /** All GPU param data beloning to a single device. */
  55. struct PerDeviceData
  56. {
  57. PerSetData* perSetData;
  58. };
  59. friend class VulkanHardwareBufferCoreManager;
  60. VulkanGpuParams(const SPtr<GpuPipelineParamInfoCore>& paramInfo, GpuDeviceFlags deviceMask);
  61. /** @copydoc GpuParamsCore::initialize */
  62. void initialize() override;
  63. PerDeviceData mPerDeviceData[BS_MAX_DEVICES];
  64. GpuDeviceFlags mDeviceMask;
  65. UINT8* mData;
  66. bool* mSetsDirty;
  67. Mutex mMutex;
  68. };
  69. /** @} */
  70. }