How can I display graphics on the screen from the kernel over the top of my X11/Wayland session?How do I find...

What does a comma signify in inorganic chemistry?

Tikz: The position of a label change step-wise and not in a continuous way

Units of measurement, especially length, when body parts vary in size among races

Why don't modern jet engines use forced exhaust mixing?

From where do electrons gain kinetic energy through a circuit?

May the tower use the runway while an emergency aircraft is inbound?

Programming a recursive formula into Mathematica and find the nth position in the sequence

My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?

What should I do if actually I found a serious flaw in someone's PhD thesis and an article derived from that PhD thesis?

Why should I pay for an SSL certificate?

What's a good pattern to calculate a variable only when it is used the first time?

Do I need to start off my book by describing the character's "normal world"?

Are unaudited server logs admissible in a court of law?

Earliest evidence of objects intended for future archaeologists?

Have made several mistakes during the course of my PhD. Can't help but feel resentment. Can I get some advice about how to move forward?

Does knowing that the exponent is in a certain range help solving discrete log?

How do I cope with haze for the photos containing sky and trees at a distance?

Regression when x and y each have uncertainties

When and which board game was the first to be ever invented?

When does The Truman Show take place?

Gofer work in exchange for Letter of Recommendation

Combinatorial Argument for Exponential and Logarithmic Function Being Inverse

Unsolved Problems due to Lack of Computational Power

What are some tips and tricks for finding the cheapest flight when luggage and other fees are not revealed until far into the booking process?



How can I display graphics on the screen from the kernel over the top of my X11/Wayland session?


How do I find the video memory region(s) representing what's on my screen, from within the Linux kernel?How can I overlay lines in a transparent, inactive layer over my screen?Why can X11 access the video card?How can I get my framebuffer console working?What's the difference between DRM and a graphics driver?Can USB devices be used with X11 over the network?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I want to draw simple (2D bitmapped) graphics onto my screen (in response to (simple) external inputs) with the lowest latency possible (the order of tens of milliseconds) so I can empirically test the results of drawing to the screen a) in realtime, b) with the least overhead possible, c) with page flipping completely disabled (tearing is fine).



Then I can compare this with drawing to the screen in various stereotypical (and arguably pathological :) ) scenarios (eg X11, Wayland, Wayland+XWayland, Wayland+XWayland+xcompmgr, etc).



To this end, how might I modify Linux so that I can draw over the top of my existing X11/Wayland session? Worded differently, yes, I want to fiddle with DRM, a) from inside the kernel, b) while X11 owns the DRM master. :)



I suspect that a hardware overlay would be the easiest (and most hardware-accelerated!) way to keep X11/Wayland from scribbling over what I'm drawing. (I'm imagining alternatives involving implementing a shadow/write-through framebuffer cache, to avoid read-back... no thanks!)



I really, really want to confine my madness to a kernel module, and I don't want to have to fiddle with my graphics driver. :S (I'm incidentally using Intel graphics, albeit on an i915)



So, reading through https://dri.freedesktop.org/docs/drm/, I get the idea that maybe I want to try and hack together something that lets me create a dumb framebuffer, create a plane looking at that dumb framebuffer, and then double-maybe set up some kind of DMA-BUF... no, wait, if I've got a plane pointing at the framebuffer, it's already on the screen... I think?



My main question is, how do I play fast and loose with DRM such that it basically tells X it's the only thing talking to the screen, while behind the scenes I'm managing an extra plane?



Answers very greatly appreciated!





My current understanding of Wayland is that it is fundamentally based around compositing, and by design cannot function without buffering one or more entire video frames before releasing it/them to the video card.



While X11 does not have this restriction - COMPOSITE is an optional extension - it uses a stream-based drawing protocol, and I am not aware of any method to draw directly into a window. The closest thing I know of is the use of the MIT-SHM extension, and while this does allow the use of shared memory, that involves at least two memory copies (me->kernel, kernel->X11), and then the poking of an XShmPutImage down the X11 pipe to tell X11 to please flip. This means that, even if I were to make my process run in realtime... well, I'm too chicken to run X in realtime as well, so I'd still have to wait for X to be scheduled, decode and reach my request in its command queue, and finally flip.



Hence my throwing my hands up in the air and trying to see if I can just shove my graphics drawing code straight into the kernel, and hopefully make it all coexist somehow.



I can imagine all of this additional overhead really adds up, and I want to quantify exactly how - or, alternatively, concretely establish that my mental models are completely incorrect and that the speed of contemporary hardware makes these concerns moot.



I am extremely curious to see what the impact would be if I eliminated all the bottlenecks, and also what the difference would be like comparing older systems versus more modern hardware.



Incidentally, this question is related to another question I asked over here and over here, both of which sadly still have no answers, and which I am no further forward on.










