1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14: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]; const auto& res = m_rc[binding.resourceBinding];
if (res.sampler != nullptr) { if (res.sampler != nullptr) {
m_descriptors[k].image.sampler = res.sampler->handle(); m_descriptors[k].image.sampler = res.sampler->handle();
m_descriptors[k].image.imageView = VK_NULL_HANDLE; m_descriptors[k].image.imageView = VK_NULL_HANDLE;
m_descriptors[k].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED; m_descriptors[k].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (m_rcTracked.set(binding.resourceBinding)) if (m_rcTracked.set(binding.resourceBinding))
m_cmd->trackResource<DxvkAccess::None>(res.sampler); m_cmd->trackResource<DxvkAccess::None>(res.sampler);
} else { } 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; } break;
@ -4661,8 +4663,8 @@ namespace dxvk {
const auto& res = m_rc[binding.resourceBinding]; const auto& res = m_rc[binding.resourceBinding];
if (res.imageView != nullptr && res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) { if (res.imageView != nullptr && res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) {
m_descriptors[k].image.sampler = 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.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout; m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.resourceBinding)) { if (m_rcTracked.set(binding.resourceBinding)) {
@ -4670,7 +4672,9 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image()); m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
} }
} else { } 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; } break;
@ -4678,8 +4682,8 @@ namespace dxvk {
const auto& res = m_rc[binding.resourceBinding]; const auto& res = m_rc[binding.resourceBinding];
if (res.imageView != nullptr && res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) { if (res.imageView != nullptr && res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) {
m_descriptors[k].image.sampler = 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.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout; m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.resourceBinding)) { if (m_rcTracked.set(binding.resourceBinding)) {
@ -4687,7 +4691,9 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::Write>(res.imageView->image()); m_cmd->trackResource<DxvkAccess::Write>(res.imageView->image());
} }
} else { } 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; } break;
@ -4696,8 +4702,8 @@ namespace dxvk {
if (res.sampler != nullptr && res.imageView != nullptr if (res.sampler != nullptr && res.imageView != nullptr
&& res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) { && res.imageView->handle(binding.viewType) != VK_NULL_HANDLE) {
m_descriptors[k].image.sampler = res.sampler->handle(); m_descriptors[k].image.sampler = res.sampler->handle();
m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType); m_descriptors[k].image.imageView = res.imageView->handle(binding.viewType);
m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout; m_descriptors[k].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.resourceBinding)) { if (m_rcTracked.set(binding.resourceBinding)) {
@ -4706,7 +4712,9 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image()); m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
} }
} else { } 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; } break;
@ -4751,7 +4759,9 @@ namespace dxvk {
if (m_rcTracked.set(binding.resourceBinding)) if (m_rcTracked.set(binding.resourceBinding))
m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer()); m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer());
} else { } 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; } break;
@ -4764,7 +4774,9 @@ namespace dxvk {
if (m_rcTracked.set(binding.resourceBinding)) if (m_rcTracked.set(binding.resourceBinding))
m_cmd->trackResource<DxvkAccess::Write>(res.bufferSlice.buffer()); m_cmd->trackResource<DxvkAccess::Write>(res.bufferSlice.buffer());
} else { } 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; } break;

View File

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