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

Fix for EvictManagedOnUnlock & SWTOR performance #2126

Merged
merged 2 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/d3d9/d3d9_common_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ namespace dxvk {

bool GetLocked(UINT Subresource) const { return m_locked.get(Subresource); }

bool IsAnySubresourceLocked() const { return m_locked.any(); }

void SetWrittenByGPU(UINT Subresource, bool value) { m_wasWrittenByGPU.set(Subresource, value); }

bool WasWrittenByGPU(UINT Subresource) const { return m_wasWrittenByGPU.get(Subresource); }
Expand Down
8 changes: 5 additions & 3 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4166,10 +4166,12 @@ namespace dxvk {
cPackedFormat = packedFormat
] (DxvkContext* ctx) {
if (cSubresources.aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
ctx->copyImageToBuffer(cImageBuffer, 0, 0, 0,
ctx->copyImageToBuffer(cImageBuffer, 0, 4, 0,
cImage, cSubresources, VkOffset3D { 0, 0, 0 },
cLevelExtent);
} else {
// Copying DS to a packed buffer is only supported for D24S8 and D32S8
// right now so the 4 byte row alignment is guaranteed by the format size
ctx->copyDepthStencilImageToPackedBuffer(
cImageBuffer, 0,
VkOffset2D { 0, 0 },
Expand Down Expand Up @@ -4223,7 +4225,7 @@ namespace dxvk {
}
}

if (pResource->IsManaged() && !m_d3d9Options.evictManagedOnUnlock && !readOnly) {
if (managed && !m_d3d9Options.evictManagedOnUnlock && !readOnly) {
pResource->SetNeedsUpload(Subresource, true);

for (uint32_t tex = m_activeTextures; tex; tex &= tex - 1) {
Expand Down Expand Up @@ -4275,7 +4277,7 @@ namespace dxvk {

if (shouldFlush) {
this->FlushImage(pResource, Subresource);
if (pResource->IsManaged())
if (!pResource->IsAnySubresourceLocked())
pResource->ClearDirtyBoxes();
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/util_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ namespace dxvk::bit {
m_dwords[i] = 0;
}

constexpr bool any() {
constexpr bool any() const {
for (size_t i = 0; i < Dwords; i++) {
if (m_dwords[i] != 0)
return true;
Expand Down