This struct allows us to report accurate max point size/line width.
---
 src/gallium/drivers/virgl/virgl_hw.h            | 29 +++++++++++++++++++++++++
 src/gallium/drivers/virgl/virgl_screen.c        |  9 ++++----
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 19 +++++++++++++++-
 3 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/virgl/virgl_hw.h 
b/src/gallium/drivers/virgl/virgl_hw.h
index e3c56db2ac..2a1305bf2e 100644
--- a/src/gallium/drivers/virgl/virgl_hw.h
+++ b/src/gallium/drivers/virgl/virgl_hw.h
@@ -259,9 +259,38 @@ struct virgl_caps_v1 {
         uint32_t max_texture_gather_components;
 };
 
+struct virgl_caps_v2 {
+        uint32_t max_version;
+        struct virgl_supported_format_mask sampler;
+        struct virgl_supported_format_mask render;
+        struct virgl_supported_format_mask depthstencil;
+        struct virgl_supported_format_mask vertexbuffer;
+        struct virgl_caps_bool_set1 bset;
+        uint32_t glsl_level;
+        uint32_t max_texture_array_layers;
+        uint32_t max_streamout_buffers;
+        uint32_t max_dual_source_render_targets;
+        uint32_t max_render_targets;
+        uint32_t max_samples;
+        uint32_t prim_mask;
+        uint32_t max_tbo_size;
+        uint32_t max_uniform_blocks;
+        uint32_t max_viewports;
+        uint32_t max_texture_gather_components;
+        float min_aliased_point_size;
+        float max_aliased_point_size;
+        float min_smooth_point_size;
+        float max_smooth_point_size;
+        float min_aliased_line_width;
+        float max_aliased_line_width;
+        float min_smooth_line_width;
+        float max_smooth_line_width;
+};
+
 union virgl_caps {
         uint32_t max_version;
         struct virgl_caps_v1 v1;
+        struct virgl_caps_v2 v2;
 };
 
 enum virgl_errors {
diff --git a/src/gallium/drivers/virgl/virgl_screen.c 
b/src/gallium/drivers/virgl/virgl_screen.c
index 725f7dbed4..613e1e531a 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -354,15 +354,16 @@ virgl_get_shader_param(struct pipe_screen *screen,
 static float
 virgl_get_paramf(struct pipe_screen *screen, enum pipe_capf param)
 {
+   struct virgl_screen *vscreen = virgl_screen(screen);
    switch (param) {
    case PIPE_CAPF_MAX_LINE_WIDTH:
-      /* fall-through */
+      return vscreen->caps.caps.v2.max_aliased_line_width;
    case PIPE_CAPF_MAX_LINE_WIDTH_AA:
-      return 255.0; /* arbitrary */
+      return vscreen->caps.caps.v2.max_smooth_line_width;
    case PIPE_CAPF_MAX_POINT_WIDTH:
-      /* fall-through */
+      return vscreen->caps.caps.v2.max_aliased_point_size;
    case PIPE_CAPF_MAX_POINT_WIDTH_AA:
-      return 255.0; /* arbitrary */
+      return vscreen->caps.caps.v2.max_smooth_point_size;
    case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
       return 16.0;
    case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS:
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c 
b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 71e652ebf3..68dd0148c9 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -704,13 +704,30 @@ static int virgl_drm_get_caps(struct virgl_winsys *vws,
 {
    struct virgl_drm_winsys *vdws = virgl_drm_winsys(vws);
    struct drm_virtgpu_get_caps args;
+   int ret;
 
    memset(&args, 0, sizeof(args));
 
    args.cap_set_id = 1;
    args.addr = (unsigned long)&caps->caps;
    args.size = sizeof(union virgl_caps);
-   return drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args);
+
+   ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args);
+
+   if (ret == -EINVAL) {
+      /* Fallback to v1 */
+      args.size = sizeof(struct virgl_caps_v1);
+      ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args);
+      caps->caps.v2.min_aliased_point_size = 0.f;
+      caps->caps.v2.max_aliased_point_size = 255.f;
+      caps->caps.v2.min_smooth_point_size = 0.f;
+      caps->caps.v2.max_smooth_point_size = 255.f;
+      caps->caps.v2.min_aliased_line_width = 0.f;
+      caps->caps.v2.max_aliased_line_width = 255.f;
+      caps->caps.v2.min_smooth_line_width = 0.f;
+      caps->caps.v2.max_smooth_line_width = 255.f;
+   }
+   return ret;
 }
 
 #define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-- 
2.16.0.rc1.238.g530d649a79-goog

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to