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

[d3d9] Use initImage to clear uninitialized image resources

This commit is contained in:
Philip Rebohle 2022-02-17 15:20:09 +01:00
parent 6d0e5dfd21
commit 752f98cf00
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 4 additions and 27 deletions

View File

@ -91,8 +91,7 @@ namespace dxvk {
// 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. We can only do that
// for non-compressed images, but that should be fine.
// expect a resource to be pre-cleared.
VkImageSubresourceRange subresources;
subresources.aspectMask = formatInfo->aspectMask;
subresources.baseMipLevel = 0;
@ -100,23 +99,7 @@ namespace dxvk {
subresources.baseArrayLayer = 0;
subresources.layerCount = image->info().numLayers;
if (formatInfo->flags.test(DxvkFormatFlag::BlockCompressed)) {
m_context->clearCompressedColorImage(image, subresources);
} else {
if (subresources.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) {
VkClearColorValue value = { };
m_context->clearColorImage(
image, value, subresources);
} else {
VkClearDepthStencilValue value;
value.depth = 0.0f;
value.stencil = 0;
m_context->clearDepthStencilImage(
image, value, subresources);
}
}
m_context->initImage(image, subresources, VK_IMAGE_LAYOUT_UNDEFINED);
};
InitImage(pTexture->GetImage());

View File

@ -1050,19 +1050,13 @@ namespace dxvk {
subresources.baseArrayLayer = 0;
subresources.layerCount = 1;
VkClearColorValue clearColor;
clearColor.float32[0] = 0.0f;
clearColor.float32[1] = 0.0f;
clearColor.float32[2] = 0.0f;
clearColor.float32[3] = 0.0f;
m_context->beginRecording(
m_device->createCommandList());
for (uint32_t i = 0; i < m_backBuffers.size(); i++) {
m_context->clearColorImage(
m_context->initImage(
m_backBuffers[i]->GetCommonTexture()->GetImage(),
clearColor, subresources);
subresources, VK_IMAGE_LAYOUT_UNDEFINED);
}
m_device->submitCommandList(