From 66d3825481ab695062d33cd5eb96a37695f129ad Mon Sep 17 00:00:00 2001 From: tobid7 Date: Wed, 17 Dec 2025 09:25:36 +0100 Subject: [PATCH] bknd-3ds: implement libpicasso to load shader --- .gitmodules | 9 ++++++--- backends/3ds/CMakeLists.txt | 4 ++-- backends/3ds/include/pd-3ds/bknd-gfx.hpp | 1 + backends/3ds/libpicasso | 1 + backends/3ds/source/bknd-gfx.cpp | 16 +++------------- 5 files changed, 13 insertions(+), 18 deletions(-) create mode 160000 backends/3ds/libpicasso diff --git a/.gitmodules b/.gitmodules index 12dc1a0..492be7a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ -[submodule "backends/desktop/glfw"] - path = backends/desktop/glfw - url = https://github.com/glfw/glfw +[submodule "backends/desktop/glfw"] + path = backends/desktop/glfw + url = https://github.com/glfw/glfw +[submodule "backends/3ds/libpicasso"] + path = backends/3ds/libpicasso + url = https://github.com/npid7/libpicasso diff --git a/backends/3ds/CMakeLists.txt b/backends/3ds/CMakeLists.txt index 019c68d..ddaa935 100755 --- a/backends/3ds/CMakeLists.txt +++ b/backends/3ds/CMakeLists.txt @@ -7,7 +7,7 @@ set(SRC source/bknd-hid.cpp source/pd-3ds.cpp ) - +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libpicasso) pd_add_lib(pd-3ds SRC_FILES ${SRC}) target_include_directories(pd-3ds PUBLIC include) -target_link_libraries(pd-3ds PUBLIC m palladium ctru citro3d) +target_link_libraries(pd-3ds PUBLIC m palladium ctru citro3d pica::pica) diff --git a/backends/3ds/include/pd-3ds/bknd-gfx.hpp b/backends/3ds/include/pd-3ds/bknd-gfx.hpp index ef9fb5b..f253858 100755 --- a/backends/3ds/include/pd-3ds/bknd-gfx.hpp +++ b/backends/3ds/include/pd-3ds/bknd-gfx.hpp @@ -56,5 +56,6 @@ class GfxC3D : public GfxDriver { DVLB_s* ShaderCode; shaderProgram_s Shader; C3D_AttrInfo ShaderInfo; + std::vector pRawShader; }; } // namespace PD \ No newline at end of file diff --git a/backends/3ds/libpicasso b/backends/3ds/libpicasso new file mode 160000 index 0000000..5d47f32 --- /dev/null +++ b/backends/3ds/libpicasso @@ -0,0 +1 @@ +Subproject commit 5d47f32928a62795255e3dcecf8edba5274ae758 diff --git a/backends/3ds/source/bknd-gfx.cpp b/backends/3ds/source/bknd-gfx.cpp index da75438..2325b21 100755 --- a/backends/3ds/source/bknd-gfx.cpp +++ b/backends/3ds/source/bknd-gfx.cpp @@ -23,11 +23,8 @@ SOFTWARE. */ #include +#include -/// @brief Shader Code (Unused as i dont want to use libpicasso here (yet)) -/// Update: Picasso breaks the linearRam or ram for somereason -/// as far as i found out loading anything into linear ram after -/// using libpicasso to compile a shader leads into a system freeze const char* LIShaderCTR = R"( ; LI7 Shader ; Constants @@ -65,13 +62,6 @@ const char* LIShaderCTR = R"( .end )"; -// clang-format off -unsigned char li_shader[] = { - 0x44, 0x56, 0x4c, 0x42, 0x1, 0x0, 0x0, 0x0, 0xa4, 0x0, 0x0, 0x0, 0x44, 0x56, 0x4c, 0x50, 0x0, 0x0, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x98, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4e, 0x1, 0xf0, 0x7, 0x4e, 0x2, 0x8, 0x2, 0x8, 0x3, 0x18, 0x2, 0x8, 0x4, 0x28, 0x2, 0x8, 0x5, 0x38, 0x2, 0x8, 0x6, 0x10, 0x40, 0x4c, 0x7, 0xf1, 0x27, 0x22, 0x8, 0x10, 0x21, 0x4c, 0x0, 0x0, 0x0, 0x88, 0xac, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa1, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x68,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8 @@ void GfxC3D::Init() { Flags |= LiBackendFlags_FlipUV_Y; - ShaderCode = DVLB_ParseFile((uint32_t*)li_shader, li_shader_size); + pRawShader = Pica::AssembleCode(LIShaderCTR); + ShaderCode = DVLB_ParseFile((uint32_t*)&pRawShader[0], pRawShader.size()); shaderProgramInit(&Shader); shaderProgramSetVsh(&Shader, &ShaderCode->DVLE[0]); pLocProjection = @@ -131,7 +122,6 @@ void GfxC3D::BindTex(PD::Li::TexAddress addr) { } void GfxC3D::RenderDrawData(const std::vector& Commands) { - // C3D_BindProgram(&Shader); shaderProgramUse(&Shader); C3D_SetAttrInfo(&ShaderInfo); C3D_Mtx proj;