mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-20 02:41:48 +00:00
This change implements timeline fences in Dawn. It includes methods and descriptor members to eventually support multi-queue, but does not implement them. Bug: dawn:26 Change-Id: I81d5fee6acef402fe099227a034d9669a89ab6c3 Reviewed-on: https://dawn-review.googlesource.com/c/2460 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
44 lines
1.6 KiB
C++
44 lines
1.6 KiB
C++
// Copyright 2018 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "dawn_native/FenceSignalTracker.h"
|
|
|
|
#include "dawn_native/Device.h"
|
|
#include "dawn_native/Fence.h"
|
|
|
|
namespace dawn_native {
|
|
|
|
FenceSignalTracker::FenceSignalTracker(DeviceBase* device) : mDevice(device) {
|
|
}
|
|
|
|
FenceSignalTracker::~FenceSignalTracker() {
|
|
ASSERT(mFencesInFlight.Empty());
|
|
}
|
|
|
|
void FenceSignalTracker::UpdateFenceOnComplete(FenceBase* fence, uint64_t value) {
|
|
// Because we currently only have a single queue, we can simply update
|
|
// the fence completed value once the last submitted serial has passed.
|
|
mFencesInFlight.Enqueue(FenceInFlight{fence, value},
|
|
mDevice->GetLastSubmittedCommandSerial());
|
|
}
|
|
|
|
void FenceSignalTracker::Tick(Serial finishedSerial) {
|
|
for (auto& fenceInFlight : mFencesInFlight.IterateUpTo(finishedSerial)) {
|
|
fenceInFlight.fence->SetCompletedValue(fenceInFlight.value);
|
|
}
|
|
mFencesInFlight.ClearUpTo(finishedSerial);
|
|
}
|
|
|
|
} // namespace dawn_native
|