Various fixes and utilties.
This commit is contained in:
parent
98e7e2727b
commit
727ffaa122
|
@ -9,12 +9,14 @@
|
|||
|
||||
#include "poly/logging.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/main.h"
|
||||
#include "poly/math.h"
|
||||
#include "poly/threading.h"
|
||||
|
||||
DEFINE_bool(fast_stdout, false,
|
||||
"Don't lock around stdout/stderr. May introduce weirdness.");
|
||||
|
@ -42,14 +44,18 @@ void format_log_line(char* buffer, size_t buffer_count, const char* file_path,
|
|||
}
|
||||
|
||||
// Format string - add a trailing newline if required.
|
||||
const char* outfmt = "%c> %s:%d: ";
|
||||
const char* outfmt = "%c> %.2X %s:%d: ";
|
||||
buffer_ptr = buffer + snprintf(buffer, buffer_count - 1, outfmt, level_char,
|
||||
poly::threading::current_thread_id(),
|
||||
filename, line_number);
|
||||
} else {
|
||||
buffer_ptr = buffer;
|
||||
*(buffer_ptr++) = level_char;
|
||||
*(buffer_ptr++) = '>';
|
||||
*(buffer_ptr++) = ' ';
|
||||
buffer_ptr +=
|
||||
sprintf(buffer_ptr, "%.4X", poly::threading::current_thread_id());
|
||||
*(buffer_ptr++) = ' ';
|
||||
}
|
||||
|
||||
// Scribble args into the print buffer.
|
||||
|
|
|
@ -65,7 +65,10 @@ X64Emitter::X64Emitter(X64Backend* backend, XbyakAllocator* allocator)
|
|||
backend_(backend),
|
||||
code_cache_(backend->code_cache()),
|
||||
allocator_(allocator),
|
||||
current_instr_(0) {}
|
||||
current_instr_(0),
|
||||
source_map_count_(0),
|
||||
stack_size_(0),
|
||||
trace_flags_(0) {}
|
||||
|
||||
X64Emitter::~X64Emitter() {}
|
||||
|
||||
|
|
|
@ -235,6 +235,11 @@ void GL4GraphicsSystem::PlayTrace(const uint8_t* trace_data, size_t trace_size,
|
|||
});
|
||||
}
|
||||
|
||||
void GL4GraphicsSystem::ClearCaches() {
|
||||
command_processor_->CallInThread(
|
||||
[&]() { command_processor_->texture_cache()->Clear(); });
|
||||
}
|
||||
|
||||
void GL4GraphicsSystem::MarkVblank() {
|
||||
static bool thread_name_set = false;
|
||||
if (!thread_name_set) {
|
||||
|
|
|
@ -46,6 +46,7 @@ class GL4GraphicsSystem : public GraphicsSystem {
|
|||
void EndTracing() override;
|
||||
void PlayTrace(const uint8_t* trace_data, size_t trace_size,
|
||||
TracePlaybackMode playback_mode) override;
|
||||
void ClearCaches() override;
|
||||
|
||||
private:
|
||||
void MarkVblank();
|
||||
|
|
|
@ -52,6 +52,7 @@ class GraphicsSystem {
|
|||
};
|
||||
virtual void PlayTrace(const uint8_t* trace_data, size_t trace_size,
|
||||
TracePlaybackMode playback_mode) {}
|
||||
virtual void ClearCaches() {}
|
||||
|
||||
protected:
|
||||
GraphicsSystem();
|
||||
|
|
|
@ -2211,10 +2211,14 @@ int trace_viewer_main(std::vector<std::wstring>& args) {
|
|||
}
|
||||
|
||||
auto control = window->child(0);
|
||||
control->on_key_char.AddListener([](poly::ui::KeyEvent& e) {
|
||||
control->on_key_char.AddListener([graphics_system](poly::ui::KeyEvent& e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
if (e.key_code() > 0 && e.key_code() < 0x10000) {
|
||||
io.AddInputCharacter(e.key_code());
|
||||
if (e.key_code() == 0x74 /* VK_F5 */) {
|
||||
graphics_system->ClearCaches();
|
||||
} else {
|
||||
io.AddInputCharacter(e.key_code());
|
||||
}
|
||||
}
|
||||
e.set_handled(true);
|
||||
});
|
||||
|
|
|
@ -257,6 +257,8 @@ inline float GpuSwap(float value, Endian endianness) {
|
|||
|
||||
inline uint32_t GpuToCpu(uint32_t p) { return p; }
|
||||
|
||||
inline uint32_t CpuToGpu(uint32_t p) { return p & 0x1FFFFFFF; }
|
||||
|
||||
// XE_GPU_REG_SQ_PROGRAM_CNTL
|
||||
typedef union {
|
||||
XEPACKEDSTRUCTANONYMOUS({
|
||||
|
|
|
@ -333,6 +333,15 @@ X_STATUS XThread::PlatformExit(int exit_code) {
|
|||
#endif // WIN32
|
||||
|
||||
void XThread::Execute() {
|
||||
XELOGKERNEL("XThread::Execute thid %d (handle=%.8X, '%s', native=%.8X)",
|
||||
thread_id_, handle(), name_.c_str(),
|
||||
poly::threading::current_thread_id());
|
||||
|
||||
// All threads get a mandatory sleep. This is to deal with some buggy
|
||||
// games that are assuming the 360 is so slow to create threads that they
|
||||
// have time to initialize shared structures AFTER CreateThread (RR).
|
||||
poly::threading::Sleep(std::chrono::milliseconds::duration(100));
|
||||
|
||||
// If a XapiThreadStartup value is present, we use that as a trampoline.
|
||||
// Otherwise, we are a raw thread.
|
||||
if (creation_params_.xapi_thread_startup) {
|
||||
|
|
|
@ -94,6 +94,8 @@ SHIM_CALL NtAllocateVirtualMemory_shim(PPCContext* ppc_state,
|
|||
return;
|
||||
}
|
||||
|
||||
XELOGD("NtAllocateVirtualMemory = %.8X", addr);
|
||||
|
||||
// Stash back.
|
||||
// Maybe set X_STATUS_ALREADY_COMMITTED if MEM_COMMIT?
|
||||
SHIM_SET_MEM_32(base_addr_ptr, addr);
|
||||
|
@ -249,6 +251,7 @@ SHIM_CALL MmAllocatePhysicalMemoryEx_shim(PPCContext* ppc_state,
|
|||
SHIM_SET_RETURN_32(0);
|
||||
return;
|
||||
}
|
||||
XELOGD("MmAllocatePhysicalMemoryEx = %.8X", base_address);
|
||||
|
||||
// Move the address into the right range.
|
||||
// if (protect_bits & X_MEM_LARGE_PAGES) {
|
||||
|
@ -260,7 +263,7 @@ SHIM_CALL MmAllocatePhysicalMemoryEx_shim(PPCContext* ppc_state,
|
|||
//}
|
||||
base_address += 0xA0000000;
|
||||
|
||||
SHIM_SET_RETURN_32(base_address);
|
||||
SHIM_SET_RETURN_64(base_address);
|
||||
}
|
||||
|
||||
SHIM_CALL MmFreePhysicalMemory_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
|
@ -381,7 +384,7 @@ SHIM_CALL MmGetPhysicalAddress_shim(PPCContext* ppc_state, KernelState* state) {
|
|||
base_address |= 0xE0000000;
|
||||
}*/
|
||||
|
||||
SHIM_SET_RETURN_32(base_address);
|
||||
SHIM_SET_RETURN_64(base_address);
|
||||
}
|
||||
|
||||
SHIM_CALL MmMapIoSpace_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
|
@ -399,7 +402,7 @@ SHIM_CALL MmMapIoSpace_shim(PPCContext* ppc_state, KernelState* state) {
|
|||
assert_true(size == 0x40);
|
||||
assert_true(flags == 0x404);
|
||||
|
||||
SHIM_SET_RETURN_32(src_address);
|
||||
SHIM_SET_RETURN_64(src_address);
|
||||
}
|
||||
|
||||
SHIM_CALL ExAllocatePoolTypeWithTag_shim(PPCContext* ppc_state,
|
||||
|
@ -420,7 +423,7 @@ SHIM_CALL ExAllocatePoolTypeWithTag_shim(PPCContext* ppc_state,
|
|||
|
||||
uint32_t addr = state->memory()->SystemHeapAlloc(adjusted_size, alignment);
|
||||
|
||||
SHIM_SET_RETURN_32(addr);
|
||||
SHIM_SET_RETURN_64(addr);
|
||||
}
|
||||
|
||||
SHIM_CALL ExFreePool_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
|
|
|
@ -565,7 +565,7 @@ spin:
|
|||
// All out of spin waits, create a full waiter.
|
||||
// TODO(benvanik): contention - do a real wait!
|
||||
// XELOGE("RtlEnterCriticalSection tried to really lock!");
|
||||
spin_wait_remaining = 1; // HACK: spin forever
|
||||
spin_wait_remaining = 0; // HACK: spin forever
|
||||
Sleep(1);
|
||||
goto spin;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ SHIM_CALL ExCreateThread_shim(PPCContext* ppc_state, KernelState* state) {
|
|||
stack_size, thread_id_ptr, xapi_thread_startup, start_address,
|
||||
start_context, creation_flags);
|
||||
|
||||
// http://jafile.com/uploads/scoop/main.cpp.txt
|
||||
// DWORD
|
||||
// LPHANDLE Handle,
|
||||
// DWORD StackSize,
|
||||
|
|
|
@ -356,7 +356,20 @@ SHIM_CALL VdIsHSIOTrainingSucceeded_shim(PPCContext* ppc_state,
|
|||
}
|
||||
|
||||
SHIM_CALL VdPersistDisplay_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD("VdPersistDisplay(?)");
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk3 = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk4 = SHIM_GET_ARG_32(4);
|
||||
uint32_t unk5 = SHIM_GET_ARG_32(5);
|
||||
uint32_t unk6 = SHIM_GET_ARG_32(6);
|
||||
uint32_t unk7 = SHIM_GET_ARG_32(7);
|
||||
|
||||
XELOGD("VdPersistDisplay(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0, unk1_ptr, unk2, unk3, unk4, unk5, unk6, unk7);
|
||||
|
||||
// unk1_ptr needs to be populated with a pointer passed to
|
||||
// MmFreePhysicalMemory(1, *unk1_ptr).
|
||||
|
||||
// ?
|
||||
SHIM_SET_RETURN_64(1);
|
||||
|
|
|
@ -46,11 +46,22 @@ bool MainWindow::Initialize() {
|
|||
}
|
||||
Resize(1280, 720);
|
||||
on_key_down.AddListener([this](poly::ui::KeyEvent& e) {
|
||||
if (e.key_code() == 115) {
|
||||
emulator()->graphics_system()->RequestFrameTrace();
|
||||
e.set_handled(true);
|
||||
return;
|
||||
bool handled = true;
|
||||
switch (e.key_code()) {
|
||||
case 0x73: { // VK_F4
|
||||
emulator()->graphics_system()->RequestFrameTrace();
|
||||
break;
|
||||
}
|
||||
case 0x74: { // VK_F5
|
||||
emulator()->graphics_system()->ClearCaches();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
e.set_handled(handled);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue