1// Copyright 2018 The Dawn Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15#include "dawn_native/metal/QueueMTL.h" 16 17#include "common/Math.h" 18#include "dawn_native/Buffer.h" 19#include "dawn_native/CommandValidation.h" 20#include "dawn_native/Commands.h" 21#include "dawn_native/DynamicUploader.h" 22#include "dawn_native/metal/CommandBufferMTL.h" 23#include "dawn_native/metal/DeviceMTL.h" 24#include "dawn_platform/DawnPlatform.h" 25#include "dawn_platform/tracing/TraceEvent.h" 26 27namespace dawn_native { namespace metal { 28 29 Queue::Queue(Device* device) : QueueBase(device) { 30 } 31 32 MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { 33 Device* device = ToBackend(GetDevice()); 34 35 DAWN_TRY(device->Tick()); 36 37 CommandRecordingContext* commandContext = device->GetPendingCommandContext(); 38 39 TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands"); 40 for (uint32_t i = 0; i < commandCount; ++i) { 41 DAWN_TRY(ToBackend(commands[i])->FillCommands(commandContext)); 42 } 43 TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands"); 44 45 return device->SubmitPendingCommandBuffer(); 46 } 47 48}} // namespace dawn_native::metal 49