From 3f38247c4e3843a082c242e1bcc8d5ef1abb3fd0 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 13 Jan 2024 00:35:10 -0600 Subject: [PATCH] VideoCommon: update the IndexGenerator logic to take a flag that avoids primitive restarts when the editor is in progress, GLTF files don't support primitive restarts and running without is easier than trying to calculate a new set of indices --- Source/Core/VideoCommon/IndexGenerator.cpp | 9 ++++++--- Source/Core/VideoCommon/IndexGenerator.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/IndexGenerator.cpp b/Source/Core/VideoCommon/IndexGenerator.cpp index 91db420950..dab228d23f 100644 --- a/Source/Core/VideoCommon/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/IndexGenerator.cpp @@ -262,11 +262,14 @@ u16* AddPoints_VSExpand(u16* index_ptr, u32 num_verts, u32 index) } } // Anonymous namespace -void IndexGenerator::Init() +void IndexGenerator::Init(bool editor_enabled) { using OpcodeDecoder::Primitive; - if (g_backend_info.bSupportsPrimitiveRestart) + // When editor is enabled, we can't take shortcuts + // as we might want to save meshes to a file + // Some formats don't allow primitive restart + if (g_backend_info.bSupportsPrimitiveRestart && !editor_enabled) { m_primitive_table[Primitive::GX_DRAW_QUADS] = AddQuads; m_primitive_table[Primitive::GX_DRAW_QUADS_2] = AddQuads_nonstandard; @@ -282,7 +285,7 @@ void IndexGenerator::Init() m_primitive_table[Primitive::GX_DRAW_TRIANGLE_STRIP] = AddStrip; m_primitive_table[Primitive::GX_DRAW_TRIANGLE_FAN] = AddFan; } - if (g_Config.UseVSForLinePointExpand()) + if (g_Config.UseVSForLinePointExpand() && !editor_enabled) { if (g_backend_info.bSupportsPrimitiveRestart) { diff --git a/Source/Core/VideoCommon/IndexGenerator.h b/Source/Core/VideoCommon/IndexGenerator.h index 4b1fb0f3c0..2768af512a 100644 --- a/Source/Core/VideoCommon/IndexGenerator.h +++ b/Source/Core/VideoCommon/IndexGenerator.h @@ -13,7 +13,7 @@ class IndexGenerator { public: - void Init(); + void Init(bool editor_enabled); void Start(u16* index_ptr); void AddIndices(OpcodeDecoder::Primitive primitive, u32 num_vertices);