From 010c974bd4fe954700f6336b4c3786c06bb2ffd6 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 2 Apr 2019 12:48:33 -0700 Subject: [PATCH] vrend: handle queries more defensively Handle these two command sequences, VIRGL_CCMD_BEGIN_QUERY VIRGL_CCMD_END_QUERY VIRGL_CCMD_GET_QUERY_RESULT VIRGL_CCMD_GET_QUERY_RESULT or VIRGL_CCMD_BEGIN_QUERY VIRGL_CCMD_END_QUERY VIRGL_CCMD_GET_QUERY_RESULT (before the query result is available) VIRGL_CCMD_BEGIN_QUERY VIRGL_CCMD_END_QUERY VIRGL_CCMD_GET_QUERY_RESULT more carefully. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/vrend_renderer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 4e057a7..3b4644a 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -8232,6 +8232,8 @@ int vrend_begin_query(struct vrend_context *ctx, uint32_t handle) if (q->index > 0 && !has_feature(feat_transform_feedback3)) return EINVAL; + list_delinit(&q->waiting_queries); + if (q->gltype == GL_TIMESTAMP) return 0; @@ -8282,8 +8284,11 @@ void vrend_get_query_result(struct vrend_context *ctx, uint32_t handle, return; ret = vrend_check_query(q); - if (ret == false) + if (ret) { + list_delinit(&q->waiting_queries); + } else if (LIST_IS_EMPTY(&q->waiting_queries)) { list_addtail(&q->waiting_queries, &vrend_state.waiting_query_list); + } } #define BUFFER_OFFSET(i) ((void *)((char *)NULL + i))