diff options
| -rw-r--r-- | include/GL/internal/dri_interface.h | 13 | ||||
| -rw-r--r-- | src/mesa/drivers/dri/intel/intel_screen.c | 46 | 
2 files changed, 59 insertions, 0 deletions
| diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 27cc1be7ff..12dd726467 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -646,6 +646,19 @@ struct __DRIdri2LoaderExtensionRec {  			       int *out_count, void *loaderPrivate);  }; +#define __DRI_COPY_BUFFER "DRI_CopyBuffer" +#define __DRI_COPY_BUFFER_VERSION 1 +typedef struct __DRIcopyBufferExtensionRec __DRIcopyBufferExtension; +struct __DRIcopyBufferExtensionRec { +    __DRIextension base; + +    int (*copyBuffer)(__DRIcontext *context, +		      __DRIbuffer *dst, int dst_x, int dst_y, +		      __DRIdrawable *src, unsigned int src_attachment, +		      int x, int y, int width, int height); +}; + +  /**   * This extension provides alternative screen, drawable and context   * constructors for DRI2. 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  }; | 
