Commit Graph

69 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
ab68982dcc glamor: Add missing prepares on the GC during fb fallbacks.
We had regressions in CopyPlane reported by xts5, because we were
(successfully!) dereferencing the null pixmap->devPrivate.ptr for a
tile or stipple without having done a prepare.

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
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
f7cd1189d0 glamor: Replace some goofy enum-likes with a real enum.
This unpacks the bitfield into an int size, but my experience has been
that packing bitfields doesn't matter for performance.

v2: Convert more comparisons against numbers or implicit bool
    comparisons to comparisons against the enum names, and fix up some
    comments.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17 14:30:51 -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
9553020b71 glamor: Drop a bunch of GLES2 ifdefs.
Now that we're using epoxy, we can write code using both desktop and
ES symbols and decide what to use at runtime.

v2: Fix a spelling mistake (latter), since the lines were moved
    anyway (noticed by Rémi Cardona).  Fix condition invert in
    glamor_set_composite_texture (caught by Michel Dänzer).

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com> (v1)
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
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
Michel Dänzer
14e02f5132 Don't use glBlitFramebufferEXT for overlapping copies.
According to the GL_EXT_framebuffer_blit spec, the result of doing so is
undefined. But we need well-defined results. :)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2013-12-18 11:23:53 -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
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
90dd6ddbab glamor_copyarea: Fixed a bug introduced by 996194...
Default return value should be FALSE.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:52 -08:00
Zhigang Gong
016995334e copyarea: Cleanup the error handling logic.
Should use ok rather than mixed ok or ret.

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
1035fc72b9 Fixed all unused variables warnings.
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
1f83411c9a glamor_copyarea: Return earlier if have zero nbox.
Almost all callers will check whether the regions is empty
before call to this internal API, but it seems the
glamor_composite_with_copy may call into here with a zero
nbox. A little weird, as the miComputeCompositeRegion return
a Non-NULL, but the region is empty.

Also remove a unecessary glflush.

So let's check it here.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:50 -08:00
Zhigang Gong
8a85071edb glamor_copyarea: Don't access a DRM only pixmap.
As EGL image/gbm only support ARGB8888 image, we don't support
other format. We may change the way to use gbm directly latter.
But now, we have to face this limitation, and thus if a client
create a 16bpp drawable, and call get texture from pixmap then
a copy to here may occur and thus we have to force retur a TRUE
without do nothing.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:50 -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
3add375065 gles2: Fixed color conversion for the formats except 1555 and 2101010.
This patch fixed two major problems when we do the color convesion with
GLES2.

1. lack of necessary formats in FBO pool.
GLES2 has three different possible texture formats, GL_RGBA,
GL_BGRA and GL_ALPHA. Previous implementation only has one bucket
for all the three formats which may reuse a incorrect texture format
when do the cache lookup. After this fix, we can enable fbo safely
when running with GLES2.

2. Refine the format matching method in
glamor_get_tex_format_type_from_pictformat.
If both revertion and swap_rb are needed, for example use GL_RGBA
to represent PICT_b8g8r8a8. Then the downloading and uploading should
be handled differently.

    The picture's format is PICT_b8g8r8a8,
    Then the expecting color layout is as below (little endian):
    0   1       2       3   : address
    a   r       g       b

    Now the in GLES2 the supported color format is GL_RGBA, type is
    GL_UNSIGNED_TYPE, then we need to shuffle the fragment
    color as :
        frag_color = sample(texture).argb;
    before we use glReadPixel to get it back.

    For the uploading process, the shuffle is a revert shuffle.
    We still use GL_RGBA, GL_UNSIGNED_BYTE to upload the color
    to a texture, then let's see
    0   1       2       3   : address
    a   r       g       b   : correct colors
    R   G       B       A   : GL_RGBA with GL_UNSIGNED_BYTE

    Now we need to shuffle again, the mapping rule is
    r = G, g = B, b = A, a = R. Then the uploading shuffle is as
    below:
        frag_color = sample(texture).gbar;

