Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d3d11] Use host memory in deferred context for "small" updates. #1805

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions src/d3d11/d3d11_context_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,33 @@ namespace dxvk {
pMapEntry->DepthPitch = pBuffer->Desc()->ByteWidth;

if (likely(m_csFlags.test(DxvkCsChunkFlag::SingleUse))) {
// For resources that cannot be written by the GPU,
// we may write to the buffer resource directly and
// just swap in the buffer slice as needed.
auto bufferSlice = pBuffer->AllocSlice();
pMapEntry->MapPointer = bufferSlice.mapPtr;

EmitCs([
cDstBuffer = pBuffer->GetBuffer(),
cPhysSlice = bufferSlice
] (DxvkContext* ctx) {
ctx->invalidateBuffer(cDstBuffer, cPhysSlice);
});
if (pBuffer->Desc()->ByteWidth <= 4096) {
pMapEntry->MapPointer = std::malloc(pBuffer->Desc()->ByteWidth);

EmitCs([
cDstBuffer = pBuffer->GetBuffer(),
cSliceLength = pBuffer->Desc()->ByteWidth,
cSlicePointer = pMapEntry->MapPointer
] (DxvkContext* ctx) {
DxvkBufferSliceHandle slice = cDstBuffer->allocSlice();
std::memcpy(slice.mapPtr, cSlicePointer, cSliceLength);
std::free(cSlicePointer);
ctx->invalidateBuffer(cDstBuffer, slice);
});
} else {
// For resources that cannot be written by the GPU,
// we may write to the buffer resource directly and
// just swap in the buffer slice as needed.
auto bufferSlice = pBuffer->AllocSlice();
pMapEntry->MapPointer = bufferSlice.mapPtr;

EmitCs([
cDstBuffer = pBuffer->GetBuffer(),
cPhysSlice = bufferSlice
] (DxvkContext* ctx) {
ctx->invalidateBuffer(cDstBuffer, cPhysSlice);
});
}
} else {
// For GPU-writable resources, we need a data slice
// to perform the update operation at execution time.
Expand Down