mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-03-25 20:51:36 +00:00
test(dualgpu): Bugs
This commit is contained in:
parent
7e07c4ba3a
commit
fbf36a4e20
4 changed files with 47 additions and 29 deletions
|
|
@ -22,7 +22,8 @@ namespace vk {
|
|||
PFN_vkDestroyInstance DestroyInstance;
|
||||
PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
|
||||
PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
|
||||
PFN_vkGetPhysicalDeviceProperties2 GetPhysicalDeviceProperties2;
|
||||
PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2;
|
||||
PFN_vkGetPhysicalDeviceFormatProperties2KHR GetPhysicalDeviceFormatProperties2;
|
||||
PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
|
||||
PFN_vkGetPhysicalDeviceFeatures2 GetPhysicalDeviceFeatures2;
|
||||
PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
|
||||
|
|
|
|||
|
|
@ -101,19 +101,6 @@ DescriptorSet::DescriptorSet(const vk::Vulkan& vk,
|
|||
});
|
||||
|
||||
size_t sampledIdx{32};
|
||||
for (const auto& img : sampledImages)
|
||||
entries.push_back({
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = *this->descriptorSet,
|
||||
.dstBinding = static_cast<uint32_t>(sampledIdx++),
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.pImageInfo = &(imageInfos.emplace_back(VkDescriptorImageInfo{
|
||||
.imageView = img.get().imageview(),
|
||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL
|
||||
}))
|
||||
});
|
||||
|
||||
for (const auto& img : sampledImagesSh)
|
||||
entries.push_back({
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
|
|
@ -127,8 +114,21 @@ DescriptorSet::DescriptorSet(const vk::Vulkan& vk,
|
|||
}))
|
||||
});
|
||||
|
||||
for (const auto& img : sampledImages)
|
||||
entries.push_back({
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = *this->descriptorSet,
|
||||
.dstBinding = static_cast<uint32_t>(sampledIdx++),
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.pImageInfo = &(imageInfos.emplace_back(VkDescriptorImageInfo{
|
||||
.imageView = img.get().imageview(),
|
||||
.imageLayout = VK_IMAGE_LAYOUT_GENERAL
|
||||
}))
|
||||
});
|
||||
|
||||
size_t storageIdx{48};
|
||||
for (const auto& img : storageImages)
|
||||
for (const auto& img : storageImagesSh)
|
||||
entries.push_back({
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = *this->descriptorSet,
|
||||
|
|
@ -141,7 +141,7 @@ DescriptorSet::DescriptorSet(const vk::Vulkan& vk,
|
|||
}))
|
||||
});
|
||||
|
||||
for (const auto& img : storageImagesSh)
|
||||
for (const auto& img : storageImages)
|
||||
entries.push_back({
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstSet = *this->descriptorSet,
|
||||
|
|
|
|||
|
|
@ -98,8 +98,13 @@ namespace {
|
|||
throw ls::vulkan_error(VK_ERROR_UNKNOWN, "no suitable memory type found");
|
||||
|
||||
// create VkDeviceMemory
|
||||
const VkMemoryDedicatedAllocateInfoKHR dedicatedInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR,
|
||||
.image = image,
|
||||
};
|
||||
const VkImportMemoryFdInfoKHR importInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
|
||||
.pNext = &dedicatedInfo,
|
||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
.fd = fd
|
||||
};
|
||||
|
|
@ -189,13 +194,18 @@ namespace {
|
|||
throw ls::vulkan_error(VK_ERROR_UNKNOWN, "no suitable memory type found");
|
||||
|
||||
// create VkDeviceMemory
|
||||
const VkExportMemoryAllocateInfoKHR importInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
|
||||
const VkMemoryDedicatedAllocateInfoKHR dedicatedInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR,
|
||||
.image = image,
|
||||
};
|
||||
const VkExportMemoryAllocateInfoKHR exportInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR,
|
||||
.pNext = &dedicatedInfo,
|
||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT
|
||||
};
|
||||
const VkMemoryAllocateInfo memoryInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||
.pNext = &importInfo,
|
||||
.pNext = &exportInfo,
|
||||
.allocationSize = reqs.size,
|
||||
.memoryTypeIndex = *mti
|
||||
};
|
||||
|
|
@ -209,12 +219,12 @@ namespace {
|
|||
throw ls::vulkan_error(res, "vkBindImageMemory() failed");
|
||||
|
||||
// export dma-buf fd
|
||||
const VkMemoryGetFdInfoKHR exportInfo{
|
||||
const VkMemoryGetFdInfoKHR getInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
|
||||
.memory = handle,
|
||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT
|
||||
};
|
||||
res = vk.df().GetMemoryFdKHR(vk.dev(), &exportInfo, &fd);
|
||||
res = vk.df().GetMemoryFdKHR(vk.dev(), &getInfo, &fd);
|
||||
if (res != VK_SUCCESS)
|
||||
throw ls::vulkan_error(res, "vkGetMemoryFdKHR() failed");
|
||||
|
||||
|
|
@ -268,23 +278,23 @@ namespace {
|
|||
}
|
||||
/// get the drm offsets and row pitches of an image
|
||||
std::vector<std::pair<uint64_t, uint64_t>> getImageLayouts(const vk::Vulkan& vk,
|
||||
VkImage image, uint64_t drmModifier) {
|
||||
VkImage image, VkFormat format, uint64_t drmModifier) {
|
||||
std::vector<std::pair<uint64_t, uint64_t>> result;
|
||||
|
||||
// fetch drm modifier information
|
||||
VkDrmFormatModifierPropertiesList2EXT formats{
|
||||
.sType = VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT,
|
||||
};
|
||||
VkPhysicalDeviceProperties2 props{
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
|
||||
VkFormatProperties2KHR props{
|
||||
.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR,
|
||||
.pNext = &formats
|
||||
};
|
||||
vk.fi().GetPhysicalDeviceProperties2(vk.physdev(), &props);
|
||||
vk.fi().GetPhysicalDeviceFormatProperties2(vk.physdev(), format, &props);
|
||||
|
||||
std::vector<VkDrmFormatModifierProperties2EXT> formatProps(formats.drmFormatModifierCount);
|
||||
formats.pDrmFormatModifierProperties = formatProps.data();
|
||||
|
||||
vk.fi().GetPhysicalDeviceProperties2(vk.physdev(), &props);
|
||||
vk.fi().GetPhysicalDeviceFormatProperties2(vk.physdev(), format, &props);
|
||||
|
||||
// find plane count for the modifier
|
||||
std::optional<size_t> planeCount;
|
||||
|
|
@ -345,7 +355,7 @@ SharedImage::SharedImage(const vk::Vulkan& vk,
|
|||
)),
|
||||
extent(extent),
|
||||
modifier(getImageDrmModifier(vk, *this->image)),
|
||||
layouts(getImageLayouts(vk, *this->image, this->modifier)) {
|
||||
layouts(getImageLayouts(vk, *this->image, format, this->modifier)) {
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -370,5 +380,5 @@ SharedImage::SharedImage(const vk::Vulkan& vk,
|
|||
)),
|
||||
extent(extent),
|
||||
modifier(getImageDrmModifier(vk, *this->image)),
|
||||
layouts(getImageLayouts(vk, *this->image, this->modifier)) {
|
||||
layouts(getImageLayouts(vk, *this->image, format, this->modifier)) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,9 +78,14 @@ namespace {
|
|||
.engineVersion = engineVersion.into(),
|
||||
.apiVersion = VK_API_VERSION_1_2 // seems 1.2 is supported on all Vulkan-capable GPUs
|
||||
};
|
||||
const std::vector<const char*> requestedExtensions{
|
||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
|
||||
};
|
||||
const VkInstanceCreateInfo instanceInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pApplicationInfo = &appInfo
|
||||
.pApplicationInfo = &appInfo,
|
||||
.enabledExtensionCount = static_cast<uint32_t>(requestedExtensions.size()),
|
||||
.ppEnabledExtensionNames = requestedExtensions.data()
|
||||
};
|
||||
auto res = vkCreateInstance(&instanceInfo, VK_NULL_HANDLE, &handle);
|
||||
if (res != VK_SUCCESS)
|
||||
|
|
@ -297,6 +302,8 @@ VulkanInstanceFuncs vk::initVulkanInstanceFuncs(VkInstance i, PFN_vkGetInstanceP
|
|||
"vkEnumerateDeviceExtensionProperties"),
|
||||
.GetPhysicalDeviceProperties2 = ipa<PFN_vkGetPhysicalDeviceProperties2>(mpa, i,
|
||||
"vkGetPhysicalDeviceProperties2"),
|
||||
.GetPhysicalDeviceFormatProperties2 = reinterpret_cast<PFN_vkGetPhysicalDeviceFormatProperties2>(mpa(i,
|
||||
"vkGetPhysicalDeviceFormatProperties2KHR")),
|
||||
.GetPhysicalDeviceQueueFamilyProperties =
|
||||
ipa<PFN_vkGetPhysicalDeviceQueueFamilyProperties>(mpa, i,
|
||||
"vkGetPhysicalDeviceQueueFamilyProperties"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue