Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

equeue: Implement sceGnmGetEqEventType/sceKernelGetEventData #1839

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nenkai
Copy link

@Nenkai Nenkai commented Dec 21, 2024

This PR implements sceGnmGetEqEventType and sceKernelGetEventData (called from the former, based on module research).

Games are normally expected to call sceGnmGetEqEventType to get the type of Eq/GraphicCore events returned from sceKernelWaitEqueue. Since this was not yet implemented, some games that would wait on a GfxEop event before rendering would permanently softlock.

Furthermore, equeue events are uniquely identified by ident and filter. Some code paths such as AddEvent were not checking on this.

Addresses a softlock in CUSA02168 (Gran Turismo Sport), CUSA24767 (Gran Turismo 7).

Needs testing.

Copy link
Collaborator

@polybiusproxy polybiusproxy left a comment

Choose a reason for hiding this comment

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

clang-format CI is failing as well.


// We need to convert IRQ# to event id
// Exclude ids we shouldn't care about as they aren't a valid EqEventType.
if (irq == Platform::InterruptId::GpuIdle || irq == Platform::InterruptId::GfxFlip)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're not checking for the rest of idents.

Comment on lines 369 to 370
auto event_type = static_cast<GnmEqEventType>(id);
eq->TriggerEvent(event_type, SceKernelEvent::Filter::GraphicsCore,
reinterpret_cast<void*>(event_type));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Irrelevant cast in my opinion, since you'll be casting to void* either way.

@@ -29,7 +29,7 @@ namespace Libraries::GnmDriver {

using namespace AmdGpu;

enum GnmEventIdents : u64 {
enum GnmEqEventType : u64 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the name change necessary?

Copy link
Author

Choose a reason for hiding this comment

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

I would say so, this is so far not used and more inline with sceGnmGetEqEventType.

Comment on lines 20 to 25
bool has_event = false;
for (auto& ev : m_events) {
if (ev.event.ident == event.event.ident && ev.event.filter == event.event.filter) {
ev = std::move(event);
has_event = true;
break;
}
}

if (!has_event) {
m_events.emplace_back(std::move(event));
}
Copy link
Collaborator

@polybiusproxy polybiusproxy Dec 21, 2024

Choose a reason for hiding this comment

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

You can move back to std::ranges::find instead of manually iterating.

Comment on lines 73 to 77
// Ensure not to clear event data for Eq events, as it'll be fetched by sceGnmGetEqEventType.
if (event.filter != SceKernelEvent::Filter::GraphicsCore) {
event.data = 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be merged IMO, proper research on kernel has to be done.

@Nenkai
Copy link
Author

Nenkai commented Dec 21, 2024

Reviews addressed.
Fixed an existing issue where events would immediately fire again after being triggered. EV_CLEAR flag for GraphicsCore events should no longer be required.

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