virtio-gpu: use the newest caps

capset2 has many new features. We currently hardcode num_capsets
to 1, however our Mesa/guest kernel/virglrenderer are new enough
to support caps v2.

We could attempt to do negotiation (see virtio_gpu_virgl_get_num_capset
in QEMU), but virtio::gpu::Gpu::get_config actually comes before
virtio::gpu::Gpu::activate. To support older Mesa/guest kernel/virglrenderer
configurations, this must be refactored.

BUG=none
TEST=get a gles31 context on tatl

Change-Id: I8d9ed54774a63da2ec5a4ba86187330521785566
Reviewed-on: https://chromium-review.googlesource.com/1258323
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
Gurchetan Singh 2018-10-02 16:07:26 -07:00 committed by chrome-bot
parent b1570f2672
commit 046df60760
3 changed files with 11 additions and 10 deletions

View file

@ -23,6 +23,7 @@ use super::gpu_renderer::{Box3, Renderer, Context as RendererContext,
format_fourcc as renderer_fourcc};
use super::protocol::GpuResponse;
use super::protocol::{VIRTIO_GPU_CAPSET_VIRGL, VIRTIO_GPU_CAPSET_VIRGL2};
const DEFAULT_WIDTH: u32 = 1280;
const DEFAULT_HEIGHT: u32 = 1024;
@ -595,14 +596,13 @@ impl Backend {
/// Gets the renderer's capset information associated with `index`.
pub fn get_capset_info(&self, index: u32) -> GpuResponse {
match index {
0 => {
let id = 1; // VIRTIO_GPU_CAPSET_VIRGL
let (version, size) = self.renderer.get_cap_set_info(id);
GpuResponse::OkCapsetInfo { id, version, size }
}
_ => GpuResponse::ErrInvalidParameter,
}
let id = match index {
0 => VIRTIO_GPU_CAPSET_VIRGL,
1 => VIRTIO_GPU_CAPSET_VIRGL2,
_ => return GpuResponse::ErrInvalidParameter,
};
let (version, size) = self.renderer.get_cap_set_info(id);
GpuResponse::OkCapsetInfo { id, version, size }
}
/// Gets the capset of `version` associated with `id`.

View file

@ -610,7 +610,7 @@ impl Gpu {
events_read: Le32::from(events_read),
events_clear: Le32::from(0),
num_scanouts: Le32::from(1),
num_capsets: Le32::from(1),
num_capsets: Le32::from(2),
}
}
}

View file

@ -369,7 +369,8 @@ pub struct virtio_gpu_cmd_submit {
unsafe impl DataInit for virtio_gpu_cmd_submit {}
const VIRTIO_GPU_CAPSET_VIRGL: u32 = 1;
pub const VIRTIO_GPU_CAPSET_VIRGL: u32 = 1;
pub const VIRTIO_GPU_CAPSET_VIRGL2: u32 = 2;
/* VIRTIO_GPU_CMD_GET_CAPSET_INFO */
#[derive(Copy, Clone, Debug)]