Commit Graph

106 Commits

Author SHA1 Message Date
Kristian Høgsberg d148034375 glamor: Add new GLAMOR_CREATE_PIXMAP_NO_TEXTURE pixmap create flag
This flag lets a DDX allocate a glamor pixmap without allocating the
texture that backs it.  The DDX can then allocate the texture itself
and then set it later.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-04-01 10:31:09 -07:00
Kristian Høgsberg fe204185bc glamor: Move glamor_egl_screen_init() prototype to glamor.h
A DDX that implements the glamor EGL functions need to pull in this
prototype but shouldn't need to pull in glamor_priv.h

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-04-01 10:31:09 -07:00
Keith Packard 82f91433e2 glamor: Get testing code using small FBOs working again
Glamor has a mode where pixmaps will be constructed from numerous
small FBOs. This allows testing of the tiled pixmap code without
needing to create huge pixmaps.

However, the render glyph code assumed that it could create a pixmap
large enough for the glyph atlas. Instead of attempting to fix that
(which would be disruptive and not helpful), I've added a new pixmap
creation usage, GLAMOR_CREATE_NO_LARGE which forces allocation of a
single large FBO.

Now that we have pixmaps with varying FBO sizes, I then went around
and fixed the few places using the global FBO max size and replaced
that with the per-pixmap FBO tiling sizes, which were already present
in each large pixmap.

Xephyr has been changed to pass GLAMOR_CREATE_NO_LARGE when it creates
the screen pixmap as it doesn't want to deal with tiling either.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-03-26 12:58:40 -07:00
Eric Anholt e23dd41195 glamor: Return the stride/size for glamor_dri3_name_from_pixmap(), too.
Just like for a caller of glamor_dri3_fd_from_pixmap(), otherwise the
consumer of that named buffer has no idea what GL chose for the
stride.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17 14:30:49 -07:00
Eric Anholt 4e21b7ee49 glamor: Drop the body of the function for enabling DRI3 extensions.
The flag is already being set at glamor_egl_screen_init() time, so no
need for the driver to separately call this.  That said, leave the
function around to keep the ABI compatibility.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17 14:30:49 -07:00
Eric Anholt 12b2adaaeb glamor: Do glyph private init at screeninit time, and other stuff at CSR.
This hasn't actually been a problem, since the server hasn't allocated
any glyphs before our glyph private initialization during
CreateScreenResources.  But it's generally not X Server style to do
things this way.

Now that glamor itself drives both parts of glyphs setup, DDX drivers
no longer need to tell glamor to initialize glyphs.  We do retain the
old public symbol so they can keep running with no changes.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17 14:30:45 -07:00
Eric Anholt d310d566b1 glamor: Extract the streamed vertex data code used by Render.
We should be uploading any vertex data using this kind of upload
style, since it saves a bunch of extra copies of our vertex data.

v2:
  - Add a simple comment about what the function does.
  - Use get_vbo_space()'s return in trapezoids, instead of dereffing
    glamor_priv->vb (by Markus Wick).
  - Fix the double-unmapping by moving put_vbo_space() outside of
    flush_composite_rects().
  - Remove the rest of the composite_vbo_offset usage, and just always
    use get_vbo_space()'s return value.
v3:
  - Fix failure to put_vbo_space in traps when no prims were
    generated.
  - Unbind the VBO from put_vbo_space().  Keeps callers from
    forgetting to do so.
v4:
  - Split out some changes into the previous 3 commits while trying to
    track down a regression.
  - Fix regression due to rebase fail where glamor_priv->vbo_offset
    wasn't incremented.
v5:
  - Fix GLES2 VBO sizing.
  - Add a comment about resize behavior.
  - Move glamor_vbo.c init code to glamor_vbo.c from
    glamor_render.c. (Derived from Markus's changes, but the GLES2 fix
    dropped almost all of the code in the functions).
v6:
  - Drop the initial BufferData on GLES2 (it happens at put() time).
  - Don't forget to set vbo_offset to the size on GLES2.
  - Use char * instead of void * in the cast to return the vbo_offset.
  - Resize the default FBO to 512kb, to be similar to previous
    behavior.  +1.66124% +/- 0.284223% (n=679) on aa10text.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus at selfnet.de>
2014-03-10 13:57:21 -07:00
Eric Anholt da08316605 glamor: Add support for DRI3.
The render-nodes case is untested.

v2: Add a flag for wayland to suppress the native DRI3 support.
    Wayland isn't running as a master itself, so it can't do the auth
    on its own and has to ask the compositor to do it for us.  Dropped
    XXX about randr provider -- the conclusion from discussion with
    keithp was that if the driver's dri3_open for a provider on a
    different screen, that's a core dri3 bug.
v3: Don't put quite so much under GLAMOR_NO_DRI3, and add a comment
    explaining what this is about.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-03-05 13:10:24 -08:00
Eric Anholt fb4a1e6ef6 glamor: Rename the DRI-related pixmap functions.
There was confusion over whether they should have egl in the name, and
they had DRI3 in the name even though they're useful to have without
DRI3.

v2: Just rename glamor_name_from_pixmap for now -- I'd accidentally
    conflict-resolved in adding new parameters from a later commit.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-03-05 13:10:22 -08: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 9fe052d90c xephyr: Build support for rendering with glamor using a -glamor option.
v2: Avoid making the Ximage for the screen that we'll never use, and
    drive the screen pixmap creation for glamor ourselves.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-03-05 13:10:12 -08:00
Eric Anholt 4afe15d8bf glamor: Put in a pluggable context switcher for GLX versus EGL.
The GLX side just gets the context from the current state.  That's
also something I want to do for EGL, so that the making a context is
separate from initializing glamor, but I think I need the modesetting
driver in the server before I think about hacking on that more.

The previous code was rather incestuous, along with pulling in xf86
dependencies to our dix code.  The new code just initializes itself
from the current state.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-14 18:30:01 -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 a7b8ce8b42 glamor: Drop xfree86 dependencies from this dix module.
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 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 0c5a7c2086 glamor: Remove compat code for building out of tree.
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 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
Axel Davy 7cfd9cc232 Add DRI3 support to glamor
This implements some DRI3 helpers to help the DDXs using
glamor to support DRI3.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:54 -08:00
Axel Davy a5321ea431 Allow to create textured pixmaps from gbm_bo without using gem names
This implements glamor_egl_create_textured_pixmap_from_gbm_bo,
which is similar to glamor_egl_create_textured_pixmap, except
it takes a gbm_bo as argument.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
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
Zhigang Gong bc1b412b3b Synch with xorg 1.13 change.
As xorg 1.13 change the scrn interaces and remove those
global arrays. Some API change cause we can't build. Now
fix it.

Signed-off-by: Zhigang Gong <zhigang.gong@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 c5b3c2cedc Added strict warning flags to CFLAGS.
We miss the strict warning flags for a long time, now add it back.
This commit also fixed most of the warnings after enable the strict
flags.

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 503f8ec1a6 Remove unecessary header file.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:51 -08:00
Zhigang Gong cea0fe3e1f fallback_optimize: Prepare for downloading/uploading subregion.
Introduced two function glamor_get_sub_pixmap/glamor_put_sub_pixmap,
can easily used to get and put sub region of a big textured pixmap.
And it can use pbo if possible.

To support download a big textured pixmap's sub region to another
pixmap's pbo, we introduce a new type of pixmap GLAMOR_MEMORY_MAP.
This type of pixmap has a valid devPrivate.ptr pointer, and that
pointer points to a pbo mapped address.

Now, we are ready to refine those
glamor_prepare_access/glamor_finish_access pairs.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:49 -08:00
Zhigang Gong 213285f2b8 For DRI swap buffers.
This commit added two APIs to support the DRI swap buffer.
one is glamor_egl_exchange_buffers() which can swap two
pixmaps' underlying KHRimages/fbos/texs. The DDX layer should
exchange the DRM bos to make them consistent to each other.

Another API is glamor_egl_create_textured_screen_ext(), which
extent one more parameters to track the DDX layer's back pixmap
pointer. This is for the triple buffer support. When using triple
buffer, the DDX layer will keep a back pixmap rather then the
front pixmap and the pixmap used by the DRI2 client. And during
the closing screen stage, we have to dereference all the back
pixmap's glamor resources. Thus we have to extent this API to
register it when create new screen.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:49 -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
Zhigang Gong 1817b6c0cf glamor_eglmodule: Change module name according to normalize naming rule.
As Xorg module loader will normalize module name which will
remove '_' when we put "glamor_egl" to the configure file,
then it will fail to find us.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:48 -08:00
Zhigang Gong bf7d79dc0a Refine CloseScreen and FreeScreen processes.
This commit move the calling to glamor_close_screen from
glamor_egl_free_screen to glamor_egl_close_screen, as this
is the right place to do this.

We should detach screen fbo and destroy the corresponding
KHR image at glamor_egl_close_screen stage. As latter
DDX driver will call DestroyPixmap to destroy screen pixmap,
if the fbo and image are still there but glamor screen private
data pointer has been freed, then it causes segfault.

This commit also introduces a new flag GLAMOR_USE_EGL_SCREEN.
if DDX driver is using EGL layer then should set this bit
when call to glamor_init and then both glamor_close_screen
and glamor_egl_close_screen will be registered correctly,
DDX layer will not need to call these two functions manually.
This way is also the preferred method within Xorg domain.