share|improve this question

































    1















    I want to draw simple (2D bitmapped) graphics onto my screen (in response to (simple) external inputs) with the lowest latency possible (the order of tens of milliseconds) so I can empirically test the results of drawing to the screen a) in realtime, b) with the least overhead possible, c) with page flipping completely disabled (tearing is fine).



    Then I can compare this with drawing to the screen in various stereotypical (and arguably pathological :) ) scenarios (eg X11, Wayland, Wayland+XWayland, Wayland+XWayland+xcompmgr, etc).



    To this end, how might I modify Linux so that I can draw over the top of my existing X11/Wayland session? Worded differently, yes, I want to fiddle with DRM, a) from inside the kernel, b) while X11 owns the DRM master. :)



    I suspect that a hardware overlay would be the easiest (and most hardware-accelerated!) way to keep X11/Wayland from scribbling over what I'm drawing. (I'm imagining alternatives involving implementing a shadow/write-through framebuffer cache, to avoid read-back... no thanks!)



    I really, really want to confine my madness to a kernel module, and I don't want to have to fiddle with my graphics driver. :S (I'm incidentally using Intel graphics, albeit on an i915)



    So, reading through https://dri.freedesktop.org/docs/drm/, I get the idea that maybe I want to try and hack together something that lets me create a dumb framebuffer, create a plane looking at that dumb framebuffer, and then double-maybe set up some kind of DMA-BUF... no, wait, if I've got a plane pointing at the framebuffer, it's already on the screen... I think?



    My main question is, how do I play fast and loose with DRM such that it basically tells X it's the only thing talking to the screen, while behind the scenes I'm managing an extra plane?



    Answers very greatly appreciated!





    My current understanding of Wayland is that it is fundamentally based around compositing, and by design cannot function without buffering one or more entire video frames before releasing it/them to the video card.



    While X11 does not have this restriction - COMPOSITE is an optional extension - it uses a stream-based drawing protocol, and I am not aware of any method to draw directly into a window. The closest thing I know of is the use of the MIT-SHM extension, and while this does allow the use of shared memory, that involves at least two memory copies (me->kernel, kernel->X11), and then the poking of an XShmPutImage down the X11 pipe to tell X11 to please flip. This means that, even if I were to make my process run in realtime... well, I'm too chicken to run X in realtime as well, so I'd still have to wait for X to be scheduled, decode and reach my request in its command queue, and finally flip.



    Hence my throwing my hands up in the air and trying to see if I can just shove my graphics drawing code straight into the kernel, and hopefully make it all coexist somehow.



    I can imagine all of this additional overhead really adds up, and I want to quantify exactly how - or, alternatively, concretely establish that my mental models are completely incorrect and that the speed of contemporary hardware makes these concerns moot.



    I am extremely curious to see what the impact would be if I eliminated all the bottlenecks, and also what the difference would be like comparing older systems versus more modern hardware.



    Incidentally, this question is related to another question I asked over here and over here, both of which sadly still have no answers, and which I am no further forward on.










    share|improve this question





























      1












      1








      1








      I want to draw simple (2D bitmapped) graphics onto my screen (in response to (simple) external inputs) with the lowest latency possible (the order of tens of milliseconds) so I can empirically test the results of drawing to the screen a) in realtime, b) with the least overhead possible, c) with page flipping completely disabled (tearing is fine).



      Then I can compare this with drawing to the screen in various stereotypical (and arguably pathological :) ) scenarios (eg X11, Wayland, Wayland+XWayland, Wayland+XWayland+xcompmgr, etc).



      To this end, how might I modify Linux so that I can draw over the top of my existing X11/Wayland session? Worded differently, yes, I want to fiddle with DRM, a) from inside the kernel, b) while X11 owns the DRM master. :)



      I suspect that a hardware overlay would be the easiest (and most hardware-accelerated!) way to keep X11/Wayland from scribbling over what I'm drawing. (I'm imagining alternatives involving implementing a shadow/write-through framebuffer cache, to avoid read-back... no thanks!)



      I really, really want to confine my madness to a kernel module, and I don't want to have to fiddle with my graphics driver. :S (I'm incidentally using Intel graphics, albeit on an i915)



      So, reading through https://dri.freedesktop.org/docs/drm/, I get the idea that maybe I want to try and hack together something that lets me create a dumb framebuffer, create a plane looking at that dumb framebuffer, and then double-maybe set up some kind of DMA-BUF... no, wait, if I've got a plane pointing at the framebuffer, it's already on the screen... I think?



      My main question is, how do I play fast and loose with DRM such that it basically tells X it's the only thing talking to the screen, while behind the scenes I'm managing an extra plane?



      Answers very greatly appreciated!





      My current understanding of Wayland is that it is fundamentally based around compositing, and by design cannot function without buffering one or more entire video frames before releasing it/them to the video card.



      While X11 does not have this restriction - COMPOSITE is an optional extension - it uses a stream-based drawing protocol, and I am not aware of any method to draw directly into a window. The closest thing I know of is the use of the MIT-SHM extension, and while this does allow the use of shared memory, that involves at least two memory copies (me->kernel, kernel->X11), and then the poking of an XShmPutImage down the X11 pipe to tell X11 to please flip. This means that, even if I were to make my process run in realtime... well, I'm too chicken to run X in realtime as well, so I'd still have to wait for X to be scheduled, decode and reach my request in its command queue, and finally flip.



      Hence my throwing my hands up in the air and trying to see if I can just shove my graphics drawing code straight into the kernel, and hopefully make it all coexist somehow.



      I can imagine all of this additional overhead really adds up, and I want to quantify exactly how - or, alternatively, concretely establish that my mental models are completely incorrect and that the speed of contemporary hardware makes these concerns moot.



      I am extremely curious to see what the impact would be if I eliminated all the bottlenecks, and also what the difference would be like comparing older systems versus more modern hardware.



      Incidentally, this question is related to another question I asked over here and over here, both of which sadly still have no answers, and which I am no further forward on.










      share|improve this question
















      I want to draw simple (2D bitmapped) graphics onto my screen (in response to (simple) external inputs) with the lowest latency possible (the order of tens of milliseconds) so I can empirically test the results of drawing to the screen a) in realtime, b) with the least overhead possible, c) with page flipping completely disabled (tearing is fine).



      Then I can compare this with drawing to the screen in various stereotypical (and arguably pathological :) ) scenarios (eg X11, Wayland, Wayland+XWayland, Wayland+XWayland+xcompmgr, etc).



      To this end, how might I modify Linux so that I can draw over the top of my existing X11/Wayland session? Worded differently, yes, I want to fiddle with DRM, a) from inside the kernel, b) while X11 owns the DRM master. :)



      I suspect that a hardware overlay would be the easiest (and most hardware-accelerated!) way to keep X11/Wayland from scribbling over what I'm drawing. (I'm imagining alternatives involving implementing a shadow/write-through framebuffer cache, to avoid read-back... no thanks!)



      I really, really want to confine my madness to a kernel module, and I don't want to have to fiddle with my graphics driver. :S (I'm incidentally using Intel graphics, albeit on an i915)



      So, reading through https://dri.freedesktop.org/docs/drm/, I get the idea that maybe I want to try and hack together something that lets me create a dumb framebuffer, create a plane looking at that dumb framebuffer, and then double-maybe set up some kind of DMA-BUF... no, wait, if I've got a plane pointing at the framebuffer, it's already on the screen... I think?



      My main question is, how do I play fast and loose with DRM such that it basically tells X it's the only thing talking to the screen, while behind the scenes I'm managing an extra plane?



      Answers very greatly appreciated!





      My current understanding of Wayland is that it is fundamentally based around compositing, and by design cannot function without buffering one or more entire video frames before releasing it/them to the video card.



      While X11 does not have this restriction - COMPOSITE is an optional extension - it uses a stream-based drawing protocol, and I am not aware of any method to draw directly into a window. The closest thing I know of is the use of the MIT-SHM extension, and while this does allow the use of shared memory, that involves at least two memory copies (me->kernel, kernel->X11), and then the poking of an XShmPutImage down the X11 pipe to tell X11 to please flip. This means that, even if I were to make my process run in realtime... well, I'm too chicken to run X in realtime as well, so I'd still have to wait for X to be scheduled, decode and reach my request in its command queue, and finally flip.



      Hence my throwing my hands up in the air and trying to see if I can just shove my graphics drawing code straight into the kernel, and hopefully make it all coexist somehow.



      I can imagine all of this additional overhead really adds up, and I want to quantify exactly how - or, alternatively, concretely establish that my mental models are completely incorrect and that the speed of contemporary hardware makes these concerns moot.



      I am extremely curious to see what the impact would be if I eliminated all the bottlenecks, and also what the difference would be like comparing older systems versus more modern hardware.



      Incidentally, this question is related to another question I asked over here and over here, both of which sadly still have no answers, and which I am no further forward on.







      linux-kernel x11 framebuffer drm high-performance






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago







      i336_

















      asked 2 days ago









      i336_i336_

      3844 silver badges18 bronze badges




      3844 silver badges18 bronze badges

























          0






          active

          oldest

          votes














          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f535758%2fhow-can-i-display-graphics-on-the-screen-from-the-kernel-over-the-top-of-my-x11%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 Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f535758%2fhow-can-i-display-graphics-on-the-screen-from-the-kernel-over-the-top-of-my-x11%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

          Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

          The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

          Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...