From 38bd40891d961eab09672cd14f7c621819c0e3ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Mon, 12 May 2014 21:31:01 +0200 Subject: [PATCH] Fixed issue with RSX Reports Reports consist of 16 bytes (64-bit timestamp, 32-bit value and 32-bit zero padding). This was found by @nohbdy some time ago. --- rpcs3/Emu/GS/GCM.h | 10 ++++++++++ rpcs3/Emu/GS/RSXThread.cpp | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/GS/GCM.h b/rpcs3/Emu/GS/GCM.h index e556eadc56..9a42af58d1 100644 --- a/rpcs3/Emu/GS/GCM.h +++ b/rpcs3/Emu/GS/GCM.h @@ -73,6 +73,16 @@ enum CELL_GCM_SURFACE_TARGET_MRT3 = 0x1f, }; +// GCM Reports +enum +{ + CELL_GCM_ZPASS_PIXEL_CNT = 1, + CELL_GCM_ZCULL_STATS = 2, + CELL_GCM_ZCULL_STATS1 = 3, + CELL_GCM_ZCULL_STATS2 = 4, + CELL_GCM_ZCULL_STATS3 = 5, +}; + struct CellGcmControl { be_t put; diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 98f7ffe0ab..c5a9233279 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -1194,21 +1194,31 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 u8 type = a0 >> 24; u32 offset = a0 & 0xffffff; - u64 data; + u32 value; switch(type) { - case 1: - data = get_system_time(); - data *= 1000; // Microseconds to nanoseconds + case CELL_GCM_ZPASS_PIXEL_CNT: + case CELL_GCM_ZCULL_STATS: + case CELL_GCM_ZCULL_STATS1: + case CELL_GCM_ZCULL_STATS2: + case CELL_GCM_ZCULL_STATS3: + value = 0; + ConLog.Warning("NV4097_GET_REPORT: Unimplemented type %d", type); break; default: - data = 0; - ConLog.Error("NV4097_GET_REPORT: bad type %d", type); + value = 0; + ConLog.Error("NV4097_GET_REPORT: Bad type %d", type); break; } - Memory.Write64(m_local_mem_addr + offset, data); + // Get timestamp, and convert it from microseconds to nanoseconds + u64 timestamp = get_system_time() * 1000; + + // TODO: Reports can be written to the main memory or the local memory (controlled by NV4097_SET_CONTEXT_DMA_REPORT) + Memory.Write64(m_local_mem_addr + offset + 0x0, timestamp); + Memory.Write32(m_local_mem_addr + offset + 0x8, value); + Memory.Write32(m_local_mem_addr + offset + 0xc, 0); } break;