Commit Graph

200 Commits

Author SHA1 Message Date
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
0dff23d65b glamor: Don't direct call to any gl functions.
Create a new structure glamor_gl_dispatch to hold all the
gl function's pointer and initialize them at run time ,
rather than use them directly. To do this is to avoid
symbol conflicts.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +08:00
Zhigang Gong
1665962270 glamor: Improve glyphs cache mechanism.
This commit applying the latest uxa's glyphs cache mechanism
and give up the old hash based cache algorithm. And the cache
picture now is much larger than the previous one also.

This new algorithm can avoid the hash insert/remove and also
the expensive sha1 checking. It could obtain about 10%
performance gain when rendering glyphs.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +08:00
Zhigang Gong
54c91079d2 glamor-gles2: Add explicit precision qualifiers for gles2.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +08:00
Zhigang Gong
504e03c0b5 glamor: GLES2 doesn't support GL_CLAMP_TO_BORDER.
Simply comments it out. Need revisit latter.

Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
2011-09-26 16:47:01 +08:00
Zhigang Gong
a228effbeb glamor: Remove useless glVertexPointer related code.
As glVertexPointer is not supported by GLES2, I totally
replaced it by VertexAttribArray. This commit remove those
old code.

Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
2011-09-26 16:47:01 +08:00
Zhigang Gong
172e8cfcd4 glamor: Remove GLEW dependency.
Glamor doesn't need to use GLEW. We can parse the extension by
ourself. This patch also fix the fbo size checking from a hard
coded style to a dynamic checking style.

Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
2011-09-26 16:47:01 +08:00
Zhigang Gong
7aecfa245f glamor-es2: Add --enable-glamor-gles2 to build system.
Now, to build a gles2 version of glamor server, we could
use ./autogen.sh --enable-glamor-ddx --enable-glamor-gles2
Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
2011-09-26 16:47:01 +08:00
Zhigang Gong
ee33c947aa glamor-es: Use glVertexAttribPointer to replace glVertexPointer.
As GLES2 doesn't support glVertexPointer.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:01 +08:00
Zhigang Gong
94d884a198 glamor-es2: Fix some non-es2 functions.
ES2.0 doesn't support QUADS and also doesn't support
some EXT APIs. Fix some of them in this commit.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:00 +08:00
Zhigang Gong
98f8ef5f99 glamor: Change to use official APIs rather than ARB version function.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:00 +08:00
Zhigang Gong
0ef1698be2 glamor: Fix one bug for Xephyr.
Xephyr doesn't has a bounded valid texture. It seems that we can't
load texture 0 directly sometimes. Especially in the copyarea, function
if that is the case, we prefer to use fbo blit to read the screen pixmap
rather than load the bound texture.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:00 +08:00
Zhigang Gong
5c4d53c512 glamor: Implement delayed solid filling.
When we need to solid fill an entire pixmap with a specific color,
we do not need to draw it immediately. We can defer it to the
following occasions:

1. The pixmap will be used as source, then we can just use a shader
   to instead of one copyarea.
2. The pixmap will be used as target, then we can do the filling
   just before drawing new pixel onto it. The filling and drawing
   will have the same target texture, we can save one time of
   fbo context switching.

Actually, for the 2nd case, we have opportunity to further optimize
it. We can just fill the untouched region.

By applying this patch, the cairo-trace for the firefox-planet-gnome's
rendering time decrease to 14seconds from 16 seconds.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:00 +08:00
Zhigang Gong
77ecd36693 glamor: We don't need to check format in compositing.
We already handle all format checking in pixmap uploading and
converting, don't need to do that again.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
da66a76f27 Revert "glamor: Don't need to read dest if op is SRC or CLEAR."
This reverts commit eb16fe0b7c8ea27b5cf9122d02e48bf585495228.
As currently glamor_prepare_access/finish_access will touch
the whole pixmap, not just the request region, then write only
mode will not work correctly. We may need to revisit all fallback
case, and convert the image to the right size before do the
prepare/finish processing.

Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
ca614860fa glamor: convert if too large source or mask .
Some strange web page has 20000*1 png picture, and actually only use
partial of it. We force to convert it to a actuall size rather than
its original size,if it is the case. Then to avoid latter's failure
uploading.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
1444fed4a8 glamor: silence compilation warnings.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
61e1ad3972 glamor: Reduce source or mask picture size if possible.
If we only need a short part of the source or mask's drawable
pixmap, we can convert it to a new small picture before
call to the low level compositing function. Then it will only
upload the smaller picture latter.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
8890b38857 glamor: Don't map the vbo to system memory.
Access mapped vbo address is too slow. And by use system memory
directly, rgb10text/aa10text increases from 980K/1160K to 117K/140K.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
c303949aab glamor: Reduce one extra copy in glamor_trapezoids.
This reduce the time when running cairo-performance-trace with
the firefox-planet-gnome.trace from 23.5 seconds to 21.5 seconds.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
cbedfe7513 glamor: Don't need to read dest if op is SRC or CLEAR.
Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
2011-09-26 16:46:35 +08:00
Zhigang Gong
b8e692d94e glamor: Move the blend set up after the pixmap uploading.
This is a bug, as if we do blend set up before do the pixmap
dynamic uploading. We will have a incorrect blend env when
doing the uploading.

