diff options
author | Yiwei Zhang <zzyiwei@chromium.org> | 2022-02-09 20:56:47 +0000 |
---|---|---|
committer | Yiwei Zhang <zzyiwei@chromium.org> | 2022-02-11 19:12:00 +0000 |
commit | a663e5d20a4e2b14ea3ac0a93b1cc013b751c02b (patch) | |
tree | 47974411298b60f010040ae57333dbaa3d75083d /server | |
parent | e8522be69312d99f5e5d29b6c9f3bdc330ae463d (diff) |
server: update render protocol to reflect the actual ops
This is mostly a naming change, along with more docs
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Diffstat (limited to 'server')
-rw-r--r-- | server/render_context.c | 53 | ||||
-rw-r--r-- | server/render_protocol.h | 59 |
2 files changed, 61 insertions, 51 deletions
diff --git a/server/render_context.c b/server/render_context.c index 4658588..46884ff 100644 --- a/server/render_context.c +++ b/server/render_context.c @@ -15,9 +15,9 @@ #include "render_virgl.h" static bool -render_context_import_blob(struct render_context *ctx, - const struct render_context_op_attach_resource_request *req, - int res_fd) +render_context_import_resource(struct render_context *ctx, + const struct render_context_op_import_resource_request *req, + int res_fd) { const uint32_t res_id = req->res_id; const enum virgl_resource_fd_type fd_type = req->fd_type; @@ -108,11 +108,11 @@ render_context_init_virgl_context(struct render_context *ctx, } static bool -render_context_export_blob(struct render_context *ctx, - const struct render_context_op_get_blob_request *req, - enum virgl_resource_fd_type *out_fd_type, - uint32_t *out_map_info, - int *out_res_fd) +render_context_create_resource(struct render_context *ctx, + const struct render_context_op_create_resource_request *req, + enum virgl_resource_fd_type *out_fd_type, + uint32_t *out_map_info, + int *out_res_fd) { const uint32_t res_id = req->res_id; const struct virgl_renderer_resource_create_blob_args blob_args = { @@ -144,6 +144,9 @@ render_context_export_blob(struct render_context *ctx, return false; } + /* RENDER_CONTEXT_OP_CREATE_RESOURCE implies attach and proxy will not send + * RENDER_CONTEXT_OP_IMPORT_RESOURCE to attach the resource again. + */ virgl_renderer_ctx_attach_resource(ctx->ctx_id, res_id); switch (fd_type) { @@ -223,17 +226,17 @@ render_context_dispatch_submit_cmd(struct render_context *ctx, } static bool -render_context_dispatch_get_blob(struct render_context *ctx, - const union render_context_op_request *req, - UNUSED const int *fds, - UNUSED int fd_count) +render_context_dispatch_create_resource(struct render_context *ctx, + const union render_context_op_request *req, + UNUSED const int *fds, + UNUSED int fd_count) { - struct render_context_op_get_blob_reply reply = { + struct render_context_op_create_resource_reply reply = { .fd_type = VIRGL_RESOURCE_FD_INVALID, }; int res_fd; - bool ok = render_context_export_blob(ctx, &req->get_blob, &reply.fd_type, - &reply.map_info, &res_fd); + bool ok = render_context_create_resource(ctx, &req->create_resource, &reply.fd_type, + &reply.map_info, &res_fd); if (!ok) return render_socket_send_reply(&ctx->socket, &reply, sizeof(reply)); @@ -245,17 +248,17 @@ render_context_dispatch_get_blob(struct render_context *ctx, } static bool -render_context_dispatch_detach_resource(UNUSED struct render_context *ctx, - const union render_context_op_request *req, - UNUSED const int *fds, - UNUSED int fd_count) +render_context_dispatch_destroy_resource(UNUSED struct render_context *ctx, + const union render_context_op_request *req, + UNUSED const int *fds, + UNUSED int fd_count) { - virgl_renderer_resource_unref(req->detach_resource.res_id); + virgl_renderer_resource_unref(req->destroy_resource.res_id); return true; } static bool -render_context_dispatch_attach_resource(struct render_context *ctx, +render_context_dispatch_import_resource(struct render_context *ctx, const union render_context_op_request *req, const int *fds, int fd_count) @@ -266,7 +269,7 @@ render_context_dispatch_attach_resource(struct render_context *ctx, } /* classic 3d resource with valid size reuses the blob import path here */ - return render_context_import_blob(ctx, &req->attach_resource, fds[0]); + return render_context_import_resource(ctx, &req->import_resource, fds[0]); } static bool @@ -310,9 +313,9 @@ static const struct render_context_dispatch_entry .dispatch = render_context_dispatch_##name } RENDER_CONTEXT_DISPATCH(NOP, nop, 0), RENDER_CONTEXT_DISPATCH(INIT, init, 2), - RENDER_CONTEXT_DISPATCH(ATTACH_RESOURCE, attach_resource, 1), - RENDER_CONTEXT_DISPATCH(DETACH_RESOURCE, detach_resource, 0), - RENDER_CONTEXT_DISPATCH(GET_BLOB, get_blob, 0), + RENDER_CONTEXT_DISPATCH(CREATE_RESOURCE, create_resource, 0), + RENDER_CONTEXT_DISPATCH(IMPORT_RESOURCE, import_resource, 1), + RENDER_CONTEXT_DISPATCH(DESTROY_RESOURCE, destroy_resource, 0), RENDER_CONTEXT_DISPATCH(SUBMIT_CMD, submit_cmd, 0), RENDER_CONTEXT_DISPATCH(SUBMIT_FENCE, submit_fence, 0), #undef RENDER_CONTEXT_DISPATCH diff --git a/server/render_protocol.h b/server/render_protocol.h index 92610c0..778adcf 100644 --- a/server/render_protocol.h +++ b/server/render_protocol.h @@ -36,9 +36,9 @@ enum render_client_op { enum render_context_op { RENDER_CONTEXT_OP_NOP = 0, RENDER_CONTEXT_OP_INIT, - RENDER_CONTEXT_OP_ATTACH_RESOURCE, - RENDER_CONTEXT_OP_DETACH_RESOURCE, - RENDER_CONTEXT_OP_GET_BLOB, + RENDER_CONTEXT_OP_CREATE_RESOURCE, + RENDER_CONTEXT_OP_IMPORT_RESOURCE, + RENDER_CONTEXT_OP_DESTROY_RESOURCE, RENDER_CONTEXT_OP_SUBMIT_CMD, RENDER_CONTEXT_OP_SUBMIT_FENCE, @@ -131,43 +131,50 @@ struct render_context_op_init_request { /* followed by 1 shmem fd and optionally 1 eventfd */ }; -/* Attach a resource to the context. +/* Export a blob resource from the context * - * This roughly corresponds to virgl_renderer_ctx_attach_resource. + * This roughly corresponds to: + * - virgl_renderer_resource_create_blob + * - virgl_renderer_resource_get_map_info + * - virgl_renderer_resource_export_blob + * - virgl_renderer_ctx_attach_resource */ -struct render_context_op_attach_resource_request { +struct render_context_op_create_resource_request { struct render_context_op_header header; uint32_t res_id; + uint64_t blob_id; + uint64_t blob_size; + uint32_t blob_flags; /* VIRGL_RENDERER_BLOB_FLAG_* */ +}; + +struct render_context_op_create_resource_reply { enum virgl_resource_fd_type fd_type; - uint64_t size; - /* followed by 1 fd */ + uint32_t map_info; /* VIRGL_RENDERER_MAP_* */ + /* followed by 1 fd if not VIRGL_RESOURCE_FD_INVALID */ }; -/* Detach a resource from the context. +/* Import a blob resource to the context * - * This roughly corresponds to virgl_renderer_ctx_detach_resource. + * This roughly corresponds to: + * - virgl_renderer_resource_import_blob + * - virgl_renderer_ctx_attach_resource */ -struct render_context_op_detach_resource_request { +struct render_context_op_import_resource_request { struct render_context_op_header header; uint32_t res_id; + enum virgl_resource_fd_type fd_type; + uint64_t size; + /* followed by 1 fd */ }; -/* Export a blob from the context. +/* Free a blob resource from the context * - * This roughly corresponds to virgl_renderer_resource_create_blob. + * This roughly corresponds to: + * - virgl_renderer_resource_unref */ -struct render_context_op_get_blob_request { +struct render_context_op_destroy_resource_request { struct render_context_op_header header; uint32_t res_id; - uint64_t blob_id; - uint64_t blob_size; - uint32_t blob_flags; /* VIRGL_RENDERER_BLOB_FLAG_* */ -}; - -struct render_context_op_get_blob_reply { - enum virgl_resource_fd_type fd_type; - uint32_t map_info; /* VIRGL_RENDERER_MAP_* */ - /* followed by 1 fd if not VIRGL_RESOURCE_FD_INVALID */ }; /* Submit a small command stream to the context. @@ -209,9 +216,9 @@ union render_context_op_request { struct render_context_op_header header; struct render_context_op_nop_request nop; struct render_context_op_init_request init; - struct render_context_op_attach_resource_request attach_resource; - struct render_context_op_detach_resource_request detach_resource; - struct render_context_op_get_blob_request get_blob; + struct render_context_op_create_resource_request create_resource; + struct render_context_op_import_resource_request import_resource; + struct render_context_op_destroy_resource_request destroy_resource; struct render_context_op_submit_cmd_request submit_cmd; struct render_context_op_submit_fence_request submit_fence; }; |