diff --git a/vtest/vtest.h b/vtest/vtest.h index 191813e..dac716e 100644 --- a/vtest/vtest.h +++ b/vtest/vtest.h @@ -75,7 +75,6 @@ int vtest_buf_read(struct vtest_input *input, void *buf, int size); int vtest_resource_busy_wait(uint32_t length_dw); int vtest_resource_busy_wait_nop(uint32_t length_dw); -int vtest_renderer_create_fence(void); int vtest_poll(void); int vtest_ping_protocol_version(uint32_t length_dw); diff --git a/vtest/vtest_fuzzer.c b/vtest/vtest_fuzzer.c index 9877531..4c3567a 100644 --- a/vtest/vtest_fuzzer.c +++ b/vtest/vtest_fuzzer.c @@ -136,11 +136,6 @@ static void vtest_fuzzer_run_renderer(int out_fd, struct vtest_input *input, if (ret < 0) { break; } - - /* GL draws are fenced, while possible fence creations are too */ - if ((header[1] == VCMD_SUBMIT_CMD || header[1] == VCMD_RESOURCE_CREATE || - header[1] == VCMD_RESOURCE_CREATE2)) - vtest_renderer_create_fence(); } while (1); if (context) { diff --git a/vtest/vtest_renderer.c b/vtest/vtest_renderer.c index 6dbf21e..9d9f517 100644 --- a/vtest/vtest_renderer.c +++ b/vtest/vtest_renderer.c @@ -93,6 +93,20 @@ struct vtest_renderer { struct vtest_context *current_context; }; +/* + * A fence is created after + * + * - VCMD_RESOURCE_CREATE + * - VCMD_RESOURCE_CREATE2 + * - VCMD_SUBMIT_CMD + * + * for VCMD_RESOURCE_BUSY_WAIT to wait on. + */ +static void vtest_renderer_create_fence(struct vtest_renderer *renderer) +{ + virgl_renderer_create_fence(renderer->fence_id++, 0); +} + static void vtest_write_fence(UNUSED void *cookie, uint32_t fence_id_in) { struct vtest_renderer *renderer = (struct vtest_renderer*)cookie; @@ -886,6 +900,9 @@ static int vtest_create_resource_internal(struct vtest_context *ctx, util_hash_table_set(ctx->resource_table, intptr_to_pointer(res->res_id), res); + if (cmd_id == VCMD_RESOURCE_CREATE || cmd_id == VCMD_RESOURCE_CREATE2) + vtest_renderer_create_fence(&renderer); + return 0; } @@ -1060,7 +1077,11 @@ int vtest_submit_cmd(uint32_t length_dw) ret = virgl_renderer_submit_cmd(cbuf, ctx->ctx_id, length_dw); free(cbuf); - return ret ? -1 : 0; + if (ret) + return -1; + + vtest_renderer_create_fence(&renderer); + return 0; } struct vtest_transfer_args { @@ -1438,13 +1459,6 @@ int vtest_resource_busy_wait_nop(UNUSED uint32_t length_dw) return 0; } -int vtest_renderer_create_fence(void) -{ - struct vtest_context *ctx = vtest_get_current_context(); - virgl_renderer_create_fence(renderer.fence_id++, ctx->ctx_id); - return 0; -} - int vtest_poll(void) { virgl_renderer_poll(); diff --git a/vtest/vtest_server.c b/vtest/vtest_server.c index e70327c..f60ec11 100644 --- a/vtest/vtest_server.c +++ b/vtest/vtest_server.c @@ -666,11 +666,6 @@ static int vtest_client_dispatch_commands(struct vtest_client *client) return VTEST_CLIENT_ERROR_COMMAND_DISPATCH; } - /* GL draws are fenced, while possible fence creations are too */ - if (header[1] == VCMD_SUBMIT_CMD || header[1] == VCMD_RESOURCE_CREATE || - header[1] == VCMD_RESOURCE_CREATE2) - vtest_renderer_create_fence(); - return 0; }