mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-05-12 15:49:39 -06:00
Optimize shader state changes: avoid redundant SetupBatch calls by tracking VS config hash
This commit is contained in:
parent
ed94588449
commit
fa1389915f
@ -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<AttributeBuffer, VERTEX_CACHE_SIZE> 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;
|
||||
|
||||
@ -306,6 +306,7 @@ private:
|
||||
PrimitiveAssembler primitive_assembler;
|
||||
CommandList cmd_list;
|
||||
std::unique_ptr<ShaderEngine> 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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user