vtest: add VCMD_CONTEXT_INIT

It gives clients access to virgl_renderer_context_create_with_flags.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Isaac Bosompem <mrisaacb@google.com>
macos/master
Chia-I Wu 5 years ago
parent 0b3e195268
commit f8000f0986
  1. 1
      vtest/vtest.h
  2. 4
      vtest/vtest_protocol.h
  3. 39
      vtest/vtest_renderer.c
  4. 1
      vtest/vtest_server.c

@ -81,6 +81,7 @@ int vtest_protocol_version(uint32_t length_dw);
/* since protocol version 3 */
int vtest_get_param(uint32_t length_dw);
int vtest_get_capset(uint32_t length_dw);
int vtest_context_init(uint32_t length_dw);
void vtest_set_max_length(uint32_t length);

@ -68,6 +68,7 @@
/* since protocol version 3 */
#define VCMD_GET_PARAM 15
#define VCMD_GET_CAPSET 16
#define VCMD_CONTEXT_INIT 17
#endif /* VIRGL_RENDERER_UNSTABLE_APIS */
#define VCMD_RES_CREATE_SIZE 10
@ -145,6 +146,9 @@
#define VCMD_GET_CAPSET_VERSION 1
/* resp capset validity and contents */
#define VCMD_CONTEXT_INIT_SIZE 1
#define VCMD_CONTEXT_INIT_CAPSET_ID 0
#endif /* VIRGL_RENDERER_UNSTABLE_APIS */
#endif /* VTEST_PROTOCOL */

@ -64,6 +64,7 @@ struct vtest_context {
char *debug_name;
unsigned protocol_version;
unsigned capset_id;
bool context_initialized;
struct util_hash_table *resource_table;
@ -327,6 +328,7 @@ static struct vtest_context *vtest_new_context(struct vtest_input *input,
ctx->debug_name = NULL;
/* By default we support version 0 unless VCMD_PROTOCOL_VERSION is sent */
ctx->protocol_version = 0;
ctx->capset_id = 0;
ctx->context_initialized = false;
return ctx;
@ -390,9 +392,16 @@ int vtest_lazy_init_context(struct vtest_context *ctx)
if (ctx->context_initialized)
return 0;
ret = virgl_renderer_context_create(ctx->ctx_id,
strlen(ctx->debug_name),
ctx->debug_name);
if (ctx->capset_id) {
ret = virgl_renderer_context_create_with_flags(ctx->ctx_id,
ctx->capset_id,
strlen(ctx->debug_name),
ctx->debug_name);
} else {
ret = virgl_renderer_context_create(ctx->ctx_id,
strlen(ctx->debug_name),
ctx->debug_name);
}
ctx->context_initialized = (ret == 0);
return ret;
@ -570,6 +579,30 @@ int vtest_get_capset(UNUSED uint32_t length_dw)
return ret >= 0 ? 0 : ret;
}
int vtest_context_init(UNUSED uint32_t length_dw)
{
struct vtest_context *ctx = vtest_get_current_context();
uint32_t context_init_buf[VCMD_CONTEXT_INIT_SIZE];
uint32_t capset_id;
int ret;
ret = ctx->input->read(ctx->input, context_init_buf, sizeof(context_init_buf));
if (ret != sizeof(context_init_buf))
return -1;
capset_id = context_init_buf[VCMD_CONTEXT_INIT_CAPSET_ID];
if (!capset_id)
return -EINVAL;
if (ctx->context_initialized) {
return ctx->capset_id == capset_id ? 0 : -EINVAL;
}
ctx->capset_id = capset_id;
return vtest_lazy_init_context(ctx);
}
int vtest_send_caps2(UNUSED uint32_t length_dw)
{
struct vtest_context *ctx = vtest_get_current_context();

@ -607,6 +607,7 @@ static const struct vtest_command {
/* since protocol version 3 */
[VCMD_GET_PARAM] = { vtest_get_param, false },
[VCMD_GET_CAPSET] = { vtest_get_capset, false },
[VCMD_CONTEXT_INIT] = { vtest_context_init, false },
};
static int vtest_client_dispatch_commands(struct vtest_client *client)

Loading…
Cancel
Save