[Mesa3d-dev] GLX_MESA_render_texture

David Reveman davidr at novell.com
Fri Jun 10 09:50:03 PDT 2005


I rewrote most of the GLX_MESA_render_texture implementation in xserver.
The previous implementation was pretty bad, the new one is a lot better
and it's now using appropriate enumeration values and opcodes.

The implementation is still wrong in the way that it works without GLX
1.3 but it's good enough for testing.

I've attached a new patch for Mesa glx, a new patch for glxproto.h and a
slightly updated version of the GLX_MESA_render_texture spec. The spec
is still very incomplete, just want to keep it in sync with the current
implementation.

I've found a memory leak in the XMesa code. I've attached a simple fix
for this, it frees the xmesa_renderbuffer structure allocated a line 86
in xm_buffer.c.

-David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesa-glx-x11-render-texture-2.diff
Type: text/x-patch
Size: 3357 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20050610/7a485f3a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glxproto.h-mesa-render-texture-2.diff
Type: text/x-patch
Size: 434 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20050610/7a485f3a/attachment-0001.bin>
-------------- next part --------------
Name

    MESA_render_texture

Name Strings

    GLX_MESA_render_texture

Contact

    David Reveman

    To discuss, join the dri-egl at lists.freedesktop.org list.

Status

    Preliminary - totally subject to change.
    Implemented in Xgl

Version

    2 (10 June 2005)

Number

    TBD

Dependencies

    OpenGL 1.1 is required.
    GLX 1.3 is required.
    GL_ARB_texture_rectangle affects the definition of this extension.
    
Overview

    This extension allows a color buffer to be used for both rendering and
    texturing. When a color buffer is bound to a texture target it cannot 
    be rendered to. Once it has been released from the texture it can be 
    rendered to once again.

    The functionality of this extension is similar to WGL_ARB_render_texture. 
    However, the purpose of this extension is not to provide 
    "render to texture" like functionality but rather the ability to bind
    an existing window system drawable to a texture. Though, there
    is nothing that prohibits it from being used for "render to texture".

    This extension is based on WGL_ARB_render_texture. However, some changes
    were made to make it better fit the new purpose and make implementation
    easier:

    -   Not only color buffers of a pbuffer can be bound as a texture. 
        Color buffers of any GLXDrawable can be bound.

    -   The requirement that the application must release the color buffer
        from the texture before it can render to the drawable again only
        applies to drawing using contexts that share this texture.

Issues

    1. What should this extension be called?

    .


    2. Do we need a glXDrawableAttribMESA?

    Yes, clients should be able to select texture target using it. However,
    there will be no garantee that a requested target can be used. Current
    texture target must always be queried using glXQueryDrawable. 


    3. Should we support everything that WGL_ARB_render_texture supports
       or should we try to keep this extensions minimal?
       GL_ARB_texture_cube_map? 1D textures? mipmapping?

    .


New Procedures and Functions

    Bool glXBindTexImageMESA (Display     *display, 
                              GLXDrawable drawable, 
                              int         buffer)

    Bool glXReleaseTexImageMESA (Display     *display, 
                                 GLXDrawable drawable, 
                                 int         buffer)


New Tokens

    GLX_BIND_TO_TEXTURE_RGB_MESA        0x????
    GLX_BIND_TO_TEXTURE_RGBA_MESA       0x????

    GLX_TEXTURE_RGB_MESA                0x????
    GLX_TEXTURE_RGBA_MESA               0x????

    GLX_TEXTURE_TARGET_MESA             0x???? (0x6001)
    GLX_TEXTURE_2D_MESA                 0x???? (0x6002)
    GLX_TEXTURE_RECTANGLE_MESA          0x???? (0x6003)
    GLX_NO_TEXTURE_MESA                 0x???? (0x6004)

    GLX_FRONT_LEFT_MESA                 0x???? (0x6005)
    GLX_FRONT_RIGHT_MESA                0x????
    GLX_BACK_LEFT_MESA                  0x????
    GLX_BACK_RIGHT_MESA                 0x????
    GLX_AUX0_MESA                       0x???? 
    GLX_AUX1_MESA                       0x???? 
    GLX_AUX2_MESA                       0x???? 
    GLX_AUX3_MESA                       0x???? 
    GLX_AUX4_MESA                       0x???? 
    GLX_AUX5_MESA                       0x???? 
    GLX_AUX6_MESA                       0x????
    GLX_AUX7_MESA                       0x???? 
    GLX_AUX8_MESA                       0x???? 
    GLX_AUX9_MESA                       0x????


GLX Protocol

    Three new GLX protocol commands are added.

        BindTexImageMESA
            1           CARD8           opcode (X assigned)
            1           16              GLX opcode (glXVendorPrivate)
            2           8               request length
            4           65544           vendor specific opcode
            4           GLX_DRAWABLE    drawable
            4           INT32           buffer

        ReleaseTexImageMESA
            1           CARD8           opcode (X assigned)
            1           16              GLX opcode (glXVendorPrivate)
            2           4               request length
            4           65544           vendor specific opcode
            4           GLX_DRAWABLE    drawable
            4           INT32           buffer


Errors

    .


Usage Examples

    Example 1: Bind redirected window to texture:

    XGetWindowAttributes (display, window, &attrib);

    templ.visualid = XVisualIDFromVisual (attrib.visual);
    visinfo = XGetVisualInfo (display, VisualIDMask, &templ, &n_items);

    glXGetConfig (display, visinfo, GLX_USE_GL, &value);
    if (value == False)
        return ERROR_CODE_1;

    pixmap = XCompositeNameWindowPixmap (display, window);
    glxpixmap = glXCreateGLXPixmap (display, visinfo, pixmap);
    status = glXQueryDrawable (display, glxpixmap, 
                               GLX_TEXTURE_TARGET_MESA,
                               &value);
    if (status != TRUE)
	return ERROR_CODE_2;

    if (value == GLX_TEXTURE_2D_MESA)
	target = GL_TEXTURE_2D;
    else if (value == GLX_TEXTURE_RECTANGLE_MESA)
	target = GL_TEXTURE_RECTANGLE_ARB;
    else /* window can't be bound to texture */
        return ERROR_CODE_3;

    glGenTextures (1, &texture);
    glBindTexture (target, texture);

    status = glXBindTexImageMESA (display, glxpixmap, GLX_FRONT_LEFT_MESA);
    if (status != TRUE)
	return ERROR_CODE_4;

    glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);


Version History

    1. 7 June 2005 - DavidR
        Initial version
    
    2. 10 June 2005 - DavidR
        Removed glXQueryDrawable
        Require GLX 1.3
        Add GLX_BIND_TO_TEXTURE_RGB_MESA, GLX_BIND_TO_TEXTURE_RGBA_MESA,
        GLX_TEXTURE_RGB_MESA, GLX_TEXTURE_RGBA_MESA.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesa-driver-x11-mem-leak-fix.diff
Type: text/x-patch
Size: 577 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20050610/7a485f3a/attachment-0002.bin>


More information about the xorg mailing list