diff --git a/src/backend/CMakeLists.txt b/src/backend/CMakeLists.txt index e9b2d8e285..88b19d5ce2 100644 --- a/src/backend/CMakeLists.txt +++ b/src/backend/CMakeLists.txt @@ -131,6 +131,8 @@ if (NXT_ENABLE_METAL) ${METAL_DIR}/InputStateMTL.h ${METAL_DIR}/PipelineLayoutMTL.mm ${METAL_DIR}/PipelineLayoutMTL.h + ${METAL_DIR}/QueueMTL.mm + ${METAL_DIR}/QueueMTL.h ${METAL_DIR}/RenderPipelineMTL.mm ${METAL_DIR}/RenderPipelineMTL.h ${METAL_DIR}/ResourceUploader.mm diff --git a/src/backend/metal/DeviceMTL.h b/src/backend/metal/DeviceMTL.h index cba124a635..d4e83a9445 100644 --- a/src/backend/metal/DeviceMTL.h +++ b/src/backend/metal/DeviceMTL.h @@ -18,7 +18,6 @@ #include "nxt/nxtcpp.h" #include "backend/Device.h" -#include "backend/Queue.h" #include "backend/metal/Forward.h" #include "common/Serial.h" @@ -82,14 +81,6 @@ namespace backend { namespace metal { id mPendingCommands = nil; }; - class Queue : public QueueBase { - public: - Queue(Device* device); - - // NXT API - void Submit(uint32_t numCommands, CommandBuffer* const* commands); - }; - }} // namespace backend::metal #endif // BACKEND_METAL_DEVICEMTL_H_ diff --git a/src/backend/metal/DeviceMTL.mm b/src/backend/metal/DeviceMTL.mm index 04defa87eb..4d61245030 100644 --- a/src/backend/metal/DeviceMTL.mm +++ b/src/backend/metal/DeviceMTL.mm @@ -1,4 +1,4 @@ -// Copyright 2017 The NXT Authors +// Copyright 2018 The NXT Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ #include "backend/metal/DepthStencilStateMTL.h" #include "backend/metal/InputStateMTL.h" #include "backend/metal/PipelineLayoutMTL.h" +#include "backend/metal/QueueMTL.h" #include "backend/metal/RenderPipelineMTL.h" #include "backend/metal/ResourceUploader.h" #include "backend/metal/SamplerMTL.h" @@ -193,21 +194,4 @@ namespace backend { namespace metal { return mResourceUploader; } - // Queue - - Queue::Queue(Device* device) : QueueBase(device) { - } - - void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { - Device* device = ToBackend(GetDevice()); - device->Tick(); - id commandBuffer = device->GetPendingCommandBuffer(); - - for (uint32_t i = 0; i < numCommands; ++i) { - commands[i]->FillCommands(commandBuffer); - } - - device->SubmitPendingCommandBuffer(); - } - }} // namespace backend::metal diff --git a/src/backend/metal/GeneratedCodeIncludes.h b/src/backend/metal/GeneratedCodeIncludes.h index 55afeb0efb..91175915b8 100644 --- a/src/backend/metal/GeneratedCodeIncludes.h +++ b/src/backend/metal/GeneratedCodeIncludes.h @@ -23,6 +23,7 @@ #include "backend/metal/DeviceMTL.h" #include "backend/metal/InputStateMTL.h" #include "backend/metal/PipelineLayoutMTL.h" +#include "backend/metal/QueueMTL.h" #include "backend/metal/RenderPipelineMTL.h" #include "backend/metal/SamplerMTL.h" #include "backend/metal/ShaderModuleMTL.h" diff --git a/src/backend/metal/QueueMTL.h b/src/backend/metal/QueueMTL.h new file mode 100644 index 0000000000..259e0f2cb5 --- /dev/null +++ b/src/backend/metal/QueueMTL.h @@ -0,0 +1,35 @@ +// Copyright 2018 The NXT 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. + +#ifndef BACKEND_METAL_QUEUEMTL_H_ +#define BACKEND_METAL_QUEUEMTL_H_ + +#include "backend/Queue.h" + +namespace backend { namespace metal { + + class CommandBuffer; + class Device; + + class Queue : public QueueBase { + public: + Queue(Device* device); + + // NXT API + void Submit(uint32_t numCommands, CommandBuffer* const* commands); + }; + +}} // namespace backend::metal + +#endif // BACKEND_METAL_QUEUEMTL_H_ diff --git a/src/backend/metal/QueueMTL.mm b/src/backend/metal/QueueMTL.mm new file mode 100644 index 0000000000..d026268be2 --- /dev/null +++ b/src/backend/metal/QueueMTL.mm @@ -0,0 +1,37 @@ +// Copyright 2018 The NXT 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 "backend/metal/QueueMTL.h" + +#include "backend/metal/CommandBufferMTL.h" +#include "backend/metal/DeviceMTL.h" + +namespace backend { namespace metal { + + Queue::Queue(Device* device) : QueueBase(device) { + } + + void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { + Device* device = ToBackend(GetDevice()); + device->Tick(); + id commandBuffer = device->GetPendingCommandBuffer(); + + for (uint32_t i = 0; i < numCommands; ++i) { + commands[i]->FillCommands(commandBuffer); + } + + device->SubmitPendingCommandBuffer(); + } + +}} // namespace backend::metal