summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2009-03-05 07:40:48 -0500
committerKristian Høgsberg <krh@redhat.com>2009-03-05 07:46:44 -0500
commit8567d003d55769287a4ce0d87573216b42e13064 (patch)
treea68e9480e29a8c71bd8ffde0634e29080ed93706 /src
parentfaa6d8af59c69b0c0239f64363b170619e2a9827 (diff)
Add a DRI CopyBuffer extension to expose 2d blits.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 7042c25564..2809fadd88 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -25,6 +25,7 @@
*
**************************************************************************/
+#include <sys/ioctl.h>
#include "main/glheader.h"
#include "main/context.h"
#include "main/framebuffer.h"
@@ -211,6 +212,50 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
intelSetTexBuffer,
};
+static int
+intelCopyBufferExt(__DRIcontext *context,
+ __DRIbuffer *dst,
+ int dst_x, int dst_y,
+ __DRIdrawable *src, unsigned int src_attachment,
+ int x, int y, int width, int height)
+{
+ struct intel_framebuffer *intel_fb = src->driverPrivate;
+ struct intel_context *intel = context->driverPrivate;
+ struct intel_region *dst_region;
+ struct intel_renderbuffer *rb;
+
+ if (src_attachment != __DRI_BUFFER_FRONT_LEFT)
+ return -1;
+
+ dst_region = intel_region_alloc_for_handle(intel,
+ dst->cpp,
+ dst_x + width,
+ dst_y + height,
+ dst->pitch / dst->cpp,
+ dst->name,
+ "copyBuffer dst temp");
+
+ intel_update_renderbuffers(context, src);
+
+ rb = intel_fb->color_rb[0];
+ intel_region_copy(intel, dst_region, 0, dst_x, dst_y,
+ rb->region, 0, x, y, width, height);
+ intel_batchbuffer_flush(intel->batch);
+ intel_region_release(&dst_region);
+
+ if (ioctl(intel->driFd, DRM_IOCTL_I915_GEM_THROTTLE, NULL) < 0) {
+ fprintf(stderr, "throttle failed: %m\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static const __DRIcopyBufferExtension intelCopyBufferExtension = {
+ { __DRI_COPY_BUFFER, __DRI_COPY_BUFFER_VERSION },
+ intelCopyBufferExt,
+};
+
static const __DRIextension *intelScreenExtensions[] = {
&driReadDrawableExtension,
&driCopySubBufferExtension.base,
@@ -219,6 +264,7 @@ static const __DRIextension *intelScreenExtensions[] = {
&driMediaStreamCounterExtension.base,
&intelTexOffsetExtension.base,
&intelTexBufferExtension.base,
+ &intelCopyBufferExtension.base,
NULL
};