1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 03:02:53 +01:00

RSXVertexData bugs fixed

* Some extra info on sys_rsx syscalls
* Code cleaned in GLGSRender.cpp
This commit is contained in:
Alexandro Sánchez Bach 2014-08-18 16:37:23 +02:00
parent f71780609d
commit b23a5f2312
3 changed files with 96 additions and 72 deletions

View File

@ -188,64 +188,67 @@ void GLGSRender::EnableVertexData(bool indexed_draw)
GL_HALF_FLOAT, GL_HALF_FLOAT,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
GL_SHORT, GL_SHORT,
GL_FLOAT, // Needs conversion
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
}; };
static const bool gl_normalized[] = static const bool gl_normalized[] =
{ {
true, GL_TRUE,
false, GL_FALSE,
false, GL_FALSE,
true, GL_TRUE,
false, GL_FALSE,
false, GL_TRUE,
GL_FALSE,
}; };
if(m_vertex_data[i].type >= 1 && m_vertex_data[i].type <= 7) if (m_vertex_data[i].type < 1 && m_vertex_data[i].type > 7) {
LOG_ERROR(RSX, "GLGSRender::EnableVertexData: Bad vertex data type (%d)!", m_vertex_data[i].type);
}
if(!m_vertex_data[i].addr)
{ {
if(!m_vertex_data[i].addr) switch(m_vertex_data[i].type)
{ {
switch(m_vertex_data[i].type) case CELL_GCM_VERTEX_S32K:
case CELL_GCM_VERTEX_S1:
switch(m_vertex_data[i].size)
{ {
case CELL_GCM_VERTEX_S32K: case 1: glVertexAttrib1s(i, (GLshort&)m_vertex_data[i].data[0]); break;
case CELL_GCM_VERTEX_S1: case 2: glVertexAttrib2sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
switch(m_vertex_data[i].size) case 3: glVertexAttrib3sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
{ case 4: glVertexAttrib4sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
case 1: glVertexAttrib1s(i, (GLshort&)m_vertex_data[i].data[0]); break;
case 2: glVertexAttrib2sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
case 3: glVertexAttrib3sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
case 4: glVertexAttrib4sv(i, (GLshort*)&m_vertex_data[i].data[0]); break;
}
break;
case CELL_GCM_VERTEX_F:
switch(m_vertex_data[i].size)
{
case 1: glVertexAttrib1f(i, (GLfloat&)m_vertex_data[i].data[0]); break;
case 2: glVertexAttrib2fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
case 3: glVertexAttrib3fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
case 4: glVertexAttrib4fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
}
break;
case CELL_GCM_VERTEX_CMP:
case CELL_GCM_VERTEX_UB:
glVertexAttrib4ubv(i, (GLubyte*)&m_vertex_data[i].data[0]);
break;
} }
break;
checkForGlError("glVertexAttrib"); case CELL_GCM_VERTEX_F:
} switch(m_vertex_data[i].size)
else {
{ case 1: glVertexAttrib1f(i, (GLfloat&)m_vertex_data[i].data[0]); break;
u32 gltype = gl_types[m_vertex_data[i].type - 1]; case 2: glVertexAttrib2fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
bool normalized = gl_normalized[m_vertex_data[i].type - 1]; case 3: glVertexAttrib3fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
case 4: glVertexAttrib4fv(i, (GLfloat*)&m_vertex_data[i].data[0]); break;
}
break;
glEnableVertexAttribArray(i); case CELL_GCM_VERTEX_CMP:
checkForGlError("glEnableVertexAttribArray"); case CELL_GCM_VERTEX_UB:
glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, reinterpret_cast<void*>(offset_list[i])); glVertexAttrib4ubv(i, (GLubyte*)&m_vertex_data[i].data[0]);
checkForGlError("glVertexAttribPointer"); break;
} }
checkForGlError("glVertexAttrib");
}
else
{
u32 gltype = gl_types[m_vertex_data[i].type - 1];
bool normalized = gl_normalized[m_vertex_data[i].type - 1];
glEnableVertexAttribArray(i);
checkForGlError("glEnableVertexAttribArray");
glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, reinterpret_cast<void*>(offset_list[i]));
checkForGlError("glVertexAttribPointer");
} }
} }
} }
@ -264,15 +267,15 @@ void GLGSRender::DisableVertexData()
void GLGSRender::InitVertexData() void GLGSRender::InitVertexData()
{ {
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};
int l; int l;
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(u32 i=0; i<m_transform_constants.size(); ++i) for (const RSXTransformConstant& c : m_transform_constants) {
{
const RSXTransformConstant& c = m_transform_constants[i];
const std::string name = fmt::Format("vc[%u]", c.id); const std::string name = fmt::Format("vc[%u]", c.id);
l = m_program.GetLocation(name); l = m_program.GetLocation(name);
checkForGlError("glGetUniformLocation " + name); checkForGlError("glGetUniformLocation " + name);
@ -283,13 +286,13 @@ void GLGSRender::InitVertexData()
} }
// Scale // Scale
scaleOffsetMat[0] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 0)] / (RSXThread::m_width / RSXThread::m_width_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[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 // Offset
scaleOffsetMat[3] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 0)] - (RSXThread::m_width / RSXThread::m_width_scale); 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[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)] - 1 / 2.0f; scaleOffsetMat[11] = (GLfloat&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 2)] - 1 / 2.0f;
scaleOffsetMat[3] /= RSXThread::m_width / RSXThread::m_width_scale; scaleOffsetMat[3] /= RSXThread::m_width / RSXThread::m_width_scale;
@ -308,10 +311,7 @@ void GLGSRender::InitFragmentData()
return; return;
} }
for(u32 i=0; i<m_fragment_constants.size(); ++i) for(const RSXTransformConstant& c : m_fragment_constants) {
{
const RSXTransformConstant& c = m_fragment_constants[i];
u32 id = c.id - m_cur_shader_prog->offset; u32 id = c.id - m_cur_shader_prog->offset;
//LOG_WARNING(RSX,"fc%u[0x%x - 0x%x] = (%f, %f, %f, %f)", id, c.id, m_cur_shader_prog->offset, c.x, c.y, c.z, c.w); //LOG_WARNING(RSX,"fc%u[0x%x - 0x%x] = (%f, %f, %f, %f)", id, c.id, m_cur_shader_prog->offset, c.x, c.y, c.z, c.w);

View File

@ -117,16 +117,18 @@ u32 RSXVertexData::GetTypeSize()
{ {
switch (type) switch (type)
{ {
case 1: return 2; case CELL_GCM_VERTEX_S1: return 2;
case 2: return 4; case CELL_GCM_VERTEX_F: return 4;
case 3: return 2; case CELL_GCM_VERTEX_SF: return 2;
case 4: return 1; case CELL_GCM_VERTEX_UB: return 1;
case 5: return 2; case CELL_GCM_VERTEX_S32K: return 2;
case 7: return 1; case CELL_GCM_VERTEX_CMP: return 4;
} case CELL_GCM_VERTEX_UB256: return 1;
LOG_ERROR(RSX, "Bad vertex data type! %d", type); default:
return 1; LOG_ERROR(RSX, "RSXVertexData::GetTypeSize: Bad vertex data type (%d)!", type);
return 1;
}
} }
#define CMD_DEBUG 0 #define CMD_DEBUG 0

View File

@ -101,15 +101,27 @@ s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u6
switch(package_id) switch(package_id)
{ {
case 0x001: // ? case 0x001: // FIFO
break;
case 0x100: // Display mode set
break; break;
case 0x101: // ? case 0x101: // Display sync
break;
case 0x102: // Display flip
break;
case 0x103: // ?
break; break;
case 0x104: // Display buffer case 0x104: // Display buffer
break; break;
case 0x106: // ? (Used by cellGcmInitPerfMon)
break;
case 0x10a: // ? case 0x10a: // ?
break; break;
@ -119,9 +131,19 @@ s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u6
case 0x301: // Depth-buffer (Z-cull) case 0x301: // Depth-buffer (Z-cull)
break; break;
default: case 0x600: // Framebuffer setup
break; break;
case 0x601: // Framebuffer blit
break;
case 0x602: // Framebuffer blit sync
break;
default:
return CELL_EINVAL;
} }
return CELL_OK; return CELL_OK;
} }
@ -129,7 +151,7 @@ s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u6
* lv2 SysCall 675 (0x2A3): sys_rsx_device_map * lv2 SysCall 675 (0x2A3): sys_rsx_device_map
* @param a1 (OUT): For example: In vsh.self it is 0x60000000, global semaphore. For a game it is 0x40000000. * @param a1 (OUT): For example: In vsh.self it is 0x60000000, global semaphore. For a game it is 0x40000000.
* @param a2 (OUT): Unused? * @param a2 (OUT): Unused?
* @param dev_id (IN): An immediate value and always 8. * @param dev_id (IN): An immediate value and always 8. (cellGcmInitPerfMon uses 11, 10, 9, 7, 12 successively).
*/ */
s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 dev_id) s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 dev_id)
{ {