BsGpuResource.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsResource.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Represents a resource that in some way deals directly with the rendering
  8. * API and the GPU.
  9. *
  10. * @note e.g. texture, mesh, buffer, etc.
  11. */
  12. class BS_CORE_EXPORT GpuResource : public Resource
  13. {
  14. public:
  15. /**
  16. * @brief Called just before writeSubresource is queued. Called from sim thread.
  17. *
  18. * @note Sim thread only.
  19. */
  20. virtual void _writeSubresourceSim(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer) { }
  21. /**
  22. * @brief Updates a part of the current resource with the provided data. Specific resource
  23. * implementations provide a way to retrieve a subresource index.
  24. *
  25. * @note Core thread only.
  26. */
  27. virtual void writeSubresource(UINT32 subresourceIdx, const GpuResourceData& data, bool discardEntireBuffer) = 0;
  28. /**
  29. * @brief Reads a part of the current resource into the provided "data" parameter.
  30. * Data buffer needs to be pre-allocated. Specific resource implementations
  31. * provide a way to retrieve a subresource index and a way to allocate
  32. * the GpuResourceData buffer.
  33. *
  34. * @note Core thread only.
  35. */
  36. virtual void readSubresource(UINT32 subresourceIdx, GpuResourceData& data) = 0;
  37. /************************************************************************/
  38. /* SERIALIZATION */
  39. /************************************************************************/
  40. public:
  41. friend class GpuResourceRTTI;
  42. static RTTITypeBase* getRTTIStatic();
  43. virtual RTTITypeBase* getRTTI() const;
  44. };
  45. }