Mailing List Archive

OpenGL questions
Hi Mark

I am trying to learn OpenGL by going through some tutorials and
examples. Would you mind answering a basic question?

Which version or versions of OpenGL and GLSL do we target in MythTV?

It looks like you do not use the #version specifier. Then OpenGL assumes
it is using GLSL version 1.10 from 2004 (OpenGL 2.0) and OpenGL ES
assumes GLSL version 1.00 from 2009 (OpenGL ES 2.0). Is that what we are
using? Do we build everything to be compatible with both of these? Those
versions seem like ancient history?

Any tips you may have regarding OpenGL for a beginner would be welcome.

Regards
Peter
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: OpenGL questions [ In reply to ]
On Fri, 29 Mar 2019 at 18:55, Peter Bennett <pb.mythtv@gmail.com> wrote:
>
> Hi Mark1 - general OpenGL state management
>
> I am trying to learn OpenGL by going through some tutorials and
> examples. Would you mind answering a basic question?
>
> Which version or versions of OpenGL and GLSL do we target in MythTV?
>
> It looks like you do not use the #version specifier. Then OpenGL assumes
> it is using GLSL version 1.10 from 2004 (OpenGL 2.0) and OpenGL ES
> assumes GLSL version 1.00 from 2009 (OpenGL ES 2.0). Is that what we are
> using? Do we build everything to be compatible with both of these? Those
> versions seem like ancient history?

Hi Peter,

We essentially target the lowest common denominator. At the moment,
that is OpenGL 2.0/ ES 2.0.

There are a number of reasons for this - all referencing the
devel/2019-render branch, where the code has obviously moved on
considerably:-

1 - In general, we do not need anything above and beyond those versions.
2 - There are still platforms that only support those versions (e.g.
Pi, some mesa drivers)
3 - Qt provides QOpenGLContext, QOpenGLFunctions etc that provide a
simple/convenient wrapper around a common subset of GL2.0 and GL ES2.0
functionality.

On point 1, our OpenGL needs are quite basic. For the most part we
only want to render textures on screen. We are not interested in
occlusion culling, geometry shaders, instancing and a hundred and one
more modern, advanced features that newer versions offer and which are
largely targeted at gaming or CAD demands (and indeed a hundred and
one old, basic features that are irrelevant). Whilst GLSL has evolved,
its core functionality is unchanged and a lot of the incompatibility
between older and newer versions is syntax rather than functionality
(for our uses at least). Yes, we use some more 'modern' functionality
where available but generally this is available by extension on the
older versions anyway. The raspberry pi driver is rapidly becoming the
real exception to this as it has, by a large margin, the most limited
feature set (and performance) of anything I've seen for a couple of
years.

That said, I'm quite sure there are gains to be had from tapping into
some of the newer features but I think, once the render branch has
stabilised (and is merged), the next effort should be Vulkan support.

> Any tips you may have regarding OpenGL for a beginner would be welcome.

Focusing purely on the MythTV use case, there are 4 areas of core
functionality that are relevant:-

1 - General OpenGL state management
- mostly handled in MythRenderOpenGL. viewport management, texture
binding, shader binding, blend state etc etc. All fairly standard.
2 - vertex data
- very simple for our use case - simply upload enough vertex data to
render a square/rectangle.
3 - textures
- core to both video and UI. Essentially pretty standard for UI (and
now largely handled by Qt) with some more demanding use cases for
video. A performance bottleneck.
4 - shaders
- obviously key to any modern OpenGL code. You'll see though that for
the most part our shaders are extremely simple - especially for just
rendering an RGBA texture on screen.
- the circle shaders etc are slighly more complicated as are the deinterlacers.

I'd recommend just focusing on GL2.0/ES2.0 to start with. Trying to
cross-reference GLSL4.6 shaders will just give you headaches:)
Everything then just builds on those basics.

I'd also highly recommend installing apitrace (and qapitrace - the gui
part). This will produce a trace of all of the OpenGL/GLX/EGL calls
that an app makes on a frame by frame basis.
If you run mythtv from the render branch with -v gpu logging, it will
also insert debug markers showing you which parts of the mythtv render
code are making those calls. At its most basic, the trace will give
you a very neat insight into how the OpenGL code is working. It won't
however provide much help with what's going on inside a shader...

I hope this helps. Any questions, just ask.
regards
Mark
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: OpenGL questions [ In reply to ]
On 3/31/19 5:56 AM, Mark Kendall wrote:
<snip>

Hi Mark

Thank you for the detailed reply.

I am building and testing some of the sample OpenGL programs., and I am
using apitrace to see what is going on.

One interesting thing I found - A sample program that uses QOpenGLWidget
to display a window with just a triangle does hundreds of OpenGL calls
that are not generated by the user code. Apart from displaying the
triangle, it uses two textures and hundreds of other calls, plus some
extra shaders that are not in the user code.

On the other hand a sample that uses QWindow and QOpenGLFunctions to
display a triangle does not create any extra textures or shaders and
seems to only generate the OpenGL code that is requested by the user code.

I have not yet tried QOpenGLWindow, I don't know how it compares to
QWindow or OpenGLWidget.

Regards
Peter


_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org