mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-09 12:56:57 +02:00
Replce GPUObjectWrapper by public const member
This commit is contained in:
parent
504939f193
commit
ef5af45acd
9 changed files with 30 additions and 19 deletions
|
@ -98,13 +98,13 @@ public:
|
|||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
static void setGPUObject(const GPUObjectWrapper& wrapper, T* object) {
|
||||
wrapper.setGPUObject(object);
|
||||
template<typename T, typename U>
|
||||
static void setGPUObject(const U& object, T* gpuObject) {
|
||||
object.gpuObject.setGPUObject(gpuObject);
|
||||
}
|
||||
template<typename T>
|
||||
static T* getGPUObject(const GPUObjectWrapper& wrapper) {
|
||||
return reinterpret_cast<T*>(wrapper.getGPUObject());
|
||||
template<typename T, typename U>
|
||||
static T* getGPUObject(const U& object) {
|
||||
return reinterpret_cast<T*>(object.gpuObject.getGPUObject());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,15 +25,12 @@ public:
|
|||
virtual ~GPUObject() = default;
|
||||
};
|
||||
|
||||
class GPUObjectWrapper {
|
||||
public:
|
||||
virtual ~GPUObjectWrapper() = default;
|
||||
|
||||
class GPUObjectPointer {
|
||||
private:
|
||||
using GPUObjectPointer = std::unique_ptr<GPUObject>;
|
||||
using GPUObjectUniquePointer = std::unique_ptr<GPUObject>;
|
||||
|
||||
// This shouldn't be used by anything else than the Backend class with the proper casting.
|
||||
mutable GPUObjectPointer _gpuObject;
|
||||
mutable GPUObjectUniquePointer _gpuObject;
|
||||
void setGPUObject(GPUObject* gpuObject) const { _gpuObject.reset(gpuObject); }
|
||||
GPUObject* getGPUObject() const { return _gpuObject.get(); }
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
|||
typedef std::shared_ptr<Swapchain> SwapchainPointer;
|
||||
|
||||
|
||||
class Framebuffer : public GPUObjectWrapper {
|
||||
class Framebuffer {
|
||||
public:
|
||||
enum BufferMask {
|
||||
BUFFER_COLOR0 = 1,
|
||||
|
@ -134,6 +134,8 @@ public:
|
|||
static const uint32 MAX_NUM_RENDER_BUFFERS = 8;
|
||||
static uint32 getMaxNumRenderBuffers() { return MAX_NUM_RENDER_BUFFERS; }
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
|
||||
protected:
|
||||
SwapchainPointer _swapchain;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
namespace gpu {
|
||||
|
||||
class Pipeline : public GPUObjectWrapper {
|
||||
class Pipeline {
|
||||
public:
|
||||
using Pointer = std::shared_ptr< Pipeline >;
|
||||
|
||||
|
@ -31,6 +31,8 @@ public:
|
|||
|
||||
const StatePointer& getState() const { return _state; }
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
|
||||
protected:
|
||||
ShaderPointer _program;
|
||||
StatePointer _state;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace gpu {
|
||||
|
||||
class Query : public GPUObjectWrapper {
|
||||
class Query {
|
||||
public:
|
||||
Query();
|
||||
~Query();
|
||||
|
@ -27,6 +27,8 @@ namespace gpu {
|
|||
uint32 queryResult;
|
||||
|
||||
double getElapsedTime();
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Query> QueryPointer;
|
||||
|
|
|
@ -108,7 +108,7 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
class Buffer : public Resource, public GPUObjectWrapper {
|
||||
class Buffer : public Resource {
|
||||
public:
|
||||
|
||||
Buffer();
|
||||
|
@ -153,6 +153,8 @@ public:
|
|||
const Sysmem& getSysmem() const { assert(_sysmem); return (*_sysmem); }
|
||||
Sysmem& editSysmem() { assert(_sysmem); return (*_sysmem); }
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
|
||||
protected:
|
||||
|
||||
Sysmem* _sysmem = NULL;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
namespace gpu {
|
||||
|
||||
class Shader : public GPUObjectWrapper {
|
||||
class Shader {
|
||||
public:
|
||||
|
||||
typedef std::shared_ptr< Shader > Pointer;
|
||||
|
@ -155,6 +155,8 @@ public:
|
|||
// independant of the graphics api in use underneath (looking at you opengl & vulkan).
|
||||
static bool makeProgram(Shader& shader, const Shader::BindingSet& bindings = Shader::BindingSet());
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
|
||||
protected:
|
||||
Shader(Type type, const Source& source);
|
||||
Shader(Type type, const Pointer& vertex, const Pointer& pixel);
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace gpu {
|
|||
|
||||
class GPUObject;
|
||||
|
||||
class State : public GPUObjectWrapper {
|
||||
class State {
|
||||
public:
|
||||
State();
|
||||
virtual ~State();
|
||||
|
@ -385,6 +385,8 @@ public:
|
|||
State(const Data& values);
|
||||
const Data& getValues() const { return _values; }
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
|
||||
protected:
|
||||
State(const State& state);
|
||||
State& operator=(const State& state);
|
||||
|
|
|
@ -136,7 +136,7 @@ protected:
|
|||
Desc _desc;
|
||||
};
|
||||
|
||||
class Texture : public Resource, public GPUObjectWrapper {
|
||||
class Texture : public Resource {
|
||||
public:
|
||||
|
||||
class Pixels {
|
||||
|
@ -356,6 +356,8 @@ public:
|
|||
// Only callable by the Backend
|
||||
void notifyMipFaceGPULoaded(uint16 level, uint8 face) const { return _storage->notifyMipFaceGPULoaded(level, face); }
|
||||
|
||||
const GPUObjectPointer gpuObject {};
|
||||
|
||||
protected:
|
||||
std::unique_ptr< Storage > _storage;
|
||||
|
||||
|
|
Loading…
Reference in a new issue