mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-20 08:52:22 +01:00
[d3d9] Fix various other ColorFill edge cases
Fixes all remaining validation in wine's color_fill_test. Some failed tests remain because apparently we do not validate resource txpes properly.
This commit is contained in:
parent
ccd19ce90b
commit
3c88591326
@ -75,6 +75,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static constexpr UINT AllLayers = UINT32_MAX;
|
||||||
|
|
||||||
D3D9CommonTexture(
|
D3D9CommonTexture(
|
||||||
D3D9DeviceEx* pDevice,
|
D3D9DeviceEx* pDevice,
|
||||||
IUnknown* pInterface,
|
IUnknown* pInterface,
|
||||||
@ -555,8 +557,6 @@ namespace dxvk {
|
|||||||
D3DRESOURCETYPE Dimension,
|
D3DRESOURCETYPE Dimension,
|
||||||
UINT Layer);
|
UINT Layer);
|
||||||
|
|
||||||
static constexpr UINT AllLayers = UINT32_MAX;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1445,6 +1445,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
D3D9CommonTexture* dstTextureInfo = dst->GetCommonTexture();
|
D3D9CommonTexture* dstTextureInfo = dst->GetCommonTexture();
|
||||||
|
|
||||||
|
if (dstTextureInfo->IsNull())
|
||||||
|
return D3D_OK;
|
||||||
|
|
||||||
if (unlikely(dstTextureInfo->Desc()->Pool != D3DPOOL_DEFAULT))
|
if (unlikely(dstTextureInfo->Desc()->Pool != D3DPOOL_DEFAULT))
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
@ -1453,37 +1456,38 @@ namespace dxvk {
|
|||||||
VkOffset3D offset = VkOffset3D{ 0u, 0u, 0u };
|
VkOffset3D offset = VkOffset3D{ 0u, 0u, 0u };
|
||||||
VkExtent3D extent = mipExtent;
|
VkExtent3D extent = mipExtent;
|
||||||
|
|
||||||
bool isFullExtent = true;
|
if (pRect != nullptr)
|
||||||
if (pRect != nullptr) {
|
|
||||||
ConvertRect(*pRect, offset, extent);
|
ConvertRect(*pRect, offset, extent);
|
||||||
|
|
||||||
isFullExtent = offset == VkOffset3D{ 0u, 0u, 0u }
|
|
||||||
&& extent == mipExtent;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rc<DxvkImageView> rtView = dst->GetRenderTargetView(false);
|
|
||||||
|
|
||||||
if (unlikely(!rtView)) {
|
|
||||||
const D3D9Format format = dstTextureInfo->Desc()->Format;
|
|
||||||
|
|
||||||
if (format != D3D9Format::NULL_FORMAT)
|
|
||||||
Logger::err(str::format("D3D9DeviceEx::ColorFill: Unsupported format ", format));
|
|
||||||
|
|
||||||
return D3D_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkClearValue clearValue = { };
|
VkClearValue clearValue = { };
|
||||||
DecodeD3DCOLOR(Color, clearValue.color.float32);
|
DecodeD3DCOLOR(Color, clearValue.color.float32);
|
||||||
|
|
||||||
if (rtView && rtView->formatInfo()->flags.test(DxvkFormatFlag::BlockCompressed)) {
|
Rc<DxvkImage> image = dstTextureInfo->GetImage();
|
||||||
|
|
||||||
|
if (image->formatInfo()->aspectMask != VK_IMAGE_ASPECT_COLOR_BIT)
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
VkImageSubresourceLayers subresource = { };
|
||||||
|
subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
subresource.mipLevel = dst->GetMipLevel();
|
||||||
|
|
||||||
|
if (dst->GetFace() == D3D9CommonTexture::AllLayers) {
|
||||||
|
subresource.baseArrayLayer = 0u;
|
||||||
|
subresource.layerCount = image->info().numLayers;
|
||||||
|
} else {
|
||||||
|
subresource.baseArrayLayer = dst->GetFace();
|
||||||
|
subresource.layerCount = 1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image->formatInfo()->flags.test(DxvkFormatFlag::BlockCompressed)) {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cImage = rtView->image(),
|
cImage = std::move(image),
|
||||||
cViewKey = rtView->info(),
|
cSubresource = subresource,
|
||||||
cOffset = offset,
|
cOffset = offset,
|
||||||
cExtent = extent,
|
cExtent = extent,
|
||||||
cClearValue = clearValue
|
cClearValue = clearValue
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
auto formatInfo = lookupFormatInfo(cViewKey.format);
|
auto formatInfo = cImage->formatInfo();
|
||||||
|
|
||||||
VkFormat blockFormat = formatInfo->elementSize == 16u
|
VkFormat blockFormat = formatInfo->elementSize == 16u
|
||||||
? VK_FORMAT_R32G32B32A32_UINT
|
? VK_FORMAT_R32G32B32A32_UINT
|
||||||
@ -1500,14 +1504,20 @@ namespace dxvk {
|
|||||||
|
|
||||||
ctx->ensureImageCompatibility(cImage, usage);
|
ctx->ensureImageCompatibility(cImage, usage);
|
||||||
|
|
||||||
DxvkImageViewKey viewKey = cViewKey;
|
DxvkImageViewKey viewKey = { };
|
||||||
|
viewKey.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
||||||
viewKey.format = blockFormat;
|
viewKey.format = blockFormat;
|
||||||
viewKey.usage = VK_IMAGE_USAGE_STORAGE_BIT;
|
viewKey.usage = VK_IMAGE_USAGE_STORAGE_BIT;
|
||||||
|
viewKey.aspects = cSubresource.aspectMask;
|
||||||
|
viewKey.mipIndex = cSubresource.mipLevel;
|
||||||
|
viewKey.mipCount = 1u;
|
||||||
|
viewKey.layerIndex = cSubresource.baseArrayLayer;
|
||||||
|
viewKey.layerCount = cSubresource.layerCount;
|
||||||
|
|
||||||
Rc<DxvkImageView> view = cImage->createView(viewKey);
|
Rc<DxvkImageView> view = cImage->createView(viewKey);
|
||||||
|
|
||||||
VkClearValue clearBlock = { };
|
VkClearValue clearBlock = { };
|
||||||
clearBlock.color = util::encodeClearBlockValue(cViewKey.format, cClearValue.color);
|
clearBlock.color = util::encodeClearBlockValue(cImage->info().format, cClearValue.color);
|
||||||
|
|
||||||
VkOffset3D offset = util::computeBlockOffset(cOffset, formatInfo->blockSize);
|
VkOffset3D offset = util::computeBlockOffset(cOffset, formatInfo->blockSize);
|
||||||
VkExtent3D extent = util::computeBlockExtent(cExtent, formatInfo->blockSize);
|
VkExtent3D extent = util::computeBlockExtent(cExtent, formatInfo->blockSize);
|
||||||
@ -1515,28 +1525,37 @@ namespace dxvk {
|
|||||||
ctx->clearImageView(view, offset, extent,
|
ctx->clearImageView(view, offset, extent,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT, clearBlock);
|
VK_IMAGE_ASPECT_COLOR_BIT, clearBlock);
|
||||||
});
|
});
|
||||||
} else if (isFullExtent) {
|
|
||||||
EmitCs([
|
|
||||||
cImageView = rtView,
|
|
||||||
cClearValue = clearValue
|
|
||||||
] (DxvkContext* ctx) {
|
|
||||||
ctx->clearRenderTarget(
|
|
||||||
cImageView,
|
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
|
||||||
cClearValue);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cImageView = rtView,
|
cImage = std::move(image),
|
||||||
|
cSubresource = subresource,
|
||||||
cOffset = offset,
|
cOffset = offset,
|
||||||
cExtent = extent,
|
cExtent = extent,
|
||||||
cClearValue = clearValue
|
cClearValue = clearValue
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
ctx->clearImageView(
|
DxvkImageUsageInfo usage = { };
|
||||||
cImageView,
|
usage.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
cOffset, cExtent,
|
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
ctx->ensureImageCompatibility(cImage, usage);
|
||||||
cClearValue);
|
|
||||||
|
DxvkImageViewKey viewKey = { };
|
||||||
|
viewKey.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
||||||
|
viewKey.format = cImage->info().format;
|
||||||
|
viewKey.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
|
viewKey.aspects = cSubresource.aspectMask;
|
||||||
|
viewKey.mipIndex = cSubresource.mipLevel;
|
||||||
|
viewKey.mipCount = 1u;
|
||||||
|
viewKey.layerIndex = cSubresource.baseArrayLayer;
|
||||||
|
viewKey.layerCount = cSubresource.layerCount;
|
||||||
|
|
||||||
|
Rc<DxvkImageView> view = cImage->createView(viewKey);
|
||||||
|
|
||||||
|
if (cOffset == VkOffset3D() && cExtent == cImage->mipLevelExtent(viewKey.mipIndex)) {
|
||||||
|
ctx->clearRenderTarget(view, cSubresource.aspectMask, cClearValue);
|
||||||
|
} else {
|
||||||
|
ctx->clearImageView(view, cOffset, cExtent,
|
||||||
|
cSubresource.aspectMask, cClearValue);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user