- a/Source/ThirdParty/ANGLE/ChangeLog +19 lines
Lines 1-3 a/Source/ThirdParty/ANGLE/ChangeLog_sec1
1
2021-11-09  Kyle Piddington  <kpiddington@apple.com>
2
3
        Upstream: Fix occlusion query buffer synchronization in angle end2end tests
4
        https://bugs.webkit.org/show_bug.cgi?id=232905
5
6
	Ensure that GPU synchronization is flushed before
7
	we try to readback from a buffer. Only impacts
8
	macOS.
9
10
        Reviewed by NOBODY (OOPS!).
11
12
        * src/libANGLE/renderer/metal/mtl_resources.h:
13
        (rx::mtl::Resource::isCPUReadMemSyncPending const):
14
        (rx::mtl::Resource::setCPUReadMemSyncPending const):
15
        (rx::mtl::Resource::resetCPUReadMemSyncPending):
16
        * src/libANGLE/renderer/metal/mtl_resources.mm:
17
        (rx::mtl::Resource::reset):
18
        (rx::mtl::Buffer::mapWithOpt):
19
1
2021-10-27  Kimmo Kinnunen  <kkinnunen@apple.com>
20
2021-10-27  Kimmo Kinnunen  <kkinnunen@apple.com>
2
21
3
        REGRESSION (Safari 15): Poor WebGL performance on https://downloads.scirra.com/labs/particles
22
        REGRESSION (Safari 15): Poor WebGL performance on https://downloads.scirra.com/labs/particles
- a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.h +9 lines
Lines 63-68 class Resource : angle::NonCopyable a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.h_sec1
63
    bool isCPUReadMemNeedSync() const { return mUsageRef->cpuReadMemNeedSync; }
63
    bool isCPUReadMemNeedSync() const { return mUsageRef->cpuReadMemNeedSync; }
64
    void resetCPUReadMemNeedSync() { mUsageRef->cpuReadMemNeedSync = false; }
64
    void resetCPUReadMemNeedSync() { mUsageRef->cpuReadMemNeedSync = false; }
65
65
66
    bool isCPUReadMemSyncPending() const { return mUsageRef->cpuReadMemSyncPending; }
67
    void setCPUReadMemSyncPending(bool value) const { mUsageRef->cpuReadMemSyncPending = value; }
68
    void resetCPUReadMemSyncPending() { mUsageRef->cpuReadMemSyncPending = false; }
69
    
66
    bool isCPUReadMemDirty() const { return mUsageRef->cpuReadMemDirty; }
70
    bool isCPUReadMemDirty() const { return mUsageRef->cpuReadMemDirty; }
67
    void resetCPUReadMemDirty() { mUsageRef->cpuReadMemDirty = false; }
71
    void resetCPUReadMemDirty() { mUsageRef->cpuReadMemDirty = false; }
68
72
Lines 82-87 class Resource : angle::NonCopyable a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.h_sec2
82
        // This flag means the resource was issued to be modified by GPU, if CPU wants to read
86
        // This flag means the resource was issued to be modified by GPU, if CPU wants to read
83
        // its content, explicit synchornization call must be invoked.
87
        // its content, explicit synchornization call must be invoked.
84
        bool cpuReadMemNeedSync = false;
88
        bool cpuReadMemNeedSync = false;
89
        
90
        // This flag is set when synchronization for the resource has been
91
         // encoded on the GPU, and a map operation must wait
92
         // until it's completed.
93
         bool cpuReadMemSyncPending = false;
85
94
86
        // This flag is useful for BufferMtl to know whether it should update the shadow copy
95
        // This flag is useful for BufferMtl to know whether it should update the shadow copy
87
        bool cpuReadMemDirty = false;
96
        bool cpuReadMemDirty = false;
- a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.mm -1 / +5 lines
Lines 44-49 void SyncContent(ContextMtl *context, a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.mm_sec1
44
        blitEncoder->synchronizeResource(resource);
44
        blitEncoder->synchronizeResource(resource);
45
45
46
        resource->resetCPUReadMemNeedSync();
46
        resource->resetCPUReadMemNeedSync();
47
        resource->setCPUReadMemSyncPending(true);
47
    }
48
    }
48
#endif
49
#endif
49
}
50
}
Lines 61-66 void EnsureContentSynced(ContextMtl *context, const std::shared_ptr<T> &resource a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.mm_sec2
61
        SyncContent(context, blitEncoder, resource);
62
        SyncContent(context, blitEncoder, resource);
62
    }
63
    }
63
#endif
64
#endif
65
    resource->resetCPUReadMemNeedSync();
64
}
66
}
65
67
66
}  // namespace
68
}  // namespace
Lines 78-83 void Resource::reset() a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.mm_sec3
78
    mUsageRef->cmdBufferQueueSerial = 0;
80
    mUsageRef->cmdBufferQueueSerial = 0;
79
    resetCPUReadMemDirty();
81
    resetCPUReadMemDirty();
80
    resetCPUReadMemNeedSync();
82
    resetCPUReadMemNeedSync();
83
    resetCPUReadMemSyncPending();
81
}
84
}
82
85
83
bool Resource::isBeingUsedByGPU(Context *context) const
86
bool Resource::isBeingUsedByGPU(Context *context) const
Lines 1000-1006 uint8_t *Buffer::mapWithOpt(ContextMtl *context, bool readonly, bool noSync) a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.mm_sec4
1000
{
1003
{
1001
    mMapReadOnly = readonly;
1004
    mMapReadOnly = readonly;
1002
1005
1003
    if (!noSync && (isCPUReadMemNeedSync() || !readonly))
1006
    if (!noSync && (isCPUReadMemSyncPending() || isCPUReadMemNeedSync() || !readonly))
1004
    {
1007
    {
1005
        CommandQueue &cmdQueue = context->cmdQueue();
1008
        CommandQueue &cmdQueue = context->cmdQueue();
1006
1009
Lines 1012-1017 uint8_t *Buffer::mapWithOpt(ContextMtl *context, bool readonly, bool noSync) a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_resources.mm_sec5
1012
        }
1015
        }
1013
1016
1014
        cmdQueue.ensureResourceReadyForCPU(this);
1017
        cmdQueue.ensureResourceReadyForCPU(this);
1018
        resetCPUReadMemSyncPending();
1015
    }
1019
    }
1016
1020
1017
    return reinterpret_cast<uint8_t *>([get() contents]);
1021
    return reinterpret_cast<uint8_t *>([get() contents]);

Return to Bug 232905