Bug 14041 - glPixelStore effect glCopyTexImage2D with ati driver
Summary: glPixelStore effect glCopyTexImage2D with ati driver
Status: RESOLVED WORKSFORME
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/r300 (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-12 11:34 UTC by Yaniv Kamay
Modified: 2011-05-06 05:24 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
ati and fglrx screenshots (153.00 KB, application/octet-stream)
2008-01-12 11:34 UTC, Yaniv Kamay
Details

Description Yaniv Kamay 2008-01-12 11:34:29 UTC
Created attachment 13675 [details]
ati and fglrx screenshots

01:00.0 VGA compatible controller: ATI Technologies Inc RV350 AP [Radeon 9600]
mesa 7.0.1
xorg-ati 1:6.7.195
xorg 1:7.2

glCopyTexImage2D generate bad texture if GL_UNPACK_ROW_LENGTH is set while using ati driver. the texture is generated ok while using fglrx or nvidia binary drivers.

According to ogl glCopyTexImage2D documentation
            "The pixels in the rectangle are processed exactly as if
            glCopyPixels had been called, but the process stops just before
            final conversion"
and in glCopyPixels documentation
            "Modes specified by glPixelStore have no effect on the operation
            of glCopyPixels."

in any case both source and destination are in internal format so glPixelStore is irrelevant.


the following example demonstrate the problem.


void draw()
{
    GLuint texture;
    int src_x = 10;
    int src_y = 10;
    int copy_x = src_x + image.width + 10;
    int copy_y = src_y + image.height + 10;
    int copy_width = 64;
    int copy_height = 64;


    glClear(GL_COLOR_BUFFER_BIT);
    glRasterPos2i(src_x, src_y);
    glPixelStorei(GL_UNPACK_ROW_LENGTH, image.width);
    glDrawPixels(image.width, image.height, GL_BGRA, GL_UNSIGNED_BYTE, image.pixels);

    glColor3f(1, 0, 0);
    glBegin(GL_LINE_LOOP);
        glVertex2f(copy_x - 1, copy_y);
	glVertex2f(copy_x + copy_width, copy_y);
        glVertex2f(copy_x + copy_width, copy_y +  copy_height + 1);
        glVertex2f(copy_x -1, copy_y + copy_height + 1);
    glEnd();

    glEnable(GL_TEXTURE_2D);
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, src_x, src_y, copy_width, copy_height, 0);
    
    GLfloat s_gen_params[] = { 1.0 / copy_width, 0, 0, 0 }; 
    GLfloat t_gen_params[] = { 0, 1.0 / copy_height, 0, 0 };
    glTexGenfv(GL_S, GL_OBJECT_PLANE, s_gen_params);
    glTexGenfv(GL_T, GL_OBJECT_PLANE, t_gen_params);
    
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();

    glTranslatef((float)-copy_x / copy_width, (float)-copy_y / copy_height, 0);
    glRecti(copy_x, copy_y, copy_x + copy_width, copy_y + copy_height);

    glFinish();
    glDeleteTextures(1, &texture);
    glDisable(GL_TEXTURE_2D);
}

static void init(int width, int height)
{
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, width, 0, height, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glClearColor(0, 0, 0, 0);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
    glEnable(GL_TEXTURE_GEN_S); 
    glEnable(GL_TEXTURE_GEN_T);
}
Comment 1 Michel Dänzer 2008-01-13 23:34:39 UTC
The r300 driver isn't actively involved in CopyTexImage, so this is probably a core issue.
Comment 2 Marek Olšák 2011-03-01 14:27:16 UTC
The CopyTexImage function was rewritten in the r300 classic driver, but the driver is no longer maintained.

Is this issue present with the r300 gallium3d driver or in any other hw or sw driver?
Comment 3 Marek Olšák 2011-03-01 16:53:13 UTC
Reassigning to r300g, so that I don't forget about it.
Comment 4 Marek Olšák 2011-05-06 05:24:28 UTC
I guess this predates CopyTexImage acceleration. Closing.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.