diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 2af22b20ec..16fb3d73eb 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -816,10 +816,36 @@ void GLGSRender::EnableVertexData(bool indexed_draw) for(u32 i=0; i> 16; + u8 stride = (data_format >> 8) & 0xff; + u8 size = (data_format >> 4) & 0xf; + u8 type = data_format & 0xf; + + u32 type_size = 1; + switch (type) + { + case CELL_GCM_VERTEX_S1: type_size = 2; break; + case CELL_GCM_VERTEX_F: type_size = 4; break; + case CELL_GCM_VERTEX_SF: type_size = 2; break; + case CELL_GCM_VERTEX_UB: type_size = 1; break; + case CELL_GCM_VERTEX_S32K: type_size = 2; break; + case CELL_GCM_VERTEX_CMP: type_size = 4; break; + case CELL_GCM_VERTEX_UB256: type_size = 1; break; + + default: + LOG_ERROR(RSX, "RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type); + break; + } + + int item_size = size * type_size; + } + offset_list[i] = cur_offset; - if(!m_vertex_data[i].IsEnabled() || !m_vertex_data[i].addr) continue; - + if (!m_vertex_data[i].IsEnabled()) continue; const size_t item_size = m_vertex_data[i].GetTypeSize() * m_vertex_data[i].size; const size_t data_size = m_vertex_data[i].data.size() - data_offset * item_size; const u32 pos = m_vdata.size(); @@ -835,12 +861,12 @@ void GLGSRender::EnableVertexData(bool indexed_draw) m_vbo.Create(indexed_draw ? 2 : 1); m_vbo.Bind(0); - m_vbo.SetData(&m_vdata[0], m_vdata.size()); + m_vbo.SetData(m_vdata.data(), m_vdata.size()); if(indexed_draw) { m_vbo.Bind(GL_ELEMENT_ARRAY_BUFFER, 1); - m_vbo.SetData(GL_ELEMENT_ARRAY_BUFFER, &m_indexed_array.m_data[0], m_indexed_array.m_data.size()); + m_vbo.SetData(GL_ELEMENT_ARRAY_BUFFER, m_indexed_array.m_data.data(), m_indexed_array.m_data.size()); } checkForGlError("initializing vbo"); @@ -941,7 +967,7 @@ void GLGSRender::EnableVertexData(bool indexed_draw) LOG_ERROR(RSX, "GLGSRender::EnableVertexData: Bad vertex data type (%d)!", m_vertex_data[i].type); } - if(!m_vertex_data[i].addr) + if(0 && !m_vertex_data[i].addr) { switch(m_vertex_data[i].type) { @@ -992,7 +1018,7 @@ void GLGSRender::DisableVertexData() m_vdata.clear(); for(u32 i=0; i vertex_size) + min_vertex_size = vertex_size; + } + + m_draw_array_count = min_vertex_size; + m_draw_array_first = 0; + } + Enable(m_set_depth_test, GL_DEPTH_TEST); Enable(m_set_alpha_test, GL_ALPHA_TEST); Enable(m_set_depth_bounds_test, GL_DEPTH_BOUNDS_TEST_EXT); @@ -1938,10 +1984,13 @@ void GLGSRender::ExecCMD() LoadVertexData(m_indexed_array.index_min, m_indexed_array.index_max - m_indexed_array.index_min + 1); } - EnableVertexData(m_indexed_array.m_count ? true : false); + if (m_indexed_array.m_count || m_draw_array_count) + { + EnableVertexData(m_indexed_array.m_count ? true : false); - InitVertexData(); - InitFragmentData(); + InitVertexData(); + InitFragmentData(); + } if(m_indexed_array.m_count) { diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index de0ff1aa8f..311dd3143c 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -95,11 +95,11 @@ RSXVertexData::RSXVertexData() void RSXVertexData::Reset() { - frequency = 0; - stride = 0; - size = 0; - type = 0; - addr = 0; + //frequency = 0; + //stride = 0; + //size = 0; + //type = 0; + //addr = 0; data.clear(); } @@ -313,7 +313,9 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case 0x0003fead: //if(cmd == 0xfeadffff) { + //LOG_WARNING(RSX, "Flip()"); Flip(); + m_last_flip_time = get_system_time(); m_gcm_current_buffer = ARGS(0); @@ -399,14 +401,14 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const u8 v2 = a0 >> 16; u8 v3 = a0 >> 24; - m_vertex_data[index].Reset(); + //m_vertex_data[index].Reset(); m_vertex_data[index].size = 4; - m_vertex_data[index].type = 4; + m_vertex_data[index].type = CELL_GCM_VERTEX_UB; m_vertex_data[index].data.push_back(v0); m_vertex_data[index].data.push_back(v1); m_vertex_data[index].data.push_back(v2); m_vertex_data[index].data.push_back(v3); - //LOG_WARNING(RSX, "index = %d, v0 = 0x%x, v1 = 0x%x, v2 = 0x%x, v3 = 0x%x", index, v0, v1, v2, v3); + //LOG_WARNING(RSX, "NV4097_SET_VERTEX_DATA4UB_M: index = %d, v0 = 0x%x, v1 = 0x%x, v2 = 0x%x, v3 = 0x%x", index, v0, v1, v2, v3); } break; @@ -418,14 +420,15 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const float v0 = (float&)a0; float v1 = (float&)a1; - m_vertex_data[index].Reset(); - m_vertex_data[index].type = 2; + //m_vertex_data[index].Reset(); + m_vertex_data[index].type = CELL_GCM_VERTEX_F; m_vertex_data[index].size = 2; - m_vertex_data[index].data.resize(sizeof(float) * 2); - (float&)m_vertex_data[index].data[sizeof(float)*0] = v0; - (float&)m_vertex_data[index].data[sizeof(float)*1] = v1; + u32 pos = m_vertex_data[index].data.size(); + m_vertex_data[index].data.resize(pos + sizeof(float) * 2); + (float&)m_vertex_data[index].data[pos + sizeof(float) * 0] = v0; + (float&)m_vertex_data[index].data[pos + sizeof(float) * 1] = v1; - //LOG_WARNING(RSX, "index = %d, v0 = %f, v1 = %f", index, v0, v1); + //LOG_WARNING(RSX, "NV4097_SET_VERTEX_DATA2F_M: index = %d, v0 = %f, v1 = %f", index, v0, v1); } break; @@ -441,16 +444,17 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const float v2 = (float&)a2; float v3 = (float&)a3; - m_vertex_data[index].Reset(); - m_vertex_data[index].type = 2; + //m_vertex_data[index].Reset(); + m_vertex_data[index].type = CELL_GCM_VERTEX_F; m_vertex_data[index].size = 4; - m_vertex_data[index].data.resize(sizeof(float) * 4); - (float&)m_vertex_data[index].data[sizeof(float)*0] = v0; - (float&)m_vertex_data[index].data[sizeof(float)*1] = v1; - (float&)m_vertex_data[index].data[sizeof(float)*2] = v2; - (float&)m_vertex_data[index].data[sizeof(float)*3] = v3; + u32 pos = m_vertex_data[index].data.size(); + m_vertex_data[index].data.resize(pos + sizeof(float) * 4); + (float&)m_vertex_data[index].data[pos + sizeof(float) * 0] = v0; + (float&)m_vertex_data[index].data[pos + sizeof(float) * 1] = v1; + (float&)m_vertex_data[index].data[pos + sizeof(float) * 2] = v2; + (float&)m_vertex_data[index].data[pos + sizeof(float) * 3] = v3; - //LOG_WARNING(RSX, "index = %d, v0 = %f, v1 = %f, v2 = %f, v3 = %f", index, v0, v1, v2, v3); + //LOG_WARNING(RSX, "NV4097_SET_VERTEX_DATA4F_M: index = %d, v0 = %f, v1 = %f, v2 = %f, v3 = %f", index, v0, v1, v2, v3); } break; @@ -460,6 +464,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const CMD_LOG("num=%d, addr=0x%x", index, addr); m_vertex_data[index].addr = addr; m_vertex_data[index].data.clear(); + + //LOG_WARNING(RSX, "NV4097_SET_VERTEX_DATA_ARRAY_OFFSET: num=%d, addr=0x%x", index, addr); } break; @@ -478,6 +484,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const cv.stride = stride; cv.size = size; cv.type = type; + + //LOG_WARNING(RSX, "NV4097_SET_VERTEX_DATA_ARRAY_FORMAT: index=%d, frequency=%d, stride=%d, size=%d, type=%d", index, frequency, stride, size, type); } break; @@ -947,6 +955,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const if (count >= 2) { m_vertex_data_base_index = ARGS(1); } + + //LOG_ERROR(RSX, "NV4097_SET_VERTEX_DATA_BASE_OFFSET: 0x%x", m_vertex_data_base_offset); } break; @@ -1453,14 +1463,24 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case NV4097_SET_SURFACE_PITCH_D: { - if (ARGS(0)) - LOG_WARNING(RSX, "NV4097_SET_SURFACE_PITCH_D: 0x%x", ARGS(0)); + m_surface_pitch_d = ARGS(0); + + if (count != 1) + { + LOG_WARNING(RSX, "NV4097_SET_SURFACE_PITCH_D: Bad count (%d)", count); + break; + } } break; case NV4097_SET_SURFACE_PITCH_Z: { m_surface_pitch_z = ARGS(0); + if (count != 1) + { + LOG_WARNING(RSX, "NV4097_SET_SURFACE_PITCH_Z: Bad count (%d)", count); + break; + } } break; @@ -1468,6 +1488,12 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const { m_set_context_dma_color_a = true; m_context_dma_color_a = ARGS(0); + + if (count != 1) + { + LOG_WARNING(RSX, "NV4097_SET_CONTEXT_DMA_COLOR_A: Bad count (%d)", count); + break; + } } break; @@ -2135,6 +2161,9 @@ void RSXThread::End() { ExecCMD(); + for (auto &vdata : m_vertex_data) + vdata.data.clear(); + m_indexed_array.Reset(); m_fragment_constants.clear(); m_transform_constants.clear(); @@ -2233,17 +2262,17 @@ void RSXThread::Task() if(cmd & CELL_GCM_METHOD_FLAG_JUMP) { - u32 addr = cmd & ~(CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT); - //LOG_WARNING(RSX, "rsx jump(0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", addr, m_ioAddress + get, cmd, get, put); - m_ctrl->get.exchange(be_t::make(addr)); + u32 offs = cmd & 0x1fffffff; + //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) { m_call_stack.push(get + 4); - u32 offs = cmd & ~CELL_GCM_METHOD_FLAG_CALL; + u32 offs = cmd & ~3; //u32 addr = offs; - //LOG_WARNING(RSX, "rsx call(0x%x) #0x%x - 0x%x - 0x%x", offs, addr, cmd, get); + //LOG_WARNING(RSX, "rsx call(0x%x) #0x%x - 0x%x", offs, cmd, get); m_ctrl->get.exchange(be_t::make(offs)); continue; } @@ -2261,12 +2290,13 @@ void RSXThread::Task() //LOG_WARNING(RSX, "non increment cmd! 0x%x", cmd); inc = 0; } - - if(cmd == 0) + else + { + //LOG_WARNING(RSX, "increment cmd! 0x%x", cmd); + } + + if(cmd == 0) //nop { - LOG_ERROR(Log::RSX, "null cmd: cmd=0x%x, put=0x%x, get=0x%x (addr=0x%x)", cmd, put, get, (u32)Memory.RSXIOMem.RealAddr(get)); - //Emu.Pause(); - //HACK! We shouldn't be here m_ctrl->get.atomic_op([](be_t& value) { value += 4; @@ -2278,7 +2308,7 @@ void RSXThread::Task() for(u32 i=0; i context, u32 count) { cellGcmSys->Log("cellGcmCallback(context_addr=0x%x, count=0x%x)", context.addr(), count); - auto& ctrl = vm::get_ref(gcm_info.control_addr); - - { - const u32 address = context->current; - const u32 upper = offsetTable.ioAddress[address >> 20]; // 12 bits - assert(upper != 0xFFFF); - const u32 offset = (upper << 20) | (address & 0xFFFFF); - //ctrl.put.exchange(be_t::make(offset)); // update put pointer - } + //auto& ctrl = vm::get_ref(gcm_info.control_addr); // preparations for changing the place (for optimized FIFO mode) //auto cmd = vm::ptr::make(context->current.ToLE()); @@ -1188,6 +1180,7 @@ s32 cellGcmCallback(vm::ptr context, u32 count) //cmd[3] = 0; // some incrementing by module value //context->current += 0x10; + if (0) { const u32 address = context->begin; const u32 upper = offsetTable.ioAddress[address >> 20]; // 12 bits @@ -1195,6 +1188,10 @@ s32 cellGcmCallback(vm::ptr context, u32 count) const u32 offset = (upper << 20) | (address & 0xFFFFF); vm::write32(context->current, CELL_GCM_METHOD_FLAG_JUMP | offset); // set JUMP cmd } + else + { + vm::write32(context->current, CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT | (0)); + } context->current = context->begin; // rewind to the beginning // TODO: something is missing diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index d4cec623e0..9335c19690 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -69,16 +69,16 @@ {1d9e6fc4-9a79-4329-a8b5-081e24822aaa} - + {6674e2ab-90cd-47de-a852-d21643ab18c2} - + {fadb4b36-57af-4583-891d-d22ff369e266} - + {4adca4fa-b90f-4662-9eb0-1d29cf3cd2eb} - + {6f1da5b2-52c5-416b-9b5c-b9897bc1b300} @@ -558,37 +558,37 @@ Emu\SysCalls\Modules - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX Emu\SysCalls\lv2 @@ -1124,58 +1124,58 @@ Emu\SysCalls - Emu\GPU\RSX\Null + GPU\RSX\Null - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX\GL + GPU\RSX\GL - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX - Emu\GPU\RSX + GPU\RSX Emu\SysCalls\lv2