gpu: make process_descriptor return Option

In preparation of adding fence support, allow process_descriptor to
defer returning the descriptor until later by returning None.

BUG=None
TEST=build with --features=gpu; null_platform_test

Change-Id: I57e4dc438e7f5a925c870e0bd596f89a2ed4e083
Reviewed-on: https://chromium-review.googlesource.com/1073957
Commit-Ready: David Riley <davidriley@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
David Riley 2018-05-17 17:03:13 -07:00 committed by chrome-bot
parent af9d7edfb7
commit 4cbaeb7eaa

View file

@ -338,7 +338,9 @@ impl Frontend {
&mut self.return_cursor_descriptors); &mut self.return_cursor_descriptors);
} }
fn process_descriptor(&mut self, mem: &GuestMemory, desc: QueueDescriptor) -> ReturnDescriptor { fn process_descriptor(&mut self,
mem: &GuestMemory,
desc: QueueDescriptor) -> Option<ReturnDescriptor> {
let mut resp = GpuResponse::ErrUnspec; let mut resp = GpuResponse::ErrUnspec;
let mut gpu_cmd = None; let mut gpu_cmd = None;
let mut len = 0; let mut len = 0;
@ -384,10 +386,10 @@ impl Frontend {
} }
} }
} }
ReturnDescriptor { Some(ReturnDescriptor {
index: desc.index, index: desc.index,
len, len,
} })
} }
fn process_ctrl(&mut self, mem: &GuestMemory) -> Option<ReturnDescriptor> { fn process_ctrl(&mut self, mem: &GuestMemory) -> Option<ReturnDescriptor> {
@ -396,7 +398,7 @@ impl Frontend {
.or_else(|| { .or_else(|| {
self.ctrl_descriptors self.ctrl_descriptors
.pop_front() .pop_front()
.map(|desc| self.process_descriptor(mem, desc)) .and_then(|desc| self.process_descriptor(mem, desc))
}) })
} }
@ -406,7 +408,7 @@ impl Frontend {
.or_else(|| { .or_else(|| {
self.cursor_descriptors self.cursor_descriptors
.pop_front() .pop_front()
.map(|desc| self.process_descriptor(mem, desc)) .and_then(|desc| self.process_descriptor(mem, desc))
}) })
} }
} }