...
 
Commits (2)
......@@ -355,13 +355,6 @@ namespace dxvk {
bool GetUploading(UINT Subresource) const { return m_uploading.get(Subresource); }
void SetNeedsUpload(UINT Subresource, bool upload) { m_needsUpload.set(Subresource, upload); }
void MarkAllForUpload() {
uint32_t subresourceDwords = CountSubresources() / 32;
for (uint32_t i = 0; i < subresourceDwords; i++)
m_needsUpload.dword(i) = std::numeric_limits<uint32_t>::max();
m_needsUpload.dword(subresourceDwords) = CountSubresources() % 32;
}
bool NeedsAnyUpload() { return m_needsUpload.any(); }
void ClearNeedsUpload() { return m_needsUpload.clearAll(); }
......
......@@ -4098,6 +4098,22 @@ namespace dxvk {
pResource->SetLocked(Subresource, true);
if (pResource->IsManaged() && !m_d3d9Options.evictManagedOnUnlock) {
pResource->SetNeedsUpload(Subresource, true);
for (uint32_t tex = m_activeTextures; tex; tex &= tex - 1) {
// Guaranteed to not be nullptr...
const uint32_t i = bit::tzcnt(tex);
auto texInfo = GetCommonTexture(m_state.textures[i]);
if (texInfo == pResource) {
m_activeTexturesToUpload |= 1 << i;
// We can early out here, no need to add another index for this.
break;
}
}
}
const uint32_t offset = CalcImageLockOffset(
pLockedBox->SlicePitch,
pLockedBox->RowPitch,
......@@ -4120,39 +4136,27 @@ namespace dxvk {
UINT Subresource = pResource->CalcSubresource(Face, MipLevel);
// We weren't locked anyway!
if (unlikely(!pResource->GetLocked(Subresource) && !m_d3d9Options.uploadAllManagedSubresources))
if (unlikely(!pResource->GetLocked(Subresource)))
return D3DERR_INVALIDCALL;
pResource->SetLocked(Subresource, false);
// Do we have a pending copy?
if (!pResource->GetReadOnlyLocked(Subresource)) {
// Only flush buffer -> image if we actually have an image
if (pResource->IsManaged() && !m_d3d9Options.evictManagedOnUnlock) {
if (unlikely(m_d3d9Options.uploadAllManagedSubresources))
pResource->MarkAllForUpload();
else
pResource->SetNeedsUpload(Subresource, true);
for (uint32_t tex = m_activeTextures; tex; tex &= tex - 1) {
// Guaranteed to not be nullptr...
const uint32_t i = bit::tzcnt(tex);
auto texInfo = GetCommonTexture(m_state.textures[i]);
if (texInfo == pResource) {
m_activeTexturesToUpload |= 1 << i;
// We can early out here, no need to add another index for this.
break;
}
}
}
else if (pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED)
// Flush image contents from staging if we aren't read only
// and we aren't deferring for managed.
bool shouldFlush = pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED;
shouldFlush &= !pResource->GetReadOnlyLocked(Subresource);
shouldFlush &= !pResource->IsManaged() || m_d3d9Options.evictManagedOnUnlock;
if (shouldFlush)
this->FlushImage(pResource, Subresource);
}
if (pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED
&& (!pResource->IsDynamic())
&& (!pResource->IsManaged() || m_d3d9Options.evictManagedOnUnlock)) {
// Toss our staging buffer if we're not dynamic
// and we aren't managed (for sysmem copy.)
bool shouldToss = pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED;
shouldToss &= !pResource->IsDynamic();
shouldToss &= !pResource->IsManaged() || m_d3d9Options.evictManagedOnUnlock;
if (shouldToss) {
pResource->DestroyBufferSubresource(Subresource);
pResource->SetDirty(Subresource, true);
}
......@@ -4170,9 +4174,6 @@ namespace dxvk {
// we need to copy its contents into the image
const Rc<DxvkBuffer> copyBuffer = pResource->GetBuffer(Subresource);
if (unlikely(copyBuffer == nullptr))
return D3D_OK;
auto formatInfo = imageFormatInfo(image->info().format);
auto subresource = pResource->GetSubresourceFromIndex(
formatInfo->aspectMask, Subresource);
......
......@@ -71,7 +71,6 @@ namespace dxvk {
this->enumerateByDisplays = config.getOption<bool> ("d3d9.enumerateByDisplays", true);
this->longMad = config.getOption<bool> ("d3d9.longMad", false);
this->tearFree = config.getOption<Tristate> ("d3d9.tearFree", Tristate::Auto);
this->uploadAllManagedSubresources = config.getOption<bool>("d3d9.uploadAllManagedSubresources", false);
// If we are not Nvidia, enable general hazards.
this->generalHazards = adapter == nullptr || !adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0);
......
......@@ -147,10 +147,6 @@ namespace dxvk {
/// Tear-free mode if vsync is disabled
/// Tearing mode if vsync is enabled
Tristate tearFree;
/// Upload all subresources of managed resources when unlocked.
/// Workaround for a game bug in Nekopara.
bool uploadAllManagedSubresources;
};
}
\ No newline at end of file
......@@ -352,10 +352,6 @@ namespace dxvk {
{ R"(\\SpellForce2.*\.exe$)", {{
{ "d3d9.forceSamplerTypeSpecConstants", "True" },
}} },
/* Nekopara */
{ R"(\\nekopara.*\.exe$)", {{
{ "d3d9.uploadAllManagedSubresources", "True" },
}} },
}};
......