Signed-off-by: Zhigang Gong <zhigang.gong@gmail.com>
2011-09-26 16:46:35 +08:00
Zhigang Gong
ca36ada041 glamor: Don't always fallback everything when change window attr.
Change the glamor_change_window_attributes's handling. We don't need
to fallback every thing to cpu at the beginning. Only when there
is a real need to change the pixmap's format, we need to do something.
Otherwise, we need do nothing here.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:35 +08:00
Zhigang Gong
ca1908e11d glamor: Concentrate and reduce some coords processing code.
Concentrate the verties and texture coords processing code to a new
file glamor_utils.h. Change most of the code to macro. Will have some
performance benefit on slow machine. And reduce most of the duplicate
code when calculate the normalized coords.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:35 +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
Zhigang Gong
3c44e3e0ce glamor: Optimize composite when soure/mask is xrgb.
Added a new shader aswizlle_prog to wired the alpha to 1 when
the image color depth is 24 (xrgb). Then we don't need to fallback
the xrgb source/mask to software composite in render phase. Also
don't wire the alpha bit to 1 in the render phase. This can get
about 2x performance gain with the cairo performance trace's
firefox-planet case.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:35 +08:00
Zhigang Gong
c97d4533f2 glamor: Silent compilation warnings due to some deprecated APIs.
those xcalloc/xfree/xalloc/XNFprintf/... are deprecated. Replace
then with the new one. And fix some other minor problems.
2011-09-26 16:46:34 +08:00
Zhigang Gong
eb3487a448 glamor: Add new feature which is to flip output on y axis.
Due to the coordinate system on EGL is different from FBO
object. To support EGL surface well, we add this new feature.
When calling glamor_init from EGL ddx driver, it should use
the new flag GLAMOR_INVERTED_Y_AXIS.
2011-09-26 16:46:34 +08:00
Eric Anholt
60775e21e3 glamor: Use a VBO to accumulate multiple glyph quads at once.
This increases us from 23000 to 27000/sec on rgb24text.
2011-09-26 16:46:34 +08:00
Eric Anholt
8ce312e619 glamor: Use glamor_composite_with_shader once per group of glyphs.
This shaves CPU time in GL setup.  Performance of rgb24text went from
18400/sec to 23500/sec.
2011-09-26 16:46:34 +08:00
Eric Anholt
6ce05e0b28 glamor: Convert the shaders path to handling glamor_composite_rect_t. 2011-09-26 16:46:34 +08:00
Eric Anholt
858ce0c192 glamor: Add support for component alpha rendering.
Brings x11perf -rgb24text from 230/sec to 18400/sec
2011-09-26 16:46:34 +08:00
Eric Anholt
d07fc66a05 glamor: Rework shader setup to make extending the IN types easier. 2011-09-26 16:46:33 +08:00
Eric Anholt
5f5c35b56d glamor: Fix up the fallback message for no texture present on compositing. 2011-09-26 16:46:33 +08:00
Eric Anholt
2fa95725d8 glamor: Add support for a1 composite sources.
They're stored just like a8, but the values are set to either 0.0 or
1.0.  Because they're a8 with only two legal values, we can't use them
as destinations, but nobody's rendering to a1 dests anyway (we hope).
2011-09-26 16:46:33 +08:00
Eric Anholt
2ba634fab9 glamor: Fix render source transforms.
Fixes (except for small bit differences) cairo source-pattern.
2011-09-26 16:46:33 +08:00
Eric Anholt
be82a06242 glamor: Fix screen_x/screen_y handling for compositing.
It's not an offset from pixmap coords to composited pixmap coords,
it's an offset from screen-relative window drawable coords to
composited pixmap coords.
2011-09-26 16:46:33 +08:00
Eric Anholt
0565c1d789 glamor: Add support for accel of x8r8g8b8 source pictures.
There's a limitation still for RepeatNone, but this fixes a bunch of
fallbacks for gnome-terminal.
2011-09-26 16:46:33 +08:00
Eric Anholt
be64167fea glamor: Don't try to CopyArea from a Solid source picture.
Fixes failure with rendercheck.
2011-09-26 16:46:33 +08:00
Eric Anholt
126fc09cb5 glamor: Rework the Render shader setup to be easily modified, like cairo-gl. 2011-09-26 16:46:33 +08:00
Eric Anholt
f4a3194837 glamor: Add the glyph cache from UXA (de-camelCased).
This doesn't yet have an optimized glamor_composite_rects()
implementation, but it does triple the speed of x11perf -aa10text.
2011-09-26 16:46:33 +08:00
Eric Anholt
7e6432e7b9 glamor: Fix up and enable accelerated composite. 2011-09-26 16:46:33 +08:00
Eric Anholt
15e58b5ffb glamor: Split the copy path out into its own function. 2011-09-26 16:46:33 +08:00
Eric Anholt
ad67299fa2 glamor: Provide more information about the operands to fallback composites. 2011-09-26 16:46:33 +08:00
Eric Anholt
4811e428a9 glamor: Pull in UXA code for dumping some composites down to copy_n_to_n.
Window dragging with metacity+gnome-terminal+xcompmgr is almost credible.
2011-09-26 16:46:33 +08:00
Eric Anholt
d8d3fa1034 glamor: All the fallbacks in the world.
Bringup is really not flying when I can't see anything.  So dump back
to all software so I can turn on a bit at a time.
2011-09-26 16:46:32 +08:00
Eric Anholt
e9d4794cd0 glamor: Add fallbacks for Render. 2011-09-26 16:46:32 +08:00
Eric Anholt
5915b4c0cf glamor: Add support for solid source pictures. 2011-09-26 16:46:32 +08:00
Eric Anholt
aa13306974 glamor: Start adding render acceleration support.
This brings in idr's glu3 code.  We'll probably want to move to linking to
it as a library, once an ABI-stable release is out.
2011-09-26 16:46:31 +08:00