summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2019-01-07 14:22:30 -0500
committerGravatar GitHub2019-01-07 14:22:30 -0500
commit23ebd4920e851a91bba0f2da70b7f63ee6b49dc3 (patch)
tree6b85aee5889aca55284c3b03b2ae9b72522532a1 /src
parentMerge pull request #1989 from lioncash/set (diff)
parentgl_shader_cache: Use dirty flags for shaders (diff)
downloadyuzu-23ebd4920e851a91bba0f2da70b7f63ee6b49dc3.tar.gz
yuzu-23ebd4920e851a91bba0f2da70b7f63ee6b49dc3.tar.xz
yuzu-23ebd4920e851a91bba0f2da70b7f63ee6b49dc3.zip
Merge pull request #1999 from ReinUsesLisp/dirty-shader
gl_shader_cache: Use dirty flags for shaders
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp8
-rw-r--r--src/video_core/engines/maxwell_3d.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.h4
5 files changed, 23 insertions, 2 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index b19b3a75a..0ed7bc5d8 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -135,6 +135,14 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
135 135
136 if (regs.reg_array[method_call.method] != method_call.argument) { 136 if (regs.reg_array[method_call.method] != method_call.argument) {
137 regs.reg_array[method_call.method] = method_call.argument; 137 regs.reg_array[method_call.method] = method_call.argument;
138 // Shader
139 constexpr u32 shader_registers_count =
140 sizeof(regs.shader_config[0]) * Regs::MaxShaderProgram / sizeof(u32);
141 if (method_call.method >= MAXWELL3D_REG_INDEX(shader_config[0]) &&
142 method_call.method < MAXWELL3D_REG_INDEX(shader_config[0]) + shader_registers_count) {
143 dirty_flags.shaders = true;
144 }
145
138 // Vertex format 146 // Vertex format
139 if (method_call.method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) && 147 if (method_call.method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) &&
140 method_call.method < 148 method_call.method <
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 0faff6fdf..d50e5a126 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1089,10 +1089,13 @@ public:
1089 MemoryManager& memory_manager; 1089 MemoryManager& memory_manager;
1090 1090
1091 struct DirtyFlags { 1091 struct DirtyFlags {
1092 bool shaders = true;
1093
1092 bool vertex_attrib_format = true; 1094 bool vertex_attrib_format = true;
1093 u32 vertex_array = 0xFFFFFFFF; 1095 u32 vertex_array = 0xFFFFFFFF;
1094 1096
1095 void OnMemoryWrite() { 1097 void OnMemoryWrite() {
1098 shaders = true;
1096 vertex_array = 0xFFFFFFFF; 1099 vertex_array = 0xFFFFFFFF;
1097 } 1100 }
1098 }; 1101 };
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 089daf96f..37f01d4f7 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -293,7 +293,7 @@ DrawParameters RasterizerOpenGL::SetupDraw() {
293 293
294void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { 294void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
295 MICROPROFILE_SCOPE(OpenGL_Shader); 295 MICROPROFILE_SCOPE(OpenGL_Shader);
296 const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 296 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
297 297
298 // Next available bindpoints to use when uploading the const buffers and textures to the GLSL 298 // Next available bindpoints to use when uploading the const buffers and textures to the GLSL
299 // shaders. The constbuffer bindpoint starts after the shader stage configuration bind points. 299 // shaders. The constbuffer bindpoint starts after the shader stage configuration bind points.
@@ -376,6 +376,8 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
376 } 376 }
377 377
378 SyncClipEnabled(clip_distances); 378 SyncClipEnabled(clip_distances);
379
380 gpu.dirty_flags.shaders = false;
379} 381}
380 382
381void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey, 383void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey,
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index aea6bf1af..c785fffa3 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -188,6 +188,10 @@ void CachedShader::CalculateProperties() {
188ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer) : RasterizerCache{rasterizer} {} 188ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer) : RasterizerCache{rasterizer} {}
189 189
190Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) { 190Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
191 if (!Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.shaders) {
192 return last_shaders[static_cast<u32>(program)];
193 }
194
191 const VAddr program_addr{GetShaderAddress(program)}; 195 const VAddr program_addr{GetShaderAddress(program)};
192 196
193 // Look up shader in the cache based on address 197 // Look up shader in the cache based on address
@@ -199,7 +203,7 @@ Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
199 Register(shader); 203 Register(shader);
200 } 204 }
201 205
202 return shader; 206 return last_shaders[static_cast<u32>(program)] = shader;
203} 207}
204 208
205} // namespace OpenGL 209} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h
index de3671acf..768747968 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.h
+++ b/src/video_core/renderer_opengl/gl_shader_cache.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <map> 8#include <map>
8#include <memory> 9#include <memory>
9 10
@@ -115,6 +116,9 @@ public:
115 116
116 /// Gets the current specified shader stage program 117 /// Gets the current specified shader stage program
117 Shader GetStageProgram(Maxwell::ShaderProgram program); 118 Shader GetStageProgram(Maxwell::ShaderProgram program);
119
120private:
121 std::array<Shader, Maxwell::MaxShaderProgram> last_shaders;
118}; 122};
119 123
120} // namespace OpenGL 124} // namespace OpenGL