Format: src/backend/vulkan

This commit is contained in:
Corentin Wallez 2017-11-24 14:18:09 -05:00 committed by Corentin Wallez
parent c7807abf04
commit 23b27a27e2
13 changed files with 317 additions and 299 deletions

View File

@ -19,19 +19,21 @@
#include <cstring>
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
BufferUploader::BufferUploader(Device* device)
: mDevice(device) {
BufferUploader::BufferUploader(Device* device) : mDevice(device) {
}
BufferUploader::~BufferUploader() {
ASSERT(mBuffersToDelete.Empty());
}
void BufferUploader::BufferSubData(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size, const void* data) {
// TODO(cwallez@chromium.org): this is soooooo bad. We should use some sort of ring buffer for this.
void BufferUploader::BufferSubData(VkBuffer buffer,
VkDeviceSize offset,
VkDeviceSize size,
const void* data) {
// TODO(cwallez@chromium.org): this is soooooo bad. We should use some sort of ring buffer
// for this.
// Create a staging buffer
VkBufferCreateInfo createInfo;
@ -45,19 +47,22 @@ namespace vulkan {
createInfo.pQueueFamilyIndices = 0;
VkBuffer stagingBuffer = VK_NULL_HANDLE;
if (mDevice->fn.CreateBuffer(mDevice->GetVkDevice(), &createInfo, nullptr, &stagingBuffer) != VK_SUCCESS) {
if (mDevice->fn.CreateBuffer(mDevice->GetVkDevice(), &createInfo, nullptr,
&stagingBuffer) != VK_SUCCESS) {
ASSERT(false);
}
VkMemoryRequirements requirements;
mDevice->fn.GetBufferMemoryRequirements(mDevice->GetVkDevice(), stagingBuffer, &requirements);
mDevice->fn.GetBufferMemoryRequirements(mDevice->GetVkDevice(), stagingBuffer,
&requirements);
DeviceMemoryAllocation allocation;
if (!mDevice->GetMemoryAllocator()->Allocate(requirements, true, &allocation)) {
ASSERT(false);
}
if (mDevice->fn.BindBufferMemory(mDevice->GetVkDevice(), stagingBuffer, allocation.GetMemory(),
if (mDevice->fn.BindBufferMemory(mDevice->GetVkDevice(), stagingBuffer,
allocation.GetMemory(),
allocation.GetMemoryOffset()) != VK_SUCCESS) {
ASSERT(false);
}
@ -75,10 +80,8 @@ namespace vulkan {
barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
mDevice->fn.CmdPipelineBarrier(commands,
VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
1, &barrier,
0, nullptr,
mDevice->fn.CmdPipelineBarrier(commands, VK_PIPELINE_STAGE_HOST_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &barrier, 0, nullptr,
0, nullptr);
VkBufferCopy copy;
@ -100,5 +103,4 @@ namespace vulkan {
mBuffersToDelete.ClearUpTo(completedSerial);
}
}
}
}} // namespace backend::vulkan

View File

@ -18,8 +18,7 @@
#include "backend/vulkan/vulkan_platform.h"
#include "common/SerialQueue.h"
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
class Device;
@ -28,7 +27,10 @@ namespace vulkan {
BufferUploader(Device* device);
~BufferUploader();
void BufferSubData(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size, const void* data);
void BufferSubData(VkBuffer buffer,
VkDeviceSize offset,
VkDeviceSize size,
const void* data);
void Tick(Serial completedSerial);
@ -37,7 +39,6 @@ namespace vulkan {
SerialQueue<VkBuffer> mBuffersToDelete;
};
}
}
}} // namespace backend::vulkan
#endif // BACKEND_VULKAN_BUFFERUPLOADER_H_

View File

@ -19,8 +19,7 @@
#include <cstring>
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
namespace {
@ -49,10 +48,9 @@ namespace vulkan {
return flags;
}
}
} // namespace
Buffer::Buffer(BufferBuilder* builder)
: BufferBase(builder) {
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
Device* device = ToBackend(GetDevice());
VkBufferCreateInfo createInfo;
@ -65,19 +63,24 @@ namespace vulkan {
createInfo.queueFamilyIndexCount = 0;
createInfo.pQueueFamilyIndices = 0;
if (device->fn.CreateBuffer(device->GetVkDevice(), &createInfo, nullptr, &mHandle) != VK_SUCCESS) {
if (device->fn.CreateBuffer(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
VK_SUCCESS) {
ASSERT(false);
}
VkMemoryRequirements requirements;
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
bool requestMappable = (GetAllowedUsage() & (nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) != 0;
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable, &mMemoryAllocation)) {
bool requestMappable =
(GetAllowedUsage() & (nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) !=
0;
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
&mMemoryAllocation)) {
ASSERT(false);
}
if (device->fn.BindBufferMemory(device->GetVkDevice(), mHandle, mMemoryAllocation.GetMemory(),
if (device->fn.BindBufferMemory(device->GetVkDevice(), mHandle,
mMemoryAllocation.GetMemory(),
mMemoryAllocation.GetMemoryOffset()) != VK_SUCCESS) {
ASSERT(false);
}
@ -118,8 +121,7 @@ namespace vulkan {
void Buffer::TransitionUsageImpl(nxt::BufferUsageBit, nxt::BufferUsageBit) {
}
MapReadRequestTracker::MapReadRequestTracker(Device* device)
: mDevice(device) {
MapReadRequestTracker::MapReadRequestTracker(Device* device) : mDevice(device) {
}
MapReadRequestTracker::~MapReadRequestTracker() {
@ -142,5 +144,4 @@ namespace vulkan {
mInflightRequests.ClearUpTo(finishedSerial);
}
}
}
}} // namespace backend::vulkan

View File

@ -17,12 +17,11 @@
#include "backend/Buffer.h"
#include "backend/vulkan/vulkan_platform.h"
#include "backend/vulkan/MemoryAllocator.h"
#include "backend/vulkan/vulkan_platform.h"
#include "common/SerialQueue.h"
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
class Device;
@ -37,7 +36,8 @@ namespace vulkan {
void SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) override;
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
void UnmapImpl() override;
void TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) override;
void TransitionUsageImpl(nxt::BufferUsageBit currentUsage,
nxt::BufferUsageBit targetUsage) override;
VkBuffer mHandle = VK_NULL_HANDLE;
DeviceMemoryAllocation mMemoryAllocation;
@ -62,7 +62,6 @@ namespace vulkan {
SerialQueue<Request> mInflightRequests;
};
}
}
}} // namespace backend::vulkan
#endif // BACKEND_VULKAN_BUFFERVK_H_

