Skip to content

RFC: Projection Libraries#129

Closed
Esras wants to merge 9 commits intoopen-ead:masterfrom
Esras:various_additions
Closed

RFC: Projection Libraries#129
Esras wants to merge 9 commits intoopen-ead:masterfrom
Esras:various_additions

Conversation

@Esras
Copy link

@Esras Esras commented Jun 10, 2023

This PR attempts to implement many of the Projection libraries and tries to update their dependencies where needed and from @aboood40091's repo.

Goals

  • Implement more of the Projection libraries, including what appear to be the Perspective, Ortho, Frustum, and Direct projections.
  • Include the Graphics, Viewport, and DrawContext library updates that @aboood40091 has been working on.
  • Organize the files in such a way to be consumable, but still implemented as a single piece in the built object file for the BotW decomp.

Addresses
0xB1D898 - 0xB1F2B0 are the bulk of the Projection functions in BotW.
0xB1FFF0 - 0xB20718 are the sead::Viewport functions

Waiting on dependencies

  • Projection::unproject(Ray<>, ...)

Non-Matching Functions

  • Projection::doScreenPosToCameraPosTo(sead::Vector3<float>*, sead::Vector3<float> const&) const
  • Projection::project(sead::Vector2<float>*, sead::Vector3<float> const&, sead::Viewport const&) const
  • Projection::unproject(sead::Vector3<float>*, sead::Vector3<float> const&, sead::Camera const&) const
  • Projection::doUpdateDeviceMatrix(sead::Matrix44<float>*, sead::Matrix44<float> const&, sead::Graphics::DevicePosture) const
  • PerspectiveProjection::PerspectiveProjection()
  • PerspectiveProjection::PerspectiveProjection(float, float, float, float)
  • OrthoProjection::OrthoProjection()
  • OrthoProjection::OrthoProjection(float, float, float, float, float, float)
  • OrthoProjection::OrthoProjection(float, float, sead::Viewport const&)
  • OrthoProjection::setByViewport(sead::Viewport const&)
  • OrthoProjection::doUpdateMatrix(sead::Matrix44<float>*) const
  • FrustumProjection::FrustumProjection(float, float, float, float, float, float)
  • DirectProjection::DirectProjection()
  • DirectProjection::DirectProjection(sead::Matrix44<float> const*, sead::Graphics::DevicePosture)
  • DirectProjection::setDirectProjectionMatrix(sead::Matrix44<float> const*, sead::Graphics::DevicePosture)
  • DirectProjection::updateAttributesForDirectProjection()
  • DirectProjection::doUpdateMatrix(sead::Matrix44<float>*) const
  • DirectProjection::doScreenPosToCameraPosTo(sead::Vector3<float>*, sead::Vector3<float> const&) const

Next Steps
I'm looking for feedback on the non-matching functions, and which of the library files that have been modified that need to be updated here.


This change is Reviewable

@aboood40091
Copy link
Contributor

All projections must be in the same header/cpp file.

@Esras Esras marked this pull request as draft June 15, 2023 04:31
@Esras Esras changed the title Projection Libraries RFC: Projection Libraries Jul 6, 2023
@Esras Esras marked this pull request as ready for review July 6, 2023 19:30
@ThePixelGamer ThePixelGamer self-requested a review August 7, 2023 19:40
Copy link
Contributor

@ThePixelGamer ThePixelGamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good but abood mentioned the projection headers and sources are supposed to be condensed into one file ie. seadProjection.(h/cpp)

bool _202;
};
static_assert(sizeof(GraphicsNvn) == 0x208);
// static_assert(sizeof(GraphicsNvn) == 0x208);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason why this was commented out?

} // namespace sead

#endif // SEAD_GRAPHICS_CONTEXT_H_
#ifndef SEAD_GRAPHICS_CONTEXT_H_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra copy and paste?

@@ -0,0 +1,550 @@
#ifndef SEAD_GRAPHICS_CONTEXT_H_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#pragma once

@@ -1,31 +1,35 @@
#pragma once
#ifndef SEAD_VIEWPORT_H_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pragma once

explicit Viewport(const BoundBox2f& parent);
explicit Viewport(const LogicalFrameBuffer& buffer);
Viewport(f32 left, f32 top, f32 sizeX, f32 sizeY);
// explicit Viewport(const BoundBox2f& box);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason behind commenting this out?

return 4;
}

void DirectResource::doCreate_(u8*, u32, Heap*) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change seems unrelated to the PR

@aboood40091
Copy link
Contributor

Progress on this pull request? It's almost going to be 2 years now since then.

@LynxDev2
Copy link
Contributor

I find it unlikely that the original author will return to this PR, so if we want it merged, someone else needs to take it over and fix the stuff that was commented on

@Esras
Copy link
Author

Esras commented Mar 15, 2025

I haven't touched it because there was an overarching discussion that I was trying to ask about regarding some of the organization and other things going on. Additional followup on the Discord at the time got very little traction, and made it difficult to care about making any changes.

To summarize (as best I can remember):

  • Is there a particular version of sead that is being targeted? If so, how is that being tracked? My use case was coming from the botw-decomp project. As changes to the code base happened over time in released titles, is that being tracked in some way here?
  • For the headers, since the compilation output was identical, I was trying to understand why putting them all in one file was desired. I believe it was described as being from debug symbols in a released title, but it didn't seem to be important as a difference.
    • A potential suggestion here is that if you want that, and you have the information and it doesn't exist in the repo, creating that outline. If it does exist, perhaps better documentation here would help someone trying to contribute. Again, I was coming at this from a particular project, and following expectations there.
  • aboood40091 mentioned already having a version of these that they had on another branch and just simply hadn't merged, so it felt like a lower priority to potentially dig into further.

I'm not fundamentally opposed to making changes to this PR (ThePixelGamer has some suggestions that should be incorporated), but the above combo of things made it feel like it wasn't worth my time.

@MonsterDruide1
Copy link
Contributor

Sorry for having it get stuck here - I'll try my best to help get this PR back on track, if you're still interested.

Is there a particular version of sead that is being targeted? If so, how is that being tracked? My use case was coming from the botw-decomp project. As changes to the code base happened over time in released titles, is that being tracked in some way here?

We haven't discovered too fundamental differences between games yet to have a proper workflow. A discussion has recently been opened in #162 - so far, this repo is mostly targeted to BotW, while some contributions come from SMO, but are also always checked again with BotW to avoid introducing conflicts.

For the headers, since the compilation output was identical, I was trying to understand why putting them all in one file was desired. I believe it was described as being from debug symbols in a released title, but it didn't seem to be important as a difference.

The documentation on the process here is ... nonexistant. First up, we can determine file boundaries and sometimes names based on inline optimizations (if it is inlined, it must be the same TU => same file) and linking order (alphabetically). As far as I know, we only have information about sead based on the pead fork, which showed up with more debug information in Super Mario Run - but I might also be missing something, maybe @ThePixelGamer has more references?

@Esras
Copy link
Author

Esras commented Jul 27, 2025

As of #167, I believe this is moot.

@Esras Esras closed this Jul 27, 2025
@MonsterDruide1
Copy link
Contributor

Yours still has additional implementations of various Projection stuff (.cpp files), and seadViewport.cpp. I'd still like to get those merged/fixed, are you interested in preparing that or do you want to hand it off to someone else?
@Esras

Esras pushed a commit to Esras/sead that referenced this pull request Jul 28, 2025
@Esras
Copy link
Author

Esras commented Jul 28, 2025

I redid the PR as #213.

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.

5 participants