1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +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, ctx->clearImageView(cDstView,
VkOffset3D { 0, 0, 0 }, VkOffset3D { 0, 0, 0 },
cDstView->mipLevelExtent(0), cDstView->mipLevelExtent(0),
VK_IMAGE_ASPECT_COLOR_BIT,
cClearValue); cClearValue);
}); });
} }
@ -852,6 +853,7 @@ namespace dxvk {
ctx->clearImageView(cDstView, ctx->clearImageView(cDstView,
VkOffset3D { 0, 0, 0 }, VkOffset3D { 0, 0, 0 },
cDstView->mipLevelExtent(0), cDstView->mipLevelExtent(0),
VK_IMAGE_ASPECT_COLOR_BIT,
cClearValue); cClearValue);
}); });
} }
@ -954,9 +956,12 @@ namespace dxvk {
// Convert the clear color format. ClearView takes // Convert the clear color format. ClearView takes
// the clear value for integer formats as a set of // the clear value for integer formats as a set of
// integral floats, so we'll have to convert. // integral floats, so we'll have to convert.
VkClearValue clearValue; VkClearValue clearValue;
VkImageAspectFlags clearAspect;
if (imgView == nullptr || imgView->info().aspect & VK_IMAGE_ASPECT_COLOR_BIT) { 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++) { for (uint32_t i = 0; i < 4; i++) {
if (formatInfo->flags.test(DxvkFormatFlag::SampledUInt)) if (formatInfo->flags.test(DxvkFormatFlag::SampledUInt))
clearValue.color.uint32[i] = uint32_t(Color[i]); clearValue.color.uint32[i] = uint32_t(Color[i]);
@ -966,6 +971,7 @@ namespace dxvk {
clearValue.color.float32[i] = Color[i]; clearValue.color.float32[i] = Color[i];
} }
} else { } else {
clearAspect = VK_IMAGE_ASPECT_DEPTH_BIT;
clearValue.depthStencil.depth = Color[0]; clearValue.depthStencil.depth = Color[0];
clearValue.depthStencil.stencil = 0; clearValue.depthStencil.stencil = 0;
} }
@ -1004,12 +1010,14 @@ namespace dxvk {
cImageView = imgView, cImageView = imgView,
cAreaOffset = offset, cAreaOffset = offset,
cAreaExtent = extent, cAreaExtent = extent,
cClearAspect = clearAspect,
cClearValue = clearValue cClearValue = clearValue
] (DxvkContext* ctx) { ] (DxvkContext* ctx) {
ctx->clearImageView( ctx->clearImageView(
cImageView, cImageView,
cAreaOffset, cAreaOffset,
cAreaExtent, cAreaExtent,
cClearAspect,
cClearValue); cClearValue);
}); });
} }
@ -1034,13 +1042,17 @@ namespace dxvk {
if (imgView != nullptr) { if (imgView != nullptr) {
EmitCs([ EmitCs([
cImageView = imgView, cImageView = imgView,
cClearAspect = clearAspect,
cClearValue = clearValue cClearValue = clearValue
] (DxvkContext* ctx) { ] (DxvkContext* ctx) {
VkOffset3D offset = { 0, 0, 0 }; VkOffset3D offset = { 0, 0, 0 };
VkExtent3D extent = cImageView->mipLevelExtent(0); VkExtent3D extent = cImageView->mipLevelExtent(0);
ctx->clearImageView(cImageView, ctx->clearImageView(
offset, extent, cClearValue); cImageView,
offset, extent,
cClearAspect,
cClearValue);
}); });
} }
} }

View File

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

View File

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