summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuelian Bai <xuelian.bai@samsung.com>2019-05-29 00:01:10 +0800
committerXuelian Bai <xuelian.bai@samsung.com>2024-01-18 09:29:10 +0800
commitfccace389a6faa9bd94ed270d6c0ceec3ec528b2 (patch)
treec2a38b39fb12c70d539896d786f3a3ffb0a75597
parentae6e7a9c92348647e3294c7f8f3ae4908b0c88e9 (diff)
downloadmesa-fccace389a6faa9bd94ed270d6c0ceec3ec528b2.tar.gz
mesa-fccace389a6faa9bd94ed270d6c0ceec3ec528b2.tar.bz2
mesa-fccace389a6faa9bd94ed270d6c0ceec3ec528b2.zip
Fix resize issue
Handle 1x1 issue for driimage When evas resize window after dequeue, then draw and swapbuffers, window is shown with old size until next makecurrent. Add validate_drawable function to check if resize happen each time makecurrent is called. For RPI4, render node is used, so buffer is allocated on another device, when 1x1 issue happen, we need to make sure if driimage size is changed, then created new if yes. Merged Commit: commit 2dc471b0e167693b81c24c9a3f89b985cb98249f Author: Zhaowei Yuan <zhaowei.yuan@samsung.com> - Check if stdraw is NULL before access Variable "stdraw" could be NULL in some case, check it before access. commit cc2dc99365906ea52b645be3bb10f50708d67e84 Author: Xuelian Bai <xuelian.bai@samsung.com> - Fix 1x1 issue of task-mgr Makecurrent is called just before resize callback is called, so we have to check if size is changed when drawcall. commit 670d77331c986a92bcf2459567ccd6dfc181bc66 Author: Xuelian Bai <xuelian.bai@samsung.com> - Fix resize issue Change-Id: Ieaebe72661a081d496ab6214c1c1526f7d16f19b Signed-Off-by: Xuelian Bai <xuelian.bai@samsung.com> - Handle 1x1 issue for driimage Change-Id: Id5a463a8db290ca5b80c130ebcdcb13c7786d70c Signed-off-by: Xuelian Bai <xuelian.bai@samsung.com>
-rw-r--r--include/GL/internal/dri_interface.h9
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h1
-rwxr-xr-xsrc/egl/drivers/dri2/platform_tizen.c45
-rw-r--r--src/gallium/frontends/dri/dri2.c33
-rw-r--r--src/gallium/frontends/dri/dri_drawable.c15
-rw-r--r--src/gallium/frontends/dri/dri_drawable.h3
-rw-r--r--src/gallium/include/frontend/api.h3
-rw-r--r--src/mesa/main/blit.c4
-rw-r--r--src/mesa/state_tracker/st_atom_framebuffer.c4
-rwxr-xr-x[-rw-r--r--]src/mesa/state_tracker/st_manager.c41
-rw-r--r--src/mesa/state_tracker/st_manager.h16
11 files changed, 168 insertions, 6 deletions
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index ad3ce1cfed4..b6342914212 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -42,7 +42,7 @@
#include <stdbool.h>
#include <stdint.h>
-
+#include <stdbool.h>
/**
* \name DRI interface structures
*
@@ -1099,6 +1099,9 @@ struct __DRIdri2LoaderExtensionRec {
* \since 5
*/
void (*destroyLoaderImageState)(void *loaderPrivate);
+#ifdef HAVE_TIZEN_PLATFORM
+ bool (*validate)(__DRIdrawable *driDrawable, void *loaderPrivate);
+#endif
};
/**
@@ -2073,6 +2076,10 @@ struct __DRIimageLoaderExtensionRec {
* \since 4
*/
void (*destroyLoaderImageState)(void *loaderPrivate);
+#ifdef HAVE_TIZEN_PLATFORM
+ bool (*validate)(__DRIdrawable *driDrawable, void *loaderPrivate);
+#endif
+
};
/**
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index ea4001cc6c1..d4db936da9c 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -383,6 +383,7 @@ struct dri2_egl_surface {
__DRIimage *dri_image_front;
int buffer_count;
+ bool valid;
#endif
#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM) || defined(HAVE_TIZEN_PLATFORM)
diff --git a/src/egl/drivers/dri2/platform_tizen.c b/src/egl/drivers/dri2/platform_tizen.c
index 3059dc39314..b313f13e79c 100755
--- a/src/egl/drivers/dri2/platform_tizen.c
+++ b/src/egl/drivers/dri2/platform_tizen.c
@@ -176,6 +176,7 @@ tizen_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
if (!dri2_surf->tbm_surface)
return EGL_FALSE;
+ dri2_surf->valid = true;
tbm_surface_internal_ref(dri2_surf->tbm_surface);
tpl_surface_get_size(dri2_surf->tpl_surface, &width, &height);
@@ -342,7 +343,7 @@ tizen_create_surface(_EGLDisplay *disp, EGLint type,
goto cleanup_surface;
}
dri2_surf->native_win = native_window;
-
+ dri2_surf->valid = true;
dri2_dpy->core->getConfigAttrib(config, __DRI_ATTRIB_DEPTH_SIZE, &depth);
dri2_dpy->core->getConfigAttrib(config, __DRI_ATTRIB_ALPHA_SIZE, &alpha);
@@ -473,6 +474,21 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
if (dri2_surf->base.Type != EGL_WINDOW_BIT)
return 0;
+ if (dri2_surf->valid == false) {
+ int i;
+ if (dri2_surf->tbm_surface) {
+ tpl_surface_cancel_dequeued_buffer(dri2_surf->tpl_surface,
+ dri2_surf->tbm_surface);
+ tbm_surface_internal_unref(dri2_surf->tbm_surface);
+ for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
+ dri2_surf->color_buffers[i].tbm_surface = NULL;
+ dri2_surf->color_buffers[i].age = 0;
+ }
+
+ dri2_surf->back = NULL;
+ dri2_surf->tbm_surface = NULL;
+ }
+ }
/* try to dequeue the next back buffer */
if (!dri2_surf->tbm_surface && !tizen_window_dequeue_buffer(dri2_surf)) {
_eglLog(_EGL_WARNING, "Could not dequeue buffer from native window");
@@ -523,9 +539,20 @@ get_back_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
int fourcc, pitch;
int offset = 0, fd;
tbm_surface_info_s surf_info;
+ EGLBoolean query;
+ int width, height;
- if (dri2_surf->dri_image_back)
- return 0;
+ if (dri2_surf->dri_image_back) {
+ query = dri2_dpy->image->queryImage(dri2_surf->dri_image_back, __DRI_IMAGE_ATTRIB_WIDTH, &width);
+ query &= dri2_dpy->image->queryImage(dri2_surf->dri_image_back, __DRI_IMAGE_ATTRIB_HEIGHT, &height);
+
+ if (width == dri2_surf->base.Width && height == dri2_surf->base.Height)
+ return 0;
+ else {
+ dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+ dri2_surf->dri_image_back = NULL;
+ }
+ }
if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
if (!dri2_surf->tbm_surface) {
@@ -1011,6 +1038,16 @@ tizen_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
{
}
+static bool
+tizen_validate_drawable(__DRIdrawable * driDrawable, void *loaderPrivate)
+{
+ struct dri2_egl_surface *dri2_surf = loaderPrivate;
+ bool v = tpl_surface_validate(dri2_surf->tpl_surface);
+
+ dri2_surf->valid = v;
+ return v;
+}
+
static int
tizen_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf,
unsigned int *attachments, int count)
@@ -1340,6 +1377,7 @@ static const __DRIdri2LoaderExtension tizen_dri2_loader_extension = {
.getBuffers = NULL,
.getBuffersWithFormat = tizen_get_buffers_with_format,
.flushFrontBuffer = tizen_flush_front_buffer,
+ .validate = tizen_validate_drawable,
};
static const __DRIimageLoaderExtension tizen_image_loader_extension = {
@@ -1347,6 +1385,7 @@ static const __DRIimageLoaderExtension tizen_image_loader_extension = {
.getBuffers = tizen_image_get_buffers,
.flushFrontBuffer = tizen_flush_front_buffer,
+ .validate = tizen_validate_drawable,
};
static const __DRIswrastLoaderExtension tizen_swrast_loader_extension = {
diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index a018ef70437..608ca0a838c 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -466,6 +466,35 @@ handle_in_fence(struct dri_context *ctx, __DRIimage *img)
/*
* Backend functions for pipe_frontend_drawable.
*/
+#ifdef HAVE_TIZEN_PLATFORM
+static bool dri2_validate_drawable(struct dri_drawable *drawable)
+{
+ const __DRIdri2LoaderExtension *loader = drawable->screen->dri2.loader;
+
+ if (loader && loader->validate != NULL) {
+ bool valid = (loader->validate)(opaque_dri_drawable(drawable), drawable->loaderPrivate);
+ if (valid == false) /*drawable may be resized, not valid anymore*/ {
+ drawable->lastStamp = drawable->base.stamp;
+ drawable->texture_mask = 0;
+ }
+ return valid;
+ }
+ else {
+ const __DRIimageLoaderExtension *image_loader = drawable->screen->image.loader;
+ if (image_loader && image_loader->validate != NULL) {
+ bool valid = (image_loader->validate)(opaque_dri_drawable(drawable),drawable->loaderPrivate);
+ if (valid == false) /*drawable may be resized, not valid anymore*/ {
+ drawable->lastStamp = drawable->base.stamp;
+ drawable->texture_mask = 0;
+ }
+ return valid;
+ }
+ return true;
+ }
+
+}
+#endif
+
static void
dri2_allocate_textures(struct dri_context *ctx,
@@ -2364,7 +2393,9 @@ dri2_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
drawable->flush_frontbuffer = dri2_flush_frontbuffer;
drawable->update_tex_buffer = dri2_update_tex_buffer;
drawable->flush_swapbuffers = dri2_flush_swapbuffers;
-
+#ifdef HAVE_TIZEN_PLATFORM
+ drawable->validate_drawable = dri2_validate_drawable;
+#endif
return drawable;
}
diff --git a/src/gallium/frontends/dri/dri_drawable.c b/src/gallium/frontends/dri/dri_drawable.c
index 58008b3c584..f81ee5c119e 100644
--- a/src/gallium/frontends/dri/dri_drawable.c
+++ b/src/gallium/frontends/dri/dri_drawable.c
@@ -42,6 +42,18 @@
static uint32_t drifb_ID = 0;
+#ifdef HAVE_TIZEN_PLATFORM
+static bool
+dri_st_framebuffer_validate_drawable(struct pipe_frontend_drawable *pdrawable)
+{
+ struct dri_drawable *drawable = (struct dri_drawable *)pdrawable;
+ if (drawable->validate_drawable == NULL)
+ return true;
+ else
+ return drawable->validate_drawable(drawable);
+}
+#endif
+
static bool
dri_st_framebuffer_validate(struct st_context *st,
struct pipe_frontend_drawable *pdrawable,
@@ -174,6 +186,9 @@ dri_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
drawable->base.flush_front = dri_st_framebuffer_flush_front;
drawable->base.validate = dri_st_framebuffer_validate;
drawable->base.flush_swapbuffers = dri_st_framebuffer_flush_swapbuffers;
+#ifdef HAVE_TIZEN_PLATFORM
+ drawable->base.validate_drawable = dri_st_framebuffer_validate_drawable;
+#endif
drawable->screen = screen;
diff --git a/src/gallium/frontends/dri/dri_drawable.h b/src/gallium/frontends/dri/dri_drawable.h
index d759fcfbb64..d54b0460712 100644
--- a/src/gallium/frontends/dri/dri_drawable.h
+++ b/src/gallium/frontends/dri/dri_drawable.h
@@ -109,6 +109,9 @@ struct dri_drawable
struct dri_drawable *drawable);
void (*swap_buffers)(struct dri_drawable *drawable);
+#ifdef HAVE_TIZEN_PLATFORM
+ bool (*validate_drawable)(struct dri_drawable *drawable);
+#endif
};
/* Typecast the opaque pointer to our own type. */
diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h
index 712cbe9e47e..d8d2979ca1f 100644
--- a/src/gallium/include/frontend/api.h
+++ b/src/gallium/include/frontend/api.h
@@ -279,6 +279,9 @@ struct pipe_frontend_drawable
unsigned count,
struct pipe_resource **out,
struct pipe_resource **resolve);
+#ifdef HAVE_TIZEN_PLATFORM
+ bool (*validate_drawable)(struct pipe_frontend_drawable *drawable);
+#endif
bool (*flush_swapbuffers)(struct st_context *st,
struct pipe_frontend_drawable *drawable);
diff --git a/src/mesa/main/blit.c b/src/mesa/main/blit.c
index c71aa14170a..ed1bf09ba64 100644
--- a/src/mesa/main/blit.c
+++ b/src/mesa/main/blit.c
@@ -371,7 +371,11 @@ do_blit_framebuffer(struct gl_context *ctx,
} clip;
struct pipe_blit_info blit;
+#ifdef HAVE_TIZEN_PLATFORM
+ st_manager_validate_framebuffers(st, true);
+#else
st_manager_validate_framebuffers(st);
+#endif
/* Make sure bitmap rendering has landed in the framebuffers */
st_flush_bitmap_cache(st);
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 16542bbb2a8..72e5b66e4b4 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -117,7 +117,11 @@ st_update_framebuffer_state( struct st_context *st )
GLuint i;
/* Window framebuffer changes are received here. */
+#ifdef HAVE_TIZEN_PLATFORM
+ st_manager_validate_framebuffers(st, true);
+#else
st_manager_validate_framebuffers(st);
+#endif
st_flush_bitmap_cache(st);
st_invalidate_readpix_cache(st);
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 34938b44e2f..83aab8a4461 100644..100755
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -78,6 +78,7 @@ struct st_screen
* We'll only return non-null for window system framebuffers.
* Note that this function may fail.
*/
+#if 0 /*Move this function to header file to be used by other files*/
static inline struct gl_framebuffer *
st_ws_framebuffer(struct gl_framebuffer *fb)
{
@@ -87,6 +88,7 @@ st_ws_framebuffer(struct gl_framebuffer *fb)
return fb;
return NULL;
}
+#endif
/**
* Map an attachment to a buffer index.
@@ -219,7 +221,11 @@ st_set_ws_renderbuffer_surface(struct gl_renderbuffer *rb,
*/
static void
st_framebuffer_validate(struct gl_framebuffer *stfb,
- struct st_context *st)
+ struct st_context *st
+#ifdef HAVE_TIZEN_PLATFORM
+ , bool valid
+#endif
+ )
{
struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
struct pipe_resource *resolve = NULL;
@@ -229,7 +235,11 @@ st_framebuffer_validate(struct gl_framebuffer *stfb,
int32_t new_stamp;
new_stamp = p_atomic_read(&stfb->drawable->stamp);
+#ifdef HAVE_TIZEN_PLATFORM
+ if (valid == GL_TRUE && stfb->drawable_stamp == new_stamp)
+#else
if (stfb->drawable_stamp == new_stamp)
+#endif
return;
memset(textures, 0, stfb->num_statts * sizeof(textures[0]));
@@ -1128,6 +1138,9 @@ st_api_make_current(struct st_context *st,
{
struct gl_framebuffer *stdraw, *stread;
bool ret;
+#ifdef HAVE_TIZEN_PLATFORM
+ bool valid = true;
+#endif
if (st) {
/* reuse or create the draw fb */
@@ -1147,10 +1160,24 @@ st_api_make_current(struct st_context *st,
if ((stdrawi && !stdraw) || (streadi && !stread))
return false;
+#ifdef HAVE_TIZEN_PLATFORM
+ if (stdraw && stdraw->drawable->validate_drawable)
+ valid = stdraw->drawable->validate_drawable(stdraw->drawable);
+#endif
+
if (stdraw && stread) {
+#ifdef HAVE_TIZEN_PLATFORM
+ st_framebuffer_validate(stdraw, st, valid);
+#else
st_framebuffer_validate(stdraw, st);
+#endif
+
if (stread != stdraw)
+#ifdef HAVE_TIZEN_PLATFORM
+ st_framebuffer_validate(stread, st, true);
+#else
st_framebuffer_validate(stread, st);
+#endif
ret = _mesa_make_current(st->ctx, stdraw, stread);
@@ -1236,16 +1263,28 @@ st_manager_flush_frontbuffer(struct st_context *st)
/**
* Re-validate the framebuffers.
*/
+#ifdef HAVE_TIZEN_PLATFORM
+void
+st_manager_validate_framebuffers(struct st_context *st, bool valid)
+#else
void
st_manager_validate_framebuffers(struct st_context *st)
+#endif
{
struct gl_framebuffer *stdraw = st_ws_framebuffer(st->ctx->DrawBuffer);
struct gl_framebuffer *stread = st_ws_framebuffer(st->ctx->ReadBuffer);
+#ifdef HAVE_TIZEN_PLATFORM
+ if (stdraw)
+ st_framebuffer_validate(stdraw, st, valid);
+ if (stread && stread != stdraw)
+ st_framebuffer_validate(stread, st, GL_TRUE);
+#else
if (stdraw)
st_framebuffer_validate(stdraw, st);
if (stread && stread != stdraw)
st_framebuffer_validate(stread, st);
+#endif
st_context_validate(st, stdraw, stread);
}
diff --git a/src/mesa/state_tracker/st_manager.h b/src/mesa/state_tracker/st_manager.h
index 4a617edb36c..abf75c569a6 100644
--- a/src/mesa/state_tracker/st_manager.h
+++ b/src/mesa/state_tracker/st_manager.h
@@ -38,11 +38,27 @@ struct st_context;
struct gl_renderbuffer;
struct pipe_surface;
+
+static inline struct gl_framebuffer *
+st_ws_framebuffer(struct gl_framebuffer *fb)
+{
+ /* FBO cannot be casted. See st_new_framebuffer */
+ if (fb && _mesa_is_winsys_fbo(fb) &&
+ fb != _mesa_get_incomplete_framebuffer())
+ return fb;
+ return NULL;
+}
+
void
st_manager_flush_frontbuffer(struct st_context *st);
+#ifdef HAVE_TIZEN_PLATFORM
+void
+st_manager_validate_framebuffers(struct st_context *st, bool valid);
+#else
void
st_manager_validate_framebuffers(struct st_context *st);
+#endif
bool
st_manager_add_color_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,