Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions layersvt/screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,9 +939,19 @@ bool prepareScreenshotData(ScreenshotQueueData &data, VkImage image1) {
pTableDevice->GetImageMemoryRequirements(device, data.image2, &memRequirements);
memAllocInfo.allocationSize = memRequirements.size;
pInstanceTable->GetPhysicalDeviceMemoryProperties(physicalDevice, &memoryProperties);
pass = memory_type_from_properties(&memoryProperties, memRequirements.memoryTypeBits,
need2steps ? VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
&memAllocInfo.memoryTypeIndex);
if (need2steps) {
pass = memory_type_from_properties(&memoryProperties, memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
&memAllocInfo.memoryTypeIndex);
} else {
pass = memory_type_from_properties(&memoryProperties, memRequirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
&memAllocInfo.memoryTypeIndex);
if (!pass) {
// Perhaps VK_MEMORY_PROPERTY_HOST_CACHED_BIT is not supported. Fallback on a memory type without it.
pass = memory_type_from_properties(&memoryProperties, memRequirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &memAllocInfo.memoryTypeIndex);
}
}
assert(pass);
(void)pass;
err = pTableDevice->AllocateMemory(device, &memAllocInfo, NULL, &data.mem2);
Expand All @@ -959,8 +969,14 @@ bool prepareScreenshotData(ScreenshotQueueData &data, VkImage image1) {
pTableDevice->GetImageMemoryRequirements(device, data.image3, &memRequirements);
memAllocInfo.allocationSize = memRequirements.size;
pInstanceTable->GetPhysicalDeviceMemoryProperties(physicalDevice, &memoryProperties);
pass = memory_type_from_properties(&memoryProperties, memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
pass = memory_type_from_properties(&memoryProperties, memRequirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
&memAllocInfo.memoryTypeIndex);
if (!pass) {
// Perhaps VK_MEMORY_PROPERTY_HOST_CACHED_BIT is not supported. Fallback on a memory type without it.
pass = memory_type_from_properties(&memoryProperties, memRequirements.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &memAllocInfo.memoryTypeIndex);
}
assert(pass);
(void)pass;
err = pTableDevice->AllocateMemory(device, &memAllocInfo, NULL, &data.mem3);
Expand Down Expand Up @@ -1214,10 +1230,22 @@ static bool writeScreenshot(ScreenshotQueueData &data) {
data.pTableDevice->GetImageSubresourceLayout(data.device, data.image2, &sr, &srLayout);
VkResult err = data.pTableDevice->MapMemory(data.device, data.mem2, 0, VK_WHOLE_SIZE, 0, (void **)&pixels);
if (VK_SUCCESS != err) return false;
VkMappedMemoryRange memoryRange = {};
memoryRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
memoryRange.memory = data.mem2;
memoryRange.size = VK_WHOLE_SIZE;
err = data.pTableDevice->InvalidateMappedMemoryRanges(data.device, 1, &memoryRange);
if (VK_SUCCESS != err) return false;
} else {
data.pTableDevice->GetImageSubresourceLayout(data.device, data.image3, &sr, &srLayout);
VkResult err = data.pTableDevice->MapMemory(data.device, data.mem3, 0, VK_WHOLE_SIZE, 0, (void **)&pixels);
if (VK_SUCCESS != err) return false;
VkMappedMemoryRange memoryRange = {};
memoryRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
memoryRange.memory = data.mem3;
memoryRange.size = VK_WHOLE_SIZE;
err = data.pTableDevice->InvalidateMappedMemoryRanges(data.device, 1, &memoryRange);
if (VK_SUCCESS != err) return false;
}

pixels += srLayout.offset;
Expand Down
Loading