Bug 1713162 - Detect copies into WebGPU swapchain for presentation r=jimb

Differential Revision: https://phabricator.services.mozilla.com/D116132
This commit is contained in:
Dzmitry Malyshau 2021-05-27 17:20:28 +00:00
Родитель bedc5ab3a3
Коммит 179d3960ce
2 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -133,6 +133,11 @@ void CommandEncoder::CopyBufferToTexture(
ConvertBufferCopyView(aSource), ConvertTextureCopyView(aDestination),
ConvertExtent(aCopySize), ToFFI(&bb));
mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb));
const auto& targetCanvas = aDestination.mTexture->mTargetCanvasElement;
if (targetCanvas) {
mTargetCanvases.AppendElement(targetCanvas);
}
}
}
void CommandEncoder::CopyTextureToBuffer(
@ -157,6 +162,11 @@ void CommandEncoder::CopyTextureToTexture(
ConvertTextureCopyView(aSource), ConvertTextureCopyView(aDestination),
ConvertExtent(aCopySize), ToFFI(&bb));
mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb));
const auto& targetCanvas = aDestination.mTexture->mTargetCanvasElement;
if (targetCanvas) {
mTargetCanvases.AppendElement(targetCanvas);
}
}
}

Просмотреть файл

@ -534,6 +534,9 @@ static void PresentCallback(ffi::WGPUBufferMapAsyncStatus status,
data->mQueuedBufferIds.pop_back();
data->mAvailableBufferIds.push_back(bufferId);
data->mBuffersLock.Unlock();
MOZ_LOG(
sLogger, LogLevel::Info,
("PresentCallback for buffer %" PRIu64 " status=%d\n", bufferId, status));
// copy the data
if (status == ffi::WGPUBufferMapAsyncStatus_Success) {
const auto bufferSize = data->mRowCount * data->mSourcePitch;
@ -596,10 +599,13 @@ ipc::IPCResult WebGPUParent::RecvSwapChainPresent(
} else {
bufferId = 0;
}
if (bufferId) {
data->mQueuedBufferIds.insert(data->mQueuedBufferIds.begin(), bufferId);
}
data->mBuffersLock.Unlock();
MOZ_LOG(sLogger, LogLevel::Info,
("RecvSwapChainPresent with buffer %" PRIu64 "\n", bufferId));
if (!bufferId) {
// TODO: add a warning - no buffer are available!
return IPC_OK();