1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Explicitly initialize null descriptor structs

There's a weird rule that requires null buffer descriptors to specify
VK_WHOLE_SIZE. Silences a bunch of validation errors in God of War.
This commit is contained in:
Philip Rebohle 2022-07-15 15:58:18 +02:00
parent 0f6ba59f16
commit b59571ab22
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 28 additions and 20 deletions

View File

@ -4646,14 +4646,16 @@ namespace dxvk {
const auto& res = m_rc[binding.resourceBinding];
if (res.sampler != nullptr) {
m_descriptors[k].image.sampler = res.sampler->handle();
m_descriptors[k].image.imageView = VK_NULL_HANDLE;
m_descriptors[k].image.sampler = res.sampler->handle();
m_descriptors[k].image.imageView = VK_NULL_HANDLE;
m_descriptors[k].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (m_rcTracked.set(binding.resourceBinding))
m_cmd->trackResource<DxvkAccess::None>(res.sampler);
} else {
m_descriptors[k].image = m_common->dummyResources().samplerDescriptor();
m_descriptors[k].image.sampler = m_common->dummyResources().samplerHandle();
m_descriptors[k].image.imageView = VK_NULL_HANDLE;
m_descriptors[k].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
}
} break;
@ -4661,8 +4663,8 @@ namespace dxvk {
const auto& res = m_rc[binding.resourceBinding];
if (res.imageView != nullptr && res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) {
m_descriptors[k].image.sampler = VK_NULL_HANDLE;
m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.sampler = VK_NULL_HANDLE;
m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.resourceBinding)) {
@ -4670,7 +4672,9 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
}
} else {
m_descriptors[k].image = VkDescriptorImageInfo();
m_descriptors[k].image.sampler = VK_NULL_HANDLE;
m_descriptors[k].image.imageView = VK_NULL_HANDLE;
m_descriptors[k].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
}
} break;
@ -4678,8 +4682,8 @@ namespace dxvk {
const auto& res = m_rc[binding.resourceBinding];
if (res.imageView != nullptr && res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) {
m_descriptors[k].image.sampler = VK_NULL_HANDLE;
m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.sampler = VK_NULL_HANDLE;
m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.resourceBinding)) {
@ -4687,7 +4691,9 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::Write>(res.imageView->image());
}
} else {
m_descriptors[k].image = VkDescriptorImageInfo();
m_descriptors[k].image.sampler = VK_NULL_HANDLE;
m_descriptors[k].image.imageView = VK_NULL_HANDLE;
m_descriptors[k].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
}
} break;
@ -4696,8 +4702,8 @@ namespace dxvk {
if (res.sampler != nullptr && res.imageView != nullptr
&& res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) {
m_descriptors[k].image.sampler = res.sampler->handle();
m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.sampler = res.sampler->handle();
m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.resourceBinding)) {
@ -4706,7 +4712,9 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
}
} else {
m_descriptors[k].image = m_common->dummyResources().samplerDescriptor();
m_descriptors[k].image.sampler = m_common->dummyResources().samplerHandle();
m_descriptors[k].image.imageView = VK_NULL_HANDLE;
m_descriptors[k].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
}
} break;
@ -4751,7 +4759,9 @@ namespace dxvk {
if (m_rcTracked.set(binding.resourceBinding))
m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer());
} else {
m_descriptors[k].buffer = VkDescriptorBufferInfo();
m_descriptors[k].buffer.buffer = VK_NULL_HANDLE;
m_descriptors[k].buffer.offset = 0;
m_descriptors[k].buffer.range = VK_WHOLE_SIZE;
}
} break;
@ -4764,7 +4774,9 @@ namespace dxvk {
if (m_rcTracked.set(binding.resourceBinding))
m_cmd->trackResource<DxvkAccess::Write>(res.bufferSlice.buffer());
} else {
m_descriptors[k].buffer = VkDescriptorBufferInfo();
m_descriptors[k].buffer.buffer = VK_NULL_HANDLE;
m_descriptors[k].buffer.offset = 0;
m_descriptors[k].buffer.range = VK_WHOLE_SIZE;
}
} break;

View File

@ -42,12 +42,8 @@ namespace dxvk {
* still require different behaviour.
* \returns Dummy sampler descriptor
*/
VkDescriptorImageInfo samplerDescriptor() const {
VkDescriptorImageInfo result;
result.sampler = m_sampler->handle();
result.imageView = VK_NULL_HANDLE;
result.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
return result;
VkSampler samplerHandle() const {
return m_sampler->handle();
}
private: