From 017b45802a3c241c0c1ac3dc2d1b5eb98d12f206 Mon Sep 17 00:00:00 2001 From: "deasung.kim" Date: Wed, 7 Dec 2016 12:04:33 +0900 Subject: [PATCH 01/16] wayland-vulkan: added wayland-vulkan protocol it need to server side present mode Change-Id: Ia12b36260c6651b4cf34c5ea222557a00b7ef2de --- src/wayland-vulkan/Makefile | 30 ++++++++++++++++++++++++++ src/wayland-vulkan/wayland-vulkan-protocol.xml | 17 +++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/wayland-vulkan/Makefile create mode 100644 src/wayland-vulkan/wayland-vulkan-protocol.xml diff --git a/src/wayland-vulkan/Makefile b/src/wayland-vulkan/Makefile new file mode 100644 index 0000000..8300a88 --- /dev/null +++ b/src/wayland-vulkan/Makefile @@ -0,0 +1,30 @@ +.SUFFIXES: .c .o .a + +CFLAGS += -Wall -fno-strict-aliasing -Wno-strict-aliasing -Wno-long-long -O3 -fPIC + +WAYLAND_VULKAN_PROTOCOLS = wayland-vulkan-protocol.xml + +wayland-vulkan-protocol.c : $(WAYLAND_VULKAN_PROTOCOLS) + wayland-scanner code < $< > $@ + +wayland-vulkan-server-protocol.h : $(WAYLAND_VULKAN_PROTOCOLS) + wayland-scanner server-header < $< > $@ + +wayland-vulkan-client-protocol.h : $(WAYLAND_VULKAN_PROTOCOLS) + wayland-scanner client-header < $< > $@ + +.PHONY: all clean client server +.DEFAULT_GOAL = all +all: client server + +client: wayland-vulkan-protocol.c wayland-vulkan-client-protocol.h + +server: wayland-vulkan-protocol.c wayland-vulkan-server-protocol.h + +clean: + rm -rf wayland-vulkan-protocol.c \ + wayland-vulkan-server-protocol.h \ + wayland-vulkan-client-protocol.h + +install: all + diff --git a/src/wayland-vulkan/wayland-vulkan-protocol.xml b/src/wayland-vulkan/wayland-vulkan-protocol.xml new file mode 100644 index 0000000..b4fe5dc --- /dev/null +++ b/src/wayland-vulkan/wayland-vulkan-protocol.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + -- 2.7.4 From 37db13d8742d812bdae8c1a45bd7b6883d7e0557 Mon Sep 17 00:00:00 2001 From: "deasung.kim" Date: Mon, 12 Dec 2016 13:42:31 +0900 Subject: [PATCH 02/16] tpl_tbm: added vulkan support funcs __tpl_tbm_display_query_window_supported_buffer_count : return min 0, max 0 (no limits) __tpl_tbm_display_query_window_supported_present_modes : return MAILBOX/IMMEDIATE (FIFO after apply worker) __tpl_tbm_surface_create_swapchain : just set present mode __tpl_tbm_surface_get_swapchain_buffers : same tpl_wayland_vk_wsi Change-Id: I99f3d3192cb835698a3534a8cc1a8ca851740b4b --- src/tpl_tbm.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index cfdbd84..44c581e 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -19,6 +19,7 @@ struct _tpl_tbm_display { struct _tpl_tbm_surface { int dummy; + int present_mode; }; static tpl_result_t @@ -321,6 +322,102 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, return tbm_surface; } +static tpl_result_t +__tpl_tbm_surface_get_swapchain_buffers(tpl_surface_t *surface, + tbm_surface_h **buffers, + int *buffer_count) +{ + tbm_surface_h buffer = NULL; + tbm_surface_queue_h tbm_queue = NULL; + tbm_surface_h *swapchain_buffers = NULL; + tbm_surface_queue_error_e tsq_err; + tpl_result_t ret = TPL_ERROR_NONE; + int i, queue_size, dequeue_count = 0; + + TPL_ASSERT(surface); + TPL_ASSERT(buffers); + TPL_ASSERT(buffer_count); + + tbm_queue = (tbm_surface_queue_h)surface->native_handle; + TPL_ASSERT(tbm_queue); + + queue_size = tbm_surface_queue_get_size(tbm_queue); + swapchain_buffers = (tbm_surface_h *)calloc(1, sizeof(tbm_surface_h) * queue_size); + if (!swapchain_buffers) { + TPL_ERR("Failed to allocate memory for buffers."); + return TPL_ERROR_OUT_OF_MEMORY; + } + + for (i = 0; i < queue_size; i++) { + tsq_err = tbm_surface_queue_dequeue(tbm_queue, &buffer); + if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", + tsq_err); + dequeue_count = i; + ret = TPL_ERROR_OUT_OF_MEMORY; + goto get_buffer_fail; + } + swapchain_buffers[i] = buffer; + } + + for (i = 0 ; i < queue_size; i++) { + tsq_err = tbm_surface_queue_release(tbm_queue, swapchain_buffers[i]); + if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("Failed to release tbm_surface. | tsq_err = %d", tsq_err); + ret = TPL_ERROR_INVALID_OPERATION; + goto release_buffer_fail; + } + } + + *buffers = swapchain_buffers; + *buffer_count = queue_size; + return TPL_ERROR_NONE; + +get_buffer_fail: + for (i = 0 ; i < dequeue_count ; i++) { + tsq_err = tbm_surface_queue_release(tbm_queue, swapchain_buffers[i]); + if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("Failed to release tbm_surface. | tsq_err = %d", tsq_err); + goto release_buffer_fail; + } + } + +release_buffer_fail: + free(swapchain_buffers); + return ret; + +} + +static tpl_result_t +__tpl_tbm_surface_create_swapchain(tpl_surface_t *surface, + tbm_format format, int width, + int height, int buffer_count, int present_mode) +{ + tpl_tbm_surface_t *tpl_tbm_surface = NULL; + + TPL_ASSERT(surface); + + tpl_tbm_surface = (tpl_tbm_surface_t *) surface->backend.data; + TPL_ASSERT(tpl_tbm_surface); + + /* FIXME: vblank has performance problem so replace all present mode to MAILBOX */ + present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX; + + /* TODO: check server supported present modes */ + switch (present_mode) { + case TPL_DISPLAY_PRESENT_MODE_MAILBOX: + case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE: + break; + default: + TPL_ERR("Unsupported present mode: %d", present_mode); + return TPL_ERROR_INVALID_PARAMETER; + } + + tpl_tbm_surface->present_mode = present_mode; + + return TPL_ERROR_NONE; +} + tpl_bool_t __tpl_display_choose_backend_tbm(tpl_handle_t native_dpy) { @@ -338,6 +435,36 @@ __tpl_display_choose_backend_tbm(tpl_handle_t native_dpy) return ret; } +static tpl_result_t +__tpl_tbm_display_query_window_supported_buffer_count( + tpl_display_t *display, + tpl_handle_t window, int *min, int *max) +{ + TPL_ASSERT(display); + + if (!display->backend.data) return TPL_ERROR_INVALID_OPERATION; + + if (min) *min = 0; + if (max) *max = 0; /* 0 mean no limit in vulkan */ + + return TPL_ERROR_NONE; +} + +static tpl_result_t +__tpl_tbm_display_query_window_supported_present_modes( + tpl_display_t *display, + tpl_handle_t window, int *modes) +{ + TPL_ASSERT(display); + + if (!display->backend.data) return TPL_ERROR_INVALID_OPERATION; + + if (modes) + *modes = TPL_DISPLAY_PRESENT_MODE_MAILBOX | TPL_DISPLAY_PRESENT_MODE_IMMEDIATE; + + return TPL_ERROR_NONE; +} + void __tpl_display_init_backend_tbm(tpl_display_backend_t *backend) { @@ -354,6 +481,11 @@ __tpl_display_init_backend_tbm(tpl_display_backend_t *backend) backend->get_pixmap_info = __tpl_tbm_display_get_pixmap_info; backend->get_buffer_from_native_pixmap = __tpl_tbm_display_get_buffer_from_native_pixmap; + backend->query_window_supported_buffer_count = + __tpl_tbm_display_query_window_supported_buffer_count; + backend->query_window_supported_present_modes = + __tpl_tbm_display_query_window_supported_present_modes; + } void @@ -369,5 +501,8 @@ __tpl_surface_init_backend_tbm(tpl_surface_backend_t *backend) backend->validate = __tpl_tbm_surface_validate; backend->dequeue_buffer = __tpl_tbm_surface_dequeue_buffer; backend->enqueue_buffer = __tpl_tbm_surface_enqueue_buffer; + backend->create_swapchain = __tpl_tbm_surface_create_swapchain; + backend->get_swapchain_buffers = + __tpl_tbm_surface_get_swapchain_buffers; } -- 2.7.4 From 323c55bed8983f295e842ed9c41cda4d0e83ceeb Mon Sep 17 00:00:00 2001 From: "deasung.kim" Date: Mon, 12 Dec 2016 14:43:30 +0900 Subject: [PATCH 03/16] tpl_worker_thread: added new interface draw_wait_buffer_get if draw_wait_buffer_get is not NULL worker call that function to get draw wait buffer this patch for tpl_tbm Change-Id: I52d366615576bc5e1f0fbd6ab34c56a201de6c58 --- src/tpl_worker_thread.c | 31 ++++++++++++++++++++++++++++++- src/tpl_worker_thread.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/tpl_worker_thread.c b/src/tpl_worker_thread.c index 7946e4f..60d01ee 100644 --- a/src/tpl_worker_thread.c +++ b/src/tpl_worker_thread.c @@ -41,7 +41,6 @@ void __tpl_worker_surface_list_insert(tpl_worker_surface_t *surface) { TPL_ASSERT(surface->surface); - TPL_ASSERT(surface->tbm_queue); if (pthread_mutex_lock(&tpl_worker_thread.surface_mutex) != 0) { TPL_ERR_ERRNO("surface list mutex lock failed"); @@ -94,6 +93,36 @@ __tpl_worker_prepare_draw_wait_buffer(int epoll_fd, if (surface->draw_wait_buffer) return; + if (surface->draw_wait_buffer_get) { + int wait_fd = -1; + tbm_surface_h tbm_surface; + + while ((tbm_surface = surface->draw_wait_buffer_get(surface->surface)) != NULL) { + if (surface->draw_wait_fd_get) + wait_fd = surface->draw_wait_fd_get(surface->surface, tbm_surface); + + if (wait_fd != -1) { + struct epoll_event wait_fence_event; + int epoll_err; + + wait_fence_event.events = EPOLLIN; + wait_fence_event.data.ptr = surface; + epoll_err = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, + wait_fd, + &wait_fence_event); + if (epoll_err == 0) { + surface->draw_wait_buffer = tbm_surface; + return; + } + } /* else can't(or not need) wait fence in poll */ + + if (surface->draw_done) + surface->draw_done(surface->surface, tbm_surface, + TPL_ERROR_INVALID_OPERATION); + } + return; + } + while (tbm_surface_queue_can_acquire(surface->tbm_queue, 0)) { tbm_surface_h tbm_surface = NULL; tbm_surface_queue_error_e tsq_err; diff --git a/src/tpl_worker_thread.h b/src/tpl_worker_thread.h index 5afa75b..f7562a9 100644 --- a/src/tpl_worker_thread.h +++ b/src/tpl_worker_thread.h @@ -17,6 +17,7 @@ struct __tpl_worker_surface { int (*draw_wait_fd_get)(tpl_surface_t *surface, tbm_surface_h tbm_surface); void (*vblank)(tpl_surface_t *surface, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec); + tbm_surface_h (*draw_wait_buffer_get)(tpl_surface_t *surface); tbm_surface_h draw_wait_buffer; }; -- 2.7.4 From fc0a372ba355f6f346ef13e6ba84f27ed65d1fa3 Mon Sep 17 00:00:00 2001 From: "deasung.kim" Date: Mon, 12 Dec 2016 14:45:33 +0900 Subject: [PATCH 04/16] tpl_tbm: implement worker thread interface tpl_enqueue_with_sync() -> wait sync in worker thread draw done -> insert vblank queue or tbm_surface_queue_enqueue() Change-Id: I09922f02bbccaa87c8630594e7f979f66e65c197 --- src/tpl_tbm.c | 361 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 328 insertions(+), 33 deletions(-) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index 44c581e..56be0ef 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -9,8 +9,22 @@ #include #include +#define USE_WORKER_THREAD +#ifndef USE_WORKER_THREAD +#define USE_WORKER_THREAD 0 +#else +#include "tpl_worker_thread.h" +#include +#include +#undef USE_WORKER_THREAD +#define USE_WORKER_THREAD 1 +#endif + typedef struct _tpl_tbm_display tpl_tbm_display_t; typedef struct _tpl_tbm_surface tpl_tbm_surface_t; +#if USE_WORKER_THREAD == 1 +typedef struct _tpl_tbm_buffer tpl_tbm_buffer_t; +#endif struct _tpl_tbm_display { int need_dpy_deinit; @@ -18,10 +32,72 @@ struct _tpl_tbm_display { }; struct _tpl_tbm_surface { - int dummy; +#if USE_WORKER_THREAD == 1 + /* tbm_surface list */ + tpl_list_t vblank_list; + pthread_mutex_t vblank_list_mutex; + + tpl_list_t draw_waiting_queue; + pthread_mutex_t draw_waiting_mutex; + + tpl_bool_t vblank_done; + + tpl_worker_surface_t worker_surface; + + tpl_bool_t need_worker_clear; +#endif int present_mode; }; +#if USE_WORKER_THREAD == 1 +struct _tpl_tbm_buffer { + tbm_fd wait_sync; +}; + +static int tpl_tbm_buffer_key; +#define KEY_tpl_tbm_buffer (unsigned long)(&tpl_tbm_buffer_key) + +static void +__tpl_tbm_buffer_free(tpl_tbm_buffer_t *tbm_buffer) +{ + TPL_ASSERT(tbm_buffer); + if (tbm_buffer->wait_sync != -1) + close(tbm_buffer->wait_sync); + free(tbm_buffer); +} + +static void +__tpl_tbm_buffer_remove_from_list(void *data) +{ + tbm_surface_h tbm_surface = data; + tbm_surface_internal_unref(tbm_surface); +} + +static TPL_INLINE tpl_tbm_buffer_t * +__tpl_tbm_get_tbm_buffer_from_tbm_surface(tbm_surface_h surface) +{ + tpl_tbm_buffer_t *buf = NULL; + + if (!tbm_surface_internal_is_valid(surface)) + return NULL; + + tbm_surface_internal_get_user_data(surface, KEY_tpl_tbm_buffer, + (void **)&buf); + return buf; +} + +static TPL_INLINE void +__tpl_tbm_set_tbm_buffer_to_tbm_surface(tbm_surface_h surface, + tpl_tbm_buffer_t *buf) +{ + tbm_surface_internal_add_user_data(surface, + KEY_tpl_tbm_buffer, + (tbm_data_free)__tpl_tbm_buffer_free); + tbm_surface_internal_set_user_data(surface, + KEY_tpl_tbm_buffer, buf); +} +#endif + static tpl_result_t __tpl_tbm_display_init(tpl_display_t *display) { @@ -165,6 +241,202 @@ __tpl_tbm_surface_queue_notify_cb(tbm_surface_queue_h surface_queue, void *data) /* Do something */ } +#if USE_WORKER_THREAD == 1 +static void +__tpl_tbm_draw_done(tpl_surface_t *surface, tbm_surface_h tbm_surface, tpl_result_t result) +{ + tpl_tbm_surface_t *tpl_tbm_surface = NULL; + tpl_tbm_buffer_t *tpl_tbm_buffer = NULL; + tbm_surface_queue_h tbm_queue = NULL; + + TPL_ASSERT(surface); + TPL_ASSERT(tbm_surface); + TPL_ASSERT(tbm_surface_internal_is_valid(tbm_surface)); + + tpl_tbm_surface = (tpl_tbm_surface_t *)surface->backend.data; + tpl_tbm_buffer = __tpl_tbm_get_tbm_buffer_from_tbm_surface(tbm_surface); + tbm_queue = (tbm_surface_queue_h)surface->native_handle; + + TPL_ASSERT(tpl_tbm_surface); + TPL_ASSERT(tpl_tbm_buffer); + TPL_ASSERT(tbm_queue); + + close(tpl_tbm_buffer->wait_sync); + tpl_tbm_buffer->wait_sync = -1; + + /* if server supported current supported mode then just send */ + + if (tpl_tbm_surface->present_mode == TPL_DISPLAY_PRESENT_MODE_FIFO) { + pthread_mutex_lock(&tpl_tbm_surface->vblank_list_mutex); + /* unref in tpl list remove callback + (__tpl_tbm_buffer_remove_from_list) */ + tbm_surface_internal_ref(tbm_surface); + __tpl_list_push_back(&tpl_tbm_surface->vblank_list, tbm_surface); + pthread_mutex_unlock(&tpl_tbm_surface->vblank_list_mutex); + } else if (tpl_tbm_surface->present_mode == TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED && + tpl_tbm_surface->vblank_done == TPL_FALSE) { + /* if can't process previous vblank event, send buffer immediately */ + pthread_mutex_lock(&tpl_tbm_surface->vblank_list_mutex); + /* unref in tpl list remove callback + (__tpl_tbm_buffer_remove_from_list) */ + tbm_surface_internal_ref(tbm_surface); + __tpl_list_push_back(&tpl_tbm_surface->vblank_list, tbm_surface); + tpl_tbm_surface->vblank_done = TPL_TRUE; + pthread_mutex_unlock(&tpl_tbm_surface->vblank_list_mutex); + } else { + tbm_surface_internal_unref(tbm_surface); + if (tbm_surface_queue_enqueue(tbm_queue, tbm_surface) != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("tbm_surface_queue_enqueue failed. tbm_queue(%p) tbm_surface(%p)", + tbm_queue, tbm_surface); + } + } +} + +static int +__tpl_tbm_draw_wait_fd_get(tpl_surface_t *surface, tbm_surface_h tbm_surface) +{ + tpl_tbm_buffer_t *tpl_tbm_buffer; + + TPL_ASSERT(tbm_surface); + TPL_ASSERT(tbm_surface_internal_is_valid(tbm_surface)); + + tpl_tbm_buffer = __tpl_tbm_get_tbm_buffer_from_tbm_surface(tbm_surface); + return tpl_tbm_buffer->wait_sync; +} + +static void +__tpl_tbm_vblank(tpl_surface_t *surface, unsigned int sequence, unsigned int tv_sec, + unsigned int tv_usec) +{ + tpl_tbm_surface_t *tpl_tbm_surface; + tbm_surface_h tbm_surface; + + TPL_ASSERT(surface); + + tpl_tbm_surface = (tpl_tbm_surface_t *)surface->backend.data; + + TPL_ASSERT(tpl_tbm_surface); + + if ((tpl_tbm_surface->present_mode & + (TPL_DISPLAY_PRESENT_MODE_FIFO | TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED)) == 0) + return; + + pthread_mutex_lock(&tpl_tbm_surface->vblank_list_mutex); + tbm_surface = __tpl_list_pop_front(&tpl_tbm_surface->vblank_list, + __tpl_tbm_buffer_remove_from_list); + pthread_mutex_unlock(&tpl_tbm_surface->vblank_list_mutex); + + if (tbm_surface_internal_is_valid(tbm_surface)) { + tbm_surface_queue_h tbm_queue = (tbm_surface_queue_h)surface->native_handle; + if (tbm_surface_queue_enqueue(tbm_queue, tbm_surface) != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("tbm_surface_queue_enqueue failed. tbm_queue(%p) tbm_surface(%p)", + tbm_queue, tbm_surface); + } + tpl_tbm_surface->vblank_done = TPL_TRUE; + } else { + tpl_tbm_surface->vblank_done = TPL_FALSE; + } + +} + +static tbm_surface_h +__tpl_tbm_draw_wait_buffer_get(tpl_surface_t *surface) +{ + tpl_tbm_surface_t *tpl_tbm_surface; + tbm_surface_h tbm_surface; + + tpl_tbm_surface = surface->backend.data; + pthread_mutex_init(&tpl_tbm_surface->draw_waiting_mutex, NULL); + tbm_surface = __tpl_list_pop_front(&tpl_tbm_surface->draw_waiting_queue, NULL); + pthread_mutex_unlock(&tpl_tbm_surface->draw_waiting_mutex); + + return tbm_surface; +} +#endif + +static tpl_result_t +__tpl_tbm_surface_create_swapchain(tpl_surface_t *surface, + tbm_format format, int width, + int height, int buffer_count, int present_mode) +{ + tpl_tbm_surface_t *tpl_tbm_surface = NULL; + + TPL_ASSERT(surface); + + tpl_tbm_surface = (tpl_tbm_surface_t *) surface->backend.data; + TPL_ASSERT(tpl_tbm_surface); + + /* FIXME: vblank has performance problem so replace all present mode to MAILBOX */ + present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX; + + /* TODO: check server supported present modes */ + switch (present_mode) { + case TPL_DISPLAY_PRESENT_MODE_MAILBOX: + case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE: + break; +#if USE_WORKER_THREAD == 1 + case TPL_DISPLAY_PRESENT_MODE_FIFO: + case TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED: + if (__tpl_worker_support_vblank() == TPL_FALSE) { + TPL_ERR("Unsupported present mode: %d, worker not support vblank", + present_mode); + return TPL_ERROR_INVALID_PARAMETER; + } +#endif + default: + TPL_ERR("Unsupported present mode: %d", present_mode); + return TPL_ERROR_INVALID_PARAMETER; + } + + tpl_tbm_surface->present_mode = present_mode; + +#if USE_WORKER_THREAD == 1 + tpl_tbm_surface->worker_surface.surface = surface; + tpl_tbm_surface->worker_surface.draw_done = __tpl_tbm_draw_done; + tpl_tbm_surface->worker_surface.draw_wait_fd_get = __tpl_tbm_draw_wait_fd_get; + tpl_tbm_surface->worker_surface.vblank = __tpl_tbm_vblank; + tpl_tbm_surface->worker_surface.draw_wait_buffer_get = __tpl_tbm_draw_wait_buffer_get; + + __tpl_list_init(&tpl_tbm_surface->vblank_list); + __tpl_list_init(&tpl_tbm_surface->draw_waiting_queue); + pthread_mutex_init(&tpl_tbm_surface->vblank_list_mutex, NULL); + pthread_mutex_init(&tpl_tbm_surface->draw_waiting_mutex, NULL); + + __tpl_worker_surface_list_insert(&tpl_tbm_surface->worker_surface); + tpl_tbm_surface->need_worker_clear = TPL_TRUE; +#endif + + return TPL_ERROR_NONE; +} + +#if USE_WORKER_THREAD == 1 +static tpl_result_t +__tpl_tbm_surface_destroy_swapchain(tpl_surface_t *surface) +{ + tpl_tbm_surface_t *tpl_tbm_surface = NULL; + + TPL_ASSERT(surface); + + tpl_tbm_surface = (tpl_tbm_surface_t *) surface->backend.data; + TPL_ASSERT(tpl_tbm_surface); + + __tpl_worker_surface_list_remove(&tpl_tbm_surface->worker_surface); + + pthread_mutex_lock(&tpl_tbm_surface->vblank_list_mutex); + __tpl_list_fini(&tpl_tbm_surface->vblank_list, NULL); + pthread_mutex_unlock(&tpl_tbm_surface->vblank_list_mutex); + pthread_mutex_destroy(&tpl_tbm_surface->vblank_list_mutex); + + pthread_mutex_lock(&tpl_tbm_surface->draw_waiting_mutex); + __tpl_list_fini(&tpl_tbm_surface->draw_waiting_queue, NULL); + pthread_mutex_unlock(&tpl_tbm_surface->draw_waiting_mutex); + pthread_mutex_destroy(&tpl_tbm_surface->draw_waiting_mutex); + tpl_tbm_surface->need_worker_clear = TPL_FALSE; + + return TPL_ERROR_NONE; +} +#endif + static tpl_result_t __tpl_tbm_surface_init(tpl_surface_t *surface) { @@ -218,6 +490,18 @@ error: static void __tpl_tbm_surface_fini(tpl_surface_t *surface) { +#if USE_WORKER_THREAD == 1 + tpl_tbm_surface_t *tpl_tbm_surface = NULL; + + TPL_ASSERT(surface); + + tpl_tbm_surface = (tpl_tbm_surface_t *) surface->backend.data; + TPL_ASSERT(tpl_tbm_surface); + + if (tpl_tbm_surface->need_worker_clear) + __tpl_tbm_surface_destroy_swapchain(surface); +#endif + TPL_ASSERT(surface); TPL_ASSERT(surface->display); @@ -237,6 +521,13 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface, int num_rects, const int *rects, tbm_fd sync_fence) { +#if USE_WORKER_THREAD == 1 + tpl_tbm_surface_t *tpl_tbm_surface = NULL; + tpl_tbm_buffer_t *tpl_tbm_buffer = NULL; +#else + tbm_surface_queue_h tbm_queue; +#endif + TPL_ASSERT(surface); TPL_ASSERT(surface->display); TPL_ASSERT(surface->display->native_handle); @@ -256,8 +547,19 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, surface->native_handle); return TPL_ERROR_INVALID_PARAMETER; } +#if USE_WORKER_THREAD == 1 + tpl_tbm_surface = surface->backend.data; - tbm_surface_queue_h tbm_queue = (tbm_surface_queue_h)surface->native_handle; + tpl_tbm_buffer = __tpl_tbm_get_tbm_buffer_from_tbm_surface(tbm_surface); + tpl_tbm_buffer->wait_sync = sync_fence; + + tbm_surface_internal_ref(tbm_surface); + pthread_mutex_init(&tpl_tbm_surface->draw_waiting_mutex, NULL); + __tpl_list_push_back(&tpl_tbm_surface->draw_waiting_queue, tbm_surface); + pthread_mutex_unlock(&tpl_tbm_surface->draw_waiting_mutex); + __tpl_worker_new_buffer_notify(&tpl_tbm_surface->worker_surface); +#else + tbm_queue = (tbm_surface_queue_h)surface->native_handle; if (!tbm_queue) { TPL_ERR("tbm_surface_queue is invalid."); @@ -275,6 +577,7 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, tbm_queue, tbm_surface); return TPL_ERROR_INVALID_OPERATION; } +#endif return TPL_ERROR_NONE; } @@ -294,6 +597,9 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tbm_surface_h tbm_surface = NULL; tbm_surface_queue_h tbm_queue = NULL; tbm_surface_queue_error_e tsq_err = 0; +#if USE_WORKER_THREAD == 1 + tpl_tbm_buffer_t *tpl_tbm_buffer = NULL; +#endif TPL_ASSERT(surface); TPL_ASSERT(surface->native_handle); @@ -315,6 +621,16 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, } } +#if USE_WORKER_THREAD == 1 + if ((tpl_tbm_buffer =__tpl_tbm_get_tbm_buffer_from_tbm_surface(tbm_surface)) == NULL) { + tpl_tbm_buffer = (tpl_tbm_buffer_t *) calloc(1, sizeof(tpl_tbm_buffer_t)); + if (!tpl_tbm_buffer) { + TPL_ERR("Mem alloc for tpl_tbm_buffer failed!"); + return NULL; + } + } +#endif + /* Inc ref count about tbm_surface */ /* It will be dec when before tbm_surface_queue_enqueue called */ tbm_surface_internal_ref(tbm_surface); @@ -388,36 +704,6 @@ release_buffer_fail: } -static tpl_result_t -__tpl_tbm_surface_create_swapchain(tpl_surface_t *surface, - tbm_format format, int width, - int height, int buffer_count, int present_mode) -{ - tpl_tbm_surface_t *tpl_tbm_surface = NULL; - - TPL_ASSERT(surface); - - tpl_tbm_surface = (tpl_tbm_surface_t *) surface->backend.data; - TPL_ASSERT(tpl_tbm_surface); - - /* FIXME: vblank has performance problem so replace all present mode to MAILBOX */ - present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX; - - /* TODO: check server supported present modes */ - switch (present_mode) { - case TPL_DISPLAY_PRESENT_MODE_MAILBOX: - case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE: - break; - default: - TPL_ERR("Unsupported present mode: %d", present_mode); - return TPL_ERROR_INVALID_PARAMETER; - } - - tpl_tbm_surface->present_mode = present_mode; - - return TPL_ERROR_NONE; -} - tpl_bool_t __tpl_display_choose_backend_tbm(tpl_handle_t native_dpy) { @@ -459,8 +745,14 @@ __tpl_tbm_display_query_window_supported_present_modes( if (!display->backend.data) return TPL_ERROR_INVALID_OPERATION; - if (modes) + if (modes) { *modes = TPL_DISPLAY_PRESENT_MODE_MAILBOX | TPL_DISPLAY_PRESENT_MODE_IMMEDIATE; +#if USE_WORKER_THREAD == 1 + if (__tpl_worker_support_vblank() == TPL_TRUE) + *modes |= TPL_DISPLAY_PRESENT_MODE_FIFO | TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED; +#endif + } + return TPL_ERROR_NONE; } @@ -502,6 +794,9 @@ __tpl_surface_init_backend_tbm(tpl_surface_backend_t *backend) backend->dequeue_buffer = __tpl_tbm_surface_dequeue_buffer; backend->enqueue_buffer = __tpl_tbm_surface_enqueue_buffer; backend->create_swapchain = __tpl_tbm_surface_create_swapchain; +#if USE_WORKER_THREAD == 1 + backend->destroy_swapchain = __tpl_tbm_surface_destroy_swapchain; +#endif backend->get_swapchain_buffers = __tpl_tbm_surface_get_swapchain_buffers; } -- 2.7.4 From fe7299d1f6f0d7685ef59722a076b55343527db7 Mon Sep 17 00:00:00 2001 From: YoungJun Cho Date: Wed, 21 Dec 2016 14:02:34 +0900 Subject: [PATCH 05/16] tpl_tbm: clean up __tpl_tbm_surface_fini() This patch cleans up __tpl_tbm_surface_fini(). For surface->type is TPL_SURFACE_TYPE_WINDOW, the added destroy callback should be removed. Change-Id: Ied7564b611bdddd1c606347190244d28f4cd1bac Signed-off-by: YoungJun Cho --- src/tpl_tbm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index cfdbd84..e5e43d5 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -222,8 +222,10 @@ __tpl_tbm_surface_fini(tpl_surface_t *surface) if (surface->type == TPL_SURFACE_TYPE_PIXMAP) tbm_surface_internal_unref((tbm_surface_h)surface->native_handle); - - if (surface->type == TPL_SURFACE_TYPE_WINDOW) { + else if (surface->type == TPL_SURFACE_TYPE_WINDOW) { + tbm_surface_queue_remove_destroy_cb( + (tbm_surface_queue_h)surface->native_handle, + __tpl_tbm_surface_queue_notify_cb, surface); /*TODO: we need fix for dequeued surface*/ } -- 2.7.4 From 45e6975c6343e5983ef0690a836cd7d0bef00a01 Mon Sep 17 00:00:00 2001 From: "deasung.kim" Date: Wed, 7 Dec 2016 12:06:03 +0900 Subject: [PATCH 06/16] tpl_wayland_vk_wsi: apply wayland-vulkan protocol get from server supproted present mode send client's present mode to server if client's present mode supported by server send buffer after draw done (not handle present mode in client) Change-Id: Icd4ab09dfdc84e6e98cf8e7c09ab3a2f502b4583 --- Makefile | 1 + packaging/libtpl-egl.spec | 12 +++++ src/tpl_wayland_vk_wsi.c | 120 +++++++++++++++++++++++++++++++++++++++------- 3 files changed, 116 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index a755695..b1f040e 100644 --- a/Makefile +++ b/Makefile @@ -76,6 +76,7 @@ TPL_SRCS += $(SRC_DIR)/tpl_wayland_vk_wsi.c TPL_SRCS += $(SRC_DIR)/tpl_gbm.c TPL_SRCS += $(SRC_DIR)/protocol/tizen-surface-protocol.c TPL_SRCS += $(SRC_DIR)/tpl_worker_thread.c +TPL_SRCS += $(SRC_DIR)/wayland-vulkan/wayland-vulkan-protocol.c endif ifneq ($(call is-feature-enabled,winsys_dri2),) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index eedabda..fabb59a 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -162,6 +162,13 @@ export TPL_VER_MAJOR=%{TPL_VER_MAJOR} export TPL_VER_MINOR=%{TPL_VER_MINOR} export TPL_RELEASE=%{TPL_RELEASE} +#wayland-vulkan build +%if "%{TPL_WINSYS}" == "WL" +cd src/wayland-vulkan +make +cd - +%endif + make all #libwayland-egl build @@ -207,6 +214,11 @@ cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so. cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/%{TZ_SYS_RO_SHARE}/license/libwayland-egl export WLD_EGL_SO_VER=%{WL_EGL_VERSION} %makeinstall +cd - + +cd src/wayland-vulkan +%makeinstall +cd - %endif %post -p /sbin/ldconfig diff --git a/src/tpl_wayland_vk_wsi.c b/src/tpl_wayland_vk_wsi.c index a305762..136ab83 100644 --- a/src/tpl_wayland_vk_wsi.c +++ b/src/tpl_wayland_vk_wsi.c @@ -11,6 +11,8 @@ #include +#include "wayland-vulkan/wayland-vulkan-client-protocol.h" + #define CLIENT_QUEUE_SIZE 3 #define USE_WORKER_THREAD @@ -33,7 +35,9 @@ struct _tpl_wayland_vk_wsi_display { struct { int min_buffer; int max_buffer; + int present_modes; } surface_capabilities; + struct wayland_vulkan *wl_vk_client; }; struct _tpl_wayland_vk_wsi_surface { @@ -153,6 +157,56 @@ __tpl_wayland_vk_wsi_display_roundtrip(tpl_display_t *display) return ret; } +static void +__tpl_wayland_vk_wsi_support_present_mode_listener(void *data, + struct wayland_vulkan *wayland_vulkan, + uint32_t mode) +{ + tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = data; + + switch (mode) { + case WAYLAND_VULKAN_PRESENT_MODE_TYPE_IMMEDIATE: + wayland_vk_wsi_display->surface_capabilities.present_modes + |= TPL_DISPLAY_PRESENT_MODE_IMMEDIATE; + break; + case WAYLAND_VULKAN_PRESENT_MODE_TYPE_MAILBOX: + wayland_vk_wsi_display->surface_capabilities.present_modes + |= TPL_DISPLAY_PRESENT_MODE_MAILBOX; + break; + case WAYLAND_VULKAN_PRESENT_MODE_TYPE_FIFO: + wayland_vk_wsi_display->surface_capabilities.present_modes + |= TPL_DISPLAY_PRESENT_MODE_FIFO; + break; + case WAYLAND_VULKAN_PRESENT_MODE_TYPE_FIFO_RELAXED: + wayland_vk_wsi_display->surface_capabilities.present_modes + |= TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED; + break; + default: + TPL_WARN("server sent unknown present type: %d", mode); + } +} + +static struct wayland_vulkan_listener wl_vk_listener = { + __tpl_wayland_vk_wsi_support_present_mode_listener, +}; + +static void +__tpl_wayland_vk_wsi_registry_handle_global(void *data, struct wl_registry *registry, + uint32_t name, const char *interface, uint32_t version) +{ + tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = data; + + if (!strcmp(interface, "wayland_vulkan")) { + wayland_vk_wsi_display->wl_vk_client = + wl_registry_bind(registry, name, &wayland_vulkan_interface, version); + } +} + +static const struct wl_registry_listener registry_listener = { + __tpl_wayland_vk_wsi_registry_handle_global, + NULL +}; + static tpl_result_t __tpl_wayland_vk_wsi_display_init(tpl_display_t *display) { @@ -175,12 +229,16 @@ __tpl_wayland_vk_wsi_display_init(tpl_display_t *display) wayland_vk_wsi_display->surface_capabilities.min_buffer = 2; wayland_vk_wsi_display->surface_capabilities.max_buffer = CLIENT_QUEUE_SIZE; + wayland_vk_wsi_display->surface_capabilities.present_modes = + TPL_DISPLAY_PRESENT_MODE_MAILBOX; display->backend.data = wayland_vk_wsi_display; if (__tpl_wayland_vk_wsi_display_is_wl_display(display->native_handle)) { struct wl_display *wl_dpy = (struct wl_display *)display->native_handle; + struct wl_registry *wl_registry; + wayland_vk_wsi_display->wl_tbm_client = wayland_tbm_client_init((struct wl_display *) wl_dpy); @@ -188,6 +246,18 @@ __tpl_wayland_vk_wsi_display_init(tpl_display_t *display) TPL_ERR("Wayland TBM initialization failed!"); goto free_wl_display; } + + wl_registry = wl_display_get_registry(wl_dpy); + /* check wl_registry */ + wl_registry_add_listener(wl_registry, ®istry_listener, wayland_vk_wsi_display); + wl_display_roundtrip(wl_dpy); + + if (wayland_vk_wsi_display->wl_vk_client) + wayland_vulkan_add_listener(wayland_vk_wsi_display->wl_vk_client, + &wl_vk_listener, wayland_vk_wsi_display); + + wl_display_roundtrip(wl_dpy); + wl_registry_destroy(wl_registry); } else { goto free_wl_display; } @@ -212,6 +282,8 @@ __tpl_wayland_vk_wsi_display_fini(tpl_display_t *display) wayland_vk_wsi_display = (tpl_wayland_vk_wsi_display_t *)display->backend.data; if (wayland_vk_wsi_display) { wayland_tbm_client_deinit(wayland_vk_wsi_display->wl_tbm_client); + if (wayland_vk_wsi_display->wl_vk_client) + wayland_vulkan_destroy(wayland_vk_wsi_display->wl_vk_client); free(wayland_vk_wsi_display); } display->backend.data = NULL; @@ -292,7 +364,8 @@ __tpl_wayland_vk_wsi_display_query_window_supported_present_modes( if (!wayland_vk_wsi_display) return TPL_ERROR_INVALID_OPERATION; if (modes) { - *modes = TPL_DISPLAY_PRESENT_MODE_MAILBOX | TPL_DISPLAY_PRESENT_MODE_IMMEDIATE; + *modes = TPL_DISPLAY_PRESENT_MODE_MAILBOX | TPL_DISPLAY_PRESENT_MODE_IMMEDIATE | + wayland_vk_wsi_display->surface_capabilities.present_modes; #if USE_WORKER_THREAD == 1 if (__tpl_worker_support_vblank() == TPL_TRUE) *modes |= TPL_DISPLAY_PRESENT_MODE_FIFO | TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED; @@ -709,6 +782,7 @@ __tpl_wayland_vk_wsi_process_draw_done(tpl_surface_t *surface, { tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = NULL; tpl_wayland_vk_wsi_buffer_t *wayland_vk_wsi_buffer = NULL; + tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = NULL; TPL_ASSERT(surface); TPL_ASSERT(tbm_surface); @@ -718,15 +792,24 @@ __tpl_wayland_vk_wsi_process_draw_done(tpl_surface_t *surface, (tpl_wayland_vk_wsi_surface_t *)surface->backend.data; wayland_vk_wsi_buffer = __tpl_wayland_vk_wsi_get_wayland_buffer_from_tbm_surface(tbm_surface); + wayland_vk_wsi_display = (tpl_wayland_vk_wsi_display_t *) + surface->display->backend.data; TPL_ASSERT(wayland_vk_wsi_surface); TPL_ASSERT(wayland_vk_wsi_buffer); - - /* TODO: send buffer to server immediate when server support present mode */ + TPL_ASSERT(wayland_vk_wsi_display); close(wayland_vk_wsi_buffer->wait_sync); wayland_vk_wsi_buffer->wait_sync = -1; + /* if server supported current supported mode then just send */ + + if (wayland_vk_wsi_surface->present_mode & + wayland_vk_wsi_display->surface_capabilities.present_modes) { + __tpl_wayland_vk_wsi_surface_commit_buffer(surface, tbm_surface); + return; + } + if (wayland_vk_wsi_surface->present_mode == TPL_DISPLAY_PRESENT_MODE_FIFO) { pthread_mutex_lock(&wayland_vk_wsi_surface->vblank_list_mutex); /* unref in tpl list remove callback @@ -833,22 +916,25 @@ __tpl_wayland_vk_wsi_surface_create_swapchain(tpl_surface_t *surface, /* FIXME: vblank has performance problem so replace all present mode to MAILBOX */ present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX; - /* TODO: check server supported present modes */ - switch (present_mode) { + if ((present_mode & wayland_vk_wsi_display->surface_capabilities.present_modes) == 0) { + /* server not supported current mode check client mode */ + switch (present_mode) { #if USE_WORKER_THREAD == 1 - case TPL_DISPLAY_PRESENT_MODE_FIFO: - case TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED: - if (__tpl_worker_support_vblank() == TPL_FALSE) { - TPL_ERR("Unsupported present mode: %d, worker not support vblank", present_mode); - return TPL_ERROR_INVALID_PARAMETER; - } + case TPL_DISPLAY_PRESENT_MODE_FIFO: + case TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED: + if (__tpl_worker_support_vblank() == TPL_FALSE) { + TPL_ERR("Unsupported present mode: %d, worker not support vblank", + present_mode); + return TPL_ERROR_INVALID_PARAMETER; + } #endif - case TPL_DISPLAY_PRESENT_MODE_MAILBOX: - case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE: - break; - default: - TPL_ERR("Unsupported present mode: %d", present_mode); - return TPL_ERROR_INVALID_PARAMETER; + case TPL_DISPLAY_PRESENT_MODE_MAILBOX: + case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE: + break; + default: + TPL_ERR("Unsupported present mode: %d", present_mode); + return TPL_ERROR_INVALID_PARAMETER; + } } wayland_vk_wsi_surface->present_mode = present_mode; -- 2.7.4 From c6b5e3584a11af18250e7b0cf5214a33500d6f70 Mon Sep 17 00:00:00 2001 From: YoungJun Cho Date: Fri, 2 Dec 2016 14:17:08 +0900 Subject: [PATCH 07/16] tpl_display: modify return value of tpl_display_create() when it is already existed This patch modifies return value of tpl_display_create() when it is already existed. Change-Id: Icd9a73b5cf03d284fd20f42edeebf86eebc80799 Signed-off-by: YoungJun Cho --- src/tpl_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tpl_display.c b/src/tpl_display.c index b58da59..d78f67a 100644 --- a/src/tpl_display.c +++ b/src/tpl_display.c @@ -30,8 +30,8 @@ tpl_display_create(tpl_backend_type_t type, tpl_handle_t native_dpy) /* Search for an already connected display for the given native display. */ display = __tpl_runtime_find_display(type, native_dpy); - /* If tpl_display already exists, then return NULL */ - TPL_CHECK_ON_TRUE_RETURN_VAL(display, NULL); + /* If tpl_display already exists, then return it */ + TPL_CHECK_ON_TRUE_RETURN_VAL(display, display); /* if backend is unknown, try to find the best match from the list of supported types */ if (TPL_BACKEND_UNKNOWN == type) -- 2.7.4 From 9d0dd2c0fee1f986913232a3c12b76bb773439b8 Mon Sep 17 00:00:00 2001 From: YoungJun Cho Date: Tue, 13 Dec 2016 17:11:41 +0900 Subject: [PATCH 08/16] wayland-egl: clean up wl_egl_window_create() This patch cleans up wl_egl_window_create(). Some callbacks are also initialized. Change-Id: I3361d02299287af0313ed96371ea61c8984fb964 Signed-off-by: YoungJun Cho --- src/wayland-egl/wayland-egl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 77e8e22..1034539 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -78,29 +78,37 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, WL_EGL_EXPORT struct wl_egl_window * wl_egl_window_create(struct wl_surface *surface, - int width, int height) + int width, int height) { struct wl_egl_window *egl_window; - if (width <= 0 || height <= 0) return NULL; - if (!surface) return NULL; + if (width <= 0 || height <= 0) + return NULL; + if (!surface) + return NULL; - egl_window = malloc(sizeof * egl_window); + egl_window = malloc(sizeof *egl_window); if (!egl_window) { WL_EGL_ERR("failed to allocate memory for egl_window"); return NULL; } egl_window->surface = surface; - egl_window->private = NULL; + egl_window->resize_callback = NULL; wl_egl_window_resize(egl_window, width, height, 0, 0); + egl_window->attached_width = 0; egl_window->attached_height = 0; + egl_window->rotation = ROTATION_0; + egl_window->private = NULL; + egl_window->rotate_callback = NULL; + egl_window->get_rotation_capability = NULL; + WL_EGL_LOG(2, "surf:%10p WxH:%dx%d egl_win:%10p priv:%10p", - surface, width, height, egl_window, egl_window->private); + surface, width, height, egl_window, egl_window->private); return egl_window; } -- 2.7.4 From 746724642f44c339c2da73c07ef7a11977be5c34 Mon Sep 17 00:00:00 2001 From: YoungJun Cho Date: Tue, 13 Dec 2016 17:09:56 +0900 Subject: [PATCH 09/16] tpl_wayland_egl: clean up __cb_client_window_resize_callback() This patch cleans up __cb_client_window_resize_callback(). It seems to be better to call tbm_surface_queue_get_width/height APIs once. Change-Id: Ib5668f472c8fffdeca020317b265cb491538e45c Signed-off-by: YoungJun Cho --- src/tpl_wayland_egl.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 2b89173..adf21f3 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -1199,28 +1199,26 @@ static const struct wl_buffer_listener buffer_release_listener = { static void __cb_client_window_resize_callback(struct wl_egl_window *wl_egl_window, - void *private) + void *private) { TPL_ASSERT(private); TPL_ASSERT(wl_egl_window); - int width, height; + int cur_w, cur_h, req_w, req_h; tpl_surface_t *surface = (tpl_surface_t *)private; - tpl_wayland_egl_surface_t *wayland_egl_surface = (tpl_wayland_egl_surface_t *) - surface->backend.data; + tpl_wayland_egl_surface_t *wayland_egl_surface = + (tpl_wayland_egl_surface_t *)surface->backend.data; - width = wl_egl_window->width; - height = wl_egl_window->height; + cur_w = tbm_surface_queue_get_width(wayland_egl_surface->tbm_queue); + cur_h = tbm_surface_queue_get_height(wayland_egl_surface->tbm_queue); + req_w = wl_egl_window->width; + req_h = wl_egl_window->height; TPL_LOG_B("WL_EGL", "[RESIZE_CB] wl_egl_window(%p) (%dx%d) -> (%dx%d)", - wl_egl_window, - tbm_surface_queue_get_width(wayland_egl_surface->tbm_queue), - tbm_surface_queue_get_height(wayland_egl_surface->tbm_queue), - width, - height); + wl_egl_window, cur_w, cur_h, req_w, req_h); + /* Check whether the surface was resized by wayland_egl */ - if ((width != tbm_surface_queue_get_width(wayland_egl_surface->tbm_queue)) - || (height != tbm_surface_queue_get_height(wayland_egl_surface->tbm_queue))) + if ((req_w != cur_w) || (req_h != cur_h)) wayland_egl_surface->resized = TPL_TRUE; } -- 2.7.4 From ab2f2d093d0b35c500f61383a4959832e705c404 Mon Sep 17 00:00:00 2001 From: YoungJun Cho Date: Wed, 21 Dec 2016 15:19:07 +0900 Subject: [PATCH 10/16] tpl_wayland_egl: clean up __tpl_wayland_egl_surface_init() This patch cleans up __tpl_wayland_egl_surface_init(). There are som omitted error routines. Change-Id: I781a89b1f685d2586bbd03eebf028d4c4b8fba6e Signed-off-by: YoungJun Cho --- src/tpl_wayland_egl.c | 68 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index adf21f3..5dea7ed 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -115,9 +115,8 @@ __tpl_wayland_egl_display_is_wl_display(tpl_handle_t native_dpy) /* MAGIC CHECK: A native display handle is a wl_display if the de-referenced first value is a memory address pointing the structure of wl_display_interface. */ - if ( wl_egl_native_dpy == &wl_display_interface ) { + if (wl_egl_native_dpy == &wl_display_interface) return TPL_TRUE; - } if (strncmp(wl_egl_native_dpy->name, wl_display_interface.name, strlen(wl_display_interface.name)) == 0) { @@ -495,8 +494,7 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) if (__tpl_object_init(&wayland_egl_surface->base, TPL_OBJECT_SURFACE, NULL) != TPL_ERROR_NONE) { TPL_ERR("Failed to initialize backend surface's base class!"); - free(wayland_egl_surface); - return TPL_ERROR_INVALID_OPERATION; + goto tpl_object_init_fail; } surface->backend.data = (void *)wayland_egl_surface; @@ -507,13 +505,15 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) wayland_egl_surface->current_buffer = NULL; wayland_egl_surface->attached_buffers = __tpl_list_alloc(); + if (!wayland_egl_surface->attached_buffers) { + TPL_ERR("Failed to allocate attached buffers tracking lists."); + goto alloc_attached_buffers_fail; + } + wayland_egl_surface->dequeued_buffers = __tpl_list_alloc(); - if (!wayland_egl_surface->attached_buffers - || !wayland_egl_surface->dequeued_buffers) { - TPL_ERR("Failed to allocate tracking lists."); - free(wayland_egl_surface); - surface->backend.data = NULL; - return TPL_ERROR_INVALID_OPERATION; + if (!wayland_egl_surface->dequeued_buffers) { + TPL_ERR("Failed to allocate dequeue buffers tracking lists."); + goto alloc_dequeue_buffers_fail; } if (wl_egl_window->surface) { @@ -535,15 +535,16 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) if (!wayland_egl_surface->tbm_queue) { TPL_ERR("TBM surface queue creation failed!"); - free(wayland_egl_surface); - surface->backend.data = NULL; - return TPL_ERROR_INVALID_OPERATION; + goto queue_create_fail; } /* Set reset_callback to tbm_queue */ - tbm_surface_queue_add_reset_cb(wayland_egl_surface->tbm_queue, - __cb_tbm_surface_queue_reset_callback, - (void *)surface); + if (tbm_surface_queue_add_reset_cb(wayland_egl_surface->tbm_queue, + __cb_tbm_surface_queue_reset_callback, + (void *)surface)) { + TPL_ERR("TBM surface queue add reset cb failed!"); + goto add_reset_cb_fail; + } surface->width = wl_egl_window->width; surface->height = wl_egl_window->height; @@ -553,18 +554,17 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) wl_egl_window->private = surface; wl_egl_window->resize_callback = (void *)__cb_client_window_resize_callback; wl_egl_window->rotate_callback = (void *)__cb_client_window_rotate_callback; - wl_egl_window->get_rotation_capability = (void *)__cb_client_window_get_rotation_capability; + wl_egl_window->get_rotation_capability = (void *) + __cb_client_window_get_rotation_capability; /* tdm_vblank object decide to be maintained every tpl_wayland_egl_surface for the case where the several surfaces is created in one display connection. */ if (wayland_egl_display->tdm_client) { if (TPL_ERROR_NONE != __tpl_wayland_egl_surface_create_vblank( - wayland_egl_surface, - wayland_egl_display->tdm_client)) { - tbm_surface_queue_destroy(wayland_egl_surface->tbm_queue); - free(wayland_egl_surface); - surface->backend.data = NULL; - return TPL_ERROR_INVALID_OPERATION; + wayland_egl_surface, + wayland_egl_display->tdm_client)) { + TPL_ERR("TBM surface create vblank failed!"); + goto create_vblank_fail; } } @@ -579,6 +579,23 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) wayland_egl_surface, wl_egl_window, surface->width, surface->height); return TPL_ERROR_NONE; + +create_vblank_fail: + tbm_surface_queue_remove_reset_cb(wayland_egl_surface->tbm_queue, + __cb_tbm_surface_queue_reset_callback, + (void *)surface); +add_reset_cb_fail: + tbm_surface_queue_destroy(wayland_egl_surface->tbm_queue); +queue_create_fail: + __tpl_list_free(wayland_egl_surface->attached_buffers, NULL); +alloc_dequeue_buffers_fail: + __tpl_list_free(wayland_egl_surface->dequeued_buffers, NULL); +alloc_attached_buffers_fail: + __tpl_object_fini(&wayland_egl_surface->base); +tpl_object_init_fail: + free(wayland_egl_surface); + surface->backend.data = NULL; + return TPL_ERROR_INVALID_OPERATION; } static void @@ -764,7 +781,7 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, if (tdm_err == TDM_ERROR_NONE) wayland_egl_surface->vblank_done = TPL_FALSE; else - TPL_ERR ("Failed to tdm_client_wait_vblank. error:%d", tdm_err); + TPL_ERR("Failed to tdm_client_wait_vblank. error:%d", tdm_err); } TRACE_ASYNC_BEGIN((int)tbm_surface, "[COMMIT ~ RELEASE_CB] BO_NAME:%d", @@ -802,9 +819,8 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, wayland_egl_surface, wayland_egl_surface->tbm_queue, tbm_surface, tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); - if (wayland_egl_surface->vblank_done == TPL_FALSE) { + if (wayland_egl_surface->vblank_done == TPL_FALSE) __tpl_wayland_egl_surface_wait_vblank(surface); - } if (sync_fence != -1) { tbm_sync_fence_wait(sync_fence, -1); -- 2.7.4 From 3920ae0d142cfca913374c9682b9073e8c0b3e2e Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Fri, 30 Dec 2016 09:47:55 +0900 Subject: [PATCH 11/16] tpl_wayland_egl: When wl_display_dispatch_queue() fails, print infomation of error in detail on __tpl_wayland_egl_surface_wait_dequeuable() When the wl_display_dispatch_queue() fails on __tpl_wayland_egl_surface_wait_dequeuable(), it generally prints errno and errno_str. If errno is EPROTO, it prints error interface name and error enumeration code. Change-Id: I774774294a396164a9b9c66492c9cb79f18257cc Signed-off-by: Mun, Gwan-gyeong --- src/tpl_wayland_egl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 5dea7ed..358432c 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -941,8 +941,24 @@ __tpl_wayland_egl_surface_wait_dequeuable(tpl_surface_t *surface) /* Application sent all buffers to the server. Wait for server response. */ if (wl_display_dispatch_queue(wayland_egl_display->wl_dpy, wayland_egl_display->wl_tbm_event_queue) == -1) { + int dpy_err; + char buf[1024]; + strerror_r(errno, buf, sizeof(buf)); + + TPL_ERR("falied to wl_display_dispatch_queue. error:%d(%s)", errno, + buf); + + dpy_err = wl_display_get_error(wayland_egl_display->wl_dpy); + if (dpy_err == EPROTO) { + const struct wl_interface *err_interface; + uint32_t err_proxy_id, err_code; + err_code = wl_display_get_protocol_error(wayland_egl_display->wl_dpy, + &err_interface, &err_proxy_id); + TPL_ERR("[Protocol Error] interface: %s, error_code: %d, proxy_id: %d", + err_interface->name, err_code, err_proxy_id); + } + ret = TPL_ERROR_INVALID_OPERATION; - TPL_ERR("falied to wl_display_dispatch_queue."); break; } } -- 2.7.4 From c0d606c41a8ce081c9790d33a9dc01f7d7d8f6e0 Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Fri, 6 Jan 2017 15:20:22 +0900 Subject: [PATCH 12/16] wayland-egl: Fixed incorrect resize on prerotation When the wl_egl_window_resize() is called, wl_egl_window_set_rotation() does not work properly on resizing of buffer. This patch selectivly apply for resizing of buffer when the wl_egl_window_resize() is called. Change-Id: Ie291b06a6d5cb60f07a56d26dbb96ce53740097b Signed-off-by: Mun, Gwan-gyeong --- src/wayland-egl/wayland-egl-priv.h | 1 + src/wayland-egl/wayland-egl.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/wayland-egl/wayland-egl-priv.h b/src/wayland-egl/wayland-egl-priv.h index 3c284fc..b16c84c 100644 --- a/src/wayland-egl/wayland-egl-priv.h +++ b/src/wayland-egl/wayland-egl-priv.h @@ -26,6 +26,7 @@ struct wl_egl_window { int attached_width; int attached_height; + int resize_requested; wl_egl_window_rotation rotation; void *private; diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 1034539..8a0be6f 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -67,6 +67,7 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, egl_window->height = height; egl_window->dx = dx; egl_window->dy = dy; + egl_window->resize_requested = 1; if (egl_window->resize_callback) egl_window->resize_callback(egl_window, egl_window->private); @@ -96,6 +97,7 @@ wl_egl_window_create(struct wl_surface *surface, egl_window->surface = surface; egl_window->resize_callback = NULL; + egl_window->resize_requested = 0; wl_egl_window_resize(egl_window, width, height, 0, 0); egl_window->attached_width = 0; @@ -145,6 +147,7 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, wl_egl_window_rotation rotation) { int resize = 0; + wl_egl_window_rotation prev_rotation; if (egl_window == NULL) { WL_EGL_ERR("egl_window is NULL"); @@ -156,15 +159,23 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, return; } + if (egl_window->resize_requested) { + prev_rotation = ROTATION_0; + egl_window->resize_requested = 0; + } + else { + prev_rotation = egl_window->rotation; + } + switch (rotation) { case ROTATION_0: case ROTATION_180: - if (egl_window->rotation == ROTATION_90 || egl_window->rotation == ROTATION_270) + if (prev_rotation == ROTATION_90 || prev_rotation == ROTATION_270) resize = 1; break; case ROTATION_90: case ROTATION_270: - if (egl_window->rotation == ROTATION_0 || egl_window->rotation == ROTATION_180) + if (prev_rotation == ROTATION_0 || prev_rotation == ROTATION_180) resize = 1; break; default: -- 2.7.4 From ec49b590f9005183a1cedb52c4a96cf9fff6d5db Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Wed, 11 Jan 2017 19:34:20 +0900 Subject: [PATCH 13/16] tpl_tbm: Remove missued pthread_mutex_init() for draw_waiting_mutex Add missed __tpl_tbm_set_tbm_buffer_to_tbm_surface() for tpl_tbm_buffer Change-Id: If705df4277b16533ec120edda027c1cdb787eeef Signed-off-by: Mun, Gwan-gyeong --- src/tpl_tbm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index 98b2de6..e7c8538 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -346,7 +346,7 @@ __tpl_tbm_draw_wait_buffer_get(tpl_surface_t *surface) tbm_surface_h tbm_surface; tpl_tbm_surface = surface->backend.data; - pthread_mutex_init(&tpl_tbm_surface->draw_waiting_mutex, NULL); + pthread_mutex_lock(&tpl_tbm_surface->draw_waiting_mutex); tbm_surface = __tpl_list_pop_front(&tpl_tbm_surface->draw_waiting_queue, NULL); pthread_mutex_unlock(&tpl_tbm_surface->draw_waiting_mutex); @@ -630,6 +630,7 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, TPL_ERR("Mem alloc for tpl_tbm_buffer failed!"); return NULL; } + __tpl_tbm_set_tbm_buffer_to_tbm_surface(tbm_surface, tpl_tbm_buffer); } #endif -- 2.7.4 From f5f2b52d81d1e5af6e80791261b2920acca33826 Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Fri, 13 Jan 2017 14:38:12 +0900 Subject: [PATCH 14/16] wayland-egl: Refactoring and fixing peephole on wl_egl_window_resize() and wl_egl_window_set_rotation() When the wl_egl_window_resize() / wl_egl_window_set_rotation is continuously called over twice previous implementation did not work properly on resizing of buffer. This patch fixes these problems. Change-Id: Idb6e1b2a38073b0bef215ef29964eccdcac9336e Signed-off-by: Mun, Gwan-gyeong --- src/wayland-egl/wayland-egl-priv.h | 1 - src/wayland-egl/wayland-egl.c | 62 ++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/wayland-egl/wayland-egl-priv.h b/src/wayland-egl/wayland-egl-priv.h index b16c84c..3c284fc 100644 --- a/src/wayland-egl/wayland-egl-priv.h +++ b/src/wayland-egl/wayland-egl-priv.h @@ -26,7 +26,6 @@ struct wl_egl_window { int attached_width; int attached_height; - int resize_requested; wl_egl_window_rotation rotation; void *private; diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 8a0be6f..8ed649f 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -58,23 +58,53 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, int width, int height, int dx, int dy) { + int prev_width, prev_height; + wl_egl_window_rotation rotation; + if (egl_window == NULL) { WL_EGL_ERR("egl_window is NULL"); return; } - egl_window->width = width; - egl_window->height = height; - egl_window->dx = dx; - egl_window->dy = dy; - egl_window->resize_requested = 1; + egl_window->dx = dx; + egl_window->dy = dy; + + rotation = egl_window->rotation; + switch (rotation) { + case ROTATION_0: + case ROTATION_180: + default: + prev_width = egl_window->width; + prev_height = egl_window->height; + break; + case ROTATION_90: + case ROTATION_270: + prev_width = egl_window->height; + prev_height = egl_window->width; + break; + } + if ((prev_width == width) && (prev_height == height)) return; + + switch (rotation) { + case ROTATION_0: + case ROTATION_180: + default: + egl_window->width = width; + egl_window->height = height; + break; + case ROTATION_90: + case ROTATION_270: + egl_window->width = height; + egl_window->height = width; + break; + } if (egl_window->resize_callback) egl_window->resize_callback(egl_window, egl_window->private); WL_EGL_LOG(2, "egl_win:%10p WxH:%dx%d dx:%d dy:%d rsz_cb:%10p", - egl_window, egl_window->width, egl_window->height, - egl_window->dx, egl_window->dy, egl_window->resize_callback); + egl_window, width, height, egl_window->dx, egl_window->dy, + egl_window->resize_callback); } WL_EGL_EXPORT struct wl_egl_window * @@ -97,7 +127,6 @@ wl_egl_window_create(struct wl_surface *surface, egl_window->surface = surface; egl_window->resize_callback = NULL; - egl_window->resize_requested = 0; wl_egl_window_resize(egl_window, width, height, 0, 0); egl_window->attached_width = 0; @@ -159,14 +188,7 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, return; } - if (egl_window->resize_requested) { - prev_rotation = ROTATION_0; - egl_window->resize_requested = 0; - } - else { - prev_rotation = egl_window->rotation; - } - + prev_rotation = egl_window->rotation; switch (rotation) { case ROTATION_0: case ROTATION_180: @@ -191,9 +213,11 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, if (egl_window->rotate_callback) egl_window->rotate_callback(egl_window, egl_window->private); - if (resize) { - wl_egl_window_resize(egl_window, egl_window->height, egl_window->width, - egl_window->dx, egl_window->dy); + if ((resize == 1) && (egl_window->resize_callback != NULL)) { + int temp = egl_window->width; + egl_window->width = egl_window->height; + egl_window->height = temp; + egl_window->resize_callback(egl_window, egl_window->private); } } -- 2.7.4 From 0f78671fe86208b26059351e5887c63936e32b78 Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Wed, 18 Jan 2017 16:56:03 +0900 Subject: [PATCH 15/16] tpl_tbm: Disable worker_thread for tbm backend. Current implementation of tbm worker_thread only works on vulkan tbm backend. For now, we disable this feature for stabilization of egl tbm backend. Change-Id: I2d419c5706720754b3d2bd6b682c31c9e30e009d Signed-off-by: Mun, Gwan-gyeong --- src/tpl_tbm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index e7c8538..aebca6d 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -9,7 +9,7 @@ #include #include -#define USE_WORKER_THREAD +//#define USE_WORKER_THREAD #ifndef USE_WORKER_THREAD #define USE_WORKER_THREAD 0 #else -- 2.7.4 From d956ab5abdffa68b3e5ce8b105d3d35a44bd30b5 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Fri, 28 Oct 2016 16:11:54 +0900 Subject: [PATCH 16/16] tc: Cleanup previous not working TC Change-Id: I9c26ebad61ce2ecfb4219e69e5af282d91260f8a Signed-off-by: Hoyub Lee --- tc/Makefile | 256 ---------------------- tc/packaging/tpl-test.spec | 33 --- tc/src/main.c | 535 --------------------------------------------- tc/src/tpl_test_buffer.c | 461 -------------------------------------- tc/src/tpl_test_display.c | 268 ----------------------- tc/src/tpl_test_object.c | 189 ---------------- tc/src/tpl_test_surface.c | 425 ----------------------------------- tc/src/tpl_test_util.h | 317 --------------------------- tc/tpl-test.manifest | 5 - 9 files changed, 2489 deletions(-) delete mode 100644 tc/Makefile delete mode 100644 tc/packaging/tpl-test.spec delete mode 100644 tc/src/main.c delete mode 100644 tc/src/tpl_test_buffer.c delete mode 100644 tc/src/tpl_test_display.c delete mode 100644 tc/src/tpl_test_object.c delete mode 100644 tc/src/tpl_test_surface.c delete mode 100644 tc/src/tpl_test_util.h delete mode 100644 tc/tpl-test.manifest diff --git a/tc/Makefile b/tc/Makefile deleted file mode 100644 index 84db03a..0000000 --- a/tc/Makefile +++ /dev/null @@ -1,256 +0,0 @@ -############################################################ -# Makefile for GLES 2.x test application -# Created by yigl - 090113 -############################################################ - -############################################################ -# configuration -############################################################ - -NULL = - -TOOLCHAIN_PREFIX = - -# Application name - -BIN_NAME = tpl-test - -# Debugging mode: yes, no -DEBUG_MODE = yes - -# Project path -INSTALL_DIR = /usr/bin - -# WS_NULL, WS_X11 -NATIVE_WIN = WS_WL -#NATIVE_WIN = WS_NULL - -# Defines -DEFS = - -# Required packages -REQ_PKGS = - -# LDFLAGS -LDFLAGS = -lm -lrt -lpthread -ltpl-egl # -lEGL -lGLESv2 - -SUPPORT_LIBPNG=0 -ifeq ($(SUPPORT_LIBPNG), 1) -REQ_PKGS += libpng -endif - -# Hostname -HOST_NAME = `uname -n` - - -# Checks GLES core -#ifeq ($(GLES_CORE), C110_SGX540) -# DEFS += -DGLES_C110_SGX540 -# REQ_PKGS += opengl-es-20 -#endif -REQ_PKGS += gles20 - -# Checks window system -ifeq ($(NATIVE_WIN), WS_NULL) - DEFS += -DWS_NULL - REQ_PKGS += - C_SRCS += \ - src/gfx_native_wnd_null.c \ - $(NULL) -endif - -ifeq ($(NATIVE_WIN), WS_X11) - DEFS += -DWS_X11 -REQ_PKGS += x11 xext libdrm libtbm libudev - C_HEADERS+= \ - src/gfx_util_x11.h \ - src/gfx_egl_x11.h \ - src/gfx_data_00.h \ - src/gfx_data_01.h \ - src/gfx_data_02.h \ - $(NULL) - C_SRCS += \ - src/gfx_native_wnd_x11.c \ - src/gfx_util_x11.c \ - src/gfx_egl_x11.c \ - src/gfx_test_gles_horizontal_tearing_with_xevent.c \ - src/gfx_test_gles_inconsistent_rendering.c \ - src/gfx_test_gles_inconsistent_rendering_with_xevent.c \ - src/gfx_test_gles_measure_perf_with_xevent.c \ - src/gfx_test_egl_client_pixmap_basic.c \ - src/gfx_test_egl_client_pixmap_glReadPixels.c \ - src/gfx_test_egl_pixmap_surface_pixmap.c \ - src/gfx_test_egl_pixmap_surface_x11_n_gles_rendering.c \ - src/gfx_test_egl_pixmap_surface_glReadPixels.c \ - src/gfx_test_egl_pixmap_surface_pixmap_eglimage.c \ - src/gfx_test_egl_window_surface_resize_x11_window.c \ - src/gfx_test_egl_window_surface_transparency.c \ - src/gfx_test_egl_EGL_texture_from_pixmap.c \ - src/gfx_test_eglimg_texture_from_pixmap.c \ - src/gfx_test_eglimg_texture_from_pixmap_many_imgs.c \ - src/gfx_test_eglimg_texture_from_pixmap_width.c \ - src/gfx_test_eglimg_texture_from_pixmap_multi_thread.c \ - src/gfx_test_eglimg_texture_from_pixmap_multi_thread2.c \ - src/gfx_test_gles_wagonwheel_effect.c \ - src/gfx_test_eglimg_rgb_yuv_texture.c\ - src/gfx_test_eglimg_rgb_yuv_texture_format.c\ - $(NULL) -endif - - -ifeq ($(NATIVE_WIN), WS_WL) - DEFS += -DWS_WL -REQ_PKGS += wayland wayland-client wayland-egl wayland-drm libdrm libtbm libudev - C_HEADERS+= \ -# src/gfx_util_x11.h \ - src/gfx_egl_x11.h \ - src/gfx_data_00.h \ - src/gfx_data_01.h \ - src/gfx_data_02.h \ - $(NULL) - C_SRCS += \ - # src/gfx_native_wnd_wayland.c \ - src/gfx_util_wayland.c \ - src/gfx_egl_x11.c \ - src/gfx_test_gles_inconsistent_rendering.c \ - src/gfx_test_egl_window_surface_transparency.c \ - $(NULL) -endif - -############################################################ -# build tools -############################################################ - -CPP = $(TOOLCHAIN_PREFIX)cpp -CC = $(TOOLCHAIN_PREFIX)gcc -CXX = $(TOOLCHAIN_PREFIX)g++ -LD = $(TOOLCHAIN_PREFIX)ld - -############################################################ -# tool flags -############################################################ - -CPP_FLAGS = \ - -fPIC \ - -Wall \ - -I$(PWD)/src \ - $(DEFS) \ - -DBLD_HOST_NAME=\"$(HOST_NAME)\" \ - -I/usr/include/libdrm/ `pkg-config --cflags $(REQ_PKGS)` \ - $(NULL) - -ifeq ($(SUPPORT_LIBPNG), 1) -CPP_FLAGS += -DSUPPORT_LIBPNG -endif - -CFLAGS = \ - $(CPP_FLAGS) \ - $(NULL) - -CXXFLAGS = \ - $(CPP_FLAGS) \ - $(NULL) - -ifeq ($(DEBUG_MODE), yes) - CFLAGS += -g -DGFX_ENABLE_LOG=1 - CXXFLAGS += -g -DGFX_ENABLE_LOG=1 -else -# CFLAGS += -O2 -# CXXFLAGS += -O2 - CFLAGS += -g - CXXFLAGS += -g -endif - -############################################################ -# library path and libs -############################################################ - -LDFLAGS += \ - `pkg-config --libs $(REQ_PKGS)` -lwayland-client -ludev -ltbm -lwayland-egl -ldrm\ - $(NULL) - -############################################################ -# sources -############################################################ - -#C_HEADERS += \ - src/gfx_platform.h \ - src/gfx_util.h \ - src/gfx_list.h \ - src/gfx_egl.h \ - src/gfx_test.h \ - $(NULL) -C_HEADERS += src/tpl_test_util.h #src/gfx_egl.h -C_SRCS += \ - src/main.c src/tpl_test_surface.c src/tpl_test_display.c src/tpl_test_object.c src/tpl_test_buffer.c - #src/gfx_util.c src/gfx_test_eglimg_map_render_basic.c src/main.c - #src/gfx_list.c \ - src/gfx_egl_common.c \ - src/gfx_test_egl_memory.c \ - src/gfx_test_gles_ext_basic.c \ - src/gfx_test_egl_color_buffer_preservation.c \ - src/gfx_test_gles_tex_mapping.c \ - src/gfx_test_gles_tex_mapping_type.c \ - src/gfx_test_gles_tex_render_basic.c \ - src/gfx_test_gles_tex_render_many_objs.c \ - src/gfx_test_gles_tex_update_basic.c \ - src/gfx_test_gles_tex_update_non_multiple_of_32.c \ - src/gfx_test_eglimg_map_render_basic.c \ - src/gfx_test_eglimg_map_render_many_objs.c \ - src/gfx_test_eglimg_map_update_basic.c \ - src/gfx_test_eglimg_map_update_non_multiple_of_32.c \ - src/gfx_test_eglimg_map_update_width.c \ - src/gfx_test_eglimg_map_n_client_pixmap_render_basic.c \ - src/gfx_test_gles_stencil_operation.c \ - src/gfx_test_gles_GL_TRIANGLES.c \ - src/gfx_test_gles_landscape.c \ - src/gfx_test_gles_texture_width.c \ - src/gfx_test_gles_horizontal_tearing.c \ - src/gfx_test_gles_measure_perf_alpha_blending.c \ - src/gfx_test_gles_measure_perf_pixel_fillrate.c \ - src/gfx_test_gles_measure_perf_texel_fillrate.c \ - src/gfx_test_gles_fbo_basic.c \ - src/gfx_test_gles_frag_shader_basic.c \ - src/gfx_test_gles_tex_render_tga.c \ - src/gfx_test_gles_binary_shader_basic.c \ - src/gfx_test_gles_binary_program_basic.c \ - src/gfx_test_gles_fbo_multisample.c \ - src/gfx_test_eglimg_map_render_2d.c \ - src/gfx_test_egl_pbuffer_basic.c \ - src/gfx_test_gles_cube_tex_render_basic.c \ - src/gfx_test_gles_cube_tex_render_fbo.c \ - src/gfx_test_egl_swap_buffer_with_damage.c \ - src/gfx_test_gles_qcom_tile_partial_rendering.c \ - src/main.c \ - $(NULL) - -CXX_SRCS += \ - $(NULL) - -OBJS = \ - $(CXX_SRCS:%.cpp=%.o) \ - $(C_SRCS:%.c=%.o) \ - $(NULL) - -############################################################ -# targets and rules -############################################################ - -all: $(BIN_NAME) - -$(BIN_NAME): $(OBJS) $(C_HEADERS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) - -%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - -%.o: %.cpp - $(CXX) $(CXXFLAGS) -c $< -o $@ - -install: $(BIN_NAME) - cp -va $(BIN_NAME) $(INSTALL_DIR) - -clean: - find . -name "*.o" -exec rm -vf {} \; - find . -name "*~" -exec rm -vf {} \; - rm -vf $(BIN_NAME) diff --git a/tc/packaging/tpl-test.spec b/tc/packaging/tpl-test.spec deleted file mode 100644 index 0f8b2c1..0000000 --- a/tc/packaging/tpl-test.spec +++ /dev/null @@ -1,33 +0,0 @@ -Name: tpl-test -Summary: test for tpl -Version: 0.0.1 -Release: 01 -Group: System/X Hardware Support -License: Samsung -Source0: %{name}-%{version}.tar.gz -BuildRequires: pkgconfig(libdrm) -BuildRequires: pkgconfig(libudev) -BuildRequires: pkgconfig(libtbm) -BuildRequires: pkgconfig(gbm) -BuildRequires: pkgconfig(wayland-client) -BuildRequires: libwayland-egl-devel -BuildRequires: libtpl-egl-devel -%description -The Simple Test Cases - - -%prep -%setup -q - -%build -export LDFLAGS="${LDFLAGS} -rdynamic" -make - -%install -mkdir -p %{buildroot}/opt/usr/tpl-test -cp -arp ./tpl-test %{buildroot}/opt/usr/tpl-test - -%files -%manifest tpl-test.manifest -%defattr(-,root,root,-) -/opt/usr/tpl-test/* diff --git a/tc/src/main.c b/tc/src/main.c deleted file mode 100644 index 896bdad..0000000 --- a/tc/src/main.c +++ /dev/null @@ -1,535 +0,0 @@ -#include -#include -#include -#include -#include - -#include "tpl_test_util.h" - -#include -#include -#include - - -typedef struct _ProgOption ProgOption; - -typedef struct _ProgOption { - int egl_r; - int egl_g; - int egl_b; - int egl_a; - int egl_d; - int egl_s; - int egl_preserved; - int egl_swap_interval; - int wnd_x; - int wnd_y; - int wnd_w; - int wnd_h; - int frames; - int tc_num; - int fps; - bool all; - bool show_names; -}; - -ProgOption g_option = { - 8, 8, 8, 8, - 24, - 0, - 0, - 1, - 0, 0, - 1920, 1080, - 1000, - 0, - 300, - false, - false -}; - -/* log related */ -#ifdef TPL_ENABLE_LOG -bool -__LOG( const char *func, int line, const char *fmt, ... ) -{ - char buff[NUM_ERR_STR] = { (char)0, }; - char str[NUM_ERR_STR] = { (char)0, }; - va_list args; - - va_start( args, fmt ); - vsprintf( buff, fmt, args ); - va_end( args ); - - sprintf( str, "[tpl_test] %s[%d] %s", func, line, buff ); - printf( "ddk:[tpl_test] %s[%d] %s\n", func, line, buff ); - __tpl_test_log_display_msg( str ); - - return true; -} - -void -__LOG_BEGIN( const char *func ) -{ - char str[NUM_ERR_STR] = { (char)0, }; - sprintf( str, "[tpl_test][B] %s", func ); - printf( "ddk:[tpl_test][B] %s\n", func ); - __tpl_test_log_display_msg( str ); -} - -void -__LOG_END( const char *func ) -{ - char str[NUM_ERR_STR] = { (char)0, }; - sprintf( str, "[tpl_test][E] %s", func ); - printf( "ddk:[tpl_test][E] %s\n", func ); - __tpl_test_log_display_msg( str ); -} - -bool -__tpl_test_log_display_msg( const char *msg ) -{ - fprintf( DEFAULT_LOG_STREAM, "%s\n", msg ); - fflush( DEFAULT_LOG_STREAM ); - return 1; -} - -bool -__LOG_ERR( const char *func, int line, const char *fmt, ... ) -{ - char buff[NUM_ERR_STR] = { (char)0, }; - char str[NUM_ERR_STR] = { (char)0, }; - va_list args; - - va_start( args, fmt ); - vsprintf( buff, fmt, args ); - va_end( args ); - - sprintf( str, "[tpl_test] %s[%d] %s", func, line, buff ); - - __tpl_test_log_display_msg( str ); - - return true; -} - -#endif /* TPL_ENABLE_LOG */ - -/* wayland native related */ -registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version) -{ - TPLNativeWnd *that = (TPLNativeWnd *)(data); - - if (strcmp(interface, "wl_compositor") == 0) { - that->compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); - } else if (strcmp(interface, "wl_shell") == 0) { - that->shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); - } else if (strcmp(interface, "wl_output") == 0) { - /*struct my_output *my_output = new struct my_output; - memset(my_output, 0, sizeof(*my_output)); - my_output->output = wl_registry_bind(registry,id, &wl_output_interface, 2);*/ - } -} - -void -registry_handle_global_remove(void *data, struct wl_registry *registry, - uint32_t name) -{ -} - -const struct wl_registry_listener registry_listener_ = { - registry_handle_global, - registry_handle_global_remove -}; - -shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface, - uint32_t serial) -{ - wl_shell_surface_pong(shell_surface, serial); -} - -void -shell_surface_handle_popup_done(void *data, - struct wl_shell_surface *shell_surface) -{ -} - -void -shell_surface_handle_configure(void *data, - struct wl_shell_surface *shell_surface, uint32_t edges, int32_t width, - int32_t height) -{ - TPLNativeWnd *that = (TPLNativeWnd *)(data); - that->width = width; - that->height = height; - wl_egl_window_resize(that->wnd, width, height, 0, 0); -} - - -const struct wl_shell_surface_listener shell_surface_listener_ = { - shell_surface_handle_ping, - shell_surface_handle_configure, - shell_surface_handle_popup_done -}; -/* wayland native end */ - -/* tpl_test related */ -TPLNativeWnd * -tpl_test_native_wnd_create( void ) -{ - TPLNativeWnd *wnd = NULL; - - TPL_RSM_MALLOC( wnd, TPLNativeWnd ); - - //wnd->dpy = (NativeDisplayType)NULL; - wnd->dpy = (void *)NULL; - wnd->screen = 0; - //wnd->root = (NativeWindowType)NULL; - wnd->root = (void *)NULL; - //wnd->wnd = (NativeWindowType)NULL; - wnd->wnd = (void *)NULL; - wnd->x = 0; - wnd->y = 0; - wnd->width = 0; - wnd->height = 0; - wnd->depth = 0; - tpl_display_t *tpl_display = NULL; - tpl_surface_t *tpl_surf = NULL; - tpl_buffer_t *tpl_buf = NULL; -finish: - return wnd; -} - -bool -tpl_test_native_wnd_initialize( TPLNativeWnd *wnd, int x, int y, int width, - int height ) -{ - bool res = false; - - TPL_CHK_PARAM( !wnd ); - TPL_CHK_PARAM( x < 0 ); - TPL_CHK_PARAM( y < 0 ); - TPL_CHK_PARAM( width <= 0 ); - TPL_CHK_PARAM( height <= 0 ); - - //wnd->dpy = (NativeDisplayType)wl_display_connect(NULL); - wnd->dpy = (void *)wl_display_connect(NULL); - if ( !wnd->dpy ) { - __log_err( "wl_display_connect() is failed."); - return res; - } - - wnd->registry = wl_display_get_registry(wnd->dpy); - - wl_registry_add_listener(wnd->registry, ®istry_listener_, wnd); - - wl_display_roundtrip(wnd->dpy); - - wnd->x = x; - wnd->y = y; - wnd->width = width; - wnd->height = height; - wnd->depth = 32; - - wnd->surface = wl_compositor_create_surface(wnd->compositor); - wnd->wnd = wl_egl_window_create(wnd->surface, wnd->width, wnd->height); - - wnd->shell_surface = wl_shell_get_shell_surface(wnd->shell, wnd->surface); - - wl_shell_surface_set_toplevel(wnd->shell_surface); - if (wnd->shell_surface) { - wl_shell_surface_add_listener(wnd->shell_surface, &shell_surface_listener_, - wnd); - } - - wl_shell_surface_set_title(wnd->shell_surface, "tpl_testtest"); - - res = true; -finish: - return res; -} - -bool -tpl_test_native_wnd_finalize( TPLNativeWnd *wnd ) -{ - bool res = false; - - TPL_CHK_PARAM( !wnd ); - TPL_CHK_PARAM( !wnd->dpy ); - - wl_egl_window_destroy(wnd->wnd); - if (wnd->shell_surface) - wl_shell_surface_destroy(wnd->shell_surface); - if (wnd->surface) - wl_surface_destroy(wnd->surface); - if (wnd->shell) - wl_shell_destroy(wnd->shell); - - if (wnd->compositor) - wl_compositor_destroy(wnd->compositor); - - wl_registry_destroy(wnd->registry); - wl_display_flush(wnd->dpy); - wl_display_disconnect(wnd->dpy); - //XCloseDisplay( (Display*)wnd->dpy ); - - res = true; -finish: - return res; -} - -bool -tpl_test_finalize( TPLNativeWnd *wnd ) -{ - bool res = true; - - TPL_CHK_PARAM( !wnd ); - - if (NULL != wnd->tpl_display) { - tpl_object_unreference((tpl_object_t *)wnd->tpl_display); - } - if (NULL != wnd->tpl_surf) { - tpl_object_unreference((tpl_object_t *)wnd->tpl_surf); - } - - res = true; -finish: - return res; -} - - -void -tpl_test_native_wnd_release( TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - - TPL_RSM_FREE( wnd ); -finish: - return; -} - -void init_option() -{ - g_option.egl_r = 8; - g_option.egl_r = 8; - g_option.egl_g = 8; - g_option.egl_b = 8; - g_option.egl_a = 8; - g_option.egl_d = 24; - g_option.egl_s = 0; - g_option.egl_preserved = 0; - g_option.egl_swap_interval = 1; - g_option.wnd_x = 0; - g_option.wnd_y = 0; - g_option.wnd_w = 1920; - g_option.wnd_h = 1080; - g_option.frames = 10000; - g_option.tc_num = 0; - g_option.fps = 300; - g_option.all = true; - g_option.show_names = false; -} -static void -print_usage( char *name ) -{ - fprintf( stderr, "\n" ); - fprintf( stderr, "Usage: %s [OPTION]...\n", name ); - fprintf( stderr, "\n" ); - fprintf( stderr, "TPL test program for the libtpl-egl\n"); - fprintf( stderr, " Build: " BLD_HOST_NAME " %s %s\n", __DATE__, __TIME__ ); - fprintf( stderr, "\n" ); - fprintf( stderr, "Options:\n" ); - - fprintf( stderr, " -w Set width size of the window default: %d\n", - g_option.wnd_w ); - fprintf( stderr, " -h Set height size of the window default: %d\n", - g_option.wnd_h ); - - fprintf( stderr, " -t Specify the test case number default: %d\n", - g_option.tc_num ); - fprintf( stderr, " -a Run all test cases default: %s\n", - g_option.all ? "true" : "false" ); - fprintf( stderr, " -l Show TC name default: %s\n", - g_option.show_names ? "true" : "false" ); - fprintf( stderr, "\n" ); - exit( 1 ); -} - -static void -check_option( int argc, char **argv ) -{ - int c; - char *opt_str = NULL; - - while ( (c = getopt(argc, argv, "alc:d:s:p:x:y:w:h:f:t:F:i:")) != EOF ) { - switch ( c ) { - case 'c': - opt_str = optarg; - if ( strcmp(opt_str, "888") == 0 ) { - g_option.egl_r = 8; - g_option.egl_g = 8; - g_option.egl_b = 8; - g_option.egl_a = 0; - } else if ( strcmp(opt_str, "8888") == 0 ) { - g_option.egl_r = 8; - g_option.egl_g = 8; - g_option.egl_b = 8; - g_option.egl_a = 8; - } else if ( strcmp(opt_str, "565") == 0 ) { - g_option.egl_r = 5; - g_option.egl_g = 6; - g_option.egl_b = 5; - g_option.egl_a = 0; - } - break; - case 'd': - g_option.egl_d = atol( optarg ); - break; - case 's': - g_option.egl_s = atol( optarg ); - break; - case 'p': - g_option.egl_preserved = atol( optarg ); - break; - case 'i': - g_option.egl_swap_interval = atol( optarg ); - break; - case 'x': - g_option.wnd_x = atol( optarg ); - break; - case 'y': - g_option.wnd_y = atol( optarg ); - break; - case 'w': - g_option.wnd_w = atol( optarg ); - break; - case 'h': - g_option.wnd_h = atol( optarg ); - break; - case 'f': - g_option.frames = atol( optarg ); - break; - case 't': - g_option.tc_num = atol( optarg ); - g_option.all = false; - break; - case 'F': - g_option.fps = atol( optarg ); - break; - case 'a': - g_option.all = true; - break; - case 'l': - g_option.show_names = true; - break; - default: - print_usage( argv[0] ); - break; - } - } - -} - -int tpl_test_log_level = 5; - -int -main( int argc, char **argv ) -{ - TPLNativeWnd *wnd = NULL; - bool res = false; - int i = 0; - int k = 0; - int total_num_test = ( sizeof(tpl_test) / sizeof(TPLTest) ) - 1; - int tc_num = 0; - char *log_env; - char *env; - - init_option(); - check_option( argc, argv ); - - log_env = getenv("TPL_TEST_LOG_LEVEL"); - if (log_env != NULL) { - tpl_test_log_level = atoi(log_env); - } - - LOG("INFO", LOG_LEVEL_LOW, "tpl_test_log_level = %d", tpl_test_log_level); - - env = getenv("TEST_SLEEP"); - if (env && !strcmp(env, "yes")) { - while (k < 20) { - usleep(1000 * 1000); - printf("sleep %d\n", k++); - } - } - - if ( g_option.show_names ) { - printf( "-------------------------------------------------\n" ); - printf( " number of test cass: %d \n", total_num_test ); - printf( "-------------------------------------------------\n" ); - while ( tpl_test[i].name ) { - printf( " [%2d] %s\n", i, tpl_test[i].name ); - i++; - } - printf( "-------------------------------------------------\n" ); - - goto finish; - } - - wnd = tpl_test_native_wnd_create(); - if ( !wnd ) goto finish; - - res = tpl_test_native_wnd_initialize( wnd, - g_option.wnd_x, - g_option.wnd_y, - g_option.wnd_w, - g_option.wnd_h ); - if ( !res ) goto finish; - - printf( "-------------------tpl test begin!!!-----------------------------------\n"); - - if ( g_option.all ) { - i = 0; - - while ( tpl_test[i].name ) { - printf( "[%4d] %-50s", i, tpl_test[i].name ); - - if ( tpl_test[i].run ) { - if (true == tpl_test[i].run( wnd )) - printf("[PASS]\n"); - else - printf("[FAIL]\n"); - } - i++; - } - } else { - tc_num = g_option.tc_num; - - if ( tc_num < 0 || tc_num > total_num_test - 1 ) goto finish; - - //printf( "----------------------------------------------\n\n" ); - if ( tpl_test[tc_num].name ) printf( "[%4d] %-50s", tc_num, - tpl_test[tc_num].name ); - else printf( "[%4d] No test name\n", tc_num ); - - if ( tpl_test[tc_num].run ) { - if (true == tpl_test[tc_num].run( wnd )) - printf("[PASS]\n"); - else - printf("[FAIL]\n"); - } - //printf( "\n----------------------------------------------\n\n" ); - } - - printf("-------------------tpl test end!!!-------------------------------------\n"); - -finish: - if ( wnd ) { - tpl_test_native_wnd_finalize( wnd ); - tpl_test_native_wnd_release( wnd ); - tpl_test_finalize( wnd ); - } - - - return 0; -} - diff --git a/tc/src/tpl_test_buffer.c b/tc/src/tpl_test_buffer.c deleted file mode 100644 index aa6d1ea..0000000 --- a/tc/src/tpl_test_buffer.c +++ /dev/null @@ -1,461 +0,0 @@ -#ifndef __TPL_BUF_TEST__ -#define __TPL_BUF_TEST__ - -#include "tpl_test_util.h" - - -bool tpl_buffer_map_unmap_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(wnd->tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //5.buffer map - void *ptr = NULL; - //int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth; - int size = wnd->width * wnd->height ; - LOG("INFO", LOG_LEVEL_LOW , "width=%d,height=%d,size=%d\n", wnd->width , - wnd->height , size); - ptr = tpl_buffer_map(wnd->tpl_buf, size); - if (ptr == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map"); - ret = false; - goto finish; - } - - //5.buffer unmap - tpl_buffer_unmap(wnd->tpl_buf, ptr, size); - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - -bool tpl_buffer_lock_unlock_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(wnd->tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //5.buffer lock - tpl_bool_t result = false; - result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_GPU_READ); - if (result == true) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock"); - ret = false; - goto finish; - } - tpl_buffer_unlock(wnd->tpl_buf); - - //TPL_LOCK_USAGE_GPU_WRITE - result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_GPU_WRITE); - if (result == true) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock"); - ret = false; - goto finish; - } - tpl_buffer_unlock(wnd->tpl_buf); - - //TPL_LOCK_USAGE_CPU_READ - result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_CPU_READ); - if (result == true) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock"); - ret = false; - goto finish; - } - tpl_buffer_unlock(wnd->tpl_buf); - - //TPL_LOCK_USAGE_CPU_WRITE - result = tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_CPU_WRITE); - if (result == true) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock"); - ret = false; - goto finish; - } - tpl_buffer_unlock(wnd->tpl_buf); - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - - -bool tpl_buffer_get_arg_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(wnd->tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //tpl_buffer_get_key - unsigned int key = 0; - key = tpl_buffer_get_key(wnd->tpl_buf); - if (key == 0) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_key"); - ret = false; - goto finish; - } - - //tpl_buffer_get_fd - int fd = -1; - fd = tpl_buffer_get_fd(wnd->tpl_buf); - if (fd == -1) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd"); - ret = false; - goto finish; - } - - //tpl_buffer_get_age - int age = -1; - age = tpl_buffer_get_age(wnd->tpl_buf); - if (age == 0) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_age"); - ret = false; - goto finish; - } - - //tpl_buffer_get_surface - tpl_surface_t *test_surf = NULL; - test_surf = tpl_buffer_get_surface(wnd->tpl_buf); - if (test_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_surface"); - ret = false; - goto finish; - } - - //tpl_buffer_get_size - int width = 0, heigh = 0; - tpl_buffer_get_size(wnd->tpl_buf, &width, &heigh); - if ((width == 0) || (heigh == 0)) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_size"); - ret = false; - goto finish; - } - - //tpl_buffer_get_depth - int depth = 0; - depth = tpl_buffer_get_depth(wnd->tpl_buf); - if (depth == 0) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_depth"); - ret = false; - goto finish; - } - //tpl_buffer_get_pitch - int pitch = 0; - pitch = tpl_buffer_get_fd(wnd->tpl_buf); - if (pitch == 0) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd"); - ret = false; - goto finish; - } - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - - -bool tpl_buffer_create_native_buffer_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(wnd->tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //create native buffer - void *native_buffer = NULL; - native_buffer = tpl_buffer_create_native_buffer(wnd->tpl_buf); - if (native_buffer == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_create_native_buffer"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - -bool tpl_buffer_abnormal_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(wnd->tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //abnormal test - - tpl_buffer_lock(wnd->tpl_buf, TPL_LOCK_USAGE_INVALID); - int test_width = 0, test_heigh = 0; - tpl_buffer_map(NULL, 0); - tpl_buffer_unmap(NULL, NULL, 0); - tpl_buffer_lock(NULL, TPL_LOCK_USAGE_INVALID); - tpl_buffer_unlock(NULL); - tpl_buffer_get_key(NULL); - tpl_buffer_get_fd(NULL); - tpl_buffer_get_age(NULL); - tpl_buffer_get_surface(NULL); - tpl_buffer_get_size(NULL, &test_width, &test_heigh); - tpl_buffer_get_depth(NULL); - tpl_buffer_get_pitch(NULL); - tpl_buffer_create_native_buffer(NULL); - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - - -bool tpl_buffer_stress_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - int index = 0; - int size = 0; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display _get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - tpl_buffer_t *buf_array[STRESS_NUM] = {0}; - for (index = 0; index < STRESS_NUM; index++) { - tpl_surface_begin_frame(wnd->tpl_surf); - buf_array[index] = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (buf_array[index] == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - void *ptr = NULL; - size = wnd->width * wnd->height ; - ptr = tpl_buffer_map(buf_array[index], size); - if (ptr == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map"); - ret = false; - goto finish; - } - //6.write - int *p = NULL; - int j = 0; - for (j = 0; j < size; j++) { - p = (int *) ptr; - if (index % 2 == 0) - *(p + j) = 0xFF00; - else - *(p + j) = 0x00FF; - } - - tpl_surface_end_frame(wnd->tpl_surf); - - tpl_surface_post(wnd->tpl_surf); - usleep(500 * 1000); //0.5s - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - -#endif - - diff --git a/tc/src/tpl_test_display.c b/tc/src/tpl_test_display.c deleted file mode 100644 index 4a3e45e..0000000 --- a/tc/src/tpl_test_display.c +++ /dev/null @@ -1,268 +0,0 @@ -#ifndef __TPL_DISPLAY_TEST__ -#define __TPL_DISPLAY_TEST__ - -#include "tpl_test_util.h" - - -bool tpl_display_get_test (TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - -bool tpl_display_bind_client_display_test(TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---", __func__); - bool ret = true; - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - // bind display handle - tpl_bool_t result = false; - result = tpl_display_bind_client_display_handle(wnd->tpl_display, - (tpl_handle_t)wnd->dpy); - if (result == false) { - LOG("ERRO", LOG_LEVEL_HIGH , " failed:tpl_display_bind_client_display_handle"); - ret = false; - goto finish; - } - - // unbind display handle - result = false; - result = tpl_display_unbind_client_display_handle(wnd->tpl_display, - (tpl_handle_t)wnd->dpy); - if (result == false) { - LOG("ERRO", LOG_LEVEL_HIGH , - " failed:tpl_display_unbind_client_display_handle"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - -bool tpl_display_get_arg_test (TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //tpl_display_get_backend_type - tpl_backend_type_t backend_type = tpl_display_get_backend_type( - wnd->tpl_display); - if (backend_type != TPL_BACKEND_WAYLAND) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_backend_type"); - ret = false; - goto finish; - } - - //tpl_display_get_native_handle - tpl_handle_t test_handle = NULL; - test_handle = tpl_display_get_native_handle(wnd->tpl_display); - if (test_handle == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_native_handle"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - -bool tpl_display_query_config_test (TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - //query config - tpl_bool_t result = false; - result = tpl_display_query_config(wnd->tpl_display, - TPL_SURFACE_TYPE_WINDOW, - 8, - 8, - 8, - 8, - 32, - NULL, - NULL); - if (result == false ) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config"); - ret = false; - goto finish; - } - - result = tpl_display_query_config(wnd->tpl_display, - TPL_SURFACE_TYPE_WINDOW, - 8, - 8, - 8, - 8, - 24, - NULL, - NULL); - if (result == false ) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config"); - ret = false; - goto finish; - } - - result = tpl_display_query_config(wnd->tpl_display, - TPL_SURFACE_TYPE_WINDOW, - 0, - 8, - 8, - 8, - 24, - NULL, - NULL); - if (result != false ) { //unmatched case - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - -bool tpl_display_filter_config_test (TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //filt config - tpl_bool_t result = false; - int test_visual_id = GBM_FORMAT_ARGB8888; - result = tpl_display_filter_config(wnd->tpl_display, &test_visual_id, 0); - if (result == false ) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config"); - ret = false; - goto finish; - } - - //filt config, unmatched case - result = tpl_display_filter_config(wnd->tpl_display, &test_visual_id, 8); - if (result != false ) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config"); - ret = false; - goto finish; - } - test_visual_id = GBM_FORMAT_XRGB8888; - result = tpl_display_filter_config(wnd->tpl_display, &test_visual_id, 0); - if (result != false ) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config"); - ret = false; - goto finish; - } - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - -bool tpl_display_abnormal_test (TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //abnormal test - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, NULL); - if (wnd->tpl_display != NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:tpl_display_get"); - ret = false; - goto finish; - } - - - //abnormal test - tpl_display_bind_client_display_handle(NULL, NULL); - tpl_display_unbind_client_display_handle(NULL, NULL); - tpl_display_get_backend_type(NULL); - tpl_display_get_native_handle(NULL); - tpl_display_filter_config(NULL, NULL, 0); - tpl_display_query_config(NULL, TPL_SURFACE_TYPE_PIXMAP, 0, 8, 8, 8, 24, NULL, - NULL); - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - -#endif - diff --git a/tc/src/tpl_test_object.c b/tc/src/tpl_test_object.c deleted file mode 100644 index 527099d..0000000 --- a/tc/src/tpl_test_object.c +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef __TPL_OBJECT_TEST__ -#define __TPL_OBJECT_TEST__ - -#include "tpl_test_util.h" - - -bool tpl_object_get_type_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(wnd->tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //tpl_object_get_type:DISPLAY - int obj_type = -1; - obj_type = tpl_object_get_type((tpl_object_t *)wnd->tpl_display); - if (obj_type != TPL_OBJECT_DISPLAY) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type"); - ret = false; - goto finish; - } - - //tpl_object_get_type:SURFACE - obj_type = -1; - obj_type = tpl_object_get_type((tpl_object_t *)wnd->tpl_surf); - if (obj_type != TPL_OBJECT_SURFACE) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - - -bool tpl_object_userdata_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2. set userdate - tpl_object_set_user_data((tpl_object_t *)wnd->tpl_display, (void *)wnd->dpy, - NULL); - - //3.get userdate - void *get_dpy = NULL; - get_dpy = (void *)tpl_object_get_user_data((tpl_object_t *)wnd->tpl_display); - if (get_dpy == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_user_data"); - ret = false; - goto finish; - } - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - -bool tpl_object_reference_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2. tpl_object_reference - tpl_object_reference((tpl_object_t *)wnd->tpl_display); - - //3.tpl_object_get_reference - int ref_count = -1; - ref_count = tpl_object_get_reference((tpl_object_t *)wnd->tpl_display); - if (ref_count == -1) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_reference"); - ret = false; - goto finish; - } - - //4.tpl_object_unreference - int unref_count = -1; - unref_count = tpl_object_unreference((tpl_object_t *)wnd->tpl_display); - if (unref_count != ref_count - 1) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_unreference"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - -bool tpl_object_abnormal_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - - //abnormal test - tpl_object_get_type(NULL); - tpl_object_set_user_data(NULL, NULL, NULL); - tpl_object_get_user_data(NULL); - tpl_object_reference(NULL); - tpl_object_get_reference(NULL); - tpl_object_unreference(NULL); - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - - - - -#endif - - diff --git a/tc/src/tpl_test_surface.c b/tc/src/tpl_test_surface.c deleted file mode 100644 index 1752b83..0000000 --- a/tc/src/tpl_test_surface.c +++ /dev/null @@ -1,425 +0,0 @@ -#ifndef __TPL_SURF_TEST__ -#define __TPL_SURF_TEST__ - -#include "tpl_test_util.h" - - -bool tpl_surface_create_test(TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - //1.tpl_display_get - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - //2.tpl_surface_create - tpl_surface_t *tpl_surf = NULL; - tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - -bool tpl_surface_get_arg_test(TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - //1.tpl_display_get - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - //2.tpl_surface_create - tpl_surface_t *tpl_surf = NULL; - tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //tpl_surface_get_display test - tpl_display_t *test_dpy = tpl_surface_get_display(tpl_surf); - if (test_dpy == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_display"); - ret = false; - goto finish; - } - //tpl_surface_get_native_handle - tpl_handle_t test_handle = tpl_surface_get_native_handle(tpl_surf); - if (test_handle == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_native_handle"); - ret = false; - goto finish; - } - //tpl_surface_get_type test - tpl_surface_type_t test_type = tpl_surface_get_type(tpl_surf); - if (test_type != TPL_SURFACE_TYPE_WINDOW) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_type"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - -bool tpl_surface_frame_test(TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_display = NULL; - //1.tpl_display_get - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - //2.tpl_surface_create - tpl_surface_t *tpl_surf = NULL; - tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(tpl_surf); - - //4.tpl_surface_validate_frame - tpl_bool_t isvalid = tpl_surface_validate_frame(tpl_surf); - - //5. end frame - tpl_surface_end_frame(tpl_surf); - - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - - return ret; -} - - -bool tpl_surface_get_buffer_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - tpl_surface_t *tpl_surf = NULL; - tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //4.get buffer reset - tpl_buffer_t *tpl_buf_r = NULL; - tpl_bool_t reset; - tpl_buf_r = tpl_surface_get_buffer(tpl_surf, &reset); - if (tpl_buf_r == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - - - - -bool tpl_surface_post_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - tpl_surface_t *tpl_surf = NULL; - tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - //5.buffer map - void *ptr = NULL; - //int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth; - int size = wnd->width * wnd->height ; - LOG("INFO", LOG_LEVEL_LOW , "width=%d,height=%d,size=%d", wnd->width , - wnd->height , size); - ptr = tpl_buffer_map(wnd->tpl_buf, size); - if (ptr == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map"); - ret = false; - goto finish; - } - - //6.write - int *p = NULL; - int j = 0; - for (j = 0; j < size; j++) { - p = (int *) ptr; - *(p + j) = 0xFF00; - } - LOG("INFO", LOG_LEVEL_LOW , "succ:write completed!"); - - //7.end frame - tpl_surface_end_frame(tpl_surf); - - //8.set post interval - int interval_set = 2; - tpl_surface_set_post_interval(tpl_surf, interval_set); - - //9. get post interval; - int interval_get = tpl_surface_get_post_interval(tpl_surf); - - if (interval_get != interval_set) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_post_interval"); - ret = false; - goto finish; - } - - //10.post - tpl_surface_post(tpl_surf); - - LOG("INFO", LOG_LEVEL_LOW , "After posted!!!"); - - int k = 1; - while (k <= 10) { - usleep(1000 * 1000); - LOG("INFO", LOG_LEVEL_LOW , "sleep %d ...", k); - //printf("%d ",k); - k++; - } - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; - - -} - - -bool tpl_surface_abnormal_test(TPLNativeWnd *wnd) -{ - TPL_CHK_PARAM( !wnd ); - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - bool ret = true; - wnd->tpl_surf = NULL; - - //1.tpl_display_get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //abnormal test - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(NULL, NULL, TPL_SURFACE_TYPE_WINDOW, - TPL_FORMAT_ARGB8888); - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, 10, - TPL_FORMAT_ARGB8888); - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_INVALID); - /* if(tpl_surf != NULL) - { - LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:%s",__func__); - ret = false; - goto finish; - } - */ - //abnormal test - int width = 0, height = 0; - tpl_surface_get_display(NULL); - tpl_surface_get_native_handle(NULL); - tpl_surface_get_type(NULL); - tpl_surface_get_size(NULL, &width, &height); - tpl_surface_get_buffer(NULL, NULL); - tpl_surface_set_post_interval(NULL, 2); - tpl_surface_get_post_interval(NULL); - tpl_surface_post(NULL); - tpl_surface_begin_frame(NULL); - tpl_surface_validate_frame(NULL); - tpl_surface_end_frame(NULL); - -finish: - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - return ret; -} - - - -bool tpl_surface_stress_test(TPLNativeWnd *wnd ) -{ - TPL_CHK_PARAM( !wnd ); - bool ret = true; - int index = 0; - LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------", __func__); - - //1.tpl_display _get - wnd->tpl_display = NULL; - wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy); - if (wnd->tpl_display == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get"); - ret = false; - goto finish; - } - - //2.tpl_surface_create - wnd->tpl_surf = NULL; - wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, - TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - //3.begin frame - tpl_surface_begin_frame(wnd->tpl_surf); - - //4.get buffer - wnd->tpl_buf = NULL; - wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (wnd->tpl_buf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - - tpl_buffer_t *surf_array[STRESS_NUM] = {0}; - tpl_buffer_t *buf_array[STRESS_NUM] = {0}; - for (index = 0; index < STRESS_NUM; index++) { - surf_array[index] = tpl_surface_create(wnd->tpl_display , - (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888); - if (wnd->tpl_surf == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create"); - ret = false; - goto finish; - } - - buf_array[index] = tpl_surface_get_buffer(wnd->tpl_surf, NULL); - if (buf_array[index] == NULL) { - LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer"); - ret = false; - goto finish; - } - } - - -finish: - for (index = 0; index < STRESS_NUM; index++) { - if (surf_array[index] != NULL) { - tpl_object_unreference((tpl_object_t *)surf_array[index]); - surf_array[index] = NULL; - } - - } - if (true == ret) - LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s", __func__); - else - LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s", __func__); - - return ret; - -} - -#endif - - diff --git a/tc/src/tpl_test_util.h b/tc/src/tpl_test_util.h deleted file mode 100644 index 763db7c..0000000 --- a/tc/src/tpl_test_util.h +++ /dev/null @@ -1,317 +0,0 @@ -#ifndef __TPL_UTIL__ -#define __TPL_UTIL__ - -#include -#include -#include -#include -//#include -//#include -//#include -//#include -#include -#include -#include -#include - - -//for tpl test: -#include -//#include - -#define STRESS_NUM 100 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _TPLNativeWnd TPLNativeWnd; - - -struct _TPLNativeWnd { - void *dpy; - struct wl_registry *registry; - struct wl_compositor *compositor; - struct wl_shell *shell; - int screen; - - void *root; - void *wnd; - struct wl_surface *surface; - struct wl_shell_surface *shell_surface; - int x; - int y; - int width; - int height; - int depth; - tpl_display_t *tpl_display; - tpl_surface_t *tpl_surf; - tpl_buffer_t *tpl_buf; -}; - -typedef struct _TPLTest TPLTest; - -struct _TPLTest { - char *name; - bool (*run) (TPLNativeWnd *); -}; - -extern int tpl_test_log_level; -#define minLevel tpl_test_log_level -#define LOG_LEVEL_LOW 1 -#define LOG_LEVEL_MID 2 -#define LOG_LEVEL_HIGH 3 - -#define LOG(type,level, format, ...) \ - do { \ - if(level>=minLevel) fprintf(stderr, "[%s|%22s:%3d] " format "\n", \ - type, __FILE__, __LINE__, ##__VA_ARGS__ ); \ - } while (0) - -#define LONGLOG(type,level, format, ...) \ - do { \ - if(level>=minLevel) fprintf(stderr, "[%s|%s@%s:%d] " format "\n", \ - type, __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \ - } while (0) - - - - -/* for tpl test */ -bool tpl_buffer_map_unmap_test(TPLNativeWnd *wnd ); -bool tpl_buffer_lock_unlock_test(TPLNativeWnd *wnd ); -bool tpl_buffer_get_arg_test(TPLNativeWnd *wnd ); -bool tpl_buffer_create_native_buffer_test(TPLNativeWnd *wnd ); - -bool tpl_display_get_test (TPLNativeWnd *wnd); -bool tpl_display_bind_client_display_test(TPLNativeWnd *wnd); -bool tpl_display_get_arg_test (TPLNativeWnd *wnd); -bool tpl_display_query_config_test (TPLNativeWnd *wnd); -bool tpl_display_filter_config_test (TPLNativeWnd *wnd); - -bool tpl_object_get_type_test(TPLNativeWnd *wnd ); -bool tpl_object_userdata_test(TPLNativeWnd *wnd ); -bool tpl_object_reference_test(TPLNativeWnd *wnd ); - -bool tpl_surface_create_test(TPLNativeWnd *wnd); -bool tpl_surface_get_arg_test(TPLNativeWnd *wnd); -bool tpl_surface_frame_test(TPLNativeWnd *wnd); -bool tpl_surface_get_buffer_test(TPLNativeWnd *wnd ); -bool tpl_surface_post_test(TPLNativeWnd *wnd ); - -bool tpl_surface_abnormal_test(TPLNativeWnd *wnd); -bool tpl_object_abnormal_test(TPLNativeWnd *wnd); -bool tpl_display_abnormal_test(TPLNativeWnd *wnd); -bool tpl_buffer_abnormal_test(TPLNativeWnd *wnd); - -bool tpl_surface_stress_test(TPLNativeWnd *wnd ); -bool tpl_buffer_stress_test(TPLNativeWnd *wnd ); - -static TPLTest tpl_test[] = { - { "Check TPL buffer map and unmap", tpl_buffer_map_unmap_test }, - { "Check TPL buffer lock and unlock", tpl_buffer_lock_unlock_test }, - { "Check TPL buffer get args", tpl_buffer_get_arg_test }, - { "TPL buffer create native buffer test", tpl_buffer_create_native_buffer_test }, - { "TPL buffer stress test", tpl_buffer_stress_test }, - - { "TPL display get test", tpl_display_get_test }, - //{ "Check TPL display bind client display",tpl_display_bind_client_display_test },/*5*/ - { "Check TPL display get args", tpl_display_get_arg_test }, - { "TPL display query config test", tpl_display_query_config_test }, - { "TPL display filter config test", tpl_display_filter_config_test }, - - { "Check TPL object get types", tpl_object_get_type_test }, - { "Check TPL object set and get userdate", tpl_object_userdata_test }, - { "Check TPL object reference and unreference", tpl_object_reference_test }, - - { "Check TPL surface create", tpl_surface_create_test }, - { "Check TPL surface get args", tpl_surface_get_arg_test }, - { "Check TPL surface frame operation" , tpl_surface_frame_test }, - { "TPL surface get buffer test", tpl_surface_get_buffer_test }, /*15*/ - { "TPL surface post test", tpl_surface_post_test }, - { "TPL surface stress test", tpl_surface_stress_test }, - /* - { "TPL surface abnormal test",tpl_surface_abnormal_test }, - { "TPL object abnormal test",tpl_object_abnormal_test }, - { "TPL display abnormal test",tpl_display_abnormal_test }, - { "TPL buffer abnormal test",tpl_buffer_abnormal_test }, - */ - { NULL, NULL } - -}; - -#define TPL_RESOURCE_BIN_SHADER_VTX_01 "data/01_vtx.bin" -#define TPL_RESOURCE_BIN_SHADER_FRAG_01 "data/01_frag.bin" -#define TPL_RESOURCE_BIN_PROGRAM_01 "data/01_program.bin" -#define TPL_RESOURCE_TGA_UNCOMP_FILE_01 "data/sample_01_uncomp.tga" -#define TPL_RESOURCE_TGA_COMP_FILE_02 "data/sample_02_comp.tga" - - -/*----------------------------------------------------------------- - * time - *-----------------------------------------------------------------*/ -#define HAVE_MONOTONIC_CLOCK 1 -#define __SEC_TO_USEC( sec ) ((sec) * 1000000) -#define __USEC_TO_SEC( usec ) ((float)(usec) * 1.0e-6f) -#define __MSEC_TO_SEC( usec ) ((float)(usec) * 1.0e-3f) -long int tpl_test_util_get_systime( void ); -void tpl_test_util_init_fps( long int *s_time ); -float tpl_test_util_get_fps( long int s_time, int frame ); - -/*----------------------------------------------------------------- - * performance measurement - *-----------------------------------------------------------------*/ -#define TPL_MEASURE_PERF 1 - -#if TPL_MEASURE_PERF -# include - -typedef struct _GfxUtilTimer GfxUtilTimer; - -#define USE_GETTIME 1 -struct _GfxUtilTimer { - bool is_begin; - bool is_measured; - char func[1024]; - int line; - char msg[1024]; -#if USE_GETTIME - long int begin_t; - long int end_t; -#else - clock_t begin_tiks; - clock_t end_tiks; - struct tms begin_buf; - struct tms end_buf; -#endif -}; - -# define __TPL_TIMER_GLOBAL_BEGIN( timer, msg ) \ - tpl_test_util_timer_begin( timer, __func__, __LINE__, msg ); -# define __TPL_TIMER_GLOBAL_END( timer, msg ) \ - tpl_test_util_timer_end( timer, __func__, __LINE__, msg ); - -# define __TPL_TIMER_BEGIN( msg ) \ - GfxUtilTimer __timer = { false, 0, 0 }; \ - tpl_test_util_timer_begin( &__timer, __func__, __LINE__, msg ); -# define __TPL_TIMER_END( msg ) \ - tpl_test_util_timer_end( &__timer, __func__, __LINE__, msg ); - -void tpl_test_util_timer_list_display( void ); -void tpl_test_util_timer_release( GfxUtilTimer *timer ); -GfxUtilTimer *tpl_test_util_timer_copy( GfxUtilTimer *src, const char *func, - int line, const char *msg ); -void tpl_test_util_timer_list_clear( void ); -void tpl_test_util_timer_begin( GfxUtilTimer *timer, const char *func, - int line, const char *msg ); -void tpl_test_util_timer_end( GfxUtilTimer *timer, const char *func, int line, - const char *msg ); -#else -# define __TPL_TIMER_GLOBAL_BEGIN( ... ) { ; } -# define __TPL_TIMER_GLOBAL_END( ... ) { ; } -# define __TPL_TIMER_BEGIN( ... ) { ; } -# define __TPL_TIMER_END( ... ) { ; } -# define tpl_test_util_timer_list_display( ... ) { ; } -# define tpl_test_util_timer_list_clear( ... ) { ; } -#endif - - -/*----------------------------------------------------------------- - * log - *-----------------------------------------------------------------*/ - -#define TPL_ENABLE_LOG 1 - - - - -#define NUM_ERR_STR 512 /* length of the error logging string */ -#define DEFAULT_LOG_STREAM stderr - -#define __log_err(fmt, args...) __LOG_ERR(__func__, __LINE__, fmt, ##args) -bool __LOG_ERR( const char *func, int line, const char *fmt, ... ); -bool __tpl_test_log_display_msg( const char *msg ); - - - -#if TPL_ENABLE_LOG -# define __log(fmt, args...) __LOG(__func__, __LINE__, fmt, ##args) -# define __log_begin( ... ) __LOG_BEGIN(__func__); -# define __log_end( ... ) __LOG_END(__func__); -bool __LOG( const char *func, int line, const char *fmt, ... ); -void __LOG_BEGIN( const char *func ); -void __LOG_END( const char *func ); -#else -# define __log( ... ) { ; } -# define __log_begin( ... ) { ; } -# define __log_end( ... ) { ; } -# define __LOG( ... ) { ; } -# define __LOG_BEGIN( ... ) { ; } -# define __LOG_END( ... ) { ; } -#endif - - -/*----------------------------------------------------------------- - * validation - *-----------------------------------------------------------------*/ -#define TPL_RSM_MALLOC( obj, type ) \ - { \ - obj = (type*)malloc( sizeof(type) ); \ - if( !obj ) \ - { \ - __log_err( "failed to allocate memory" ); \ - goto finish; \ - } \ - } - -#define TPL_RSM_FREE( obj ) \ - { \ - free( obj ); \ - } - -#define TPL_RSM_MEMCPY( dst, src, type, num ) \ - { \ - memcpy( dst, src, sizeof(type) * num ); \ - } - -#define TPL_CHK_PARAM( exp ) \ - { \ - if( exp ) \ - { \ - __log_err( "invalid input parameter. '"#exp"' is true" ); \ - goto finish; \ - } \ - } - -/*----------------------------------------------------------------- - * math and misc - *-----------------------------------------------------------------*/ -#define PI 3.1415926535897932384626433832795f - -#define FLOAT_TO_FIXED(x) (long)((x)*65536.0f) - -typedef struct _GfxMatrix GfxMatrix_t; - -struct _GfxMatrix { - //GLfloat m[4][4]; -}; - -typedef enum { - TPL_TEX_COLOR_BLACK, - TPL_TEX_COLOR_WHITE, - TPL_TEX_COLOR_GREY, - TPL_TEX_COLOR_RED, - TPL_TEX_COLOR_GREEN, - TPL_TEX_COLOR_BLUE, - TPL_TEX_COLOR_RGB, - TPL_TEX_COLOR_RGB2, - TPL_TEX_COLOR_RGBA_TRANSLUCENCE, - TPL_TEX_COLOR_RGBA_4444, - TPL_TEX_COLOR_RGBA_5551, -} GfxTexColor; - -#ifdef __cplusplus -} -#endif - -#endif /* __TPL_UTIL__ */ diff --git a/tc/tpl-test.manifest b/tc/tpl-test.manifest deleted file mode 100644 index 97e8c31..0000000 --- a/tc/tpl-test.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - -- 2.7.4