GrObject.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Gr/Common.h>
  7. #include <AnKi/Util/Atomic.h>
  8. namespace anki
  9. {
  10. /// @addtogroup graphics
  11. /// @{
  12. /// Graphics object type.
  13. enum class GrObjectType : U8
  14. {
  15. BUFFER,
  16. COMMAND_BUFFER,
  17. FRAMEBUFFER,
  18. OCCLUSION_QUERY,
  19. TIMESTAMP_QUERY,
  20. SAMPLER,
  21. SHADER,
  22. TEXTURE,
  23. TEXTURE_VIEW,
  24. SHADER_PROGRAM,
  25. FENCE,
  26. RENDER_GRAPH,
  27. ACCELERATION_STRUCTURE,
  28. COUNT,
  29. FIRST = 0
  30. };
  31. /// Base of all graphics objects.
  32. class GrObject
  33. {
  34. public:
  35. GrObject(GrManager* manager, GrObjectType type, CString name);
  36. GrObject(const GrObject&) = delete; // Non-copyable
  37. virtual ~GrObject();
  38. GrObject& operator=(const GrObject&) = delete; // Non-copyable
  39. GrObjectType getType() const
  40. {
  41. return m_type;
  42. }
  43. GrManager& getManager()
  44. {
  45. return *m_manager;
  46. }
  47. const GrManager& getManager() const
  48. {
  49. return *m_manager;
  50. }
  51. GrAllocator<U8> getAllocator() const;
  52. Atomic<I32>& getRefcount()
  53. {
  54. return m_refcount;
  55. }
  56. /// A unique identifier for caching objects.
  57. U64 getUuid() const
  58. {
  59. return m_uuid;
  60. }
  61. /// Get its name.
  62. CString getName() const
  63. {
  64. return m_name;
  65. }
  66. private:
  67. GrManager* m_manager;
  68. Char* m_name = nullptr;
  69. U64 m_uuid;
  70. Atomic<I32> m_refcount;
  71. GrObjectType m_type;
  72. };
  73. /// @}
  74. } // end namespace anki