reset pools on newframe
This commit is contained in:
@@ -56,13 +56,13 @@ class PD_API GfxDriver : public DriverInterface {
|
|||||||
virtual void PutIndex(size_t loc, u16 idx, PD::ptr accessor) = 0;
|
virtual void PutIndex(size_t loc, u16 idx, PD::ptr accessor) = 0;
|
||||||
virtual const Li::Vertex& GetVertex(size_t loc) const = 0;
|
virtual const Li::Vertex& GetVertex(size_t loc) const = 0;
|
||||||
virtual const u16& GetIndex(size_t loc) const = 0;
|
virtual const u16& GetIndex(size_t loc) const = 0;
|
||||||
|
virtual void ResetPools() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void SysDeinit() {}
|
virtual void SysDeinit() {}
|
||||||
virtual void SysInit() {}
|
virtual void SysInit() {}
|
||||||
virtual void SysReset() {}
|
virtual void SysReset() {}
|
||||||
virtual void Submit(size_t count, size_t start) {}
|
virtual void Submit(size_t count, size_t start) {}
|
||||||
virtual void ResetPools() = 0;
|
|
||||||
void RegisterTexture(const Li::Texture& tex);
|
void RegisterTexture(const Li::Texture& tex);
|
||||||
void UnregisterTexture(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]; }
|
const u16& GetIndex(size_t loc) const override { return pIdxPool[loc]; }
|
||||||
|
|
||||||
|
void ResetPools() override {
|
||||||
|
pVtxPool.NoReset();
|
||||||
|
pIdxPool.NoReset();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
u16* GetIndexBufPtr(size_t start) { return &pIdxPool[start]; }
|
u16* GetIndexBufPtr(size_t start) { return &pIdxPool[start]; }
|
||||||
Li::Vertex* GetVertexBufPtr(size_t start) { return &pVtxPool[start]; }
|
Li::Vertex* GetVertexBufPtr(size_t start) { return &pVtxPool[start]; }
|
||||||
size_t GetVertexPoolSize() const { return pVtxPool.size(); }
|
size_t GetVertexPoolSize() const { return pVtxPool.size(); }
|
||||||
size_t GetIndexPoolSize() const { return pIdxPool.size(); }
|
size_t GetIndexPoolSize() const { return pIdxPool.size(); }
|
||||||
void ResetPools() override {
|
|
||||||
pVtxPool.NoReset();
|
|
||||||
pIdxPool.NoReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VtxPool pVtxPool;
|
VtxPool pVtxPool;
|
||||||
@@ -259,6 +260,8 @@ class PD_API Gfx {
|
|||||||
|
|
||||||
static const u16& GetIndex(size_t loc) { return driver->GetIndex(loc); }
|
static const u16& GetIndex(size_t loc) { return driver->GetIndex(loc); }
|
||||||
|
|
||||||
|
static void NewFrame() { driver->ResetPools(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unique_ptr<GfxDriver> driver;
|
static std::unique_ptr<GfxDriver> driver;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ PD_API void GfxDriver::Reset() {
|
|||||||
CountDrawcalls = pCountDrawcalls;
|
CountDrawcalls = pCountDrawcalls;
|
||||||
pCountCommands = 0;
|
pCountCommands = 0;
|
||||||
pCountDrawcalls = 0;
|
pCountDrawcalls = 0;
|
||||||
ResetPools();
|
|
||||||
SysReset();
|
SysReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ int main(int argc, char** argv) {
|
|||||||
RightStick.pColor = "#00ffff";
|
RightStick.pColor = "#00ffff";
|
||||||
while (pOs->Mainloop()) {
|
while (pOs->Mainloop()) {
|
||||||
PD::Hid::Update();
|
PD::Hid::Update();
|
||||||
PD::Gfx::Reset(); // needs to be on top now
|
PD::Gfx::NewFrame();
|
||||||
pOs->ClearViewPort();
|
pOs->ClearViewPort();
|
||||||
app.Update(pOs->GetViewport(), pList);
|
app.Update(pOs->GetViewport(), pList);
|
||||||
pList.SetFontscale(0.7);
|
pList.SetFontscale(0.7);
|
||||||
@@ -263,6 +263,7 @@ int main(int argc, char** argv) {
|
|||||||
pList.PathAdd(PD::fvec2(1000, 360));
|
pList.PathAdd(PD::fvec2(1000, 360));
|
||||||
|
|
||||||
pList.PathStroke("#ff00ff", 10, LiDrawFlags_AA);
|
pList.PathStroke("#ff00ff", 10, LiDrawFlags_AA);
|
||||||
|
PD::Gfx::Reset(); // needs to be on top now
|
||||||
PD::Gfx::Draw(pList);
|
PD::Gfx::Draw(pList);
|
||||||
pList.Clear();
|
pList.Clear();
|
||||||
pOs->SwapBuffers();
|
pOs->SwapBuffers();
|
||||||
|
|||||||
Reference in New Issue
Block a user