Age | Commit message (Collapse) | Author | Files | Lines |
|
As an existing comment suggests, buffer_to_image() can be inlined into
the video_frame() function. Do this here.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Currently gst-decoder.c manually uploads each video frame provided
by GStreamer. It does this by attaching the DMA-BUF (or making a
DMA-BUF if GStreamer doesn't provide one) to an EGLImage. It then
binds this EGLImage to an external texture sampler target.
The GStreamer "glupload" element can do all this for us and much more.
The glupload element supports many more formats and also checks if
the GPU can directly import these formats, while also handling
converting in shaders if the format is not supported.
While we could add these checks and missing texture format support to
kmscube, that effort would be better spent improving the core GStreamer
glupload, as improvements there benefit all GStreamer users.
The plugin gets better OES_EGL_image_external support starting in
1.24, but as kmscube only requires 1.22 currently we move to using
normal GL_TEXTURE_2D in cube-video.c. We can switch back to
GL_TEXTURE_EXTERNAL_OES when we move to 1.24 if it shows better
performance on some platforms, but so far no platform I have
tested on shows any issue with using regular 2D texture targets.
Switch to using glupload here. The result is less code to maintain in
kmscube while also providing a much greater range of supported formats.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Add an option to write frames to png files. libpng was already
an optional dependency to kmscube and texturator already had that
feature, so we can reuse most of that.
This is mainly useful in the offscreen mode to view the rendered
frames when using a machine without an accessible display, so for
now limit this feature to offscreen.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
|
|
This was originally in the texturator program, but it can be used
as-is to implement write to file in kmscube, so move it common.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
|
|
Upstream Linux disables addfb2 ioctl on big_endian machines on most
drivers. This commit works around that issue.
Signed-off-by: Maya Matuszczyk <maccraft123mc@gmail.com>
|
|
All the cubes can share a common set of vertex data which simplifies
each cube and saves program data. Factor out the common cube vertex
data into a common location.
Also interleave the vertex data which allows for loading this data
to the GPU with a single glBufferData() call. This should also make
the vertex fetching slightly more efficient by keeping the data for
each vertex closer in memory (not that this really matters much, but
it is nice to have example code like this do things the right way).
Lastly, label the data components to more easily see what is going
into each vertex while defining the data structure.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
As we now do not need to set binding locations in-between compiling and
linking our shaders, we can combine these two into one function that
does both. Do this here for all cubes.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
While both specifying the binding location and letting the compiler pick
the location do work, setting the binding manually often leads to bugs
like found in previous patches. Since we do not need to force aliasing
here we can switch to letting the compiler pick. This also allows for
combining compilation and linking as no in-between step of specifying
the binding location is needed.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The pad handle for our "sink" element is already fetched and correctly
unref'd above when setting up the query probe. Use the same for the
event probe.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The 3 cubes: gears, shadertoy, and video all use a second program for
rendering something other than a cube. For the first two they already
use a second VBO for the non-cube vertex data, but video cube aliases
the cube VBO to define vertices for the background rendering. While
this does work, it is easy to define exactly the vertex data we need
and put this in a separate VBO. This helps later if we want to better
split background rendering from cube face rendering.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
When we get to the end of a video a NULL frame is returned, this signals
that we should rebuild the decoder to start a new video. The issue is
after making this new decoder we do not fetch a new frame, which means
a NULL frame EGLImage is set as the texture target. This is usually
harmless and results in a single frame of black video.
Instead fetch a new frame. While here also check that the new decoder
was created successfully.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Vertex attribute information should be setup each draw loop as we switch
shader programs and each may use different attribute information. They
do not currently, but will in a later patch. This is also cleaner as we
should be disabling attribute arrays not used by the current program.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
We do not need to delete and re-generate our texture object at the end of
video, keep the same object. This allows us to set the texture parameters
for this texture object as part of init and not each draw loop.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Instead of setting the viewport each draw loop based on the stored
screen width and height, if we need to modify the viewport for offscreen
rendering, save the current viewport and restore it when done. This
allows us to avoid saving the width and height.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Instead of destroying and re-creating the gear framebuffer each draw loop,
create it once on init and simply re-bind it in each draw loop.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Using a normal texture as the renderbuffer target is actually an
extension and not always available in GLES2.0. Instead we can use
glRenderbufferStorage and glFramebufferRenderbuffer for the same
result here as we do not later make use of the depth buffer as
a texture. This makes this more portable to more basic GLES2.0
implementations.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Without vertex array objects (not available in ES2.0), vertex attributes
are global and so should be setup, enabled, and then disabled around the
draw function that make use of them. This keeps state local to prevent
bugs.
The draw_gear() function already does this, but the cube drawing does not.
Move the vertex attribute setup out of init() and to draw(). This will
prevent any accidental overwriting of vertex attributes should any other
attribute location alias these in a different program (attribute locations
are per-program, but attribute indexes are global!).
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
If we leave depth testing enabled but do not clear the depth buffer then
drawing this cube may end up being masked by the gears' depth buffer.
Since we do not need depth testing when drawing the cube, redisable depth
testing before drawing the cube.
While here, do not enable and disable face culling each draw loop, it is
enabled in setup and can be left enabled.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The attribute name we are looking for is called "in_TexCoord" in the
shader, but we set the bind number for "in_color". This usually works
okay anyway as 2 would be the next available number, but we should
ensure correct behavior by specifying the correct attribute name.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Instead of setting the viewport each draw loop based on the stored
screen width and height, if we need to modify the viewport for offscreen
rendering, save the current viewport and restore it when done. This
allows us to avoid saving the width and height.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The function draw_shadertoy() binds a texture framebuffer object for
rendering the shadertoy onto and then restores the old framebuffer.
But it assumes the old framebuffer object number was 0, which is usually
the case but that is not guaranteed. To be fully correct we should fetch
the current framebuffer number and restore to that.
This exposes another issue that init_shadertoy() rebinds the framebuffer
but never sets it back to the original value. This was masked by the
unconditional binding to 0 in draw_shadertoy(). Now that it doesn't always
rebind to 0, we never rebind to the original. So save and restore the
framebuffer number in init_shadertoy() also.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Vertex attribute information is setup each loop before drawing, no need
to set this up in init as it will be overwritten each draw call anyway.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The texture parameters for this texture object are already setup as
part of init, no need to do these each draw loop. It also was setting
GL_TEXTURE_WRAP_R which is unneeded for 2D textures.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The attribute name we are looking for is called "in_TexCoord" in the
shader, but we set the bind number for "in_color". This usually works
okay anyway as 2 would be the next available number, but we should
ensure correct behavior by specifying the correct attribute name.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The attribute "position" in the shadertoy program should be bound to 0
location, but we call glBindAttribLocation on the cube program instead.
This still tends to work out as 0 is the default lowest binding index,
but we should be explicit here and ensure correct behavior.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
This is enabled on setup and nothing disables it, no need to re-enable
face culling each draw loop. This matches most other cubes.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The clear color is global state that only needs set once. Move this to
the cube init functions and out of the draw loops, only the glClear()
call itself needs done each loop.
Remove the glClear() from the kmscube main function while here as all
cubes already call this as part of their draw loop anyway.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The projection matrix only changes with aspect ratio changes, track the
projection matrix for the current aspect ratio. This allows us to not
recompute it each frame.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The operation of taking the 3x3 matrix starting at 0,0 from a 4x4 matrix
is common enough that it is the default action when casting mat4 to mat3.
So instead of manually building out a 3x3 normal matrix from the modelview
and passing that into the shader, simply have the shader cast the normal
matrix from the already available modelview matrix.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
This timer function and related definitions are only used by the
perfcntrs code, move them out of common.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Only some parts of the esUtils are actually defined in esUtil.c, remove
extra definitions and function declarations from esUtil.h.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
Do as the TODO comment in gst-decoder.c suggests and turn this function
into a common helper.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The FPS code is common for each run loop. Factor this out into
and put in perfcntrs.c.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The call to init_egl() can be made before calling the cube
init function. This allows it to be factored out into a common
location. struct egl is then passed in to each init() for use
as needed; the same as struct gbm.
As the cube init function no longer needs to modify struct egl
outside of setting the draw function, to keep egl const move
the draw call out of egl. It didn't make much sense in here to
begin with and seems to have been placed in this struct out
of convenience. Move the draw function to a new struct of cube
specific data.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
This matches init_gbm() and allows for more refactoring in later patches.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
For a couple cubes we only store the gbm struct to get access to
the screen buffer resolution. Just store the resolution directly.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
These EGL extension are not used in this cube, remove these checks.
Signed-off-by: Andrew Davis <afd@ti.com>
|
|
The gears mode currently depends on either GLES3 or desktop GL to build,
but in both cases without a proper meson dependency check.
It also doesn't really use any features which would require those GL
versions over GLES2, which is already a global dependency of kmscube.
So just change it to use symbols which are available in GLES2 and it
can be built and run in all platforms.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
|
|
On some platforms, `EGLNativeDisplayType` is an int instead of
a pointer, in which case the void pointer will raise
a `-Wint-conversion`.
Let's cast it to the correct type directly.
Closes: https://gitlab.freedesktop.org/mesa/kmscube/-/issues/16
|
|
decodebin3 is no more experimental since GStreamer-1.22:
https://gstreamer.freedesktop.org/releases/1.22
decodebin3 is now prefered to decodebin till GStreamer-1.24:
https://gstreamer.freedesktop.org/releases/1.24
This solves negotiation issues encountered with V4L2 stateless hardware
video decoders when using kmscube video playback option.
Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
|
|
Offscreen renders need an explicit video mode to be passed by the
user. However, when it's missing, current error handling just says that
initialising a DRM device failed, which sounds a bit misleading.
Add a warning message asking for a video mode command line parameter.
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Eric Engestrom <eric@engestrom.ch>
|
|
Since commit 38986c1 (kmscube: add option to run for specified # of frames)
we have the option of running for a given number of frames. This allows
usage for instance in automatic system tests like climate chamber etc.
To allow starting in background without termination from STDIN add a
new option that prevents polling / selecting for console input.
Signed-off-by: Markus Niebel <Markus.Niebel@tq-group.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
|
|
When importing an egl image from a linux dma buf fd, we need to pass
the proper image attributes to eglCreateImageKHR. The modifier check
here should not ignore DRM_FORMAT_MOD_LINEAR when setting
EGL_DMA_BUF_PLANE0_MODIFIER_LO/HI_EXT else the ordering of
samples within a plane will be incorrect, resulting in
incorrect/garbled pixels being presented.
v2: Update code changes to set EGL_DMA_BUF_PLANE0_MODIFIER_LO/HI
whenever an extension exposes modifiers so that INVALID modifiers are
accepted (Daniel Stone)
|
|
Use gears mode with -g or --gears to render gears on each cube face.
Renders gears to texture once and then renders the texture on each face.
Based on cube-tex.c and of course, gears.
|
|
- Add esInvert() function
- Add esTranspose() function
- Rewrite esRotate() function
- Set identity matrix at beginning of esFrustum()
|
|
|
|
This reverts commit f296635648ba31454bfe6a9ff7495f6b28af26ec
|
|
Kmscube currently selects the first connector that has a link status of
connected. Add a command line option to use a specific connector if
more than one connector has a connected link status.
Signed-off-by: Ralph Campbell <ralphcampbell1@gmail.com>
|
|
It is useful to be able to render the kube without touching the KMS. For
example, this allows us to utilise DRM render devices or to measure the
performance without waiting for vblank.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
|
|
Signed-off-by: Eric Engestrom <eric@igalia.com>
|