OSDN Git Service

surfaceflinger: discard stale commands
authorChia-I Wu <olv@google.com>
Thu, 22 Jun 2017 17:48:28 +0000 (10:48 -0700)
committerChia-I Wu <olv@google.com>
Thu, 22 Jun 2017 19:01:07 +0000 (19:01 +0000)
When we skip validate, we may have stale commands on the command
buffer.  They should be discarded.

Bug: 62906801
Test: manual
Change-Id: Ie7921ba75ab2252b834cda6924e1fcfdf236f759

services/surfaceflinger/DisplayHardware/HWC2.cpp
services/surfaceflinger/DisplayHardware/HWC2.h
services/surfaceflinger/DisplayHardware/HWComposer.cpp

index 95689d9..c48a28f 100644 (file)
@@ -717,6 +717,12 @@ Error Display::presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests
     }
     return error;
 }
+
+void Display::discardCommands()
+{
+    mDevice.mComposer->resetCommands();
+}
+
 // For use by Device
 
 int32_t Display::getAttribute(hwc2_config_t configId, Attribute attribute)
index 4d9155c..7463e3b 100644 (file)
@@ -259,6 +259,12 @@ public:
                                                  uint32_t* outNumRequests,
                                                           android::sp<android::Fence>* outPresentFence, uint32_t* state);
 
+    // Most methods in this class write a command to a command buffer.  The
+    // command buffer is implicitly submitted in validate, present, and
+    // presentOrValidate.  This method provides a way to discard the commands,
+    // which can be used to discard stale commands.
+    void discardCommands();
+
     // Other Display methods
 
     Device& getDevice() const { return mDevice; }
index 913c43f..8c28fae 100644 (file)
@@ -620,6 +620,7 @@ status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) {
     auto& hwcDisplay = displayData.hwcDisplay;
 
     if (displayData.validateWasSkipped) {
+        hwcDisplay->discardCommands();
         auto error = displayData.presentError;
         if (error != HWC2::Error::None) {
             ALOGE("skipValidate: failed for display %d: %s (%d)",