summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-12-26 05:28:17 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-02-28 21:00:23 +0100
commit7c16b3551b5294d86a7dc8e0721c081bd88547ed (patch)
tree481af352889cd5c22166c215d755f93a297869ef
parentgl_state: Remove color mask tracking (diff)
downloadyuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar.gz
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar.bz2
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar.lz
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar.xz
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.tar.zst
yuzu-7c16b3551b5294d86a7dc8e0721c081bd88547ed.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp32
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h2
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp35
-rw-r--r--src/video_core/renderer_opengl/gl_state.h10
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp1
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp1
6 files changed, 12 insertions, 69 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index d0c811929..3ccedcf55 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -467,12 +467,10 @@ void RasterizerOpenGL::Clear() {
SyncViewport(clear_state);
SyncRasterizeEnable(clear_state);
if (regs.clear_flags.scissor) {
- SyncScissorTest(clear_state);
+ SyncScissorTest();
}
- if (regs.clear_flags.viewport) {
- clear_state.EmulateViewportWithScissor();
- }
+ UNIMPLEMENTED_IF(regs.clear_flags.viewport);
clear_state.Apply();
@@ -508,7 +506,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
SyncLogicOpState();
SyncCullMode();
SyncPrimitiveRestart();
- SyncScissorTest(state);
+ SyncScissorTest();
SyncTransformFeedback();
SyncPointState();
SyncPolygonOffset();
@@ -1140,25 +1138,13 @@ void RasterizerOpenGL::SyncLogicOpState() {
}
}
-void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
+void RasterizerOpenGL::SyncScissorTest() {
const auto& regs = system.GPU().Maxwell3D().regs;
- const bool geometry_shaders_enabled =
- regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
- const std::size_t viewport_count =
- geometry_shaders_enabled ? Tegra::Engines::Maxwell3D::Regs::NumViewports : 1;
- for (std::size_t i = 0; i < viewport_count; i++) {
- const auto& src = regs.scissor_test[i];
- auto& dst = current_state.viewports[i].scissor;
- dst.enabled = (src.enable != 0);
- if (dst.enabled == 0) {
- return;
- }
- const u32 width = src.max_x - src.min_x;
- const u32 height = src.max_y - src.min_y;
- dst.x = src.min_x;
- dst.y = src.min_y;
- dst.width = width;
- dst.height = height;
+ for (std::size_t index = 0; index < Maxwell::NumViewports; ++index) {
+ const auto& src = regs.scissor_test[index];
+ oglEnablei(GL_SCISSOR_TEST, src.enable, static_cast<GLuint>(index));
+ glScissorIndexed(static_cast<GLuint>(index), src.min_x, src.min_y, src.max_x - src.min_x,
+ src.max_y - src.min_y);
}
}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 91179323d..0450657a7 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -167,7 +167,7 @@ private:
void SyncMultiSampleState();
/// Syncs the scissor test state to match the guest state
- void SyncScissorTest(OpenGLState& current_state);
+ void SyncScissorTest();
/// Syncs the transform feedback state to match the guest state
void SyncTransformFeedback();
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index bcacc5590..dcea16fd3 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -171,19 +171,6 @@ void OpenGLState::ApplyViewport() {
current.depth_range_far = updated.depth_range_far;
glDepthRangeIndexed(i, updated.depth_range_near, updated.depth_range_far);
}
-
- Enable(GL_SCISSOR_TEST, i, current.scissor.enabled, updated.scissor.enabled);
-
- if (current.scissor.x != updated.scissor.x || current.scissor.y != updated.scissor.y ||
- current.scissor.width != updated.scissor.width ||
- current.scissor.height != updated.scissor.height) {
- current.scissor.x = updated.scissor.x;
- current.scissor.y = updated.scissor.y;
- current.scissor.width = updated.scissor.width;
- current.scissor.height = updated.scissor.height;
- glScissorIndexed(i, updated.scissor.x, updated.scissor.y, updated.scissor.width,
- updated.scissor.height);
- }
}
}
@@ -306,28 +293,6 @@ void OpenGLState::Apply() {
ApplyRenderBuffer();
}
-void OpenGLState::EmulateViewportWithScissor() {
- auto& current = viewports[0];
- if (current.scissor.enabled) {
- const GLint left = std::max(current.x, current.scissor.x);
- const GLint right =
- std::max(current.x + current.width, current.scissor.x + current.scissor.width);
- const GLint bottom = std::max(current.y, current.scissor.y);
- const GLint top =
- std::max(current.y + current.height, current.scissor.y + current.scissor.height);
- current.scissor.x = std::max(left, 0);
- current.scissor.y = std::max(bottom, 0);
- current.scissor.width = std::max(right - left, 0);
- current.scissor.height = std::max(top - bottom, 0);
- } else {
- current.scissor.enabled = true;
- current.scissor.x = current.x;
- current.scissor.y = current.y;
- current.scissor.width = current.width;
- current.scissor.height = current.height;
- }
-}
-
OpenGLState& OpenGLState::UnbindTexture(GLuint handle) {
for (auto& texture : textures) {
if (texture == handle) {
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index ccc302014..44eb35dd5 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -63,13 +63,6 @@ public:
GLint height = 0;
GLfloat depth_range_near = 0.0f; // GL_DEPTH_RANGE
GLfloat depth_range_far = 1.0f; // GL_DEPTH_RANGE
- struct {
- bool enabled = false; // GL_SCISSOR_TEST
- GLint x = 0;
- GLint y = 0;
- GLsizei width = 0;
- GLsizei height = 0;
- } scissor;
};
std::array<Viewport, Tegra::Engines::Maxwell3D::Regs::NumViewports> viewports;
@@ -117,9 +110,6 @@ public:
OpenGLState& ResetFramebuffer(GLuint handle);
OpenGLState& ResetRenderbuffer(GLuint handle);
- /// Viewport does not affects glClearBuffer so emulate viewport using scissor test
- void EmulateViewportWithScissor();
-
private:
static OpenGLState cur_state;
};
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 0bdbb70a4..f6cb02c53 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -536,6 +536,7 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
} else {
glDisable(GL_FRAMEBUFFER_SRGB);
}
+ glDisablei(GL_SCISSOR_TEST, 0);
u32 buffers{};
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 6dbf727ee..0d5ef9ef6 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -568,6 +568,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_POLYGON_OFFSET_FILL);
+ glDisablei(GL_SCISSOR_TEST, 0);
glCullFace(GL_BACK);
glFrontFace(GL_CW);
glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);