Skip to content

API v1#178

Open
WSSDude wants to merge 2 commits intowopss:masterfrom
WSSDude:features/api-update
Open

API v1#178
WSSDude wants to merge 2 commits intowopss:masterfrom
WSSDude:features/api-update

Conversation

@WSSDude
Copy link
Collaborator

@WSSDude WSSDude commented Feb 1, 2025

  • promote v0 to v1
  • swap to references instead of pointers
  • update GameState hooks
  • update documentation
  • fix incorrect naming of IGameState::OnUpdate to OnTick
  • rename GameStates::Add to AddHook
  • split GameState hooks to before/after hooks for more granular control and better verbosity
  • add EMainReason::Run for notifying plugins about entry to CRunningState
  • add NOMINMAX preprocessor define
  • fix incorrect naming of EGameStateStatus enum values
  • fix members of CGameApplication
  • simpler vendor exclusion in pre-commit

@WSSDude WSSDude force-pushed the features/api-update branch 3 times, most recently from caa8d5d to ae4f1c3 Compare February 1, 2025 13:26
@WSSDude WSSDude changed the title Promote v0 to v1 Promote v0 to v1, extend v1 and extend GpuApi Feb 1, 2025
@WSSDude WSSDude force-pushed the features/api-update branch from caa50b4 to b4f0e57 Compare February 2, 2025 09:34
@WSSDude WSSDude marked this pull request as ready for review February 2, 2025 09:56
@WSSDude WSSDude marked this pull request as draft February 2, 2025 09:56
@WSSDude
Copy link
Collaborator Author

WSSDude commented Feb 2, 2025

Practically same as wopss/RED4ext#94 (comment), would like to have a more proper look over the Present again if something might not be useful to expose, even if it may not be intresting now due to missing structs (already pre-exposed index into monitors structure that is used with HDR and contains curves for various supported modes by the monitor in the ResizeBuffers...)

But those are for the next PR, this was supposed to be about API primarily...

Copy link
Owner

@wopss wopss left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I saw some changes that include STL structs, which I would not prefer in the API, since it might be used in other code than C++ or compiled with a different C++ version.

@WSSDude WSSDude force-pushed the features/api-update branch 2 times, most recently from 9099004 to d66f101 Compare February 2, 2025 23:01
@WSSDude
Copy link
Collaborator Author

WSSDude commented Feb 5, 2025

Just some update on why nothing gets posted for a bit - I found various issues trying to use this, trying to find some better hooks for initialize/deinitialize or some combination that should be reliable enough. Initialize only does base initialization of devices, not swapchain and some other systems that I had plan to hook. Same for shutdown - is just absolute last step of shutdown as I found out and not shutdown for all systems as I thought at first.

Found something already and got a bit sidetracked by it, should hopefully post some updates soon...

Also considering swapping the ResizeBackbuffer for some more upper-level function as it may get called twice a frame for no good reason as I found out, leading to some suboptimal things on hooked side.

@WSSDude WSSDude force-pushed the features/api-update branch from d66f101 to 14258bc Compare February 16, 2025 00:13
@WSSDude WSSDude changed the title Promote v0 to v1, extend v1 and extend GpuApi API v1 Feb 16, 2025
@WSSDude WSSDude force-pushed the features/api-update branch from 14258bc to 1cd1cd6 Compare February 16, 2025 00:18
@WSSDude WSSDude marked this pull request as ready for review February 16, 2025 00:23
@WSSDude WSSDude requested review from psiberx and wopss February 16, 2025 00:23
@WSSDude WSSDude mentioned this pull request Feb 16, 2025
@WSSDude WSSDude force-pushed the features/api-update branch from 1cd1cd6 to 1934055 Compare February 16, 2025 01:46
wopss
wopss previously approved these changes Feb 17, 2025
* promote v0 to v1
* swap to references instead of pointers
* update `GameState` hooks
* update documentation
* fix incorrect naming of
  `IGameState::OnUpdate` to `OnTick`
* rename `GameStates::Add` to `AddHook`
* split `GameState` hooks to before/after
  hooks for more granular control and
  better verbosity
* add `EMainReason::Run` for notifying plugins
  about entry to `CRunningState`
* add NOMINMAX preprocessor define
* fix incorrect naming of `EGameStateStatus`
  enum values
* fix members of `CGameApplication`
* simpler `vendor` exclusion in pre-commit
@WSSDude
Copy link
Collaborator Author

WSSDude commented Feb 18, 2025

I just quickly removed changes to SSwapChainData that I left in on accident and noticed just now trying to work on another PR... No other changes done.

@WSSDude WSSDude requested a review from wopss February 18, 2025 18:56
wopss
wopss previously approved these changes Feb 19, 2025
@WSSDude WSSDude marked this pull request as draft February 19, 2025 16:40
@WSSDude
Copy link
Collaborator Author

WSSDude commented Feb 19, 2025

Ill try to add something which wraps the newer API, should be doable I believe... Something to emulate v1 via v0 iface.

@WSSDude
Copy link
Collaborator Author

WSSDude commented Feb 19, 2025

Or does it make sense even when it will break compat nonetheless without recompilation? Kinda going off the Discord discussion... @psiberx @wopss ?

@WSSDude WSSDude marked this pull request as ready for review February 19, 2025 22:06
namespace RED4ext
{
/**
* @brief The latest plugin info type.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd delete "the latest" from all comments.

*/
enum class EGameStateResult : uint8_t
{
Running, /**< Hook has not yet finished. Until the state changes, hook continues to operate. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this comment is missing the most important part: "Running" prevents game state transition.

{
Running, /**< Hook has not yet finished. Until the state changes, hook continues to operate. */
Finished, /**< Hook has finished. When signaled, hook is detached. */
Observing /**< Hook is observing, not running a task. Hook won't get detached until shutdown. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to "Running", the most important property of "Observing" is that it doesn't prevent game state transition (while still executing).

/**
* @brief Result type for game state hooks.
*/
enum class EGameStateResult : uint8_t
Copy link
Collaborator

Choose a reason for hiding this comment

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

Proposal: rename it to EGameStateHookResult.

Observing /**< Hook is observing, not running a task. Hook won't get detached until shutdown. */
};

struct GameState
Copy link
Collaborator

Choose a reason for hiding this comment

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

Proposal: rename it to GameStateHooks.

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.

3 participants