mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-01 16:24:12 +01:00
[d3d11] Fix MAP_WRITE_DISCARD for mapped images on deferred contexts
The previous implementation was straight-up broken since it would use the wrong subresource layout. We can discard the image now so let's just do that.
This commit is contained in:
parent
30f2a8c26b
commit
789e8db699
@ -302,25 +302,42 @@ namespace dxvk {
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
VkFormat packedFormat = pTexture->GetPackedFormat();
|
VkFormat packedFormat = pTexture->GetPackedFormat();
|
||||||
|
|
||||||
auto formatInfo = lookupFormatInfo(packedFormat);
|
auto formatInfo = lookupFormatInfo(packedFormat);
|
||||||
auto subresource = pTexture->GetSubresourceFromIndex(
|
|
||||||
formatInfo->aspectMask, Subresource);
|
|
||||||
|
|
||||||
VkExtent3D levelExtent = pTexture->MipLevelExtent(subresource.mipLevel);
|
|
||||||
|
|
||||||
auto layout = pTexture->GetSubresourceLayout(formatInfo->aspectMask, Subresource);
|
auto layout = pTexture->GetSubresourceLayout(formatInfo->aspectMask, Subresource);
|
||||||
auto dataSlice = AllocStagingBuffer(util::computeImageDataSize(packedFormat, levelExtent));
|
|
||||||
|
if (pTexture->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) {
|
||||||
|
auto storage = pTexture->AllocStorage();
|
||||||
|
auto mapPtr = storage->mapPtr();
|
||||||
|
|
||||||
|
EmitCs([
|
||||||
|
cImage = pTexture->GetImage(),
|
||||||
|
cStorage = std::move(storage)
|
||||||
|
] (DxvkContext* ctx) {
|
||||||
|
ctx->invalidateImage(cImage, Rc<DxvkResourceAllocation>(cStorage));
|
||||||
|
ctx->initImage(cImage, cImage->getAvailableSubresources(), VK_IMAGE_LAYOUT_PREINITIALIZED);
|
||||||
|
});
|
||||||
|
|
||||||
|
pMappedResource->RowPitch = layout.RowPitch;
|
||||||
|
pMappedResource->DepthPitch = layout.DepthPitch;
|
||||||
|
pMappedResource->pData = mapPtr;
|
||||||
|
return S_OK;
|
||||||
|
} else {
|
||||||
|
auto dataSlice = AllocStagingBuffer(layout.Size);
|
||||||
|
|
||||||
pMappedResource->RowPitch = layout.RowPitch;
|
pMappedResource->RowPitch = layout.RowPitch;
|
||||||
pMappedResource->DepthPitch = layout.DepthPitch;
|
pMappedResource->DepthPitch = layout.DepthPitch;
|
||||||
pMappedResource->pData = dataSlice.mapPtr(0);
|
pMappedResource->pData = dataSlice.mapPtr(0);
|
||||||
|
|
||||||
|
auto subresource = pTexture->GetSubresourceFromIndex(formatInfo->aspectMask, Subresource);
|
||||||
|
auto mipExtent = pTexture->MipLevelExtent(subresource.mipLevel);
|
||||||
|
|
||||||
UpdateImage(pTexture, &subresource,
|
UpdateImage(pTexture, &subresource,
|
||||||
VkOffset3D { 0, 0, 0 }, levelExtent,
|
VkOffset3D { 0, 0, 0 }, mipExtent,
|
||||||
std::move(dataSlice));
|
std::move(dataSlice));
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D11DeferredContext::UpdateMappedBuffer(
|
void D3D11DeferredContext::UpdateMappedBuffer(
|
||||||
|
Loading…
Reference in New Issue
Block a user