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

nvapi-drs: Add NvAPI_DRS_CreateProfile #190

Merged
merged 2 commits into from
Jul 10, 2024
Merged

nvapi-drs: Add NvAPI_DRS_CreateProfile #190

merged 2 commits into from
Jul 10, 2024

Conversation

jp7677
Copy link
Owner

@jp7677 jp7677 commented Jul 10, 2024

Return no-implementation no prevent applications from doing more things with the profile.

This fixes a startup crash for Battle Brothers which apparently forgets to check if a function pointer is valid.

12058.183:0124:0128:info:dxvk-nvapi:NvAPI_QueryInterface NvAPI_DRS_CreateApplication: Not implemented method
12058.183:0124:0128:info:dxvk-nvapi:NvAPI_QueryInterface NvAPI_DRS_DeleteProfile: Not implemented method
12058.183:0124:0128:info:dxvk-nvapi:NvAPI_QueryInterface NvAPI_DRS_EnumApplications: Not implemented method
12058.183:0124:0128:info:dxvk-nvapi:NvAPI_QueryInterface NvAPI_DRS_GetProfileInfo: Not implemented method
12058.183:0124:0128:info:dxvk-nvapi:NvAPI_QueryInterface NvAPI_DRS_SaveSettings: Not implemented method
12058.183:0124:0128:info:dxvk-nvapi:NvAPI_QueryInterface NvAPI_DRS_SetSetting: Not implemented method
12058.183:0124:0128:info:dxvk-nvapi:NvAPI_Initialize
...
10435.820:0128:012c:info:dxvk-nvapi:<-NvAPI_Initialize: OK
10435.820:0128:012c:trace:dxvk-nvapi:NvAPI_DRS_CreateSession (ptr=0xa54a24)
10435.820:0128:012c:info:dxvk-nvapi:<-NvAPI_DRS_CreateSession: OK
10435.820:0128:012c:trace:dxvk-nvapi:NvAPI_DRS_LoadSettings (hnd=0x772955a0)
10435.820:0128:012c:info:dxvk-nvapi:<-NvAPI_DRS_LoadSettings: OK
10435.820:0128:012c:trace:dxvk-nvapi:NvAPI_DRS_FindProfileByName (hnd=0x772955a0, ptr=0xa5ea78, ptr=0xa54a20)
10435.820:0128:012c:info:dxvk-nvapi:<-NvAPI_DRS_FindProfileByName (Battle Brothers): Profile not found
10435.820:0128:012c:trace:dxvk-nvapi:NvAPI_DRS_CreateProfile (hnd=0x772955a0, ptr=0xa54a28, ptr=0xa54a20)
10435.820:0128:012c:info:dxvk-nvapi:<-NvAPI_DRS_CreateProfile: No implementation

By returning no-implementation not-supported, it doesn't call the other DRS functions. For safety we might consider to add those others as well because if it calls such a function, it explodes. I figured when playing with the return code. But from very brief testing this PR seems sufficient.

This addresses ValveSoftware/Proton#4148 (comment)

@Saancreed
Copy link
Collaborator

This fixes a startup crash for Battle Brothers which apparently forgets to check if a function pointer is valid.

That… should not be possible unless the game is using the open source SDK. SDK used by games has this check builtin (probably for all the functions it supports) and never even exposes to the application the fact that something like nvapi_QueryInterface even exists.

🤔

Maybe we should add a simple

static NvAPI_Status NvAPI_StubFunction(...)
{
    return NVAPI_NO_IMPLEMENTATION;
}

and return that to applications when we're asked for a function that we know about but don't have implemented?

Copy link
Collaborator

@Saancreed Saancreed left a comment

Choose a reason for hiding this comment

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

Technically nothing wrong with this but it's not, well, scalable, we should think of something better in the long term.

Return not-supported to prevent applications
from doing more with the profile.
@jp7677 jp7677 merged commit bb3d4ad into master Jul 10, 2024
2 checks passed
@jp7677 jp7677 deleted the drs-create-profile branch August 6, 2024 20:15
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.

None yet

2 participants