Skip to content

Commit

Permalink
Merge pull request #18707 from hrydgard/more-beta-fixes
Browse files Browse the repository at this point in the history
More beta fixes
  • Loading branch information
hrydgard committed Jan 16, 2024
2 parents 98c061f + 6066e74 commit 69a25ba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
18 changes: 13 additions & 5 deletions Common/GPU/Vulkan/VulkanRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,17 +511,25 @@ void VulkanRenderManager::CompileThreadFunc() {
}

void VulkanRenderManager::DrainAndBlockCompileQueue() {
std::unique_lock<std::mutex> lock(compileMutex_);
compileBlocked_ = true;
compileCond_.notify_all();
while (!compileQueue_.empty()) {
queueRunner_.WaitForCompileNotification();
while (true) {
bool anyInQueue = false;
{
std::unique_lock<std::mutex> lock(compileMutex_);
anyInQueue = !compileQueue_.empty();
}
if (anyInQueue) {
queueRunner_.WaitForCompileNotification();
} else {
break;
}
}
// At this point, no more tasks can be queued to the threadpool. So wait for them all to go away.
CreateMultiPipelinesTask::WaitForAll();
}

void VulkanRenderManager::ReleaseCompileQueue() {
std::unique_lock<std::mutex> lock(compileMutex_);
compileBlocked_ = false;
}

Expand Down Expand Up @@ -791,11 +799,11 @@ VKRGraphicsPipeline *VulkanRenderManager::CreateGraphicsPipeline(VKRGraphicsPipe
VKRRenderPassStoreAction::STORE, VKRRenderPassStoreAction::DONT_CARE, VKRRenderPassStoreAction::DONT_CARE,
};
VKRRenderPass *compatibleRenderPass = queueRunner_.GetRenderPass(key);
std::lock_guard<std::mutex> lock(compileMutex_);
if (compileBlocked_) {
delete pipeline;
return nullptr;
}
std::lock_guard<std::mutex> lock(compileMutex_);
bool needsCompile = false;
for (size_t i = 0; i < (size_t)RenderPassType::TYPE_COUNT; i++) {
if (!(variantBitmask & (1 << i)))
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class VulkanRenderManager {
std::condition_variable compileCond_;
std::mutex compileMutex_;
std::vector<CompileQueueEntry> compileQueue_;
bool compileBlocked_ = false;
std::atomic<bool> compileBlocked_{};

// Thread for measuring presentation delay.
std::thread presentWaitThread_;
Expand Down
28 changes: 13 additions & 15 deletions Core/CoreTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,22 +536,20 @@ void RemoveAllEvents(int event_type)
RemoveEvent(event_type);
}

//This raise only the events required while the fifo is processing data
void ProcessFifoWaitEvents()
{
while (first)
{
if (first->time <= (s64)GetTicks())
{
// LOG(CPU, "[Scheduler] %s (%lld, %lld) ",
// first->name ? first->name : "?", (u64)GetTicks(), (u64)first->time);
Event* evt = first;
void ProcessEvents() {
while (first) {
if (first->time <= (s64)GetTicks()) {
// INFO_LOG(CPU, "%s (%lld, %lld) ", first->name ? first->name : "?", (u64)GetTicks(), (u64)first->time);
Event *evt = first;
first = first->next;
event_types[evt->type].callback(evt->userdata, (int)(GetTicks() - evt->time));
if (evt->type >= 0 && evt->type < event_types.size()) {
event_types[evt->type].callback(evt->userdata, (int)(GetTicks() - evt->time));
} else {
_dbg_assert_msg_(false, "Bad event type %d", evt->type);
}
FreeEvent(evt);
}
else
{
} else {
// Caught up to the current time.
break;
}
}
Expand Down Expand Up @@ -604,7 +602,7 @@ void Advance() {

if (hasTsEvents.load(std::memory_order_acquire))
MoveEvents();
ProcessFifoWaitEvents();
ProcessEvents();

if (!first) {
// This should never happen in PPSSPP.
Expand Down
2 changes: 2 additions & 0 deletions Core/MIPS/JitCommon/JitBlockCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ static void ExpandRange(std::pair<u32, u32> &range, u32 newStart, u32 newEnd) {

void JitBlockCache::FinalizeBlock(int block_num, bool block_link) {
JitBlock &b = blocks_[block_num];
_dbg_assert_(b.blockNum == block_num);

_assert_msg_(Memory::IsValidAddress(b.originalAddress), "FinalizeBlock: Bad originalAddress %08x in block %d (b.num: %d) proxy: %s sz: %d", b.originalAddress, block_num, b.blockNum, b.proxyFor ? "y" : "n", b.codeSize);

b.originalFirstOpcode = Memory::Read_Opcode_JIT(b.originalAddress);
Expand Down

0 comments on commit 69a25ba

Please sign in to comment.