CmBindableGpuParams.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Specialized class for binding GPU parameters to the render system. This is a temporary class that
  7. * is used for temporarily saving parameter data while parameters are scheduled to be bound to the GPU.
  8. * This allows us to freely modify base GpuParams without worrying about changing scheduled by still
  9. * not executed parameter binds.
  10. *
  11. * @note Upon assignment this class transfers ownership of its internal data. Internal data
  12. * is destroyed when last assigned instance goes out of scope.
  13. * (In short, you should never have more than one active copy of an instance of this class)
  14. *
  15. * Created on the sim thread and used exclusively on the core thread.
  16. *
  17. * @see CoreThreadAccessorBase::bindGpuParams
  18. **/
  19. class BS_CORE_EXPORT BindableGpuParams
  20. {
  21. public:
  22. BindableGpuParams(const GpuParamsPtr& sourceParams, FrameAlloc* allocator);
  23. BindableGpuParams(const BindableGpuParams& source);
  24. ~BindableGpuParams();
  25. /**
  26. * @brief Uploads all CPU stored parameter buffer data to the GPU buffers.
  27. */
  28. void updateHardwareBuffers();
  29. /**
  30. * @brief Gets a parameter block buffer from the specified slot.
  31. */
  32. GpuParamBlockBufferPtr getParamBlockBuffer(UINT32 slot) const;
  33. /**
  34. * @brief Gets a parameter block buffer by name.
  35. */
  36. GpuParamBlockBufferPtr getParamBlockBuffer(const String& name) const;
  37. /**
  38. * @brief Gets a texture bound to the specified slot.
  39. */
  40. HTexture getTexture(UINT32 slot);
  41. /**
  42. * @brief Gets a sampler state bound to the specified slot.
  43. */
  44. HSamplerState getSamplerState(UINT32 slot);
  45. /**
  46. * @brief Gets a description of all parameters stored in this class.
  47. */
  48. const GpuParamDesc& getParamDesc() const { return mParamDesc; }
  49. private:
  50. mutable bool mOwnsData;
  51. const GpuParamDesc& mParamDesc;
  52. UINT8* mData;
  53. UINT32 mNumParamBlocks;
  54. UINT32 mNumTextures;
  55. UINT32 mNumSamplerStates;
  56. FrameAlloc* mAllocator;
  57. BindableGpuParamBlock** mParamBlocks;
  58. GpuParamBlockBufferPtr* mParamBlockBuffers;
  59. HTexture* mTextures;
  60. HSamplerState* mSamplerStates;
  61. };
  62. }