Skip to content

Commit

Permalink
[dxvk] Refactor meta blits
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Sep 28, 2024
1 parent 051883c commit 35c7913
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 315 deletions.
37 changes: 27 additions & 10 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,20 +1330,37 @@ namespace dxvk {
srcImage = resolveSrc;
}

DxvkImageViewKey dstViewInfo;
dstViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
dstViewInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT;
dstViewInfo.format = dstImage->info().format;
dstViewInfo.aspects = blitInfo.dstSubresource.aspectMask;
dstViewInfo.mipIndex = blitInfo.dstSubresource.mipLevel;
dstViewInfo.mipCount = 1;
dstViewInfo.layerIndex = blitInfo.dstSubresource.baseArrayLayer;
dstViewInfo.layerCount = blitInfo.dstSubresource.layerCount;
dstViewInfo.packedSwizzle = DxvkImageViewKey::packSwizzle(dstTextureInfo->GetMapping().Swizzle);

DxvkImageViewKey srcViewInfo;
srcViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
srcViewInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
srcViewInfo.format = srcImage->info().format;
srcViewInfo.aspects = blitInfo.srcSubresource.aspectMask;
srcViewInfo.mipIndex = blitInfo.srcSubresource.mipLevel;
srcViewInfo.mipCount = 1;
srcViewInfo.layerIndex = blitInfo.srcSubresource.baseArrayLayer;
srcViewInfo.layerCount = blitInfo.srcSubresource.layerCount;
srcViewInfo.packedSwizzle = DxvkImageViewKey::packSwizzle(srcTextureInfo->GetMapping().Swizzle);

EmitCs([
cDstImage = dstImage,
cDstMap = dstTextureInfo->GetMapping().Swizzle,
cSrcImage = srcImage,
cSrcMap = srcTextureInfo->GetMapping().Swizzle,
cDstView = dstImage->createView(dstViewInfo),
cSrcView = srcImage->createView(srcViewInfo),
cBlitInfo = blitInfo,
cFilter = stretch ? DecodeFilter(Filter) : VK_FILTER_NEAREST
] (DxvkContext* ctx) {
ctx->blitImage(
cDstImage,
cDstMap,
cSrcImage,
cSrcMap,
cBlitInfo,
ctx->blitImageView(
cDstView, cBlitInfo.dstOffsets,
cSrcView, cBlitInfo.srcOffsets,
cFilter);
});
}
Expand Down
36 changes: 28 additions & 8 deletions src/d3d9/d3d9_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,37 @@ namespace dxvk {
}
#endif

DxvkImageViewKey dstViewInfo;
dstViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
dstViewInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT;
dstViewInfo.format = blittedSrc->info().format;
dstViewInfo.aspects = blitInfo.dstSubresource.aspectMask;
dstViewInfo.mipIndex = blitInfo.dstSubresource.mipLevel;
dstViewInfo.mipCount = 1;
dstViewInfo.layerIndex = blitInfo.dstSubresource.baseArrayLayer;
dstViewInfo.layerCount = blitInfo.dstSubresource.layerCount;
dstViewInfo.packedSwizzle = DxvkImageViewKey::packSwizzle(dstTexInfo->GetMapping().Swizzle);

DxvkImageViewKey srcViewInfo;
srcViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
srcViewInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
srcViewInfo.format = srcImage->info().format;
srcViewInfo.aspects = blitInfo.srcSubresource.aspectMask;
srcViewInfo.mipIndex = blitInfo.srcSubresource.mipLevel;
srcViewInfo.mipCount = 1;
srcViewInfo.layerIndex = blitInfo.srcSubresource.baseArrayLayer;
srcViewInfo.layerCount = blitInfo.srcSubresource.layerCount;
srcViewInfo.packedSwizzle = DxvkImageViewKey::packSwizzle(srcTexInfo->GetMapping().Swizzle);

m_parent->EmitCs([
cDstImage = blittedSrc,
cDstMap = dstTexInfo->GetMapping().Swizzle,
cSrcImage = srcImage,
cSrcMap = srcTexInfo->GetMapping().Swizzle,
cDstView = blittedSrc->createView(dstViewInfo),
cSrcView = srcImage->createView(srcViewInfo),
cBlitInfo = blitInfo
] (DxvkContext* ctx) {
ctx->blitImage(
cDstImage, cDstMap,
cSrcImage, cSrcMap,
cBlitInfo, VK_FILTER_NEAREST);
ctx->blitImageView(
cDstView, cBlitInfo.dstOffsets,
cSrcView, cBlitInfo.srcOffsets,
VK_FILTER_NEAREST);
});

srcImage = std::move(blittedSrc);
Expand Down
Loading

0 comments on commit 35c7913

Please sign in to comment.