GrObject.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /// @addtogroup graphics
  10. /// @{
  11. /// Graphics object type.
  12. enum class GrObjectType : U8
  13. {
  14. BUFFER,
  15. COMMAND_BUFFER,
  16. FRAMEBUFFER,
  17. OCCLUSION_QUERY,
  18. TIMESTAMP_QUERY,
  19. SAMPLER,
  20. SHADER,
  21. TEXTURE,
  22. TEXTURE_VIEW,
  23. SHADER_PROGRAM,
  24. FENCE,
  25. RENDER_GRAPH,
  26. ACCELERATION_STRUCTURE,
  27. COUNT,
  28. FIRST = 0
  29. };
  30. /// Base of all graphics objects.
  31. class GrObject
  32. {
  33. public:
  34. GrObject(GrManager* manager, GrObjectType type, CString name);
  35. GrObject(const GrObject&) = delete; // Non-copyable
  36. virtual ~GrObject();
  37. GrObject& operator=(const GrObject&) = delete; // Non-copyable
  38. GrObjectType getType() const
  39. {
  40. return m_type;
  41. }
  42. GrManager& getManager()
  43. {
  44. return *m_manager;
  45. }
  46. const GrManager& getManager() const
  47. {
  48. return *m_manager;
  49. }
  50. GrAllocator<U8> getAllocator() const;
  51. Atomic<I32>& getRefcount()
  52. {
  53. return m_refcount;
  54. }
  55. /// A unique identifier for caching objects.
  56. U64 getUuid() const
  57. {
  58. return m_uuid;
  59. }
  60. /// Get its name.
  61. CString getName() const
  62. {
  63. return m_name;
  64. }
  65. private:
  66. GrManager* m_manager;
  67. Char* m_name = nullptr;
  68. U64 m_uuid;
  69. Atomic<I32> m_refcount;
  70. GrObjectType m_type;
  71. };
  72. /// @}
  73. } // end namespace anki