BsGpuResource.h 2.0 KB

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