As interfaces changed, bump the version to 0.3.0.

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 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 ca2ddd33a1 glamor_set_pixmap_texture/screen_pixmap: Remove useless parameters.
As after we got a texture, no matter the texture is created
on the glamor_create_pixmap or on the egl layer, we all already
know the texture's width and height there. We don't need
to pass them in.

This commit also simply the glamor_egl_create_textured_screen to
reuse the egl_create_textured_pixmap. And also remove the useless
root image from the egl private structure. As now the root image
is bound to the screen image, we don't take care it separately
here. It will be freed at the screen closing.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong 9264335347 Added more drawing functions.
As we want to take over all the possible GC ops from the DDX
layer, we need to add all the missed functions.
This commit also fixed one bug at polylines.
We simply drop the bugy optimized code now, as it did not
consider of clip info.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:47 -08:00
Zhigang Gong c65dc68622 Export glamor_validate_gc to DDX.
This is also a function which may direct access pixmaps which
may be a glamor only pixmap and DDX doesn't know how to access
it. We have to export this API to DDX driver and let the DDX
driver use it to do the validation.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -08:00
Zhigang Gong b36d264ec9 Add a new API glamor_create_gc.
As at ValidateGC stage, it may need to touch the pixmap directly, for
example the tile pixmap. We must export this interface to DDX driver
and let the DDX driver to route the processing to us. As this pixmap
may be a texture only pixmap, and DDX don't know how to handle it.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -08:00
Zhigang Gong 5769d8603d Export glamor_create_texture to DDX driver.
If DDX failed to create textured pixmap from its BO's handle,
it can turn to call this API to create a brand new glamor
rather than fallback to pure in memory pixmap.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -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 e3d16c9ebd Classfy glamor pixmap to different types.
During the integration with intel driver, we introduce two
new type of pixmap, one is TEXTURE_DRM, the other is DRM_ONLY.
TEXTURE_DRM means we create a texture bind to the DRM buffer
successfully. And then the texture and the external BO is
consistent. DRM_ONLY means that we failed to create a texture
from the external DRM BO. We need to handle those different
types carefully, so we have to track them in the data structure.

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 9b6a484df0 Add new version glamor_poly_fill_rect without internal fallback.
If need fallback, this new version just returns FALSE without
doing anything. It's the caller's responsibility to implement
fallback method.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18 11:23:46 -08:00
Zhigang Gong ba1b3b5324 Add new version glamor_fillspans without internal fallback.
For the purpose of incrementally intergration of existing intel
driver, for the GC operations we may don't want to use glamor's
internal fallback which is in general much slower than the
implementation in intel driver. If the parameter "fallback" is
false when call the glamor_fillspans, then if glamor found it
can't accelerate it then it will just return a FALSE rather than
fallback to a slow path.

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 bf4cbbd4e9 glamor: Move glamor_glyphs_init to create screen resources stage.
As in glamor_glyphs_init, we may need to create pixmap. Thus it must
be called after the pixmap resources allocation. Just move it to
screen resource creation stage is good enough for mow.

Also introduce a macro GLAMOR_FOR_XORG to glamor.h. As glamor may
be used by Xephyr which doesn't don't have those xorg header files
and also don't need the egl extension.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +08:00
Zhigang Gong ae38bd7c45 glamor: Change glamor_egl_init API.
Slightly change the API glamor_egl_init,
as this initialization is to initialize the display not
the screen, we should call it in xxx_preinit rather
than xxxScreenInit(). we change the input parameter as
below, as in preInit, the screen may not be allocated
at all. And in glamor_egl_init, it will not call
glamor_init. Driver should call glamor_init at
screen_init stage.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +08:00
Zhigang Gong 60f14d60f6 glamor-egl: Move EGL surfaceless related code to dix module.
The functions in glamor_egl.c could be shared by any egl back
end drivers.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +08:00
Zhigang Gong 65812b538f glamor-dix: Make a glamor dix module.
And modify the header file to export three APIs to the
ddx driver.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2011-09-26 16:47:02 +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 b60e6cb66d glamor: Silence compilation warnings.
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
Zhigang Gong 26ff612171 glamor: Resolved merge conflictions with Kristian's glamor-ddx patch. 2011-09-26 16:46:34 +08:00
Eric Anholt 4d52ae7f2d glamor: Start trying to hook up the rendering bits 2011-09-26 16:46:30 +08:00
Eric Anholt da6e0ffad2 More ephyr/glamor glue. 2011-09-26 16:46:30 +08:00
Eric Anholt 0ec823ce5b Add build infrastructure for glamor. 2011-09-26 16:37:50 +08:00