-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(linux): Add Vulkan video encoder for Linux #4603
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
Open
neatnoise
wants to merge
8
commits into
LizardByte:master
Choose a base branch
from
neatnoise:vulkan-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,206
−5
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7bfc410
Add Vulkan video encoder for Linux
neatnoise 81289c1
fix: correct Vulkan VBR rc_mode value from 3 to 4 per Vulkan spec
neatnoise e76b2ff
fix: correct VBR default in web config.html from 3 to 4
neatnoise 0f24ad8
feat(linux): improve vulkan encoder, add rgb2nv12 shader
neatnoise 75f7041
fix: address review feedback - ordering, translations, remove ifdef g…
neatnoise 854c242
vulkan: disable SEI/AUD units to match VAAPI behavior
neatnoise dc8a319
vulkan: optimize encoder frame path
neatnoise fe2111b
vulkan: use 2x1 horizontal chroma subsampling
neatnoise File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #version 450 | ||
|
|
||
| layout(local_size_x = 16, local_size_y = 16) in; | ||
|
|
||
| layout(set = 0, binding = 0) uniform sampler2D rgb_in; | ||
| layout(set = 0, binding = 1, r8) uniform writeonly image2D y_out; | ||
| layout(set = 0, binding = 2, rg8) uniform writeonly image2D uv_out; | ||
|
|
||
| layout(push_constant) uniform PushConstants { | ||
| vec4 color_vec_y; | ||
| vec4 color_vec_u; | ||
| vec4 color_vec_v; | ||
| vec2 range_y; | ||
| vec2 range_uv; | ||
| ivec2 src_offset; | ||
| ivec2 src_size; | ||
| ivec2 dst_size; | ||
| } pc; | ||
|
|
||
| void main() { | ||
| ivec2 pos = ivec2(gl_GlobalInvocationID.xy); | ||
| if (pos.x >= pc.dst_size.x || pos.y >= pc.dst_size.y) | ||
| return; | ||
|
|
||
| // Precompute scaling factors | ||
| vec2 inv_tex = 1.0 / vec2(textureSize(rgb_in, 0)); | ||
| vec2 scale = vec2(pc.src_size) / vec2(pc.dst_size); | ||
|
|
||
| // Map output pixel to input texture coordinate | ||
| vec2 uv = (vec2(pc.src_offset) + (vec2(pos) + 0.5) * scale) * inv_tex; | ||
| vec3 rgb = texture(rgb_in, uv).rgb; | ||
|
|
||
| // Y plane | ||
| float y = dot(pc.color_vec_y.xyz, rgb) + pc.color_vec_y.w; | ||
| imageStore(y_out, pos, vec4(y * pc.range_y.x + pc.range_y.y, 0, 0, 0)); | ||
|
|
||
| // UV plane (half resolution, one thread per 2x2 block) | ||
| if ((pos.x & 1) == 0 && (pos.y & 1) == 0) { | ||
| vec2 step = scale * inv_tex; | ||
|
|
||
| // Average 2x1 horizontal pair for chroma subsampling | ||
| vec3 avg = (rgb + texture(rgb_in, uv + vec2(step.x, 0)).rgb) * 0.5; | ||
|
|
||
| float cb = dot(pc.color_vec_u.xyz, avg) + pc.color_vec_u.w; | ||
| float cr = dot(pc.color_vec_v.xyz, avg) + pc.color_vec_v.w; | ||
|
|
||
| imageStore(uv_out, pos >> 1, vec4(cb * pc.range_uv.x + pc.range_uv.y, | ||
| cr * pc.range_uv.x + pc.range_uv.y, 0, 0)); | ||
| } | ||
| } |
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.