Skip to content

Commit

Permalink
Temporarily turn off Vulkan threading on AMD, see issue #10097.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Nov 16, 2017
1 parent 23b795e commit 766ddf9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion GPU/Vulkan/DrawEngineVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ VkDescriptorSet DrawEngineVulkan::GetOrCreateDescriptorSet(VkImageView imageView
descAlloc.descriptorSetCount = 1;
VkResult result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, &desc);
// Even in release mode, this is bad.
_assert_msg_(G3D, result == VK_SUCCESS, "Ran out of descriptors in pool. sz=%d", (int)frame->descSets.size());
_assert_msg_(G3D, result == VK_SUCCESS, "Ran out of descriptor space in pool. sz=%d", (int)frame->descSets.size());

// We just don't write to the slots we don't care about.
// We need 8 now that we support secondary texture bindings.
Expand Down
24 changes: 13 additions & 11 deletions ext/native/thin3d/VulkanRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#define VLOG(...)
#endif

// This works great. Not much reason to disable so let's not even bother with an option.
const bool useThread = true;

#ifndef UINT64_MAX
#define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
#endif
Expand Down Expand Up @@ -127,6 +124,11 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan
}

queueRunner_.CreateDeviceObjects();

// Temporary AMD hack for issue #10097
if (vulkan_->GetPhysicalDeviceProperties().vendorID == VULKAN_VENDOR_AMD) {
useThread_ = false;
}
}

void VulkanRenderManager::CreateBackbuffers() {
Expand Down Expand Up @@ -188,7 +190,7 @@ void VulkanRenderManager::CreateBackbuffers() {
}

// Start the thread.
if (useThread && HasBackbuffers()) {
if (useThread_ && HasBackbuffers()) {
run_ = true;
// Won't necessarily be 0.
threadInitFrame_ = vulkan_->GetCurFrame();
Expand All @@ -198,7 +200,7 @@ void VulkanRenderManager::CreateBackbuffers() {
}

void VulkanRenderManager::StopThread() {
if (useThread && run_) {
if (useThread_ && run_) {
run_ = false;
// Stop the thread.
for (int i = 0; i < vulkan_->GetInflightFrames(); i++) {
Expand Down Expand Up @@ -337,7 +339,7 @@ void VulkanRenderManager::BeginFrame() {
FrameData &frameData = frameData_[curFrame];

// Make sure the very last command buffer from the frame before the previous has been fully executed.
if (useThread) {
if (useThread_) {
std::unique_lock<std::mutex> lock(frameData.push_mutex);
while (!frameData.readyForFence) {
VLOG("PUSH: Waiting for frame[%d].readyForFence = 1", curFrame);
Expand Down Expand Up @@ -693,7 +695,7 @@ void VulkanRenderManager::Finish() {
curRenderStep_ = nullptr;
int curFrame = vulkan_->GetCurFrame();
FrameData &frameData = frameData_[curFrame];
if (!useThread) {
if (!useThread_) {
frameData.steps = std::move(steps_);
frameData.type = VKRRunType::END;
Run(curFrame);
Expand Down Expand Up @@ -800,7 +802,7 @@ void VulkanRenderManager::Submit(int frame, bool triggerFence) {
}

// When !triggerFence, we notify after syncing with Vulkan.
if (useThread && triggerFence) {
if (useThread_ && triggerFence) {
VLOG("PULL: Frame %d.readyForFence = true", frame);
std::unique_lock<std::mutex> lock(frameData.push_mutex);
frameData.readyForFence = true;
Expand Down Expand Up @@ -880,7 +882,7 @@ void VulkanRenderManager::EndSyncFrame(int frame) {
VkResult res = vkBeginCommandBuffer(frameData.mainCmd, &begin);
assert(res == VK_SUCCESS);

if (useThread) {
if (useThread_) {
std::unique_lock<std::mutex> lock(frameData.push_mutex);
frameData.readyForFence = true;
frameData.push_condVar.notify_all();
Expand All @@ -891,7 +893,7 @@ void VulkanRenderManager::FlushSync() {
// TODO: Reset curRenderStep_?
int curFrame = vulkan_->GetCurFrame();
FrameData &frameData = frameData_[curFrame];
if (!useThread) {
if (!useThread_) {
frameData.steps = std::move(steps_);
frameData.type = VKRRunType::SYNC;
Run(curFrame);
Expand All @@ -905,7 +907,7 @@ void VulkanRenderManager::FlushSync() {
frameData.pull_condVar.notify_all();
}

if (useThread) {
if (useThread_) {
std::unique_lock<std::mutex> lock(frameData.push_mutex);
// Wait for the flush to be hit, since we're syncing.
while (!frameData.readyForFence) {
Expand Down
3 changes: 3 additions & 0 deletions ext/native/thin3d/VulkanRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,7 @@ class VulkanRenderManager {
VkImageView view = VK_NULL_HANDLE;
};
DepthBufferInfo depth_;

// This works great - except see issue #10097. WTF?
bool useThread_ = true;
};

0 comments on commit 766ddf9

Please sign in to comment.