-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Make AMF encoder utilize all VCNs #11752
base: master
Are you sure you want to change the base?
Conversation
VCNs are HW units which can process encoders in parallel boosting performance if several encoders are run simultaneously. Added controller to balance load of VCNs. Made AMF context and D3D11 device and context shared between all encoder instances. Using KeyedMutex to synchronize copying from texture from OBS core to texture allocated and used in encoder caused submitting a lot of HW fences to all HW queues leading to parallel encode queues waiting for other queue's job's done and hence significant performance degradation. To work this around, encoder's texture is created as shared, it's opened and copy is done on a device used in OBS core, using synchronization on CPU.
Add proper release of shared device and contexts. Make selecting VCN separate for different codecs, they may have different number of VCNs.
1. Added mutex for static amf_context, enc_instance_counter, d3d device and context. 2. Saving ID3D11Query in amf_texencode. 3. Changed pthread_mutex_t to std::mutex.
… started This happened because AMF creates d3d11 device internally on fallback encoder start up and then texture encoder creates new d3d11 device on start up, creates textures with this new device and tries to work with AMF with different d3d11 device inside.
To make termination visible and make sure it is done in correct order. Also run clang-format to fix formatting.
@@ -1505,6 +1815,7 @@ static void register_avc() | |||
amf_encoder_info.create = amf_avc_create_texencode; | |||
amf_encoder_info.destroy = amf_destroy; | |||
amf_encoder_info.update = amf_avc_update; | |||
amf_encoder_info.encode_texture2 = amf_encode_tex2; | |||
amf_encoder_info.encode_texture = amf_encode_tex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When encode_texture2 is set you can remove encode_texture
@@ -1833,6 +2155,7 @@ static void register_hevc() | |||
amf_encoder_info.create = amf_hevc_create_texencode; | |||
amf_encoder_info.destroy = amf_destroy; | |||
amf_encoder_info.update = amf_hevc_update; | |||
amf_encoder_info.encode_texture2 = amf_encode_tex2; | |||
amf_encoder_info.encode_texture = amf_encode_tex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When encode_texture2 is set you can remove encode_texture
@@ -2138,6 +2472,7 @@ static void register_av1() | |||
amf_encoder_info.create = amf_av1_create_texencode; | |||
amf_encoder_info.destroy = amf_destroy; | |||
amf_encoder_info.update = amf_av1_update; | |||
amf_encoder_info.encode_texture2 = amf_encode_tex2; | |||
amf_encoder_info.encode_texture = amf_encode_tex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When encode_texture2 is set you can remove encode_texture
Description
Make AMF encoder utilize all VCNs (HW encoding units in AMD GPUs) which are present in used GPU, currently only one VCN is used. Reduce amount of D3D devices being created by making one shared device being used by all AMF encode sessions.
Motivation and Context
When use obs-multi-rtmp plugin to run multiple streams at once this change significantly increases performance allowing to run more streams simultaneously.
How Has This Been Tested?
Run OBS on Windows 10, AMD Radeon RX 6800, and run multiple streams with obs-multi-rtmp plugin
Types of changes
Checklist: