diff --git a/src/video_core/pica/pica_core.cpp b/src/video_core/pica/pica_core.cpp index d12a986c1..20b737cf6 100644 --- a/src/video_core/pica/pica_core.cpp +++ b/src/video_core/pica/pica_core.cpp @@ -487,8 +487,12 @@ void PicaCore::SubmitImmediate(u32 value) { } void PicaCore::DrawImmediate() { - // Compile the vertex shader. - shader_engine->SetupBatch(vs_setup, regs.internal.vs.main_offset); + // Compute current VS config hash + u64 vs_hash = vs_setup.GetProgramCodeHash() ^ vs_setup.GetSwizzleDataHash(); + if (vs_hash != last_vs_hash) { + shader_engine->SetupBatch(vs_setup, regs.internal.vs.main_offset); + last_vs_hash = vs_hash; + } // Track vertex in the debug recorder. if (debug_context) { @@ -590,6 +594,13 @@ void PicaCore::LoadVertices(bool is_indexed) { std::array vertex_cache; u32 vertex_cache_pos = 0; + // Compute current VS config hash + u64 vs_hash = vs_setup.GetProgramCodeHash() ^ vs_setup.GetSwizzleDataHash(); + if (vs_hash != last_vs_hash) { + shader_engine->SetupBatch(vs_setup, regs.internal.vs.main_offset); + last_vs_hash = vs_hash; + } + // Compile the vertex shader for this batch. ShaderUnit shader_unit; AttributeBuffer vs_output; diff --git a/src/video_core/pica/pica_core.h b/src/video_core/pica/pica_core.h index 8cdcb493d..07e398e9a 100644 --- a/src/video_core/pica/pica_core.h +++ b/src/video_core/pica/pica_core.h @@ -306,6 +306,7 @@ private: PrimitiveAssembler primitive_assembler; CommandList cmd_list; std::unique_ptr shader_engine; + u64 last_vs_hash = 0xDEADBEEFDEADBEEF; // Track last used VS hash }; #define GPU_REG_INDEX(field_name) (offsetof(Pica::PicaCore::Regs, field_name) / sizeof(u32))