QOpenGLWidget video rendering perfomance in multiple processes












0















My problem may seem vague without code, but it actually isn't.



So, there I've got an almost properly-working widget, which renders video frames.



Qt 5.10 and QOpenGLWidget subclassing worked fine, I didn't make any sophisticated optimizations -- there are two textures and a couple of shaders, converting YUV pixel format to RGB -- glTexImage2D() + shaders, no buffers.



Video frames are obtained from FFMPEG, it shows great performance due to hardware acceleration... when there is only one video window.



The piece of software is a "video wall" -- multiple independent video windows on the same screen. Of course, multi-threading would be the preferred solution, but legacy holds for now, I can't change it.



So, 1 window with Full HD video consumes ~2% CPU & 8-10% GPU regardless of the size of the window. But 7-10 similar windows, launched from the same executable at the same time consume almost all the CPU. My math says that 2 x 8 != 100...



My best guesses are:




  • This is a ffmpeg decoder issue, hardware acceleration still is not magic, some hardware pipeline stalls

  • 7-8-9 independent OpenGL contexts cost a lot more than 1 cost x N

  • I'm not using PUBO or some other complex techniques to improve OpenGL rendering. It still explains nothing, but at least it is a guess


The behavior is the same on Ubuntu, where decoding uses different codec (I mean that using GPU accelerated or CPU accelerated codecs makes no difference!), so, it makes more probable that I'm missing something about OpenGL... or not, because launching 6-7 Qt examples with dynamic textures shows normal growth of CPU usages -- it is approximately a sum for the number of windows.



Anyway, it becomes quite tricky for me to profile the case, so I hope someone could have been solving the similar problem before and could share his experience with me. I'd be appreciated for any ideas, how to deal with the described riddle.



I can add any pieces of code if that helps.










