mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 03:57:24 +00:00
devices: gpu: make 'wsi' gpu option recognize the 'vulkan' parameter
'GpuParameters' are used for parsing the command-line, but are also passed through a tube. When that happens, the default serializer turns the 'wsi' member to "Vulkan", but the custom deserializer function expects 'vk' in order to build it properly. Fix this by making RutabagaWsi use the kebab-case for serializing/deserializing so it gets serialized into 'vulkan', and making the 'deserialize_wsi' function accept 'vulkan' as a valid option. BUG=b:218223240 TEST=cargo test --features "gpu" parse_gpu Change-Id: I831ddc623ff6b5ddd74dbfe82cf7ccc0f7647272 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3889322 Auto-Submit: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Pujun Lun <lunpujun@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
150384ad2d
commit
a11457c245
3 changed files with 10 additions and 3 deletions
|
@ -116,9 +116,11 @@ fn deserialize_wsi<'de, D: Deserializer<'de>>(
|
|||
|
||||
match s.as_str() {
|
||||
"vk" => Ok(Some(RutabagaWsi::Vulkan)),
|
||||
_ => Err(serde::de::Error::custom(
|
||||
"gpu parameter 'wsi' should be vk".to_string(),
|
||||
)),
|
||||
"vulkan" => Ok(Some(RutabagaWsi::Vulkan)),
|
||||
_ => Err(serde::de::Error::custom(format!(
|
||||
"unrecognized gpu parameter {} for 'wsi' option",
|
||||
s.as_str(),
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -428,6 +428,7 @@ const GFXSTREAM_RENDERER_FLAGS_ASYNC_FENCE_CB: u32 = 1 << 23;
|
|||
pub struct GfxstreamFlags(u32);
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum RutabagaWsi {
|
||||
Vulkan,
|
||||
}
|
||||
|
|
|
@ -565,6 +565,10 @@ mod tests {
|
|||
let gpu_params: GpuParameters = parse_gpu_options("backend=virglrenderer,wsi=vk").unwrap();
|
||||
assert!(matches!(gpu_params.wsi, Some(RutabagaWsi::Vulkan)));
|
||||
|
||||
let gpu_params: GpuParameters =
|
||||
parse_gpu_options("backend=virglrenderer,wsi=vulkan").unwrap();
|
||||
assert!(matches!(gpu_params.wsi, Some(RutabagaWsi::Vulkan)));
|
||||
|
||||
let gpu_params: GpuParameters = parse_gpu_options("wsi=vk,backend=virglrenderer").unwrap();
|
||||
assert!(matches!(gpu_params.wsi, Some(RutabagaWsi::Vulkan)));
|
||||
|
||||
|
|
Loading…
Reference in a new issue