Commit Graph

38 Commits

Author SHA1 Message Date
Andrea Cavalli ea5e7c688e Test 2021-09-12 16:41:24 +02:00
Michel Dänzer add3df2001 Consolidate fourcc.h
Move the copy in hw/xfree86/common to include/, and remove the one in
hw/kdrive/src/.

Fixes DIX glamor code including an xfree86 DDX header.
2020-09-15 11:43:16 +02:00
Julien Isorce f4115bcc8c glamor: add support for NV12 in Xv
Useful when video decoders only output NV12. Currently
glamor Xv only supports I420 and YV12.

Note that Intel's sna supports I420, YV12, YUY2, UYVY, NV12.

Test: xvinfo | grep NV12
Test: gst-launch-1.0 videotestsrc ! video/x-raw, format=NV12 ! xvimagesink

v2: Combine the two texture2Ds on u_sampler.

Signed-off-by: Julien Isorce <jisorce@oblong.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-11 15:54:57 -04:00
David Woodhouse 12a6b189fb glamor: fix glamor_xv_query_image_attributes() for odd-width images
Images which are one pixel wider than a multiple of 8 are being handled
incorrectly. Other drivers round up the width to a multiple of two
before they start calculating. Do the same.

https://bugzilla.gnome.org/show_bug.cgi?id=795235

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2018-04-17 17:30:16 -04:00
Corentin Rossignon dbfbe58b94 glamor: Specify GLSL version for xv shader
SAMPLE is a GLSL keyword in newer OpenGL version.
This fix issue with gnome-shell and playing video using xv

Signed-off-by: Corentin Rossignon <corentin.rossignon@gmail.com>
Bugzilla: https://bugs.freedesktop.org/104405
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-01-08 14:46:20 -05:00
Olivier Fourdan 7bfb87a213 glamor: an FBO is not needed for Xv pixmaps
It appears that on some hardware/diver combo such as nv30/nouveau, using
GL_ALPHA as format for 8-bit depth will cause an incomplete attachment
error (GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) when trying to bind the
texture.

As a result, the FBO is NULL and glamor segfaults when trying to access
the FBO width/height in pixmap_priv_get_scale() in glamor_xv_render().

This happens with glamor-xv which uses 8-bit pixmaps, meaning that on
such hardware/driver, trying to play a video using Xv will lead to a
crash of the Xserver. This affects Xwayland, Xephyr, modesetting driver
with glamor accel.

But the use of an FBO is not actually needed for glamox-xv, so by
disabling FBO at pixmap creation, we can avoid the issue entirely.

Fix suggested by Eric Anholt <eric@anholt.net>

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=100710
Fixes: https://bugzilla.redhat.com/1412814
Reviewed-by: Eric Anholt <eric@anholt.net>
2017-04-21 11:53:13 -07:00
Hans de Goede 947e94a341 glamor: Fix XvPutImage when src_y != 0
We already take src_y into account when uploading the src data by
starting at the top line of the src data when uploading.

Adjust src_y accordingly when rendering.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-03-08 13:05:38 -05:00
Eric Anholt 07f0d90e4a glamor: Simplify the pixmap box looping.
We had a double loop across h and w, and passed the current x and y
out to callers who then used w to multiply/add to an index.  Instead,
just single loop across w * h.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29 18:13:09 -08:00
Eric Anholt 03f34f8556 glamor: Convert XV to using glamor_program.c.
One less custom path!  By following the common glamor_program.c use
pattern, we get the ability to handle large pixmaps as the
destination.  It's also one less place where glamor_utils.h coordinate
transformation happens.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29 18:13:04 -08:00
Eric Anholt f368a0ba3a glamor: Simplify XV vertex setup.
We were clipping the drawn rectangle to each clip box, then expanding
the box to a big triangle to avoid tearing, then drawing each triangle
to the destination through a scissor.  If we're using a scissor for
clipping, though, then we don't need to clip the drawn primitive on
the CPU in the first place.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29 18:13:01 -08:00
Eric Anholt 294e45b60d glamor: Set up XV sampler uniforms once at program build time.
No sense doing it on every draw.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-01-29 18:12:57 -08:00
Dave Airlie d99204fb5e glamor/xv: add vbo support (v2.1)
This converts the Xv code to using VBOs instead of
client ptrs. This is necessary to move towards using
the core profile later.

