mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 09:39:15 +00:00
graphics-hook: Handle VkImageViewUsageCreateInfo
Our solution for adding TRANSFER_SRC usage for imageless framebuffers was triggering validation errors when combined with image view usage overrides. Add TRANSFER_SRC onto usage overrides for swap chain image views to fix mismatches.
This commit is contained in:
parent
e86b2950a2
commit
b5c5f71cee
|
@ -1826,25 +1826,22 @@ static VkResult VKAPI_CALL
|
|||
OBS_CreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator, VkImageView *pView)
|
||||
{
|
||||
bool from_swap_chain = false;
|
||||
|
||||
struct vk_data *const data = get_device_data(device);
|
||||
const PFN_vkCreateImageView func = data->funcs.CreateImageView;
|
||||
VkResult result = func(device, pCreateInfo, pAllocator, pView);
|
||||
if (data->valid && (result == VK_SUCCESS)) {
|
||||
if (data->valid) {
|
||||
struct vk_swap_data *swap = swap_walk_begin(data);
|
||||
|
||||
while (swap) {
|
||||
bool match = false;
|
||||
for (uint32_t i = 0, count = swap->image_count;
|
||||
i < count; ++i) {
|
||||
match = swap->swap_images[i] ==
|
||||
from_swap_chain = swap->swap_images[i] ==
|
||||
pCreateInfo->image;
|
||||
if (match)
|
||||
if (from_swap_chain)
|
||||
break;
|
||||
}
|
||||
if (match) {
|
||||
add_swap_view_data(data, *pView, pAllocator);
|
||||
if (from_swap_chain)
|
||||
break;
|
||||
}
|
||||
|
||||
swap = swap_walk_next(swap);
|
||||
}
|
||||
|
@ -1852,6 +1849,27 @@ OBS_CreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
|
|||
swap_walk_end(data);
|
||||
}
|
||||
|
||||
if (from_swap_chain) {
|
||||
const void *pCurrent = pCreateInfo->pNext;
|
||||
while (pCurrent) {
|
||||
VkBaseInStructure baseIn;
|
||||
memcpy(&baseIn, pCurrent, sizeof(baseIn));
|
||||
if (baseIn.sType ==
|
||||
VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO) {
|
||||
((VkImageViewUsageCreateInfo *)pCurrent)
|
||||
->usage |=
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
pCurrent = baseIn.pNext;
|
||||
}
|
||||
}
|
||||
|
||||
const PFN_vkCreateImageView func = data->funcs.CreateImageView;
|
||||
VkResult result = func(device, pCreateInfo, pAllocator, pView);
|
||||
if ((result == VK_SUCCESS) && from_swap_chain)
|
||||
add_swap_view_data(data, *pView, pAllocator);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue