From 077f48b4efc89b89c6dd8c28ff3341910d4ad3f1 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 29 Feb 2020 14:00:15 +0000 Subject: [PATCH] [d3d9] Flush format converter in device after init Otherwise we can be overwritten if its a new resource we just created by the initializer. --- src/d3d9/d3d9_device.cpp | 1 + src/d3d9/d3d9_format_helpers.cpp | 17 +++++++++++++++-- src/d3d9/d3d9_format_helpers.h | 6 ++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 9189eaf79..211c3854f 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4682,6 +4682,7 @@ namespace dxvk { D3D9DeviceLock lock = LockDevice(); m_initializer->Flush(); + m_converter->Flush(); if (m_csIsBusy || !m_csChunk->empty()) { // Add commands to flush the threaded diff --git a/src/d3d9/d3d9_format_helpers.cpp b/src/d3d9/d3d9_format_helpers.cpp index 50e43e6e7..460b3c262 100644 --- a/src/d3d9/d3d9_format_helpers.cpp +++ b/src/d3d9/d3d9_format_helpers.cpp @@ -14,6 +14,12 @@ namespace dxvk { } + void D3D9FormatHelper::Flush() { + if (m_transferCommands != 0) + FlushInternal(); + } + + void D3D9FormatHelper::ConvertFormat( D3D9_CONVERSION_FORMAT_INFO conversionFormat, const Rc& dstImage, @@ -67,7 +73,7 @@ namespace dxvk { (imageExtent.height / 8) + (imageExtent.height % 8), 1); - m_context->flushCommandList(); + m_transferCommands += 1; } @@ -112,7 +118,7 @@ namespace dxvk { // Reset the spec constants used... m_context->setSpecConstant(VK_PIPELINE_BIND_POINT_COMPUTE, 0, 0); - m_context->flushCommandList(); + m_transferCommands += 1; } @@ -135,4 +141,11 @@ namespace dxvk { { 0u, 0u, 0u, sizeof(VkExtent2D) }, code); } + + void D3D9FormatHelper::FlushInternal() { + m_context->flushCommandList(); + + m_transferCommands = 0; + } + } \ No newline at end of file diff --git a/src/d3d9/d3d9_format_helpers.h b/src/d3d9/d3d9_format_helpers.h index 5c100c868..99327666e 100644 --- a/src/d3d9/d3d9_format_helpers.h +++ b/src/d3d9/d3d9_format_helpers.h @@ -13,6 +13,8 @@ namespace dxvk { D3D9FormatHelper(const Rc& device); + void Flush(); + void ConvertFormat( D3D9_CONVERSION_FORMAT_INFO conversionFormat, const Rc& dstImage, @@ -43,9 +45,13 @@ namespace dxvk { Rc InitShader(SpirvCodeBuffer code); + void FlushInternal(); + Rc m_device; Rc m_context; + size_t m_transferCommands = 0; + std::array, D3D9ConversionFormat_Count> m_shaders; };