Commit Graph

46 Commits

Author SHA1 Message Date
Eric Anholt 8702c938b3 glamor: Introduce a central place for our pixmap format/type handling.
We had various helper functions trying to come up with the
internalformat/format/type/render formats for pixmaps, and it's much
nicer to just detect what those should be once at startup.  This gives
us a chance to do the right thing for GLES.

It also, notably, fixes our format/type for depth 15 and 16 setup for
desktop GL, so that we actually allocate 16bpp (GL_RGB/565) on most
drivers instead of 32bpp (GL_RGB/UBYTE).

GLES still has regressions over desktop (2 regressions in llvmpipe
XTS, many in rendercheck), but I think this is a good baseline.

Signed-off-by: Eric Anholt <eric@anholt.net>
2019-04-17 19:34:48 +00:00
Eric Anholt c94da112a7 glamor: Plumb the pixmap through fbo creation instead of a "format"
For GLES, we're going to need a lot more logic for picking the
iformat/format/type of texture setup, so we'll want the pixmap's depth
and is_cbcr flag.

Signed-off-by: Eric Anholt <eric@anholt.net>
2019-04-17 19:34:48 +00:00
Eric Anholt 1b2e224d7d glamor: Switch the gl_flavor to a boolean is_gles.
There are only 2 flavors we are distinguishing -- GL versions are
handled separately.

Signed-off-by: Eric Anholt <eric@anholt.net>
2019-04-17 19:34:48 +00:00
Paul Kocialkowski c98c7709c6 glamor: Propagate FBO allocation failure for picture to texture upload
When uploading a picture to a texture, glamor_upload_picture_to_texture
calls glamor_pixmap_ensure_fbo to ensure that there is backing FBO.
The FBO will be allocated if the picture's drawable pixmap does not have
one already, which can fail when there is no GL memory left.

glamor_upload_picture_to_texture checks that the call succeeded and will
enter the failure path if it did not. However, unlike many other
functions in glamor, this one has ret set to TRUE initially, so it needs
to be set to FALSE when a failure happens.

Otherwise, the error is not propagated and the failure path return TRUE.
This leads to a fault when trying to access the FBO pointer later on.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2019-03-08 14:29:40 +01:00
Eric Anholt 0b4c0c75d0 glamor: Replace "finish access" shader with texture swizzling.
For pictures without alpha, and for most other formats for GLES2, we
would make a temporary FBO, make another temporary texture, upload our
GLAMOR_MEMORY pixmap to the texture, then run the "finish access" shader
across it to swizzle its values around into the temporary FBO (which we
would use for a single Render operation and then throw away).

We can simplify everything by using GL_ARB_texture_swizzle (or its
GLES3 counterpart).  It's just not worth the complexity to try to
improve the performance of this already low-performance path (SHM
pixmaps + Render) on GLES2.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt b0cc04992c glamor: Drop dead large-pixmap handling code in temp picture uploads.
The glamor_pixmap_ensure_fbo() in glamor_pixmap_upload_prepare() will
always fail on a large pixmap, so we can just be explicit about
bailing out here and then dump the rest of this garbage.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt 094b1bea8b glamor: Drop unused PBO code in temporary picture uploading.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt 6112fecc3a glamor: Generalize the a1-to-a8 conversion path.
Pixman is quite qualified to allocate our temporary memory, and all we
need to do is decide what formats to convert from and to.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt 8f1411c384 glamor: Drop the REVERT_UPLOADING_1_5_5_5 path.
There was only a pretty special case that could have even worked --
you've got a GLES2 renderer, you've got a SHM pixmap, it's 1555 (not
the usual 565 for 16-bit), and you're little endian (BE was broken,
since GL's 5_5_5_1 picks the 1 bit from the lowest bit of the short,
and on BE we weren't doing the conversion path that swaps around the
channels).  This is just not worth the complexity.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt 2cc7a0815e glamor: Drop the GLES2 REVERT_UPLOADING_2_10_10_10 paths.
These just smash your 2_10_10_10 data into 8888, despite what the
comments said.  That's not valid rendering, so just ditch this path
and fall back to software.  One might also note in the code being
removed here that the REVERT_UPLOADING_10_10_10_2 path wasn't even
connected.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:43 -05:00
Eric Anholt f667d51770 glamor: Merge the two GL-type-from-pictformat paths.
It clarifies what the difference is between the two paths, and would
potentially encourage us to handle GLES extensions that expose
additional types.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:42 -05:00
Eric Anholt c7574c63c6 glamor: Propagate that is_upload is always true.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:42 -05:00
Eric Anholt 1bed5ef2b8 glamor: Drop dead fbo handling from GLAMOR_MEMORY pict uploads.
The previous commit asserts that we don't have one.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:42 -05:00
Eric Anholt ee7ca670b1 glamor: Make sure that GLAMOR_MEMORY pixmaps don't retain an FBO.
glamor_composite_choose_shader() may upload our scratch pixmaps to get
a Render operation completed.  We don't want to hang onto GL memory
for our scratch pixmaps, since we'll just have to reallocate them at a
new w/h next time around, and the contents will be updated as well.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:42 -05:00
Eric Anholt a96c6d4658 glamor: Simplify temporary picture uploading call stack.
glamor_upload_sub_pixmap_to_texture() only had the one caller, so we
can merge it in, fix its silly return value, and propagate a bunch of
constants.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2016-03-10 11:12:42 -05:00
Keith Packard e6754dcb59 glamor: Use GL_RED instead of GL_ALPHA if we have texture_swizzle (v3)
GL_RED is supported by core profiles while GL_ALPHA is not; use GL_RED
for one channel objects (depth 1 to 8), and then swizzle them into the
alpha channel when used as a mask.

