Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc crash fixes from mystery thread #17392

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ class VulkanRenderManager {
void Invalidate(InvalidationFlags flags);

void ResetStats();
void DrainCompileQueue();

private:
void EndCurRenderStep();

void ThreadFunc();
void CompileThreadFunc();
void DrainCompileQueue();

void Run(VKRRenderThreadTask &task);

Expand Down
5 changes: 3 additions & 2 deletions Core/MIPS/JitCommon/JitBlockCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static uint64_t HashJitBlock(const JitBlock &b) {
}

JitBlockCache::JitBlockCache(MIPSState *mipsState, CodeBlockCommon *codeBlock) :
codeBlock_(codeBlock), blocks_(nullptr), num_blocks_(0) {
codeBlock_(codeBlock) {
}

JitBlockCache::~JitBlockCache() {
Expand All @@ -90,7 +90,8 @@ bool JitBlock::ContainsAddress(u32 em_address) {
}

bool JitBlockCache::IsFull() const {
return num_blocks_ >= MAX_NUM_BLOCKS - 1;
// -10 to safely leave space for some proxy blocks, which we don't check before we allocate (not ideal, but should work).
return num_blocks_ >= MAX_NUM_BLOCKS - 10;
}

void JitBlockCache::Init() {
Expand Down
4 changes: 2 additions & 2 deletions Core/MIPS/JitCommon/JitBlockCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ class JitBlockCache : public JitBlockCacheDebugInterface {
MIPSOpcode GetEmuHackOpForBlock(int block_num) const;

CodeBlockCommon *codeBlock_;
JitBlock *blocks_;
JitBlock *blocks_ = nullptr;
std::unordered_multimap<u32, int> proxyBlockMap_;

int num_blocks_;
int num_blocks_ = 0;
std::unordered_multimap<u32, int> links_to_;
std::map<std::pair<u32,u32>, u32> block_map_; // (end_addr, start_addr) -> number

Expand Down
3 changes: 3 additions & 0 deletions GPU/Vulkan/GPU_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ void GPU_Vulkan::SaveCache(const Path &filename) {
}

GPU_Vulkan::~GPU_Vulkan() {
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
rm->DrainCompileQueue();

SaveCache(shaderCachePath_);
// Note: We save the cache in DeviceLost
DestroyDeviceObjects();
Expand Down