GpuFenceMTLSharedEvent.cpp (1287B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "GpuFenceMTLSharedEvent.h" 8 9 #include "mozilla/gfx/Logging.h" 10 11 namespace mozilla { 12 namespace layers { 13 14 /* static */ 15 RefPtr<GpuFenceMTLSharedEvent> GpuFenceMTLSharedEvent::Create( 16 UniquePtr<webgpu::ffi::WGPUMetalSharedEventHandle>&& aSharedEventHandle, 17 const uint64_t aFenceValue) { 18 if (!aSharedEventHandle) { 19 MOZ_ASSERT_UNREACHABLE("unexpected to be called"); 20 return nullptr; 21 } 22 return new GpuFenceMTLSharedEvent(std::move(aSharedEventHandle), aFenceValue); 23 } 24 25 GpuFenceMTLSharedEvent::GpuFenceMTLSharedEvent( 26 UniquePtr<webgpu::ffi::WGPUMetalSharedEventHandle>&& aSharedEventHandle, 27 const uint64_t aFenceValue) 28 : mSharedEventHandle(std::move(aSharedEventHandle)), 29 mFenceValue(aFenceValue) {} 30 31 bool GpuFenceMTLSharedEvent::HasCompleted() { 32 auto value = 33 wgpu_server_metal_shared_event_signaled_value(mSharedEventHandle.get()); 34 return value >= mFenceValue; 35 } 36 37 } // namespace layers 38 } // namespace mozilla