gl_rasterizer: Skip VAO binding if the state is clean.

This commit is contained in:
Markus Wick 2018-11-06 19:15:44 +01:00
parent 0590dd2971
commit 359db6a673
3 changed files with 21 additions and 2 deletions

View File

@ -92,8 +92,16 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) {
debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr);
} }
u32 old = regs.reg_array[method];
regs.reg_array[method] = value; regs.reg_array[method] = value;
if (value != old) {
if (method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) &&
method < MAXWELL3D_REG_INDEX(vertex_attrib_format) + regs.vertex_attrib_format.size()) {
dirty_flags.vertex_attrib_format = true;
}
}
switch (method) { switch (method) {
case MAXWELL3D_REG_INDEX(macros.data): { case MAXWELL3D_REG_INDEX(macros.data): {
ProcessMacroUpload(value); ProcessMacroUpload(value);

View File

@ -983,6 +983,12 @@ public:
State state{}; State state{};
MemoryManager& memory_manager; MemoryManager& memory_manager;
struct DirtyFlags {
bool vertex_attrib_format = true;
};
DirtyFlags dirty_flags;
/// Reads a register value located at the input method address /// Reads a register value located at the input method address
u32 GetRegisterValue(u32 method) const; u32 GetRegisterValue(u32 method) const;

View File

@ -124,10 +124,15 @@ RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo
RasterizerOpenGL::~RasterizerOpenGL() {} RasterizerOpenGL::~RasterizerOpenGL() {}
void RasterizerOpenGL::SetupVertexFormat() { void RasterizerOpenGL::SetupVertexFormat() {
MICROPROFILE_SCOPE(OpenGL_VAO); auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
const auto& regs = gpu.regs; const auto& regs = gpu.regs;
if (!gpu.dirty_flags.vertex_attrib_format)
return;
gpu.dirty_flags.vertex_attrib_format = false;
MICROPROFILE_SCOPE(OpenGL_VAO);
auto [iter, is_cache_miss] = vertex_array_cache.try_emplace(regs.vertex_attrib_format); auto [iter, is_cache_miss] = vertex_array_cache.try_emplace(regs.vertex_attrib_format);
auto& VAO = iter->second; auto& VAO = iter->second;