glamor: Fix and enable ZPixmap PutImage acceleration.
This commit is contained in:
		
							parent
							
								
									2ba634fab9
								
							
						
					
					
						commit
						9bcbcbf8c2
					
				| 
						 | 
					@ -137,6 +137,9 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
 | 
				
			||||||
	0.0, 1.0,
 | 
						0.0, 1.0,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glamor_fallback("glamor_put_image_xybitmap: disabled\n");
 | 
				
			||||||
 | 
					    goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (glamor_priv->put_image_xybitmap_prog == 0) {
 | 
					    if (glamor_priv->put_image_xybitmap_prog == 0) {
 | 
				
			||||||
	ErrorF("no program for xybitmap putimage\n");
 | 
						ErrorF("no program for xybitmap putimage\n");
 | 
				
			||||||
	goto fail;
 | 
						goto fail;
 | 
				
			||||||
| 
						 | 
					@ -158,6 +161,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
 | 
				
			||||||
    glamor_set_transform_for_pixmap(pixmap, &glamor_priv->solid_transform);
 | 
					    glamor_set_transform_for_pixmap(pixmap, &glamor_priv->solid_transform);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    glGenTextures(1, &tex);
 | 
					    glGenTextures(1, &tex);
 | 
				
			||||||
 | 
					    glActiveTexture(GL_TEXTURE0);
 | 
				
			||||||
    glEnable(GL_TEXTURE_2D);
 | 
					    glEnable(GL_TEXTURE_2D);
 | 
				
			||||||
    glBindTexture(GL_TEXTURE_2D, tex);
 | 
					    glBindTexture(GL_TEXTURE_2D, tex);
 | 
				
			||||||
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 | 
					    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 | 
				
			||||||
| 
						 | 
					@ -237,7 +241,10 @@ void
 | 
				
			||||||
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 | 
					glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 | 
				
			||||||
		 int w, int h, int left_pad, int image_format, char *bits)
 | 
							 int w, int h, int left_pad, int image_format, char *bits)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    glamor_screen_private *glamor_priv =
 | 
				
			||||||
 | 
						glamor_get_screen_private(drawable->pScreen);
 | 
				
			||||||
    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
 | 
					    PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
 | 
				
			||||||
 | 
					    glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 | 
				
			||||||
    GLenum type, format;
 | 
					    GLenum type, format;
 | 
				
			||||||
    RegionPtr clip;
 | 
					    RegionPtr clip;
 | 
				
			||||||
    BoxPtr pbox;
 | 
					    BoxPtr pbox;
 | 
				
			||||||
| 
						 | 
					@ -245,14 +252,8 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 | 
				
			||||||
    int bpp = drawable->bitsPerPixel;
 | 
					    int bpp = drawable->bitsPerPixel;
 | 
				
			||||||
    int src_stride = PixmapBytePad(w, drawable->depth);
 | 
					    int src_stride = PixmapBytePad(w, drawable->depth);
 | 
				
			||||||
    int x_off, y_off;
 | 
					    int x_off, y_off;
 | 
				
			||||||
 | 
					    float vertices[4][2], texcoords[4][2];
 | 
				
			||||||
    goto fail;
 | 
					    GLuint tex;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!glamor_set_destination_pixmap(pixmap)) {
 | 
					 | 
				
			||||||
	fbPutImage(drawable, gc, depth, x, y, w, h, left_pad,
 | 
					 | 
				
			||||||
		   image_format, bits);
 | 
					 | 
				
			||||||
	return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (image_format == XYBitmap) {
 | 
					    if (image_format == XYBitmap) {
 | 
				
			||||||
	assert(depth == 1);
 | 
						assert(depth == 1);
 | 
				
			||||||
| 
						 | 
					@ -261,13 +262,26 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (pixmap_priv == NULL) {
 | 
				
			||||||
 | 
						glamor_fallback("glamor_put_image: system memory pixmap\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)
 | 
					    if (bpp == 1 && image_format == XYPixmap)
 | 
				
			||||||
	image_format = ZPixmap;
 | 
						image_format = ZPixmap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!glamor_set_planemask(pixmap, gc->planemask))
 | 
					 | 
				
			||||||
	goto fail;
 | 
					 | 
				
			||||||
    if (image_format != ZPixmap) {
 | 
					    if (image_format != ZPixmap) {
 | 
				
			||||||
	ErrorF("putimage: non-ZPixmap\n");
 | 
						glamor_fallback("glamor_put_image: non-ZPixmap\n");
 | 
				
			||||||
	goto fail;
 | 
						goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -281,29 +295,57 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 | 
				
			||||||
	type = GL_UNSIGNED_BYTE;
 | 
						type = GL_UNSIGNED_BYTE;
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
    case 24:
 | 
					    case 24:
 | 
				
			||||||
	format = GL_RGB;
 | 
						assert(drawable->bitsPerPixel == 32);
 | 
				
			||||||
	type = GL_UNSIGNED_BYTE;
 | 
						/* FALLTHROUGH */
 | 
				
			||||||
	break;
 | 
					 | 
				
			||||||
    case 32:
 | 
					    case 32:
 | 
				
			||||||
	format = GL_BGRA;
 | 
						format = GL_BGRA;
 | 
				
			||||||
	type = GL_UNSIGNED_INT_8_8_8_8_REV;
 | 
						type = GL_UNSIGNED_INT_8_8_8_8_REV;
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
	ErrorF("stub put_image depth %d\n", drawable->depth);
 | 
						glamor_fallback("glamor_putimage: bad depth %d\n", drawable->depth);
 | 
				
			||||||
	goto fail;
 | 
						goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!glamor_set_planemask(pixmap, gc->planemask))
 | 
				
			||||||
 | 
						goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    glamor_set_alu(gc->alu);
 | 
					    glamor_set_alu(gc->alu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glVertexPointer(2, GL_FLOAT, sizeof(float) * 2, vertices);
 | 
				
			||||||
 | 
					    glEnableClientState(GL_VERTEX_ARRAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glClientActiveTexture(GL_TEXTURE0);
 | 
				
			||||||
 | 
					    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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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);
 | 
				
			||||||
 | 
					    glBindTexture(GL_TEXTURE_2D, tex);
 | 
				
			||||||
 | 
					    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
 | 
				
			||||||
 | 
							 w, h, 0,
 | 
				
			||||||
 | 
							 format, type, bits);
 | 
				
			||||||
 | 
					    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);
 | 
				
			||||||
 | 
					    glUseProgramObjectARB(glamor_priv->finish_access_prog);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    x += drawable->x;
 | 
					    x += drawable->x;
 | 
				
			||||||
    y += drawable->y;
 | 
					    y += drawable->y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
 | 
					    glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 | 
					 | 
				
			||||||
    glPixelStorei(GL_UNPACK_ROW_LENGTH, src_stride * 8 / bpp);
 | 
					 | 
				
			||||||
    if (bpp == 1)
 | 
					 | 
				
			||||||
	glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
 | 
					 | 
				
			||||||
    clip = fbGetCompositeClip(gc);
 | 
					    clip = fbGetCompositeClip(gc);
 | 
				
			||||||
    for (nbox = REGION_NUM_RECTS(clip),
 | 
					    for (nbox = REGION_NUM_RECTS(clip),
 | 
				
			||||||
	 pbox = REGION_RECTS(clip);
 | 
						 pbox = REGION_RECTS(clip);
 | 
				
			||||||
| 
						 | 
					@ -314,7 +356,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 | 
				
			||||||
	int y1 = y;
 | 
						int y1 = y;
 | 
				
			||||||
	int x2 = x + w;
 | 
						int x2 = x + w;
 | 
				
			||||||
	int y2 = y + h;
 | 
						int y2 = y + h;
 | 
				
			||||||
	char *src;
 | 
						float src_x1, src_x2, src_y1, src_y2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (x1 < pbox->x1)
 | 
						if (x1 < pbox->x1)
 | 
				
			||||||
	    x1 = pbox->x1;
 | 
						    x1 = pbox->x1;
 | 
				
			||||||
| 
						 | 
					@ -327,13 +369,37 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
 | 
				
			||||||
	if (x1 >= x2 || y1 >= y2)
 | 
						if (x1 >= x2 || y1 >= y2)
 | 
				
			||||||
	    continue;
 | 
						    continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	src = bits + (y1 - y) * src_stride + (x1 - x) * (bpp / 8);
 | 
						src_x1 = (float)(x1 - x) / w;
 | 
				
			||||||
	glRasterPos2i(x1 + x_off, y1 + y_off);
 | 
						src_y1 = (float)(y1 - y) / h;
 | 
				
			||||||
	glDrawPixels(x2 - x1,
 | 
						src_x2 = (float)(x2 - x) / w;
 | 
				
			||||||
		     y2 - y1,
 | 
						src_y2 = (float)(y2 - y) / h;
 | 
				
			||||||
		     format, type,
 | 
					
 | 
				
			||||||
		     src);
 | 
						vertices[0][0] = v_from_x_coord_x(pixmap, x1 + x_off);
 | 
				
			||||||
 | 
						vertices[0][1] = v_from_x_coord_y(pixmap, y1 + y_off);
 | 
				
			||||||
 | 
						vertices[1][0] = v_from_x_coord_x(pixmap, x2 + x_off);
 | 
				
			||||||
 | 
						vertices[1][1] = v_from_x_coord_y(pixmap, y1 + y_off);
 | 
				
			||||||
 | 
						vertices[2][0] = v_from_x_coord_x(pixmap, x2 + x_off);
 | 
				
			||||||
 | 
						vertices[2][1] = v_from_x_coord_y(pixmap, y2 + y_off);
 | 
				
			||||||
 | 
						vertices[3][0] = v_from_x_coord_x(pixmap, x1 + x_off);
 | 
				
			||||||
 | 
						vertices[3][1] = v_from_x_coord_y(pixmap, y2 + y_off);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						texcoords[0][0] = src_x1;
 | 
				
			||||||
 | 
						texcoords[0][1] = src_y1;
 | 
				
			||||||
 | 
						texcoords[1][0] = src_x2;
 | 
				
			||||||
 | 
						texcoords[1][1] = src_y1;
 | 
				
			||||||
 | 
						texcoords[2][0] = src_x2;
 | 
				
			||||||
 | 
						texcoords[2][1] = src_y2;
 | 
				
			||||||
 | 
						texcoords[3][0] = src_x1;
 | 
				
			||||||
 | 
						texcoords[3][1] = src_y2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glDisable(GL_TEXTURE_2D);
 | 
				
			||||||
 | 
					    glUseProgramObjectARB(0);
 | 
				
			||||||
 | 
					    glDisableClientState(GL_VERTEX_ARRAY);
 | 
				
			||||||
 | 
					    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 | 
				
			||||||
 | 
					    glDeleteTextures(1, &tex);
 | 
				
			||||||
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
 | 
					    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
 | 
				
			||||||
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
 | 
					    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
 | 
				
			||||||
    glamor_set_alu(GXcopy);
 | 
					    glamor_set_alu(GXcopy);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue