[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#545085: [libgl1-mesa-dri] sigsegv when readpixels from frontbuffer with i915



Package: libgl1-mesa-dri
Version: 7.5.1-1
Severity: normal

I've here a bigger program which worked in previous (cannot tell which)
version of this package, but currently it seems to crash when it calls
glReadPixels. I tried to create a similar testcase for the bug report and
noticed that it only(?) happened when I tried to read from frontbuffer. The
simple test is attached to this mail. It can be compiled with:

g++ -o readpixels_z readpixels_z.cpp `sdl-config --cflags` `sdl-config --libs` -lGL -lGLU

Backtrace:
#0  0x00000000 in ?? ()
#1  0xb7729dba in _swrast_ReadPixels (ctx=0x64, x=0, y=0, width=100, height=100, format=6407, type=5121, packing=0x809a40c, pixels=0xbfff7b98)
    at swrast/s_readpix.c:605
#2  0xb7604c49 in intelReadPixels (ctx=0x808d530, x=0, y=0, width=100, height=100, format=6407, type=5121, pack=0x809a40c, pixels=0xbfff7b98)
	    at intel_pixel_read.c:305
#3  0xb7794ec6 in _mesa_ReadPixels (x=0, y=0, width=100, height=100, format=6407, type=5121, pixels=0xbfff7b98) at main/readpix.c:191
#4  0x08048e42 in Test_glReadPixels() ()
#5  0x0804908b in main ()

--- System information. ---
Architecture: i386
Kernel:       Linux 2.6.31-rc5

Debian Release: squeeze/sid
  500 unstable        ftp.debian.org 
  500 unstable        eeepc.debian.net 
    1 experimental    ftp.debian.org 

--- Package information. ---
Depends               (Version) | Installed
===============================-+-==============
libc6             (>= 2.3.6-6~) | 2.9-26
libdrm-intel1        (>= 2.4.9) | 2.4.12-1
libdrm2              (>= 2.3.1) | 2.4.12-1
libexpat1           (>= 1.95.8) | 2.0.1-4


Package's Recommends field is empty.

Suggests       (Version) | Installed
========================-+-===========
libglide3                | 
#include <iostream>
#include <GL/gl.h>
#include <GL/glu.h>
#include "SDL.h"

using namespace std;

const unsigned int WIDTH = 100;
const unsigned int HEIGHT = 100;
const unsigned int BPP = 16;

SDL_Surface *surface;

bool Test_glReadPixels()
{
	unsigned char pixels[WIDTH*HEIGHT*3];

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glBegin(GL_TRIANGLES);
	glVertex3f(-0.0f,  1.0f, -6.0f);
	glVertex3f(-1.0f, -1.0f, -6.0f);
	glVertex3f(1.0f, -1.0f, -6.0f);
	glEnd();
	SDL_GL_SwapBuffers();

	// Full Read -> all pixel at the same time
	glReadBuffer( GL_FRONT );
	glReadPixels(0, 0, WIDTH, HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, static_cast<void*>(pixels));

	return true;
}

int main()
{
	int videoFlags;
	const SDL_VideoInfo *videoInfo;

	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		cerr << "Video initialization failed: " << SDL_GetError() << endl;
		SDL_Quit();
		exit(1);
	}

	videoInfo = SDL_GetVideoInfo();
	if (!videoInfo) {
		cerr << "Video query failed: " << SDL_GetError() << endl;
		SDL_Quit();
		exit(1);
	}

	videoFlags  = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
	if (videoInfo->hw_available)
		videoFlags |= SDL_HWSURFACE;
	else
		videoFlags |= SDL_SWSURFACE;

	if (videoInfo->blit_hw)
		videoFlags |= SDL_HWACCEL;

	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	surface = SDL_SetVideoMode(WIDTH, HEIGHT, BPP, videoFlags);

	if (!surface) {
		cerr << "Video mode set failed: " << SDL_GetError() << endl;
		SDL_Quit();
		exit(1);
	}

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);

	const GLfloat ratio = static_cast<GLfloat>(WIDTH) / static_cast<GLfloat>(HEIGHT);
	glViewport(0, 0, WIDTH, HEIGHT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(45.0f, ratio, 0.25f, 100.0f);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	if (Test_glReadPixels() != true) {
		SDL_Quit();
		return 1;
	}

	SDL_Quit();
	return 0;
}

Reply to: