1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[dxvk] Validate image layouts in render pass formats read from cache

This will discard invalid cache entries generated by DXVK 1.4.3.
This commit is contained in:
Philip Rebohle 2019-10-27 00:04:57 +02:00
parent 03dc59ef39
commit 8c34f4ff8a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 29 additions and 0 deletions

View File

@ -553,6 +553,9 @@ namespace dxvk {
entry.format.color[i].layout = unpackImageLayout(imageLayout);
}
if (!validateRenderPassFormat(entry.format))
return false;
// Read common pipeline state
if (!data.read(entry.gpState.bsBindingMask)
|| !data.read(entry.gpState.ia)
@ -985,4 +988,27 @@ namespace dxvk {
}
}
bool DxvkStateCache::validateRenderPassFormat(
const DxvkRenderPassFormat& format) {
bool valid = true;
if (format.depth.format) {
valid &= format.depth.layout == VK_IMAGE_LAYOUT_GENERAL
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
|| format.depth.layout == VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL;
}
for (uint32_t i = 0; i < MaxNumRenderTargets && valid; i++) {
if (format.color[i].format) {
valid &= format.color[i].layout == VK_IMAGE_LAYOUT_GENERAL
|| format.color[i].layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
}
}
return valid;
}
}

View File

@ -186,6 +186,9 @@ namespace dxvk {
static VkImageLayout unpackImageLayout(
uint8_t layout);
static bool validateRenderPassFormat(
const DxvkRenderPassFormat& format);
};
}