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