[d3d11] Pre-clear images that would have undefined contents

Fixes significant visual bugs in Nier: Automata that were caused
by partially initialized images.
This commit is contained in:
Philip Rebohle 2018-01-02 21:32:39 +01:00
parent 98bcfec0f3
commit 755e6d36e3
1 changed files with 18 additions and 2 deletions

View File

@ -1440,14 +1440,30 @@ namespace dxvk {
}
}
} else {
// Leave the image contents undefined
// While the Microsoft docs state that resource contents
// are undefined if no initial data is provided, some
// applications expect a resource to be pre-cleared.
VkImageSubresourceRange subresources;
subresources.aspectMask = formatInfo->aspectMask;
subresources.baseMipLevel = 0;
subresources.levelCount = image->info().mipLevels;
subresources.baseArrayLayer = 0;
subresources.layerCount = image->info().numLayers;
m_resourceInitContext->initImage(image, subresources);
if (subresources.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) {
VkClearColorValue value;
std::memset(&value, 0, sizeof(value));
m_resourceInitContext->clearColorImage(
image, value, subresources);
} else {
VkClearDepthStencilValue value;
value.depth = 0.0f;
value.stencil = 0;
m_resourceInitContext->clearDepthStencilImage(
image, value, subresources);
}
}
m_dxvkDevice->submitCommandList(