// 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. #ifndef DAWNNATIVE_METAL_DEVICEMTL_H_ #define DAWNNATIVE_METAL_DEVICEMTL_H_ #include "dawn_native/dawn_platform.h" #include "common/Serial.h" #include "dawn_native/Device.h" #include "dawn_native/metal/Forward.h" #import #import #include #include namespace dawn_native { namespace metal { class MapRequestTracker; class ResourceUploader; class Device : public DeviceBase { public: Device(id mtlDevice); ~Device(); CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override; InputStateBase* CreateInputState(InputStateBuilder* builder) override; RenderPassDescriptorBase* CreateRenderPassDescriptor( RenderPassDescriptorBuilder* builder) override; SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override; Serial GetCompletedCommandSerial() const final override; Serial GetLastSubmittedCommandSerial() const final override; void TickImpl() override; const dawn_native::PCIInfo& GetPCIInfo() const override; id GetMTLDevice(); id GetPendingCommandBuffer(); Serial GetPendingCommandSerial() const; void SubmitPendingCommandBuffer(); MapRequestTracker* GetMapTracker() const; ResourceUploader* GetResourceUploader() const; private: ResultOrError CreateBindGroupImpl( const BindGroupDescriptor* descriptor) override; ResultOrError CreateBindGroupLayoutImpl( const BindGroupLayoutDescriptor* descriptor) override; ResultOrError CreateBufferImpl(const BufferDescriptor* descriptor) override; ResultOrError CreateComputePipelineImpl( const ComputePipelineDescriptor* descriptor) override; ResultOrError CreatePipelineLayoutImpl( const PipelineLayoutDescriptor* descriptor) override; ResultOrError CreateQueueImpl() override; ResultOrError CreateRenderPipelineImpl( const RenderPipelineDescriptor* descriptor) override; ResultOrError CreateSamplerImpl(const SamplerDescriptor* descriptor) override; ResultOrError CreateShaderModuleImpl( const ShaderModuleDescriptor* descriptor) override; ResultOrError CreateTextureImpl(const TextureDescriptor* descriptor) override; ResultOrError CreateTextureViewImpl( TextureBase* texture, const TextureViewDescriptor* descriptor) override; void CollectPCIInfo(); void OnCompletedHandler(); id mMtlDevice = nil; id mCommandQueue = nil; std::unique_ptr mMapTracker; std::unique_ptr mResourceUploader; Serial mCompletedSerial = 0; Serial mLastSubmittedSerial = 0; id mPendingCommands = nil; dawn_native::PCIInfo mPCIInfo; }; }} // namespace dawn_native::metal #endif // DAWNNATIVE_METAL_DEVICEMTL_H_