bknd-3ds: implement libpicasso to load shader

This commit is contained in:
2025-12-17 09:25:36 +01:00
parent 6c38aa6f21
commit 66d3825481
5 changed files with 13 additions and 18 deletions

3
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[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

View File

@@ -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)

View File

@@ -56,5 +56,6 @@ class GfxC3D : public GfxDriver {
DVLB_s* ShaderCode;
shaderProgram_s Shader;
C3D_AttrInfo ShaderInfo;
std::vector<u8> pRawShader;
};
} // namespace PD

View File

@@ -23,11 +23,8 @@ SOFTWARE.
*/
#include <pd-3ds/bknd-gfx.hpp>
#include <pica.hpp>
/// @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,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 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x2, 0x0, 0x1, 0x0, 0xf, 0x0, 0x0, 0x0, 0x3, 0x0, 0x2, 0x0, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x13, 0x0, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x0,
};
// clang-format on
size_t li_shader_size = 0x124;
namespace PD {
GPU_TEXCOLOR GetTexFmt(Li::Texture::Type type) {
if (type == Li::Texture::RGBA32)
@@ -98,7 +88,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<PD::Li::Command::Ref>& Commands) {
// C3D_BindProgram(&Shader);
shaderProgramUse(&Shader);
C3D_SetAttrInfo(&ShaderInfo);
C3D_Mtx proj;