tests: refactor caps getting code out.

This just makes getting caps be common code.

Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Dave Airlie 7 years ago
parent 8007cc0b12
commit 3cd2caad2b
  1. 55
      tests/testvirgl.c

@ -267,47 +267,42 @@ int testvirgl_create_backed_simple_buffer(struct virgl_resource *res,
return 0; return 0;
} }
uint32_t testvirgl_get_glsl_level_from_caps(void) static void *get_caps(void)
{ {
uint32_t max_ver, max_size, glsl_level; uint32_t max_ver, max_size, glsl_level;
void *caps; void *caps;
virgl_renderer_get_cap_set(1, &max_ver, &max_size);
ck_assert_int_eq(max_ver, 1);
ck_assert_int_ne(max_size, 0);
ck_assert_int_eq(max_size, sizeof(struct virgl_caps_v1));
caps = malloc(max_size); virgl_renderer_get_cap_set(1, &max_ver, &max_size);
ck_assert_int_eq(max_ver, 1);
ck_assert_int_ne(max_size, 0);
ck_assert_int_eq(max_size, sizeof(struct virgl_caps_v1));
caps = malloc(max_size);
virgl_renderer_fill_caps(0, 0, caps); virgl_renderer_fill_caps(0, 0, caps);
return caps;
}
struct virgl_caps_v1 *v1 = (struct virgl_caps_v1*) caps; uint32_t testvirgl_get_glsl_level_from_caps(void)
glsl_level = v1->glsl_level; {
uint32_t glsl_level;
void *caps = get_caps();
struct virgl_caps_v1 *v1 = (struct virgl_caps_v1*) caps;
glsl_level = v1->glsl_level;
free(caps); free(caps);
return glsl_level; return glsl_level;
} }
unsigned testvirgl_get_multisample_from_caps(void) unsigned testvirgl_get_multisample_from_caps(void)
{ {
uint32_t max_ver, max_size; void *caps = get_caps();
unsigned multisample; unsigned multisample;
void *caps;
virgl_renderer_get_cap_set(1, &max_ver, &max_size);
ck_assert_int_eq(max_ver, 1);
ck_assert_int_ne(max_size, 0);
ck_assert_int_eq(max_size, sizeof(struct virgl_caps_v1));
caps = malloc(max_size);
virgl_renderer_fill_caps(0, 0, caps);
struct virgl_caps_v1 *v1 = (struct virgl_caps_v1*) caps; struct virgl_caps_v1 *v1 = (struct virgl_caps_v1*) caps;
multisample = v1->bset.texture_multisample; multisample = v1->bset.texture_multisample;
free(caps); free(caps);
return multisample; return multisample;
} }

Loading…
Cancel
Save