1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 16:24:12 +01:00

[d3d11] Use GetSubresourceLayout for image maps on the immediate context

This commit is contained in:
Philip Rebohle 2021-05-19 17:18:08 +02:00
parent 1b296f8338
commit 7184b75f8f
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -418,8 +418,6 @@ namespace dxvk {
formatInfo->aspectMask, Subresource);
if (pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) {
const VkImageType imageType = mappedImage->info().type;
// Wait for the resource to become available
if (!WaitForResource(mappedImage, MapType, MapFlags))
return DXGI_ERROR_WAS_STILL_DRAWING;
@ -430,17 +428,14 @@ namespace dxvk {
// Query the subresource's memory layout and hope that
// the application respects the returned pitch values.
if (pMappedResource) {
VkSubresourceLayout layout = mappedImage->querySubresourceLayout(subresource);
pMappedResource->pData = mappedImage->mapPtr(layout.offset);
pMappedResource->RowPitch = imageType >= VK_IMAGE_TYPE_2D ? layout.rowPitch : layout.size;
pMappedResource->DepthPitch = imageType >= VK_IMAGE_TYPE_3D ? layout.depthPitch : layout.size;
auto layout = pResource->GetSubresourceLayout(formatInfo->aspectMask, Subresource);
pMappedResource->pData = mappedImage->mapPtr(layout.Offset);
pMappedResource->RowPitch = layout.RowPitch;
pMappedResource->DepthPitch = layout.DepthPitch;
}
return S_OK;
} else {
VkExtent3D levelExtent = mappedImage->mipLevelExtent(subresource.mipLevel);
VkExtent3D blockCount = util::computeBlockCount(levelExtent, formatInfo->blockSize);
DxvkBufferSliceHandle physSlice;
if (MapType == D3D11_MAP_WRITE_DISCARD) {
@ -476,9 +471,10 @@ namespace dxvk {
// Set up map pointer. Data is tightly packed within the mapped buffer.
if (pMappedResource) {
pMappedResource->pData = physSlice.mapPtr;
pMappedResource->RowPitch = formatInfo->elementSize * blockCount.width;
pMappedResource->DepthPitch = formatInfo->elementSize * blockCount.width * blockCount.height;
auto layout = pResource->GetSubresourceLayout(formatInfo->aspectMask, Subresource);
pMappedResource->pData = reinterpret_cast<char*>(physSlice.mapPtr) + layout.Offset;
pMappedResource->RowPitch = layout.RowPitch;
pMappedResource->DepthPitch = layout.DepthPitch;
}
return S_OK;