mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 14:53:01 +02:00
Use a unique_ptr to track gpu objects
This commit is contained in:
parent
8da027c56f
commit
504939f193
1 changed files with 9 additions and 6 deletions
|
@ -11,8 +11,10 @@
|
||||||
#ifndef hifi_gpu_Format_h
|
#ifndef hifi_gpu_Format_h
|
||||||
#define hifi_gpu_Format_h
|
#define hifi_gpu_Format_h
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
|
|
||||||
|
@ -25,14 +27,15 @@ public:
|
||||||
|
|
||||||
class GPUObjectWrapper {
|
class GPUObjectWrapper {
|
||||||
public:
|
public:
|
||||||
virtual ~GPUObjectWrapper() { delete _gpuObject; }
|
virtual ~GPUObjectWrapper() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
using GPUObjectPointer = std::unique_ptr<GPUObject>;
|
||||||
|
|
||||||
// This shouldn't be used by anything else than the Backend class with the proper casting.
|
// This shouldn't be used by anything else than the Backend class with the proper casting.
|
||||||
// TODO: Consider using std::unique_ptr to get rid of dtor and ensure correct destruction of GPU objects
|
mutable GPUObjectPointer _gpuObject;
|
||||||
mutable GPUObject* _gpuObject { nullptr };
|
void setGPUObject(GPUObject* gpuObject) const { _gpuObject.reset(gpuObject); }
|
||||||
void setGPUObject(GPUObject* gpuObject) const { _gpuObject = gpuObject; }
|
GPUObject* getGPUObject() const { return _gpuObject.get(); }
|
||||||
GPUObject* getGPUObject() const { return _gpuObject; }
|
|
||||||
|
|
||||||
friend class Backend;
|
friend class Backend;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue