zink/query: refactor get_query_result to map upfront.
This maps upfront and processes the results in a clearer way. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15702>
This commit is contained in:
parent
f090cac54a
commit
7f3a959d2f
|
@ -435,60 +435,49 @@ get_query_result(struct pipe_context *pctx,
|
||||||
|
|
||||||
int num_results = query->curr_query - query->last_start;
|
int num_results = query->curr_query - query->last_start;
|
||||||
int result_size = get_num_results(query->type) * sizeof(uint64_t);
|
int result_size = get_num_results(query->type) * sizeof(uint64_t);
|
||||||
|
int num_maps = get_num_queries(query->type);
|
||||||
|
|
||||||
struct zink_query_buffer *qbo;
|
struct zink_query_buffer *qbo;
|
||||||
struct pipe_transfer *xfer;
|
struct pipe_transfer *xfer[PIPE_MAX_VERTEX_STREAMS] = { 0 };
|
||||||
LIST_FOR_EACH_ENTRY(qbo, &query->buffers, list) {
|
LIST_FOR_EACH_ENTRY(qbo, &query->buffers, list) {
|
||||||
uint64_t *xfb_results = NULL;
|
uint64_t *results[PIPE_MAX_VERTEX_STREAMS];
|
||||||
uint64_t *results;
|
|
||||||
bool is_timestamp = query->type == PIPE_QUERY_TIMESTAMP || query->type == PIPE_QUERY_TIMESTAMP_DISJOINT;
|
bool is_timestamp = query->type == PIPE_QUERY_TIMESTAMP || query->type == PIPE_QUERY_TIMESTAMP_DISJOINT;
|
||||||
if (!qbo->num_results)
|
if (!qbo->num_results)
|
||||||
continue;
|
continue;
|
||||||
results = pipe_buffer_map_range(pctx, qbo->buffers[0], 0,
|
|
||||||
(is_timestamp ? 1 : qbo->num_results) * result_size, flags, &xfer);
|
for (unsigned i = 0; i < num_maps; i++) {
|
||||||
if (!results) {
|
results[i] = pipe_buffer_map_range(pctx, qbo->buffers[i], 0,
|
||||||
if (wait)
|
(is_timestamp ? 1 : qbo->num_results) * result_size, flags, &xfer[i]);
|
||||||
debug_printf("zink: qbo read failed!");
|
if (!results[i]) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
struct pipe_transfer *xfb_xfer = NULL;
|
|
||||||
if (query->type == PIPE_QUERY_PRIMITIVES_GENERATED) {
|
|
||||||
xfb_results = pipe_buffer_map_range(pctx, qbo->buffers[1], 0,
|
|
||||||
qbo->num_results * result_size, flags, &xfb_xfer);
|
|
||||||
if (!xfb_results) {
|
|
||||||
if (wait)
|
if (wait)
|
||||||
debug_printf("zink: xfb qbo read failed!");
|
debug_printf("zink: qbo read failed!");
|
||||||
pipe_buffer_unmap(pctx, xfer);
|
goto fail;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check_query_results(query, result, is_timestamp ? 1 : qbo->num_results, results, xfb_results);
|
|
||||||
pipe_buffer_unmap(pctx, xfer);
|
|
||||||
if (xfb_xfer)
|
|
||||||
pipe_buffer_unmap(pctx, xfb_xfer);
|
|
||||||
if (query->type == PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE) {
|
if (query->type == PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE) {
|
||||||
for (unsigned i = 1; i < ARRAY_SIZE(qbo->buffers) && !result->b; i++) {
|
for (unsigned i = 0; i < PIPE_MAX_VERTEX_STREAMS && !result->b; i++) {
|
||||||
uint64_t *results = pipe_buffer_map_range(pctx, qbo->buffers[i],
|
check_query_results(query, result, num_results, results[i], NULL);
|
||||||
0,
|
|
||||||
qbo->num_results * result_size, flags, &xfer);
|
|
||||||
if (!results) {
|
|
||||||
if (wait)
|
|
||||||
debug_printf("zink: qbo read failed!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
check_query_results(query, result, num_results, results, xfb_results);
|
|
||||||
pipe_buffer_unmap(pctx, xfer);
|
|
||||||
}
|
}
|
||||||
/* if overflow is detected we can stop */
|
} else
|
||||||
if (result->b)
|
check_query_results(query, result, is_timestamp ? 1 : qbo->num_results, results[0], results[1]);
|
||||||
break;
|
|
||||||
}
|
for (unsigned i = 0 ; i < num_maps; i++)
|
||||||
|
pipe_buffer_unmap(pctx, xfer[i]);
|
||||||
|
|
||||||
|
/* if overflow is detected we can stop */
|
||||||
|
if (query->type == PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE && result->b)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_time_query(query))
|
if (is_time_query(query))
|
||||||
timestamp_to_nanoseconds(screen, &result->u64);
|
timestamp_to_nanoseconds(screen, &result->u64);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
fail:
|
||||||
|
for (unsigned i = 0 ; i < num_maps; i++)
|
||||||
|
if (xfer[i])
|
||||||
|
pipe_buffer_unmap(pctx, xfer[i]);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue