CmBindableGpuParams.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. namespace CamelotFramework
  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 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. class CM_EXPORT BindableGpuParams
  18. {
  19. public:
  20. BindableGpuParams(const GpuParamsPtr& sourceParams, FrameAlloc* allocator);
  21. BindableGpuParams(const BindableGpuParams& source);
  22. ~BindableGpuParams();
  23. /**
  24. * @brief Updates all used hardware parameter buffers. Should ONLY be called from core thread.
  25. */
  26. void updateHardwareBuffers();
  27. GpuParamBlockBufferPtr getParamBlockBuffer(UINT32 slot) const;
  28. GpuParamBlockBufferPtr getParamBlockBuffer(const String& name) const;
  29. HTexture getTexture(UINT32 slot);
  30. HSamplerState getSamplerState(UINT32 slot);
  31. const GpuParamDesc& getParamDesc() const { return mParamDesc; }
  32. private:
  33. mutable bool mOwnsData;
  34. const GpuParamDesc& mParamDesc;
  35. UINT8* mData;
  36. UINT32 mNumParamBlocks;
  37. UINT32 mNumTextures;
  38. UINT32 mNumSamplerStates;
  39. FrameAlloc* mAllocator;
  40. BindableGpuParamBlock** mParamBlocks;
  41. GpuParamBlockBufferPtr* mParamBlockBuffers;
  42. HTexture* mTextures;
  43. HSamplerState* mSamplerStates;
  44. };
  45. }