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

[dxvk] Add aspect mask parameter to clearImageView

This commit is contained in:
Philip Rebohle 2019-05-09 09:08:29 +02:00
parent 1fb8b5ec69
commit a1feaa6748
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 22 additions and 5 deletions

View File

@ -812,6 +812,7 @@ namespace dxvk {
ctx->clearImageView(cDstView,
VkOffset3D { 0, 0, 0 },
cDstView->mipLevelExtent(0),
VK_IMAGE_ASPECT_COLOR_BIT,
cClearValue);
});
}
@ -852,6 +853,7 @@ namespace dxvk {
ctx->clearImageView(cDstView,
VkOffset3D { 0, 0, 0 },
cDstView->mipLevelExtent(0),
VK_IMAGE_ASPECT_COLOR_BIT,
cClearValue);
});
}
@ -955,8 +957,11 @@ namespace dxvk {
// the clear value for integer formats as a set of
// integral floats, so we'll have to convert.
VkClearValue clearValue;
VkImageAspectFlags clearAspect;
if (imgView == nullptr || imgView->info().aspect & VK_IMAGE_ASPECT_COLOR_BIT) {
clearAspect = VK_IMAGE_ASPECT_COLOR_BIT;
for (uint32_t i = 0; i < 4; i++) {
if (formatInfo->flags.test(DxvkFormatFlag::SampledUInt))
clearValue.color.uint32[i] = uint32_t(Color[i]);
@ -966,6 +971,7 @@ namespace dxvk {
clearValue.color.float32[i] = Color[i];
}
} else {
clearAspect = VK_IMAGE_ASPECT_DEPTH_BIT;
clearValue.depthStencil.depth = Color[0];
clearValue.depthStencil.stencil = 0;
}
@ -1004,12 +1010,14 @@ namespace dxvk {
cImageView = imgView,
cAreaOffset = offset,
cAreaExtent = extent,
cClearAspect = clearAspect,
cClearValue = clearValue
] (DxvkContext* ctx) {
ctx->clearImageView(
cImageView,
cAreaOffset,
cAreaExtent,
cClearAspect,
cClearValue);
});
}
@ -1034,13 +1042,17 @@ namespace dxvk {
if (imgView != nullptr) {
EmitCs([
cImageView = imgView,
cClearAspect = clearAspect,
cClearValue = clearValue
] (DxvkContext* ctx) {
VkOffset3D offset = { 0, 0, 0 };
VkExtent3D extent = cImageView->mipLevelExtent(0);
ctx->clearImageView(cImageView,
offset, extent, cClearValue);
ctx->clearImageView(
cImageView,
offset, extent,
cClearAspect,
cClearValue);
});
}
}

View File

@ -734,11 +734,12 @@ namespace dxvk {
const Rc<DxvkImageView>& imageView,
VkOffset3D offset,
VkExtent3D extent,
VkImageAspectFlags aspect,
VkClearValue value) {
const VkImageUsageFlags viewUsage = imageView->info().usage;
if (viewUsage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))
this->clearImageViewFb(imageView, offset, extent, value);
this->clearImageViewFb(imageView, offset, extent, aspect, value);
else if (viewUsage & VK_IMAGE_USAGE_STORAGE_BIT)
this->clearImageViewCs(imageView, offset, extent, value);
}
@ -2236,6 +2237,7 @@ namespace dxvk {
const Rc<DxvkImageView>& imageView,
VkOffset3D offset,
VkExtent3D extent,
VkImageAspectFlags aspect,
VkClearValue value) {
this->updateFramebuffer();
@ -2311,7 +2313,7 @@ namespace dxvk {
// Perform the actual clear operation
VkClearAttachment clearInfo;
clearInfo.aspectMask = imageView->info().aspect;
clearInfo.aspectMask = aspect;
clearInfo.colorAttachment = attachmentIndex;
clearInfo.clearValue = value;

View File

@ -300,12 +300,14 @@ namespace dxvk {
* \param [in] imageView The image view
* \param [in] offset Offset of the rect to clear
* \param [in] extent Extent of the rect to clear
* \param [in] aspect Aspect mask to clear
* \param [in] value The clear value
*/
void clearImageView(
const Rc<DxvkImageView>& imageView,
VkOffset3D offset,
VkExtent3D extent,
VkImageAspectFlags aspect,
VkClearValue value);
/**
@ -983,6 +985,7 @@ namespace dxvk {
const Rc<DxvkImageView>& imageView,
VkOffset3D offset,
VkExtent3D extent,
VkImageAspectFlags aspect,
VkClearValue value);
void clearImageViewCs(