diff --git a/include/pd/drivers/gfx.hpp b/include/pd/drivers/gfx.hpp index c7a2082..51fe2c4 100755 --- a/include/pd/drivers/gfx.hpp +++ b/include/pd/drivers/gfx.hpp @@ -56,13 +56,13 @@ class PD_API GfxDriver : public DriverInterface { virtual void PutIndex(size_t loc, u16 idx, PD::ptr accessor) = 0; virtual const Li::Vertex& GetVertex(size_t loc) const = 0; virtual const u16& GetIndex(size_t loc) const = 0; + virtual void ResetPools() = 0; protected: virtual void SysDeinit() {} virtual void SysInit() {} virtual void SysReset() {} virtual void Submit(size_t count, size_t start) {} - virtual void ResetPools() = 0; void RegisterTexture(const Li::Texture& tex); void UnregisterTexture(const Li::Texture& tex); @@ -170,15 +170,16 @@ class GfxDriverBase : public GfxDriver { const u16& GetIndex(size_t loc) const override { return pIdxPool[loc]; } + void ResetPools() override { + pVtxPool.NoReset(); + pIdxPool.NoReset(); + } + protected: u16* GetIndexBufPtr(size_t start) { return &pIdxPool[start]; } Li::Vertex* GetVertexBufPtr(size_t start) { return &pVtxPool[start]; } size_t GetVertexPoolSize() const { return pVtxPool.size(); } size_t GetIndexPoolSize() const { return pIdxPool.size(); } - void ResetPools() override { - pVtxPool.NoReset(); - pIdxPool.NoReset(); - } private: VtxPool pVtxPool; @@ -259,6 +260,8 @@ class PD_API Gfx { static const u16& GetIndex(size_t loc) { return driver->GetIndex(loc); } + static void NewFrame() { driver->ResetPools(); } + private: static std::unique_ptr driver; }; diff --git a/source/drivers/gfx.cpp b/source/drivers/gfx.cpp index ea1d98d..80e0175 100644 --- a/source/drivers/gfx.cpp +++ b/source/drivers/gfx.cpp @@ -33,7 +33,6 @@ PD_API void GfxDriver::Reset() { CountDrawcalls = pCountDrawcalls; pCountCommands = 0; pCountDrawcalls = 0; - ResetPools(); SysReset(); } diff --git a/tests/gfx/source/main.cpp b/tests/gfx/source/main.cpp index 980f9ab..79fba90 100644 --- a/tests/gfx/source/main.cpp +++ b/tests/gfx/source/main.cpp @@ -199,7 +199,7 @@ int main(int argc, char** argv) { RightStick.pColor = "#00ffff"; while (pOs->Mainloop()) { PD::Hid::Update(); - PD::Gfx::Reset(); // needs to be on top now + PD::Gfx::NewFrame(); pOs->ClearViewPort(); app.Update(pOs->GetViewport(), pList); pList.SetFontscale(0.7); @@ -263,6 +263,7 @@ int main(int argc, char** argv) { pList.PathAdd(PD::fvec2(1000, 360)); pList.PathStroke("#ff00ff", 10, LiDrawFlags_AA); + PD::Gfx::Reset(); // needs to be on top now PD::Gfx::Draw(pList); pList.Clear(); pOs->SwapBuffers();