BsVulkanGpuParams.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. };
  62. friend class VulkanHardwareBufferCoreManager;
  63. VulkanGpuParams(const GPU_PARAMS_DESC& desc, GpuDeviceFlags deviceMask);
  64. PerDeviceData mPerDeviceData[BS_MAX_DEVICES];
  65. GpuDeviceFlags mDeviceMask;
  66. UINT8* mData;
  67. bool* mSetsDirty;
  68. };
  69. /** @} */
  70. }