RSX: Fixed NV4097_SET_VERTEX_DATA4UB_M, NV4097_SET_VERTEX_DATA2F_M & NV4097_SET_VERTEX_DATA4F_M implementation

This commit is contained in:
DHrpcs3 2014-12-02 00:02:05 +02:00
parent 7ba0bda244
commit d593e47554
4 changed files with 164 additions and 88 deletions

View File

@ -816,10 +816,36 @@ void GLGSRender::EnableVertexData(bool indexed_draw)
for(u32 i=0; i<m_vertex_count; ++i)
{
if (0)
{
u32 data_format = methodRegisters[NV4097_SET_VERTEX_DATA_ARRAY_FORMAT + i * 4];
u16 frequency = data_format >> 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<m_vertex_count; ++i)
{
if(!m_vertex_data[i].IsEnabled() || !m_vertex_data[i].addr) continue;
if(!m_vertex_data[i].IsEnabled()) continue;
glDisableVertexAttribArray(i);
checkForGlError("glDisableVertexAttribArray");
}
@ -1002,14 +1028,16 @@ void GLGSRender::DisableVertexData()
void GLGSRender::InitVertexData()
{
int l;
GLfloat scaleOffsetMat[16] = {
GLfloat scaleOffsetMat[16] =
{
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
for (const RSXTransformConstant& c : m_transform_constants) {
for (const RSXTransformConstant& c : m_transform_constants)
{
const std::string name = fmt::Format("vc[%u]", c.id);
l = m_program.GetLocation(name);
checkForGlError("glGetUniformLocation " + name);
@ -1676,6 +1704,24 @@ void GLGSRender::ExecCMD()
checkForGlError("glColorMask");
}
if (!m_indexed_array.m_count && !m_draw_array_count)
{
u32 min_vertex_size = ~0;
for(auto &i : m_vertex_data)
{
if (!i.size)
continue;
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;
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)
{

View File

@ -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<u32>::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<u32>::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<u32>::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<u32>& value)
{
value += 4;
@ -2278,7 +2308,7 @@ void RSXThread::Task()
for(u32 i=0; i<count; i++)
{
methodRegisters[(cmd & 0xffff) + (i*4*inc)] = ARGS(i);
methodRegisters[(cmd & 0xffff) + (i * 4 * inc)] = ARGS(i);
}
DoCmd(cmd, cmd & 0x3ffff, args.addr(), count);

View File

@ -1170,15 +1170,7 @@ s32 cellGcmCallback(vm::ptr<CellGcmContextData> context, u32 count)
{
cellGcmSys->Log("cellGcmCallback(context_addr=0x%x, count=0x%x)", context.addr(), count);
auto& ctrl = vm::get_ref<CellGcmControl>(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<u32>::make(offset)); // update put pointer
}
//auto& ctrl = vm::get_ref<CellGcmControl>(gcm_info.control_addr);
// preparations for changing the place (for optimized FIFO mode)
//auto cmd = vm::ptr<u32>::make(context->current.ToLE());
@ -1188,6 +1180,7 @@ s32 cellGcmCallback(vm::ptr<CellGcmContextData> 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<CellGcmContextData> 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

View File

@ -69,16 +69,16 @@
<Filter Include="Emu\CPU\ARMv7\Modules">
<UniqueIdentifier>{1d9e6fc4-9a79-4329-a8b5-081e24822aaa}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\GPU">
<Filter Include="GPU">
<UniqueIdentifier>{6674e2ab-90cd-47de-a852-d21643ab18c2}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\GPU\RSX">
<Filter Include="GPU\RSX">
<UniqueIdentifier>{fadb4b36-57af-4583-891d-d22ff369e266}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\GPU\RSX\Null">
<Filter Include="GPU\RSX\Null">
<UniqueIdentifier>{4adca4fa-b90f-4662-9eb0-1d29cf3cd2eb}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\GPU\RSX\GL">
<Filter Include="GPU\RSX\GL">
<UniqueIdentifier>{6f1da5b2-52c5-416b-9b5c-b9897bc1b300}</UniqueIdentifier>
</Filter>
</ItemGroup>
@ -558,37 +558,37 @@
<Filter>Emu\SysCalls\Modules</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GL\GLProgram.cpp">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GL\GLProgramBuffer.cpp">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GL\GLVertexProgram.cpp">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GL\OpenGL.cpp">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GL\GLBuffers.cpp">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GL\GLFragmentProgram.cpp">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GL\GLGSRender.cpp">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GSManager.cpp">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\GSRender.cpp">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\RSXTexture.cpp">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\RSXThread.cpp">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\SysCalls\lv2\sys_event_flag.cpp">
<Filter>Emu\SysCalls\lv2</Filter>
@ -1124,58 +1124,58 @@
<Filter>Emu\SysCalls</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Null\NullGSRender.h">
<Filter>Emu\GPU\RSX\Null</Filter>
<Filter>GPU\RSX\Null</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLGSRender.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLProcTable.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLProgram.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLProgramBuffer.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLShaderParam.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLVertexProgram.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\OpenGL.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLBuffers.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\GLFragmentProgram.h">
<Filter>Emu\GPU\RSX\GL</Filter>
<Filter>GPU\RSX\GL</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GSManager.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GSRender.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\RSXFragmentProgram.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\RSXTexture.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\RSXThread.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\RSXVertexProgram.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\sysutil_video.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GCM.h">
<Filter>Emu\GPU\RSX</Filter>
<Filter>GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\SysCalls\lv2\sys_event_flag.h">
<Filter>Emu\SysCalls\lv2</Filter>