PICA: Scissor fixes and cleanups
This commit is contained in:
parent
f9be06b15f
commit
f0b9bc14b6
5 changed files with 39 additions and 45 deletions
|
@ -357,8 +357,8 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) {
|
|||
case PICA_REG_INDEX(scissor_test.mode):
|
||||
shader_dirty = true;
|
||||
break;
|
||||
case PICA_REG_INDEX(scissor_test.right):
|
||||
case PICA_REG_INDEX(scissor_test.left_minus_1):
|
||||
case PICA_REG_INDEX(scissor_test.x1): // and y1
|
||||
case PICA_REG_INDEX(scissor_test.x2): // and y2
|
||||
SyncScissorTest();
|
||||
break;
|
||||
|
||||
|
@ -1179,15 +1179,15 @@ void RasterizerOpenGL::SyncDepthTest() {
|
|||
void RasterizerOpenGL::SyncScissorTest() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
|
||||
if (uniform_block_data.data.scissor_right != regs.scissor_test.right ||
|
||||
uniform_block_data.data.scissor_bottom != regs.scissor_test.bottom ||
|
||||
uniform_block_data.data.scissor_left != regs.scissor_test.GetLeft() ||
|
||||
uniform_block_data.data.scissor_top != regs.scissor_test.GetTop()) {
|
||||
if (uniform_block_data.data.scissor_x1 != regs.scissor_test.x1 ||
|
||||
uniform_block_data.data.scissor_y1 != regs.scissor_test.y1 ||
|
||||
uniform_block_data.data.scissor_x2 != regs.scissor_test.x2 ||
|
||||
uniform_block_data.data.scissor_y2 != regs.scissor_test.y2) {
|
||||
|
||||
uniform_block_data.data.scissor_right = regs.scissor_test.right;
|
||||
uniform_block_data.data.scissor_bottom = regs.scissor_test.bottom;
|
||||
uniform_block_data.data.scissor_left = regs.scissor_test.GetLeft();
|
||||
uniform_block_data.data.scissor_top = regs.scissor_test.GetTop();
|
||||
uniform_block_data.data.scissor_x1 = regs.scissor_test.x1;
|
||||
uniform_block_data.data.scissor_y1 = regs.scissor_test.y1;
|
||||
uniform_block_data.data.scissor_x2 = regs.scissor_test.x2;
|
||||
uniform_block_data.data.scissor_y2 = regs.scissor_test.y2;
|
||||
uniform_block_data.dirty = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,10 +331,10 @@ private:
|
|||
GLint alphatest_ref;
|
||||
GLfloat depth_scale;
|
||||
GLfloat depth_offset;
|
||||
GLint scissor_right;
|
||||
GLint scissor_bottom;
|
||||
GLint scissor_left;
|
||||
GLint scissor_top;
|
||||
GLint scissor_x1;
|
||||
GLint scissor_y1;
|
||||
GLint scissor_x2;
|
||||
GLint scissor_y2;
|
||||
alignas(16) GLvec3 fog_color;
|
||||
alignas(16) GLvec3 lighting_global_ambient;
|
||||
LightSrc light_src[8];
|
||||
|
|
|
@ -557,10 +557,10 @@ layout (std140) uniform shader_data {
|
|||
int alphatest_ref;
|
||||
float depth_scale;
|
||||
float depth_offset;
|
||||
int scissor_right;
|
||||
int scissor_bottom;
|
||||
int scissor_left;
|
||||
int scissor_top;
|
||||
int scissor_x1;
|
||||
int scissor_y1;
|
||||
int scissor_x2;
|
||||
int scissor_y2;
|
||||
vec3 fog_color;
|
||||
vec3 lighting_global_ambient;
|
||||
LightSrc light_src[NUM_LIGHTS];
|
||||
|
@ -589,13 +589,14 @@ vec4 secondary_fragment_color = vec4(0.0);
|
|||
}
|
||||
|
||||
// Append the scissor test
|
||||
if (state.scissor_test_mode == Regs::ScissorMode::Include || state.scissor_test_mode == Regs::ScissorMode::Exclude) {
|
||||
out += "if (scissor_left <= scissor_right || scissor_top <= scissor_bottom) discard;\n";
|
||||
if (state.scissor_test_mode != Regs::ScissorMode::Disabled) {
|
||||
out += "if (";
|
||||
// Negate the condition if we have to keep only the pixels outside the scissor box
|
||||
if (state.scissor_test_mode == Regs::ScissorMode::Include)
|
||||
out += "!";
|
||||
out += "(gl_FragCoord.x >= scissor_right && gl_FragCoord.x <= scissor_left && gl_FragCoord.y >= scissor_bottom && gl_FragCoord.y <= scissor_top)) discard;\n";
|
||||
// x2,y2 have +1 added to cover the entire pixel area
|
||||
out += "(gl_FragCoord.x >= scissor_x1 && gl_FragCoord.x < scissor_x2 + 1 && "
|
||||
"gl_FragCoord.y >= scissor_y1 && gl_FragCoord.y < scissor_y2 + 1)) discard;\n";
|
||||
}
|
||||
|
||||
out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue