PhysicalDeviceVk.h#

The Physical Device class.

Includes#

  • PVRVk/DebugUtilsVk.h

  • PVRVk/ForwardDecObjectsVk.h

  • PVRVk/InstanceVk.h

  • PVRVk/PVRVkObjectBaseVk.h

  • PVRVk/TypesVk.h

Included By#

Namespaces#

Classes#

Source Code#

#pragma once
#include "PVRVk/ForwardDecObjectsVk.h"
#include "PVRVk/InstanceVk.h"
#include "PVRVk/PVRVkObjectBaseVk.h"
#include "PVRVk/TypesVk.h"
#include "PVRVk/DebugUtilsVk.h"

namespace pvrvk {
namespace impl {

class PhysicalDevice_ : public PVRVkInstanceObjectBase<VkPhysicalDevice, ObjectType::e_PHYSICAL_DEVICE>, public std::enable_shared_from_this<PhysicalDevice_>
{
private:
    friend class Instance_;

    class make_shared_enabler
    {
    protected:
        make_shared_enabler() {}
        friend class PhysicalDevice_;
    };

    static PhysicalDevice constructShared(Instance& instance, const VkPhysicalDevice& vkPhysicalDevice)
    {
        return std::make_shared<PhysicalDevice_>(make_shared_enabler{}, instance, vkPhysicalDevice);
    }

    void updateDisplayPlaneProperties();

    void retrieveDisplays();

    std::vector<QueueFamilyProperties> _queueFamilyPropeties;
    PhysicalDeviceProperties _deviceProperties;
    std::vector<Display> _displays;
    std::vector<DisplayPlanePropertiesKHR> _displayPlaneProperties;
    PhysicalDeviceMemoryProperties _deviceMemoryProperties;
    PhysicalDeviceFeatures _deviceFeatures;
    std::vector<FormatProperties> _supportedFormats;
    std::vector<ExtensionProperties> _deviceExtensions;
    uint32_t _graphicsQueueIndex;
    uint32_t _universalQueueFamilyId;

public:
    DECLARE_NO_COPY_SEMANTICS(PhysicalDevice_)


    PhysicalDevice_(make_shared_enabler, Instance& instance, const VkPhysicalDevice& vkPhysicalDevice);

    ~PhysicalDevice_()
    {
        _vkHandle = VK_NULL_HANDLE;

        _supportedFormats.clear();
        _deviceExtensions.clear();
    }

    const PhysicalDeviceProperties& getProperties() const { return _deviceProperties; }

    const std::vector<Display>& getDisplays() const;

    const Display& getDisplay(uint32_t id) const;

    Display& getDisplay(uint32_t id);

    uint32_t getNumDisplays() const { return static_cast<uint32_t>(_displays.size()); }

    const PhysicalDeviceMemoryProperties& getMemoryProperties() const { return _deviceMemoryProperties; }

    bool getSurfaceSupport(uint32_t queueFamilyIndex, Surface surface) const;

    FormatProperties getFormatProperties(pvrvk::Format format);

    SurfaceCapabilitiesKHR getSurfaceCapabilities(const Surface& surface) const;

    const PhysicalDeviceFeatures& getFeatures() const { return _deviceFeatures; }

    DisplayMode createDisplayMode(pvrvk::Display& display, const pvrvk::DisplayModeCreateInfo& displayModeCreateInfo);

    Device createDevice(const DeviceCreateInfo& deviceCreateInfo);

    const std::vector<QueueFamilyProperties>& getQueueFamilyProperties() const { return _queueFamilyPropeties; }

    std::vector<PresentModeKHR> getSurfacePresentModes(const Surface& surface) const;

    std::vector<SurfaceFormatKHR> getSurfaceFormats(const Surface& surface) const;

    std::vector<ExtensionProperties>& getDeviceExtensionsProperties();

    const ImageFormatProperties getImageFormatProperties(
        pvrvk::Format format, pvrvk::ImageType imageType, pvrvk::ImageTiling tiling, pvrvk::ImageUsageFlags usage, pvrvk::ImageCreateFlags flags);

    const std::vector<SparseImageFormatProperties> getSparseImageFormatProperties(
        pvrvk::Format format, pvrvk::ImageType imageType, pvrvk::SampleCountFlags sampleCount, pvrvk::ImageUsageFlags usage, pvrvk::ImageTiling tiling);

    uint32_t getMemoryTypeIndex(uint32_t allowedMemoryTypeBits, pvrvk::MemoryPropertyFlags requiredMemoryProperties, pvrvk::MemoryPropertyFlags& usedMemoryProperties) const;

    uint32_t getNumDisplayPlanes() { return static_cast<uint32_t>(_displayPlaneProperties.size()); }

    Display getDisplayPlaneProperties(uint32_t displayPlaneIndex, uint32_t& currentStackIndex);

    std::vector<Display> getDisplayPlaneSupportedDisplays(uint32_t planeIndex);

    DisplayPlaneCapabilitiesKHR getDisplayPlaneCapabilities(DisplayMode& mode, uint32_t planeIndex);

    bool populateExtensionFeatures(ExtensionFeatures& extensionFeatures);

    template<class VkPhysicalDeviceExtensionFeatures>
    bool populateExtensionFeaturesVk(pvrvk::StructureType type, VkPhysicalDeviceExtensionFeatures* featuresStruct)
    {
        featuresStruct->sType = static_cast<VkStructureType>(type);
        return _populateExtensionFeaturesVk(static_cast<void*>(featuresStruct));
    }

    template<class VkPhysicalDeviceExtensionProperties>
    bool populateExtensionPropertiesVk(pvrvk::StructureType type, VkPhysicalDeviceExtensionProperties* propertiesStruct)
    {
        propertiesStruct->sType = static_cast<VkStructureType>(type);
        return _populateExtensionPropertiesVk(static_cast<void*>(propertiesStruct));
    }

    std::vector<FragmentShadingRate> getAvailableFragmentShadingRates();

private:
    bool _populateExtensionFeaturesVk(void* featuresStruct);

    bool _populateExtensionPropertiesVk(void* propertiesStruct);
};
} // namespace impl
} // namespace pvrvk