Skip to content

g3d: Implement ResMaterial and ResShaderParam - #3

Open
arayaphong wants to merge 1 commit into
open-ead:mainfrom
arayaphong:implement/g3d-res-material
Open

arayaphong wants to merge 1 commit into
open-ead:mainfrom
arayaphong:implement/g3d-res-material

Conversation

@arayaphong

@arayaphong arayaphong commented Sep 25, 2026 •

Copy link
Copy Markdown

Implements nn::g3d::ResMaterial and nn::g3d::ResShaderParam (lib/g3d/src/g3d/g3d_ResMaterial.cpp), ported from the closed open-ead/nnheaders#88 as requested.

  • 23 of the 24 functions in ResMaterial.o match.
  • ResShaderParam::ConvertSrt3dCallback is non-matching (SIMD scheduling and register allocation), marked NON_MATCHING with a decomp.me link: https://decomp.me/scratch/lkHXp
  • Adds lib/g3d/include/nn/g3d/g3d_ResMaterial.h, adds the source to lib/g3d/CMakeLists.txt, and forward-declares struct TextureRef in g3d_ResFile.h, g3d_ResModel.h and g3d_ResMaterialAnim.h (they previously had typedef void* TextureRef, which conflicts with the real struct definition).
  • No changes needed in nnsdk: nn/util/util_Arithmetic.h and nn/gfx/gfx_Sampler.h already provide everything used here.

One thing to decide: ConvertSrt3dCallback uses NEON intrinsics (<arm_neon.h>), which only compile for ARM targets. The PR workflow builds for the x86_64 host, so this file does not compile there. I verified the port itself is correct by compiling it for an aarch64 target, and clang-format/clang-tidy are clean. How would you like architecture-specific code handled here - an aarch64 build path, a guard, or something else?

Formatted with this repo clang-format config; clang-tidy is clean.


This change is Reviewable

@arayaphong arayaphong changed the title g3d: Implement \ResMaterial\ and \ResShaderParam\ g3d: Implement ResMaterial and ResShaderParam Sep 25, 2026
@Pistonight

Copy link
Copy Markdown
Member

That is unfortunate and I think we might have to change the setup to cross build for arm64

@arayaphong

Copy link
Copy Markdown
Author

I found SIMDe (https://github.com/simd-everywhere/simde), which could let the NEON intrinsics compile on x86_64. I haven't tried it yet, so I'm not sure how stable it is.

@Pistonight

Copy link
Copy Markdown
Member

I don't think it's worth to add more hacks on top of -D__aarch64__. I got cross build working with the container image and I think the easiest way to go from here is to make a wrapper script that execute commands in the container

@Pistonight

Copy link
Copy Markdown
Member

Hi there! The aarch64 toolchain is set up. If you rebase and revert the CMakeLists.txt changes (it's automatically globbed now), it should build (hopefully)

@arayaphong
arayaphong force-pushed the implement/g3d-res-material branch from 509a7c5 to fc6eb42 Compare September 28, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants