From 12f217aba997dab447c0247b1716d3197ee0eb41 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 21 Jun 2014 06:57:23 +0800 Subject: [PATCH 1/3] RSX: matrix offset fix and use original buffer width for writing color/depth --- rpcs3/Emu/GS/GL/GLGSRender.cpp | 16 ++++++++-------- rpcs3/Emu/GS/RSXThread.cpp | 8 ++------ rpcs3/Emu/GS/RSXThread.h | 2 ++ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index a19194566d..8ef82ae519 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -289,12 +289,12 @@ void GLGSRender::InitVertexData() // Scale scaleOffsetMat[0] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 0)] / (RSXThread::m_width / RSXThread::m_width_scale); scaleOffsetMat[5] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 1)] / (RSXThread::m_height / RSXThread::m_height_scale); - scaleOffsetMat[10] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4*2)]; + scaleOffsetMat[10] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 2)]; // Offset scaleOffsetMat[3] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 0)] - (RSXThread::m_width / RSXThread::m_width_scale); scaleOffsetMat[7] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 1)] - (RSXThread::m_height / RSXThread::m_height_scale); - scaleOffsetMat[11] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 2)]; + scaleOffsetMat[11] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 2)] - 1 / 2.0f; scaleOffsetMat[3] /= RSXThread::m_width / RSXThread::m_width_scale; scaleOffsetMat[7] /= RSXThread::m_height / RSXThread::m_height_scale; @@ -452,11 +452,11 @@ void GLGSRender::WriteDepthBuffer() return; } - glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, &Memory[address]); + glReadPixels(0, 0, RSXThread::m_buffer_width, RSXThread::m_buffer_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, &Memory[address]); checkForGlError("glReadPixels"); glBindTexture(GL_TEXTURE_2D, g_depth_tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RSXThread::m_width, RSXThread::m_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &Memory[address]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RSXThread::m_buffer_width, RSXThread::m_buffer_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &Memory[address]); checkForGlError("glTexImage2D"); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); checkForGlError("glGetTexImage"); @@ -481,7 +481,7 @@ void GLGSRender::WriteColourBufferA() glReadBuffer(GL_COLOR_ATTACHMENT0); checkForGlError("glReadBuffer(GL_COLOR_ATTACHMENT0)"); - glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); + glReadPixels(0, 0, RSXThread::m_buffer_width, RSXThread::m_buffer_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); checkForGlError("glReadPixels(GL_RGBA, GL_UNSIGNED_INT_8_8_8_8)"); } @@ -504,7 +504,7 @@ void GLGSRender::WriteColourBufferB() glReadBuffer(GL_COLOR_ATTACHMENT1); checkForGlError("glReadBuffer(GL_COLOR_ATTACHMENT1)"); - glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); + glReadPixels(0, 0, RSXThread::m_buffer_width, RSXThread::m_buffer_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); checkForGlError("glReadPixels(GL_RGBA, GL_UNSIGNED_INT_8_8_8_8)"); } @@ -527,7 +527,7 @@ void GLGSRender::WriteColourBufferC() glReadBuffer(GL_COLOR_ATTACHMENT2); checkForGlError("glReadBuffer(GL_COLOR_ATTACHMENT2)"); - glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); + glReadPixels(0, 0, RSXThread::m_buffer_width, RSXThread::m_buffer_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); checkForGlError("glReadPixels(GL_RGBA, GL_UNSIGNED_INT_8_8_8_8)"); } @@ -550,7 +550,7 @@ void GLGSRender::WriteColourBufferD() glReadBuffer(GL_COLOR_ATTACHMENT3); checkForGlError("glReadBuffer(GL_COLOR_ATTACHMENT3)"); - glReadPixels(0, 0, RSXThread::m_width, RSXThread::m_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); + glReadPixels(0, 0, RSXThread::m_buffer_width, RSXThread::m_buffer_height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, &Memory[address]); checkForGlError("glReadPixels(GL_RGBA, GL_UNSIGNED_INT_8_8_8_8)"); } diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 8f5b9f2d1a..4bd4330d7b 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -1267,10 +1267,6 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 if (Ini.GSDownscale.GetValue() && Ini.GSResolution.GetValue() == 4) { - // Disable write color/depth buffer during downscaling as it is not yet scaled propertly - Ini.GSDumpColorBuffers.SetValue(false); - Ini.GSDumpDepthBuffer.SetValue(false); - if (m_width == 1280 && m_height == 720) { // Set scale ratio for 720p @@ -1867,7 +1863,7 @@ void RSXThread::End() void RSXThread::Task() { u8 inc; - ConLog.Write("RSX thread entry"); + ConLog.Write("RSX thread enter"); OnInitThread(); @@ -1957,7 +1953,7 @@ void RSXThread::Task() //memset(Memory.GetMemFromAddr(p.m_ioAddress + get), 0, (count + 1) * 4); } - ConLog.Write("RSX thread exit..."); + ConLog.Write("RSX thread exit"); OnExitThread(); } diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index 96166d4c0f..310011e044 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -140,6 +140,8 @@ public: u32 m_width; u32 m_height; + u32 m_buffer_width; + u32 m_buffer_height; float m_width_scale; float m_height_scale; u32 m_draw_array_count; From c3960b7f4392dc785c7ec8641b83cfa956f2fd80 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 21 Jun 2014 12:29:17 +0800 Subject: [PATCH 2/3] Misc thread started/ended/aborted aligment --- rpcs3/Emu/GS/RSXThread.cpp | 4 ++-- rpcs3/Emu/SysCalls/Modules/cellAdec.cpp | 22 +++++++++++----------- rpcs3/Emu/SysCalls/Modules/cellAudio.cpp | 16 ++++++++-------- rpcs3/Emu/SysCalls/Modules/cellDmux.cpp | 8 ++++---- rpcs3/Emu/SysCalls/Modules/cellVdec.cpp | 16 ++++++++-------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 4bd4330d7b..a3768f4c2d 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -1863,7 +1863,7 @@ void RSXThread::End() void RSXThread::Task() { u8 inc; - ConLog.Write("RSX thread enter"); + ConLog.Write("RSX thread started"); OnInitThread(); @@ -1953,7 +1953,7 @@ void RSXThread::Task() //memset(Memory.GetMemFromAddr(p.m_ioAddress + get), 0, (count + 1) * 4); } - ConLog.Write("RSX thread exit"); + ConLog.Write("RSX thread ended"); OnExitThread(); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index d4ef62518b..f15d9e1792 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -36,7 +36,7 @@ next: { if (Emu.IsStopped()) { - ConLog.Warning("adecRawRead() aborted"); + ConLog.Warning("adecRawRead(): aborted"); return 0; } Sleep(1); @@ -53,7 +53,7 @@ next: { if (!Memory.CopyToReal(buf, adec.reader.addr, adec.reader.size)) { - ConLog.Error("adecRawRead: data reading failed (reader.size=0x%x)", adec.reader.size); + ConLog.Error("adecRawRead(): data reading failed (reader.size=0x%x)", adec.reader.size); Emu.Pause(); return 0; } @@ -89,7 +89,7 @@ next: } else if (!Memory.CopyToReal(buf, adec.reader.addr, buf_size)) { - ConLog.Error("adecRawRead: data reading failed (buf_size=0x%x)", buf_size); + ConLog.Error("adecRawRead(): data reading failed (buf_size=0x%x)", buf_size); Emu.Pause(); return 0; } @@ -111,7 +111,7 @@ int adecRead(void* opaque, u8* buf, int buf_size) { if (buf_size < (int)adec.reader.rem_size) { - ConLog.Error("adecRead: too small buf_size (rem_size = %d, buf_size = %d)", adec.reader.rem_size, buf_size); + ConLog.Error("adecRead(): too small buf_size (rem_size = %d, buf_size = %d)", adec.reader.rem_size, buf_size); Emu.Pause(); return 0; } @@ -131,7 +131,7 @@ int adecRead(void* opaque, u8* buf, int buf_size) if (adecRawRead(opaque, header, 8) < 8) break; if (header[0] != 0x0f || header[1] != 0xd0) { - ConLog.Error("adecRead: 0x0FD0 header not found"); + ConLog.Error("adecRead(): 0x0FD0 header not found"); Emu.Pause(); return -1; } @@ -141,7 +141,7 @@ int adecRead(void* opaque, u8* buf, int buf_size) OMAHeader oma(1 /* atrac3p id */, header[2], header[3]); if (buf_size < sizeof(oma) + 8) { - ConLog.Error("adecRead: OMAHeader writing failed"); + ConLog.Error("adecRead(): OMAHeader writing failed"); Emu.Pause(); return 0; } @@ -198,7 +198,7 @@ u32 adecOpen(AudioDecoder* data) thread t("Audio Decoder[" + std::to_string(adec_id) + "] Thread", [&]() { - ConLog.Write("Audio Decoder enter()"); + ConLog.Write("Audio Decoder thread started"); AdecTask& task = adec.task; @@ -371,7 +371,7 @@ u32 adecOpen(AudioDecoder* data) { if (Emu.IsStopped()) { - ConLog.Warning("adecDecodeAu aborted"); + ConLog.Warning("adecDecodeAu: aborted"); return; } @@ -497,16 +497,16 @@ u32 adecOpen(AudioDecoder* data) case adecClose: { adec.is_finished = true; - ConLog.Write("Audio Decoder exit"); + ConLog.Write("Audio Decoder thread ended"); return; } default: - ConLog.Error("Audio Decoder error: unknown task(%d)", task.type); + ConLog.Error("Audio Decoder thread error: unknown task(%d)", task.type); } } adec.is_finished = true; - ConLog.Warning("Audio Decoder aborted"); + ConLog.Warning("Audio Decoder thread aborted"); }); t.detach(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index ca4d8072f0..4538f042a0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -50,11 +50,11 @@ int cellAudioInit() if (do_dump && !m_dump.Init()) { - ConLog.Error("Audio aborted: AudioDumper::Init() failed"); + ConLog.Error("cellAudioInit(): AudioDumper::Init() failed"); return; } - ConLog.Write("Audio started"); + ConLog.Write("Audio thread started"); if (Ini.AudioDumpToFile.GetValue()) m_dump.WriteHeader(); @@ -146,7 +146,7 @@ int cellAudioInit() { if (Emu.IsStopped()) { - ConLog.Warning("Audio aborted"); + ConLog.Warning("Audio thread aborted"); goto abort; } @@ -426,7 +426,7 @@ int cellAudioInit() { if (m_dump.WriteData(&buf8ch, sizeof(buf8ch)) != sizeof(buf8ch)) // write file data { - ConLog.Error("Audio aborted: AudioDumper::WriteData() failed"); + ConLog.Error("cellAudioInit(): AudioDumper::WriteData() failed"); goto abort; } } @@ -434,13 +434,13 @@ int cellAudioInit() { if (m_dump.WriteData(&buf2ch, sizeof(buf2ch)) != sizeof(buf2ch)) // write file data { - ConLog.Error("Audio aborted: AudioDumper::WriteData() failed"); + ConLog.Error("cellAudioInit(): AudioDumper::WriteData() failed"); goto abort; } } else { - ConLog.Error("Audio aborted: unknown AudioDumper::GetCh() value (%d)", m_dump.GetCh()); + ConLog.Error("cellAudioInit(): unknown AudioDumper::GetCh() value (%d)", m_dump.GetCh()); goto abort; } } @@ -448,7 +448,7 @@ int cellAudioInit() //ConLog.Write("Audio perf: start=%d (access=%d, AddData=%d, events=%d, dump=%d)", //stamp0 - m_config.start_time, stamp1 - stamp0, stamp2 - stamp1, stamp3 - stamp2, get_system_time() - stamp3); } - ConLog.Write("Audio finished"); + ConLog.Write("Audio thread ended"); abort: queue.Push(nullptr); queue_float.Push(nullptr); @@ -505,7 +505,7 @@ int cellAudioQuit() Sleep(1); if (Emu.IsStopped()) { - ConLog.Warning("cellAudioQuit() aborted"); + ConLog.Warning("cellAudioQuit(): aborted"); return CELL_OK; } } diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index 0abaed44aa..ccada21244 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -47,7 +47,7 @@ u32 dmuxOpen(Demuxer* data) thread t("Demuxer[" + std::to_string(dmux_id) + "] Thread", [&]() { - ConLog.Write("Demuxer enter (mem=0x%x, size=0x%x, cb=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc, dmux.cbArg); + ConLog.Write("Demuxer thread started (mem=0x%x, size=0x%x, cb=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc, dmux.cbArg); DemuxerTask task; DemuxerStream stream; @@ -357,7 +357,7 @@ u32 dmuxOpen(Demuxer* data) case dmuxClose: { dmux.is_finished = true; - ConLog.Write("Demuxer exit"); + ConLog.Write("Demuxer thread ended"); return; } @@ -450,11 +450,11 @@ u32 dmuxOpen(Demuxer* data) break; default: - ConLog.Error("Demuxer error: unknown task(%d)", task.type); + ConLog.Error("Demuxer thread error: unknown task(%d)", task.type); return; } } - ConLog.Warning("Demuxer aborted"); + ConLog.Warning("Demuxer thread aborted"); }); t.detach(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index 69a6256de3..be6d1f6e96 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -35,7 +35,7 @@ next: { if (Emu.IsStopped()) { - ConLog.Warning("vdecRead() aborted"); + ConLog.Warning("vdecRead(): aborted"); return 0; } Sleep(1); @@ -52,7 +52,7 @@ next: { if (!Memory.CopyToReal(buf, vdec.reader.addr, vdec.reader.size)) { - ConLog.Error("vdecRead: data reading failed (reader.size=0x%x)", vdec.reader.size); + ConLog.Error("vdecRead(): data reading failed (reader.size=0x%x)", vdec.reader.size); Emu.Pause(); return 0; } @@ -92,7 +92,7 @@ next: } else if (!Memory.CopyToReal(buf, vdec.reader.addr, buf_size)) { - ConLog.Error("vdecRead: data reading failed (buf_size=0x%x)", buf_size); + ConLog.Error("vdecRead(): data reading failed (buf_size=0x%x)", buf_size); Emu.Pause(); return 0; } @@ -136,7 +136,7 @@ u32 vdecOpen(VideoDecoder* data) thread t("Video Decoder[" + std::to_string(vdec_id) + "] Thread", [&]() { - ConLog.Write("Video Decoder enter()"); + ConLog.Write("Video Decoder thread started"); VdecTask& task = vdec.task; @@ -305,7 +305,7 @@ u32 vdecOpen(VideoDecoder* data) { if (Emu.IsStopped()) { - ConLog.Warning("vdecDecodeAu aborted"); + ConLog.Warning("vdecDecodeAu: aborted"); return; } @@ -398,7 +398,7 @@ u32 vdecOpen(VideoDecoder* data) case vdecClose: { vdec.is_finished = true; - ConLog.Write("Video Decoder exit"); + ConLog.Write("Video Decoder thread ended"); return; } @@ -409,12 +409,12 @@ u32 vdecOpen(VideoDecoder* data) break; default: - ConLog.Error("Video Decoder error: unknown task(%d)", task.type); + ConLog.Error("Video Decoder thread error: unknown task(%d)", task.type); } } vdec.is_finished = true; - ConLog.Warning("Video Decoder aborted"); + ConLog.Warning("Video Decoder thread aborted"); }); t.detach(); From 4e55e6abbd331ad61d9cd24896fcf1ad2f031a1b Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 21 Jun 2014 18:04:59 +0800 Subject: [PATCH 3/3] Set rendering width/height to buffer width/height --- rpcs3/Emu/GS/RSXThread.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index a3768f4c2d..7e4c1bfa2a 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -1262,9 +1262,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 } gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr); - m_width = re(buffers[m_gcm_current_buffer].width); - m_height = re(buffers[m_gcm_current_buffer].height); + m_buffer_width = re(buffers[m_gcm_current_buffer].width); + m_buffer_height = re(buffers[m_gcm_current_buffer].height); + m_width = m_buffer_width; + m_height = m_buffer_height; + if (Ini.GSDownscale.GetValue() && Ini.GSResolution.GetValue() == 4) { if (m_width == 1280 && m_height == 720)