DeviceVk.h#
The PVRVk Device class. One of the bysiest classes in Vulkan, together with the Command Buffer.
Includes#
PVRVk/DebugUtilsVk.h
PVRVk/ExtensionsVk.h
PVRVk/LayersVk.h
PVRVk/PVRVkObjectBaseVk.h
PVRVk/PhysicalDeviceVk.h
Included By#
Namespaces#
Classes#
Source Code#
#pragma once
#include "PVRVk/PhysicalDeviceVk.h"
#include "PVRVk/ExtensionsVk.h"
#include "PVRVk/LayersVk.h"
#include "PVRVk/PVRVkObjectBaseVk.h"
#include "PVRVk/DebugUtilsVk.h"
namespace pvrvk {
struct SamplerCreateInfo;
namespace impl {
//\cond NO_DOXYGEN
inline void reportDestroyedAfterDevice() { assert(false && "Attempted to destroy object after its corresponding device"); }
//\endcond
class Device_ : public PVRVkPhysicalDeviceObjectBase<VkDevice, ObjectType::e_DEVICE>, public std::enable_shared_from_this<Device_>
{
private:
friend class PhysicalDevice_;
class make_shared_enabler
{
protected:
make_shared_enabler() {}
friend class Device_;
};
static Device constructShared(PhysicalDevice& physicalDevice, const DeviceCreateInfo& createInfo)
{
return std::make_shared<Device_>(make_shared_enabler{}, physicalDevice, createInfo);
}
struct QueueFamily
{
uint32_t queueFamily;
std::vector<Queue> queues;
};
DeviceExtensionTable _extensionTable;
std::vector<QueueFamily> _queueFamilies;
DeviceCreateInfo _createInfo;
VkDeviceBindings _vkBindings;
PhysicalDeviceTransformFeedbackProperties _transformFeedbackProperties;
PhysicalDeviceTransformFeedbackFeatures _transformFeedbackFeatures;
public:
DECLARE_NO_COPY_SEMANTICS(Device_)
Device_(make_shared_enabler, PhysicalDevice& physicalDevice, const DeviceCreateInfo& createInfo);
~Device_()
{
_queueFamilies.clear();
if (getVkHandle() != VK_NULL_HANDLE)
{
_vkBindings.vkDestroyDevice(getVkHandle(), nullptr);
_vkHandle = VK_NULL_HANDLE;
}
}
void retrieveQueues();
void waitIdle();
ComputePipeline createComputePipeline(const ComputePipelineCreateInfo& createInfo, const PipelineCache& pipelineCache = PipelineCache());
void createComputePipelines(const ComputePipelineCreateInfo* createInfo, uint32_t numCreateInfos, const PipelineCache& pipelineCache, ComputePipeline* outPipelines);
RaytracingPipeline createRaytracingPipeline(const RaytracingPipelineCreateInfo& createInfo, const PipelineCache& pipelineCache = PipelineCache());
void createRaytracingPipelines(const RaytracingPipelineCreateInfo* createInfo, uint32_t numCreateInfos, const PipelineCache& pipelineCache, RaytracingPipeline* outPipelines);
GraphicsPipeline createGraphicsPipeline(const GraphicsPipelineCreateInfo& createInfo, const PipelineCache& pipelineCache = PipelineCache());
void createGraphicsPipelines(const GraphicsPipelineCreateInfo* createInfos, uint32_t numCreateInfos, const PipelineCache& pipelineCache, GraphicsPipeline* outPipelines);
Sampler createSampler(const SamplerCreateInfo& createInfo);
Image createImage(const ImageCreateInfo& createInfo);
ImageView createImageView(const ImageViewCreateInfo& createInfo);
BufferView createBufferView(const BufferViewCreateInfo& createInfo);
Buffer createBuffer(const BufferCreateInfo& createInfo);
AccelerationStructure createAccelerationStructure(const AccelerationStructureCreateInfo& createInfo, pvrvk::Buffer asBuffer);
DeviceMemory allocateMemory(const MemoryAllocationInfo& allocationInfo, const pvrvk::MemoryAllocateFlags memoryAllocateFlags = pvrvk::MemoryAllocateFlags::e_NONE);
ShaderModule createShaderModule(const ShaderModuleCreateInfo& createInfo);
Framebuffer createFramebuffer(const FramebufferCreateInfo& createInfo);
RenderPass createRenderPass(const RenderPassCreateInfo& createInfo);
DescriptorPool createDescriptorPool(const DescriptorPoolCreateInfo& createInfo);
DescriptorSetLayout createDescriptorSetLayout(const DescriptorSetLayoutCreateInfo& createInfo);
PipelineCache createPipelineCache(const PipelineCacheCreateInfo& createInfo = PipelineCacheCreateInfo());
void mergePipelineCache(const PipelineCache* srcPipeCaches, uint32_t numSrcPipeCaches, PipelineCache destPipeCache);
PipelineLayout createPipelineLayout(const PipelineLayoutCreateInfo& createInfo);
bool waitForFences(uint32_t numFences, const Fence* fences, const bool waitAll, const uint64_t timeout);
void resetFences(uint32_t numFences, const Fence* fences);
CommandPool createCommandPool(const CommandPoolCreateInfo& createInfo);
Fence createFence(const FenceCreateInfo& createInfo = FenceCreateInfo());
Event createEvent(const EventCreateInfo& createInfo = EventCreateInfo());
Semaphore createSemaphore(const SemaphoreCreateInfo& createInfo = SemaphoreCreateInfo());
TimelineSemaphore createTimelineSemaphore(SemaphoreCreateInfo& createInfo);
QueryPool createQueryPool(const QueryPoolCreateInfo& createInfo);
Swapchain createSwapchain(const SwapchainCreateInfo& createInfo, const Surface& surface);
Queue getQueue(uint32_t queueFamily, uint32_t queueId)
{
for (uint32_t i = 0; i < _queueFamilies.size(); ++i)
{
if (_queueFamilies[i].queueFamily == queueFamily) { return _queueFamilies[i].queues[queueId]; }
}
throw ErrorValidationFailedEXT("Request for queue from family id that did not exist.");
}
const VulkanExtensionList& getEnabledExtensionList() { return _createInfo.getExtensionList(); }
const DeviceExtensionTable& getEnabledExtensionTable() const { return _extensionTable; }
void updateDescriptorSets(const WriteDescriptorSet* writeDescSets, uint32_t numWriteDescSets, const CopyDescriptorSet* copyDescSets, uint32_t numCopyDescSets);
inline const VkDeviceBindings& getVkBindings() const { return _vkBindings; }
inline const PhysicalDeviceTransformFeedbackProperties& getTransformFeedbackProperties() const { return _transformFeedbackProperties; }
inline PhysicalDeviceTransformFeedbackProperties getTransformFeedbackProperties() { return _transformFeedbackProperties; }
inline const PhysicalDeviceTransformFeedbackFeatures& getTransformFeedbackFeatures() const { return _transformFeedbackFeatures; }
inline PhysicalDeviceTransformFeedbackFeatures getTransformFeedbackFeatures() { return _transformFeedbackFeatures; }
inline const DeviceCreateInfo& getDeviceCreateInfo() const
{
return _createInfo;
}
;
};
} // namespace impl
} // namespace pvrvk