|
|
|
@ -71,6 +71,9 @@ static int virgl_renderer_resource_create_internal(struct virgl_renderer_resourc |
|
|
|
|
struct pipe_resource *pipe_res; |
|
|
|
|
struct vrend_renderer_resource_create_args vrend_args = { 0 }; |
|
|
|
|
|
|
|
|
|
if (!state.vrend_initialized) |
|
|
|
|
return EINVAL; |
|
|
|
|
|
|
|
|
|
/* do not accept handle 0 */ |
|
|
|
|
if (args->handle == 0) |
|
|
|
|
return EINVAL; |
|
|
|
@ -160,6 +163,7 @@ void virgl_renderer_fill_caps(uint32_t set, uint32_t version, |
|
|
|
|
switch (set) { |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VIRGL: |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VIRGL2: |
|
|
|
|
if (state.vrend_initialized) |
|
|
|
|
vrend_renderer_fill_caps(set, version, (union virgl_caps *)caps); |
|
|
|
|
break; |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VENUS: |
|
|
|
@ -209,6 +213,8 @@ int virgl_renderer_context_create_with_flags(uint32_t ctx_id, |
|
|
|
|
switch (capset_id) { |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VIRGL: |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VIRGL2: |
|
|
|
|
if (!state.vrend_initialized) |
|
|
|
|
return EINVAL; |
|
|
|
|
ctx = vrend_renderer_context_create(ctx_id, nlen, name); |
|
|
|
|
break; |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VENUS: |
|
|
|
@ -416,6 +422,7 @@ int virgl_renderer_context_get_poll_fd(uint32_t ctx_id) |
|
|
|
|
void virgl_renderer_force_ctx_0(void) |
|
|
|
|
{ |
|
|
|
|
TRACE_FUNC(); |
|
|
|
|
if (state.vrend_initialized) |
|
|
|
|
vrend_renderer_force_ctx_0(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -467,16 +474,16 @@ void virgl_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver, |
|
|
|
|
uint32_t *max_size) |
|
|
|
|
{ |
|
|
|
|
TRACE_FUNC(); |
|
|
|
|
|
|
|
|
|
/* this may be called before virgl_renderer_init */ |
|
|
|
|
switch (cap_set) { |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VIRGL: |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VIRGL2: |
|
|
|
|
vrend_renderer_get_cap_set(cap_set, max_ver, max_size); |
|
|
|
|
break; |
|
|
|
|
case VIRGL_RENDERER_CAPSET_VENUS: |
|
|
|
|
if (state.vkr_initialized) { |
|
|
|
|
*max_ver = 0; |
|
|
|
|
*max_size = vkr_get_capset(NULL); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
*max_ver = 0; |
|
|
|
@ -604,9 +611,8 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks |
|
|
|
|
return -EBUSY; |
|
|
|
|
|
|
|
|
|
if (!state.client_initialized) { |
|
|
|
|
if (!cookie || !cbs) |
|
|
|
|
return -1; |
|
|
|
|
if (cbs->version < 1 || cbs->version > VIRGL_RENDERER_CALLBACKS_VERSION) |
|
|
|
|
if (cbs && (cbs->version < 1 || |
|
|
|
|
cbs->version > VIRGL_RENDERER_CALLBACKS_VERSION)) |
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
state.cookie = cookie; |
|
|
|
@ -616,7 +622,11 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!state.resource_initialized) { |
|
|
|
|
ret = virgl_resource_table_init(vrend_renderer_get_pipe_callbacks()); |
|
|
|
|
const struct virgl_resource_pipe_callbacks *pipe_cbs = |
|
|
|
|
(flags & VIRGL_RENDERER_NO_VIRGL) ? NULL : |
|
|
|
|
vrend_renderer_get_pipe_callbacks(); |
|
|
|
|
|
|
|
|
|
ret = virgl_resource_table_init(pipe_cbs); |
|
|
|
|
if (ret) |
|
|
|
|
goto fail; |
|
|
|
|
state.resource_initialized = true; |
|
|
|
@ -629,8 +639,8 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks |
|
|
|
|
state.context_initialized = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!state.winsys_initialized && (flags & (VIRGL_RENDERER_USE_EGL | |
|
|
|
|
VIRGL_RENDERER_USE_GLX))) { |
|
|
|
|
if (!state.winsys_initialized && !(flags & VIRGL_RENDERER_NO_VIRGL) && |
|
|
|
|
(flags & (VIRGL_RENDERER_USE_EGL | VIRGL_RENDERER_USE_GLX))) { |
|
|
|
|
int drm_fd = -1; |
|
|
|
|
|
|
|
|
|
if (flags & VIRGL_RENDERER_USE_EGL) { |
|
|
|
@ -647,9 +657,14 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks |
|
|
|
|
state.winsys_initialized = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!state.vrend_initialized) { |
|
|
|
|
if (!state.vrend_initialized && !(flags & VIRGL_RENDERER_NO_VIRGL)) { |
|
|
|
|
uint32_t renderer_flags = 0; |
|
|
|
|
|
|
|
|
|
if (!cookie || !cbs) { |
|
|
|
|
ret = -1; |
|
|
|
|
goto fail; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (flags & VIRGL_RENDERER_THREAD_SYNC) |
|
|
|
|
renderer_flags |= VREND_USE_THREAD_SYNC; |
|
|
|
|
if (flags & VIRGL_RENDERER_USE_EXTERNAL_BLOB) |
|
|
|
|