Skip to content

Commit

Permalink
- Add deadlock workaround for BB
Browse files Browse the repository at this point in the history
- Skip 5 shaders for BB
- Add Linux threads creation workaround
  • Loading branch information
NielsGx committed Sep 7, 2024
1 parent 749fe92 commit 7246ef2
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux-qt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Linux-Qt

on:
push:
branches: [ "main" ]
branches: [ "bb-deadlock-shaders-fixes" ]
pull_request:
branches: [ "main" ]
branches: [ "bb-deadlock-shaders-fixes" ]

env:
BUILD_TYPE: Release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-qt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Windows-Qt

on:
push:
branches: [ "main" ]
branches: [ "bb-deadlock-shaders-fixes" ]
pull_request:
branches: [ "main" ]
branches: [ "bb-deadlock-shaders-fixes" ]

env:
BUILD_TYPE: Release
Expand Down
28 changes: 26 additions & 2 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64_x64" ]
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"variables": [
{
"name": "ENABLE_QT_GUI",
"value": "True",
"type": "BOOL"
},
{
"name": "CMAKE_PREFIX_PATH",
"value": "C:/Qt/6.7.2/msvc2019_64",
"type": "PATH"
}
]
},
{
"name": "x64-Clang-Debug",
Expand All @@ -20,7 +32,19 @@
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64_x64" ]
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"variables": [
{
"name": "ENABLE_QT_GUI",
"value": "True",
"type": "BOOL"
},
{
"name": "CMAKE_PREFIX_PATH",
"value": "C:/Qt/6.7.2/msvc2019_64",
"type": "PATH"
}
]
},
{
"name": "x64-Clang-RelWithDebInfo",
Expand Down
21 changes: 16 additions & 5 deletions src/core/libraries/kernel/thread_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ void init_pthreads() {
}

void pthreadInitSelfMainThread() {
auto name = "Main_Thread";
auto* pthread_pool = g_pthread_cxt->GetPthreadPool();
g_pthread_self = pthread_pool->Create();
g_pthread_self = pthread_pool->Create(name);
scePthreadAttrInit(&g_pthread_self->attr);
g_pthread_self->pth = pthread_self();
g_pthread_self->name = "Main_Thread";
g_pthread_self->name = name;
}

int PS4_SYSV_ABI scePthreadAttrInit(ScePthreadAttr* attr) {
Expand Down Expand Up @@ -1013,7 +1014,7 @@ int PS4_SYSV_ABI scePthreadCreate(ScePthread* thread, const ScePthreadAttr* attr
attr = g_pthread_cxt->GetDefaultAttr();
}

*thread = pthread_pool->Create();
*thread = pthread_pool->Create(name);

if ((*thread)->attr != nullptr) {
scePthreadAttrDestroy(&(*thread)->attr);
Expand Down Expand Up @@ -1055,17 +1056,27 @@ int PS4_SYSV_ABI scePthreadCreate(ScePthread* thread, const ScePthreadAttr* attr
}
}

ScePthread PThreadPool::Create() {
ScePthread PThreadPool::Create(const char* name) {
std::scoped_lock lock{m_mutex};

for (auto* p : m_threads) {
if (p->is_free) {
if (p->is_free ||
(p->name == name && (p->name.starts_with("CSChr") || p->name.starts_with("CSCloth")))) {
p->is_free = false;
return p;
}
}

#ifdef _WIN64
auto* ret = new PthreadInternal{};
#else
// Linux specific hack
static u8* hint_address = reinterpret_cast<u8*>(0x7FFFFC000ULL);
auto* ret = reinterpret_cast<PthreadInternal*>(
mmap(hint_address, sizeof(PthreadInternal), PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0));
hint_address += Common::AlignUp(sizeof(PthreadInternal), 4_KB);
#endif
ret->is_free = false;
ret->is_detached = false;
ret->is_almost_done = false;
Expand Down
2 changes: 1 addition & 1 deletion src/core/libraries/kernel/thread_management.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct PthreadSemInternal {

class PThreadPool {
public:
ScePthread Create();
ScePthread Create(const char* name);

private:
std::vector<ScePthread> m_threads;
Expand Down
3 changes: 2 additions & 1 deletion src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ const ComputePipeline* PipelineCache::GetComputePipeline() {
}

bool ShouldSkipShader(u64 shader_hash, const char* shader_type) {
static constexpr std::array<u64, 0> skip_hashes = {};
static constexpr std::array<u64, 5> skip_hashes = {0xc0cbc309, 0x77d1c63, 0xff7a6d7c,
0xddfbac23, 0x896e7242};
if (std::ranges::contains(skip_hashes, shader_hash)) {
LOG_WARNING(Render_Vulkan, "Skipped {} shader hash {:#x}.", shader_type, shader_hash);
return true;
Expand Down

0 comments on commit 7246ef2

Please sign in to comment.