vrend: Introudce VIRGL_CAP_V2_VIDEO_MEMORY to query video memory

This will allow for the virgl userspace driver to be able to respond
to PIPE_CAP_VIDEO_MEMORY requests.

Signed-off-by: Rohan Garg <rohan.garg@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Rohan Garg 3 years ago committed by Rohan Garg
parent b620ab260d
commit 7e7a4e72a1
  1. 2
      src/virgl_hw.h
  2. 11
      src/vrend_renderer.c
  3. 9
      src/vrend_winsys.c
  4. 2
      src/vrend_winsys.h
  5. 12
      src/vrend_winsys_glx.c
  6. 1
      src/vrend_winsys_glx.h

@ -408,6 +408,7 @@ enum virgl_formats {
/* These are used by the capability_bits_v2 field in virgl_caps_v2. */
#define VIRGL_CAP_V2_BLEND_EQUATION (1 << 0)
#define VIRGL_CAP_V2_UNTYPED_RESOURCE (1 << 1)
#define VIRGL_CAP_V2_VIDEO_MEMORY (1 << 2)
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
* but are fixed, no other should be passed to virgl either.
@ -559,6 +560,7 @@ struct virgl_caps_v2 {
uint32_t host_feature_check_version;
struct virgl_supported_format_mask supported_readback_formats;
struct virgl_supported_format_mask scanout;
uint32_t max_video_memory;
uint32_t capability_bits_v2;
};

@ -58,6 +58,10 @@
#include "tgsi/tgsi_text.h"
#ifdef HAVE_EPOXY_GLX_H
#include <epoxy/glx.h>
#endif
/*
* VIRGL_RENDERER_CAPSET_VIRGL has version 0 and 1, but they are both
* virgl_caps_v1 and are exactly the same.
@ -9984,6 +9988,7 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c
{
GLint max;
GLfloat range[2];
uint32_t video_memory;
/* Count this up when you add a feature flag that is used to set a CAP in
* the guest that was set unconditionally before. Then check that flag and
@ -10289,6 +10294,12 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c
if (egl)
caps->v2.capability_bits_v2 |= VIRGL_CAP_V2_UNTYPED_RESOURCE;
#endif
video_memory = vrend_winsys_query_video_memory();
if (video_memory) {
caps->v2.capability_bits_v2 |= VIRGL_CAP_V2_VIDEO_MEMORY;
caps->v2.max_video_memory = video_memory;
}
}
void vrend_renderer_fill_caps(uint32_t set, uint32_t version,

@ -198,3 +198,12 @@ int vrend_winsys_get_fd_for_texture2(uint32_t tex_id, int *fd, int *stride, int
return -1;
#endif
}
uint32_t vrend_winsys_query_video_memory(void)
{
#ifdef HAVE_EPOXY_GLX_H
return virgl_glx_query_video_memory(glx_info);
#else
return 0;
#endif
}

@ -58,4 +58,6 @@ int vrend_winsys_get_fourcc_for_texture(uint32_t tex_id, uint32_t format, int *f
int vrend_winsys_get_fd_for_texture(uint32_t tex_id, int *fd);
int vrend_winsys_get_fd_for_texture2(uint32_t tex_id, int *fd, int *stride, int *offset);
uint32_t vrend_winsys_query_video_memory(void);
#endif /* VREND_WINSYS_H */

@ -102,3 +102,15 @@ int virgl_glx_make_context_current(struct virgl_glx *d, virgl_renderer_gl_contex
{
return glXMakeContextCurrent(d->display, d->pbuffer, d->pbuffer, virglctx);
}
uint32_t virgl_glx_query_video_memory(struct virgl_glx *d)
{
uint32_t video_memory = 0;
if (d) {
if (epoxy_has_glx_extension(d->display, DefaultScreen(d->display), "GLX_MESA_query_renderer")) {
glXQueryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &video_memory);
}
}
return video_memory;
}

@ -33,5 +33,6 @@ void virgl_glx_destroy(struct virgl_glx *ve);
virgl_renderer_gl_context virgl_glx_create_context(struct virgl_glx *ve, struct virgl_gl_ctx_param *vparams);
void virgl_glx_destroy_context(struct virgl_glx *ve, virgl_renderer_gl_context virglctx);
int virgl_glx_make_context_current(struct virgl_glx *ve, virgl_renderer_gl_context virglctx);
uint32_t virgl_glx_query_video_memory(struct virgl_glx *ve);
#endif

Loading…
Cancel
Save