Metal: Split off QueueMTL

This commit is contained in:
Corentin Wallez 2018-06-18 18:24:26 -04:00 committed by Corentin Wallez
parent 0f2e7b67c1
commit 1f51263672
6 changed files with 77 additions and 27 deletions

View File

@ -131,6 +131,8 @@ if (NXT_ENABLE_METAL)
${METAL_DIR}/InputStateMTL.h ${METAL_DIR}/InputStateMTL.h
${METAL_DIR}/PipelineLayoutMTL.mm ${METAL_DIR}/PipelineLayoutMTL.mm
${METAL_DIR}/PipelineLayoutMTL.h ${METAL_DIR}/PipelineLayoutMTL.h
${METAL_DIR}/QueueMTL.mm
${METAL_DIR}/QueueMTL.h
${METAL_DIR}/RenderPipelineMTL.mm ${METAL_DIR}/RenderPipelineMTL.mm
${METAL_DIR}/RenderPipelineMTL.h ${METAL_DIR}/RenderPipelineMTL.h
${METAL_DIR}/ResourceUploader.mm ${METAL_DIR}/ResourceUploader.mm

View File

@ -18,7 +18,6 @@
#include "nxt/nxtcpp.h" #include "nxt/nxtcpp.h"
#include "backend/Device.h" #include "backend/Device.h"
#include "backend/Queue.h"
#include "backend/metal/Forward.h" #include "backend/metal/Forward.h"
#include "common/Serial.h" #include "common/Serial.h"
@ -82,14 +81,6 @@ namespace backend { namespace metal {
id<MTLCommandBuffer> mPendingCommands = nil; id<MTLCommandBuffer> mPendingCommands = nil;
}; };
class Queue : public QueueBase {
public:
Queue(Device* device);
// NXT API
void Submit(uint32_t numCommands, CommandBuffer* const* commands);
};
}} // namespace backend::metal }} // namespace backend::metal
#endif // BACKEND_METAL_DEVICEMTL_H_ #endif // BACKEND_METAL_DEVICEMTL_H_

View File

@ -1,4 +1,4 @@
// Copyright 2017 The NXT Authors // Copyright 2018 The NXT Authors
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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/DepthStencilStateMTL.h"
#include "backend/metal/InputStateMTL.h" #include "backend/metal/InputStateMTL.h"
#include "backend/metal/PipelineLayoutMTL.h" #include "backend/metal/PipelineLayoutMTL.h"
#include "backend/metal/QueueMTL.h"
#include "backend/metal/RenderPipelineMTL.h" #include "backend/metal/RenderPipelineMTL.h"
#include "backend/metal/ResourceUploader.h" #include "backend/metal/ResourceUploader.h"
#include "backend/metal/SamplerMTL.h" #include "backend/metal/SamplerMTL.h"
@ -193,21 +194,4 @@ namespace backend { namespace metal {
return mResourceUploader; 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<MTLCommandBuffer> commandBuffer = device->GetPendingCommandBuffer();
for (uint32_t i = 0; i < numCommands; ++i) {
commands[i]->FillCommands(commandBuffer);
}
device->SubmitPendingCommandBuffer();
}
}} // namespace backend::metal }} // namespace backend::metal

View File

@ -23,6 +23,7 @@
#include "backend/metal/DeviceMTL.h" #include "backend/metal/DeviceMTL.h"
#include "backend/metal/InputStateMTL.h" #include "backend/metal/InputStateMTL.h"
#include "backend/metal/PipelineLayoutMTL.h" #include "backend/metal/PipelineLayoutMTL.h"
#include "backend/metal/QueueMTL.h"
#include "backend/metal/RenderPipelineMTL.h" #include "backend/metal/RenderPipelineMTL.h"
#include "backend/metal/SamplerMTL.h" #include "backend/metal/SamplerMTL.h"
#include "backend/metal/ShaderModuleMTL.h" #include "backend/metal/ShaderModuleMTL.h"

View File

@ -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_

View File

@ -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<MTLCommandBuffer> commandBuffer = device->GetPendingCommandBuffer();
for (uint32_t i = 0; i < numCommands; ++i) {
commands[i]->FillCommands(commandBuffer);
}
device->SubmitPendingCommandBuffer();
}
}} // namespace backend::metal