PVRVkObjectBaseVk.h#

Defines a simple interface for a PVRVk Vulkan object.

Includes#

  • PVRVk/ForwardDecObjectsVk.h

  • PVRVk/TypesVk.h

Included By#

Namespaces#

Classes#

Source Code#

#pragma once
#include "PVRVk/TypesVk.h"
#include "PVRVk/ForwardDecObjectsVk.h"

namespace pvrvk {
namespace impl {
template<class VkHandleType, ObjectType PVRVkObjectType>
class PVRVkObjectBase
{
public:
    DECLARE_NO_COPY_SEMANTICS(PVRVkObjectBase)
    inline const VkHandleType& getVkHandle() const { return _vkHandle; }

    inline ObjectType getObjectType() const { return _objectType; }

protected:
    VkHandleType _vkHandle;

    ObjectType _objectType;

    PVRVkObjectBase() : _vkHandle(VK_NULL_HANDLE), _objectType(PVRVkObjectType) {}

    explicit PVRVkObjectBase(const VkHandleType& handle) : _vkHandle(handle), _objectType(PVRVkObjectType) { assert(_objectType != ObjectType::e_UNKNOWN); }
};

template<class VkHandleType, ObjectType PVRVkObjectType>
class PVRVkInstanceObjectBase : public PVRVkObjectBase<VkHandleType, PVRVkObjectType>
{
public:
    DECLARE_NO_COPY_SEMANTICS(PVRVkInstanceObjectBase)


    inline const Instance getInstance() const { return _instance.lock(); }

    inline Instance getInstance() { return _instance.lock(); }

protected:
    InstanceWeakPtr _instance;

    PVRVkInstanceObjectBase() : PVRVkObjectBase<VkHandleType, PVRVkObjectType>() {}
    explicit PVRVkInstanceObjectBase(const InstanceWeakPtr& instance) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(), _instance(instance) {}
    explicit PVRVkInstanceObjectBase(const VkHandleType& handle) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(handle) {}
    PVRVkInstanceObjectBase(const InstanceWeakPtr& instance, const VkHandleType& handle) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(handle), _instance(instance) {}
};

template<class VkHandleType, ObjectType PVRVkObjectType>
class PVRVkPhysicalDeviceObjectBase : public PVRVkObjectBase<VkHandleType, PVRVkObjectType>
{
public:
    DECLARE_NO_COPY_SEMANTICS(PVRVkPhysicalDeviceObjectBase)


    inline const PhysicalDevice getPhysicalDevice() const { return _physicalDevice.lock(); }

    inline PhysicalDevice getPhysicalDevice() { return _physicalDevice.lock(); }

protected:
    PhysicalDeviceWeakPtr _physicalDevice;

    PVRVkPhysicalDeviceObjectBase() : PVRVkObjectBase<VkHandleType, PVRVkObjectType>() {}
    explicit PVRVkPhysicalDeviceObjectBase(const PhysicalDeviceWeakPtr& physicalDevice) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(), _physicalDevice(physicalDevice) {}
    explicit PVRVkPhysicalDeviceObjectBase(const VkHandleType& handle) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(handle) {}
    PVRVkPhysicalDeviceObjectBase(const PhysicalDeviceWeakPtr& physicalDevice, const VkHandleType& handle)
        : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(handle), _physicalDevice(physicalDevice)
    {}
};

template<class VkHandleType, ObjectType PVRVkObjectType>
class PVRVkDeviceObjectBase : public PVRVkObjectBase<VkHandleType, PVRVkObjectType>
{
public:
    DECLARE_NO_COPY_SEMANTICS(PVRVkDeviceObjectBase)


    inline const Device getDevice() const { return _device.lock(); }

    inline Device getDevice() { return _device.lock(); }

protected:
    DeviceWeakPtr _device;

    PVRVkDeviceObjectBase() : PVRVkObjectBase<VkHandleType, PVRVkObjectType>() {}
    explicit PVRVkDeviceObjectBase(const DeviceWeakPtr& device) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(), _device(device) {}
    explicit PVRVkDeviceObjectBase(const VkHandleType& handle) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(handle) {}
    PVRVkDeviceObjectBase(const DeviceWeakPtr& device, const VkHandleType& handle) : PVRVkObjectBase<VkHandleType, PVRVkObjectType>(handle), _device(device) {}
};
} // namespace impl
} // namespace pvrvk