diff --git a/tests/test_virgl_cmd.c b/tests/test_virgl_cmd.c index a1dde11..b618cdc 100644 --- a/tests/test_virgl_cmd.c +++ b/tests/test_virgl_cmd.c @@ -46,7 +46,7 @@ START_TEST(virgl_test_clear) ck_assert_int_eq(ret, 0); /* init and create simple 2D resource */ - ret = testvirgl_create_backed_simple_2d_res(&res, 1); + ret = testvirgl_create_backed_simple_2d_res(&res, 1, 50, 50); ck_assert_int_eq(ret, 0); /* attach resource to context */ @@ -118,11 +118,11 @@ START_TEST(virgl_test_blit_simple) ck_assert_int_eq(ret, 0); /* init and create simple 2D resource */ - ret = testvirgl_create_backed_simple_2d_res(&res, 1); + ret = testvirgl_create_backed_simple_2d_res(&res, 1, 50, 50); ck_assert_int_eq(ret, 0); /* init and create simple 2D resource */ - ret = testvirgl_create_backed_simple_2d_res(&res2, 2); + ret = testvirgl_create_backed_simple_2d_res(&res2, 2, 50, 50); ck_assert_int_eq(ret, 0); /* attach resource to context */ diff --git a/tests/testvirgl.c b/tests/testvirgl.c index bdafc09..60233ed 100644 --- a/tests/testvirgl.c +++ b/tests/testvirgl.c @@ -49,12 +49,12 @@ void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_arg res->flags = 0; } -void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *res, int handle) +void testvirgl_init_simple_buffer_sized(struct virgl_renderer_resource_create_args *res, int handle, int width) { res->handle = handle; res->target = PIPE_BUFFER; res->format = PIPE_FORMAT_R8_UNORM; - res->width = 50; + res->width = width; res->height = 1; res->depth = 1; res->array_size = 1; @@ -64,6 +64,11 @@ void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *re res->flags = 0; } +void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *res, int handle) +{ + testvirgl_init_simple_buffer_sized(res, handle, 50); +} + void testvirgl_init_simple_2d_resource(struct virgl_renderer_resource_create_args *res, int handle) { res->handle = handle; @@ -145,13 +150,15 @@ void testvirgl_fini_ctx_cmdbuf(struct virgl_context *ctx) } int testvirgl_create_backed_simple_2d_res(struct virgl_resource *res, - int handle) + int handle, int w, int h) { struct virgl_renderer_resource_create_args args; uint32_t backing_size; int ret; testvirgl_init_simple_2d_resource(&args, handle); + args.width = w; + args.height = h; ret = virgl_renderer_resource_create(&args, NULL, 0); ck_assert_int_eq(ret, 0); @@ -181,3 +188,30 @@ void testvirgl_destroy_backed_res(struct virgl_resource *res) free(iovs); virgl_renderer_resource_unref(res->handle); } + +int testvirgl_create_backed_simple_buffer(struct virgl_resource *res, + int handle, int size, int binding) +{ + struct virgl_renderer_resource_create_args args; + uint32_t backing_size; + int ret; + + testvirgl_init_simple_buffer_sized(&args, handle, size); + args.bind = binding; + ret = virgl_renderer_resource_create(&args, NULL, 0); + ck_assert_int_eq(ret, 0); + + res->handle = handle; + res->base.target = args.target; + res->base.format = args.format; + res->base.bind = args.bind; + backing_size = args.width * args.height * util_format_get_blocksize(res->base.format); + res->iovs = malloc(sizeof(struct iovec)); + + res->iovs[0].iov_base = malloc(backing_size); + res->iovs[0].iov_len = backing_size; + res->niovs = 1; + + virgl_renderer_resource_attach_iov(res->handle, res->iovs, res->niovs); + return 0; +} diff --git a/tests/testvirgl.h b/tests/testvirgl.h index 267ab5e..4043e2c 100644 --- a/tests/testvirgl.h +++ b/tests/testvirgl.h @@ -56,6 +56,7 @@ struct virgl_resource { void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *res, int handle); +void testvirgl_init_simple_buffer_sized(struct virgl_renderer_resource_create_args *res, int handle, int width); void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_args *args, int handle); void testvirgl_init_simple_2d_resource(struct virgl_renderer_resource_create_args *res, int handle); int testvirgl_init_single_ctx(void); @@ -66,6 +67,8 @@ int testvirgl_init_ctx_cmdbuf(struct virgl_context *ctx); void testvirgl_fini_ctx_cmdbuf(struct virgl_context *ctx); int testvirgl_create_backed_simple_2d_res(struct virgl_resource *res, - int handle); + int handle, int w, int h); +int testvirgl_create_backed_simple_buffer(struct virgl_resource *res, + int handle, int size, int bind); void testvirgl_destroy_backed_res(struct virgl_resource *res); #endif