mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 00:33:01 +00:00
gl: Handle clip plane switching using API calls and the state tracker
This commit is contained in:
parent
903d847058
commit
bd9c876e36
@ -289,6 +289,9 @@ void GLGSRender::update_draw_state()
|
||||
break;
|
||||
}
|
||||
|
||||
// Clip planes
|
||||
gl_state.clip_planes((current_vertex_program.output_mask >> CELL_GCM_ATTRIB_OUTPUT_UC0) & 0x3F);
|
||||
|
||||
// Sample control
|
||||
// TODO: MinSampleShading
|
||||
//gl_state.enable(rsx::method_registers.msaa_enabled(), GL_MULTISAMPLE);
|
||||
|
@ -320,14 +320,6 @@ void GLGSRender::on_init_thread()
|
||||
query.result = 0;
|
||||
}
|
||||
|
||||
//Clip planes are shader controlled; enable all planes driver-side
|
||||
glEnable(GL_CLIP_DISTANCE0 + 0);
|
||||
glEnable(GL_CLIP_DISTANCE0 + 1);
|
||||
glEnable(GL_CLIP_DISTANCE0 + 2);
|
||||
glEnable(GL_CLIP_DISTANCE0 + 3);
|
||||
glEnable(GL_CLIP_DISTANCE0 + 4);
|
||||
glEnable(GL_CLIP_DISTANCE0 + 5);
|
||||
|
||||
m_ui_renderer.create();
|
||||
m_video_output_pass.create();
|
||||
|
||||
|
@ -133,6 +133,7 @@ namespace gl
|
||||
|
||||
cmd->disable(GL_CULL_FACE);
|
||||
cmd->disable(GL_SCISSOR_TEST);
|
||||
cmd->clip_planes(GL_NONE);
|
||||
|
||||
if (enable_depth_writes)
|
||||
{
|
||||
|
@ -182,6 +182,7 @@ namespace gl
|
||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &old_vao);
|
||||
|
||||
load_program(cmd, scale_x, scale_y, shader_offsets.data(), counts.size(), color);
|
||||
cmd->clip_planes(GL_NONE);
|
||||
|
||||
m_vao.bind();
|
||||
|
||||
|
@ -88,13 +88,13 @@ static const vertex_reg_info reg_table[] =
|
||||
//Fog output shares a data source register with clip planes 0-2 so only declare when specified
|
||||
{ "fog_c", true, "dst_reg5", ".xxxx", true, "", "", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_FOG },
|
||||
//Warning: Always define all 3 clip plane groups together to avoid flickering with openGL
|
||||
{ "gl_ClipDistance[0]", false, "dst_reg5", ".y * user_clip_factor[0].x", false, "user_clip_enabled[0].x > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC0 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC1 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC2 },
|
||||
{ "gl_ClipDistance[1]", false, "dst_reg5", ".z * user_clip_factor[0].y", false, "user_clip_enabled[0].y > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC0 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC1 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC2 },
|
||||
{ "gl_ClipDistance[2]", false, "dst_reg5", ".w * user_clip_factor[0].z", false, "user_clip_enabled[0].z > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC0 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC1 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC2 },
|
||||
{ "gl_ClipDistance[0]", false, "dst_reg5", ".y * user_clip_factor[0].x", false, "user_clip_enabled[0].x > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC0 },
|
||||
{ "gl_ClipDistance[1]", false, "dst_reg5", ".z * user_clip_factor[0].y", false, "user_clip_enabled[0].y > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC1 },
|
||||
{ "gl_ClipDistance[2]", false, "dst_reg5", ".w * user_clip_factor[0].z", false, "user_clip_enabled[0].z > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC2 },
|
||||
{ "gl_PointSize", false, "dst_reg6", ".x", false, "", "", "", true, CELL_GCM_ATTRIB_OUTPUT_POINTSIZE },
|
||||
{ "gl_ClipDistance[3]", false, "dst_reg6", ".y * user_clip_factor[0].w", false, "user_clip_enabled[0].w > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC3 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC4 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC5 },
|
||||
{ "gl_ClipDistance[4]", false, "dst_reg6", ".z * user_clip_factor[1].x", false, "user_clip_enabled[1].x > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC3 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC4 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC5 },
|
||||
{ "gl_ClipDistance[5]", false, "dst_reg6", ".w * user_clip_factor[1].y", false, "user_clip_enabled[1].y > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC3 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC4 | CELL_GCM_ATTRIB_OUTPUT_MASK_UC5 },
|
||||
{ "gl_ClipDistance[3]", false, "dst_reg6", ".y * user_clip_factor[0].w", false, "user_clip_enabled[0].w > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC3 },
|
||||
{ "gl_ClipDistance[4]", false, "dst_reg6", ".z * user_clip_factor[1].x", false, "user_clip_enabled[1].x > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC4 },
|
||||
{ "gl_ClipDistance[5]", false, "dst_reg6", ".w * user_clip_factor[1].y", false, "user_clip_enabled[1].y > 0", "0.5", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_UC5 },
|
||||
{ "tc0", true, "dst_reg7", "", false, "", "", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_TEX0 },
|
||||
{ "tc1", true, "dst_reg8", "", false, "", "", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_TEX1 },
|
||||
{ "tc2", true, "dst_reg9", "", false, "", "", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_TEX2 },
|
||||
|
@ -10,6 +10,7 @@ namespace gl
|
||||
class driver_state
|
||||
{
|
||||
const u32 DEPTH_BOUNDS = 0xFFFF0001;
|
||||
const u32 CLIP_PLANES = 0xFFFF0002;
|
||||
const u32 DEPTH_RANGE = 0xFFFF0004;
|
||||
const u32 STENCIL_FRONT_FUNC = 0xFFFF0005;
|
||||
const u32 STENCIL_BACK_FUNC = 0xFFFF0006;
|
||||
@ -308,6 +309,24 @@ namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
void clip_planes(GLuint mask)
|
||||
{
|
||||
if (!test_and_set_property(CLIP_PLANES, mask))
|
||||
{
|
||||
for (u32 i = 0; i < 6; ++i)
|
||||
{
|
||||
if (mask & (1 << i))
|
||||
{
|
||||
glEnable(GL_CLIP_DISTANCE0 + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_CLIP_DISTANCE0 + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void use_program(GLuint program)
|
||||
{
|
||||
if (current_program == program)
|
||||
|
Loading…
x
Reference in New Issue
Block a user