vrend: use VREND_RESOURCE_STORAGE_IOVEC for PIPE_BIND_CUSTOM

PIPE_BIND_CUSTOM is used for query buffers and fences by the guest.
We can safely replace VREND_RESOURCE_STORAGE_SYSTEM by
VREND_RESOURCE_STORAGE_IOVEC.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 6 years ago committed by Gurchetan Singh
parent dbefdb7e36
commit ddcb1b90d8
  1. 26
      src/vrend_renderer.c

@ -6148,8 +6148,9 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a
pipe_reference_init(&gr->base.reference, 1); pipe_reference_init(&gr->base.reference, 1);
if (args->bind == VIRGL_BIND_CUSTOM) { if (args->bind == VIRGL_BIND_CUSTOM) {
/* custom should only be for buffers */ assert(args->target == PIPE_BUFFER);
gr->storage = VREND_RESOURCE_STORAGE_SYSTEM; /* use iovec directly when attached */
gr->storage = VREND_RESOURCE_STORAGE_IOVEC;
gr->ptr = malloc(args->width); gr->ptr = malloc(args->width);
if (!gr->ptr) { if (!gr->ptr) {
FREE(gr); FREE(gr);
@ -8118,17 +8119,24 @@ static bool vrend_get_one_query_result(GLuint query_id, bool use_64, uint64_t *r
static bool vrend_check_query(struct vrend_query *query) static bool vrend_check_query(struct vrend_query *query)
{ {
uint64_t result; struct virgl_host_query_state state;
struct virgl_host_query_state *state;
bool ret; bool ret;
ret = vrend_get_one_query_result(query->id, vrend_is_timer_query(query->gltype), &result); state.result_size = vrend_is_timer_query(query->gltype) ? 8 : 4;
ret = vrend_get_one_query_result(query->id, state.result_size == 8,
&state.result);
if (ret == false) if (ret == false)
return false; return false;
state = (struct virgl_host_query_state *)query->res->ptr; state.query_state = VIRGL_QUERY_STATE_DONE;
state->result = result;
state->query_state = VIRGL_QUERY_STATE_DONE; if (query->res->iov) {
vrend_write_to_iovec(query->res->iov, query->res->num_iovs, 0,
(const void *) &state, sizeof(state));
} else {
*((struct virgl_host_query_state *) query->res->ptr) = state;
}
return true; return true;
} }
@ -8197,7 +8205,7 @@ int vrend_create_query(struct vrend_context *ctx, uint32_t handle,
struct vrend_resource *res; struct vrend_resource *res;
uint32_t ret_handle; uint32_t ret_handle;
res = vrend_renderer_ctx_res_lookup(ctx, res_handle); res = vrend_renderer_ctx_res_lookup(ctx, res_handle);
if (!res) { if (!res || res->storage != VREND_RESOURCE_STORAGE_IOVEC) {
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return EINVAL; return EINVAL;
} }

Loading…
Cancel
Save