Compare commits
8
Commits
c828166ce4
..
stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6547f64d13
|
||
|
|
2b37204763
|
||
|
|
8c2bcedc93
|
||
|
|
01d3eb771e
|
||
|
|
6de3683818
|
||
|
|
ec49f70c0b
|
||
|
|
6284ff885d
|
||
|
|
91c245c1a6
|
@@ -141,6 +141,9 @@ void GfxCitro3D::SysInit() {
|
||||
PDLOG("GfxCitro3D::SysInit();");
|
||||
impl = new Impl();
|
||||
Flags |= PDGfxBackendFlags_FlipUV_Y;
|
||||
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||
Flags |= PDGfxBackendFlags_ReqPow2;
|
||||
Flags |= PDGfxBackendFlags_ApproxSDF;
|
||||
impl->pShaderRaw = Pica::AssembleCode(LIShaderCTR);
|
||||
impl->pCode = DVLB_ParseFile((uint32_t*)impl->pShaderRaw.data(),
|
||||
impl->pShaderRaw.size());
|
||||
@@ -265,7 +268,13 @@ void GfxCitro3D::UploadPools() {
|
||||
BufInfo_Add(buf, GetVertexBufPtr(0), sizeof(Li::Vertex), 3, 0x210);
|
||||
}
|
||||
|
||||
void GfxCitro3D::ClipRect() {}
|
||||
void GfxCitro3D::ClipRect() {
|
||||
// This is so cursed but it works
|
||||
C3D_SetScissor(CurrentHasClip ? GPU_SCISSOR_NORMAL : GPU_SCISSOR_DISABLE,
|
||||
ViewPort.y - CurrentClip.w - CurrentClip.y,
|
||||
ViewPort.x - CurrentClip.z - CurrentClip.x,
|
||||
ViewPort.y - CurrentClip.y, ViewPort.x - CurrentClip.x);
|
||||
}
|
||||
} // namespace PD
|
||||
#else
|
||||
namespace PD {
|
||||
|
||||
@@ -112,6 +112,7 @@ void GfxDirectX9::SysInit() {
|
||||
}
|
||||
if (psBlob) psBlob->Release();
|
||||
if (errBlob) errBlob->Release();
|
||||
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||
} else {
|
||||
PDERR(
|
||||
"GfxDirectX9::SysInit Error: pDevice is not set!\nYOu need to include "
|
||||
@@ -286,7 +287,20 @@ void GfxDirectX9::UploadPools() {
|
||||
impl->IBO->Unlock();
|
||||
}
|
||||
|
||||
void GfxDirectX9::ClipRect() {}
|
||||
void GfxDirectX9::ClipRect() {
|
||||
if (CurrentHasClip) {
|
||||
RECT r;
|
||||
r.left = CurrentClip.x;
|
||||
r.top = CurrentClip.y;
|
||||
r.right = CurrentClip.x + CurrentClip.z;
|
||||
r.bottom = CurrentClip.y + CurrentClip.w;
|
||||
|
||||
impl->Device->SetScissorRect(&r);
|
||||
impl->Device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
|
||||
} else {
|
||||
impl->Device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
}
|
||||
}
|
||||
} // namespace PD
|
||||
#else
|
||||
namespace PD {
|
||||
|
||||
@@ -73,6 +73,7 @@ void GfxOpenGL2::pSetupShaderAttribs(u32 shader) {
|
||||
}
|
||||
|
||||
void GfxOpenGL2::SysInit() {
|
||||
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||
pShader = CreateShaderProgram(pVertCode, pFragCode);
|
||||
glUseProgram(pShader);
|
||||
glGenBuffers(1, &VBO);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace PD {
|
||||
void GfxOpenGL3::SysInit() {
|
||||
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||
std::string vcode = SpirvHelper::SPV2GLSL(
|
||||
std::vector<unsigned int>(
|
||||
Shaders::VertexShader,
|
||||
|
||||
+1
-22
@@ -56,21 +56,9 @@ struct PD_API Mat4 {
|
||||
constexpr float* Ptr() { return m.data(); }
|
||||
constexpr const float* Ptr() const { return m.data(); }
|
||||
|
||||
constexpr float& operator()(int row, int col) {
|
||||
#ifdef __3DS__
|
||||
// 3ds is full reverse order iirc
|
||||
return m[row * 4 + (3 - col)];
|
||||
#else
|
||||
return m[col * 4 + row];
|
||||
#endif
|
||||
}
|
||||
constexpr float& operator()(int row, int col) { return m[col * 4 + row]; }
|
||||
constexpr float operator()(int row, int col) const {
|
||||
#ifdef __3DS__
|
||||
// 3ds is full reverse order iirc
|
||||
return m[row * 4 + (3 - col)];
|
||||
#else
|
||||
return m[col * 4 + row];
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr Mat4 operator*(const Mat4& v) const {
|
||||
@@ -122,21 +110,12 @@ struct PD_API Mat4 {
|
||||
constexpr static Mat4 Ortho(float l, float r, float b, float t, float n,
|
||||
float f) {
|
||||
Mat4 ret;
|
||||
#ifdef __3DS__ // Patch to rotate the Matrix correctly
|
||||
ret(0, 1) = 2.f / (t - b);
|
||||
ret(0, 3) = (b + t) / (b - t);
|
||||
ret(1, 0) = 2.f / (l - r);
|
||||
ret(1, 3) = (l + r) / (r - l);
|
||||
ret(2, 2) = 1.f / (n - f);
|
||||
ret(2, 3) = 0.5f * (n + f) / (n - f) - 0.5f;
|
||||
#else
|
||||
ret(0, 0) = 2.0f / (r - l);
|
||||
ret(0, 3) = -(r + l) / (r - l);
|
||||
ret(1, 1) = 2.0f / (t - b);
|
||||
ret(1, 3) = -(t + b) / (t - b);
|
||||
ret(2, 2) = -2.0f / (f - n);
|
||||
ret(2, 3) = -(f + n) / (f - n);
|
||||
#endif
|
||||
ret(3, 3) = 1.f;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ using PDGfxBackendFlags = PD::u32;
|
||||
enum PDGfxBackendFlags_ {
|
||||
PDGfxBackendFlags_None = 0,
|
||||
PDGfxBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
|
||||
PDGfxBackendFlags_WindingCW = 1 << 0, // Use CW instead of CCW winding
|
||||
PDGfxBackendFlags_WindingCW = 1 << 1, // Use CW instead of CCW winding
|
||||
PDGfxBackendFlags_HasClipRect = 1 << 2, // Clip rects supported
|
||||
PDGfxBackendFlags_ReqPow2 = 1 << 3, // Tex size must be pow of 2
|
||||
PDGfxBackendFlags_ApproxSDF = 1 << 4, // Fake SDF for non smoothstep systems
|
||||
};
|
||||
|
||||
namespace PD {
|
||||
|
||||
@@ -56,12 +56,6 @@ class PD_API Font {
|
||||
*/
|
||||
void LoadTTF(const std::vector<u8>& data, int px_height = 32,
|
||||
LiFontFlags flags = LiFontFlags_None);
|
||||
/**
|
||||
* Function that loads a default integrated font...
|
||||
* This will only work if PD_LI_INCLUDE_FONTS was set
|
||||
* on lithium build cause otherwise the font data is not included
|
||||
*/
|
||||
void LoadDefaultFont(int id = 0, int pixel_height = 32);
|
||||
/**
|
||||
* Getter for Codepoint reference
|
||||
* @return codepoint dataholder reference
|
||||
|
||||
@@ -85,13 +85,8 @@ PD_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
Mat4 ret;
|
||||
ret(0, 0) = 1.f / (aspect * _fov);
|
||||
ret(1, 1) = 1.f / _fov;
|
||||
#ifdef __3DS__
|
||||
ret(2, 3) = f * n / (n - f);
|
||||
ret(2, 2) = -(-1.f) * n / (n - f);
|
||||
#else
|
||||
ret(2, 2) = -(f + n) / (f - n);
|
||||
ret(2, 3) = -(2.f * f * n) / (f - n);
|
||||
#endif
|
||||
ret(3, 2) = -1.f;
|
||||
ret(3, 3) = 0.0f;
|
||||
return ret;
|
||||
|
||||
@@ -195,8 +195,6 @@ PD_API void Font::LoadTTF(const std::vector<u8>& data, int px_height,
|
||||
}
|
||||
}
|
||||
|
||||
PD_API void Font::LoadDefaultFont(int id, int pixel_height) {}
|
||||
|
||||
PD_API Font::Codepoint& Font::GetCodepoint(u32 c) {
|
||||
if (c < 128) {
|
||||
// Direct Access (~11% improvement)
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
if (!(Flags & UI7MenuFlags_NoResize)) {
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||
l->SetLayer(1);
|
||||
l->SetLayer(21);
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(0, 20));
|
||||
l->PathAdd(self->FinalPos() + self->GetSize());
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(20, 0));
|
||||
|
||||
+11
-1
@@ -207,7 +207,17 @@ PD_API void Context::MetricsMenu(bool* show) {
|
||||
}
|
||||
m->SeparatorText("Palladium Info");
|
||||
m->Label("Os Driver: {}", PD::Os::GetDriverName());
|
||||
m->Label("Renderer: {}", PD::Gfx::GetDriverName());
|
||||
if (m->BeginTreeNode(
|
||||
std::format("Gfx Driver: {}", PD::Gfx::GetDriverName()))) {
|
||||
m->SeparatorText("Features");
|
||||
if (PD::Gfx::GetFlags() & PDGfxBackendFlags_HasClipRect)
|
||||
m->Label("ClipRects");
|
||||
if (PD::Gfx::GetFlags() & PDGfxBackendFlags_ReqPow2)
|
||||
m->Label("Texture As Pow of 2");
|
||||
if (PD::Gfx::GetFlags() & PDGfxBackendFlags_ApproxSDF)
|
||||
m->Label("SDF Approximation");
|
||||
m->EndTreeNode();
|
||||
}
|
||||
if (m->BeginTreeNode(
|
||||
std::string(std::string("Input: ") + PD::Hid::GetDriverName()))) {
|
||||
/* if (pIO.pCtx.Hid()->Flags & PD::HidDriver::Flags_HasKeyboard) {
|
||||
|
||||
@@ -20,9 +20,26 @@ bool ColorTests() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IDTests() {
|
||||
std::cout << std::format("HashID32(\"1234\") -> {:016X}",
|
||||
PD::HashID32("1234").Get())
|
||||
<< std::endl;
|
||||
std::cout << std::format("HashID32(\"1235\") -> {:016X}",
|
||||
PD::HashID32("1235").Get())
|
||||
<< std::endl;
|
||||
std::cout << std::format("HashID64(\"1234\") -> {:016X}",
|
||||
PD::HashID64("1234").Get())
|
||||
<< std::endl;
|
||||
std::cout << std::format("HashID64(\"1235\") -> {:016X}",
|
||||
PD::HashID64("1235").Get())
|
||||
<< std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
PD::Os::UseDriver<PD::OsDriver>();
|
||||
ColorTests();
|
||||
IDTests();
|
||||
std::cout << PD::Os::GetTime() << std::endl;
|
||||
PD::Pool<int> pool;
|
||||
pool.Init(90);
|
||||
|
||||
@@ -21,6 +21,8 @@ class OsCtx {
|
||||
virtual bool Mainloop() { return false; }
|
||||
virtual void ClearViewPort() {}
|
||||
virtual void SwapBuffers() {}
|
||||
virtual int GetScreenCount() { return 1; }
|
||||
virtual void DrawOnScreen(int s = 0) {}
|
||||
PD::fvec2 PositionTranslate(PD::fvec2 in) {
|
||||
return fvec2(in.x * pViewPort.x, in.y * pViewPort.y);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ class HorizonCtr : public PD::OsCtx {
|
||||
bool Mainloop() override;
|
||||
void ClearViewPort() override;
|
||||
void SwapBuffers() override;
|
||||
int GetScreenCount() override { return 2; }
|
||||
void DrawOnScreen(int s) override;
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
|
||||
@@ -208,11 +208,17 @@ int main(int argc, char** argv) {
|
||||
RightStick.pColor = "#00ffff";
|
||||
PD::UI7::Context ui7;
|
||||
ui7.GetIO().Font = &font;
|
||||
#ifdef __3DS__
|
||||
ui7.AddViewPort("Default", PD::ivec4(0, 0, 320, 240));
|
||||
ui7.GetIO().FontScale = 0.5f;
|
||||
#else
|
||||
ui7.AddViewPort("Default", PD::ivec4(0, 0, 1280, 720));
|
||||
#endif
|
||||
ui7.UseViewPort("Default");
|
||||
bool pMetricsWin = true;
|
||||
while (pOs->Mainloop()) {
|
||||
PD::TT::End("OSCTX::MainLoop");
|
||||
pOs->DrawOnScreen(0);
|
||||
pOs->ClearViewPort();
|
||||
PD::TT::Scope __st("MainLoop");
|
||||
PD::TT::Beg("MainRaw");
|
||||
@@ -302,6 +308,7 @@ int main(int argc, char** argv) {
|
||||
PD::TT::Beg("BuildUI7Menus");
|
||||
if (auto m = ui7.BeginMenu("Test")) {
|
||||
m->Label("Hello World!");
|
||||
m->Image(pTex, 128.f);
|
||||
ui7.EndMenu();
|
||||
}
|
||||
if (auto m = ui7.BeginMenu("LI DBG INFO")) {
|
||||
@@ -324,7 +331,10 @@ int main(int argc, char** argv) {
|
||||
PD::TT::End("UI7::Context::Update");
|
||||
PD::Gfx::Reset();
|
||||
PD::TT::Beg("PD::Gfx::Draw");
|
||||
pOs->DrawOnScreen(1);
|
||||
pOs->ClearViewPort();
|
||||
PD::Gfx::Draw(ui7.GetDrawData());
|
||||
pOs->DrawOnScreen(0);
|
||||
PD::Gfx::Draw(pList);
|
||||
PD::TT::End("PD::Gfx::Draw");
|
||||
pList.Clear();
|
||||
|
||||
@@ -16,6 +16,7 @@ struct HorizonCtr::Impl {
|
||||
C3D_RenderTarget* Top = nullptr;
|
||||
C3D_RenderTarget* Bottom = nullptr;
|
||||
uint32_t* pSocBuf = nullptr;
|
||||
int CurrentScreen = 0;
|
||||
};
|
||||
|
||||
void HorizonCtr::Init() {
|
||||
@@ -63,13 +64,25 @@ bool HorizonCtr::Mainloop() {
|
||||
pViewPort = ivec2(400, 240);
|
||||
bool _kill = hidKeysUp() & KEY_START;
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
impl->CurrentScreen = 0;
|
||||
return aptMainLoop() && !_kill;
|
||||
}
|
||||
|
||||
void HorizonCtr::ClearViewPort() {
|
||||
PD::Gfx::SetViewPort(pViewPort);
|
||||
C3D_RenderTargetClear(impl->CurrentScreen ? impl->Bottom : impl->Top,
|
||||
C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0);
|
||||
}
|
||||
|
||||
void HorizonCtr::DrawOnScreen(int s) {
|
||||
impl->CurrentScreen = s;
|
||||
if (s == 0) {
|
||||
C3D_FrameDrawOn(impl->Top);
|
||||
C3D_RenderTargetClear(impl->Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0);
|
||||
pViewPort = PD::ivec2(400, 240);
|
||||
} else if (s == 1) {
|
||||
C3D_FrameDrawOn(impl->Bottom);
|
||||
pViewPort = PD::ivec2(320, 240);
|
||||
}
|
||||
PD::Gfx::SetViewPort(pViewPort);
|
||||
}
|
||||
|
||||
void HorizonCtr::SwapBuffers() { C3D_FrameEnd(0); }
|
||||
|
||||
Reference in New Issue
Block a user