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>
This commit is contained in:
parent
ba6dd8aa49
commit
355334fcd9
|
@ -31,6 +31,8 @@ libglamor_la_SOURCES = \
|
|||
glamor_render.c \
|
||||
glamor_tile.c \
|
||||
glamor_triangles.c\
|
||||
glamor_pixmap.c\
|
||||
glamor_picture.c\
|
||||
glamor.h
|
||||
libglamor_la_LIBADD = \
|
||||
glu3/libglu3.la
|
||||
|
|
109
glamor/glamor.c
109
glamor/glamor.c
|
@ -59,8 +59,7 @@ glamor_get_drawable_pixmap(DrawablePtr drawable)
|
|||
return (PixmapPtr)drawable;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
|
@ -73,6 +72,8 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
|||
/* Create a framebuffer object wrapping the texture so that we can render
|
||||
* to it.
|
||||
*/
|
||||
pixmap_priv->gl_fbo = 1;
|
||||
pixmap_priv->gl_tex = 1;
|
||||
glGenFramebuffersEXT(1, &pixmap_priv->fb);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
|
||||
|
@ -87,13 +88,24 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
|||
NULL);
|
||||
}
|
||||
|
||||
/* Set screen pixmap. If tex equal to 0, means it is called from ephyr. */
|
||||
void
|
||||
glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h, unsigned int tex)
|
||||
{
|
||||
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
glamor_set_pixmap_texture(pixmap, w, h, tex);
|
||||
glamor_priv->screen_fbo = pixmap_priv->fb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define GLAMOR_PIXMAP_MEMORY 0
|
||||
#define GLAMOR_PIXMAP_TEXTURE 1
|
||||
|
||||
|
||||
/* XXX For the screen pixmap, the w and h maybe 0,0 too, but it should
|
||||
* be GLAMOR_GL pixmap. Now, all the pixmap will have a valid pixmap_priv.
|
||||
* This is not good enough. After we can identify which is the screen
|
||||
* pixmap and which is not, then we can split the pixmap to exclusive
|
||||
* two types GLAMOR_GL and GLAMOR_FB, and for those GLAMOR_FB pixmaps,
|
||||
* we don't need to allocate pixmap_priv. */
|
||||
|
||||
static PixmapPtr
|
||||
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||
|
@ -102,22 +114,24 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
PixmapPtr pixmap;
|
||||
GLenum format;
|
||||
GLuint tex;
|
||||
enum glamor_pixmap_type type = GLAMOR_GL;
|
||||
int type = GLAMOR_PIXMAP_TEXTURE;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
if (w > 32767 || h > 32767)
|
||||
return NullPixmap;
|
||||
|
||||
if (w > MAX_WIDTH || h > MAX_HEIGHT || ( depth == 1 && w != 0 && h != 0)) {
|
||||
if (!glamor_check_fbo_width_height(w,h) || !glamor_check_fbo_depth(depth)) {
|
||||
/* MESA can only support upto MAX_WIDTH*MAX_HEIGHT fbo.
|
||||
If we exceed such limitation, we have to use framebuffer.*/
|
||||
type = GLAMOR_FB;
|
||||
type = GLAMOR_PIXMAP_MEMORY;
|
||||
pixmap = fbCreatePixmap (screen, w, h, depth, usage);
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
|
||||
(((w * pixmap->drawable.bitsPerPixel +
|
||||
7) / 8) + 3) & ~3,
|
||||
NULL);
|
||||
|
||||
glamor_fallback("fallback to software fb for pixmap %p , %d x %d depth %d\n", pixmap, w, h, depth);
|
||||
glamor_fallback("choose cpu memory for pixmap %p ,"
|
||||
" %d x %d depth %d\n", pixmap, w, h, depth);
|
||||
} else
|
||||
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
|
||||
|
||||
|
@ -127,7 +141,10 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
return NullPixmap;
|
||||
}
|
||||
|
||||
if (w == 0 || h == 0 || type == GLAMOR_FB)
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap_priv->container = pixmap;
|
||||
|
||||
if (w == 0 || h == 0 || type == GLAMOR_PIXMAP_MEMORY)
|
||||
return pixmap;
|
||||
|
||||
/* We should probably take advantage of ARB_fbo's allowance of GL_ALPHA.
|
||||
|
@ -154,13 +171,51 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For Xephyr use only. set up the screen pixmap to correct state.
|
||||
**/
|
||||
static PixmapPtr
|
||||
glamor_create_screen_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||
unsigned int usage)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
assert(w ==0 && h == 0);
|
||||
|
||||
glamor_priv->screen_fbo = 0;
|
||||
pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
|
||||
|
||||
if (dixAllocatePrivates(&pixmap->devPrivates, PRIVATE_PIXMAP) != TRUE) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
ErrorF("Fail to allocate privates for PIXMAP.\n");
|
||||
return NullPixmap;
|
||||
}
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap_priv->tex = 0;
|
||||
pixmap_priv->gl_fbo = 1;
|
||||
pixmap_priv->gl_tex = 1;
|
||||
|
||||
screen->CreatePixmap = glamor_create_pixmap;
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static Bool
|
||||
glamor_destroy_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
if (pixmap->refcnt == 1) {
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv->fb)
|
||||
glDeleteFramebuffersEXT(1, &pixmap_priv->fb);
|
||||
if (pixmap_priv->tex)
|
||||
glDeleteTextures(1, &pixmap_priv->tex);
|
||||
if (pixmap_priv->pbo)
|
||||
glDeleteBuffersARB(1, &pixmap_priv->pbo);
|
||||
}
|
||||
|
||||
return fbDestroyPixmap(pixmap);
|
||||
|
@ -177,6 +232,18 @@ glamor_wakeup_handler(void *data, int result, void *last_select_mask)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_set_debug_level(int *debug_level)
|
||||
{
|
||||
char *debug_level_string;
|
||||
debug_level_string = getenv("GLAMOR_DEBUG");
|
||||
if (debug_level_string && sscanf(debug_level_string, "%d", debug_level) == 1)
|
||||
return;
|
||||
*debug_level = 0;
|
||||
}
|
||||
|
||||
int glamor_debug_level;
|
||||
|
||||
/** Set up glamor for an already-configured GL context. */
|
||||
Bool
|
||||
glamor_init(ScreenPtr screen, unsigned int flags)
|
||||
|
@ -186,7 +253,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
#ifdef RENDER
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
#endif
|
||||
|
||||
if (flags & ~GLAMOR_VALID_FLAGS) {
|
||||
ErrorF("glamor_init: Invalid flags %x\n", flags);
|
||||
return FALSE;
|
||||
|
@ -205,7 +271,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate screen private\n",
|
||||
screen->myNum);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, glamor_priv);
|
||||
|
||||
if (!dixRegisterPrivateKey(glamor_pixmap_private_key,PRIVATE_PIXMAP,
|
||||
|
@ -213,6 +281,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
glewInit();
|
||||
|
@ -243,7 +312,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
glamor_set_debug_level(&glamor_debug_level);
|
||||
glamor_priv->saved_close_screen = screen->CloseScreen;
|
||||
screen->CloseScreen = glamor_close_screen;
|
||||
|
||||
|
@ -251,6 +320,10 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
screen->CreateGC = glamor_create_gc;
|
||||
|
||||
glamor_priv->saved_create_pixmap = screen->CreatePixmap;
|
||||
|
||||
if (flags & GLAMOR_HOSTX)
|
||||
screen->CreatePixmap = glamor_create_screen_pixmap;
|
||||
else
|
||||
screen->CreatePixmap = glamor_create_pixmap;
|
||||
|
||||
glamor_priv->saved_destroy_pixmap = screen->DestroyPixmap;
|
||||
|
@ -281,6 +354,10 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
glamor_priv->saved_triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
glamor_init_composite_shaders(screen);
|
||||
glamor_priv->saved_create_picture = ps->CreatePicture;
|
||||
ps->CreatePicture = glamor_create_picture;
|
||||
glamor_priv->saved_destroy_picture = ps->DestroyPicture;
|
||||
ps->DestroyPicture = glamor_destroy_picture;
|
||||
#endif
|
||||
glamor_init_solid_shader(screen);
|
||||
glamor_init_tile_shader(screen);
|
||||
|
@ -288,7 +365,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
glamor_init_finish_access_shaders(screen);
|
||||
glamor_glyphs_init(screen);
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
|
@ -319,6 +395,7 @@ glamor_close_screen(int idx, ScreenPtr screen)
|
|||
ps->Trapezoids = glamor_priv->saved_trapezoids;
|
||||
ps->Glyphs = glamor_priv->saved_glyphs;
|
||||
ps->Triangles = glamor_priv->saved_triangles;
|
||||
ps->CreatePicture = glamor_priv->saved_create_picture;
|
||||
}
|
||||
#endif
|
||||
free(glamor_priv);
|
||||
|
|
|
@ -39,9 +39,10 @@
|
|||
#endif /* GLAMOR_H */
|
||||
|
||||
|
||||
#define GLAMOR_INVERTED_Y_AXIS 0x1
|
||||
#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS)
|
||||
#define GLAMOR_INVERTED_Y_AXIS 1
|
||||
#define GLAMOR_HOSTX 2
|
||||
#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS | GLAMOR_HOSTX)
|
||||
|
||||
Bool glamor_init(ScreenPtr screen, unsigned int flags);
|
||||
void glamor_fini(ScreenPtr screen);
|
||||
void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex);
|
||||
void glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h, unsigned int tex);
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
*
|
||||
* GC CopyArea implementation
|
||||
*/
|
||||
|
||||
static Bool
|
||||
glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
||||
DrawablePtr dst,
|
||||
|
@ -49,45 +48,36 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
|
||||
|
||||
if (src == dst) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
|
||||
"src == dest\n");
|
||||
glamor_delayed_fallback(screen,"src == dest\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!GLEW_EXT_framebuffer_blit) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
|
||||
"no EXT_framebuffer_blit\n");
|
||||
glamor_delayed_fallback(screen,"no EXT_framebuffer_blit\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
|
||||
if (src_pixmap_priv->fb == 0) {
|
||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (src_pixmap != screen_pixmap) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
|
||||
"no src fbo\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (gc) {
|
||||
if (gc->alu != GXcopy) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
|
||||
"non-copy ALU\n");
|
||||
glamor_delayed_fallback(screen, "non-copy ALU\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!glamor_pm_is_solid(dst, gc->planemask)) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_fbo_blit(): "
|
||||
"non-solid planemask\n");
|
||||
glamor_delayed_fallback(screen, "non-solid planemask\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!glamor_set_destination_pixmap(dst_pixmap))
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
|
||||
glamor_delayed_fallback(screen, "no src fbo\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (glamor_set_destination_pixmap(dst_pixmap)) {
|
||||
return FALSE;
|
||||
}
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, src_pixmap_priv->fb);
|
||||
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
|
@ -124,7 +114,6 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -142,29 +131,26 @@ glamor_copy_n_to_n_copypixels(DrawablePtr src,
|
|||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
int x_off, y_off, i;
|
||||
|
||||
if (src != dst) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_copypixels(): "
|
||||
"src != dest\n");
|
||||
glamor_delayed_fallback(screen, "src != dest\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (gc) {
|
||||
if (gc->alu != GXcopy) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_copypixels(): "
|
||||
"non-copy ALU\n");
|
||||
glamor_delayed_fallback(screen,"non-copy ALU\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!glamor_pm_is_solid(dst, gc->planemask)) {
|
||||
glamor_delayed_fallback(screen, "glamor_copy_n_to_n_copypixels(): "
|
||||
"non-solid planemask\n");
|
||||
glamor_delayed_fallback(screen,"non-solid planemask\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!glamor_set_destination_pixmap(dst_pixmap))
|
||||
if (glamor_set_destination_pixmap(dst_pixmap)) {
|
||||
glamor_delayed_fallback(screen, "dst has no fbo.\n");
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, dst_pixmap->drawable.width,
|
||||
|
@ -196,7 +182,6 @@ glamor_copy_n_to_n_copypixels(DrawablePtr src,
|
|||
GL_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -216,22 +201,34 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
int i;
|
||||
float vertices[4][2], texcoords[4][2];
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
int src_x_off, src_y_off, dst_x_off, dst_y_off;
|
||||
|
||||
enum glamor_pixmap_status src_status = GLAMOR_NONE;
|
||||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
|
||||
|
||||
if (src == dst) {
|
||||
glamor_fallback("glamor_copy_n_to_n with same src/dst\n");
|
||||
glamor_delayed_fallback(dst->pScreen, "same src/dst\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!src_pixmap_priv || !src_pixmap_priv->tex) {
|
||||
glamor_fallback("glamor_copy_n_to_n with non-texture src\n");
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
|
||||
glamor_delayed_fallback(dst->pScreen, "dst has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_destination_pixmap(dst_pixmap))
|
||||
if (!src_pixmap_priv->gl_tex) {
|
||||
#ifndef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
||||
glamor_delayed_fallback(dst->pScreen, "src has no fbo.\n");
|
||||
goto fail;
|
||||
#else
|
||||
/* XXX in yInverted mode we have bug here.*/
|
||||
if (!glamor_priv->yInverted) goto fail;
|
||||
src_status = glamor_upload_pixmap_to_texture(src_pixmap);
|
||||
if (src_status != GLAMOR_UPLOAD_DONE)
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (gc) {
|
||||
glamor_set_alu(gc->alu);
|
||||
|
@ -239,6 +236,8 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
dx += src_x_off;
|
||||
|
@ -258,7 +257,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
assert(GLEW_ARB_fragment_shader);
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog);
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog[0]);
|
||||
|
||||
for (i = 0; i < nbox; i++) {
|
||||
|
||||
|
@ -324,23 +323,23 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
void *closure)
|
||||
{
|
||||
if (glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
|
||||
glamor_clear_delayed_fallbacks(dst->pScreen);
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
if (glamor_copy_n_to_n_copypixels(src, dst, gc, box, nbox, dx, dy)) {
|
||||
glamor_clear_delayed_fallbacks(dst->pScreen);
|
||||
if (glamor_copy_n_to_n_copypixels(src, dst, gc, box, nbox, dx, dy)){
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
if (glamor_copy_n_to_n_textured(src, dst, gc, box, nbox, dx, dy)) {
|
||||
glamor_clear_delayed_fallbacks(dst->pScreen);
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
glamor_report_delayed_fallbacks(src->pScreen);
|
||||
glamor_report_delayed_fallbacks(dst->pScreen);
|
||||
|
||||
glamor_fallback("glamor_copy_area() from %p to %p (%c,%c)\n", src, dst,
|
||||
glamor_fallback("from %p to %p (%c,%c)\n", src, dst,
|
||||
glamor_get_drawable_location(src),
|
||||
glamor_get_drawable_location(dst));
|
||||
if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) {
|
||||
|
@ -352,6 +351,11 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
}
|
||||
glamor_finish_access(dst);
|
||||
}
|
||||
return;
|
||||
|
||||
done:
|
||||
glamor_clear_delayed_fallbacks(src->pScreen);
|
||||
glamor_clear_delayed_fallbacks(dst->pScreen);
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
|
|
|
@ -44,133 +44,16 @@ glamor_get_drawable_location(const DrawablePtr drawable)
|
|||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL)
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
if (pixmap_priv == NULL || pixmap_priv->gl_fbo == 0)
|
||||
return 'm';
|
||||
if (pixmap_priv->fb == 0)
|
||||
if (pixmap_priv->fb == glamor_priv->screen_fbo)
|
||||
return 's';
|
||||
else
|
||||
return 'f';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the offsets to add to coordinates to make them address the same bits in
|
||||
* the backing drawable. These coordinates are nonzero only for redirected
|
||||
* windows.
|
||||
*/
|
||||
void
|
||||
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
|
||||
int *x, int *y)
|
||||
{
|
||||
#ifdef COMPOSITE
|
||||
if (drawable->type == DRAWABLE_WINDOW) {
|
||||
*x = -pixmap->screen_x;
|
||||
*y = -pixmap->screen_y;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_set_destination_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (pixmap_priv == NULL) {
|
||||
glamor_fallback("glamor_set_destination_pixmap(): no pixmap priv");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pixmap_priv->fb == 0) {
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (pixmap != screen_pixmap) {
|
||||
glamor_fallback("glamor_set_destination_pixmap(): no fbo");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
|
||||
glViewport(0, 0,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
|
||||
{
|
||||
if (glamor_pm_is_solid(&pixmap->drawable, planemask)) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
ErrorF("unsupported planemask\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_set_alu(unsigned char alu)
|
||||
{
|
||||
if (alu == GXcopy) {
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
return;
|
||||
}
|
||||
glEnable(GL_COLOR_LOGIC_OP);
|
||||
switch (alu) {
|
||||
case GXclear:
|
||||
glLogicOp(GL_CLEAR);
|
||||
break;
|
||||
case GXand:
|
||||
glLogicOp(GL_AND);
|
||||
break;
|
||||
case GXandReverse:
|
||||
glLogicOp(GL_AND_REVERSE);
|
||||
break;
|
||||
case GXandInverted:
|
||||
glLogicOp(GL_AND_INVERTED);
|
||||
break;
|
||||
case GXnoop:
|
||||
glLogicOp(GL_NOOP);
|
||||
break;
|
||||
case GXxor:
|
||||
glLogicOp(GL_XOR);
|
||||
break;
|
||||
case GXor:
|
||||
glLogicOp(GL_OR);
|
||||
break;
|
||||
case GXnor:
|
||||
glLogicOp(GL_NOR);
|
||||
break;
|
||||
case GXequiv:
|
||||
glLogicOp(GL_EQUIV);
|
||||
break;
|
||||
case GXinvert:
|
||||
glLogicOp(GL_INVERT);
|
||||
break;
|
||||
case GXorReverse:
|
||||
glLogicOp(GL_OR_REVERSE);
|
||||
break;
|
||||
case GXcopyInverted:
|
||||
glLogicOp(GL_COPY_INVERTED);
|
||||
break;
|
||||
case GXorInverted:
|
||||
glLogicOp(GL_OR_INVERTED);
|
||||
break;
|
||||
case GXnand:
|
||||
glLogicOp(GL_NAND);
|
||||
break;
|
||||
case GXset:
|
||||
glLogicOp(GL_SET);
|
||||
break;
|
||||
default:
|
||||
FatalError("unknown logic op\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glamor_get_transform_uniform_locations(GLint prog,
|
||||
|
@ -245,136 +128,13 @@ glamor_link_glsl_prog(GLint prog)
|
|||
}
|
||||
}
|
||||
|
||||
static float ubyte_to_float(uint8_t b)
|
||||
{
|
||||
return b / 255.0f;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_get_color_4f_from_pixel(PixmapPtr pixmap, unsigned long fg_pixel,
|
||||
GLfloat *color)
|
||||
{
|
||||
switch (pixmap->drawable.depth) {
|
||||
case 1:
|
||||
color[0] = 0.0;
|
||||
color[1] = 0.0;
|
||||
color[2] = 0.0;
|
||||
color[3] = fg_pixel & 0x01;
|
||||
break;
|
||||
case 8:
|
||||
color[0] = 0.0;
|
||||
color[1] = 0.0;
|
||||
color[2] = 0.0;
|
||||
color[3] = (fg_pixel & 0xff) / 255.0;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
color[0] = ubyte_to_float((fg_pixel >> 16) & 0xFF);
|
||||
color[1] = ubyte_to_float((fg_pixel >> 8) & 0xFF);
|
||||
color[2] = ubyte_to_float((fg_pixel >> 0) & 0xFF);
|
||||
color[3] = ubyte_to_float((fg_pixel >> 24) & 0xFF);
|
||||
break;
|
||||
default:
|
||||
ErrorF("pixmap with bad depth: %d\n", pixmap->drawable.depth);
|
||||
color[0] = 1.0;
|
||||
color[1] = 0.0;
|
||||
color[2] = 1.0;
|
||||
color[3] = 1.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
unsigned int stride, row_length, y;
|
||||
GLenum format, type;
|
||||
uint8_t *data, *read;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
|
||||
if (!pixmap_priv)
|
||||
return TRUE;
|
||||
|
||||
if (pixmap_priv->fb == 0) {
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (pixmap != screen_pixmap)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
stride = pixmap->devKind;
|
||||
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
|
||||
|
||||
assert(drawable->depth != 1);
|
||||
switch (drawable->depth) {
|
||||
case 8:
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case 24:
|
||||
assert(drawable->bitsPerPixel == 32);
|
||||
/* FALLTHROUGH */
|
||||
case 32:
|
||||
format = GL_BGRA;
|
||||
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
default:
|
||||
ErrorF("Unknown prepareaccess depth %d\n", drawable->depth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pixmap_priv->access_mode = access;
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, row_length);
|
||||
|
||||
if (GLEW_MESA_pack_invert || glamor_priv->yInverted) {
|
||||
|
||||
if (!glamor_priv->yInverted)
|
||||
glPixelStorei(GL_PACK_INVERT_MESA, 1);
|
||||
|
||||
glGenBuffersARB (1, &pixmap_priv->pbo);
|
||||
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
|
||||
glBufferDataARB (GL_PIXEL_PACK_BUFFER_EXT,
|
||||
stride * pixmap->drawable.height,
|
||||
NULL, GL_DYNAMIC_DRAW_ARB);
|
||||
glReadPixels (0, 0,
|
||||
row_length, pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
|
||||
data = glMapBufferARB (GL_PIXEL_PACK_BUFFER_EXT, GL_READ_WRITE_ARB);
|
||||
|
||||
if (!glamor_priv->yInverted)
|
||||
glPixelStorei(GL_PACK_INVERT_MESA, 0);
|
||||
|
||||
} else {
|
||||
data = malloc(stride * pixmap->drawable.height);
|
||||
|
||||
glGenBuffersARB(1, &pixmap_priv->pbo);
|
||||
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
|
||||
glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
|
||||
stride * pixmap->drawable.height,
|
||||
NULL, GL_STREAM_READ_ARB);
|
||||
glReadPixels (0, 0, row_length, pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
read = glMapBufferARB(GL_PIXEL_PACK_BUFFER_EXT, GL_READ_ONLY_ARB);
|
||||
|
||||
for (y = 0; y < pixmap->drawable.height; y++)
|
||||
memcpy(data + y * stride,
|
||||
read + (pixmap->drawable.height - y - 1) * stride, stride);
|
||||
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_EXT);
|
||||
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, 0);
|
||||
glDeleteBuffersARB(1, &pixmap_priv->pbo);
|
||||
pixmap_priv->pbo = 0;
|
||||
}
|
||||
|
||||
pixmap->devPrivate.ptr = data;
|
||||
|
||||
return TRUE;
|
||||
return glamor_download_pixmap_to_cpu(pixmap, access);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -405,185 +165,71 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
|
||||
GLint fs_prog, vs_prog, avs_prog, aswizzle_prog;
|
||||
|
||||
glamor_priv->finish_access_prog = glCreateProgramObjectARB();
|
||||
glamor_priv->aswizzle_prog = glCreateProgramObjectARB();
|
||||
glamor_priv->finish_access_prog[0] = glCreateProgramObjectARB();
|
||||
glamor_priv->finish_access_prog[1] = glCreateProgramObjectARB();
|
||||
|
||||
if (GLEW_ARB_fragment_shader) {
|
||||
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
|
||||
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER_ARB, fs_source);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog, vs_prog);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog, fs_prog);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog[0], vs_prog);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog[0], fs_prog);
|
||||
|
||||
avs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
|
||||
aswizzle_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER_ARB, aswizzle_source);
|
||||
glAttachObjectARB(glamor_priv->aswizzle_prog, avs_prog);
|
||||
glAttachObjectARB(glamor_priv->aswizzle_prog, aswizzle_prog);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog[1], avs_prog);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog[1], aswizzle_prog);
|
||||
} else {
|
||||
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER_ARB, vs_source);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog, vs_prog);
|
||||
glAttachObjectARB(glamor_priv->finish_access_prog[0], vs_prog);
|
||||
ErrorF("Lack of framgment shader support.\n");
|
||||
}
|
||||
|
||||
glamor_link_glsl_prog(glamor_priv->finish_access_prog);
|
||||
glamor_link_glsl_prog(glamor_priv->aswizzle_prog);
|
||||
glamor_link_glsl_prog(glamor_priv->finish_access_prog[0]);
|
||||
glamor_link_glsl_prog(glamor_priv->finish_access_prog[1]);
|
||||
|
||||
if (GLEW_ARB_fragment_shader) {
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
sampler_uniform_location =
|
||||
glGetUniformLocationARB(glamor_priv->finish_access_prog, "sampler");
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog);
|
||||
glGetUniformLocationARB(glamor_priv->finish_access_prog[0], "sampler");
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog[0]);
|
||||
glUniform1iARB(sampler_uniform_location, 0);
|
||||
glUseProgramObjectARB(0);
|
||||
|
||||
sampler_uniform_location =
|
||||
glGetUniformLocationARB(glamor_priv->aswizzle_prog, "sampler");
|
||||
glUseProgramObjectARB(glamor_priv->aswizzle_prog);
|
||||
glGetUniformLocationARB(glamor_priv->finish_access_prog[1], "sampler");
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog[1]);
|
||||
glUniform1iARB(sampler_uniform_location, 0);
|
||||
glUseProgramObjectARB(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load texture from the pixmap's data pointer and then
|
||||
* draw the texture to the fbo, and flip the y axis.
|
||||
* */
|
||||
static void
|
||||
glamor_load_texture_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
unsigned int stride, row_length;
|
||||
GLenum format, type;
|
||||
static float vertices[8] = {-1, -1,
|
||||
1, -1,
|
||||
1, 1,
|
||||
-1, 1};
|
||||
static float texcoords[8] = {0, 1,
|
||||
1, 1,
|
||||
1, 0,
|
||||
0, 0};
|
||||
static float texcoords_inverted[8] = {0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1};
|
||||
float *ptexcoords;
|
||||
|
||||
void * texel;
|
||||
GLuint tex;
|
||||
int alfa_mode = 0;
|
||||
|
||||
if (glamor_priv->yInverted)
|
||||
ptexcoords = texcoords_inverted;
|
||||
else
|
||||
ptexcoords = texcoords;
|
||||
|
||||
assert(pixmap->drawable.depth != 1);
|
||||
stride = pixmap->devKind;
|
||||
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
|
||||
switch (pixmap->drawable.depth) {
|
||||
case 8:
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case 24:
|
||||
assert(pixmap->drawable.bitsPerPixel == 32);
|
||||
/* FALLTHROUGH */
|
||||
alfa_mode = 1;
|
||||
case 32:
|
||||
format = GL_BGRA;
|
||||
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
default:
|
||||
ErrorF("Unknown finishaccess depth %d\n", pixmap->drawable.depth);
|
||||
return;
|
||||
}
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, ptexcoords);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
|
||||
|
||||
glGenTextures(1, &tex);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
if (glamor_priv->yInverted || GLEW_MESA_pack_invert) {
|
||||
texel = NULL;
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, pixmap_priv->pbo);
|
||||
}
|
||||
else
|
||||
texel = pixmap->devPrivate.ptr;
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
pixmap->drawable.width, pixmap->drawable.height, 0,
|
||||
format, type, texel);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
assert(GLEW_ARB_fragment_shader);
|
||||
if (alfa_mode == 0)
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog);
|
||||
else
|
||||
glUseProgramObjectARB(glamor_priv->aswizzle_prog);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glUseProgramObjectARB(0);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDeleteTextures(1, &tex);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_finish_access(DrawablePtr drawable)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
/* Check if finish_access was already called once on this */
|
||||
if (pixmap->devPrivate.ptr == NULL)
|
||||
return;
|
||||
|
||||
if (!pixmap_priv)
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return;
|
||||
|
||||
if (pixmap_priv->fb == 0) {
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (pixmap != screen_pixmap)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( pixmap_priv->access_mode != GLAMOR_ACCESS_RO) {
|
||||
glamor_load_texture_pixmap(pixmap);
|
||||
glamor_restore_pixmap_to_texture(pixmap);
|
||||
}
|
||||
|
||||
if (GLEW_MESA_pack_invert || glamor_priv->yInverted) {
|
||||
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
|
||||
if (pixmap_priv->pbo != 0 && pixmap_priv->pbo_valid) {
|
||||
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, 0);
|
||||
glBindBufferARB (GL_PIXEL_UNPACK_BUFFER_EXT, 0);
|
||||
glDeleteBuffersARB (1, &pixmap_priv->pbo);
|
||||
pixmap_priv->pbo_valid = FALSE;
|
||||
glDeleteBuffersARB(1, &pixmap_priv->pbo);
|
||||
pixmap_priv->pbo = 0;
|
||||
} else
|
||||
free(pixmap->devPrivate.ptr);
|
||||
|
||||
pixmap->devPrivate.ptr = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
|
||||
* current fill style.
|
||||
|
@ -630,8 +276,6 @@ glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
|||
{
|
||||
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
|
||||
return FALSE;
|
||||
// ErrorF("stubbed out stipple depth %d\n", pixmap->drawable.depth);
|
||||
// glamor_solid_fail_region(pixmap, x, y, width, height);
|
||||
}
|
||||
|
||||
GCOps glamor_gc_ops = {
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
#ifndef __GLAMOR_DEBUG_H__
|
||||
#define __GLAMOR_DEBUG_H__
|
||||
|
||||
|
||||
#define GLAMOR_DELAYED_STRING_MAX 64
|
||||
|
||||
#define GLAMOR_DEBUG_NONE 0
|
||||
#define GLAMOR_DEBUG_FALLBACK 1
|
||||
#define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 2
|
||||
#define GLAMOR_DEBUG_TEXTURE_DOWNLOAD 3
|
||||
|
||||
|
||||
#define __debug_output_message(_format_, _prefix_, ...) \
|
||||
LogMessageVerb(X_NONE, 0, \
|
||||
"%32s:\t" _format_ , \
|
||||
/*_prefix_,*/ \
|
||||
__FUNCTION__, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define glamor_debug_output(_level_, _format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= _level_) \
|
||||
__debug_output_message(_format_, \
|
||||
"Glamor debug", \
|
||||
##__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_fallback(_format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
|
||||
__debug_output_message(_format_, \
|
||||
"Glamor fallback", \
|
||||
##__VA_ARGS__);} while(0)
|
||||
|
||||
|
||||
|
||||
#define glamor_delayed_fallback(_screen_, _format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
glamor_screen_private *_glamor_priv_; \
|
||||
_glamor_priv_ = glamor_get_screen_private(_screen_); \
|
||||
_glamor_priv_->delayed_fallback_pending = 1; \
|
||||
snprintf(_glamor_priv_->delayed_fallback_string, \
|
||||
GLAMOR_DELAYED_STRING_MAX, \
|
||||
"glamor delayed fallback: \t%s " _format_ , \
|
||||
__FUNCTION__, ##__VA_ARGS__); } } while(0)
|
||||
|
||||
|
||||
#define glamor_clear_delayed_fallbacks(_screen_) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
glamor_screen_private *_glamor_priv_; \
|
||||
_glamor_priv_ = glamor_get_screen_private(_screen_); \
|
||||
_glamor_priv_->delayed_fallback_pending = 0; } } while(0)
|
||||
|
||||
#define glamor_report_delayed_fallbacks(_screen_) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
glamor_screen_private *_glamor_priv_; \
|
||||
_glamor_priv_ = glamor_get_screen_private(_screen_); \
|
||||
LogMessageVerb(X_INFO, 0, "%s", \
|
||||
_glamor_priv_->delayed_fallback_string); \
|
||||
_glamor_priv_->delayed_fallback_pending = 0; } } while(0)
|
||||
|
||||
|
||||
#endif
|
|
@ -89,7 +89,6 @@ glamor_fill(DrawablePtr drawable,
|
|||
}
|
||||
return;
|
||||
fail:
|
||||
glamor_fallback("glamor_fill()");
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbFill(drawable, gc, x, y, width, height);
|
||||
|
@ -154,16 +153,22 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
GLfloat color[4];
|
||||
float vertices[4][2];
|
||||
|
||||
if (!glamor_set_destination_pixmap(pixmap))
|
||||
goto fail;
|
||||
glamor_set_alu(alu);
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
ErrorF("Failedto set planemask in glamor_solid.\n");
|
||||
if (glamor_set_destination_pixmap(pixmap)) {
|
||||
glamor_fallback("dest has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
glamor_set_alu(alu);
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glUseProgramObjectARB(glamor_priv->solid_prog);
|
||||
glamor_get_color_4f_from_pixel(pixmap, fg_pixel, color);
|
||||
glamor_get_rgba_from_pixel(fg_pixel,
|
||||
&color[0],
|
||||
&color[1],
|
||||
&color[2],
|
||||
&color[3],
|
||||
format_for_pixmap(pixmap));
|
||||
glUniform4fvARB(glamor_priv->solid_color_uniform_location, 1, color);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
|
||||
|
@ -196,22 +201,4 @@ fail:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Highlight places where we're doing it wrong. */
|
||||
void
|
||||
glamor_solid_fail_region(PixmapPtr pixmap, int x, int y, int width, int height)
|
||||
{
|
||||
unsigned long pixel;
|
||||
|
||||
switch (pixmap->drawable.depth) {
|
||||
case 24:
|
||||
case 32:
|
||||
pixel = 0x00ff00ff; /* our favorite color */
|
||||
break;
|
||||
default:
|
||||
case 8:
|
||||
pixel = 0xd0d0d0d0;
|
||||
break;
|
||||
}
|
||||
|
||||
glamor_solid(pixmap, x, y, width, height, GXcopy, ~0, pixel);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ glamor_fill_spans(DrawablePtr drawable,
|
|||
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
|
||||
goto fail;
|
||||
|
||||
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
|
||||
ppt = points;
|
||||
while (n--) {
|
||||
|
@ -82,7 +81,7 @@ glamor_fill_spans(DrawablePtr drawable,
|
|||
}
|
||||
return;
|
||||
fail:
|
||||
glamor_fallback("glamor_fillspans(): to %p (%c)\n", drawable,
|
||||
glamor_fallback("to %p (%c)\n", drawable,
|
||||
glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
|
|
|
@ -31,18 +31,6 @@
|
|||
|
||||
#include "glamor_priv.h"
|
||||
|
||||
static void
|
||||
set_bit(uint8_t *bitfield, unsigned int index, unsigned int val)
|
||||
{
|
||||
int i = index / 8;
|
||||
int mask = 1 << (index % 8);
|
||||
|
||||
if (val)
|
||||
bitfield[i] |= mask;
|
||||
else
|
||||
bitfield[i] &= ~mask;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax,
|
||||
|
@ -53,39 +41,27 @@ glamor_get_spans(DrawablePtr drawable,
|
|||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
GLenum format, type;
|
||||
int ax;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
int i, j;
|
||||
uint8_t *temp_dst = NULL, *readpixels_dst = (uint8_t *)dst;
|
||||
int i;
|
||||
uint8_t *readpixels_dst = (uint8_t *)dst;
|
||||
int x_off, y_off;
|
||||
|
||||
switch (drawable->depth) {
|
||||
case 1:
|
||||
temp_dst = malloc(wmax);
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
readpixels_dst = temp_dst;
|
||||
break;
|
||||
case 8:
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
format = GL_BGRA;
|
||||
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
default:
|
||||
glamor_fallback("glamor_get_spans(): "
|
||||
"Unknown getspans depth %d\n", drawable->depth);
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&ax
|
||||
)) {
|
||||
glamor_fallback("unknown depth. %d \n",
|
||||
drawable->depth);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_destination_pixmap(pixmap))
|
||||
if (glamor_set_destination_pixmap(pixmap)) {
|
||||
glamor_fallback("pixmap has no fbo.\n");
|
||||
goto fail;
|
||||
|
||||
}
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (glamor_priv->yInverted) {
|
||||
glReadPixels(points[i].x + x_off,
|
||||
|
@ -102,21 +78,12 @@ glamor_get_spans(DrawablePtr drawable,
|
|||
format, type,
|
||||
readpixels_dst);
|
||||
}
|
||||
if (temp_dst) {
|
||||
for (j = 0; j < widths[i]; j++) {
|
||||
set_bit((uint8_t *)dst, j, temp_dst[j] & 0x1);
|
||||
}
|
||||
dst += PixmapBytePad(widths[i], drawable->depth);
|
||||
} else {
|
||||
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
}
|
||||
free(temp_dst);
|
||||
return;
|
||||
|
||||
fail:
|
||||
free(temp_dst);
|
||||
glamor_fallback("glamor_get_spans() from %p (%c)\n", drawable,
|
||||
glamor_fallback("from %p (%c)\n", drawable,
|
||||
glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
|
||||
fbGetSpans(drawable, wmax, points, widths, count, dst);
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
*/
|
||||
#define GLYPH_BUFFER_SIZE 256
|
||||
|
||||
|
||||
typedef struct {
|
||||
PicturePtr source;
|
||||
glamor_composite_rect_t rects[GLYPH_BUFFER_SIZE];
|
||||
|
@ -573,6 +574,7 @@ static void glamor_glyphs_to_mask(PicturePtr mask,
|
|||
glamor_glyph_buffer_t *buffer)
|
||||
{
|
||||
#ifdef RENDER
|
||||
|
||||
glamor_composite_rects(PictOpAdd, buffer->source, mask,
|
||||
buffer->count, buffer->rects);
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glamor_priv.h"
|
||||
|
||||
/* Upload picture to texture. We may need to flip the y axis or
|
||||
* wire alpha to 1. So we may conditional create fbo for the picture.
|
||||
* */
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_picture_to_texture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
assert(picture->pDrawable);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
assert(GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) == 1);
|
||||
return glamor_upload_pixmap_to_texture(pixmap);
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
|
||||
{
|
||||
if (!picture || !picture->pDrawable)
|
||||
return TRUE;
|
||||
|
||||
return glamor_prepare_access(picture->pDrawable, access);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_finish_access_picture(PicturePtr picture)
|
||||
{
|
||||
if (!picture || !picture->pDrawable)
|
||||
return;
|
||||
|
||||
glamor_finish_access(picture->pDrawable);
|
||||
}
|
||||
|
||||
/*
|
||||
* We should already has drawable attached to it, if it has one.
|
||||
* Then set the attached pixmap to is_picture format, and set
|
||||
* the pict format.
|
||||
* */
|
||||
int
|
||||
glamor_create_picture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
|
||||
if (!picture || !picture->pDrawable)
|
||||
return 0;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
assert(pixmap_priv);
|
||||
|
||||
pixmap_priv->is_picture = 1;
|
||||
pixmap_priv->pict_format = picture->format;
|
||||
return glamor_priv->saved_create_picture(picture);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_destroy_picture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
|
||||
if (!picture || !picture->pDrawable)
|
||||
return;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
assert(pixmap_priv);
|
||||
|
||||
pixmap_priv->is_picture = 0;
|
||||
pixmap_priv->pict_format = 0;
|
||||
glamor_priv->saved_destroy_picture(picture);
|
||||
}
|
||||
|
||||
void glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_priv)
|
||||
{
|
||||
pixmap_priv->pict_format = picture->format;
|
||||
}
|
||||
|
|
@ -0,0 +1,483 @@
|
|||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glamor_priv.h"
|
||||
/**
|
||||
* Sets the offsets to add to coordinates to make them address the same bits in
|
||||
* the backing drawable. These coordinates are nonzero only for redirected
|
||||
* windows.
|
||||
*/
|
||||
void
|
||||
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
|
||||
int *x, int *y)
|
||||
{
|
||||
#ifdef COMPOSITE
|
||||
if (drawable->type == DRAWABLE_WINDOW) {
|
||||
*x = -pixmap->screen_x;
|
||||
*y = -pixmap->screen_y;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv)
|
||||
{
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
|
||||
glViewport(0, 0,
|
||||
pixmap_priv->container->drawable.width,
|
||||
pixmap_priv->container->drawable.height);
|
||||
}
|
||||
|
||||
int
|
||||
glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv)
|
||||
{
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return -1;
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_set_destination_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
return glamor_set_destination_pixmap_priv(pixmap_priv);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
|
||||
{
|
||||
if (glamor_pm_is_solid(&pixmap->drawable, planemask)) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
glamor_fallback("unsupported planemask %lx\n", planemask);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
glamor_set_alu(unsigned char alu)
|
||||
{
|
||||
if (alu == GXcopy) {
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
return;
|
||||
}
|
||||
glEnable(GL_COLOR_LOGIC_OP);
|
||||
switch (alu) {
|
||||
case GXclear:
|
||||
glLogicOp(GL_CLEAR);
|
||||
break;
|
||||
case GXand:
|
||||
glLogicOp(GL_AND);
|
||||
break;
|
||||
case GXandReverse:
|
||||
glLogicOp(GL_AND_REVERSE);
|
||||
break;
|
||||
case GXandInverted:
|
||||
glLogicOp(GL_AND_INVERTED);
|
||||
break;
|
||||
case GXnoop:
|
||||
glLogicOp(GL_NOOP);
|
||||
break;
|
||||
case GXxor:
|
||||
glLogicOp(GL_XOR);
|
||||
break;
|
||||
case GXor:
|
||||
glLogicOp(GL_OR);
|
||||
break;
|
||||
case GXnor:
|
||||
glLogicOp(GL_NOR);
|
||||
break;
|
||||
case GXequiv:
|
||||
glLogicOp(GL_EQUIV);
|
||||
break;
|
||||
case GXinvert:
|
||||
glLogicOp(GL_INVERT);
|
||||
break;
|
||||
case GXorReverse:
|
||||
glLogicOp(GL_OR_REVERSE);
|
||||
break;
|
||||
case GXcopyInverted:
|
||||
glLogicOp(GL_COPY_INVERTED);
|
||||
break;
|
||||
case GXorInverted:
|
||||
glLogicOp(GL_OR_INVERTED);
|
||||
break;
|
||||
case GXnand:
|
||||
glLogicOp(GL_NAND);
|
||||
break;
|
||||
case GXset:
|
||||
glLogicOp(GL_SET);
|
||||
break;
|
||||
default:
|
||||
FatalError("unknown logic op\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Upload pixmap to a specified texture.
|
||||
* This texture may not be the one attached to it.
|
||||
**/
|
||||
|
||||
static void
|
||||
__glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, GLuint tex)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
unsigned int stride, row_length;
|
||||
void *texels;
|
||||
GLenum iformat = GL_RGBA;
|
||||
|
||||
stride = pixmap->devKind;
|
||||
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
|
||||
|
||||
if (pixmap_priv->pbo && pixmap_priv->pbo_valid) {
|
||||
texels = NULL;
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, pixmap_priv->pbo);
|
||||
}
|
||||
else
|
||||
texels = pixmap->devPrivate.ptr;
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
iformat,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height, 0,
|
||||
format, type, texels);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Load texture from the pixmap's data pointer and then
|
||||
* draw the texture to the fbo, and flip the y axis.
|
||||
* */
|
||||
|
||||
static void
|
||||
_glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, int ax, int flip)
|
||||
{
|
||||
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
static float vertices[8] = {-1, -1,
|
||||
1, -1,
|
||||
1, 1,
|
||||
-1, 1};
|
||||
static float texcoords[8] = {0, 1,
|
||||
1, 1,
|
||||
1, 0,
|
||||
0, 0};
|
||||
static float texcoords_inv[8] = {0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1};
|
||||
float *ptexcoords;
|
||||
|
||||
GLuint tex;
|
||||
int need_flip;
|
||||
need_flip = (flip && !glamor_priv->yInverted);
|
||||
|
||||
/* Try fast path firstly, upload the pixmap to the texture attached
|
||||
* to the fbo directly. */
|
||||
|
||||
if (ax == 0 && !need_flip) {
|
||||
__glamor_upload_pixmap_to_texture(pixmap, format, type, pixmap_priv->tex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (need_flip)
|
||||
ptexcoords = texcoords;
|
||||
else
|
||||
ptexcoords = texcoords_inv;
|
||||
|
||||
/* Slow path, we need to flip y or wire alpha to 1. */
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, ptexcoords);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
|
||||
|
||||
glGenTextures(1, &tex);
|
||||
|
||||
__glamor_upload_pixmap_to_texture(pixmap, format, type, tex);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog[ax]);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glUseProgramObjectARB(0);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDeleteTextures(1, &tex);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
}
|
||||
|
||||
|
||||
/* */
|
||||
static int
|
||||
glamor_pixmap_upload_prepare(PixmapPtr pixmap, int need_fbo)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (!glamor_check_fbo_width_height(pixmap->drawable.width , pixmap->drawable.height)
|
||||
|| !glamor_check_fbo_depth(pixmap->drawable.depth)) {
|
||||
glamor_fallback("upload failed reason: bad size or depth %d x %d @depth %d \n",
|
||||
pixmap->drawable.width, pixmap->drawable.height, pixmap->drawable.depth);
|
||||
return -1;
|
||||
}
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return 0;
|
||||
if (pixmap_priv->tex == 0) {
|
||||
/* Create a framebuffer object wrapping the texture so that we can render
|
||||
* to it.
|
||||
*/
|
||||
glGenTextures(1, &pixmap_priv->tex);
|
||||
glBindTexture(GL_TEXTURE_2D, pixmap_priv->tex);
|
||||
}
|
||||
|
||||
if (need_fbo && pixmap_priv->fb == 0) {
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap->drawable.width,
|
||||
pixmap->drawable.height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glGenFramebuffersEXT(1, &pixmap_priv->fb);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D,
|
||||
pixmap_priv->tex,
|
||||
0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
|
||||
{
|
||||
GLenum format, type;
|
||||
int ax;
|
||||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&ax)) {
|
||||
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
return GLAMOR_UPLOAD_FAILED;
|
||||
}
|
||||
if (glamor_pixmap_upload_prepare(pixmap, ax))
|
||||
return GLAMOR_UPLOAD_FAILED;
|
||||
glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD,
|
||||
"Uploading pixmap %p %dx%d depth%d.\n",
|
||||
pixmap,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, ax, 0);
|
||||
return GLAMOR_UPLOAD_DONE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_pixmap_to_texure_from_data(PixmapPtr pixmap, void *data)
|
||||
{
|
||||
enum glamor_pixmap_status upload_status;
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
assert(pixmap_priv->pbo_valid == 0);
|
||||
assert(pixmap->devPrivate.ptr == NULL);
|
||||
pixmap->devPrivate.ptr = data;
|
||||
upload_status = glamor_upload_pixmap_to_texture(pixmap);
|
||||
pixmap->devPrivate.ptr = NULL;
|
||||
return upload_status;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
|
||||
{
|
||||
GLenum format, type;
|
||||
int ax;
|
||||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&ax)) {
|
||||
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
assert(0);
|
||||
}
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, ax, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move a pixmap to CPU memory.
|
||||
* The input data is the pixmap's fbo.
|
||||
* The output data is at pixmap->devPrivate.ptr. We always use pbo
|
||||
* to read the fbo and then map it to va. If possible, we will use
|
||||
* it directly as devPrivate.ptr.
|
||||
* If successfully download a fbo to cpu then return TRUE.
|
||||
* Otherwise return FALSE.
|
||||
**/
|
||||
|
||||
Bool
|
||||
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
unsigned int stride, row_length, y;
|
||||
GLenum format, type, gl_access, gl_usage;
|
||||
int ax;
|
||||
uint8_t *data, *read;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return TRUE;
|
||||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&ax)) {
|
||||
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
assert(0); // Should never happen.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pixmap_priv->access_mode = access;
|
||||
|
||||
switch (access) {
|
||||
case GLAMOR_ACCESS_RO:
|
||||
gl_access = GL_READ_ONLY_ARB;
|
||||
gl_usage = GL_STREAM_READ_ARB;
|
||||
break;
|
||||
case GLAMOR_ACCESS_WO:
|
||||
gl_access = GL_WRITE_ONLY_ARB;
|
||||
gl_usage = GL_STREAM_DRAW_ARB;
|
||||
break;
|
||||
case GLAMOR_ACCESS_RW:
|
||||
gl_access = GL_READ_WRITE_ARB;
|
||||
gl_usage = GL_DYNAMIC_DRAW_ARB;
|
||||
break;
|
||||
default:
|
||||
ErrorF("Glamor: Invalid access code. %d\n", access);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DOWNLOAD,
|
||||
"Downloading pixmap %p %dx%d depth%d\n",
|
||||
pixmap,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
|
||||
stride = pixmap->devKind;
|
||||
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, row_length);
|
||||
|
||||
if (GLEW_MESA_pack_invert || glamor_priv->yInverted) {
|
||||
|
||||
if (!glamor_priv->yInverted)
|
||||
glPixelStorei(GL_PACK_INVERT_MESA, 1);
|
||||
if (pixmap_priv->pbo == 0)
|
||||
glGenBuffersARB (1, &pixmap_priv->pbo);
|
||||
glBindBufferARB (GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
|
||||
glBufferDataARB (GL_PIXEL_PACK_BUFFER_EXT,
|
||||
stride * pixmap->drawable.height,
|
||||
NULL, gl_usage);
|
||||
if (access != GLAMOR_ACCESS_WO)
|
||||
glReadPixels (0, 0,
|
||||
row_length, pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
data = glMapBufferARB (GL_PIXEL_PACK_BUFFER_EXT, gl_access);
|
||||
pixmap_priv->pbo_valid = TRUE;
|
||||
|
||||
if (!glamor_priv->yInverted)
|
||||
glPixelStorei(GL_PACK_INVERT_MESA, 0);
|
||||
|
||||
} else {
|
||||
data = malloc(stride * pixmap->drawable.height);
|
||||
assert(data);
|
||||
if (access != GLAMOR_ACCESS_WO) {
|
||||
if (pixmap_priv->pbo == 0)
|
||||
glGenBuffersARB(1, &pixmap_priv->pbo);
|
||||
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, pixmap_priv->pbo);
|
||||
glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
|
||||
stride * pixmap->drawable.height,
|
||||
NULL, GL_STREAM_READ_ARB);
|
||||
glReadPixels (0, 0, row_length, pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
read = glMapBufferARB(GL_PIXEL_PACK_BUFFER_EXT, GL_READ_ONLY_ARB);
|
||||
|
||||
for (y = 0; y < pixmap->drawable.height; y++)
|
||||
memcpy(data + y * stride,
|
||||
read + (pixmap->drawable.height - y - 1) * stride, stride);
|
||||
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_EXT);
|
||||
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, 0);
|
||||
pixmap_priv->pbo_valid = FALSE;
|
||||
glDeleteBuffersARB(1, &pixmap_priv->pbo);
|
||||
pixmap_priv->pbo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
pixmap->devPrivate.ptr = data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
assert(pixmap_priv->gl_fbo == 0);
|
||||
if (pixmap_priv->fb)
|
||||
glDeleteFramebuffersEXT(1, &pixmap_priv->fb);
|
||||
if (pixmap_priv->tex)
|
||||
glDeleteTextures(1, &pixmap_priv->tex);
|
||||
if (pixmap_priv->pbo)
|
||||
glDeleteBuffersARB(1, &pixmap_priv->pbo);
|
||||
pixmap_priv->fb = pixmap_priv->tex = pixmap_priv->pbo = 0;
|
||||
|
||||
}
|
||||
|
||||
void glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
_glamor_destroy_upload_pixmap(pixmap);
|
||||
}
|
||||
|
|
@ -50,9 +50,9 @@ glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
int off_x, off_y;
|
||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
|
||||
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
|
||||
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
xorg = drawable->x;
|
||||
yorg = drawable->y;
|
||||
|
@ -101,9 +101,8 @@ glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
return;
|
||||
|
||||
fail:
|
||||
glamor_fallback("glamor_poly_fill_rect() to %p (%c)\n",
|
||||
glamor_fallback(" to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbPolyFillRect(drawable, gc, nrect, prect );
|
||||
|
|
|
@ -49,18 +49,17 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
xRectangle *rects;
|
||||
int x1, x2, y1, y2;
|
||||
int i;
|
||||
|
||||
/* Don't try to do wide lines or non-solid fill style. */
|
||||
if (gc->lineWidth != 0) {
|
||||
/* This ends up in miSetSpans, which is accelerated as well as we
|
||||
* can hope X wide lines will be.
|
||||
*/
|
||||
/*glamor_fallback("glamor_poly_lines(): wide lines\n");*/
|
||||
goto fail;
|
||||
}
|
||||
if (gc->lineStyle != LineSolid ||
|
||||
gc->fillStyle != FillSolid) {
|
||||
glamor_fallback("glamor_poly_lines(): non-solid fill\n");
|
||||
glamor_fallback("non-solid fill line style %d, fill style %d\n",
|
||||
gc->lineStyle, gc->fillStyle);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -77,11 +76,9 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
y2 = points[i + 1].y;
|
||||
}
|
||||
if (x1 != x2 && y1 != y2) {
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
free(rects);
|
||||
glamor_fallback("stub diagonal poly_line\n");
|
||||
goto fail;
|
||||
return;
|
||||
}
|
||||
if (x1 < x2) {
|
||||
rects[i].x = x1;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "glyphstr.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MAX_WIDTH
|
||||
#define MAX_WIDTH 4096
|
||||
#endif
|
||||
|
@ -47,10 +48,23 @@
|
|||
#define MAX_HEIGHT 4096
|
||||
#endif
|
||||
|
||||
typedef enum glamor_access {
|
||||
GLAMOR_ACCESS_RO,
|
||||
GLAMOR_ACCESS_RW,
|
||||
} glamor_access_t;
|
||||
#include "glamor_debug.h"
|
||||
|
||||
#define glamor_check_fbo_width_height(_w_, _h_) (_w_ > 0 && _h_ > 0 \
|
||||
&& _w_ < MAX_WIDTH \
|
||||
&& _h_ < MAX_HEIGHT)
|
||||
|
||||
#define glamor_check_fbo_depth(_depth_) ( \
|
||||
_depth_ == 8 \
|
||||
|| _depth_ == 15 \
|
||||
|| _depth_ == 16 \
|
||||
|| _depth_ == 24 \
|
||||
|| _depth_ == 30 \
|
||||
|| _depth_ == 32)
|
||||
|
||||
|
||||
#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv->is_picture == 1)
|
||||
#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) (pixmap_priv->gl_fbo == 1)
|
||||
|
||||
typedef struct glamor_transform_uniforms {
|
||||
GLint x_bias;
|
||||
|
@ -149,9 +163,11 @@ typedef struct glamor_screen_private {
|
|||
CopyWindowProcPtr saved_copy_window;
|
||||
BitmapToRegionProcPtr saved_bitmap_to_region;
|
||||
TrianglesProcPtr saved_triangles;
|
||||
CreatePictureProcPtr saved_create_picture;
|
||||
DestroyPictureProcPtr saved_destroy_picture;
|
||||
|
||||
char *delayed_fallback_string;
|
||||
int yInverted;
|
||||
int screen_fbo;
|
||||
GLuint vbo;
|
||||
int vbo_offset;
|
||||
int vbo_size;
|
||||
|
@ -159,8 +175,7 @@ typedef struct glamor_screen_private {
|
|||
int vb_stride;
|
||||
|
||||
/* glamor_finishaccess */
|
||||
GLint finish_access_prog;
|
||||
GLint aswizzle_prog;
|
||||
GLint finish_access_prog[2];
|
||||
|
||||
/* glamor_solid */
|
||||
GLint solid_prog;
|
||||
|
@ -183,21 +198,60 @@ typedef struct glamor_screen_private {
|
|||
int render_nr_verts;
|
||||
|
||||
glamor_glyph_cache_t glyph_caches[GLAMOR_NUM_GLYPH_CACHES];
|
||||
char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
|
||||
int delayed_fallback_pending;
|
||||
} glamor_screen_private;
|
||||
|
||||
enum glamor_pixmap_type {
|
||||
GLAMOR_GL,
|
||||
GLAMOR_FB
|
||||
};
|
||||
typedef enum glamor_access {
|
||||
GLAMOR_ACCESS_RO,
|
||||
GLAMOR_ACCESS_RW,
|
||||
GLAMOR_ACCESS_WO,
|
||||
} glamor_access_t;
|
||||
|
||||
/*
|
||||
* glamor_pixmap_private - glamor pixmap's private structure.
|
||||
* @gl_fbo: The pixmap is attached to a fbo originally.
|
||||
* @gl_tex: The pixmap is in a gl texture originally.
|
||||
* @pbo_valid: The pbo has a valid copy of the pixmap's data.
|
||||
* @is_picture: The drawable is attached to a picture.
|
||||
* @tex: attached texture.
|
||||
* @fb: attached fbo.
|
||||
* @pbo: attached pbo.
|
||||
* @access_mode: access mode during the prepare/finish pair.
|
||||
* @pict_format: the corresponding picture's format.
|
||||
* @container: The corresponding pixmap's pointer.
|
||||
**/
|
||||
|
||||
typedef struct glamor_pixmap_private {
|
||||
unsigned char gl_fbo:1;
|
||||
unsigned char gl_tex:1;
|
||||
unsigned char pbo_valid:1;
|
||||
unsigned char is_picture:1;
|
||||
GLuint tex;
|
||||
GLuint fb;
|
||||
GLuint pbo;
|
||||
enum glamor_pixmap_type type;
|
||||
glamor_access_t access_mode;
|
||||
PictFormatShort pict_format;
|
||||
PixmapPtr container;
|
||||
} glamor_pixmap_private;
|
||||
|
||||
/*
|
||||
* Pixmap dynamic status, used by dynamic upload feature.
|
||||
*
|
||||
* GLAMOR_NONE: initial status, don't need to do anything.
|
||||
* GLAMOR_UPLOAD_PENDING: marked as need to be uploaded to gl texture.
|
||||
* GLAMOR_UPLOAD_DONE: the pixmap has been uploaded successfully.
|
||||
* GLAMOR_UPLOAD_FAILED: fail to upload the pixmap.
|
||||
*
|
||||
* */
|
||||
typedef enum glamor_pixmap_status {
|
||||
GLAMOR_NONE,
|
||||
GLAMOR_UPLOAD_PENDING,
|
||||
GLAMOR_UPLOAD_DONE,
|
||||
GLAMOR_UPLOAD_FAILED
|
||||
} glamor_pixmap_status_t;
|
||||
|
||||
|
||||
extern DevPrivateKey glamor_screen_private_key;
|
||||
extern DevPrivateKey glamor_pixmap_private_key;
|
||||
static inline glamor_screen_private *
|
||||
|
@ -216,6 +270,228 @@ glamor_get_pixmap_private(PixmapPtr pixmap)
|
|||
#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
/**
|
||||
* Borrow from uxa.
|
||||
*/
|
||||
static inline CARD32
|
||||
format_for_depth(int depth)
|
||||
{
|
||||
switch (depth) {
|
||||
case 1: return PICT_a1;
|
||||
case 4: return PICT_a4;
|
||||
case 8: return PICT_a8;
|
||||
case 15: return PICT_x1r5g5b5;
|
||||
case 16: return PICT_r5g6b5;
|
||||
default:
|
||||
case 24: return PICT_x8r8g8b8;
|
||||
#if XORG_VERSION_CURRENT >= 10699900
|
||||
case 30: return PICT_x2r10g10b10;
|
||||
#endif
|
||||
case 32: return PICT_a8r8g8b8;
|
||||
}
|
||||
}
|
||||
|
||||
static inline CARD32
|
||||
format_for_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PictFormatShort pict_format;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
|
||||
pict_format = pixmap_priv->pict_format;
|
||||
else
|
||||
pict_format = format_for_depth(pixmap->drawable.depth);
|
||||
|
||||
return pict_format;
|
||||
}
|
||||
|
||||
/*
|
||||
* Map picture's format to the correct gl texture format and type.
|
||||
* xa is used to indicate whehter we need to wire alpha to 1.
|
||||
*
|
||||
* Return 0 if find a matched texture type. Otherwise return -1.
|
||||
**/
|
||||
static inline int
|
||||
glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
||||
GLenum *tex_format,
|
||||
GLenum *tex_type,
|
||||
int *xa)
|
||||
{
|
||||
*xa = 0;
|
||||
switch (format) {
|
||||
case PICT_a1:
|
||||
*tex_format = GL_COLOR_INDEX;
|
||||
*tex_type = GL_BITMAP;
|
||||
break;
|
||||
case PICT_b8g8r8x8:
|
||||
*xa = 1;
|
||||
case PICT_b8g8r8a8:
|
||||
*tex_format = GL_BGRA;
|
||||
*tex_type = GL_UNSIGNED_INT_8_8_8_8;
|
||||
break;
|
||||
|
||||
case PICT_x8r8g8b8:
|
||||
*xa = 1;
|
||||
case PICT_a8r8g8b8:
|
||||
*tex_format = GL_BGRA;
|
||||
*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
case PICT_x8b8g8r8:
|
||||
*xa = 1;
|
||||
case PICT_a8b8g8r8:
|
||||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
case PICT_x2r10g10b10:
|
||||
*xa = 1;
|
||||
case PICT_a2r10g10b10:
|
||||
*tex_format = GL_BGRA;
|
||||
*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||
break;
|
||||
case PICT_x2b10g10r10:
|
||||
*xa = 1;
|
||||
case PICT_a2b10g10r10:
|
||||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||
break;
|
||||
|
||||
case PICT_r5g6b5:
|
||||
*tex_format = GL_RGB;
|
||||
*tex_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
break;
|
||||
case PICT_b5g6r5:
|
||||
*tex_format = GL_RGB;
|
||||
*tex_type = GL_UNSIGNED_SHORT_5_6_5_REV;
|
||||
break;
|
||||
case PICT_x1b5g5r5:
|
||||
*xa = 1;
|
||||
case PICT_a1b5g5r5:
|
||||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||
break;
|
||||
|
||||
case PICT_x1r5g5b5:
|
||||
*xa = 1;
|
||||
case PICT_a1r5g5b5:
|
||||
*tex_format = GL_BGRA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||
break;
|
||||
case PICT_a8:
|
||||
*tex_format = GL_ALPHA;
|
||||
*tex_type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case PICT_x4r4g4b4:
|
||||
*xa = 1;
|
||||
case PICT_a4r4g4b4:
|
||||
*tex_format = GL_BGRA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
|
||||
break;
|
||||
|
||||
case PICT_x4b4g4r4:
|
||||
*xa = 1;
|
||||
case PICT_a4b4g4r4:
|
||||
*tex_format = GL_RGBA;
|
||||
*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
|
||||
break;
|
||||
|
||||
default:
|
||||
LogMessageVerb(X_INFO, 0, "fail to get matched format for %x \n", format);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static inline int
|
||||
glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
|
||||
GLenum *format,
|
||||
GLenum *type,
|
||||
int *ax)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PictFormatShort pict_format;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
|
||||
pict_format = pixmap_priv->pict_format;
|
||||
else
|
||||
pict_format = format_for_depth(pixmap->drawable.depth);
|
||||
|
||||
return glamor_get_tex_format_type_from_pictformat(pict_format,
|
||||
format, type, ax);
|
||||
}
|
||||
|
||||
|
||||
/* borrowed from uxa */
|
||||
static inline Bool
|
||||
glamor_get_rgba_from_pixel(CARD32 pixel,
|
||||
float * red,
|
||||
float * green,
|
||||
float * blue,
|
||||
float * alpha,
|
||||
CARD32 format)
|
||||
{
|
||||
int rbits, bbits, gbits, abits;
|
||||
int rshift, bshift, gshift, ashift;
|
||||
|
||||
rbits = PICT_FORMAT_R(format);
|
||||
gbits = PICT_FORMAT_G(format);
|
||||
bbits = PICT_FORMAT_B(format);
|
||||
abits = PICT_FORMAT_A(format);
|
||||
|
||||
if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) {
|
||||
rshift = gshift = bshift = ashift = 0;
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
|
||||
bshift = 0;
|
||||
gshift = bbits;
|
||||
rshift = gshift + gbits;
|
||||
ashift = rshift + rbits;
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
|
||||
rshift = 0;
|
||||
gshift = rbits;
|
||||
bshift = gshift + gbits;
|
||||
ashift = bshift + bbits;
|
||||
#if XORG_VERSION_CURRENT >= 10699900
|
||||
} else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
|
||||
ashift = 0;
|
||||
rshift = abits;
|
||||
if (abits == 0)
|
||||
rshift = PICT_FORMAT_BPP(format) - (rbits+gbits+bbits);
|
||||
gshift = rshift + rbits;
|
||||
bshift = gshift + gbits;
|
||||
#endif
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#define COLOR_INT_TO_FLOAT(_fc_, _p_, _s_, _bits_) \
|
||||
*_fc_ = (((_p_) >> (_s_)) & (( 1 << (_bits_)) - 1)) \
|
||||
/ (float)((1<<(_bits_)) - 1)
|
||||
|
||||
if (rbits)
|
||||
COLOR_INT_TO_FLOAT(red, pixel, rshift, rbits);
|
||||
else
|
||||
*red = 0;
|
||||
|
||||
if (gbits)
|
||||
COLOR_INT_TO_FLOAT(green, pixel, gshift, gbits);
|
||||
else
|
||||
*green = 0;
|
||||
|
||||
if (bbits)
|
||||
COLOR_INT_TO_FLOAT(blue, pixel, bshift, bbits);
|
||||
else
|
||||
*blue = 0;
|
||||
|
||||
if (abits)
|
||||
COLOR_INT_TO_FLOAT(alpha, pixel, ashift, abits);
|
||||
else
|
||||
*alpha = 1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns TRUE if the given planemask covers all the significant bits in the
|
||||
* pixel values for pDrawable.
|
||||
|
@ -227,51 +503,7 @@ glamor_pm_is_solid(DrawablePtr drawable, unsigned long planemask)
|
|||
FbFullMask(drawable->depth);
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_fallback(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
//LogMessageVerb(X_INFO, 3, "fallback: ");
|
||||
//LogMessageVerb(X_NONE, 3, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_delayed_fallback(ScreenPtr screen, char *format, ...)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
va_list ap;
|
||||
|
||||
if (glamor_priv->delayed_fallback_string != NULL)
|
||||
return;
|
||||
|
||||
va_start(ap, format);
|
||||
XNFvasprintf(&glamor_priv->delayed_fallback_string, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_clear_delayed_fallbacks(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
free(glamor_priv->delayed_fallback_string);
|
||||
glamor_priv->delayed_fallback_string = NULL;
|
||||
}
|
||||
|
||||
static inline void
|
||||
glamor_report_delayed_fallbacks(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
if (glamor_priv->delayed_fallback_string) {
|
||||
//LogMessageVerb(X_INFO, 3, "fallback: %s",
|
||||
// glamor_priv->delayed_fallback_string);
|
||||
glamor_clear_delayed_fallbacks(screen);
|
||||
}
|
||||
}
|
||||
extern int glamor_debug_level;
|
||||
|
||||
static inline float
|
||||
v_from_x_coord_x(PixmapPtr pixmap, int x)
|
||||
|
@ -359,7 +591,15 @@ GLint glamor_compile_glsl_prog(GLenum type, const char *source);
|
|||
void glamor_link_glsl_prog(GLint prog);
|
||||
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap, unsigned long fg_pixel,
|
||||
GLfloat *color);
|
||||
Bool glamor_set_destination_pixmap(PixmapPtr pixmap);
|
||||
|
||||
int glamor_set_destination_pixmap(PixmapPtr pixmap);
|
||||
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
/* nc means no check. caller must ensure this pixmap has valid fbo.
|
||||
* usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
|
||||
* */
|
||||
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
void glamor_set_alu(unsigned char alu);
|
||||
Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
|
||||
void glamor_get_transform_uniform_locations(GLint prog,
|
||||
|
@ -462,7 +702,7 @@ Bool glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
int tile_x, int tile_y);
|
||||
void glamor_init_tile_shader(ScreenPtr screen);
|
||||
|
||||
/* glamor_triangles */
|
||||
/* glamor_triangles.c */
|
||||
void
|
||||
glamor_triangles (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
|
@ -473,4 +713,82 @@ glamor_triangles (CARD8 op,
|
|||
int ntris,
|
||||
xTriangle *tris);
|
||||
|
||||
/* glamor_pixmap.c */
|
||||
|
||||
/**
|
||||
* Download a pixmap's texture to cpu memory. If success,
|
||||
* One copy of current pixmap's texture will be put into
|
||||
* the pixmap->devPrivate.ptr. Will use pbo to map to
|
||||
* the pointer if possible.
|
||||
* The pixmap must be a gl texture pixmap. gl_fbo and
|
||||
* gl_tex must be 1. Used by glamor_prepare_access.
|
||||
*
|
||||
*/
|
||||
Bool
|
||||
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access);
|
||||
|
||||
/**
|
||||
* Restore a pixmap's data which is downloaded by
|
||||
* glamor_download_pixmap_to_cpu to its original
|
||||
* gl texture. Used by glamor_finish_access.
|
||||
*
|
||||
* The pixmap must be
|
||||
* in texture originally. In other word, the gl_fbo
|
||||
* must be 1.
|
||||
**/
|
||||
void
|
||||
glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
|
||||
|
||||
/**
|
||||
* Upload a pixmap to gl texture. Used by dynamic pixmap
|
||||
* uploading feature. The pixmap must be a software pixmap.
|
||||
* This function will change current FBO and current shaders.
|
||||
*/
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_pixmap_to_texture(PixmapPtr pixmap);
|
||||
|
||||
/**
|
||||
* Upload a picture to gl texture. Similar to the
|
||||
* glamor_upload_pixmap_to_texture. Used in rendering.
|
||||
**/
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_picture_to_texture(PicturePtr picture);
|
||||
|
||||
/**
|
||||
* Destroy all the resources allocated on the uploading
|
||||
* phase, includs the tex and fbo.
|
||||
**/
|
||||
void
|
||||
glamor_destroy_upload_pixmap(PixmapPtr pixmap);
|
||||
|
||||
|
||||
|
||||
int
|
||||
glamor_create_picture(PicturePtr picture);
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
|
||||
void
|
||||
glamor_finish_access_picture(PicturePtr picture);
|
||||
|
||||
void
|
||||
glamor_destroy_picture(PicturePtr picture);
|
||||
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_picture_to_texture(PicturePtr picture);
|
||||
|
||||
void
|
||||
glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
/* Dynamic pixmap upload to texture if needed.
|
||||
* Sometimes, the target is a gl texture pixmap/picture,
|
||||
* but the source or mask is in cpu memory. In that case,
|
||||
* upload the source/mask to gl texture and then avoid
|
||||
* fallback the whole process to cpu. Most of the time,
|
||||
* this will increase performance obviously. */
|
||||
|
||||
|
||||
#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
||||
|
||||
#endif /* GLAMOR_PRIV_H */
|
||||
|
|
|
@ -132,6 +132,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
0.0, 1.0,
|
||||
};
|
||||
|
||||
|
||||
dest_coords[0][0] = v_from_x_coord_x(pixmap, x);
|
||||
dest_coords[0][1] = v_from_x_coord_y(pixmap, y);
|
||||
dest_coords[1][0] = v_from_x_coord_x(pixmap, x + w);
|
||||
|
@ -226,13 +227,11 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
return;
|
||||
|
||||
fail:
|
||||
glamor_set_alu(GXcopy);
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
|
||||
glamor_fallback("glamor_put_image(): to %p (%c)\n",
|
||||
glamor_fallback(": to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
fail:
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap, bits);
|
||||
glamor_finish_access(drawable);
|
||||
|
@ -251,12 +250,11 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
RegionPtr clip;
|
||||
BoxPtr pbox;
|
||||
int nbox;
|
||||
int bpp = drawable->bitsPerPixel;
|
||||
int src_stride = PixmapBytePad(w, drawable->depth);
|
||||
int x_off, y_off;
|
||||
float vertices[4][2], texcoords[4][2];
|
||||
GLuint tex;
|
||||
int alfa_mode = 0;
|
||||
int ax = 0;
|
||||
if (image_format == XYBitmap) {
|
||||
assert(depth == 1);
|
||||
glamor_put_image_xybitmap(drawable, gc, x, y, w, h,
|
||||
|
@ -264,56 +262,32 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
return;
|
||||
}
|
||||
|
||||
if (pixmap_priv == NULL) {
|
||||
glamor_fallback("glamor_put_image: system memory pixmap\n");
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
glamor_fallback("has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (pixmap_priv->fb == 0) {
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (pixmap != screen_pixmap) {
|
||||
glamor_fallback("glamor_put_image: no fbo\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (bpp == 1 && image_format == XYPixmap)
|
||||
image_format = ZPixmap;
|
||||
|
||||
if (image_format != ZPixmap) {
|
||||
glamor_fallback("glamor_put_image: non-ZPixmap\n");
|
||||
glamor_fallback("non-ZPixmap\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
switch (drawable->depth) {
|
||||
case 1:
|
||||
format = GL_COLOR_INDEX;
|
||||
type = GL_BITMAP;
|
||||
break;
|
||||
case 8:
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case 24:
|
||||
assert(drawable->bitsPerPixel == 32);
|
||||
/* FALLTHROUGH */
|
||||
alfa_mode = 1;
|
||||
case 32:
|
||||
format = GL_BGRA;
|
||||
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
default:
|
||||
glamor_fallback("glamor_putimage: bad depth %d\n", drawable->depth);
|
||||
if (!glamor_set_planemask(pixmap, gc->planemask)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_planemask(pixmap, gc->planemask))
|
||||
goto fail;
|
||||
|
||||
glamor_set_alu(gc->alu);
|
||||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&ax
|
||||
)) {
|
||||
glamor_fallback("unknown depth. %d \n",
|
||||
drawable->depth);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* XXX consider to reuse a function to do the following work. */
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
|
@ -321,14 +295,12 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
glTexCoordPointer(2, GL_FLOAT, sizeof(float) * 2, texcoords);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, pixmap_priv->fb);
|
||||
glViewport(0, 0, pixmap->drawable.width, pixmap->drawable.height);
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, src_stride * 8 /
|
||||
pixmap->drawable.bitsPerPixel);
|
||||
if (bpp == 1)
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
|
||||
|
||||
|
||||
glGenTextures(1, &tex);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
@ -341,10 +313,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
assert(GLEW_ARB_fragment_shader);
|
||||
if (alfa_mode == 0)
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog);
|
||||
else
|
||||
glUseProgramObjectARB(glamor_priv->aswizzle_prog);
|
||||
glUseProgramObjectARB(glamor_priv->finish_access_prog[ax]);
|
||||
|
||||
x += drawable->x;
|
||||
y += drawable->y;
|
||||
|
@ -425,7 +394,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
|
||||
fail:
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
glamor_fallback("glamor_put_image(): to %p (%c)\n",
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPutImage(drawable, gc, depth, x, y, w, h, left_pad, image_format,
|
||||
|
|
|
@ -86,7 +86,7 @@ glamor_create_composite_fs(struct shader_key *key)
|
|||
"uniform sampler2D source_sampler;\n"
|
||||
"vec4 get_source()\n"
|
||||
"{\n"
|
||||
" return texture2D(source_sampler, gl_TexCoord[0].xy);\n"
|
||||
" return vec4(texture2D(source_sampler, gl_TexCoord[0].xy).rgb, 1);\n"
|
||||
"}\n";
|
||||
const char *mask_solid_fetch =
|
||||
"uniform vec4 mask;\n"
|
||||
|
@ -104,7 +104,7 @@ glamor_create_composite_fs(struct shader_key *key)
|
|||
"uniform sampler2D mask_sampler;\n"
|
||||
"vec4 get_mask()\n"
|
||||
"{\n"
|
||||
" return texture2D(mask_sampler, gl_TexCoord[1].xy);\n"
|
||||
" return vec4(texture2D(mask_sampler, gl_TexCoord[1].xy).rgb, 1);\n"
|
||||
"}\n";
|
||||
const char *in_source_only =
|
||||
"void main()\n"
|
||||
|
@ -299,7 +299,7 @@ glamor_set_composite_op(ScreenPtr screen,
|
|||
struct blendinfo *op_info;
|
||||
|
||||
if (op >= ARRAY_SIZE(composite_op_info)) {
|
||||
ErrorF("unsupported render op\n");
|
||||
glamor_fallback("unsupported render op %d \n", op);
|
||||
return GL_FALSE;
|
||||
}
|
||||
op_info = &composite_op_info[op];
|
||||
|
@ -321,7 +321,7 @@ glamor_set_composite_op(ScreenPtr screen,
|
|||
if (mask && mask->componentAlpha && PICT_FORMAT_RGB(mask->format) != 0 &&
|
||||
op_info->source_alpha) {
|
||||
if (source_blend != GL_ZERO) {
|
||||
ErrorF("Dual-source composite blending not supported\n");
|
||||
glamor_fallback("Dual-source composite blending not supported\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
if (dest_blend == GL_SRC_ALPHA)
|
||||
|
@ -496,6 +496,7 @@ good_source_format(PicturePtr picture)
|
|||
case PICT_x8r8g8b8:
|
||||
return TRUE;
|
||||
default:
|
||||
return TRUE;
|
||||
glamor_fallback("Bad source format 0x%08x\n", picture->format);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -511,6 +512,7 @@ good_mask_format(PicturePtr picture)
|
|||
case PICT_x8r8g8b8:
|
||||
return TRUE;
|
||||
default:
|
||||
return TRUE;
|
||||
glamor_fallback("Bad mask format 0x%08x\n", picture->format);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -525,6 +527,7 @@ good_dest_format(PicturePtr picture)
|
|||
case PICT_x8r8g8b8:
|
||||
return TRUE;
|
||||
default:
|
||||
return TRUE;
|
||||
glamor_fallback("Bad dest format 0x%08x\n", picture->format);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -673,6 +676,71 @@ glamor_emit_composite_rect(ScreenPtr screen,
|
|||
glamor_emit_composite_vert(screen, src_coords, mask_coords, dst_coords, 3);
|
||||
}
|
||||
|
||||
|
||||
int pict_format_combine_tab[][3] =
|
||||
{
|
||||
{PICT_TYPE_ARGB, PICT_TYPE_A, PICT_TYPE_ARGB},
|
||||
{PICT_TYPE_ABGR, PICT_TYPE_A, PICT_TYPE_ABGR},
|
||||
};
|
||||
|
||||
static Bool
|
||||
combine_pict_format(PictFormatShort *des, const PictFormatShort src,
|
||||
const PictFormatShort mask, enum shader_in in_ca)
|
||||
{
|
||||
PictFormatShort new_vis;
|
||||
int src_type, mask_type, src_bpp, mask_bpp;
|
||||
int i;
|
||||
if (src == mask) {
|
||||
*des = src;
|
||||
return TRUE;
|
||||
}
|
||||
src_bpp = PICT_FORMAT_BPP(src);
|
||||
mask_bpp = PICT_FORMAT_BPP(mask);
|
||||
|
||||
assert(src_bpp == mask_bpp);
|
||||
|
||||
new_vis = PICT_FORMAT_VIS(src) | PICT_FORMAT_VIS(mask);
|
||||
|
||||
switch(in_ca) {
|
||||
case SHADER_IN_SOURCE_ONLY:
|
||||
return TRUE;
|
||||
case SHADER_IN_NORMAL:
|
||||
src_type = PICT_FORMAT_TYPE(src);
|
||||
mask_type = PICT_TYPE_A;
|
||||
break;
|
||||
case SHADER_IN_CA_SOURCE:
|
||||
src_type = PICT_FORMAT_TYPE(src);
|
||||
mask_type = PICT_FORMAT_TYPE(mask);
|
||||
break;
|
||||
case SHADER_IN_CA_ALPHA:
|
||||
src_type = PICT_TYPE_A;
|
||||
mask_type = PICT_FORMAT_TYPE(mask);
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (src_type == mask_type) {
|
||||
*des = PICT_VISFORMAT(src_bpp, src_type, new_vis);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for(i = 0;
|
||||
i < sizeof(pict_format_combine_tab)/sizeof(pict_format_combine_tab[0]);
|
||||
i++)
|
||||
{
|
||||
if ((src_type == pict_format_combine_tab[i][0]
|
||||
&& mask_type == pict_format_combine_tab[i][1])
|
||||
||(src_type == pict_format_combine_tab[i][1]
|
||||
&& mask_type == pict_format_combine_tab[i][0])) {
|
||||
*des = PICT_VISFORMAT(src_bpp, pict_format_combine_tab[i][2], new_vis);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
glamor_composite_with_shader(CARD8 op,
|
||||
PicturePtr source,
|
||||
|
@ -687,6 +755,7 @@ glamor_composite_with_shader(CARD8 op,
|
|||
PixmapPtr source_pixmap = NULL, mask_pixmap = NULL;
|
||||
glamor_pixmap_private *source_pixmap_priv = NULL;
|
||||
glamor_pixmap_private *mask_pixmap_priv = NULL;
|
||||
glamor_pixmap_private *dest_pixmap_priv = NULL;
|
||||
struct shader_key key;
|
||||
glamor_composite_shader *shader;
|
||||
RegionRec region;
|
||||
|
@ -696,7 +765,15 @@ glamor_composite_with_shader(CARD8 op,
|
|||
int dest_x_off, dest_y_off;
|
||||
int source_x_off, source_y_off;
|
||||
int mask_x_off, mask_y_off;
|
||||
enum glamor_pixmap_status source_status = GLAMOR_NONE;
|
||||
enum glamor_pixmap_status mask_status = GLAMOR_NONE;
|
||||
PictFormatShort saved_source_format = 0;
|
||||
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
|
||||
glamor_fallback("dest has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
memset(&key, 0, sizeof(key));
|
||||
if (!source->pDrawable) {
|
||||
if (source->pSourcePict->type == SourcePictTypeSolidFill) {
|
||||
|
@ -706,11 +783,7 @@ glamor_composite_with_shader(CARD8 op,
|
|||
goto fail;
|
||||
}
|
||||
} else {
|
||||
if (PICT_FORMAT_A(source->format) != 0) {
|
||||
key.source = SHADER_SOURCE_TEXTURE_ALPHA;
|
||||
} else {
|
||||
key.source = SHADER_SOURCE_TEXTURE;
|
||||
}
|
||||
}
|
||||
if (mask) {
|
||||
if (!mask->pDrawable) {
|
||||
|
@ -721,11 +794,7 @@ glamor_composite_with_shader(CARD8 op,
|
|||
goto fail;
|
||||
}
|
||||
} else {
|
||||
if (PICT_FORMAT_A(mask->format) != 0) {
|
||||
key.mask = SHADER_MASK_TEXTURE_ALPHA;
|
||||
} else {
|
||||
key.mask = SHADER_MASK_TEXTURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mask->componentAlpha) {
|
||||
|
@ -754,56 +823,136 @@ glamor_composite_with_shader(CARD8 op,
|
|||
glamor_fallback("mask alphaMap\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (key.source == SHADER_SOURCE_TEXTURE ||
|
||||
key.source == SHADER_SOURCE_TEXTURE_ALPHA) {
|
||||
source_pixmap = glamor_get_drawable_pixmap(source->pDrawable);
|
||||
source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
|
||||
if (source_pixmap == dest_pixmap) {
|
||||
glamor_fallback("glamor_composite(): source == dest\n");
|
||||
glamor_fallback("source == dest\n");
|
||||
goto fail;
|
||||
}
|
||||
if (!source_pixmap_priv || source_pixmap_priv->tex == 0) {
|
||||
glamor_fallback("glamor_composite(): no texture in source\n");
|
||||
if (!source_pixmap_priv || source_pixmap_priv->gl_tex == 0) {
|
||||
#ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
||||
source_status = GLAMOR_UPLOAD_PENDING;
|
||||
#else
|
||||
glamor_fallback("no texture in source\n");
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
if ((source_status != GLAMOR_UPLOAD_PENDING)
|
||||
&& !good_source_format(source)) {
|
||||
goto fail;
|
||||
}
|
||||
if (!good_source_format(source))
|
||||
goto fail;
|
||||
}
|
||||
if (key.mask == SHADER_MASK_TEXTURE ||
|
||||
key.mask == SHADER_MASK_TEXTURE_ALPHA) {
|
||||
mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable);
|
||||
mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
|
||||
if (mask_pixmap == dest_pixmap) {
|
||||
glamor_fallback("glamor_composite(): mask == dest\n");
|
||||
glamor_fallback("mask == dest\n");
|
||||
goto fail;
|
||||
}
|
||||
if (!mask_pixmap_priv || mask_pixmap_priv->tex == 0) {
|
||||
glamor_fallback("glamor_composite(): no texture in mask\n");
|
||||
if (!mask_pixmap_priv || mask_pixmap_priv->gl_tex == 0) {
|
||||
#ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
||||
mask_status = GLAMOR_UPLOAD_PENDING;
|
||||
#else
|
||||
glamor_fallback("no texture in mask\n");
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
if ((mask_status != GLAMOR_UPLOAD_PENDING)
|
||||
&& !good_mask_format(mask)) {
|
||||
goto fail;
|
||||
}
|
||||
if (!good_mask_format(mask))
|
||||
}
|
||||
if (!good_dest_format(dest)) {
|
||||
goto fail;
|
||||
}
|
||||
if (!good_dest_format(dest))
|
||||
goto fail;
|
||||
|
||||
shader = glamor_lookup_composite_shader(screen, &key);
|
||||
if (shader->prog == 0) {
|
||||
glamor_fallback("glamor_composite(): "
|
||||
"no shader program for this render acccel mode\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glUseProgramObjectARB(shader->prog);
|
||||
|
||||
if (!glamor_set_destination_pixmap(dest_pixmap))
|
||||
goto fail;
|
||||
|
||||
if (!glamor_set_composite_op(screen, op, dest, mask)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
||||
if (source_status == GLAMOR_UPLOAD_PENDING
|
||||
&& mask_status == GLAMOR_UPLOAD_PENDING
|
||||
&& source_pixmap == mask_pixmap) {
|
||||
|
||||
if (source->format != mask->format) {
|
||||
saved_source_format = source->format;
|
||||
/* XXX
|
||||
* when need to flip the texture and mask and source share the same pixmap,
|
||||
* there is a bug, need to be fixed. *
|
||||
*/
|
||||
if (!glamor_priv->yInverted)
|
||||
goto fail;
|
||||
if (!combine_pict_format(&source->format, source->format, mask->format, key.in)) {
|
||||
glamor_fallback("combine source %x mask %x failed.\n",
|
||||
source->format, mask->format);
|
||||
goto fail;
|
||||
}
|
||||
if (source->format != saved_source_format) {
|
||||
glamor_picture_format_fixup(source, source_pixmap_priv);
|
||||
}
|
||||
/* XXX
|
||||
* By default, glamor_upload_picture_to_texture will wire alpha to 1
|
||||
* if one picture doesn't have alpha. So we don't do that again in
|
||||
* rendering function. But here is a special case, as source and
|
||||
* mask share the same texture but may have different formats. For
|
||||
* example, source doesn't have alpha, but mask has alpha. Then the
|
||||
* texture will have the alpha value for the mask. And will not wire
|
||||
* to 1 for the source. In this case, we have to use different shader
|
||||
* to wire the source's alpha to 1.
|
||||
*
|
||||
* But this may cause a potential problem if the source's repeat mode
|
||||
* is REPEAT_NONE, and if the source is smaller than the dest, then
|
||||
* for the region not covered by the source may be painted incorrectly.
|
||||
* because we wire the alpha to 1.
|
||||
*
|
||||
**/
|
||||
if (!PICT_FORMAT_A(saved_source_format) && PICT_FORMAT_A(mask->format))
|
||||
key.source = SHADER_SOURCE_TEXTURE;
|
||||
|
||||
if (!PICT_FORMAT_A(mask->format) && PICT_FORMAT_A(saved_source_format))
|
||||
key.mask = SHADER_MASK_TEXTURE;
|
||||
|
||||
mask_status = GLAMOR_NONE;
|
||||
}
|
||||
source_status = glamor_upload_picture_to_texture(source);
|
||||
|
||||
if (source_status != GLAMOR_UPLOAD_DONE) {
|
||||
glamor_fallback("Failed to upload source texture.\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (source_status == GLAMOR_UPLOAD_PENDING) {
|
||||
source_status = glamor_upload_picture_to_texture(source);
|
||||
if (source_status != GLAMOR_UPLOAD_DONE) {
|
||||
glamor_fallback("Failed to upload source texture.\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask_status == GLAMOR_UPLOAD_PENDING) {
|
||||
mask_status = glamor_upload_picture_to_texture(mask);
|
||||
if (mask_status != GLAMOR_UPLOAD_DONE) {
|
||||
glamor_fallback("Failed to upload mask texture.\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(dest_pixmap_priv);
|
||||
|
||||
shader = glamor_lookup_composite_shader(screen, &key);
|
||||
if (shader->prog == 0) {
|
||||
glamor_fallback("no shader program for this render acccel mode\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glUseProgramObjectARB(shader->prog);
|
||||
if (key.source == SHADER_SOURCE_SOLID) {
|
||||
glamor_set_composite_solid(source, shader->source_uniform_location);
|
||||
} else {
|
||||
|
@ -831,7 +980,6 @@ glamor_composite_with_shader(CARD8 op,
|
|||
glamor_get_drawable_deltas(mask->pDrawable, mask_pixmap,
|
||||
&mask_x_off, &mask_y_off);
|
||||
}
|
||||
|
||||
while (nrect--) {
|
||||
INT16 x_source;
|
||||
INT16 y_source;
|
||||
|
@ -937,24 +1085,11 @@ glamor_composite_with_shader(CARD8 op,
|
|||
glamor_set_transformed_point(mask, mask_pixmap,
|
||||
mask_texcoords + 6, tx1, ty2);
|
||||
}
|
||||
#if 0
|
||||
else memset(mask_texcoords, 0, sizeof(mask_texcoords));
|
||||
for (i = 0; i < 4; i++) {
|
||||
ErrorF("%d: (%04.4f, %04.4f) (%04.4f, %04.4f) "
|
||||
"(%04.4f, %04.4f)\n",
|
||||
i,
|
||||
source_texcoords[i][0], source_texcoords[i][1],
|
||||
mask_texcoords[i][0], mask_texcoords[i][1],
|
||||
vertices[i][0], vertices[i][1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
glamor_emit_composite_rect(screen, source_texcoords,
|
||||
mask_texcoords, vertices);
|
||||
}
|
||||
rects++;
|
||||
}
|
||||
|
||||
glamor_flush_composite_rects(screen);
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
@ -971,9 +1106,14 @@ glamor_composite_with_shader(CARD8 op,
|
|||
glActiveTexture(GL_TEXTURE1);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glUseProgramObjectARB(0);
|
||||
if (saved_source_format)
|
||||
source->format = saved_source_format;
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
if (saved_source_format)
|
||||
source->format = saved_source_format;
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glUseProgramObjectARB(0);
|
||||
return FALSE;
|
||||
|
@ -1038,7 +1178,7 @@ glamor_composite(CARD8 op,
|
|||
if (glamor_composite_with_shader(op, source, mask, dest, 1, &rect))
|
||||
return;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
glamor_fallback("glamor_composite(): "
|
||||
"from picts %p/%p(%c,%c) to pict %p (%c)\n",
|
||||
source, mask,
|
||||
|
@ -1049,12 +1189,11 @@ fail:
|
|||
|
||||
glUseProgramObjectARB(0);
|
||||
glDisable(GL_BLEND);
|
||||
if (glamor_prepare_access(dest->pDrawable, GLAMOR_ACCESS_RW)) {
|
||||
if (source->pDrawable == NULL ||
|
||||
glamor_prepare_access(source->pDrawable, GLAMOR_ACCESS_RO))
|
||||
if (glamor_prepare_access_picture(dest, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_picture(source, GLAMOR_ACCESS_RO))
|
||||
{
|
||||
if (!mask || mask->pDrawable == NULL ||
|
||||
glamor_prepare_access(mask->pDrawable, GLAMOR_ACCESS_RO))
|
||||
if (!mask ||
|
||||
glamor_prepare_access_picture(mask, GLAMOR_ACCESS_RO))
|
||||
{
|
||||
fbComposite(op,
|
||||
source, mask, dest,
|
||||
|
@ -1062,13 +1201,12 @@ fail:
|
|||
x_mask, y_mask,
|
||||
x_dest, y_dest,
|
||||
width, height);
|
||||
if (mask && mask->pDrawable != NULL)
|
||||
glamor_finish_access(mask->pDrawable);
|
||||
if (mask)
|
||||
glamor_finish_access_picture(mask);
|
||||
}
|
||||
if (source->pDrawable != NULL)
|
||||
glamor_finish_access(source->pDrawable);
|
||||
glamor_finish_access_picture(source);
|
||||
}
|
||||
glamor_finish_access(dest->pDrawable);
|
||||
glamor_finish_access_picture(dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,46 +37,23 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
{
|
||||
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
GLenum format, type;
|
||||
uint8_t *temp_src = NULL, *drawpixels_src = (uint8_t *)src;
|
||||
int i, j;
|
||||
int wmax = 0;
|
||||
int ax, i;
|
||||
uint8_t *drawpixels_src = (uint8_t *)src;
|
||||
RegionPtr clip = fbGetCompositeClip(gc);
|
||||
BoxRec *pbox;
|
||||
int x_off, y_off;
|
||||
|
||||
goto fail;
|
||||
|
||||
for (i = 0 ; i < n; i++) {
|
||||
if (wmax < widths[i])
|
||||
wmax = widths[i];
|
||||
}
|
||||
|
||||
switch (drawable->depth) {
|
||||
case 1:
|
||||
temp_src = malloc(wmax);
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
drawpixels_src = temp_src;
|
||||
break;
|
||||
case 8:
|
||||
format = GL_ALPHA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case 24:
|
||||
format = GL_RGB;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case 32:
|
||||
format = GL_BGRA;
|
||||
type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
default:
|
||||
glamor_fallback("glamor_set_spans()Unknown depth %d\n",
|
||||
if (glamor_get_tex_format_type_from_pixmap(dest_pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&ax
|
||||
)) {
|
||||
glamor_fallback("unknown depth. %d \n",
|
||||
drawable->depth);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_destination_pixmap(dest_pixmap))
|
||||
if (glamor_set_destination_pixmap(dest_pixmap))
|
||||
goto fail;
|
||||
if (!glamor_set_planemask(dest_pixmap, gc->planemask))
|
||||
goto fail;
|
||||
|
@ -87,14 +64,6 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (temp_src) {
|
||||
for (j = 0; j < widths[i]; j++) {
|
||||
if (src[j / 8] & (1 << (j % 8)))
|
||||
temp_src[j] = 0xff;
|
||||
else
|
||||
temp_src[j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
n = REGION_NUM_RECTS(clip);
|
||||
pbox = REGION_RECTS(clip);
|
||||
|
@ -113,19 +82,14 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
format, type,
|
||||
drawpixels_src);
|
||||
}
|
||||
if (temp_src) {
|
||||
src += PixmapBytePad(widths[i], drawable->depth);
|
||||
} else {
|
||||
drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
}
|
||||
fail:
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glamor_set_planemask(dest_pixmap, ~0);
|
||||
glamor_set_alu(GXcopy);
|
||||
free(temp_src);
|
||||
|
||||
glamor_fallback("glamor_set_spans(): to %p (%c)\n",
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbSetSpans(drawable, gc, src, points, widths, n, sorted);
|
||||
|
|
|
@ -91,24 +91,26 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
glamor_pixmap_private *tile_priv = glamor_get_pixmap_private(tile);
|
||||
float vertices[4][2];
|
||||
float source_texcoords[4][2];
|
||||
|
||||
if (glamor_priv->tile_prog == 0) {
|
||||
glamor_fallback("Tiling unsupported\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_destination_pixmap(pixmap))
|
||||
if (glamor_set_destination_pixmap(pixmap)) {
|
||||
glamor_fallback("dest has no fbo.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (tile_priv->tex == 0) {
|
||||
if (tile_priv->gl_tex == 0) {
|
||||
glamor_fallback("Non-texture tile pixmap\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planemask))
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback("unsupported planemask %lx\n", planemask);
|
||||
goto fail;
|
||||
}
|
||||
glamor_set_alu(alu);
|
||||
|
||||
glUseProgramObjectARB(glamor_priv->tile_prog);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
|
|
@ -45,7 +45,7 @@ ephyr_glamor_init(ScreenPtr screen)
|
|||
|
||||
ephyr_glamor_host_create_context(kd_screen);
|
||||
|
||||
glamor_init(screen, 0);
|
||||
glamor_init(screen, GLAMOR_HOSTX);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -113,8 +113,7 @@ glamor_resize(ScrnInfoPtr scrn, int width, int height)
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
|
||||
|
||||
glamor_set_pixmap_texture(screen->GetScreenPixmap(screen),
|
||||
width, height, texture);
|
||||
glamor_set_screen_pixmap_texture(screen, width, height, texture);
|
||||
glamor->root = image;
|
||||
scrn->virtualX = width;
|
||||
scrn->virtualY = height;
|
||||
|
|
Loading…
Reference in New Issue