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

Add patch-vk for vulkan limit bypass support #872

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Amjad50
Copy link

@Amjad50 Amjad50 commented Dec 3, 2024

Purpose of proposed changes

Vulkan recently added Video Encoding API Nvidia, and AMD started implementing support for this.

And for Nvidia cards, similar to NVENC API, there is a limit to consumer grade cards.

This PR adds a new patch script patch-vk to patch libnvidia-eglcore.so which contain the functionality controlling the encoding session and its restrictions.

In this PR as well I added patch support for versions from 555.42.02 to 565.57.01 (all use the same patch, so other versions might also be patched).

Essential steps taken

Check 35d33fb for details on the patch itself, but to summarize.

The function doing the restriction is 0xD7E780 (address in version 555.58.02).
The function signature is like this

// This is C++, but for `C` translation it will be something like this
bool auth_release(void* this, bool is_auth);

It will take either is_auth==true if in auth or false when releasing.

It will return either true for success or false for failure.

What we changed here is that we replaced this function implementation with just return true;.

So it won't do increment or decrement the "usage" counters

This bypasses the limit for vulkan drivers.

Whenever an encoder session is created, it will call a function that
does "authorization", and then before it exit or when the session is
closed, it will "release" it.

This happens at the function 0xD7E780 (address in version 555.58.02).

The function signature is like this
```C
// This is C++, but for `C` translation it will be something like this
bool auth_release(void* this, bool is_auth);
```

It will take either `is_auth==true` if in `auth` or `false` when
releasing.

It will return either `true` for success or `false` for failure.

What we changed here is that we replaced this function implementation
with `return true;`.

And it seems to be working as expected, and we can bypass the limit by
not even registering and checking for it.

Part of this commit, I checked the other surrounding versions, and they
all seem to use the exact same function which is good for us.

I actually didn't test any version beside 555.58.02, so it could need
some testing.

Signed-off-by: Amjad Alsharafi <[email protected]>
Updated the README template, as well as `drivers.json` to include this new patch category

Signed-off-by: Amjad Alsharafi <[email protected]>
@Amjad50
Copy link
Author

Amjad50 commented Jan 1, 2025

Hello @jailuthra , can this be reviewed?

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.

1 participant