[Mesa-dev] [PATCH] egl/android: Fix build for Jelly Bean (v2)

Chad Versace chad.versace at linux.intel.com
Thu Dec 27 12:22:18 PST 2012


On 12/20/2012 09:00 PM, Tapani Pälli wrote:
> On 12/21/2012 01:11 AM, Chad Versace wrote:
>> In Jelly Bean, the interface to ANativeWindow changed. The change included
>> adding a new parameter the queueBuffer and dequeueBuffer methods and
>> removing the lockBuffer method.
>>
>> v2:
>>   - s/fence_fd == -1/fence_fd != -1/
>>   - Fix leak. Close the fence_fd.
>>
>> CC: Tapani Pälli <tapani.palli at intel.com>
>> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
>> ---
>>  src/egl/drivers/dri2/platform_android.c | 59 +++++++++++++++++++++++++++++++++
>>  src/egl/main/Android.mk                 |  5 +++
>>  2 files changed, 64 insertions(+)
>>
>> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
>> index 15bf054..402df11 100644
>> --- a/src/egl/drivers/dri2/platform_android.c
>> +++ b/src/egl/drivers/dri2/platform_android.c
>> @@ -31,6 +31,10 @@
>>  #include <errno.h>
>>  #include <dlfcn.h>
>>  
>> +#if ANDROID_VERSION >= 0x402
>> +#include <sync/sync.h>
>> +#endif
>> +
>>  /* for droid_get_pci_id */
>>  #include <xf86drm.h>
>>  #include <i915_drm.h>
>> @@ -79,11 +83,48 @@ get_native_buffer_name(struct ANativeWindowBuffer *buf)
>>  static EGLBoolean
>>  droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
>>  {
>> +#if ANDROID_VERSION >= 0x0402
>> +   int fence_fd;
>> +
>> +   if (dri2_surf->window->dequeueBuffer(dri2_surf->window, &dri2_surf->buffer,
>> +                                        &fence_fd))
>> +      return EGL_FALSE;
>> +
>> +   /* If access to the buffer is controlled by a sync fence, then block on the
>> +    * fence.
>> +    *
>> +    * It may be more performant to postpone blocking until there is an
>> +    * immediate need to write to the buffer. But doing so would require adding
>> +    * hooks to the DRI2 loader.
>> +    *
>> +    * From the ANativeWindow::dequeueBuffer documentation:
>> +    *
>> +    *    The libsync fence file descriptor returned in the int pointed to by
>> +    *    the fenceFd argument will refer to the fence that must signal
>> +    *    before the dequeued buffer may be written to.  A value of -1
>> +    *    indicates that the caller may access the buffer immediately without
>> +    *    waiting on a fence.  If a valid file descriptor is returned (i.e.
>> +    *    any value except -1) then the caller is responsible for closing the
>> +    *    file descriptor.
>> +    */
>> +    if (fence_fd >= 0) {
>> +       /* From the SYNC_IOC_WAIT documentation in <linux/sync.h>:
>> +        *
>> +        *    Waits indefinitely if timeout < 0.
>> +        */
>> +        int timeout = -1;
>> +        sync_wait(fence_fd, timeout);
> 
> I'm getting link error "error: undefined reference to 'sync_wait'",
> where is this function coming from?

sync_wait() comes from libsync. The last hunk of this patch, quoted below,
links libsync into libGLES_mesa. I'm surprised that you are getting link
errors, because the `make libGLES_mesa` succeeds for me. Did you apply
patch 1/2?


>> +        close(fd);
> 
> typo here, should be close(fence_fd)

Typo is now fixed.

> otherwise things look good to me;
> 
> Reviewed-by: Tapani Pälli <tapani.palli at intel.com>


>> diff --git a/src/egl/main/Android.mk b/src/egl/main/Android.mk
>> index a4a00f3..97e4860 100644
>> --- a/src/egl/main/Android.mk
>> +++ b/src/egl/main/Android.mk
>> @@ -79,7 +79,12 @@ LOCAL_STATIC_LIBRARIES += libmesa_egl_dri2
>>  # require i915_dri and/or i965_dri
>>  LOCAL_REQUIRED_MODULES += \
>>  	$(addsuffix _dri, $(filter i915 i965, $(MESA_GPU_DRIVERS)))
>> +
>> +ifeq ($(shell echo "$(MESA_ANDROID_VERSION) >= 4.2" | bc),1)
>> +    LOCAL_SHARED_LIBRARIES += \
>> +        libsync
>>  endif
>> +endif # MESA_BUILD_CLASSIC
>>  
>>  ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
>>  




More information about the mesa-dev mailing list