share|improve this question

























  • If the issue is with CPU then you should profile your code. If you use old fixed-pipeline OpenGL then perhaps, only perhaps, you have an issue with RAM-to-GPU data movement. These are only guesses. Without profiling and seeing your code nothing can be asserted.

    – Ripi2
    Nov 23 '18 at 19:18











  • Qt's problem? Unsure. I don't want to mislead you but: software.intel.com/en-us/articles/… How is that applicable to your problem exactly, I wish I could express it in the actual answer.

    – Alexander V
    Nov 24 '18 at 5:03






  • 1





    I roughly remember that OpenGL context switches are expensive. However, I remember also that QOpenGLWidgets may share a context. There's a subject in Qt doc. for this: Context Sharing

    – Scheff
    Nov 24 '18 at 11:20











  • @Ripi2, good guess but no, I'm using shaders/buffers and all other stuff from the new pipeline.It has to be profiling, but the tricky thing is somewhat about I described: one "demo.exe" works fine, eight exe's simultaneously work lame. And they share no data at all =(

    – MasterAler
    Nov 26 '18 at 12:32











  • @AlexanderV, yeah, that's about OpenGL optimizations, was thinking to use some of it, but my doubt origins in single-launched-app good perfomance. I'd consder it to be the bottleneck otherwise.

    – MasterAler
    Nov 26 '18 at 12:33
















0















My problem may seem vague without code, but it actually isn't.



So, there I've got an almost properly-working widget, which renders video frames.



Qt 5.10 and QOpenGLWidget subclassing worked fine, I didn't make any sophisticated optimizations -- there are two textures and a couple of shaders, converting YUV pixel format to RGB -- glTexImage2D() + shaders, no buffers.



Video frames are obtained from FFMPEG, it shows great performance due to hardware acceleration... when there is only one video window.



The piece of software is a "video wall" -- multiple independent video windows on the same screen. Of course, multi-threading would be the preferred solution, but legacy holds for now, I can't change it.



So, 1 window with Full HD video consumes ~2% CPU & 8-10% GPU regardless of the size of the window. But 7-10 similar windows, launched from the same executable at the same time consume almost all the CPU. My math says that 2 x 8 != 100...



My best guesses are:




  • This is a ffmpeg decoder issue, hardware acceleration still is not magic, some hardware pipeline stalls

  • 7-8-9 independent OpenGL contexts cost a lot more than 1 cost x N

  • I'm not using PUBO or some other complex techniques to improve OpenGL rendering. It still explains nothing, but at least it is a guess


The behavior is the same on Ubuntu, where decoding uses different codec (I mean that using GPU accelerated or CPU accelerated codecs makes no difference!), so, it makes more probable that I'm missing something about OpenGL... or not, because launching 6-7 Qt examples with dynamic textures shows normal growth of CPU usages -- it is approximately a sum for the number of windows.



Anyway, it becomes quite tricky for me to profile the case, so I hope someone could have been solving the similar problem before and could share his experience with me. I'd be appreciated for any ideas, how to deal with the described riddle.



I can add any pieces of code if that helps.










share|improve this question

























  • If the issue is with CPU then you should profile your code. If you use old fixed-pipeline OpenGL then perhaps, only perhaps, you have an issue with RAM-to-GPU data movement. These are only guesses. Without profiling and seeing your code nothing can be asserted.

    – Ripi2
    Nov 23 '18 at 19:18











  • Qt's problem? Unsure. I don't want to mislead you but: software.intel.com/en-us/articles/… How is that applicable to your problem exactly, I wish I could express it in the actual answer.

    – Alexander V
    Nov 24 '18 at 5:03






  • 1





    I roughly remember that OpenGL context switches are expensive. However, I remember also that QOpenGLWidgets may share a context. There's a subject in Qt doc. for this: Context Sharing

    – Scheff
    Nov 24 '18 at 11:20











  • @Ripi2, good guess but no, I'm using shaders/buffers and all other stuff from the new pipeline.It has to be profiling, but the tricky thing is somewhat about I described: one "demo.exe" works fine, eight exe's simultaneously work lame. And they share no data at all =(

    – MasterAler
    Nov 26 '18 at 12:32











  • @AlexanderV, yeah, that's about OpenGL optimizations, was thinking to use some of it, but my doubt origins in single-launched-app good perfomance. I'd consder it to be the bottleneck otherwise.

    – MasterAler
    Nov 26 '18 at 12:33














0












0








0








My problem may seem vague without code, but it actually isn't.



So, there I've got an almost properly-working widget, which renders video frames.



Qt 5.10 and QOpenGLWidget subclassing worked fine, I didn't make any sophisticated optimizations -- there are two textures and a couple of shaders, converting YUV pixel format to RGB -- glTexImage2D() + shaders, no buffers.



Video frames are obtained from FFMPEG, it shows great performance due to hardware acceleration... when there is only one video window.



The piece of software is a "video wall" -- multiple independent video windows on the same screen. Of course, multi-threading would be the preferred solution, but legacy holds for now, I can't change it.



So, 1 window with Full HD video consumes ~2% CPU & 8-10% GPU regardless of the size of the window. But 7-10 similar windows, launched from the same executable at the same time consume almost all the CPU. My math says that 2 x 8 != 100...



My best guesses are:




  • This is a ffmpeg decoder issue, hardware acceleration still is not magic, some hardware pipeline stalls

  • 7-8-9 independent OpenGL contexts cost a lot more than 1 cost x N

  • I'm not using PUBO or some other complex techniques to improve OpenGL rendering. It still explains nothing, but at least it is a guess


The behavior is the same on Ubuntu, where decoding uses different codec (I mean that using GPU accelerated or CPU accelerated codecs makes no difference!), so, it makes more probable that I'm missing something about OpenGL... or not, because launching 6-7 Qt examples with dynamic textures shows normal growth of CPU usages -- it is approximately a sum for the number of windows.



Anyway, it becomes quite tricky for me to profile the case, so I hope someone could have been solving the similar problem before and could share his experience with me. I'd be appreciated for any ideas, how to deal with the described riddle.



I can add any pieces of code if that helps.










share|improve this question
















My problem may seem vague without code, but it actually isn't.



So, there I've got an almost properly-working widget, which renders video frames.



Qt 5.10 and QOpenGLWidget subclassing worked fine, I didn't make any sophisticated optimizations -- there are two textures and a couple of shaders, converting YUV pixel format to RGB -- glTexImage2D() + shaders, no buffers.



Video frames are obtained from FFMPEG, it shows great performance due to hardware acceleration... when there is only one video window.



The piece of software is a "video wall" -- multiple independent video windows on the same screen. Of course, multi-threading would be the preferred solution, but legacy holds for now, I can't change it.



So, 1 window with Full HD video consumes ~2% CPU & 8-10% GPU regardless of the size of the window. But 7-10 similar windows, launched from the same executable at the same time consume almost all the CPU. My math says that 2 x 8 != 100...



My best guesses are:




  • This is a ffmpeg decoder issue, hardware acceleration still is not magic, some hardware pipeline stalls

  • 7-8-9 independent OpenGL contexts cost a lot more than 1 cost x N

  • I'm not using PUBO or some other complex techniques to improve OpenGL rendering. It still explains nothing, but at least it is a guess


The behavior is the same on Ubuntu, where decoding uses different codec (I mean that using GPU accelerated or CPU accelerated codecs makes no difference!), so, it makes more probable that I'm missing something about OpenGL... or not, because launching 6-7 Qt examples with dynamic textures shows normal growth of CPU usages -- it is approximately a sum for the number of windows.



Anyway, it becomes quite tricky for me to profile the case, so I hope someone could have been solving the similar problem before and could share his experience with me. I'd be appreciated for any ideas, how to deal with the described riddle.



I can add any pieces of code if that helps.







c++ qt opengl ffmpeg






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 18:13









marc_s

577k12911141259




577k12911141259










asked Nov 23 '18 at 17:44









MasterAlerMasterAler

463512




463512













  • If the issue is with CPU then you should profile your code. If you use old fixed-pipeline OpenGL then perhaps, only perhaps, you have an issue with RAM-to-GPU data movement. These are only guesses. Without profiling and seeing your code nothing can be asserted.

    – Ripi2
    Nov 23 '18 at 19:18











  • Qt's problem? Unsure. I don't want to mislead you but: software.intel.com/en-us/articles/… How is that applicable to your problem exactly, I wish I could express it in the actual answer.

    – Alexander V
    Nov 24 '18 at 5:03






  • 1





    I roughly remember that OpenGL context switches are expensive. However, I remember also that QOpenGLWidgets may share a context. There's a subject in Qt doc. for this: Context Sharing

    – Scheff
    Nov 24 '18 at 11:20











  • @Ripi2, good guess but no, I'm using shaders/buffers and all other stuff from the new pipeline.It has to be profiling, but the tricky thing is somewhat about I described: one "demo.exe" works fine, eight exe's simultaneously work lame. And they share no data at all =(

    – MasterAler
    Nov 26 '18 at 12:32











  • @AlexanderV, yeah, that's about OpenGL optimizations, was thinking to use some of it, but my doubt origins in single-launched-app good perfomance. I'd consder it to be the bottleneck otherwise.

    – MasterAler
    Nov 26 '18 at 12:33



















  • If the issue is with CPU then you should profile your code. If you use old fixed-pipeline OpenGL then perhaps, only perhaps, you have an issue with RAM-to-GPU data movement. These are only guesses. Without profiling and seeing your code nothing can be asserted.

    – Ripi2
    Nov 23 '18 at 19:18











  • Qt's problem? Unsure. I don't want to mislead you but: software.intel.com/en-us/articles/… How is that applicable to your problem exactly, I wish I could express it in the actual answer.

    – Alexander V
    Nov 24 '18 at 5:03






  • 1





    I roughly remember that OpenGL context switches are expensive. However, I remember also that QOpenGLWidgets may share a context. There's a subject in Qt doc. for this: Context Sharing

    – Scheff
    Nov 24 '18 at 11:20











  • @Ripi2, good guess but no, I'm using shaders/buffers and all other stuff from the new pipeline.It has to be profiling, but the tricky thing is somewhat about I described: one "demo.exe" works fine, eight exe's simultaneously work lame. And they share no data at all =(

    – MasterAler
    Nov 26 '18 at 12:32











  • @AlexanderV, yeah, that's about OpenGL optimizations, was thinking to use some of it, but my doubt origins in single-launched-app good perfomance. I'd consder it to be the bottleneck otherwise.

    – MasterAler
    Nov 26 '18 at 12:33

















If the issue is with CPU then you should profile your code. If you use old fixed-pipeline OpenGL then perhaps, only perhaps, you have an issue with RAM-to-GPU data movement. These are only guesses. Without profiling and seeing your code nothing can be asserted.

– Ripi2
Nov 23 '18 at 19:18





If the issue is with CPU then you should profile your code. If you use old fixed-pipeline OpenGL then perhaps, only perhaps, you have an issue with RAM-to-GPU data movement. These are only guesses. Without profiling and seeing your code nothing can be asserted.

– Ripi2
Nov 23 '18 at 19:18













Qt's problem? Unsure. I don't want to mislead you but: software.intel.com/en-us/articles/… How is that applicable to your problem exactly, I wish I could express it in the actual answer.

– Alexander V
Nov 24 '18 at 5:03





Qt's problem? Unsure. I don't want to mislead you but: software.intel.com/en-us/articles/… How is that applicable to your problem exactly, I wish I could express it in the actual answer.

– Alexander V
Nov 24 '18 at 5:03




1




1





I roughly remember that OpenGL context switches are expensive. However, I remember also that QOpenGLWidgets may share a context. There's a subject in Qt doc. for this: Context Sharing

– Scheff
Nov 24 '18 at 11:20





I roughly remember that OpenGL context switches are expensive. However, I remember also that QOpenGLWidgets may share a context. There's a subject in Qt doc. for this: Context Sharing

– Scheff
Nov 24 '18 at 11:20













@Ripi2, good guess but no, I'm using shaders/buffers and all other stuff from the new pipeline.It has to be profiling, but the tricky thing is somewhat about I described: one "demo.exe" works fine, eight exe's simultaneously work lame. And they share no data at all =(

– MasterAler
Nov 26 '18 at 12:32





@Ripi2, good guess but no, I'm using shaders/buffers and all other stuff from the new pipeline.It has to be profiling, but the tricky thing is somewhat about I described: one "demo.exe" works fine, eight exe's simultaneously work lame. And they share no data at all =(

– MasterAler
Nov 26 '18 at 12:32













@AlexanderV, yeah, that's about OpenGL optimizations, was thinking to use some of it, but my doubt origins in single-launched-app good perfomance. I'd consder it to be the bottleneck otherwise.

– MasterAler
Nov 26 '18 at 12:33





@AlexanderV, yeah, that's about OpenGL optimizations, was thinking to use some of it, but my doubt origins in single-launched-app good perfomance. I'd consder it to be the bottleneck otherwise.

– MasterAler
Nov 26 '18 at 12:33












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451021%2fqopenglwidget-video-rendering-perfomance-in-multiple-processes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451021%2fqopenglwidget-video-rendering-perfomance-in-multiple-processes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen