Add debug getters (and somehow text is not rendering :/)
This commit is contained in:
@@ -42,6 +42,11 @@ class PD_API GfxDriver : public DriverInterface {
|
|||||||
Li::Texture::Ptr GetWhiteTexture() { return &pWhite; }
|
Li::Texture::Ptr GetWhiteTexture() { return &pWhite; }
|
||||||
PDBackendFlags GetFlags() { return Flags; }
|
PDBackendFlags GetFlags() { return Flags; }
|
||||||
|
|
||||||
|
size_t GetNumVertices() const { return CountVertices; }
|
||||||
|
size_t GetNumIndices() const { return CountIndices; }
|
||||||
|
size_t GetNumDrawcalls() const { return CountDrawcalls; }
|
||||||
|
size_t GetNumCommands() const { return CountCommands; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void SysDeinit() {}
|
virtual void SysDeinit() {}
|
||||||
virtual void SysInit() {}
|
virtual void SysInit() {}
|
||||||
@@ -58,6 +63,8 @@ class PD_API GfxDriver : public DriverInterface {
|
|||||||
size_t CountIndices = 0;
|
size_t CountIndices = 0;
|
||||||
size_t CurrentIndex = 0;
|
size_t CurrentIndex = 0;
|
||||||
size_t CurrentVertex = 0;
|
size_t CurrentVertex = 0;
|
||||||
|
size_t pCountDrawcalls = 0;
|
||||||
|
size_t pCountCommands = 0;
|
||||||
TextureID CurrentTex = 0;
|
TextureID CurrentTex = 0;
|
||||||
Mat4 Projection;
|
Mat4 Projection;
|
||||||
ivec2 ViewPort;
|
ivec2 ViewPort;
|
||||||
@@ -91,7 +98,7 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Draw(const Pool<Li::Command>& commands) override {
|
void Draw(const Pool<Li::Command>& commands) override {
|
||||||
CountCommands += commands.size();
|
pCountCommands += commands.size();
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
while (index < commands.size()) {
|
while (index < commands.size()) {
|
||||||
CurrentTex = commands[index].Tex;
|
CurrentTex = commands[index].Tex;
|
||||||
@@ -103,8 +110,6 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
(CurrentTex == commands[index].Tex ||
|
(CurrentTex == commands[index].Tex ||
|
||||||
(CurrentTex == pWhite.GetID() && commands[index].Tex == 0))) {
|
(CurrentTex == pWhite.GetID() && commands[index].Tex == 0))) {
|
||||||
const auto& c = commands[index];
|
const auto& c = commands[index];
|
||||||
CountVertices += c.VertexCount;
|
|
||||||
CountIndices += c.IndexCount;
|
|
||||||
auto pIdx = pIdxPool.Allocate(c.IndexCount);
|
auto pIdx = pIdxPool.Allocate(c.IndexCount);
|
||||||
auto pVtx = pVtxPool.Allocate(c.VertexCount);
|
auto pVtx = pVtxPool.Allocate(c.VertexCount);
|
||||||
for (size_t i = 0; i < c.IndexCount; i++) {
|
for (size_t i = 0; i < c.IndexCount; i++) {
|
||||||
@@ -118,6 +123,7 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
Submit(CurrentIndex - startidx, startidx);
|
Submit(CurrentIndex - startidx, startidx);
|
||||||
|
pCountDrawcalls++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,6 +178,11 @@ class PD_API Gfx {
|
|||||||
|
|
||||||
static const char* GetDriverName() { return driver->GetName(); }
|
static const char* GetDriverName() { return driver->GetName(); }
|
||||||
|
|
||||||
|
static size_t GetNumVertices() { return driver->GetNumVertices(); }
|
||||||
|
static size_t GetNumIndices() { return driver->GetNumIndices(); }
|
||||||
|
static size_t GetNumDrawcalls() { return driver->GetNumDrawcalls(); }
|
||||||
|
static size_t GetNumCommands() { return driver->GetNumCommands(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unique_ptr<GfxDriver> driver;
|
static std::unique_ptr<GfxDriver> driver;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,8 +25,14 @@ PD_API void GfxDriver::SetViewPort(int x, int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PD_API void GfxDriver::Reset() {
|
PD_API void GfxDriver::Reset() {
|
||||||
|
CountIndices = CurrentIndex;
|
||||||
|
CountVertices = CurrentVertex;
|
||||||
CurrentVertex = 0;
|
CurrentVertex = 0;
|
||||||
CurrentIndex = 0;
|
CurrentIndex = 0;
|
||||||
|
CountCommands = pCountCommands;
|
||||||
|
CountDrawcalls = pCountDrawcalls;
|
||||||
|
pCountCommands = 0;
|
||||||
|
pCountDrawcalls = 0;
|
||||||
ResetPools();
|
ResetPools();
|
||||||
SysReset();
|
SysReset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ PD_API void Font::LoadTTF(const std::string& path, int px_height) {
|
|||||||
PDLOG("Font: Loading {}...", path);
|
PDLOG("Font: Loading {}...", path);
|
||||||
TT::Scope st("LI_LoadTTF_" + path);
|
TT::Scope st("LI_LoadTTF_" + path);
|
||||||
auto font = PD::IO::LoadFile2Mem(path);
|
auto font = PD::IO::LoadFile2Mem(path);
|
||||||
|
PDLOG("Font Size: {}", PD::Strings::FormatBytes(font.size()));
|
||||||
LoadTTF(font, px_height);
|
LoadTTF(font, px_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ int main(int argc, char** argv) {
|
|||||||
pList.DrawRectFilled(pOs->PositionTranslate(PD::fvec2(0.02f, 0.5f)),
|
pList.DrawRectFilled(pOs->PositionTranslate(PD::fvec2(0.02f, 0.5f)),
|
||||||
pOs->SizeTranslate(PD::fvec2(0.3)), 0xffffffff);
|
pOs->SizeTranslate(PD::fvec2(0.3)), 0xffffffff);
|
||||||
pList.DrawText(5, "Hello World!", 0xff0000ff);
|
pList.DrawText(5, "Hello World!", 0xff0000ff);
|
||||||
|
pList.DrawText(
|
||||||
|
pOs->PositionTranslate(PD::fvec2(0.005, 0.9)),
|
||||||
|
std::format("VIDC: [{}, {}, {}, {}]\nGfxDriver: {}",
|
||||||
|
PD::Gfx::GetNumVertices(), PD::Gfx::GetNumIndices(),
|
||||||
|
PD::Gfx::GetNumDrawcalls(), PD::Gfx::GetNumCommands(),
|
||||||
|
PD::Gfx::GetDriverName())
|
||||||
|
.c_str(),
|
||||||
|
PD::Color("#ffffff"));
|
||||||
PD::Gfx::Reset();
|
PD::Gfx::Reset();
|
||||||
PD::Gfx::Draw(pList);
|
PD::Gfx::Draw(pList);
|
||||||
pList.Clear();
|
pList.Clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user