BsVulkanGpuParams.h 2.9 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. * Notifies the object that a command buffer containing the object is about to be submitted to a queue.
  31. *
  32. * @param[in] buffer Command buffer on which we're about to submit the GPU params.
  33. * @param[out] transitionInfo Contains barriers that transition resources to appropriate queues families
  34. * and/or transition image layouts.
  35. */
  36. void prepareForSubmit(VulkanCmdBuffer* buffer, UnorderedMap<UINT32, TransitionInfo>& transitionInfo);
  37. /** Binds the internal descriptor sets to the provided command buffer. */
  38. void bind(VulkanCommandBuffer& buffer);
  39. protected:
  40. /** Contains data about writing to either buffer or a texture descriptor. */
  41. union WriteInfo
  42. {
  43. VkDescriptorImageInfo image;
  44. VkDescriptorBufferInfo buffer;
  45. VkBufferView bufferView;
  46. };
  47. /** All GPU param data related to a single descriptor set. */
  48. struct PerSetData
  49. {
  50. VulkanDescriptorLayout* layout;
  51. VulkanDescriptorSet* set;
  52. VkWriteDescriptorSet* writeSetInfos;
  53. WriteInfo* writeInfos;
  54. UINT32 numElements;
  55. };
  56. /** All GPU param data beloning to a single device. */
  57. struct PerDeviceData
  58. {
  59. PerSetData* perSetData;
  60. UINT32 numSets;
  61. VkPipelineLayout pipelineLayout;
  62. };
  63. friend class VulkanHardwareBufferCoreManager;
  64. VulkanGpuParams(const GPU_PARAMS_DESC& desc, GpuDeviceFlags deviceMask);
  65. PerDeviceData mPerDeviceData[BS_MAX_DEVICES];
  66. GpuDeviceFlags mDeviceMask;
  67. UINT8* mData;
  68. bool* mSetsDirty;
  69. };
  70. /** @} */
  71. }