After this commit, gles2 version can pass render check with all
the formats except those 1555/2101010.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:49 -08:00
Zhigang Gong
8012b030c3 glamor_copyarea: Don't use GL_CLAMP_TO_BORDER when GLES2 enabled.
We may need to modify all the shader to handle GL_CLAMP_TO_BORDER
when using GLES2. XXX, for now, we just ignore them.

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
430bc16ca0 GLX: Enable glx support.
If we are using MESA as our GL library, then both xserver's
GLX and glamor are link to the same library. As xserver's
GLX has its own _glapi_get/set_context/dispatch etc, and it
is a simplified version derived from mesa thus is not
sufficient for mesa/egl's dri loader which is used by glamor.

Then if glx module is loaded before glamoregl module, the
initialization of mesa/egl/opengl will not be correct, and
will fail at a very early stage, most likely fail to map
the element buffer.

Two methodis to fix this problem, first is to modify the xserver's
glx's glapi.c to fit mesa's requirement. The second is to put
a glamor.conf as below, to the system's xorg.conf path.

Section "Module"
        Load  "glamoregl"
EndSection

Then glamor will be loaded firstly, and the mesa's libglapi.so
will be used. As current xserver's dispatch table is the same
as mesa's, then the glx's dri loader can work without problem.

We took the second method as it don't need any change to xorg.:)
Although this is not a graceful implementation as it depends
on the xserver's dispatch table and the mesa's dispatch table
is the same and the context set and get is using the same method.
Anyway it works.

As by default, xserver will enable GLX_USE_TLS. But mesa will not
enable it, you may need to enable that when build mesa.

Three pre-requirements to make this glamor version work:

0. Make sure xserver has commit 66e603, if not please pull the latest
   master branch.
1. Rebuild mesa by enable GLX_USE_TLS.
2. Put the glamor.conf to your system's xorg.conf path and make sure
   it loaded prior to glx module.

Preliminary testing shows indirect glxgears works fine.

If user want to use GLES2 for glamor by using MESA, GLX will not
work correctly.

If you are not using normal MESA, for example PVR's private GLES
implementation, then it should be ok to use GLES2 glamor and the
GLX should work as expected. In this commit, I use gbm to check
whether we are using MESA or non-mesa. Maybe not the best way.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:48 -08:00
Chris Wilson
97efbd25fe Use CLAMP_TO_BORDER in copy_n_to_n so we can sample outside of the source
In order to reduce a composite operation to a source, we need to provide
Render semantics for the pixel values of samples outside of the source
pixmap, i.e. they need to be rgba(0, 0, 0, 0). This is provided by using
the CLAMP_TO_BORDER repeat mode, but only if the texture has an alpha
channel.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:48 -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
a65e1c736a Reduce the double check of pixmap's private pointer.
As we now add the checking to the Macro, we don't need to check
the pointer outside the Macro.

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
36d424feae Call glamor_create_pixmap directly in glamor rendering path.
When glamor is rendering pixmaps, and needs to create some
temporary pixmap, it's better to use glamor version create
pixmap directly. As if goes to external DDX's create pixmap,
it may create a external DRM buffer which is not necessary.
All the case within glamor scope is to create a texture only
pixmap or a in memory pixmap.

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
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
1658454dea glamor: Fix the copy of overlaped region in one pixmap.
Originaly, we use fbo blit to handle overlaped region copy.
But GLES2 doesn't support that, just simply copy the needed
region to another texture can fix this problem.

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
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
1f3f3baf14 glamor: Avoid 2D bitblit if possible.
It turns out that the use of fbo blit is one of the root cause
which lead to slow drawing, especially slow filling rects.

We guess there should be a performance bug in the mesa driver
or even in the kernel drm driver. Currently, the only thing
glamor can do is to avoid calling those functions.

We check whether the copy source and destination has overlapped
region, if it has, we have to call fbo blit function. If it has
not, we can load the source texture directly and draw it to the
target texture. We totally don't need the glCopyPixels here, so
remove it.

By apply this patch, the rendering time of firefox-planet-gnome
decrease to 10.4 seconds. At the same platform, uxa driver get 13
seconds. This is the first time we get better performance than
uxa driver.

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
477a54bc9e glamor: Fixed two unintialized warnings.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:46:36 +08:00
Zhigang Gong
1dca5d7b91 glamor: Reduce source pixmap's size.
If the dest pixmap is in texture memory, but source pixmap is not.
Then we need to upload the source pixmap to texture memory. Previous
version will upload the whole source pixmap. This commit preprocess
the source pixmap, and reduce it to a smaller tempory pixmap only
contains the required region.

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