mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-21 00:13:22 +02:00
gl_shader_cache: Use dirty flags for shaders
This commit is contained in:
parent
59c665b28e
commit
0ab17ab406
@ -135,6 +135,14 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
|
|||||||
|
|
||||||
if (regs.reg_array[method_call.method] != method_call.argument) {
|
if (regs.reg_array[method_call.method] != method_call.argument) {
|
||||||
regs.reg_array[method_call.method] = method_call.argument;
|
regs.reg_array[method_call.method] = method_call.argument;
|
||||||
|
// Shader
|
||||||
|
constexpr u32 shader_registers_count =
|
||||||
|
sizeof(regs.shader_config[0]) * Regs::MaxShaderProgram / sizeof(u32);
|
||||||
|
if (method_call.method >= MAXWELL3D_REG_INDEX(shader_config[0]) &&
|
||||||
|
method_call.method < MAXWELL3D_REG_INDEX(shader_config[0]) + shader_registers_count) {
|
||||||
|
dirty_flags.shaders = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Vertex format
|
// Vertex format
|
||||||
if (method_call.method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) &&
|
if (method_call.method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) &&
|
||||||
method_call.method <
|
method_call.method <
|
||||||
|
@ -1089,10 +1089,13 @@ public:
|
|||||||
MemoryManager& memory_manager;
|
MemoryManager& memory_manager;
|
||||||
|
|
||||||
struct DirtyFlags {
|
struct DirtyFlags {
|
||||||
|
bool shaders = true;
|
||||||
|
|
||||||
bool vertex_attrib_format = true;
|
bool vertex_attrib_format = true;
|
||||||
u32 vertex_array = 0xFFFFFFFF;
|
u32 vertex_array = 0xFFFFFFFF;
|
||||||
|
|
||||||
void OnMemoryWrite() {
|
void OnMemoryWrite() {
|
||||||
|
shaders = true;
|
||||||
vertex_array = 0xFFFFFFFF;
|
vertex_array = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -293,7 +293,7 @@ DrawParameters RasterizerOpenGL::SetupDraw() {
|
|||||||
|
|
||||||
void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_Shader);
|
MICROPROFILE_SCOPE(OpenGL_Shader);
|
||||||
const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
|
auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
|
||||||
|
|
||||||
// Next available bindpoints to use when uploading the const buffers and textures to the GLSL
|
// Next available bindpoints to use when uploading the const buffers and textures to the GLSL
|
||||||
// shaders. The constbuffer bindpoint starts after the shader stage configuration bind points.
|
// shaders. The constbuffer bindpoint starts after the shader stage configuration bind points.
|
||||||
@ -376,6 +376,8 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SyncClipEnabled(clip_distances);
|
SyncClipEnabled(clip_distances);
|
||||||
|
|
||||||
|
gpu.dirty_flags.shaders = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey,
|
void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey,
|
||||||
|
@ -188,6 +188,10 @@ void CachedShader::CalculateProperties() {
|
|||||||
ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer) : RasterizerCache{rasterizer} {}
|
ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer) : RasterizerCache{rasterizer} {}
|
||||||
|
|
||||||
Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
|
Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
|
||||||
|
if (!Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.shaders) {
|
||||||
|
return last_shaders[static_cast<u32>(program)];
|
||||||
|
}
|
||||||
|
|
||||||
const VAddr program_addr{GetShaderAddress(program)};
|
const VAddr program_addr{GetShaderAddress(program)};
|
||||||
|
|
||||||
// Look up shader in the cache based on address
|
// Look up shader in the cache based on address
|
||||||
@ -199,7 +203,7 @@ Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
|
|||||||
Register(shader);
|
Register(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
return shader;
|
return last_shaders[static_cast<u32>(program)] = shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -115,6 +116,9 @@ public:
|
|||||||
|
|
||||||
/// Gets the current specified shader stage program
|
/// Gets the current specified shader stage program
|
||||||
Shader GetStageProgram(Maxwell::ShaderProgram program);
|
Shader GetStageProgram(Maxwell::ShaderProgram program);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::array<Shader, Maxwell::MaxShaderProgram> last_shaders;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
Loading…
Reference in New Issue
Block a user