Detect depth mode by viewport
This commit is contained in:
@@ -566,10 +566,8 @@ void RasterizerOpenGL::SyncViewport() {
|
||||
if (regs.screen_y_control.y_negate != 0) {
|
||||
flip_y = !flip_y;
|
||||
}
|
||||
const bool is_zero_to_one = regs.depth_mode == Maxwell::DepthMode::ZeroToOne;
|
||||
const GLenum origin = flip_y ? GL_UPPER_LEFT : GL_LOWER_LEFT;
|
||||
const GLenum depth = is_zero_to_one ? GL_ZERO_TO_ONE : GL_NEGATIVE_ONE_TO_ONE;
|
||||
state_tracker.ClipControl(origin, depth);
|
||||
state_tracker.SetOrigin(origin);
|
||||
state_tracker.SetYNegate(regs.screen_y_control.y_negate != 0);
|
||||
}
|
||||
|
||||
@@ -593,6 +591,15 @@ void RasterizerOpenGL::SyncViewport() {
|
||||
const GLdouble reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne;
|
||||
const GLdouble near_depth = src.translate_z - src.scale_z * reduce_z;
|
||||
const GLdouble far_depth = src.translate_z + src.scale_z;
|
||||
if (i == 0) {
|
||||
const auto& viewports = regs.viewports[i];
|
||||
const GLenum depth = viewports.depth_range_near != src.translate_z &&
|
||||
viewports.depth_range_far != src.translate_z
|
||||
? GL_NEGATIVE_ONE_TO_ONE
|
||||
: GL_ZERO_TO_ONE;
|
||||
state_tracker.SetDepthMode(depth);
|
||||
}
|
||||
|
||||
if (device.HasDepthBufferFloat()) {
|
||||
glDepthRangeIndexeddNV(static_cast<GLuint>(i), near_depth, far_depth);
|
||||
} else {
|
||||
|
||||
@@ -112,6 +112,22 @@ public:
|
||||
glClipControl(origin, depth);
|
||||
}
|
||||
|
||||
void SetOrigin(GLenum new_origin) {
|
||||
if (new_origin == origin) {
|
||||
return;
|
||||
}
|
||||
origin = new_origin;
|
||||
glClipControl(origin, depth);
|
||||
}
|
||||
|
||||
void SetDepthMode(GLenum new_depth) {
|
||||
if (new_depth == depth) {
|
||||
return;
|
||||
}
|
||||
depth = new_depth;
|
||||
glClipControl(origin, depth);
|
||||
}
|
||||
|
||||
void SetYNegate(bool new_y_negate) {
|
||||
if (new_y_negate == y_negate) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user