mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[d3d11] Optimize Unmap on immediate contexts
This commit is contained in:
parent
5a6711ed1d
commit
0364a79eb0
@ -273,12 +273,17 @@ namespace dxvk {
|
|||||||
void STDMETHODCALLTYPE D3D11ImmediateContext::Unmap(
|
void STDMETHODCALLTYPE D3D11ImmediateContext::Unmap(
|
||||||
ID3D11Resource* pResource,
|
ID3D11Resource* pResource,
|
||||||
UINT Subresource) {
|
UINT Subresource) {
|
||||||
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
// Since it is very uncommon for images to be mapped compared
|
||||||
pResource->GetType(&resourceDim);
|
// to buffers, we count the currently mapped images in order
|
||||||
|
// to avoid a virtual method call in the common case.
|
||||||
|
if (unlikely(m_mappedImageCount > 0)) {
|
||||||
|
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||||
|
pResource->GetType(&resourceDim);
|
||||||
|
|
||||||
if (unlikely(resourceDim != D3D11_RESOURCE_DIMENSION_BUFFER)) {
|
if (resourceDim != D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
D3D10DeviceLock lock = LockContext();
|
D3D10DeviceLock lock = LockContext();
|
||||||
UnmapImage(GetCommonTexture(pResource), Subresource);
|
UnmapImage(GetCommonTexture(pResource), Subresource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +472,7 @@ namespace dxvk {
|
|||||||
pMappedResource->DepthPitch = layout.DepthPitch;
|
pMappedResource->DepthPitch = layout.DepthPitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_mappedImageCount += 1;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,11 +483,15 @@ namespace dxvk {
|
|||||||
D3D11_MAP mapType = pResource->GetMapType(Subresource);
|
D3D11_MAP mapType = pResource->GetMapType(Subresource);
|
||||||
pResource->SetMapType(Subresource, D3D11_MAP(~0u));
|
pResource->SetMapType(Subresource, D3D11_MAP(~0u));
|
||||||
|
|
||||||
if (mapType == D3D11_MAP(~0u)
|
if (mapType == D3D11_MAP(~0u))
|
||||||
|| mapType == D3D11_MAP_READ)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER) {
|
// Decrement mapped image counter only after making sure
|
||||||
|
// the given subresource is actually mapped right now
|
||||||
|
m_mappedImageCount -= 1;
|
||||||
|
|
||||||
|
if ((mapType != D3D11_MAP_READ) &&
|
||||||
|
(pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER)) {
|
||||||
// Now that data has been written into the buffer,
|
// Now that data has been written into the buffer,
|
||||||
// we need to copy its contents into the image
|
// we need to copy its contents into the image
|
||||||
VkImageAspectFlags aspectMask = imageFormatInfo(pResource->GetPackedFormat())->aspectMask;
|
VkImageAspectFlags aspectMask = imageFormatInfo(pResource->GetPackedFormat())->aspectMask;
|
||||||
|
@ -123,6 +123,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<sync::CallbackFence> m_eventSignal;
|
Rc<sync::CallbackFence> m_eventSignal;
|
||||||
uint64_t m_eventCount = 0ull;
|
uint64_t m_eventCount = 0ull;
|
||||||
|
uint32_t m_mappedImageCount = 0u;
|
||||||
|
|
||||||
|
|
||||||
dxvk::high_resolution_clock::time_point m_lastFlush
|
dxvk::high_resolution_clock::time_point m_lastFlush
|
||||||
|
Loading…
x
Reference in New Issue
Block a user