tests: modify some test utility functions

add w/h version for texture 2d
add backed buffer binding fn.
macos/master
Dave Airlie 10 years ago
parent 1c29fc4176
commit bdb49d5636
  1. 6
      tests/test_virgl_cmd.c
  2. 40
      tests/testvirgl.c
  3. 5
      tests/testvirgl.h

@ -46,7 +46,7 @@ START_TEST(virgl_test_clear)
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
/* init and create simple 2D resource */ /* 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); ck_assert_int_eq(ret, 0);
/* attach resource to context */ /* attach resource to context */
@ -118,11 +118,11 @@ START_TEST(virgl_test_blit_simple)
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
/* init and create simple 2D resource */ /* 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); ck_assert_int_eq(ret, 0);
/* init and create simple 2D resource */ /* 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); ck_assert_int_eq(ret, 0);
/* attach resource to context */ /* attach resource to context */

@ -49,12 +49,12 @@ void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_arg
res->flags = 0; 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->handle = handle;
res->target = PIPE_BUFFER; res->target = PIPE_BUFFER;
res->format = PIPE_FORMAT_R8_UNORM; res->format = PIPE_FORMAT_R8_UNORM;
res->width = 50; res->width = width;
res->height = 1; res->height = 1;
res->depth = 1; res->depth = 1;
res->array_size = 1; res->array_size = 1;
@ -64,6 +64,11 @@ void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *re
res->flags = 0; 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) void testvirgl_init_simple_2d_resource(struct virgl_renderer_resource_create_args *res, int handle)
{ {
res->handle = 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 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; struct virgl_renderer_resource_create_args args;
uint32_t backing_size; uint32_t backing_size;
int ret; int ret;
testvirgl_init_simple_2d_resource(&args, handle); testvirgl_init_simple_2d_resource(&args, handle);
args.width = w;
args.height = h;
ret = virgl_renderer_resource_create(&args, NULL, 0); ret = virgl_renderer_resource_create(&args, NULL, 0);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
@ -181,3 +188,30 @@ void testvirgl_destroy_backed_res(struct virgl_resource *res)
free(iovs); free(iovs);
virgl_renderer_resource_unref(res->handle); 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;
}

@ -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(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_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); void testvirgl_init_simple_2d_resource(struct virgl_renderer_resource_create_args *res, int handle);
int testvirgl_init_single_ctx(void); 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); void testvirgl_fini_ctx_cmdbuf(struct virgl_context *ctx);
int testvirgl_create_backed_simple_2d_res(struct virgl_resource *res, 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); void testvirgl_destroy_backed_res(struct virgl_resource *res);
#endif #endif

Loading…
Cancel
Save