0027-egl-tizen-support-DRI-driver-handling-of-swap-preser.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. From 446ff9fb0a0137745a2301982c52d187285d9837 Mon Sep 17 00:00:00 2001
  2. From: Frank Binns <frank.binns@imgtec.com>
  3. Date: Mon, 18 Dec 2017 19:22:50 +0000
  4. Subject: [PATCH] egl/tizen: support DRI driver handling of swap preserve
  5. This adds a new flag (__DRI_IMAGE_BUFFER_PREV) to the __DRIimageBufferMask
  6. enum that allows a DRI driver to request the previous back buffer. This
  7. will only be returned if the swap behaviour is EGL_BUFFER_PRESERVED and
  8. should result in the DRI driver preserving the previous content instead of
  9. this being done in the platform code. For hardware that supports it, this
  10. should avoid a blit being performed every frame, although this will still
  11. be necessary under certain conditions, e.g. an empty swap.
  12. ---
  13. include/GL/internal/dri_interface.h | 3 +++
  14. src/egl/drivers/dri2/platform_tizen.c | 29 +++++++++++++++++++++------
  15. 2 files changed, 26 insertions(+), 6 deletions(-)
  16. diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
  17. index b197092..16cc095 100644
  18. --- a/include/GL/internal/dri_interface.h
  19. +++ b/include/GL/internal/dri_interface.h
  20. @@ -2073,12 +2073,15 @@ enum __DRIimageBufferMask {
  21. * OpenGL ES API and little change to the SurfaceFlinger API.
  22. */
  23. __DRI_IMAGE_BUFFER_SHARED = (1 << 2),
  24. +#define DRI_IMAGE_HAS_BUFFER_PREV
  25. + __DRI_IMAGE_BUFFER_PREV = (1 << 31),
  26. };
  27. struct __DRIimageList {
  28. uint32_t image_mask;
  29. __DRIimage *back;
  30. __DRIimage *front;
  31. + __DRIimage *prev;
  32. };
  33. #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
  34. diff --git a/src/egl/drivers/dri2/platform_tizen.c b/src/egl/drivers/dri2/platform_tizen.c
  35. index 4946215..2bc9b3e 100644
  36. --- a/src/egl/drivers/dri2/platform_tizen.c
  37. +++ b/src/egl/drivers/dri2/platform_tizen.c
  38. @@ -147,7 +147,8 @@ create_image_from_native(struct dri2_egl_surface *dri2_surf,
  39. }
  40. static int
  41. -get_back_bo(struct dri2_egl_surface *dri2_surf, bool allow_update)
  42. +get_back_bo(struct dri2_egl_surface *dri2_surf, bool allow_update,
  43. + bool allow_preserve)
  44. {
  45. struct dri2_egl_display *dri2_dpy =
  46. dri2_egl_display(dri2_surf->base.Resource.Display);
  47. @@ -277,7 +278,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf, bool allow_update)
  48. dri2_surf->back->locked = true;
  49. if (dri2_surf->base.SwapBehavior == EGL_BUFFER_PRESERVED &&
  50. - dri2_surf->current) {
  51. + allow_preserve && dri2_surf->current) {
  52. _EGLContext *ctx = _eglGetCurrentContext();
  53. struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
  54. @@ -609,7 +610,7 @@ dri2_tizen_swap_buffers_with_damage(_EGLDisplay *dpy, _EGLSurface *draw,
  55. * Make sure we have a back buffer in case we're swapping without ever
  56. * rendering.
  57. */
  58. - if (get_back_bo(dri2_surf, false) < 0) {
  59. + if (get_back_bo(dri2_surf, false, true) < 0) {
  60. _eglError(EGL_BAD_ALLOC, "DRI2: failed to get back buffer");
  61. return EGL_FALSE;
  62. }
  63. @@ -673,7 +674,7 @@ dri2_tizen_query_buffer_age(_EGLDisplay *dpy, _EGLSurface *surface)
  64. {
  65. struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface);
  66. - if (get_back_bo(dri2_surf, false) < 0) {
  67. + if (get_back_bo(dri2_surf, false, true) < 0) {
  68. _eglError(EGL_BAD_ALLOC, "DRI2: failed to get back buffer");
  69. return -1;
  70. }
  71. @@ -748,14 +749,22 @@ dri2_tizen_get_buffers(__DRIdrawable *driDrawable,
  72. buffers->image_mask = 0;
  73. buffers->front = NULL;
  74. buffers->back = NULL;
  75. + buffers->prev = NULL;
  76. if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT)
  77. if (get_front_bo(dri2_surf) < 0)
  78. return 0;
  79. - if (buffer_mask & __DRI_IMAGE_BUFFER_BACK)
  80. - if (get_back_bo(dri2_surf, true) < 0)
  81. + if (buffer_mask & __DRI_IMAGE_BUFFER_BACK) {
  82. + /*
  83. + * The DRI driver has requested the previous buffer so it will take care
  84. + * of preserving the previous content.
  85. + */
  86. + bool allow_preserve = !(buffer_mask & __DRI_IMAGE_BUFFER_PREV);
  87. +
  88. + if (get_back_bo(dri2_surf, true, allow_preserve) < 0)
  89. return 0;
  90. + }
  91. if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
  92. buffers->front = dri2_surf->front;
  93. @@ -767,6 +776,14 @@ dri2_tizen_get_buffers(__DRIdrawable *driDrawable,
  94. buffers->image_mask |= __DRI_IMAGE_BUFFER_BACK;
  95. }
  96. + if (buffer_mask & __DRI_IMAGE_BUFFER_PREV) {
  97. + if (dri2_surf->base.SwapBehavior == EGL_BUFFER_PRESERVED &&
  98. + dri2_surf->current) {
  99. + buffers->prev = dri2_surf->current->dri_image;
  100. + buffers->image_mask |= __DRI_IMAGE_BUFFER_PREV;
  101. + }
  102. + }
  103. +
  104. return 1;
  105. }