From 4e5934fed17373e55bd2bac6a35632734beeab30 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 14 Sep 2009 16:06:51 +0800 Subject: intel: Add support for GL_OES_EGL_image. This is primitive and some pathes are not tested. --- src/mesa/drivers/dri/i915/Makefile | 1 + src/mesa/drivers/dri/i915/intel_eglimage.c | 1 + src/mesa/drivers/dri/i915/intel_eglimage.h | 1 + src/mesa/drivers/dri/intel/intel_context.c | 3 + src/mesa/drivers/dri/intel/intel_eglimage.c | 139 ++++++++++++++++++++++++++ src/mesa/drivers/dri/intel/intel_eglimage.h | 61 +++++++++++ src/mesa/drivers/dri/intel/intel_extensions.c | 3 + 7 files changed, 209 insertions(+) create mode 120000 src/mesa/drivers/dri/i915/intel_eglimage.c create mode 120000 src/mesa/drivers/dri/i915/intel_eglimage.h create mode 100644 src/mesa/drivers/dri/intel/intel_eglimage.c create mode 100644 src/mesa/drivers/dri/intel/intel_eglimage.h diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 034c03f8b2..f5242ddc7b 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -18,6 +18,7 @@ DRIVER_SOURCES = \ intel_buffer_objects.c \ intel_batchbuffer.c \ intel_clear.c \ + intel_eglimage.c \ intel_extensions.c \ intel_generatemipmap.c \ intel_mipmap_tree.c \ diff --git a/src/mesa/drivers/dri/i915/intel_eglimage.c b/src/mesa/drivers/dri/i915/intel_eglimage.c new file mode 120000 index 0000000000..6047b254a0 --- /dev/null +++ b/src/mesa/drivers/dri/i915/intel_eglimage.c @@ -0,0 +1 @@ +../intel/intel_eglimage.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/i915/intel_eglimage.h b/src/mesa/drivers/dri/i915/intel_eglimage.h new file mode 120000 index 0000000000..a2cde85a28 --- /dev/null +++ b/src/mesa/drivers/dri/i915/intel_eglimage.h @@ -0,0 +1 @@ +../intel/intel_eglimage.h \ No newline at end of file diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index a38ecce65b..7a2e7617d0 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -54,6 +54,7 @@ #include "intel_regions.h" #include "intel_buffer_objects.h" #include "intel_fbo.h" +#include "intel_eglimage.h" #include "intel_decode.h" #include "intel_bufmgr.h" #include "intel_screen.h" @@ -602,6 +603,8 @@ intelInitDriverFunctions(struct dd_function_table *functions) intelInitPixelFuncs(functions); intelInitBufferObjectFuncs(functions); intel_init_syncobj_functions(functions); + + intelInitEGLImageFuncs(functions); } diff --git a/src/mesa/drivers/dri/intel/intel_eglimage.c b/src/mesa/drivers/dri/intel/intel_eglimage.c new file mode 100644 index 0000000000..fed8675c26 --- /dev/null +++ b/src/mesa/drivers/dri/intel/intel_eglimage.c @@ -0,0 +1,139 @@ +/************************************************************************** + * + * Copyright (C) 2009 Chia-I Wu + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "main/mtypes.h" +#include "main/teximage.h" + +#include "intel_context.h" +#include "intel_fbo.h" +#include "intel_tex.h" + +#include "intel_eglimage.h" +#include "main/eglimage.h" + +#include "EGL/internal/eglimage_dri.h" + + +#if FEATURE_OES_EGL_image + + +/* move to intel_fbo.c */ +static void +copy_renderbuffer(struct intel_renderbuffer *dst, + struct intel_renderbuffer *src) +{ + dst->Base.Width = src->Base.Width; + dst->Base.Height = src->Base.Height; + dst->Base.InternalFormat = src->Base.InternalFormat; + dst->Base._ActualFormat = src->Base._ActualFormat; + dst->Base._BaseFormat = src->Base._BaseFormat; + + dst->Base.ColorEncoding = src->Base.ColorEncoding; + dst->Base.ComponentType = src->Base.ComponentType; + + dst->Base.RedBits = src->Base.RedBits; + dst->Base.GreenBits = src->Base.GreenBits; + dst->Base.BlueBits = src->Base.BlueBits; + dst->Base.AlphaBits = src->Base.AlphaBits; + dst->Base.IndexBits = src->Base.IndexBits; + dst->Base.DepthBits = src->Base.DepthBits; + dst->Base.StencilBits = src->Base.StencilBits; + dst->Base.NumSamples = src->Base.NumSamples; + + dst->Base.DataType = src->Base.DataType; + + intel_renderbuffer_set_region(dst, src->region); +} + +static __DRIEGLImage * +get_image(GLcontext *ctx, GLeglImageOES image) +{ + __DRIEGLImage *driImage; + + driImage = _eglClientGetImageData((__DRIEGLImageHandle) image); + if (!driImage || driImage->magic != __DRI_EGL_IMAGE_MAGIC) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glEGLImageTargetTexture2DOES(image=0x%x)", image); + return NULL; + } + + return driImage; +} + +void +intelEGLImageTargetRenderbufferStorage(GLcontext *ctx, + struct gl_renderbuffer *rb, + GLeglImageOES image) +{ + struct intel_renderbuffer *irb = intel_renderbuffer(rb); + __DRIEGLImage *driImage; + struct intel_framebuffer *image_fb; + struct intel_renderbuffer *image_rb; + + driImage = get_image(ctx, image); + if (!driImage) + return; + + image_fb = driImage->drawable->driverPrivate; + image_rb = image_fb->color_rb[0]; + + copy_renderbuffer(irb, image_rb); +} + + +void +intelEGLImageTargetTexture2D(GLcontext *ctx, + struct gl_texture_object *texObj, + GLeglImageOES image) +{ + struct intel_context *intel = intel_context(ctx); + __DRIEGLImage *driImage; + GLint glx_texture_format; + + driImage = get_image(ctx, image); + if (!driImage) + return; + + /* only level == 0 is supported */ + if (driImage->level) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetTexture2DOES(level=%d)", driImage->level); + return; + } + + glx_texture_format = (driImage->texture_format_rgba) + ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT; + + /* TODO refactor intelSetTexBuffer2 to avoid lock... */ + _mesa_unlock_texture(ctx, texObj); + intelSetTexBuffer2(intel->driContext, texObj->Target, glx_texture_format, + driImage->drawable); + _mesa_lock_texture(ctx, texObj); +} + + +#endif /* FEATURE_OES_EGL_image */ diff --git a/src/mesa/drivers/dri/intel/intel_eglimage.h b/src/mesa/drivers/dri/intel/intel_eglimage.h new file mode 100644 index 0000000000..ef1bf2eacd --- /dev/null +++ b/src/mesa/drivers/dri/intel/intel_eglimage.h @@ -0,0 +1,61 @@ +/************************************************************************** + * + * Copyright (C) 2009 Chia-I Wu + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef INTEL_EGLIMAGE_H +#define INTEL_EGLIMAGE_H + +#include "main/mtypes.h" + +/* main/eglimage.h might not exist */ +#if FEATURE_OES_EGL_image + +#ifndef GL_OES_EGL_image +typedef void *GLeglImageOES; +#endif + +#include "main/eglimage.h" + +extern void +intelEGLImageTargetRenderbufferStorage(GLcontext *ctx, + struct gl_renderbuffer *rb, + GLeglImageOES image); + +extern void +intelEGLImageTargetTexture2D(GLcontext *ctx, + struct gl_texture_object *texObj, + GLeglImageOES image); + +#else +#define _MESA_INIT_EGLIMAGE_FUNCTIONS(driver, impl) do { } while (0) +#endif /* FEATURE_OES_EGL_image */ + +static INLINE void +intelInitEGLImageFuncs(struct dd_function_table *functions) +{ + _MESA_INIT_EGLIMAGE_FUNCTIONS(functions, intel); +} + +#endif /* INTEL_EGLIMAGE_H */ diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c index 5431cf90a1..21af22fbfb 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.c +++ b/src/mesa/drivers/dri/intel/intel_extensions.c @@ -179,6 +179,9 @@ static const struct dri_extension ttm_extensions[] = { { "GL_ARB_pixel_buffer_object", NULL }, { "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions }, { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, +#if FEATURE_OES_EGL_image + { "GL_OES_EGL_image", NULL }, +#endif { NULL, NULL } }; -- cgit v1.2.3