summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-12-29 02:31:00 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-02-28 21:56:42 +0100
commitba6f390448987c01ae0e4b7ffe98b77bbd47c6d9 (patch)
tree7361f386e668982a6d279d032d2b475291e4e398 /src
parentgl_state_tracker: Implement dirty flags for viewports (diff)
downloadyuzu-ba6f390448987c01ae0e4b7ffe98b77bbd47c6d9.tar
yuzu-ba6f390448987c01ae0e4b7ffe98b77bbd47c6d9.tar.gz
yuzu-ba6f390448987c01ae0e4b7ffe98b77bbd47c6d9.tar.bz2
yuzu-ba6f390448987c01ae0e4b7ffe98b77bbd47c6d9.tar.lz
yuzu-ba6f390448987c01ae0e4b7ffe98b77bbd47c6d9.tar.xz
yuzu-ba6f390448987c01ae0e4b7ffe98b77bbd47c6d9.tar.zst
yuzu-ba6f390448987c01ae0e4b7ffe98b77bbd47c6d9.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp24
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.cpp9
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.h33
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp1
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp1
5 files changed, 58 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 2427b8c07..2ec4c9f55 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -1102,12 +1102,28 @@ void RasterizerOpenGL::SyncLogicOpState() {
}
void RasterizerOpenGL::SyncScissorTest() {
- const auto& regs = system.GPU().Maxwell3D().regs;
+ auto& gpu = system.GPU().Maxwell3D();
+ auto& flags = gpu.dirty.flags;
+ if (!flags[Dirty::Scissors]) {
+ return;
+ }
+ flags[Dirty::Scissors] = false;
+
+ const auto& regs = gpu.regs;
for (std::size_t index = 0; index < Maxwell::NumViewports; ++index) {
+ if (!flags[Dirty::Scissor0 + index]) {
+ continue;
+ }
+ flags[Dirty::Scissor0 + index] = false;
+
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);
+ if (src.enable) {
+ glEnablei(GL_SCISSOR_TEST, 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);
+ } else {
+ glDisablei(GL_SCISSOR_TEST, static_cast<GLuint>(index));
+ }
}
}
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp
index 6293f6102..9e1db59ae 100644
--- a/src/video_core/renderer_opengl/gl_state_tracker.cpp
+++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp
@@ -77,6 +77,14 @@ void SetupDirtyViewports(Tables& tables) {
tables[1][OFF(viewport_transform_enabled)] = Viewports;
}
+void SetupDirtyScissors(Tables& tables) {
+ for (std::size_t i = 0; i < Regs::NumViewports; ++i) {
+ const std::size_t offset = OFF(scissor_test) + i * NUM(scissor_test[0]);
+ FillBlock(tables[0], offset, NUM(scissor_test[0]), Scissor0 + i);
+ }
+ FillBlock(tables[1], OFF(scissor_test), NUM(scissor_test), Scissors);
+}
+
} // Anonymous namespace
StateTracker::StateTracker(Core::System& system) : system{system} {}
@@ -97,6 +105,7 @@ void StateTracker::Initialize() {
auto& tables = dirty.tables;
SetupDirtyRenderTargets(tables);
SetupDirtyViewports(tables);
+ SetupDirtyScissors(tables);
}
} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.h b/src/video_core/renderer_opengl/gl_state_tracker.h
index 93c64a44a..5153dc5d1 100644
--- a/src/video_core/renderer_opengl/gl_state_tracker.h
+++ b/src/video_core/renderer_opengl/gl_state_tracker.h
@@ -15,15 +15,30 @@ class System;
namespace OpenGL {
namespace Dirty {
+
enum : u8 {
First = VideoCommon::Dirty::LastCommonEntry,
VertexFormats,
+
VertexBuffers,
+ VertexBuffer0,
+ VertexBuffer31 = VertexBuffer0 + 31,
+
VertexInstances,
- Shaders,
- Viewports,
+ VertexInstance0,
+ VertexInstance31 = VertexInstance0 + 31,
+
ViewportTransform,
+ Viewports,
+ Viewport0,
+ Viewport15 = Viewport0 + 15,
+
+ Scissors,
+ Scissor0,
+ Scissor15 = Scissor0 + 15,
+
+ Shaders,
CullTestEnable,
FrontFace,
CullFace,
@@ -34,11 +49,11 @@ enum : u8 {
BlendState,
PolygonOffset,
- Viewport0,
- VertexBuffer0 = Viewport0 + 16,
- VertexInstance0 = VertexBuffer0 + 32,
+ Last
};
-}
+static_assert(Last <= 0xff);
+
+} // namespace Dirty
class StateTracker {
public:
@@ -52,6 +67,12 @@ public:
flags[OpenGL::Dirty::Viewport0] = true;
}
+ void NotifyScissor0() {
+ auto& flags = system.GPU().Maxwell3D().dirty.flags;
+ flags[OpenGL::Dirty::Scissors] = true;
+ flags[OpenGL::Dirty::Scissor0] = true;
+ }
+
void NotifyFramebuffer() {
auto& flags = system.GPU().Maxwell3D().dirty.flags;
flags[VideoCommon::Dirty::RenderTargets] = true;
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 1cadcf287..a02326b9f 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -519,6 +519,7 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
UNIMPLEMENTED_IF(dst_params.target == SurfaceTarget::Texture3D);
// TODO: Signal state tracker about these changes
+ state_tracker.NotifyScissor0();
state_tracker.NotifyFramebuffer();
if (dst_params.srgb_conversion) {
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 73d2d9027..f2b07ac81 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -577,6 +577,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
// TODO: Signal state tracker about these changes
state_tracker.NotifyViewport0();
+ state_tracker.NotifyScissor0();
state_tracker.NotifyFramebuffer();
program_manager.UseVertexShader(vertex_program.handle);