st/dri: Add support for GLX_EXT_texture_from_pixmap with direct rendering.
authorMichel Dänzer <daenzer@vmware.com>
Thu, 13 Aug 2009 18:24:09 +0000 (20:24 +0200)
committerMichel Dänzer <daenzer@vmware.com>
Thu, 13 Aug 2009 18:24:09 +0000 (20:24 +0200)
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_drawable.h
src/gallium/state_trackers/dri/dri_screen.c

index 1d91fbb89fbb05daac3baed5db043816cf64ee2e..0a952f7b2840ae4b7089866a15b3a7311c481d5b 100644 (file)
@@ -204,6 +204,30 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
    st_resize_framebuffer(drawable->stfb, dri_drawable->w, dri_drawable->h);
 }
 
+/**
+ * These are used for GLX_EXT_texture_from_pixmap
+ */
+void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
+                          GLint format, __DRIdrawable *dPriv)
+{
+   struct dri_drawable *drawable = dri_drawable(dPriv);
+   struct pipe_surface *ps;
+
+   dri_get_buffers(drawable->dPriv);
+   st_get_framebuffer_surface(drawable->stfb, ST_SURFACE_FRONT_LEFT, &ps);
+
+   st_bind_texture_surface(ps, target == GL_TEXTURE_2D ? ST_TEXTURE_2D :
+                           ST_TEXTURE_RECT, 0,
+                           format == GLX_TEXTURE_FORMAT_RGBA_EXT ?
+                           PIPE_FORMAT_R8G8B8A8_UNORM : PIPE_FORMAT_R8G8B8X8_UNORM);
+}
+
+void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
+                         __DRIdrawable *dPriv)
+{
+   dri2_set_tex_buffer2(pDRICtx, target, GLX_TEXTURE_FORMAT_RGBA_EXT, dPriv);
+}
+
 void
 dri_flush_frontbuffer(struct pipe_screen *screen,
                      struct pipe_surface *surf, void *context_private)
index 2fbd5f1eb7cc6dc0774fed6f3aedabdd6ad10f11..dfd0b8766d2206edc3795408fba899f1e94a2b45 100644 (file)
@@ -91,6 +91,12 @@ void dri_get_buffers(__DRIdrawablePrivate * dPriv);
 
 void dri_destroy_buffer(__DRIdrawablePrivate * dPriv);
 
+void dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
+                          GLint glx_texture_format, __DRIdrawable *dPriv);
+
+void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
+                         __DRIdrawable *dPriv);
+
 void
 dri1_update_drawables(struct dri_context *ctx,
                      struct dri_drawable *draw, struct dri_drawable *read);
index 5f78b7264af49b89c34492ce7c556afe19a8e139..25555128f931f6595237f6db4eadbfafdec362cb 100644 (file)
@@ -57,12 +57,19 @@ PUBLIC const char __driConfigOptions[] =
 
    const uint __driNConfigOptions = 3;
 
+static const __DRItexBufferExtension dri2TexBufferExtension = {
+    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+   dri2_set_tex_buffer,
+   dri2_set_tex_buffer2,
+};
+
    static const __DRIextension *dri_screen_extensions[] = {
       &driReadDrawableExtension,
       &driCopySubBufferExtension.base,
       &driSwapControlExtension.base,
       &driFrameTrackingExtension.base,
       &driMediaStreamCounterExtension.base,
+      &dri2TexBufferExtension.base,
       NULL
    };