v2: put all boxes into single vbo, use draw arrays
to offset things. (Eric)
v2.1: brown paper bag with releasing vbo.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2016-01-21 06:47:41 +10:00
Eric Anholt b51e079e18 glamor: Use the new upload/download interface for XV uploads.
We don't need any of its weird handling of picture formats, since our
XV pixmaps don't have any pictures attached.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2015-07-10 09:42:58 -07:00
Eric Anholt 6ba6cc57e1 glamor: Just set the logic op to what we want at the start of all rendering.
By dropping the unconditional logic op disable at the end of
rendering, this fixes GL errors being thrown in GLES2 contexts (which
don't have logic ops).  On desktop, this also means a little less
overhead per draw call from taking one less trip through the
glEnable/glDisable switch statement of doom in Mesa.

The exchange here is that we end up taking a trip through it in the
XV, Render, and gradient-generation paths.  If the glEnable() is
actually costly, we should probably cache our logic op state in our
screen, since there's no way the GL could make that switch statement
as cheap as the caller caching it would be.

v2: Don't forget to set the logic op in Xephyr's drawing.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-03-24 12:43:34 -07:00
Keith Packard 020fcc5828 glamor: Eliminate separate 'large' pixmap private structure
Just embed the large elements in the regular pixmap private and
collapse the union to a single struct.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24 12:34:50 -07:00
Keith Packard af687396f1 glamor: Remove screen private and pixmap ptrs from pixmap private and fbo
There's no reason to waste memory storing redundant copies of the same
pointer all over the system; just pass in pointers as necessary to
each function.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-03-24 12:32:46 -07:00
Keith Packard d723928870 glamor: Fix nlines in glamor_xv_put_image when src_y is odd
The number of lines of video to update in the texture needs to be
computed from the height of the updated source, not the full height of
the source.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-12-28 15:12:33 -08:00
Michel Dänzer 70a6f65f9e glamor: Make sure Xvideo source image data is properly aligned
_glamor_upload_bits_to_pixmap_texture currently ignores the stride
parameter, but __glamor_upload_pixmap_to_texture uses 4-byte alignment
via glPixelStorei(GL_UNPACK_ALIGNMENT, 4).

Also fix up the stride argument passed in though, in case it starts
being used properly in the future.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87455
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-12-25 13:30:16 -08:00
Keith Packard d4111239e6 glamor: Free Xv put image data immediately after use
The Xv StopVideo callback is not invoked on textured video ports, so
the temporary pixmaps allocated for the video planes are never freed.

Freeing the storage immediately after use is a simple solution to this
problem which doesn't appear to have any visible performance impact.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-08-17 14:17:30 -07:00
Keith Packard 8a60d1c3f4 glamor: Eliminate diagonal tearing in xv
This uses a single large triangle and a scissor to draw the video
instead of two triangles.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2014-07-28 13:12:52 -07:00
Eric Anholt e310387f44 glamor: Remove always-true yInverted flag.
All users of glamor had the same value set, and it complicated things
for no reason.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-07-17 17:35:38 -07:00
Eric Anholt 98b6158bc1 glamor: Share code for put_image handling.
The difference between the two is that XF86 has the clip helper that
lets you upload less data when rendering video that's clipped.  I
don't think that's really worth the trouble, especially in a world of
compositors, so I've dropped it to get to shared code.

It turns out the clipping code was broken on xf86-video-intel anyway.
To reproduce, run without a compositor, and use another window to clip
the top half of your XV output on the glamor XV adaptor: the rendering
got confused about which half of the window was being drawn to.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-06-15 23:20:09 +01:00
Eric Anholt 65efc14b6a glamor: Split the XV code into XF86-dependent parts and generic.
I want to expose this from Xephyr as well, both to be able to test XV
changes rapidly, and beause the XV passthrough to the host's overlay
really doesn't work out well when we glXSwapBuffers() over the
colorkey.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-06-15 23:20:02 +01:00
Eric Anholt fab0a4a4c9 glamor: Replace glamor_get/put_context() with just glamor_make_current().
Now that we have the DIX global state for the current context, we
don't need to track nesting to try to reduce MakeCurrent overhead.

v2: Fix a mistaken replacement of a put_context with make_current in
    glamor_fill_spans_gl() (caught by keithp).

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com> (v1)
2014-04-23 10:32:23 -07:00
Keith Packard 6aac97198f glamor: Initialize XV shaders from glamor_xv_init instead of glamor_init
The glamor_init calls to glamor_init_xv_shader were never getting run
because GLAMOR_XV was never defined. Instead of trying to make that
work, fix glamor_xv_init to make the call instead.

Further, just get rid of the glamor_fini_xv_shader function entirely
as the shader program will be destroyed when the context is destroyed
at server reset time.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-04-03 13:07:51 -07:00
Markus Wick 9999a66013 glamor: don't reset the GLSL program
We don't use fixed function rendering, so there is no need to reset
the program at all.  This lets the driver avoid checking for state
changes between draw calls when we rebind the same program.

Improves xephyr x11perf -f8text performance by 6.03062% +/- 1.64928%
(n=20)

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-03-17 14:30:58 -07:00
Eric Anholt 1a4b249939 glamor: Apply debug labels to our shaders.
This will help tools like fips, apitrace, or INTEL_DEBUG=shader_time
provide useful information about the shaders in use.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17 14:30:57 -07:00
Eric Anholt 2d20f75b60 xorg: Connect up the glamor XV code, xorg DDX-only for now.
Porting this code to be non-xorg-dependent is going to take
significant hacking, so just dump it in the glamoregl module for the
moment, so I can hack on it while regression testing.

v2: Fix compiler warnings by adding #include dix-config.h at the top,
    don't try to auto-init (I'll try to fix the xv ABI later).
v3: Fix last minute breakage of having reintroduced xf86ScrnToScreen
    (one of the compat macros).  Just use the drawable's pScreen instead.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-03-05 13:10:20 -08:00
Eric Anholt 781c692cf9 glamor: Rename glamor_get/put_dispatch to glamor_get/put_context.
It used to be the thing that returned your dispatch table and happeend
to set up the context, but now it just sets up the context.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-14 18:29:56 -08:00
Eric Anholt 0373b3f4f7 glamor: Convert to using libepoxy.
Libepoxy hides all the GL versus GLES2 dispatch handling for us, with
higher performance.

v2: Squash in the later patch to drop the later of two repeated
    glamor_get_dispatch()es instead (caught by keithp)

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-14 18:28:56 -08:00
Eric Anholt 54e78ec31e glamor: Convert use of the old "pointer" typedef to "void *".
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27 09:30:47 -08:00
Eric Anholt 7759e4d090 glamor: Disable the XV code for now.
We're going to want to make this DIX code instead of XF86 if at all
possible, but for now just disable it so we can work on the rest of
the build.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27 09:30:47 -08:00
Eric Anholt 7f6e865359 glamor: Fix some indent damage of putting a ' ' after the '*' for pointers.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27 09:30:47 -08:00
Eric Anholt 5f57d436c3 glamor: Fix some mangling of shader strings by indent.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27 09:30:47 -08:00
Eric Anholt d84d71029a glamor: Apply x-indent.sh.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27 09:30:47 -08:00
Dave Airlie b8055bd1f6 glamor: fix leak in xv code.
This loop needed to go one higher, not sure if this fixes the leak
MrCooper was seeing on irc, but it fixes a leak.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:54 -08:00
Fabio Pedretti 403004fe79 glamor: remove unused variable
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:54 -08:00
Dave Airlie e3d1d4e3ca glamor: add initial Xv support
This does YV12 and I420 for now, not sure if we can do packed without
a GL extension.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2013-12-18 11:23:54 -08:00