BsVulkanSamplerState.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 "BsVulkanResource.h"
  6. #include "BsSamplerState.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Vulkan
  10. * @{
  11. */
  12. /** Wrapper around a Vulkan sampler object that manages its usage and lifetime. */
  13. class VulkanSampler : public VulkanResource
  14. {
  15. public:
  16. VulkanSampler(VulkanResourceManager* owner, VkSampler sampler);
  17. ~VulkanSampler();
  18. /** Returns the internal handle to the Vulkan object. */
  19. VkSampler getHandle() const { return mSampler; }
  20. private:
  21. VkSampler mSampler;
  22. };
  23. /** Vulkan implementation of a sampler state. Wraps a Vulkan sampler object. */
  24. class VulkanSamplerStateCore : public SamplerStateCore
  25. {
  26. public:
  27. ~VulkanSamplerStateCore();
  28. /**
  29. * Gets the resource wrapping the sampler object, on the specified device. If sampler state device mask doesn't
  30. * include the provided device, null is returned.
  31. */
  32. VulkanSampler* getResource(UINT32 deviceIdx) const { return mSamplers[deviceIdx]; }
  33. /*
  34. * Returns a set sampler handles for the devices matching the provided mask.
  35. *
  36. * @param[in] mask Mask which determines for which devices we want the handles for. The device must exist
  37. * in both the provided mask and the mask of the sampler state was created with.
  38. * @param[out] handles Output array holding up to BS_MAX_LINKED_DEVICES handles. Only the first @p numHandles
  39. * entries of the array are defined.
  40. * @param[out] numHandles Number of entries in the @p handles array.
  41. */
  42. void getHandles(GpuDeviceFlags mask, VkSampler(&handles)[BS_MAX_LINKED_DEVICES], UINT32& numHandles);
  43. protected:
  44. friend class VulkanRenderStateCoreManager;
  45. VulkanSamplerStateCore(const SAMPLER_STATE_DESC& desc, GpuDeviceFlags deviceMask);
  46. /** @copydoc SamplerStateCore::createInternal */
  47. void createInternal() override;
  48. VulkanSampler* mSamplers[BS_MAX_DEVICES];
  49. GpuDeviceFlags mDeviceMask;
  50. };
  51. /** @} */
  52. }