OpenGL renderer: Proper clipping implementation

This commit is contained in:
DHrpcs3 2016-06-21 01:31:50 +03:00
parent 8fd3064905
commit cbf880fb71

View File

@ -215,13 +215,42 @@ void GLGSRender::begin()
u8 clip_plane_4 = (clip_plane_control >> 16) & 0xf; u8 clip_plane_4 = (clip_plane_control >> 16) & 0xf;
u8 clip_plane_5 = (clip_plane_control >> 20) & 0xf; u8 clip_plane_5 = (clip_plane_control >> 20) & 0xf;
//TODO auto set_clip_plane_control = [&](int index, u8 control)
if (__glcheck enable(clip_plane_0, GL_CLIP_DISTANCE0)) {} {
if (__glcheck enable(clip_plane_1, GL_CLIP_DISTANCE1)) {} int value = 0;
if (__glcheck enable(clip_plane_2, GL_CLIP_DISTANCE2)) {} int location;
if (__glcheck enable(clip_plane_3, GL_CLIP_DISTANCE3)) {} if (m_program->uniforms.has_location("uc_m" + std::to_string(index), &location))
if (__glcheck enable(clip_plane_4, GL_CLIP_DISTANCE4)) {} {
if (__glcheck enable(clip_plane_5, GL_CLIP_DISTANCE5)) {} switch (control)
{
default:
LOG_ERROR(RSX, "bad clip plane control (0x%x)", control);
case CELL_GCM_USER_CLIP_PLANE_DISABLE:
value = 0;
break;
case CELL_GCM_USER_CLIP_PLANE_ENABLE_GE:
value = 1;
break;
case CELL_GCM_USER_CLIP_PLANE_ENABLE_LT:
value = -1;
break;
}
__glcheck m_program->uniforms[location] = value;
}
__glcheck enable(value, GL_CLIP_DISTANCE0 + index);
};
set_clip_plane_control(0, clip_plane_0);
set_clip_plane_control(1, clip_plane_1);
set_clip_plane_control(2, clip_plane_2);
set_clip_plane_control(3, clip_plane_3);
set_clip_plane_control(4, clip_plane_4);
set_clip_plane_control(5, clip_plane_5);
__glcheck enable(rsx::method_registers[NV4097_SET_POLY_OFFSET_FILL_ENABLE], GL_POLYGON_OFFSET_FILL); __glcheck enable(rsx::method_registers[NV4097_SET_POLY_OFFSET_FILL_ENABLE], GL_POLYGON_OFFSET_FILL);