Commit Graph

49 Commits

Author SHA1 Message Date
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
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
f3f4fc7a65 glamor: Add a screen argument to drop an ifdef from glamor_set_alu().
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
62965d278c glamor: Drop useless glEnable/glDisable(GL_TEXTURE_2D) calls.
Those calls are only for enabling texture handling in the fixed
function pipeline, while everything we do is with shaders.

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
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
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
Zhigang Gong
32a7438bf7 glamor_copyarea: Use blitcopy if current state is not render.
Practically, for pure 2D blit, the blit copy is much faster
than textured copy. For the x11perf copywinwin100, it's about
3x faster. But if we have heavy rendering/compositing, then use
textured copy will get much better (>30%)performance for most
of the cases.

So we simply add a data element to track current state. For
rendering state we use textured copy, otherwise, we use blit
copy.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:53 -08:00
Zhigang Gong
c41d5c79e7 glamor_emit_composite_vert: Optimize to don't do two times vert coping.
We change some macros to put the vert to the vertex buffer
directly when we cacluating it. This way, we can get about
4% performance gain.

This commit also fixed one RepeatPad bug, when we RepeatPad
a not eaxct size fbo. We need to calculate the edge. The edge
should be 1.0 - half point, not 1.0.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:52 -08:00
Zhigang Gong
8ca16754f7 largepixmap: Fix the selfcopy issue.
If the source and destination are the same pixmap/fbo, and we
need to split the copy to small pieces. Then we do need to
consider the sequence of the small pieces when the copy area
has overlaps. This commit take the reverse/upsidedown into
the clipping function, thus it can generate correct sequence
and avoid corruption self copying.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:51 -08:00
Zhigang Gong
e96ea02010 largepixmap: Implement infrastructure for large pixmap.
Added infrastructure for largepixmap, this commit implemented:
1. Create/Destroy large pixmap.
2. Upload/Download large pixmap.
3. Implement basic repeat normal support.
3. tile/fill/copyarea large pixmap get supported.

The most complicated part glamor_composite still not implemented.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:51 -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
8169280464 glamor_set_destination_pixmap_priv_nc: set drawable's width x height.
Previous implementation set the whole fbo's width and height as the
viewpoint. This may increase the numerical error as we may only has
a partial region as the valid pixmap. So add a new marco
pixmap_priv_get_dest_scale to get proper scale factor for the
destination pixmap. For the source/mask pixmap, we still need to
consider the whole fbo's size.

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
Zhigang Gong
9bcddff93b pending_op: Remove the pending operations handling.
We have disabled this feature for a long time, and previous
testing shows that this(pending fill) will not bring observed
performance gain. Now remove it.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:50 -08:00
Zhigang Gong
3e9c35bdcb glamor_set_alu: Fallback for non GXcopy ops with GLES2.
As GLES2 doesn't support LogiOps, we have to fallback
here. GLES2 programing guide's statement is as below:

"In addition, LogicOp is removed as it is very
infrequently used by applications and the OpenGL ES
working group did not get requests from independent
software vendors (ISVs) to support this feature in
OpenGL ES 2.0."

So, I think, fallback here may not a big deal ;).

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:49 -08:00
Zhigang Gong
53387728dd glamor_tile/composite: Modify fs to re-calculate texture coords.
Then we don't need to fixup the larger pixmap to the exact
size, just need to let the shader to re-calculate the correct
texture coords.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:48 -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
91891b3711 glamor_fill/tile: Fixed a tileX/tileY calculation bug.
The previous's calculation is incorrect, now fix it and then
we don't need to fallback at glamor_tile.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Tested-by: Peng Li <peng.li@intel.com>
2013-12-18 11:23:48 -08:00
Zhigang Gong
9c6fd931a6 glamor-fbo-pool: Enable to reuse different size fbo/texture.
Fixup three special cases, one is in tile and the other is in
composite. Both cases are due to repeat texture issue. Maybe
we can refine the shader to recalculate texture coords to
support partial texture's repeating.

The third is when upload a memory pixmap to texture, as now
the texture may not have the exact size as the pixmap, we
should not use the full rect coords.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong
c7e79d6acf glamor-fbo-pool: Implement fbo cache mechanism.
We classify the cache according to the texture's format/width/height.
As openGL doesn't allow us to change a texture's format/width/height
after the internal texture object is already allocated, we can't
just calculate the size and then according ths size to put the
fbo to an bucket which is just like SNA does. We can only put
the fbo to the corresponding format/width/height bucket.

This commit only support the exact size match. The following patch
will remove this restriction, just need to handle the repeat/tile
case when the size is not exactly match.

Should use fls instead of ffs when decide the width/height bucket,
thanks for Chris to point this out.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong
2ff4100849 glamor_fbo: Introduce glamor fbo to manage all the fb/tex.
This is the first patch to implement a fbo/tex pool mechanism which
is like the sna's BO cache list. We firstly need to decopule the
fbo/tex from each pixmap. The new glamor_pixmap_fbo data
structure is for that purpose. It's somehow independent to each
pixmap and can be reused latter by other pixmaps once it's detached
from the current pixmap.

And this commit also slightly change the way to create a
memory pixmap. We will not create a pixmap private data structure
by default, instead we will crete that structure when a memory
pixmap is attaching a fbo to it.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong
d42eb04c29 Remove useless output messages.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong
9ff39e53eb Revert "Disable glamor_tile temporary."
The previous corruption output is caused by GLAMOR/UXA flushing
issue. Now get fixed.

This reverts commit 0d2d3e4f051e48c3499e1c972e012803a8623526.
2013-12-18 11:23:46 -08:00
Zhigang Gong
13ab4d59af Disable glamor_tile temporary.
Enable glamor tile cause corrupted output. Need more investigation.

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
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
b4f265c7f9 glamor: Fallback to software fb when repeat is needed.
Need to be fixed latter. We should not need any fallback here.
But currently, the implementation for repeating tiling is
broken.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +08:00
Zhigang Gong
0eea084db5 glamor: GLES2 doesn't support glEnable/Disable Texture 2D.
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
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
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
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
734b10e9f7 glamor: Fix one typo bug in glamor_tile.
It will return when the destination pixmap has a fbo but will continue
when it doesn't have a fbo.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +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
d7f8b888d0 glamor: For non-supported fill style fallback to fbFill.
The previous implementation will just skip the rendering
which is not good.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:35 +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
d61a13cf3f glamor: Fix and enable tile fill acceleration (aka the root weave). 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
5fadea5d9c glamor: Fix some screen_xy offsets to be the right way around. 2011-09-26 16:46:31 +08:00
Eric Anholt
44e4599b83 glamor: Move planemask to a function in case I decide to fill it in. 2011-09-26 16:46:31 +08:00
Eric Anholt
e3c02c09c1 glamor: Add ALU support to solid, tile, and putimage. 2011-09-26 16:46:31 +08:00
Eric Anholt
16c3b929dd glamor: Add untested support for tile filling. 2011-09-26 16:46:31 +08:00