Skip to content

Commit fcbdcca

Browse files
committed
Re-instate DMA read/write sync in MappedArray
This is required so that the data cache is flushed and the GPU can see any updates. The initial sync is also returned to read-only, so this effectively reverts commit c0cc32c. This also means it's not safe to alter image buffers in remote processes, though we can consider other ways to handle that. Signed-off-by: David Plowman <[email protected]>
1 parent 354f84f commit fcbdcca

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

picamera2/request.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ def __init__(self, request: "CompletedRequest", stream: str, write: bool = True)
3434
assert request.request is not None
3535
self.__fb = request.request.buffers[stream]
3636
self.__allocator = request.picam2.allocator
37-
self.__sync = None
38-
if self.__allocator.needs_sync:
39-
# This is just for legacy LibcameraAllocator, which you shouldn't really use.
40-
self.__sync = self.__allocator.sync(self.__allocator, self.__fb, write)
37+
self.__sync = self.__allocator.sync(self.__allocator, self.__fb, write)
4138

4239
def __enter__(self) -> Any:
4340
if self.__sync:
@@ -50,9 +47,7 @@ def __enter__(self) -> Any:
5047
return self.__mm
5148

5249
def __exit__(self, exc_type: Any, exc_value: Any, exc_traceback: Any) -> None:
53-
if self.__sync:
54-
# For legacy LibcameraAllocator, which you shouldn't be using.
55-
self.__sync.__exit__(exc_type, exc_value, exc_traceback)
50+
self.__sync.__exit__(exc_type, exc_value, exc_traceback)
5651

5752

5853
class MappedArray:
@@ -102,7 +97,7 @@ def __init__(self, request: Any, picam2: "Picamera2") -> None:
10297
self.config = self.picam2.camera_config.copy()
10398
self.stream_map = self.picam2.stream_map.copy()
10499
with self.lock:
105-
self.syncs = [picam2.allocator.sync(self.picam2.allocator, buffer, True)
100+
self.syncs = [picam2.allocator.sync(self.picam2.allocator, buffer, False)
106101
for buffer in self.request.buffers.values()]
107102
self.picam2.allocator.acquire(self.request.buffers)
108103
[sync.__enter__() for sync in self.syncs]

0 commit comments

Comments
 (0)