mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[d3d11] Cache raw mapped pointer rather than allocation object
Reduces ref counting overhead again and matches previous behaviour. We should probably do something about the possible case of deferred context execution with MAP_WRITE_DISCARD followed by MAP_WRITE_NO_OVERWRITE on the immediate context, but we haven't seen a game rely on this yet.
This commit is contained in:
parent
50878f2846
commit
39f50999a3
@ -98,7 +98,7 @@ namespace dxvk {
|
||||
info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
|
||||
|
||||
m_buffer = m_parent->GetDXVKDevice()->importBuffer(info, importInfo, GetMemoryFlags());
|
||||
m_allocation = m_buffer->getAllocation();
|
||||
m_mapPtr = m_buffer->mapPtr(0);
|
||||
|
||||
m_mapMode = DetermineMapMode(m_buffer->memFlags());
|
||||
} else if (!(pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL)) {
|
||||
@ -114,12 +114,12 @@ namespace dxvk {
|
||||
// Create the buffer and set the entire buffer slice as mapped,
|
||||
// so that we only have to update it when invalidating the buffer
|
||||
m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, memoryFlags);
|
||||
m_allocation = m_buffer->getAllocation();
|
||||
m_mapPtr = m_buffer->mapPtr(0);
|
||||
} else {
|
||||
m_sparseAllocator = m_parent->GetDXVKDevice()->createSparsePageAllocator();
|
||||
m_sparseAllocator->setCapacity(info.size / SparseMemoryPageSize);
|
||||
|
||||
m_allocation = nullptr;
|
||||
m_mapPtr = nullptr;
|
||||
m_mapMode = D3D11_COMMON_BUFFER_MAP_MODE_NONE;
|
||||
}
|
||||
|
||||
|
@ -118,12 +118,13 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
Rc<DxvkResourceAllocation> DiscardSlice(DxvkLocalAllocationCache* cache) {
|
||||
m_allocation = m_buffer->allocateSlice(cache);
|
||||
return m_allocation;
|
||||
auto allocation = m_buffer->allocateSlice(cache);
|
||||
m_mapPtr = allocation->mapPtr();
|
||||
return allocation;
|
||||
}
|
||||
|
||||
Rc<DxvkResourceAllocation> GetMappedSlice() const {
|
||||
return m_allocation;
|
||||
void* GetMapPtr() const {
|
||||
return m_mapPtr;
|
||||
}
|
||||
|
||||
D3D10Buffer* GetD3D10Iface() {
|
||||
@ -184,9 +185,10 @@ namespace dxvk {
|
||||
Rc<DxvkBuffer> m_buffer;
|
||||
Rc<DxvkBuffer> m_soCounter;
|
||||
Rc<DxvkSparsePageAllocator> m_sparseAllocator;
|
||||
Rc<DxvkResourceAllocation> m_allocation;
|
||||
uint64_t m_seq = 0ull;
|
||||
|
||||
void* m_mapPtr = nullptr;
|
||||
|
||||
D3D11DXGIResource m_resource;
|
||||
D3D10Buffer m_d3d10;
|
||||
|
||||
|
@ -348,7 +348,7 @@ namespace dxvk {
|
||||
} else if (likely(MapType == D3D11_MAP_WRITE_NO_OVERWRITE)) {
|
||||
// Put this on a fast path without any extra checks since it's
|
||||
// a somewhat desired method to partially update large buffers
|
||||
pMappedResource->pData = pResource->GetMappedSlice()->mapPtr();
|
||||
pMappedResource->pData = pResource->GetMapPtr();
|
||||
pMappedResource->RowPitch = bufferSize;
|
||||
pMappedResource->DepthPitch = bufferSize;
|
||||
return S_OK;
|
||||
@ -376,10 +376,9 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
if (doInvalidatePreserve) {
|
||||
auto srcSlice = pResource->GetMappedSlice();
|
||||
auto dstSlice = pResource->DiscardSlice(nullptr);
|
||||
auto srcPtr = pResource->GetMapPtr();
|
||||
|
||||
auto srcPtr = srcSlice->mapPtr();
|
||||
auto dstSlice = pResource->DiscardSlice(nullptr);
|
||||
auto dstPtr = dstSlice->mapPtr();
|
||||
|
||||
EmitCs([
|
||||
@ -398,7 +397,7 @@ namespace dxvk {
|
||||
if (!WaitForResource(buffer, sequenceNumber, MapType, MapFlags))
|
||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
||||
|
||||
pMappedResource->pData = pResource->GetMappedSlice()->mapPtr();
|
||||
pMappedResource->pData = pResource->GetMapPtr();
|
||||
pMappedResource->RowPitch = bufferSize;
|
||||
pMappedResource->DepthPitch = bufferSize;
|
||||
return S_OK;
|
||||
@ -713,7 +712,7 @@ namespace dxvk {
|
||||
ctx->invalidateBuffer(cBuffer, std::move(cBufferSlice));
|
||||
});
|
||||
} else {
|
||||
mapPtr = pDstBuffer->GetMappedSlice()->mapPtr();
|
||||
mapPtr = pDstBuffer->GetMapPtr();
|
||||
}
|
||||
|
||||
std::memcpy(reinterpret_cast<char*>(mapPtr) + Offset, pSrcData, Length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user