virgl: add support for venus renderer

Add VIRGL_RENDERER_VENUS and the related bits.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Chia-I Wu 4 years ago
parent 9b2d22b584
commit 6c31f85330
  1. 1
      src/meson.build
  2. 38
      src/venus_hw.h
  3. 34
      src/virglrenderer.c
  4. 4
      src/virglrenderer.h
  5. 3
      src/virglrenderer_hw.h
  6. 7
      src/vkr_renderer.c

@ -76,6 +76,7 @@ vrend_winsys_glx_sources = [
venus_sources = [ venus_sources = [
'venus-protocol/vn_protocol_renderer.h', 'venus-protocol/vn_protocol_renderer.h',
'venus_hw.h',
'vkr_cs.c', 'vkr_cs.c',
'vkr_cs.h', 'vkr_cs.h',
'vkr_object.h', 'vkr_object.h',

@ -0,0 +1,38 @@
/*
* Copyright 2020 Chromium
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VENUS_HW_H
#define VENUS_HW_H
#include <stdint.h>
#ifdef VIRGL_RENDERER_UNSTABLE_APIS
struct virgl_renderer_capset_venus {
uint32_t wire_format_version;
uint32_t vk_xml_version;
uint32_t vk_ext_command_serialization_spec_version;
uint32_t vk_mesa_venus_protocol_spec_version;
};
#endif
#endif /* VENUS_HW_H */

@ -35,6 +35,7 @@
#include "pipe/p_state.h" #include "pipe/p_state.h"
#include "util/u_format.h" #include "util/u_format.h"
#include "util/u_math.h" #include "util/u_math.h"
#include "vkr_renderer.h"
#include "vrend_renderer.h" #include "vrend_renderer.h"
#include "vrend_winsys.h" #include "vrend_winsys.h"
@ -55,6 +56,7 @@ struct global_state {
bool context_initialized; bool context_initialized;
bool winsys_initialized; bool winsys_initialized;
bool vrend_initialized; bool vrend_initialized;
bool vkr_initialized;
}; };
static struct global_state state; static struct global_state state;
@ -160,6 +162,10 @@ void virgl_renderer_fill_caps(uint32_t set, uint32_t version,
case VIRGL_RENDERER_CAPSET_VIRGL2: case VIRGL_RENDERER_CAPSET_VIRGL2:
vrend_renderer_fill_caps(set, version, (union virgl_caps *)caps); vrend_renderer_fill_caps(set, version, (union virgl_caps *)caps);
break; break;
case VIRGL_RENDERER_CAPSET_VENUS:
if (state.vkr_initialized)
vkr_get_capset(caps);
break;
default: default:
break; break;
} }
@ -205,6 +211,11 @@ int virgl_renderer_context_create_with_flags(uint32_t ctx_id,
case VIRGL_RENDERER_CAPSET_VIRGL2: case VIRGL_RENDERER_CAPSET_VIRGL2:
ctx = vrend_renderer_context_create(ctx_id, nlen, name); ctx = vrend_renderer_context_create(ctx_id, nlen, name);
break; break;
case VIRGL_RENDERER_CAPSET_VENUS:
if (!state.vkr_initialized)
return EINVAL;
ctx = vkr_context_create(nlen, name);
break;
default: default:
return EINVAL; return EINVAL;
break; break;
@ -461,6 +472,12 @@ void virgl_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver,
case VIRGL_RENDERER_CAPSET_VIRGL2: case VIRGL_RENDERER_CAPSET_VIRGL2:
vrend_renderer_get_cap_set(cap_set, max_ver, max_size); vrend_renderer_get_cap_set(cap_set, max_ver, max_size);
break; break;
case VIRGL_RENDERER_CAPSET_VENUS:
if (state.vkr_initialized) {
*max_ver = 0;
*max_size = vkr_get_capset(NULL);
}
break;
default: default:
*max_ver = 0; *max_ver = 0;
*max_size = 0; *max_size = 0;
@ -558,6 +575,9 @@ void virgl_renderer_cleanup(UNUSED void *cookie)
if (state.resource_initialized) if (state.resource_initialized)
virgl_resource_table_cleanup(); virgl_resource_table_cleanup();
if (state.vkr_initialized)
vkr_renderer_fini();
if (state.vrend_initialized) if (state.vrend_initialized)
vrend_renderer_fini(); vrend_renderer_fini();
@ -641,6 +661,17 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
state.vrend_initialized = true; state.vrend_initialized = true;
} }
if (!state.vkr_initialized && (flags & VIRGL_RENDERER_VENUS)) {
uint32_t vkr_flags = 0;
if (flags & VIRGL_RENDERER_THREAD_SYNC)
vkr_flags |= VKR_RENDERER_THREAD_SYNC;
int ret = vkr_renderer_init(vkr_flags);
if (ret)
goto fail;
state.vkr_initialized = true;
}
return 0; return 0;
fail: fail:
@ -676,6 +707,9 @@ void virgl_renderer_reset(void)
if (state.resource_initialized) if (state.resource_initialized)
virgl_resource_table_reset(); virgl_resource_table_reset();
if (state.vkr_initialized)
vkr_renderer_reset();
if (state.vrend_initialized) if (state.vrend_initialized)
vrend_renderer_reset(); vrend_renderer_reset();
} }

@ -90,6 +90,10 @@ struct virgl_renderer_callbacks {
*/ */
#define VIRGL_RENDERER_USE_EXTERNAL_BLOB (1 << 5) #define VIRGL_RENDERER_USE_EXTERNAL_BLOB (1 << 5)
/* Enable venus renderer.
*/
#define VIRGL_RENDERER_VENUS (1 << 6)
#endif /* VIRGL_RENDERER_UNSTABLE_APIS */ #endif /* VIRGL_RENDERER_UNSTABLE_APIS */
VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb); VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb);

@ -24,12 +24,15 @@
#ifndef VIRGLRENDERER_HW_H #ifndef VIRGLRENDERER_HW_H
#define VIRGLRENDERER_HW_H #define VIRGLRENDERER_HW_H
#include "venus_hw.h"
#include "virgl_hw.h" #include "virgl_hw.h"
#ifdef VIRGL_RENDERER_UNSTABLE_APIS #ifdef VIRGL_RENDERER_UNSTABLE_APIS
enum virgl_renderer_capset { enum virgl_renderer_capset {
VIRGL_RENDERER_CAPSET_VIRGL = 1, VIRGL_RENDERER_CAPSET_VIRGL = 1,
VIRGL_RENDERER_CAPSET_VIRGL2 = 2, VIRGL_RENDERER_CAPSET_VIRGL2 = 2,
/* 3 is reserved for gfxstream */
VIRGL_RENDERER_CAPSET_VENUS = 4,
}; };
#endif #endif

@ -4008,13 +4008,6 @@ fail:
return NULL; return NULL;
} }
struct virgl_renderer_capset_venus {
uint32_t wire_format_version;
uint32_t vk_xml_version;
uint32_t vk_ext_command_serialization_spec_version;
uint32_t vk_mesa_venus_protocol_spec_version;
};
size_t size_t
vkr_get_capset(void *capset) vkr_get_capset(void *capset)
{ {

Loading…
Cancel
Save