From dabac038202847e0b5c20d31a7f1690d15a9a0d2 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 26 Dec 2014 21:32:53 +0300 Subject: [PATCH] Revert "Formatting RSX thread" This reverts commit 97d50a0692c0b5f3c613d07218bd8169ce033ec3. --- rpcs3/Emu/RSX/RSXThread.cpp | 351 ++++++++++++++++++------------------ rpcs3/Emu/RSX/RSXThread.h | 14 +- 2 files changed, 177 insertions(+), 188 deletions(-) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index caa0481f1d..ef64c0d754 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -14,42 +14,34 @@ u32 methodRegisters[0xffff]; -void RSXThread::NativeRescale(float width, float height) +void RSXThread::nativeRescale(float width, float height) { switch (Ini.GSResolution.GetValue()) { case 1: // 1920x1080 window size - { m_width_scale = 1920 / width * 2.0f; m_height_scale = 1080 / height * 2.0f; m_width = 1920; m_height = 1080; - } - break; + break; case 2: // 1280x720 window size - { m_width_scale = 1280 / width * 2.0f; m_height_scale = 720 / height * 2.0f; m_width = 1280; m_height = 720; - } - break; + break; case 4: // 720x480 window size - { m_width_scale = 720 / width * 2.0f; m_height_scale = 480 / height * 2.0f; m_width = 720; m_height = 480; - } - break; + break; case 5: // 720x576 window size - { m_width_scale = 720 / width * 2.0f; m_height_scale = 576 / height * 2.0f; m_width = 720; m_height = 576; - } - break; + break; } } @@ -57,7 +49,7 @@ u32 GetAddress(u32 offset, u32 location) { u32 res = 0; - switch (location) + switch(location) { case CELL_GCM_LOCATION_LOCAL: { @@ -113,18 +105,18 @@ void RSXVertexData::Reset() void RSXVertexData::Load(u32 start, u32 count, u32 baseOffset, u32 baseIndex=0) { - if (!addr) return; + if(!addr) return; const u32 tsize = GetTypeSize(); data.resize((start + count) * tsize * size); - for (u32 i = start; i < start + count; ++i) + for(u32 i=start; i(addr + baseOffset + stride * (i + baseIndex)); u8* dst = &data[i * tsize * size]; - switch (tsize) + switch(tsize) { case 1: { @@ -136,7 +128,7 @@ void RSXVertexData::Load(u32 start, u32 count, u32 baseOffset, u32 baseIndex=0) { const u16* c_src = (const u16*)src; u16* c_dst = (u16*)dst; - for (u32 j = 0; j < size; ++j) *c_dst++ = re16(*c_src++); + for(u32 j=0; j::make(args_addr); std::string debug = GetMethodName(cmd); debug += "("; - for (u32 i = 0; i < count; ++i) debug += (i ? ", " : "") + fmt::Format("0x%x", ARGS(i)); + for(u32 i=0; i> 31); CMD_LOG("num=%d, addr=0x%x", index, addr); @@ -481,7 +518,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const } break; - case_16(NV4097_SET_VERTEX_DATA_ARRAY_FORMAT, 4) + case_16(NV4097_SET_VERTEX_DATA_ARRAY_FORMAT, 4): { const u32 a0 = ARGS(0); u16 frequency = a0 >> 16; @@ -505,9 +542,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_VERTEX_ATTRIB_INPUT_MASK: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_VERTEX_ATTRIB_INPUT_MASK: 0x%x", ARGS(0)); - } //VertexData[0].prog.attributeInputMask = ARGS(0); } @@ -516,9 +551,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_VERTEX_ATTRIB_OUTPUT_MASK: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_VERTEX_ATTRIB_OUTPUT_MASK: 0x%x", ARGS(0)); - } //VertexData[0].prog.attributeOutputMask = ARGS(0); //FragmentData.prog.attributeInputMask = ARGS(0)/* & ~0x20*/; @@ -541,9 +574,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_COLOR_MASK_MRT: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_COLOR_MASK_MRT: 0x%x", ARGS(0)); - } } break; @@ -647,9 +678,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_BLEND_COLOR2: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_BLEND_COLOR2: 0x % x", ARGS(0)); - } } break; @@ -664,9 +693,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_REDUCE_DST_COLOR: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_REDUCE_DST_COLOR: 0x%x", ARGS(0)); - } } break; @@ -842,8 +869,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const { u32 a0 = ARGS(0); - if (a0 & 0x01) m_clear_surface_z = m_clear_z; - if (a0 & 0x02) m_clear_surface_s = m_clear_s; + if(a0 & 0x01) m_clear_surface_z = m_clear_z; + if(a0 & 0x02) m_clear_surface_s = m_clear_s; m_clear_surface_mask |= a0 & 0x3; } @@ -853,12 +880,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const { const u32 a0 = ARGS(0); - if (a0 & 0x01) m_clear_surface_z = m_clear_z; - if (a0 & 0x02) m_clear_surface_s = m_clear_s; - if (a0 & 0x10) m_clear_surface_color_r = m_clear_color_r; - if (a0 & 0x20) m_clear_surface_color_g = m_clear_color_g; - if (a0 & 0x40) m_clear_surface_color_b = m_clear_color_b; - if (a0 & 0x80) m_clear_surface_color_a = m_clear_color_a; + if(a0 & 0x01) m_clear_surface_z = m_clear_z; + if(a0 & 0x02) m_clear_surface_s = m_clear_s; + if(a0 & 0x10) m_clear_surface_color_r = m_clear_color_r; + if(a0 & 0x20) m_clear_surface_color_g = m_clear_color_g; + if(a0 & 0x40) m_clear_surface_color_b = m_clear_color_b; + if(a0 & 0x80) m_clear_surface_color_a = m_clear_color_a; m_clear_surface_mask = a0; ExecCMD(NV4097_CLEAR_SURFACE); @@ -886,25 +913,21 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_CLEAR_RECT_HORIZONTAL: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_CLEAR_RECT_HORIZONTAL: 0x%x", ARGS(0)); - } } break; case NV4097_SET_CLEAR_RECT_VERTICAL: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_CLEAR_RECT_VERTICAL: 0x%x", ARGS(0)); - } } break; // Arrays case NV4097_DRAW_ARRAYS: { - for (u32 c = 0; c < count; ++c) + for(u32 c=0; c> 24) + 1; - if (first < m_indexed_array.m_first) m_indexed_array.m_first = first; + if(first < m_indexed_array.m_first) m_indexed_array.m_first = first; - for (u32 i = first; i < _count; ++i) + for(u32 i=first; i<_count; ++i) { u32 index; - switch (m_indexed_array.m_type) + switch(m_indexed_array.m_type) { case 0: { @@ -966,8 +989,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const break; } - if (index < m_indexed_array.index_min) m_indexed_array.index_min = index; - if (index > m_indexed_array.index_max) m_indexed_array.index_max = index; + if(index < m_indexed_array.index_min) m_indexed_array.index_min = index; + if(index > m_indexed_array.index_max) m_indexed_array.index_max = index; } m_indexed_array.m_count += _count; @@ -1008,9 +1031,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const u32 vertex_size = i.data.size() / (i.size * i.GetTypeSize()); if (min_vertex_size > vertex_size) - { min_vertex_size = vertex_size; - } } m_draw_array_count = min_vertex_size; @@ -1074,9 +1095,10 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const if (count == 2) { - if (ARGS(1)) + const u32 start = ARGS(1); + if (start) { - LOG_WARNING(RSX, "NV4097_SET_TRANSFORM_PROGRAM_LOAD: start = %d", ARGS(0)); + LOG_WARNING(RSX, "NV4097_SET_TRANSFORM_PROGRAM_LOAD: start = %d", start); } } } @@ -1084,51 +1106,51 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_TRANSFORM_PROGRAM_START: { - if (ARGS(0)) + const u32 start = ARGS(0); + if (start) { - LOG_WARNING(RSX, "NV4097_SET_TRANSFORM_PROGRAM_START: start = %d", ARGS(0)); + LOG_WARNING(RSX, "NV4097_SET_TRANSFORM_PROGRAM_START: start = %d", start); } } break; - case_32(NV4097_SET_TRANSFORM_PROGRAM, 4) + case_32(NV4097_SET_TRANSFORM_PROGRAM, 4): { //LOG_WARNING(RSX, "NV4097_SET_TRANSFORM_PROGRAM[%d](%d)", index, count); - if (!m_cur_vertex_prog) + if(!m_cur_vertex_prog) { LOG_WARNING(RSX, "NV4097_SET_TRANSFORM_PROGRAM: m_cur_vertex_prog == NULL"); break; } - for (u32 i = 0; i < count; ++i) m_cur_vertex_prog->data.push_back(ARGS(i)); + for(u32 i=0; idata.push_back(ARGS(i)); } break; case NV4097_SET_TRANSFORM_TIMEOUT: - { + // TODO: // (cmd)[1] = CELL_GCM_ENDIAN_SWAP((count) | ((registerCount) << 16)); \ - if (!m_cur_vertex_prog) + if(!m_cur_vertex_prog) { LOG_WARNING(RSX, "NV4097_SET_TRANSFORM_TIMEOUT: m_cur_vertex_prog == NULL"); break; } //m_cur_vertex_prog->Decompile(); - } break; case NV4097_SET_TRANSFORM_CONSTANT_LOAD: { - if ((count - 1) % 4) + if((count - 1) % 4) { CMD_LOG("NV4097_SET_TRANSFORM_CONSTANT_LOAD [%d]", count); break; } - for (u32 id = ARGS(0), i = 1; i < count; ++id) + for(u32 id = ARGS(0), i = 1; i= 2) + if(count >= 2) { m_set_stencil_func_ref = true; m_stencil_func_ref = ARGS(1); - if (count >= 3) + if(count >= 3) { m_set_stencil_func_mask = true; m_stencil_func_mask = ARGS(2); @@ -1258,12 +1276,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_set_stencil_fail = true; m_stencil_fail = ARGS(0); - if (count >= 2) + if(count >= 2) { m_set_stencil_zfail = true; m_stencil_zfail = ARGS(1); - if (count >= 3) + if(count >= 3) { m_set_stencil_zpass = true; m_stencil_zpass = ARGS(2); @@ -1284,12 +1302,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_set_back_stencil_func = true; m_back_stencil_func = ARGS(0); - if (count >= 2) + if(count >= 2) { m_set_back_stencil_func_ref = true; m_back_stencil_func_ref = ARGS(1); - if (count >= 3) + if(count >= 3) { m_set_back_stencil_func_mask = true; m_back_stencil_func_mask = ARGS(2); @@ -1317,12 +1335,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_set_stencil_fail = true; m_stencil_fail = ARGS(0); - if (count >= 2) + if(count >= 2) { m_set_back_stencil_zfail = true; m_back_stencil_zfail = ARGS(1); - if (count >= 3) + if(count >= 3) { m_set_back_stencil_zpass = true; m_back_stencil_zpass = ARGS(2); @@ -1334,9 +1352,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_SCULL_CONTROL: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_SCULL_CONTROL: 0x%x", ARGS(0)); - } //This is stencil culling , nothing to do with stencil masking on regular color or depth buffer //const u32 a0 = ARGS(0); @@ -1374,9 +1390,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_POINT_PARAMS_ENABLE: { if (ARGS(0)) - { LOG_ERROR(RSX, "NV4097_SET_POINT_PARAMS_ENABLE: 0x%x", ARGS(0)); - } } break; @@ -1403,7 +1417,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_scissor_x = ARGS(0) & 0xffff; m_scissor_w = ARGS(0) >> 16; - if (count == 2) + if(count == 2) { m_set_scissor_vertical = true; m_scissor_y = ARGS(1) & 0xffff; @@ -1446,7 +1460,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_height = buffers[m_gcm_current_buffer].height; // Rescale native resolution to fit 1080p/720p/480p/576p window size - NativeRescale((float)m_width, (float)m_height); + nativeRescale((float)m_width, (float)m_height); } break; @@ -1561,7 +1575,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_set_context_dma_color_c = true; m_context_dma_color_c = ARGS(0); - if (count > 1) + if(count > 1) { m_set_context_dma_color_d = true; m_context_dma_color_d = ARGS(1); @@ -1586,18 +1600,14 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_CONTEXT_DMA_SEMAPHORE: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_CONTEXT_DMA_SEMAPHORE: 0x%x", ARGS(0)); - } } break; case NV4097_SET_CONTEXT_DMA_NOTIFIES: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_CONTEXT_DMA_NOTIFIES: 0x%x", ARGS(0)); - } } break; @@ -1609,7 +1619,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_surface_clip_x = a0; m_surface_clip_w = a0 >> 16; - if (count == 2) + if(count == 2) { const u32 a1 = ARGS(1); m_set_surface_clip_vertical = true; @@ -1708,9 +1718,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_ZCULL_CONTROL0: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_ZCULL_CONTROL0: 0x%x", ARGS(0)); - } //m_set_depth_func = true; //m_depth_func = ARGS(0) >> 4; @@ -1720,9 +1728,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_ZCULL_CONTROL1: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_ZCULL_CONTROL1: 0x%x", ARGS(0)); - } //m_set_depth_func = true; //m_depth_func = ARGS(0) >> 4; @@ -1732,18 +1738,14 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_ZCULL_STATS_ENABLE: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_SET_ZCULL_STATS_ENABLE: 0x%x", ARGS(0)); - } } break; case NV4097_ZCULL_SYNC: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV4097_ZCULL_SYNC: 0x%x", ARGS(0)); - } } break; @@ -1838,7 +1840,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const const u8 cullNearFarEnable = ARGS(0) & 0xf; const u8 zclampEnable = (ARGS(0) >> 4) & 0xf; const u8 cullIgnoreW = (ARGS(0) >> 8) & 0xf; - LOG_WARNING(RSX, "TODO: NV4097_SET_ZMIN_MAX_CONTROL: cullNearFarEnable=%d, zclampEnable=%d, cullIgnoreW=%d", cullNearFarEnable, zclampEnable, cullIgnoreW); + LOG_WARNING(RSX, "TODO: NV4097_SET_ZMIN_MAX_CONTROL: cullNearFarEnable=%d, zclampEnable=%d, cullIgnoreW=%d", + cullNearFarEnable, zclampEnable, cullIgnoreW); } break; @@ -1917,7 +1920,6 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const if (!offset) { - // } else { @@ -1929,18 +1931,14 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV0039_PITCH_IN: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV0039_PITCH_IN: 0x%x", ARGS(0)); - } } break; case NV0039_BUFFER_NOTIFY: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV0039_BUFFER_NOTIFY: 0x%x", ARGS(0)); - } } break; @@ -1969,9 +1967,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV309E_SET_CONTEXT_DMA_IMAGE: { if (ARGS(0)) - { LOG_WARNING(RSX, "NV309E_SET_CONTEXT_DMA_IMAGE: 0x%x", ARGS(0)); - } } break; @@ -2013,21 +2009,21 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const c.y = (float&)a; } - if (count >= 3) + if(count >= 3) { u32 a = ARGS(2); a = a << 16 | a >> 16; c.z = (float&)a; } - if (count >= 4) + if(count >= 4) { u32 a = ARGS(3); a = a << 16 | a >> 16; c.w = (float&)a; } - if (count >= 5) + if(count >= 5) { LOG_WARNING(RSX, "NV308A_COLOR: count = %d", count); } @@ -2074,9 +2070,9 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const LOG_WARNING(RSX, "*** m_dst_offset=0x%x, m_color: conv_in_h=0x%x, format_src_pitch=0x%x, conv_in_x=0x%x, conv_in_y=0x%x, conv_out_x=0x%x, conv_out_y=0x%x", m_dst_offset, m_color_conv_in_h, m_color_format_src_pitch, m_color_conv_in_x, m_color_conv_in_y, m_color_conv_out_x, m_color_conv_out_y); - for (u16 y = 0; y < m_color_conv_in_h; ++y) + for(u16 y=0; y lock(m_cs_main); - inc = 1; + inc=1; u32 get = m_ctrl->get.read_sync(); u32 put = m_ctrl->put.read_sync(); - if (put == get || !Emu.IsRunning()) + if(put == get || !Emu.IsRunning()) { - if (put == get) + if(put == get) { - if (m_flip_status == 0) - { + if(m_flip_status == 0) m_sem_flip.post_and_wait(); - } m_sem_flush.post_and_wait(); } @@ -2322,54 +2316,52 @@ void RSXThread::Task() continue; } - + //ConLog.Write("addr = 0x%x", m_ioAddress + get); const u32 cmd = ReadIO32(get); const u32 count = (cmd >> 18) & 0x7ff; + //if(cmd == 0) continue; if (Ini.RSXLogging.GetValue()) - { LOG_NOTICE(Log::RSX, "%s (cmd=0x%x)", GetMethodName(cmd & 0xffff).c_str(), cmd); - } - if (cmd & CELL_GCM_METHOD_FLAG_JUMP) + //LOG_NOTICE(Log::RSX, "put=0x%x, get=0x%x, cmd=0x%x (%s)", put, get, cmd, GetMethodName(cmd & 0xffff).c_str()); + + if(cmd & CELL_GCM_METHOD_FLAG_JUMP) { u32 offs = cmd & 0x1fffffff; - //LOG_WARNING(RSX, "RSX: jump cmd (0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", offs, m_ioAddress + get, cmd, get, put); + //LOG_WARNING(RSX, "rsx jump(0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", offs, m_ioAddress + get, cmd, get, put); m_ctrl->get.exchange(be_t::make(offs)); continue; } - - if (cmd & CELL_GCM_METHOD_FLAG_CALL) + if(cmd & CELL_GCM_METHOD_FLAG_CALL) { m_call_stack.push(get + 4); u32 offs = cmd & ~3; - //LOG_WARNING(RSX, "RSX: call cmd (0x%x) #0x%x - 0x%x", offs, cmd, get); + //u32 addr = offs; + //LOG_WARNING(RSX, "rsx call(0x%x) #0x%x - 0x%x", offs, cmd, get); m_ctrl->get.exchange(be_t::make(offs)); continue; } - - if (cmd == CELL_GCM_METHOD_FLAG_RETURN) + if(cmd == CELL_GCM_METHOD_FLAG_RETURN) { //LOG_WARNING(RSX, "rsx return!"); u32 get = m_call_stack.top(); m_call_stack.pop(); - //LOG_WARNING(RSX, "RSX: return cmd (0x%x)", get); + //LOG_WARNING(RSX, "rsx return(0x%x)", get); m_ctrl->get.exchange(be_t::make(get)); continue; } - - if (cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) + if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) { - //LOG_WARNING(RSX,"RSX: non-increment cmd! 0x%x", cmd); + //LOG_WARNING(RSX, "non increment cmd! 0x%x", cmd); inc = 0; } else { - //LOG_WARNING(RSX, "RSX: increment cmd! 0x%x", cmd); - inc++; + //LOG_WARNING(RSX, "increment cmd! 0x%x", cmd); } - if (cmd == 0) //nop + if(cmd == 0) //nop { m_ctrl->get.atomic_op([](be_t& value) { @@ -2380,7 +2372,7 @@ void RSXThread::Task() auto args = vm::ptr::make((u32)Memory.RSXIOMem.RealAddr(get + 4)); - for (u32 i = 0; i < count; i++) + for(u32 i=0; i