cfg: Handle additional case

This commit is contained in:
IndecisiveTurtle 2024-08-15 15:26:32 +03:00
parent ca674b4ea9
commit 1ca8a5c3c9
6 changed files with 28 additions and 15 deletions

View File

@ -1064,7 +1064,16 @@ ScePthread PThreadPool::Create() {
} }
} }
#ifdef _WIN64
auto* ret = new PthreadInternal{}; auto* ret = new PthreadInternal{};
#else
// TODO: 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_free = false;
ret->is_detached = false; ret->is_detached = false;
ret->is_almost_done = false; ret->is_almost_done = false;

View File

@ -10,6 +10,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <thread>
#include "common/assert.h" #include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
@ -59,6 +60,7 @@ int PS4_SYSV_ABI sce_net_in6addr_nodelocal_allnodes() {
} }
OrbisNetId PS4_SYSV_ABI sceNetAccept(OrbisNetId s, OrbisNetSockaddr* addr, u32* paddrlen) { OrbisNetId PS4_SYSV_ABI sceNetAccept(OrbisNetId s, OrbisNetSockaddr* addr, u32* paddrlen) {
std::this_thread::sleep_for(std::chrono::seconds(5));
LOG_ERROR(Lib_Net, "(STUBBED) called"); LOG_ERROR(Lib_Net, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
} }

View File

@ -103,7 +103,8 @@ void CFG::EmitDivergenceLabels() {
// Sometimes compiler might insert instructions between the SAVEEXEC and the branch. // Sometimes compiler might insert instructions between the SAVEEXEC and the branch.
// Those instructions need to be wrapped in the condition as well so allow branch // Those instructions need to be wrapped in the condition as well so allow branch
// as end scope instruction. // as end scope instruction.
inst.opcode == Opcode::S_CBRANCH_EXECZ; inst.opcode == Opcode::S_CBRANCH_EXECZ ||
inst.opcode == Opcode::S_ANDN2_B64;
}; };
// Since we will be adding new labels, avoid iterating those as well. // Since we will be adding new labels, avoid iterating those as well.
@ -120,23 +121,12 @@ void CFG::EmitDivergenceLabels() {
s32 curr_begin = -1; s32 curr_begin = -1;
for (size_t index = GetIndex(start); index < end_index; index++) { for (size_t index = GetIndex(start); index < end_index; index++) {
const auto& inst = inst_list[index]; const auto& inst = inst_list[index];
// Mark a potential start of an exec scope.
if (is_open_scope(inst)) {
curr_begin = index;
continue;
}
if (is_close_scope(inst) && curr_begin != -1) { if (is_close_scope(inst) && curr_begin != -1) {
// If there are no instructions inside scope don't do anything. // If there are no instructions inside scope don't do anything.
if (index - curr_begin == 1) { if (index - curr_begin == 1) {
curr_begin = -1; curr_begin = -1;
continue; continue;
} }
// Ensure the register holding EXEC is the same as the one saved.
const u32 backup_sreg = inst_list[curr_begin].dst[0].code;
const u32 restore_sreg = inst.src[0].code;
if (inst.opcode == Opcode::S_MOV_B64 && backup_sreg != restore_sreg) {
continue;
}
// Add a label to the instruction right after the open scope call. // Add a label to the instruction right after the open scope call.
// It is the start of a new basic block. // It is the start of a new basic block.
const auto& save_inst = inst_list[curr_begin]; const auto& save_inst = inst_list[curr_begin];
@ -144,13 +134,21 @@ void CFG::EmitDivergenceLabels() {
AddLabel(label); AddLabel(label);
// Add a label to the close scope instruction as well. // Add a label to the close scope instruction as well.
AddLabel(index_to_pc[index]); AddLabel(index_to_pc[index]);
// Reset scope begin.
curr_begin = -1; curr_begin = -1;
} }
// Mark a potential start of an exec scope.
if (is_open_scope(inst)) {
curr_begin = index;
}
} }
} }
// Sort labels to make sure block insertion is correct. // Sort labels to make sure block insertion is correct.
std::ranges::sort(labels); std::ranges::sort(labels);
for (const auto label : labels) {
LOG_INFO(Render_Vulkan, "Emitting label {:#x}", label);
}
} }
void CFG::EmitBlocks() { void CFG::EmitBlocks() {
@ -167,7 +165,7 @@ void CFG::EmitBlocks() {
const Label end = *next_it; const Label end = *next_it;
const size_t end_index = GetIndex(end) - 1; const size_t end_index = GetIndex(end) - 1;
const auto& end_inst = inst_list[end_index]; const auto& end_inst = inst_list[end_index];
LOG_INFO(Render_Vulkan, "Emitting block {:#x}-{:#x}", start, end);
// Insert block between the labels using the last instruction // Insert block between the labels using the last instruction
// as an indicator for branching type. // as an indicator for branching type.
Block* block = block_pool.Create(); Block* block = block_pool.Create();

View File

@ -180,6 +180,10 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
UNREACHABLE_MSG("Invalid PM4 type {}", type); UNREACHABLE_MSG("Invalid PM4 type {}", type);
} }
if (VAddr(dcb.data()) == 0x3c24df50) {
printf("bad\n");
}
const u32 count = header->type3.NumWords(); const u32 count = header->type3.NumWords();
const PM4ItOpcode opcode = header->type3.opcode; const PM4ItOpcode opcode = header->type3.opcode;
switch (opcode) { switch (opcode) {

View File

@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma clang optimize off
#include <algorithm> #include <algorithm>
#include "common/alignment.h" #include "common/alignment.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"

View File

@ -114,7 +114,7 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache,
} }
} }
const u32 size = vsharp.GetSize(); const u32 size = vsharp.GetSize();
if (buffer.is_written && compute_key != 0xe991ee280187cbc) { if (buffer.is_written && compute_key != 0xe991ee280187cbc && compute_key != 0xfefebf9f) {
texture_cache.InvalidateMemory(address, size, true); texture_cache.InvalidateMemory(address, size, true);
} }
const u32 alignment = const u32 alignment =