aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
diff options
context:
space:
mode:
authorStéphane Marchesin <[email protected]>2018-02-09 17:21:59 -0800
committerDave Airlie <[email protected]>2018-02-13 14:23:54 +1000
commit5e4a2b394eb03d5b49df8d3f2263c65b24ad2bb9 (patch)
tree0c873e0cd3f25592a749c62f9a07fe0266b1ebdd /src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
parent10457712edb744d358c4b7c891fdaa1a6c136046 (diff)
virgl: Support v2 caps struct (v2)
This struct allows us to report: - accurate max point size/line width. - accurate texel and texture gather offsets - vertex/geometry limits. Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/winsys/virgl/drm/virgl_drm_winsys.c')
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 71e652ebf31..fd6ae98a515 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -704,13 +704,49 @@ 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;
+ bool fill_v2 = false;
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 == -1 && errno == EINVAL) {
+ /* Fallback to v1 */
+ args.size = sizeof(struct virgl_caps_v1);
+ ret = drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_GET_CAPS, &args);
+ if (ret == -1)
+ return ret;
+ fill_v2 = true;
+ }
+ if (caps->caps.max_version == 1)
+ fill_v2 = true;
+
+ if (fill_v2) {
+ 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;
+ caps->caps.v2.max_texture_lod_bias = 16.0f;
+ caps->caps.v2.max_geom_output_vertices = 256;
+ caps->caps.v2.max_geom_total_output_components = 16384;
+ caps->caps.v2.max_vertex_outputs = 32;
+ caps->caps.v2.max_vertex_attribs = 16;
+ caps->caps.v2.max_shader_patch_varyings = 0;
+ caps->caps.v2.min_texel_offset = -8;
+ caps->caps.v2.max_texel_offset = 7;
+ caps->caps.v2.min_texture_gather_offset = -8;
+ caps->caps.v2.max_texture_gather_offset = 7;
+ }
+ return ret;
}
#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))