From cccbc3b5e427223f60a041fc70bba7cd4c688180 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 5 Mar 2015 14:19:21 +1000 Subject: [PATCH] renderer: return values from submit_cmd/decode block makes easier to write unit tests. --- src/virglrenderer.c | 8 ++++---- src/virglrenderer.h | 6 +++--- src/vrend_decode.c | 16 +++++++++------- src/vrend_renderer.c | 2 +- src/vrend_renderer.h | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index 739efa7..c20633e 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -72,11 +72,11 @@ void virgl_renderer_context_destroy(uint32_t handle) vrend_renderer_context_destroy(handle); } -void virgl_renderer_submit_cmd(void *buffer, - int ctx_id, - int ndw) +int virgl_renderer_submit_cmd(void *buffer, + int ctx_id, + int ndw) { - vrend_decode_block(ctx_id, buffer, ndw); + return vrend_decode_block(ctx_id, buffer, ndw); } int virgl_renderer_transfer_write_iov(uint32_t handle, diff --git a/src/virglrenderer.h b/src/virglrenderer.h index bc67163..ceca2ac 100644 --- a/src/virglrenderer.h +++ b/src/virglrenderer.h @@ -92,9 +92,9 @@ VIRGL_EXPORT void virgl_renderer_resource_unref(uint32_t res_handle); VIRGL_EXPORT int virgl_renderer_context_create(uint32_t handle, uint32_t nlen, const char *name); VIRGL_EXPORT void virgl_renderer_context_destroy(uint32_t handle); -VIRGL_EXPORT void virgl_renderer_submit_cmd(void *buffer, - int ctx_id, - int ndw); +VIRGL_EXPORT int virgl_renderer_submit_cmd(void *buffer, + int ctx_id, + int ndw); VIRGL_EXPORT int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id, uint32_t level, uint32_t stride, diff --git a/src/vrend_decode.c b/src/vrend_decode.c index 2fc821b..6bd6101 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -1033,22 +1033,22 @@ struct vrend_context *vrend_lookup_renderer_ctx(uint32_t ctx_id) return dec_ctx[ctx_id]->grctx; } -void vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw) +int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw) { struct vrend_decode_ctx *gdctx; boolean bret; int ret; if (ctx_id > VREND_MAX_CTX) - return; + return EINVAL; if (dec_ctx[ctx_id] == NULL) - return; + return EINVAL; gdctx = dec_ctx[ctx_id]; bret = vrend_hw_switch_context(gdctx->grctx, TRUE); if (bret == FALSE) - return; + return EINVAL; gdctx->ds->buf = block; gdctx->ds->buf_total = ndw; @@ -1161,13 +1161,15 @@ void vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw) if (ret == EINVAL) { vrend_report_buffer_error(gdctx->grctx, header); - break; + goto out; } if (ret == ENOMEM) - break; + goto out; gdctx->ds->buf_offset += (len) + 1; } - + return 0; +out: + return ret; } void vrend_decode_reset(bool ctx_0_only) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index c905eec..604e51a 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -393,7 +393,7 @@ static inline const char *pipe_shader_to_prefix(int shader_type) return NULL; } -static const char *vrend_ctx_error_strings[] = { "None", "Unknown", "Illegal shader", "Illegal handle", "Illegal resource", "Illegal surface", "Illegal vertex format" }; +static const char *vrend_ctx_error_strings[] = { "None", "Unknown", "Illegal shader", "Illegal handle", "Illegal resource", "Illegal surface", "Illegal vertex format", "Illegal command buffer" }; static void __report_context_error(const char *fname, struct vrend_context *ctx, enum virgl_ctx_errors error, uint32_t value) { diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 1700ded..57566ee 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -281,7 +281,7 @@ void vrend_transfer_write_tex_return(struct pipe_resource *res, void vrend_renderer_fini(void); -void vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw); +int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw); struct vrend_context *vrend_lookup_renderer_ctx(uint32_t ctx_id); int vrend_renderer_create_fence(int client_fence_id, uint32_t ctx_id);