Commit 50038d6d by Alexis Hétu

Revert "Do not call Scheduler destructor in libVulkan."

This reverts commit 1f89f58f. Original cl: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36548 Reason for revert: Causes timeout flakes on Regres Bug: b/141380274 Change-Id: I184e96c586e449b7dcd5b445078064cbafb7df72 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36592Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent e3a59837
......@@ -16,9 +16,6 @@
#include "VkConfig.h"
#include "Pipeline/SpirvShader.hpp" // sw::SIMD::Width
#include "System/CPUID.hpp"
#include "marl/thread.h"
#include <limits>
#include <cstring>
......@@ -26,13 +23,8 @@
namespace vk
{
PhysicalDevice::PhysicalDevice(const void*, void* mem) : scheduler(new marl::Scheduler())
PhysicalDevice::PhysicalDevice(const void*, void* mem)
{
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
......@@ -803,9 +795,4 @@ const VkPhysicalDeviceMemoryProperties& PhysicalDevice::getMemoryProperties() co
return properties;
}
marl::Scheduler* PhysicalDevice::getScheduler() const
{
return scheduler.get();
}
} // namespace vk
......@@ -18,8 +18,6 @@
#include "VkObject.hpp"
#include "VkFormat.h"
#include "marl/scheduler.h"
#ifdef VK_USE_PLATFORM_ANDROID_KHR
#include <vulkan/vk_android_native_buffer.h>
#endif
......@@ -72,13 +70,9 @@ public:
VkQueueFamilyProperties* pQueueFamilyProperties) const;
const VkPhysicalDeviceMemoryProperties& getMemoryProperties() const;
marl::Scheduler *getScheduler() const;
private:
const VkPhysicalDeviceLimits& getLimits() const;
VkSampleCountFlags getSampleCounts() const;
std::unique_ptr<marl::Scheduler> scheduler;
};
using DispatchablePhysicalDevice = DispatchableObject<PhysicalDevice, VkPhysicalDevice>;
......
......@@ -68,6 +68,9 @@
#include "Reactor/Nucleus.hpp"
#include "marl/scheduler.h"
#include "marl/thread.h"
#include "System/CPUID.hpp"
#include <algorithm>
......@@ -117,6 +120,17 @@ void setCPUDefaults()
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
// initialization of the swiftshader driver.
void initializeLibrary()
......@@ -588,7 +602,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
(void)queueFamilyPropertyCount; // Silence unused variable warning
}
auto scheduler = vk::Cast(physicalDevice)->getScheduler();
auto scheduler = getOrCreateScheduler();
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