Commit 1f89f58f by Jamie Madill

Do not call Scheduler destructor in libVulkan.

This is causing a deadlock on Windows 7. The process teardown is calling a destructor function that ends up calling a bunch of synchronization logic that should not be called on process exit. Bug: b/141380274 Bug: angleproject:3909 Change-Id: I4787d495d965e8b43d15be9c952c4b1de9bdf197 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36548 Presubmit-Ready: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 2ef66b69
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include "VkConfig.h" #include "VkConfig.h"
#include "Pipeline/SpirvShader.hpp" // sw::SIMD::Width #include "Pipeline/SpirvShader.hpp" // sw::SIMD::Width
#include "System/CPUID.hpp"
#include "marl/thread.h"
#include <limits> #include <limits>
#include <cstring> #include <cstring>
...@@ -23,8 +26,13 @@ ...@@ -23,8 +26,13 @@
namespace vk namespace vk
{ {
PhysicalDevice::PhysicalDevice(const void*, void* mem) PhysicalDevice::PhysicalDevice(const void*, void* mem) : scheduler(new marl::Scheduler())
{ {
scheduler->setThreadInitializer([] {
sw::CPUID::setFlushToZero(true);
sw::CPUID::setDenormalsAreZero(true);
});
scheduler->setWorkerThreadCount(std::min<size_t>(marl::Thread::numLogicalCPUs(), 16));
} }
const VkPhysicalDeviceFeatures& PhysicalDevice::getFeatures() const const VkPhysicalDeviceFeatures& PhysicalDevice::getFeatures() const
...@@ -795,4 +803,9 @@ const VkPhysicalDeviceMemoryProperties& PhysicalDevice::getMemoryProperties() co ...@@ -795,4 +803,9 @@ const VkPhysicalDeviceMemoryProperties& PhysicalDevice::getMemoryProperties() co
return properties; return properties;
} }
marl::Scheduler* PhysicalDevice::getScheduler() const
{
return scheduler.get();
}
} // namespace vk } // namespace vk
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "VkObject.hpp" #include "VkObject.hpp"
#include "VkFormat.h" #include "VkFormat.h"
#include "marl/scheduler.h"
#ifdef VK_USE_PLATFORM_ANDROID_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR
#include <vulkan/vk_android_native_buffer.h> #include <vulkan/vk_android_native_buffer.h>
#endif #endif
...@@ -70,9 +72,13 @@ public: ...@@ -70,9 +72,13 @@ public:
VkQueueFamilyProperties* pQueueFamilyProperties) const; VkQueueFamilyProperties* pQueueFamilyProperties) const;
const VkPhysicalDeviceMemoryProperties& getMemoryProperties() const; const VkPhysicalDeviceMemoryProperties& getMemoryProperties() const;
marl::Scheduler *getScheduler() const;
private: private:
const VkPhysicalDeviceLimits& getLimits() const; const VkPhysicalDeviceLimits& getLimits() const;
VkSampleCountFlags getSampleCounts() const; VkSampleCountFlags getSampleCounts() const;
std::unique_ptr<marl::Scheduler> scheduler;
}; };
using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>; using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
......
...@@ -68,9 +68,6 @@ ...@@ -68,9 +68,6 @@
#include "Reactor/Nucleus.hpp" #include "Reactor/Nucleus.hpp"
#include "marl/scheduler.h"
#include "marl/thread.h"
#include "System/CPUID.hpp" #include "System/CPUID.hpp"
#include <algorithm> #include <algorithm>
...@@ -120,17 +117,6 @@ void setCPUDefaults() ...@@ -120,17 +117,6 @@ void setCPUDefaults()
sw::CPUID::setEnableSSE(true); sw::CPUID::setEnableSSE(true);
} }
marl::Scheduler* getOrCreateScheduler()
{
static auto scheduler = std::unique_ptr<marl::Scheduler>(new marl::Scheduler());
scheduler->setThreadInitializer([] {
sw::CPUID::setFlushToZero(true);
sw::CPUID::setDenormalsAreZero(true);
});
scheduler->setWorkerThreadCount(std::min<size_t>(marl::Thread::numLogicalCPUs(), 16));
return scheduler.get();
}
// initializeLibrary() is called by vkCreateInstance() to perform one-off global // initializeLibrary() is called by vkCreateInstance() to perform one-off global
// initialization of the swiftshader driver. // initialization of the swiftshader driver.
void initializeLibrary() void initializeLibrary()
...@@ -602,7 +588,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -602,7 +588,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
(void)queueFamilyPropertyCount; // Silence unused variable warning (void)queueFamilyPropertyCount; // Silence unused variable warning
} }
auto scheduler = getOrCreateScheduler(); auto scheduler = vk::Cast(physicalDevice)->getScheduler();
return vk::DispatchableDevice::Create(pAllocator, pCreateInfo, pDevice, vk::Cast(physicalDevice), enabledFeatures, scheduler); return vk::DispatchableDevice::Create(pAllocator, pCreateInfo, pDevice, vk::Cast(physicalDevice), enabledFeatures, scheduler);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment