GrObject.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright (C) 2009-present, 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. // Graphics object type
  10. enum class GrObjectType : U8
  11. {
  12. kBuffer,
  13. kCommandBuffer,
  14. kFramebuffer,
  15. kOcclusionQuery,
  16. kTimstampQuery,
  17. kPipelineQuery,
  18. kSampler,
  19. kShader,
  20. kTexture,
  21. kShaderProgram,
  22. kFence,
  23. kRenderGraph,
  24. kAccelerationStructure,
  25. kGrUpscaler,
  26. kCount,
  27. kFirst = 0
  28. };
  29. // Base of all graphics objects
  30. class GrObject
  31. {
  32. public:
  33. GrObject(GrObjectType type, CString name);
  34. GrObject(const GrObject&) = delete; // Non-copyable
  35. virtual ~GrObject();
  36. GrObject& operator=(const GrObject&) = delete; // Non-copyable
  37. GrObjectType getType() const
  38. {
  39. return m_type;
  40. }
  41. void retain() const
  42. {
  43. m_refcount.fetchAdd(1);
  44. }
  45. I32 release() const
  46. {
  47. return m_refcount.fetchSub(1);
  48. }
  49. // A unique identifier for caching objects
  50. U32 getUuid() const
  51. {
  52. return m_uuid;
  53. }
  54. // Get its name
  55. CString getName() const
  56. {
  57. return m_name;
  58. }
  59. private:
  60. Char* m_name = nullptr;
  61. U32 m_uuid;
  62. mutable Atomic<I32> m_refcount;
  63. GrObjectType m_type;
  64. };
  65. } // end namespace anki