View File

@ -15,8 +15,7 @@
#include "backend/vulkan/MemoryAllocator.h"
#include "backend/vulkan/VulkanBackend.h"
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
DeviceMemoryAllocation::~DeviceMemoryAllocation() {
ASSERT(mMemory == VK_NULL_HANDLE);
@ -34,15 +33,16 @@ namespace vulkan {
return mMappedPointer;
}
MemoryAllocator::MemoryAllocator(Device* device)
:mDevice(device) {
MemoryAllocator::MemoryAllocator(Device* device) : mDevice(device) {
}
MemoryAllocator::~MemoryAllocator() {
ASSERT(mReleasedMemory.Empty());
}
bool MemoryAllocator::Allocate(VkMemoryRequirements requirements, bool mappable, DeviceMemoryAllocation* allocation) {
bool MemoryAllocator::Allocate(VkMemoryRequirements requirements,
bool mappable,
DeviceMemoryAllocation* allocation) {
const VulkanDeviceInfo& info = mDevice->GetDeviceInfo();
// Find a suitable memory type for this allocation
@ -54,7 +54,8 @@ namespace vulkan {
}
// Mappable resource must be host visible
if (mappable && (info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) {
if (mappable &&
(info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) {
continue;
}
@ -66,16 +67,20 @@ namespace vulkan {
// For non-mappable resources, favor device local memory.
if (!mappable) {
if ((info.memoryTypes[bestType].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == 0 &&
(info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0) {
if ((info.memoryTypes[bestType].propertyFlags &
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == 0 &&
(info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) !=
0) {
bestType = static_cast<int>(i);
continue;
}
}
// All things equal favor the memory in the biggest heap
VkDeviceSize bestTypeHeapSize = info.memoryHeaps[info.memoryTypes[bestType].heapIndex].size;
VkDeviceSize candidateHeapSize = info.memoryHeaps[info.memoryTypes[bestType].heapIndex].size;
VkDeviceSize bestTypeHeapSize =
info.memoryHeaps[info.memoryTypes[bestType].heapIndex].size;
VkDeviceSize candidateHeapSize =
info.memoryHeaps[info.memoryTypes[bestType].heapIndex].size;
if (candidateHeapSize > bestTypeHeapSize) {
bestType = static_cast<int>(i);
continue;
@ -95,14 +100,15 @@ namespace vulkan {
allocateInfo.memoryTypeIndex = static_cast<uint32_t>(bestType);
VkDeviceMemory allocatedMemory = VK_NULL_HANDLE;
if (mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo, nullptr, &allocatedMemory) != VK_SUCCESS) {
if (mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo, nullptr,
&allocatedMemory) != VK_SUCCESS) {
return false;
}
void* mappedPointer = nullptr;
if (mappable) {
if (mDevice->fn.MapMemory(mDevice->GetVkDevice(), allocatedMemory, 0, requirements.size, 0,
&mappedPointer) != VK_SUCCESS) {
if (mDevice->fn.MapMemory(mDevice->GetVkDevice(), allocatedMemory, 0, requirements.size,
0, &mappedPointer) != VK_SUCCESS) {
return false;
}
}
@ -127,5 +133,4 @@ namespace vulkan {
}
mReleasedMemory.ClearUpTo(finishedSerial);
}
}
}
}} // namespace backend::vulkan

View File

@ -18,8 +18,7 @@
#include "backend/vulkan/vulkan_platform.h"
#include "common/SerialQueue.h"
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
class Device;
class MemoryAllocator;
@ -43,7 +42,9 @@ namespace vulkan {
MemoryAllocator(Device* device);
~MemoryAllocator();
bool Allocate(VkMemoryRequirements requirements, bool mappable, DeviceMemoryAllocation* allocation);
bool Allocate(VkMemoryRequirements requirements,
bool mappable,
DeviceMemoryAllocation* allocation);
void Free(DeviceMemoryAllocation* allocation);
void Tick(Serial finishedSerial);
@ -53,7 +54,6 @@ namespace vulkan {
SerialQueue<VkDeviceMemory> mReleasedMemory;
};
}
}
}} // namespace backend::vulkan
#endif // BACKEND_VULKAN_MEMORYALLOCATOR_H_

View File

@ -15,8 +15,8 @@
#include "backend/vulkan/VulkanBackend.h"
#include "backend/Commands.h"
#include "backend/vulkan/BufferVk.h"
#include "backend/vulkan/BufferUploader.h"
#include "backend/vulkan/BufferVk.h"
#include "common/Platform.h"
#include <spirv-cross/spirv_cross.hpp>
@ -31,8 +31,7 @@
# error "Unimplemented Vulkan backend platform"
#endif
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
nxtProcTable GetNonValidatingProcs();
nxtProcTable GetValidatingProcs();
@ -380,10 +379,12 @@ namespace vulkan {
// Find a universal queue family
{
constexpr uint32_t kUniversalFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT;
constexpr uint32_t kUniversalFlags =
VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT;
int universalQueueFamily = -1;
for (unsigned int i = 0; i < mDeviceInfo.queueFamilies.size(); ++i) {
if ((mDeviceInfo.queueFamilies[i].queueFlags & kUniversalFlags) == kUniversalFlags) {
if ((mDeviceInfo.queueFamilies[i].queueFlags & kUniversalFlags) ==
kUniversalFlags) {
universalQueueFamily = i;
break;
}
@ -439,7 +440,8 @@ namespace vulkan {
createInfo.pfnCallback = Device::OnDebugReportCallback;
createInfo.pUserData = this;
if (fn.CreateDebugReportCallbackEXT(mInstance, &createInfo, nullptr, &mDebugReportCallback) != VK_SUCCESS) {
if (fn.CreateDebugReportCallbackEXT(mInstance, &createInfo, nullptr,
&mDebugReportCallback) != VK_SUCCESS) {
return false;
}
@ -536,7 +538,8 @@ namespace vulkan {
allocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocateInfo.commandBufferCount = 1;
if (fn.AllocateCommandBuffers(mVkDevice, &allocateInfo, &commands.commandBuffer) != VK_SUCCESS) {
if (fn.AllocateCommandBuffers(mVkDevice, &allocateInfo, &commands.commandBuffer) !=
VK_SUCCESS) {
ASSERT(false);
}
@ -565,8 +568,7 @@ namespace vulkan {
// Queue
Queue::Queue(QueueBuilder* builder)
: QueueBase(builder) {
Queue::Queue(QueueBuilder* builder) : QueueBase(builder) {
}
Queue::~Queue() {
@ -577,8 +579,7 @@ namespace vulkan {
// Texture
Texture::Texture(TextureBuilder* builder)
: TextureBase(builder) {
Texture::Texture(TextureBuilder* builder) : TextureBase(builder) {
}
Texture::~Texture() {
@ -589,8 +590,7 @@ namespace vulkan {
// SwapChain
SwapChain::SwapChain(SwapChainBuilder* builder)
: SwapChainBase(builder) {
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
const auto& im = GetImplementation();
im.Init(im.userData, nullptr);
}
@ -601,5 +601,4 @@ namespace vulkan {
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
return GetDevice()->CreateTexture(builder);
}
}
}
}} // namespace backend::vulkan

View File

@ -17,15 +17,13 @@
#include "nxt/nxtcpp.h"
#include "backend/vulkan/VulkanFunctions.h"
#include "backend/vulkan/VulkanInfo.h"
#include "backend/BindGroup.h"
#include "backend/BindGroupLayout.h"
#include "backend/BlendState.h"
#include "backend/Device.h"
#include "backend/CommandBuffer.h"
#include "backend/ComputePipeline.h"
#include "backend/DepthStencilState.h"
#include "backend/Device.h"
#include "backend/Framebuffer.h"
#include "backend/InputState.h"
#include "backend/PipelineLayout.h"
@ -37,14 +35,15 @@
#include "backend/SwapChain.h"
#include "backend/Texture.h"
#include "backend/ToBackend.h"
#include "backend/vulkan/VulkanFunctions.h"
#include "backend/vulkan/VulkanInfo.h"
#include "common/DynamicLib.h"
#include "common/Serial.h"
#include "common/SerialQueue.h"
#include <queue>
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
using BindGroup = BindGroupBase;
using BindGroupLayout = BindGroupLayoutBase;
@ -218,7 +217,8 @@ namespace vulkan {
~Texture();
private:
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage,
nxt::TextureUsageBit targetUsage) override;
};
class SwapChain : public SwapChainBase {
@ -230,7 +230,6 @@ namespace vulkan {
TextureBase* GetNextTextureImpl(TextureBuilder* builder) override;
};
}
}
}} // namespace backend::vulkan
#endif // BACKEND_VULKAN_VULKANBACKEND_H_

View File

@ -17,8 +17,7 @@
#include "backend/vulkan/VulkanInfo.h"
#include "common/DynamicLib.h"
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
#define GET_GLOBAL_PROC(name) \
name = reinterpret_cast<decltype(name)>(GetInstanceProcAddr(nullptr, "vk" #name)); \
@ -44,8 +43,10 @@ namespace vulkan {
return false; \
}
bool VulkanFunctions::LoadInstanceProcs(VkInstance instance, const VulkanGlobalKnobs& usedKnobs) {
// Load this proc first so that we can destroy the instance even if some other GET_INSTANCE_PROC fails
bool VulkanFunctions::LoadInstanceProcs(VkInstance instance,
const VulkanGlobalKnobs& usedKnobs) {
// Load this proc first so that we can destroy the instance even if some other
// GET_INSTANCE_PROC fails
GET_INSTANCE_PROC(DestroyInstance);
GET_INSTANCE_PROC(CreateDevice);
@ -217,5 +218,4 @@ namespace vulkan {
return true;
}
}
}
}} // namespace backend::vulkan

View File

@ -19,8 +19,7 @@
class DynamicLib;
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
struct VulkanGlobalKnobs;
struct VulkanDeviceKnobs;
@ -54,11 +53,14 @@ namespace vulkan {
PFN_vkGetDeviceProcAddr GetDeviceProcAddr = nullptr;
PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures = nullptr;
PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties = nullptr;
PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties = nullptr;
PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties =
nullptr;
PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties = nullptr;
PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties = nullptr;
PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties = nullptr;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties = nullptr;
PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties =
nullptr;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties
GetPhysicalDeviceSparseImageFormatProperties = nullptr;
// Not technically an instance proc but we want to be able to use it as soon as the
// device is created.
PFN_vkDestroyDevice DestroyDevice = nullptr;
@ -71,9 +73,11 @@ namespace vulkan {
// VK_KHR_surface
PFN_vkDestroySurfaceKHR DestroySurfaceKHR = nullptr;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR = nullptr;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR = nullptr;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR =
nullptr;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR = nullptr;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR = nullptr;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR =
nullptr;
// ---------- Device procs
@ -206,7 +210,6 @@ namespace vulkan {
PFN_vkQueuePresentKHR QueuePresentKHR = nullptr;
};
}
}
}} // namespace backend::vulkan
#endif // BACKEND_VULKAN_VULKANFUNCTIONS_H_

View File

@ -26,10 +26,9 @@ namespace {
bool IsExtensionName(const VkExtensionProperties& extension, const char* name) {
return strncmp(extension.extensionName, name, VK_MAX_EXTENSION_NAME_SIZE) == 0;
}
}
} // namespace
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
const char kLayerNameLunargStandardValidation[] = "VK_LAYER_LUNARG_standard_validation";
@ -65,13 +64,15 @@ namespace vulkan {
// Gather the info about the instance extensions
{
uint32_t count = 0;
VkResult result = device.fn.EnumerateInstanceExtensionProperties(nullptr, &count, nullptr);
VkResult result =
device.fn.EnumerateInstanceExtensionProperties(nullptr, &count, nullptr);
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
return false;
}
info->extensions.resize(count);
result = device.fn.EnumerateInstanceExtensionProperties(nullptr, &count, info->extensions.data());
result = device.fn.EnumerateInstanceExtensionProperties(nullptr, &count,
info->extensions.data());
if (result != VK_SUCCESS) {
return false;
}
@ -109,7 +110,9 @@ namespace vulkan {
return true;
}
bool GatherDeviceInfo(const Device& device, VkPhysicalDevice physicalDevice, VulkanDeviceInfo* info) {
bool GatherDeviceInfo(const Device& device,
VkPhysicalDevice physicalDevice,
VulkanDeviceInfo* info) {
// Gather general info about the device
device.fn.GetPhysicalDeviceProperties(physicalDevice, &info->properties);
device.fn.GetPhysicalDeviceFeatures(physicalDevice, &info->features);
@ -119,8 +122,10 @@ namespace vulkan {
VkPhysicalDeviceMemoryProperties memory;
device.fn.GetPhysicalDeviceMemoryProperties(physicalDevice, &memory);
info->memoryTypes.assign(memory.memoryTypes, memory.memoryTypes + memory.memoryTypeCount);
info->memoryHeaps.assign(memory.memoryHeaps, memory.memoryHeaps + memory.memoryHeapCount);
info->memoryTypes.assign(memory.memoryTypes,
memory.memoryTypes + memory.memoryTypeCount);
info->memoryHeaps.assign(memory.memoryHeaps,
memory.memoryHeaps + memory.memoryHeapCount);
}
// Gather info about device queue families
@ -129,19 +134,22 @@ namespace vulkan {
device.fn.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count, nullptr);
info->queueFamilies.resize(count);
device.fn.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count, info->queueFamilies.data());
device.fn.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count,
info->queueFamilies.data());
}
// Gather the info about the device layers
{
uint32_t count = 0;
VkResult result = device.fn.EnumerateDeviceLayerProperties(physicalDevice, &count, nullptr);
VkResult result =
device.fn.EnumerateDeviceLayerProperties(physicalDevice, &count, nullptr);
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
return false;
}
info->layers.resize(count);
result = device.fn.EnumerateDeviceLayerProperties(physicalDevice, &count, info->layers.data());
result = device.fn.EnumerateDeviceLayerProperties(physicalDevice, &count,
info->layers.data());
if (result != VK_SUCCESS) {
return false;
}
@ -150,13 +158,15 @@ namespace vulkan {
// Gather the info about the device extensions
{
uint32_t count = 0;
VkResult result = device.fn.EnumerateDeviceExtensionProperties(physicalDevice, nullptr, &count, nullptr);
VkResult result = device.fn.EnumerateDeviceExtensionProperties(physicalDevice, nullptr,
&count, nullptr);
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
return false;
}
info->extensions.resize(count);
result = device.fn.EnumerateDeviceExtensionProperties(physicalDevice, nullptr, &count, info->extensions.data());
result = device.fn.EnumerateDeviceExtensionProperties(physicalDevice, nullptr, &count,
info->extensions.data());
if (result != VK_SUCCESS) {
return false;
}
@ -173,5 +183,4 @@ namespace vulkan {
return true;
}
}
}
}} // namespace backend::vulkan

View File

@ -19,8 +19,7 @@
#include <vector>
namespace backend {
namespace vulkan {
namespace backend { namespace vulkan {
class Device;
@ -68,8 +67,9 @@ namespace vulkan {
bool GatherGlobalInfo(const Device& device, VulkanGlobalInfo* info);
bool GetPhysicalDevices(const Device& device, std::vector<VkPhysicalDevice>* physicalDevices);
bool GatherDeviceInfo(const Device& device, VkPhysicalDevice physicalDevice, VulkanDeviceInfo* info);
}
}
bool GatherDeviceInfo(const Device& device,
VkPhysicalDevice physicalDevice,
VulkanDeviceInfo* info);
}} // namespace backend::vulkan
#endif // BACKEND_VULKAN_VULKANINFO_H_