[Mesa-dev] [PATCH 1/3] egl: add EGL_NV_post_sub_buffer

Chia-I Wu olvaffe at gmail.com
Wed Dec 14 23:16:14 PST 2011


On Thu, Dec 15, 2011 at 5:21 AM, Ian Romanick <idr at freedesktop.org> wrote:
> On 12/14/2011 12:24 PM, Fredrik Höglund wrote:
>>
>> v2: Handle EGL_POST_SUB_BUFFER_SUPPORTED_NV in
>>     _eglParseSurfaceAttribList()
>>
>> Signed-off-by: Fredrik Höglund<fredrik at kde.org>
>> ---
>>  include/EGL/eglext.h      |    9 +++++++++
>>  src/egl/main/eglapi.c     |   24 ++++++++++++++++++++++++
>>  src/egl/main/eglapi.h     |    8 ++++++++
>>  src/egl/main/egldisplay.h |    2 ++
>>  src/egl/main/eglmisc.c    |    2 ++
>>  src/egl/main/eglsurface.c |   23 +++++++++++++++++++++++
>>  src/egl/main/eglsurface.h |    4 ++++
>>  7 files changed, 72 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
>> index 9484b83..d03a24d 100644
>> --- a/include/EGL/eglext.h
>> +++ b/include/EGL/eglext.h
>> @@ -144,6 +144,15 @@ typedef EGLImageKHR (EGLAPIENTRYP
>> PFNEGLCREATEDRMIMAGEMESA) (EGLDisplay dpy, con
>>  typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESA) (EGLDisplay
>> dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
>>  #endif
>>
>> +#ifndef EGL_NV_post_sub_buffer
>> +#define EGL_NV_post_sub_buffer 1
>> +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV       0x30BE
>> +#ifdef EGL_EGLEXT_PROTOTYPES
>> +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV(EGLDisplay dpy,
>> EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
>> +#endif /* EGL_EGLEXT_PROTOTYPES */
>> +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay
>> dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
>> +#endif
>> +
>>  #ifndef EGL_WL_bind_wayland_display
>>  #define EGL_WL_bind_wayland_display 1
>>
>
> I think we may be treating this file incorrectly.  It's my understanding
> that eglext.h comes from Khronos, and we don't get to modify it.  Our
> current eglext.h is based on version 7 (current version is 10), and it has
> diverged quite a bit.  I want to ping folks at Khronos and figure out how
> we're supposed to deal with this file.
That is great.  I always download the latest eglext.h and add our
changes to it when I need to update the file.

>
>> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
>> index 3cb1a5b..ff15476 100644
>> --- a/src/egl/main/eglapi.c
>> +++ b/src/egl/main/eglapi.c
>> @@ -951,6 +951,9 @@ eglGetProcAddress(const char *procname)
>>  #ifdef EGL_ANDROID_swap_rectangle
>>        { "eglSetSwapRectangleANDROID", (_EGLProc)
>> eglSetSwapRectangleANDROID },
>>  #endif
>> +#ifdef EGL_NV_post_sub_buffer
>
>
> It seems weird that we define this in our own header file, then check to see
> if it's defined.  I understand that the new code is just following the
> pattern of the existing code.  Perhaps Kristian or Chia-I can shed some
> light on this convention.
The convention was established before I started working on EGL.  I
agree with you that those checks are unnecessary (and ugly..).  I will
remove them in a separate patch, if no one objects.

>> +      { "eglPostSubBufferNV", (_EGLProc) eglPostSubBufferNV },
>> +#endif
>>        { NULL, NULL }
>>     };
>>     EGLint i;
>> @@ -1590,3 +1593,24 @@ eglSetSwapRectangleANDROID(EGLDisplay dpy,
>> EGLSurface draw,
>>     RETURN_EGL_EVAL(disp, ret);
>>  }
>>  #endif
>> +
>> +#ifdef EGL_NV_post_sub_buffer
>> +EGLBoolean EGLAPIENTRY
>> +eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface,
>> +                   EGLint x, EGLint y, EGLint width, EGLint height)
>> +{
>> +   _EGLDisplay *disp = _eglLockDisplay(dpy);
>> +   _EGLSurface *surf = _eglLookupSurface(surface, disp);
>> +   _EGLDriver *drv;
>> +   EGLBoolean ret;
>> +
>> +   _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
>> +
>> +   if (!disp->Extensions.NV_post_sub_buffer)
>> +      RETURN_EGL_EVAL(disp, EGL_FALSE);
>> +
>> +   ret = drv->API.PostSubBufferNV(drv, disp, surf, x, y, width, height);
>> +
>> +   RETURN_EGL_EVAL(disp, ret);
>> +}
>> +#endif
>> diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
>> index 1e0aef6..f374273 100644
>> --- a/src/egl/main/eglapi.h
>> +++ b/src/egl/main/eglapi.h
>> @@ -135,6 +135,10 @@ typedef EGLBoolean
>> (*UnbindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *dis
>>  typedef EGLBoolean (*SetSwapRectangleANDROID_t)(_EGLDriver *drv,
>> _EGLDisplay *disp, _EGLSurface *draw, EGLint left, EGLint top, EGLint width,
>> EGLint height);
>>  #endif
>>
>> +#ifdef EGL_NV_post_sub_buffer
>> +typedef EGLBoolean (*PostSubBufferNV_t)(_EGLDriver *drv, _EGLDisplay
>> *disp, _EGLSurface *surface, EGLint x, EGLint y, EGLint width, EGLint
>> height);
>> +#endif
>> +
>>  /**
>>   * The API dispatcher jumps through these functions
>>   */
>> @@ -218,6 +222,10 @@ struct _egl_api
>>  #ifdef EGL_ANDROID_swap_rectangle
>>     SetSwapRectangleANDROID_t SetSwapRectangleANDROID;
>>  #endif
>> +
>> +#ifdef EGL_NV_post_sub_buffer
>> +   PostSubBufferNV_t PostSubBufferNV;
>> +#endif
>>  };
>>
>>  #endif /* EGLAPI_INCLUDED */
>> diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
>> index 67a2e24..8f737df 100644
>> --- a/src/egl/main/egldisplay.h
>> +++ b/src/egl/main/egldisplay.h
>> @@ -112,6 +112,8 @@ struct _egl_extensions
>>
>>     EGLBoolean ANDROID_image_native_buffer;
>>     EGLBoolean ANDROID_swap_rectangle;
>> +
>> +   EGLBoolean NV_post_sub_buffer;
>>  };
>>
>>
>> diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
>> index ab48bc6..30cd04e 100644
>> --- a/src/egl/main/eglmisc.c
>> +++ b/src/egl/main/eglmisc.c
>> @@ -116,6 +116,8 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
>>
>>     _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
>>     _EGL_CHECK_EXTENSION(ANDROID_swap_rectangle);
>> +
>> +   _EGL_CHECK_EXTENSION(NV_post_sub_buffer);
>>  #undef _EGL_CHECK_EXTENSION
>>  }
>>
>> diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
>> index 3564ecd..2db801a 100644
>> --- a/src/egl/main/eglsurface.c
>> +++ b/src/egl/main/eglsurface.c
>> @@ -170,6 +170,20 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const
>> EGLint *attrib_list)
>>           }
>>           surf->RenderBuffer = val;
>>           break;
>> +#ifdef EGL_NV_post_sub_buffer
>> +      case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
>> +         if (!dpy->Extensions.NV_post_sub_buffer ||
>> +             type != EGL_WINDOW_BIT) {
>> +            err = EGL_BAD_ATTRIBUTE;
>> +            break;
>> +         }
>> +         if (val != EGL_TRUE&&  val != EGL_FALSE) {
>>
>> +            err = EGL_BAD_PARAMETER;
>> +            break;
>> +         }
>> +         surf->PostSubBufferSupportedNV = val;
>> +         break;
>> +#endif
>>        /* pbuffer surface attributes */
>>        case EGL_WIDTH:
>>           if (type != EGL_PBUFFER_BIT) {
>> @@ -323,6 +337,10 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy,
>> EGLint type,
>>     surf->VerticalResolution = EGL_UNKNOWN;
>>     surf->AspectRatio = EGL_UNKNOWN;
>>
>> +#ifdef EGL_NV_post_sub_buffer
>> +   surf->PostSubBufferSupportedNV = EGL_FALSE;
>> +#endif
>> +
>>     /* the default swap interval is 1 */
>>     _eglClampSwapInterval(surf, 1);
>>
>> @@ -392,6 +410,11 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy,
>> _EGLSurface *surface,
>>     case EGL_VG_COLORSPACE:
>>        *value = surface->VGColorspace;
>>        break;
>> +#ifdef EGL_NV_post_sub_buffer
>> +   case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
>> +      *value = surface->PostSubBufferSupportedNV;
>> +      break;
>> +#endif
>>     default:
>>        _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
>>        return EGL_FALSE;
>> diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
>> index 0541ff4..7b774da 100644
>> --- a/src/egl/main/eglsurface.h
>> +++ b/src/egl/main/eglsurface.h
>> @@ -73,6 +73,10 @@ struct _egl_surface
>>
>>     /* True if the surface is bound to an OpenGL ES texture */
>>     EGLBoolean BoundToTexture;
>> +
>> +#ifdef EGL_NV_post_sub_buffer
>> +   EGLBoolean PostSubBufferSupportedNV;
>> +#endif
>>  };
>>
>>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev



-- 
olv at LunarG.com


More information about the mesa-dev mailing list