[airlied: updated to master, add swizzle to composited glyphs and xv paths]

v2: consolidate setting swizzle into the texture creation code, it
    should work fine there. Handle swizzle when setting color as well.
v3: Fix drawing to a8 with Render (changes by anholt, reviewed by airlied).

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-01-26 12:03:54 -08:00
Dave Airlie 5582ad1b9b glamor: use vbos in gradient/picture code.
This converts two client arrays users to using vbos,
this is necessary to move to using core profile later.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2016-01-21 06:47:35 +10:00
Eric Anholt e7aa4d3c74 glamor: Fix assert failures when fallback picture upload alloc fails.
If the glTexImage (or glTexSubImage) out-of-memories, error out
cleanly so that we can fall back to software.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-11-10 13:55:49 -08:00
Alan Coopersmith c1f5f9022f glamor: Get rid of an extraneous ; at the end of a C source line
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-09-30 10:24:33 -07:00
Eric Anholt 8097c88702 glamor: Drop tracking of the last picture attached to pixmaps.
Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-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 0dbdb83b0d glamor: Use the actual picture's format when uploading memory pixmaps.
The pixmap->picture is just the *last* picture attached to the pixmap,
so you'd potentially be looking at the wrong one when trying to
temporarily upload to avoid a composite fallback.

There's some trickiness in glamor_render.c when we're dealing with the
upload of a GLAMOR_MEMORY pixmap as both the source and mask using
different formats, where we smash the source's format to a new value
so that the mask can use the same uploaded bits.  Dropping most of
that should be safe, since it will be uploaded as the source first, so
the smashed format will still be used.

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-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 1fd11c46aa glamor: Move glamor_render.c pict handling to glamor_picture.c
These functions aren't used by anything else, and are specific to the
temporary-upload-as-a-weird-format path of glamor_render.c, called
through glamor_upload_picture_to_texture().

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 80b6652c9f glamor: Drop a bunch of glamor_priv == NULL checks.
Now that it's always non-null when the pixmap is non-null, we don't
need so much of this.  glamor_get_pixmap_private() itself still
accepts a NULL pixmap and returns NULL, because of glamor_render.c

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2015-07-10 09:42:57 -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 2f80c7791b glamor: Eliminate GLAMOR_SEPARATE_TEXTURE pixmap type
This was only used to signal when we couldn't ask the DDX to draw to a
pixmap; now that we have no DDX-based fallbacks, we don't need to have
this type.

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:01:39 -07:00
Peter Hutterer 732fd7e571 Drop trailing whitespaces
sed -i "s/[ ]\+$//g" **/*.(c|h)

happy reviewing...
git diff -w is an empty diff.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
Keith Packard 15e4d14dfa glamor: Replace fallback preparation code
These offer a simpler and more efficient means for temporarily
transitioning to CPU-accessible memory for fallback implementations.

v2: Do not attempt fallbacks with GLAMOR_DRM_ONLY pixmaps

    glamor cannot transfer pixels for GLAMOR_DRM_ONLY pixmaps using
    glReadPixels and glTexSubImage2D, and so there's no way to perform
    fallback operations with these pixmaps.

v3: Clear ->pbo field when deleting the PBO.  Otherwise, we'd reuse
    the old name next time we fall back on the pixmap, which would
    potentially conflict with some other pixmap that genned a new
    name, or just do a lazy allocation of the name (compat GL context,
    like we currently use) or error out (core GL context, like we hope
    to use some day).  Also, style fixes.  Changes by anholt, acked by
    keithp.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-06-15 22:02:40 +01:00
Eric Anholt 93f1824a0b glamor: Rely on nested mappings to handle src==dst and !prepare bugs.
Now that the core deals with that for us, we can avoid all this extra
carefulness.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17 14:30:56 -07:00
Eric Anholt d63283860a glamor: Pass pixmaps around to unifdef glamor_iformat_for_depth().
v2: Just pass in the PicturePtr to glamor_pict_format_is_compatible()
    (suggestion by keithp)

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-02-14 18:30:01 -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 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
Zhigang Gong b8f0a21882 Silence compilation warnings.
After increase to gcc4.7, it reports more warnings, now
fix them.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Tested-by: Junyan He<junyan.he@linux.intel.com>
2013-12-18 11:23:53 -08:00
Zhigang Gong ace35e408c glamor_largepixmap: first commit for large pixmap.
This is the first commit to add support for large pixmap.
The large here means a pixmap is larger than the texutre's
size limitation thus can't fit into one single texutre.

The previous implementation will simply fallback to use a
in memory pixmap to contain the large pixmap which is
very slow in practice.

The basic idea here is to use an array of texture to hold
the large pixmap. And when we need to get a specific area
of the pixmap, we just need to compute/clip the correct
region and find the corresponding fbo.

We need to implement some auxiliary routines to clip every
rendering operations into small pieces which can fit into
one texture.

The complex part is the transformation/repeat/repeatReflect
and repeat pad and their comination. We will support all of
them step by step.

This commit just add some necessary data structure to represent
the large pixmap, and doesn't change any rendering process.
This commit doesn't add real large pixmap support.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:51 -08:00
Zhigang Gong 5c1f15fac2 Added some copyright and author information.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:51 -08:00
Chris Wilson 556adfa6b9 Fixup glx support
Renaming glamor_priv->dispatch and wrapping the access to
the dispatch table with a function that also ensured the
context was bound.

 dispatch = glamor_get_dispatch(glamor_priv);
 ...
 glamor_put_dispatch(glamor_priv);

So that we catch all places where we attempt to call into GL withouta
context. As an optimisation we can then do glamor_get_context();
glamor_put_context() around the rendering entry points to reduce the
frequency of having to restore the old context. (Along with allowing
the context to be recursively acquired and making the old context part of
the glamor_egl state.)

Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:48 -08:00
Zhigang Gong e03ad27dfb glamor_picture: Fix the wrong order of header file.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:48 -08:00
Zhigang Gong 994a9ff7f5 glamor_create_picture: Fix the format matching method.
We should not simply set a TEXTURE_DRM pixmap to a separated
texture pixmap. If the format is compatible with current fbo
then it is just fine to keep it as TEXTURE_DRM type and we
can safely fallback to DDX layer on it.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong 28fcd7cd01 Rearrange data structure and remove unused fileds.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong 7329414bf2 Silence a compilation warning.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong 057f52a04d Track all picture's drawable pict format.
Even if a picture's pixmap is a pure in memory pixmap, we still need
to track its format. The reason is we may need to upload this drawable
to texture thus we need to know its real picture format.

As to the MACRO to check whether a pixmap is a picture, we should
check whether the priv is non-NULL before we touch its field.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong 27c4c0457d Remove the assertion which is not safe sometimes.
The original version assumes that each drawable pixmap should
have a valid private pixmap pointer. But this is not true after
we create this libglamor. As the DDX layer may create a pure
software drawable pixmap which doesn't have a private pixmap
pointer.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong 8c7fcefb96 glamor-for-ddx: Exports all rendering/drawing functions.
This commit exports all the rest rendering/drawing functions
to the DDX drivers. And introduce some new pixmap type. For
a pixmap which has a separated texture, we never fallback
it to the DDX layer.

This commit also adds the following new functions:
glamor_composite_rects, glamor_get_image_nf which are needed
by UXA framework. Just a simple wrapper function of miXXX.
Will consider to optimize them next few weeks.

This commit also Fixed a glyphs rendering bug pointed by Chris.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -08:00
Zhigang Gong 92fd83872f Remove the access mode from private pixmap structure.
Change the finish_access to pass in the access mode, and remove
the access mode from the pixmap structure. This element should
not be a pixmap's property.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -08:00
Zhigang Gong b5630663cf exports more rendering functions to DDX driver.
Exports all necessary rendering functions to DDx drivers, including
CopyArea, Glyphs, Composite, Triangles, ....

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -08:00
Zhigang Gong b861aad8e2 Initial version.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -08:00
Zhigang Gong 355334fcd9 glamor : Add dynamic texture uploading feature.
Major refactoring.
1. Rewrite the pixmap texture uploading and downloading functions.
   Add some new functions for both the prepare/finish access and
   the new performance feature dynamic texture uploading, which
   could download and upload the current image to/from a private
   texture/fbo. In the uploading or downloading phase, we need to
   handle two things:
   The first is the yInverted option, If it set, then we don't need
   to flip y. If not set, if it is from a dynamic texture uploading
   then we don't need to flip either if the current drawing process
   will flip it latter. If it is from finish_access, then we must
   flip the y axis.

   The second thing is the alpha channel hanlding, if the pixmap's
   format is something like x8a8r8g8, x1r5g5b5 which means it doesn't
   has alpha channel, but it do has those extra bits. Then we need to
   wire those bits to 1.

2. Add almost all the required picture format support.
   This is not as trivial as it looks like. The previous implementation
   only support GL_a8,GL_a8r8g8b8,GL_x8r8g8b8. All the other format,
   we have to fallback to cpu. The reason why we can't simply add those
   other color format is because the exists of picture. one drawable
   pixmap may has one or even more container pictures. The drawable pixmap's
   depth can't map to a specified color format, for example depth 16 can
   mapped to r5g6b5, x1r5g5b5, a1r5g5b5, or even b5g6r5. So we can't get
   get the color format just from the depth value. But the pixmap do not
   has a pict_format element. We have to make a new one in the pixmap
   private data structure. Reroute the CreatePicture to glamor_create_picture
   and then store the picture's format to the pixmap's private structure.

   This is not an ideal solution, as there may be more than one pictures
   refer to the same pixmap. Then we will have trouble. There is an example
   in glamor_composite_with_shader. The source and mask often share the
   same pixmap, but use different picture format. Our current solution is to
   combine those two different picture formats to one which will not lose any
   data. Then change the source's format to this new format and then upload
   the pixmap to texture once. It works. If we fail to find a matched new
   format then we fallback.

   There still is a potential problem, if two pictures refer to the same
   pixmap, and one of them destroy the picture, but the other still remained
   to be used latter. We don't handle that situation currently. To be fixed.

3. Dynamic texture uploading.
   This is a performance feature. Although we don't like the client to hold
   a pixmap data to shared memory and we can't accelerate it. And even worse,
   we may need to fallback all the required pixmaps to cpu memory and then
   process them on CPU. This feature is to mitigate this penalty. When the
   target pixmap has a valid gl fbo attached to it. But the other pixmaps are
   not. Then it will be more efficient to upload the other pixmaps to GPU and
   then do the blitting or rendering on GPU than fallback all the pixmaps to CPU.
   To enable this feature, I experienced a significant performance improvement
   in the Game "Mines" :).

4. Debug facility.
   Modify the debug output mechanism. Now add a new macro:
   glamor_debug_output(_level_, _format_,...) to conditional output some messages
   according to the environment variable GLAMOR_DEBUG. We have the following
   levels currently.
    exports GLAMOR_DEBUG to 3 will enable all the above messages.

5. Changes in pixmap private data structure.
   Add some for the full color format supports and relate it to the pictures which
   already described. Also Add the following new elements:
   gl_fbo - to indicates whether this pixmap is on gpu only.
   gl_tex - to indicates whether the tex is valid and is containing the pixmap's
            image originally.
   As we bring the dynamic pixmap uploading feature, so a cpu memory pixmap may
   also has a valid fbo or tex attached to it. So we will have to use the above
   new element to check it true type.

After this commit, we can pass the rendercheck testing for all the picture formats.
And is much much fater than fallback to cpu when doing rendercheck testing.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:35 +08:00