egl-helpers.c (6779a3076f295fafe52d43049fa954426c1d594a) | egl-helpers.c (fa6426805b124400cfb700b75e8fe4a89dd2ed7a) |
---|---|
1/* 2 * Copyright (C) 2015-2016 Gerd Hoffmann <kraxel@redhat.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * --- 334 unchanged lines hidden (view full) --- 343 EGL_NO_CONTEXT, 344 EGL_LINUX_DMA_BUF_EXT, 345 NULL, attrs); 346 if (image == EGL_NO_IMAGE_KHR) { 347 error_report("eglCreateImageKHR failed"); 348 return; 349 } 350 | 1/* 2 * Copyright (C) 2015-2016 Gerd Hoffmann <kraxel@redhat.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * --- 334 unchanged lines hidden (view full) --- 343 EGL_NO_CONTEXT, 344 EGL_LINUX_DMA_BUF_EXT, 345 NULL, attrs); 346 if (image == EGL_NO_IMAGE_KHR) { 347 error_report("eglCreateImageKHR failed"); 348 return; 349 } 350 |
351 glGenTextures(1, &dmabuf->texture); 352 texture = qemu_dmabuf_get_texture(dmabuf); | 351 glGenTextures(1, &texture); 352 qemu_dmabuf_set_texture(dmabuf, texture); |
353 glBindTexture(GL_TEXTURE_2D, texture); 354 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 355 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 356 357 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image); 358 eglDestroyImageKHR(qemu_egl_display, image); 359} 360 361void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf) 362{ 363 uint32_t texture; 364 365 texture = qemu_dmabuf_get_texture(dmabuf); 366 if (texture == 0) { 367 return; 368 } 369 370 glDeleteTextures(1, &texture); | 353 glBindTexture(GL_TEXTURE_2D, texture); 354 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 355 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 356 357 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image); 358 eglDestroyImageKHR(qemu_egl_display, image); 359} 360 361void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf) 362{ 363 uint32_t texture; 364 365 texture = qemu_dmabuf_get_texture(dmabuf); 366 if (texture == 0) { 367 return; 368 } 369 370 glDeleteTextures(1, &texture); |
371 dmabuf->texture = 0; | 371 qemu_dmabuf_set_texture(dmabuf, 0); |
372} 373 374void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf) 375{ 376 EGLSyncKHR sync; 377 378 if (epoxy_has_egl_extension(qemu_egl_display, 379 "EGL_KHR_fence_sync") && 380 epoxy_has_egl_extension(qemu_egl_display, 381 "EGL_ANDROID_native_fence_sync")) { 382 sync = eglCreateSyncKHR(qemu_egl_display, 383 EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); 384 if (sync != EGL_NO_SYNC_KHR) { | 372} 373 374void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf) 375{ 376 EGLSyncKHR sync; 377 378 if (epoxy_has_egl_extension(qemu_egl_display, 379 "EGL_KHR_fence_sync") && 380 epoxy_has_egl_extension(qemu_egl_display, 381 "EGL_ANDROID_native_fence_sync")) { 382 sync = eglCreateSyncKHR(qemu_egl_display, 383 EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); 384 if (sync != EGL_NO_SYNC_KHR) { |
385 dmabuf->sync = sync; | 385 qemu_dmabuf_set_sync(dmabuf, sync); |
386 } 387 } 388} 389 390void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf) 391{ 392 void *sync = qemu_dmabuf_get_sync(dmabuf); | 386 } 387 } 388} 389 390void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf) 391{ 392 void *sync = qemu_dmabuf_get_sync(dmabuf); |
393 int fence_fd; |
|
393 394 if (sync) { | 394 395 if (sync) { |
395 dmabuf->fence_fd = eglDupNativeFenceFDANDROID(qemu_egl_display, 396 sync); | 396 fence_fd = eglDupNativeFenceFDANDROID(qemu_egl_display, 397 sync); 398 qemu_dmabuf_set_fence_fd(dmabuf, fence_fd); |
397 eglDestroySyncKHR(qemu_egl_display, sync); | 399 eglDestroySyncKHR(qemu_egl_display, sync); |
398 dmabuf->sync = NULL; | 400 qemu_dmabuf_set_sync(dmabuf, NULL); |
399 } 400} 401 402#endif /* CONFIG_GBM */ 403 404/* ---------------------------------------------------------------------- */ 405 406EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win) --- 266 unchanged lines hidden --- | 401 } 402} 403 404#endif /* CONFIG_GBM */ 405 406/* ---------------------------------------------------------------------- */ 407 408EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win) --- 266 unchanged lines hidden --- |