From b0c75a5b68bcd0aff12d7612f8f57a66f46d39e5 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 23 Nov 2017 15:52:29 -0500 Subject: [PATCH] Member rename: src/backend/metal --- src/backend/metal/BufferMTL.h | 6 +- src/backend/metal/BufferMTL.mm | 22 +++---- src/backend/metal/CommandBufferMTL.h | 4 +- src/backend/metal/CommandBufferMTL.mm | 60 +++++++++--------- src/backend/metal/ComputePipelineMTL.h | 4 +- src/backend/metal/ComputePipelineMTL.mm | 10 +-- src/backend/metal/DepthStencilStateMTL.h | 2 +- src/backend/metal/DepthStencilStateMTL.mm | 8 +-- src/backend/metal/InputStateMTL.h | 2 +- src/backend/metal/InputStateMTL.mm | 12 ++-- src/backend/metal/MetalBackend.h | 16 ++--- src/backend/metal/MetalBackend.mm | 74 +++++++++++------------ src/backend/metal/PipelineLayoutMTL.h | 2 +- src/backend/metal/PipelineLayoutMTL.mm | 8 +-- src/backend/metal/RenderPipelineMTL.h | 6 +- src/backend/metal/RenderPipelineMTL.mm | 14 ++--- src/backend/metal/ResourceUploader.h | 4 +- src/backend/metal/ResourceUploader.mm | 14 ++--- src/backend/metal/SamplerMTL.h | 2 +- src/backend/metal/SamplerMTL.mm | 6 +- src/backend/metal/ShaderModuleMTL.h | 2 +- src/backend/metal/ShaderModuleMTL.mm | 6 +- src/backend/metal/TextureMTL.h | 2 +- src/backend/metal/TextureMTL.mm | 10 +-- 24 files changed, 148 insertions(+), 148 deletions(-) diff --git a/src/backend/metal/BufferMTL.h b/src/backend/metal/BufferMTL.h index d14a79bfc7..9519c2893f 100644 --- a/src/backend/metal/BufferMTL.h +++ b/src/backend/metal/BufferMTL.h @@ -40,7 +40,7 @@ namespace metal { void UnmapImpl() override; void TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) override; - id mtlBuffer = nil; + id mMtlBuffer = nil; }; class BufferView : public BufferViewBase { @@ -57,14 +57,14 @@ namespace metal { void Tick(Serial finishedSerial); private: - Device* device; + Device* mDevice; struct Request { Ref buffer; uint32_t mapSerial; uint32_t offset; }; - SerialQueue inflightRequests; + SerialQueue mInflightRequests; }; } diff --git a/src/backend/metal/BufferMTL.mm b/src/backend/metal/BufferMTL.mm index 3a8c0bc2e0..bcc5ad0f8c 100644 --- a/src/backend/metal/BufferMTL.mm +++ b/src/backend/metal/BufferMTL.mm @@ -30,27 +30,27 @@ namespace metal { storageMode = MTLResourceStorageModePrivate; } - mtlBuffer = [ToBackend(GetDevice())->GetMTLDevice() newBufferWithLength:GetSize() + mMtlBuffer = [ToBackend(GetDevice())->GetMTLDevice() newBufferWithLength:GetSize() options:storageMode]; } Buffer::~Buffer() { - [mtlBuffer release]; - mtlBuffer = nil; + [mMtlBuffer release]; + mMtlBuffer = nil; } id Buffer::GetMTLBuffer() { - return mtlBuffer; + return mMtlBuffer; } void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, uint32_t offset) { - const char* data = reinterpret_cast([mtlBuffer contents]); + const char* data = reinterpret_cast([mMtlBuffer contents]); CallMapReadCallback(mapSerial, NXT_BUFFER_MAP_READ_STATUS_SUCCESS, data + offset); } void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) { auto* uploader = ToBackend(GetDevice())->GetResourceUploader(); - uploader->BufferSubData(mtlBuffer, start * sizeof(uint32_t), count * sizeof(uint32_t), data); + uploader->BufferSubData(mMtlBuffer, start * sizeof(uint32_t), count * sizeof(uint32_t), data); } void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t) { @@ -70,11 +70,11 @@ namespace metal { } MapReadRequestTracker::MapReadRequestTracker(Device* device) - : device(device) { + : mDevice(device) { } MapReadRequestTracker::~MapReadRequestTracker() { - ASSERT(inflightRequests.Empty()); + ASSERT(mInflightRequests.Empty()); } void MapReadRequestTracker::Track(Buffer* buffer, uint32_t mapSerial, uint32_t offset) { @@ -83,14 +83,14 @@ namespace metal { request.mapSerial = mapSerial; request.offset = offset; - inflightRequests.Enqueue(std::move(request), device->GetPendingCommandSerial()); + mInflightRequests.Enqueue(std::move(request), mDevice->GetPendingCommandSerial()); } void MapReadRequestTracker::Tick(Serial finishedSerial) { - for (auto& request : inflightRequests.IterateUpTo(finishedSerial)) { + for (auto& request : mInflightRequests.IterateUpTo(finishedSerial)) { request.buffer->OnMapReadCommandSerialFinished(request.mapSerial, request.offset); } - inflightRequests.ClearUpTo(finishedSerial); + mInflightRequests.ClearUpTo(finishedSerial); } } } diff --git a/src/backend/metal/CommandBufferMTL.h b/src/backend/metal/CommandBufferMTL.h index 2c390e38c1..e3e66f6d46 100644 --- a/src/backend/metal/CommandBufferMTL.h +++ b/src/backend/metal/CommandBufferMTL.h @@ -32,8 +32,8 @@ namespace metal { void FillCommands(id commandBuffer); private: - Device* device; - CommandIterator commands; + Device* mDevice; + CommandIterator mCommands; }; } diff --git a/src/backend/metal/CommandBufferMTL.mm b/src/backend/metal/CommandBufferMTL.mm index 95a2d9bcc5..9e326d3902 100644 --- a/src/backend/metal/CommandBufferMTL.mm +++ b/src/backend/metal/CommandBufferMTL.mm @@ -149,12 +149,12 @@ namespace metal { } CommandBuffer::CommandBuffer(CommandBufferBuilder* builder) - : CommandBufferBase(builder), device(ToBackend(builder->GetDevice())), - commands(builder->AcquireCommands()) { + : CommandBufferBase(builder), mDevice(ToBackend(builder->GetDevice())), + mCommands(builder->AcquireCommands()) { } CommandBuffer::~CommandBuffer() { - FreeCommands(&commands); + FreeCommands(&mCommands); } void CommandBuffer::FillCommands(id commandBuffer) { @@ -165,16 +165,16 @@ namespace metal { uint32_t indexBufferOffset = 0; CurrentEncoders encoders; - encoders.device = device; + encoders.device = mDevice; PerStage> pushConstants; uint32_t currentSubpass = 0; - while (commands.NextCommandId(&type)) { + while (mCommands.NextCommandId(&type)) { switch (type) { case Command::BeginComputePass: { - commands.NextCommand(); + mCommands.NextCommand(); encoders.BeginCompute(commandBuffer); pushConstants[nxt::ShaderStage::Compute].fill(0); @@ -186,7 +186,7 @@ namespace metal { case Command::BeginRenderPass: { - BeginRenderPassCmd* beginRenderPassCmd = commands.NextCommand(); + BeginRenderPassCmd* beginRenderPassCmd = mCommands.NextCommand(); encoders.currentRenderPass = ToBackend(beginRenderPassCmd->renderPass.Get()); encoders.currentFramebuffer = ToBackend(beginRenderPassCmd->framebuffer.Get()); encoders.EnsureNoBlitEncoder(); @@ -196,7 +196,7 @@ namespace metal { case Command::BeginRenderSubpass: { - commands.NextCommand(); + mCommands.NextCommand(); encoders.BeginSubpass(commandBuffer, currentSubpass); pushConstants[nxt::ShaderStage::Vertex].fill(0); @@ -213,7 +213,7 @@ namespace metal { case Command::CopyBufferToBuffer: { - CopyBufferToBufferCmd* copy = commands.NextCommand(); + CopyBufferToBufferCmd* copy = mCommands.NextCommand(); auto& src = copy->source; auto& dst = copy->destination; @@ -229,7 +229,7 @@ namespace metal { case Command::CopyBufferToTexture: { - CopyBufferToTextureCmd* copy = commands.NextCommand(); + CopyBufferToTextureCmd* copy = mCommands.NextCommand(); auto& src = copy->source; auto& dst = copy->destination; Buffer* buffer = ToBackend(src.buffer.Get()); @@ -261,7 +261,7 @@ namespace metal { case Command::CopyTextureToBuffer: { - CopyTextureToBufferCmd* copy = commands.NextCommand(); + CopyTextureToBufferCmd* copy = mCommands.NextCommand(); auto& src = copy->source; auto& dst = copy->destination; Texture* texture = ToBackend(src.texture.Get()); @@ -293,7 +293,7 @@ namespace metal { case Command::Dispatch: { - DispatchCmd* dispatch = commands.NextCommand(); + DispatchCmd* dispatch = mCommands.NextCommand(); ASSERT(encoders.compute); [encoders.compute dispatchThreadgroups:MTLSizeMake(dispatch->x, dispatch->y, dispatch->z) @@ -303,7 +303,7 @@ namespace metal { case Command::DrawArrays: { - DrawArraysCmd* draw = commands.NextCommand(); + DrawArraysCmd* draw = mCommands.NextCommand(); ASSERT(encoders.render); [encoders.render @@ -317,7 +317,7 @@ namespace metal { case Command::DrawElements: { - DrawElementsCmd* draw = commands.NextCommand(); + DrawElementsCmd* draw = mCommands.NextCommand(); ASSERT(encoders.render); [encoders.render @@ -334,20 +334,20 @@ namespace metal { case Command::EndComputePass: { - commands.NextCommand(); + mCommands.NextCommand(); encoders.EndCompute(); } break; case Command::EndRenderPass: { - commands.NextCommand(); + mCommands.NextCommand(); } break; case Command::EndRenderSubpass: { - commands.NextCommand(); + mCommands.NextCommand(); encoders.EndSubpass(); currentSubpass += 1; } @@ -355,7 +355,7 @@ namespace metal { case Command::SetComputePipeline: { - SetComputePipelineCmd* cmd = commands.NextCommand(); + SetComputePipelineCmd* cmd = mCommands.NextCommand(); lastComputePipeline = ToBackend(cmd->pipeline).Get(); ASSERT(encoders.compute); @@ -365,7 +365,7 @@ namespace metal { case Command::SetRenderPipeline: { - SetRenderPipelineCmd* cmd = commands.NextCommand(); + SetRenderPipelineCmd* cmd = mCommands.NextCommand(); lastRenderPipeline = ToBackend(cmd->pipeline).Get(); ASSERT(encoders.render); @@ -377,8 +377,8 @@ namespace metal { case Command::SetPushConstants: { - SetPushConstantsCmd* cmd = commands.NextCommand(); - uint32_t* values = commands.NextData(cmd->count); + SetPushConstantsCmd* cmd = mCommands.NextCommand(); + uint32_t* values = mCommands.NextData(cmd->count); for (auto stage : IterateStages(cmd->stages)) { memcpy(&pushConstants[stage][cmd->offset], values, cmd->count * sizeof(uint32_t)); @@ -412,7 +412,7 @@ namespace metal { case Command::SetStencilReference: { - SetStencilReferenceCmd* cmd = commands.NextCommand(); + SetStencilReferenceCmd* cmd = mCommands.NextCommand(); ASSERT(encoders.render); @@ -422,7 +422,7 @@ namespace metal { case Command::SetBlendColor: { - SetBlendColorCmd* cmd = commands.NextCommand(); + SetBlendColorCmd* cmd = mCommands.NextCommand(); ASSERT(encoders.render); @@ -436,7 +436,7 @@ namespace metal { case Command::SetBindGroup: { - SetBindGroupCmd* cmd = commands.NextCommand(); + SetBindGroupCmd* cmd = mCommands.NextCommand(); BindGroup* group = ToBackend(cmd->group.Get()); uint32_t groupIndex = cmd->index; @@ -550,7 +550,7 @@ namespace metal { case Command::SetIndexBuffer: { - SetIndexBufferCmd* cmd = commands.NextCommand(); + SetIndexBufferCmd* cmd = mCommands.NextCommand(); auto b = ToBackend(cmd->buffer.Get()); indexBuffer = b->GetMTLBuffer(); indexBufferOffset = cmd->offset; @@ -559,9 +559,9 @@ namespace metal { case Command::SetVertexBuffers: { - SetVertexBuffersCmd* cmd = commands.NextCommand(); - auto buffers = commands.NextData>(cmd->count); - auto offsets = commands.NextData(cmd->count); + SetVertexBuffersCmd* cmd = mCommands.NextCommand(); + auto buffers = mCommands.NextData>(cmd->count); + auto offsets = mCommands.NextData(cmd->count); std::array, kMaxVertexInputs> mtlBuffers; std::array mtlOffsets; @@ -584,7 +584,7 @@ namespace metal { case Command::TransitionBufferUsage: { - TransitionBufferUsageCmd* cmd = commands.NextCommand(); + TransitionBufferUsageCmd* cmd = mCommands.NextCommand(); cmd->buffer->UpdateUsageInternal(cmd->usage); } @@ -592,7 +592,7 @@ namespace metal { case Command::TransitionTextureUsage: { - TransitionTextureUsageCmd* cmd = commands.NextCommand(); + TransitionTextureUsageCmd* cmd = mCommands.NextCommand(); cmd->texture->UpdateUsageInternal(cmd->usage); } diff --git a/src/backend/metal/ComputePipelineMTL.h b/src/backend/metal/ComputePipelineMTL.h index fe14f07845..5af954259b 100644 --- a/src/backend/metal/ComputePipelineMTL.h +++ b/src/backend/metal/ComputePipelineMTL.h @@ -31,8 +31,8 @@ namespace metal { MTLSize GetLocalWorkGroupSize() const; private: - id mtlComputePipelineState = nil; - MTLSize localWorkgroupSize; + id mMtlComputePipelineState = nil; + MTLSize mLocalWorkgroupSize; }; } diff --git a/src/backend/metal/ComputePipelineMTL.mm b/src/backend/metal/ComputePipelineMTL.mm index da9551a566..ed067d855e 100644 --- a/src/backend/metal/ComputePipelineMTL.mm +++ b/src/backend/metal/ComputePipelineMTL.mm @@ -31,7 +31,7 @@ namespace metal { auto compilationData = module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout())); NSError *error = nil; - mtlComputePipelineState = [mtlDevice + mMtlComputePipelineState = [mtlDevice newComputePipelineStateWithFunction:compilationData.function error:&error]; if (error != nil) { NSLog(@" error => %@", error); @@ -40,19 +40,19 @@ namespace metal { } // Copy over the local workgroup size as it is passed to dispatch explicitly in Metal - localWorkgroupSize = compilationData.localWorkgroupSize; + mLocalWorkgroupSize = compilationData.localWorkgroupSize; } ComputePipeline::~ComputePipeline() { - [mtlComputePipelineState release]; + [mMtlComputePipelineState release]; } void ComputePipeline::Encode(id encoder) { - [encoder setComputePipelineState:mtlComputePipelineState]; + [encoder setComputePipelineState:mMtlComputePipelineState]; } MTLSize ComputePipeline::GetLocalWorkGroupSize() const { - return localWorkgroupSize; + return mLocalWorkgroupSize; } } diff --git a/src/backend/metal/DepthStencilStateMTL.h b/src/backend/metal/DepthStencilStateMTL.h index e8f3df7272..2208df0877 100644 --- a/src/backend/metal/DepthStencilStateMTL.h +++ b/src/backend/metal/DepthStencilStateMTL.h @@ -32,7 +32,7 @@ namespace metal { id GetMTLDepthStencilState(); private: - id mtlDepthStencilState = nil; + id mMtlDepthStencilState = nil; }; } diff --git a/src/backend/metal/DepthStencilStateMTL.mm b/src/backend/metal/DepthStencilStateMTL.mm index 7f35bd71ee..8b456e66f0 100644 --- a/src/backend/metal/DepthStencilStateMTL.mm +++ b/src/backend/metal/DepthStencilStateMTL.mm @@ -97,17 +97,17 @@ namespace metal { } auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice(); - mtlDepthStencilState = [mtlDevice newDepthStencilStateWithDescriptor:mtlDepthStencilDescriptor]; + mMtlDepthStencilState = [mtlDevice newDepthStencilStateWithDescriptor:mtlDepthStencilDescriptor]; [mtlDepthStencilDescriptor release]; } DepthStencilState::~DepthStencilState() { - [mtlDepthStencilState release]; - mtlDepthStencilState = nil; + [mMtlDepthStencilState release]; + mMtlDepthStencilState = nil; } id DepthStencilState::GetMTLDepthStencilState() { - return mtlDepthStencilState; + return mMtlDepthStencilState; } } diff --git a/src/backend/metal/InputStateMTL.h b/src/backend/metal/InputStateMTL.h index 771bf2b6eb..c9dd0963f5 100644 --- a/src/backend/metal/InputStateMTL.h +++ b/src/backend/metal/InputStateMTL.h @@ -30,7 +30,7 @@ namespace metal { MTLVertexDescriptor* GetMTLVertexDescriptor(); private: - MTLVertexDescriptor* mtlVertexDescriptor = nil; + MTLVertexDescriptor* mMtlVertexDescriptor = nil; }; } diff --git a/src/backend/metal/InputStateMTL.mm b/src/backend/metal/InputStateMTL.mm index d72f1c65fe..9bbfa43444 100644 --- a/src/backend/metal/InputStateMTL.mm +++ b/src/backend/metal/InputStateMTL.mm @@ -46,7 +46,7 @@ namespace metal { InputState::InputState(InputStateBuilder* builder) : InputStateBase(builder) { - mtlVertexDescriptor = [MTLVertexDescriptor new]; + mMtlVertexDescriptor = [MTLVertexDescriptor new]; const auto& attributesSetMask = GetAttributesSetMask(); for (uint32_t i = 0; i < attributesSetMask.size(); ++i) { @@ -59,7 +59,7 @@ namespace metal { attribDesc.format = VertexFormatType(info.format); attribDesc.offset = info.offset; attribDesc.bufferIndex = kMaxBindingsPerGroup + info.bindingSlot; - mtlVertexDescriptor.attributes[i] = attribDesc; + mMtlVertexDescriptor.attributes[i] = attribDesc; [attribDesc release]; } @@ -81,18 +81,18 @@ namespace metal { layoutDesc.stride = info.stride; } // TODO(cwallez@chromium.org): make the offset depend on the pipeline layout - mtlVertexDescriptor.layouts[kMaxBindingsPerGroup + i] = layoutDesc; + mMtlVertexDescriptor.layouts[kMaxBindingsPerGroup + i] = layoutDesc; [layoutDesc release]; } } InputState::~InputState() { - [mtlVertexDescriptor release]; - mtlVertexDescriptor = nil; + [mMtlVertexDescriptor release]; + mMtlVertexDescriptor = nil; } MTLVertexDescriptor* InputState::GetMTLVertexDescriptor() { - return mtlVertexDescriptor; + return mMtlVertexDescriptor; } } diff --git a/src/backend/metal/MetalBackend.h b/src/backend/metal/MetalBackend.h index d3e3048bc3..0f58bf4191 100644 --- a/src/backend/metal/MetalBackend.h +++ b/src/backend/metal/MetalBackend.h @@ -124,14 +124,14 @@ namespace metal { private: void OnCompletedHandler(); - id mtlDevice = nil; - id commandQueue = nil; - MapReadRequestTracker* mapReadTracker; - ResourceUploader* resourceUploader; + id mMtlDevice = nil; + id mCommandQueue = nil; + MapReadRequestTracker* mMapReadTracker; + ResourceUploader* mResourceUploader; - Serial finishedCommandSerial = 0; - Serial pendingCommandSerial = 1; - id pendingCommands = nil; + Serial mFinishedCommandSerial = 0; + Serial mPendingCommandSerial = 1; + id mPendingCommands = nil; }; class BindGroup : public BindGroupBase { @@ -161,7 +161,7 @@ namespace metal { void Submit(uint32_t numCommands, CommandBuffer* const * commands); private: - id commandQueue = nil; + id mCommandQueue = nil; }; class RenderPass : public RenderPassBase { diff --git a/src/backend/metal/MetalBackend.mm b/src/backend/metal/MetalBackend.mm index d2aaa00903..6053b969a3 100644 --- a/src/backend/metal/MetalBackend.mm +++ b/src/backend/metal/MetalBackend.mm @@ -45,10 +45,10 @@ namespace metal { // Device Device::Device(id mtlDevice) - : mtlDevice(mtlDevice), mapReadTracker(new MapReadRequestTracker(this)), - resourceUploader(new ResourceUploader(this)) { - [mtlDevice retain]; - commandQueue = [mtlDevice newCommandQueue]; + : mMtlDevice(mtlDevice), mMapReadTracker(new MapReadRequestTracker(this)), + mResourceUploader(new ResourceUploader(this)) { + [mMtlDevice retain]; + mCommandQueue = [mMtlDevice newCommandQueue]; } Device::~Device() { @@ -58,25 +58,25 @@ namespace metal { // SubmitPendingCommandBuffer then wait for it to be passed. Instead we submit and // wait for the serial before the next pendingCommandSerial. SubmitPendingCommandBuffer(); - while (finishedCommandSerial != pendingCommandSerial - 1) { + while (mFinishedCommandSerial != mPendingCommandSerial - 1) { usleep(100); } Tick(); - [pendingCommands release]; - pendingCommands = nil; + [mPendingCommands release]; + mPendingCommands = nil; - delete mapReadTracker; - mapReadTracker = nullptr; + delete mMapReadTracker; + mMapReadTracker = nullptr; - delete resourceUploader; - resourceUploader = nullptr; + delete mResourceUploader; + mResourceUploader = nullptr; - [mtlDevice release]; - mtlDevice = nil; + [mMtlDevice release]; + mMtlDevice = nil; - [commandQueue release]; - commandQueue = nil; + [mCommandQueue release]; + mCommandQueue = nil; } BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) { @@ -138,8 +138,8 @@ namespace metal { } void Device::TickImpl() { - resourceUploader->Tick(finishedCommandSerial); - mapReadTracker->Tick(finishedCommandSerial); + mResourceUploader->Tick(mFinishedCommandSerial); + mMapReadTracker->Tick(mFinishedCommandSerial); // Code above might have added GPU work, submit it. This also makes sure // that even when no GPU work is happening, the serial number keeps incrementing. @@ -147,34 +147,34 @@ namespace metal { } id Device::GetMTLDevice() { - return mtlDevice; + return mMtlDevice; } id Device::GetPendingCommandBuffer() { - if (pendingCommands == nil) { - pendingCommands = [commandQueue commandBuffer]; - [pendingCommands retain]; + if (mPendingCommands == nil) { + mPendingCommands = [mCommandQueue commandBuffer]; + [mPendingCommands retain]; } - return pendingCommands; + return mPendingCommands; } void Device::SubmitPendingCommandBuffer() { - if (pendingCommands == nil) { + if (mPendingCommands == nil) { return; } // Ok, ObjC blocks are weird. My understanding is that local variables are captured by value // so this-> works as expected. However it is unclear how members are captured, (are they // captured using this-> or by value?) so we make a copy of the pendingCommandSerial on the stack. - Serial pendingSerial = pendingCommandSerial; - [pendingCommands addCompletedHandler:^(id) { - this->finishedCommandSerial = pendingSerial; + Serial pendingSerial = mPendingCommandSerial; + [mPendingCommands addCompletedHandler:^(id) { + this->mFinishedCommandSerial = pendingSerial; }]; - [pendingCommands commit]; - [pendingCommands release]; - pendingCommands = nil; - pendingCommandSerial ++; + [mPendingCommands commit]; + [mPendingCommands release]; + mPendingCommands = nil; + mPendingCommandSerial ++; } uint64_t Device::GetPendingCommandSerial() { @@ -183,15 +183,15 @@ namespace metal { // enqueued on the next Tick() and eventually increments the serial. Otherwise if no GPU work // happens we could be waiting for this serial forever. GetPendingCommandBuffer(); - return pendingCommandSerial; + return mPendingCommandSerial; } MapReadRequestTracker* Device::GetMapReadTracker() const { - return mapReadTracker; + return mMapReadTracker; } ResourceUploader* Device::GetResourceUploader() const { - return resourceUploader; + return mResourceUploader; } // Bind Group @@ -220,16 +220,16 @@ namespace metal { Queue::Queue(QueueBuilder* builder) : QueueBase(builder) { Device* device = ToBackend(builder->GetDevice()); - commandQueue = [device->GetMTLDevice() newCommandQueue]; + mCommandQueue = [device->GetMTLDevice() newCommandQueue]; } Queue::~Queue() { - [commandQueue release]; - commandQueue = nil; + [mCommandQueue release]; + mCommandQueue = nil; } id Queue::GetMTLCommandQueue() { - return commandQueue; + return mCommandQueue; } void Queue::Submit(uint32_t numCommands, CommandBuffer* const * commands) { diff --git a/src/backend/metal/PipelineLayoutMTL.h b/src/backend/metal/PipelineLayoutMTL.h index 34b4fdadbc..4598e2a17c 100644 --- a/src/backend/metal/PipelineLayoutMTL.h +++ b/src/backend/metal/PipelineLayoutMTL.h @@ -36,7 +36,7 @@ namespace metal { const BindingIndexInfo& GetBindingIndexInfo(nxt::ShaderStage stage) const; private: - PerStage indexInfo; + PerStage mIndexInfo; }; } diff --git a/src/backend/metal/PipelineLayoutMTL.mm b/src/backend/metal/PipelineLayoutMTL.mm index 3714a3a2bd..749e3c9811 100644 --- a/src/backend/metal/PipelineLayoutMTL.mm +++ b/src/backend/metal/PipelineLayoutMTL.mm @@ -41,15 +41,15 @@ namespace metal { switch (groupInfo.types[binding]) { case nxt::BindingType::UniformBuffer: case nxt::BindingType::StorageBuffer: - indexInfo[stage][group][binding] = bufferIndex; + mIndexInfo[stage][group][binding] = bufferIndex; bufferIndex++; break; case nxt::BindingType::Sampler: - indexInfo[stage][group][binding] = samplerIndex; + mIndexInfo[stage][group][binding] = samplerIndex; samplerIndex++; break; case nxt::BindingType::SampledTexture: - indexInfo[stage][group][binding] = textureIndex; + mIndexInfo[stage][group][binding] = textureIndex; textureIndex++; break; } @@ -59,7 +59,7 @@ namespace metal { } const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo(nxt::ShaderStage stage) const { - return indexInfo[stage]; + return mIndexInfo[stage]; } } diff --git a/src/backend/metal/RenderPipelineMTL.h b/src/backend/metal/RenderPipelineMTL.h index c057dad47c..6233890b2b 100644 --- a/src/backend/metal/RenderPipelineMTL.h +++ b/src/backend/metal/RenderPipelineMTL.h @@ -33,9 +33,9 @@ namespace metal { void Encode(id encoder); private: - MTLIndexType mtlIndexType; - MTLPrimitiveType mtlPrimitiveTopology; - id mtlRenderPipelineState = nil; + MTLIndexType mMtlIndexType; + MTLPrimitiveType mMtlPrimitiveTopology; + id mMtlRenderPipelineState = nil; }; } diff --git a/src/backend/metal/RenderPipelineMTL.mm b/src/backend/metal/RenderPipelineMTL.mm index a8c93518a6..289fd31848 100644 --- a/src/backend/metal/RenderPipelineMTL.mm +++ b/src/backend/metal/RenderPipelineMTL.mm @@ -66,8 +66,8 @@ namespace metal { RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder) : RenderPipelineBase(builder), - mtlIndexType(MTLIndexFormat(GetIndexFormat())), - mtlPrimitiveTopology(MTLPrimitiveTopology(GetPrimitiveTopology())) { + mMtlIndexType(MTLIndexFormat(GetIndexFormat())), + mMtlPrimitiveTopology(MTLPrimitiveTopology(GetPrimitiveTopology())) { auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice(); @@ -116,7 +116,7 @@ namespace metal { // TODO(kainino@chromium.org): push constants, textures, samplers NSError *error = nil; - mtlRenderPipelineState = [mtlDevice + mMtlRenderPipelineState = [mtlDevice newRenderPipelineStateWithDescriptor:descriptor error:&error]; if (error != nil) { NSLog(@" error => %@", error); @@ -129,19 +129,19 @@ namespace metal { } RenderPipeline::~RenderPipeline() { - [mtlRenderPipelineState release]; + [mMtlRenderPipelineState release]; } MTLIndexType RenderPipeline::GetMTLIndexType() const { - return mtlIndexType; + return mMtlIndexType; } MTLPrimitiveType RenderPipeline::GetMTLPrimitiveTopology() const { - return mtlPrimitiveTopology; + return mMtlPrimitiveTopology; } void RenderPipeline::Encode(id encoder) { - [encoder setRenderPipelineState:mtlRenderPipelineState]; + [encoder setRenderPipelineState:mMtlRenderPipelineState]; } } diff --git a/src/backend/metal/ResourceUploader.h b/src/backend/metal/ResourceUploader.h index c95f74fd45..e87526d3d5 100644 --- a/src/backend/metal/ResourceUploader.h +++ b/src/backend/metal/ResourceUploader.h @@ -34,8 +34,8 @@ namespace metal { void Tick(Serial finishedSerial); private: - Device* device; - SerialQueue> inflightUploadBuffers; + Device* mDevice; + SerialQueue> mInflightUploadBuffers; }; diff --git a/src/backend/metal/ResourceUploader.mm b/src/backend/metal/ResourceUploader.mm index 058bfc6dc4..d0a58f3878 100644 --- a/src/backend/metal/ResourceUploader.mm +++ b/src/backend/metal/ResourceUploader.mm @@ -20,20 +20,20 @@ namespace backend { namespace metal { ResourceUploader::ResourceUploader(Device* device) - : device(device) { + : mDevice(device) { } ResourceUploader::~ResourceUploader() { - ASSERT(inflightUploadBuffers.Empty()); + ASSERT(mInflightUploadBuffers.Empty()); } void ResourceUploader::BufferSubData(id buffer, uint32_t start, uint32_t size, const void* data) { // TODO(cwallez@chromium.org) use a ringbuffer instead of creating a small buffer for each update - id uploadBuffer = [device->GetMTLDevice() newBufferWithLength:size + id uploadBuffer = [mDevice->GetMTLDevice() newBufferWithLength:size options:MTLResourceStorageModeShared]; memcpy([uploadBuffer contents], data, size); - id commandBuffer = device->GetPendingCommandBuffer(); + id commandBuffer = mDevice->GetPendingCommandBuffer(); id encoder = [commandBuffer blitCommandEncoder]; [encoder copyFromBuffer:uploadBuffer sourceOffset:0 @@ -42,14 +42,14 @@ namespace metal { size:size]; [encoder endEncoding]; - inflightUploadBuffers.Enqueue(uploadBuffer, device->GetPendingCommandSerial()); + mInflightUploadBuffers.Enqueue(uploadBuffer, mDevice->GetPendingCommandSerial()); } void ResourceUploader::Tick(Serial finishedSerial) { - for (id buffer : inflightUploadBuffers.IterateUpTo(finishedSerial)) { + for (id buffer : mInflightUploadBuffers.IterateUpTo(finishedSerial)) { [buffer release]; } - inflightUploadBuffers.ClearUpTo(finishedSerial); + mInflightUploadBuffers.ClearUpTo(finishedSerial); } } diff --git a/src/backend/metal/SamplerMTL.h b/src/backend/metal/SamplerMTL.h index 84b485d6e0..23a64f55f1 100644 --- a/src/backend/metal/SamplerMTL.h +++ b/src/backend/metal/SamplerMTL.h @@ -30,7 +30,7 @@ namespace metal { id GetMTLSamplerState(); private: - id mtlSamplerState = nil; + id mMtlSamplerState = nil; }; } diff --git a/src/backend/metal/SamplerMTL.mm b/src/backend/metal/SamplerMTL.mm index a3ef42c23f..84083434a3 100644 --- a/src/backend/metal/SamplerMTL.mm +++ b/src/backend/metal/SamplerMTL.mm @@ -49,15 +49,15 @@ namespace metal { // TODO(kainino@chromium.org): wrap modes auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice(); - mtlSamplerState = [mtlDevice newSamplerStateWithDescriptor:desc]; + mMtlSamplerState = [mtlDevice newSamplerStateWithDescriptor:desc]; } Sampler::~Sampler() { - [mtlSamplerState release]; + [mMtlSamplerState release]; } id Sampler::GetMTLSamplerState() { - return mtlSamplerState; + return mMtlSamplerState; } } diff --git a/src/backend/metal/ShaderModuleMTL.h b/src/backend/metal/ShaderModuleMTL.h index f74b78a341..984c9c5efd 100644 --- a/src/backend/metal/ShaderModuleMTL.h +++ b/src/backend/metal/ShaderModuleMTL.h @@ -42,7 +42,7 @@ namespace metal { // Calling compile on CompilerMSL somehow changes internal state that makes subsequent // compiles return invalid MSL. We keep the spirv around and recreate the compiler everytime // we need to use it. - std::vector spirv; + std::vector mSpirv; }; } diff --git a/src/backend/metal/ShaderModuleMTL.mm b/src/backend/metal/ShaderModuleMTL.mm index a3e6d83943..51645f74cd 100644 --- a/src/backend/metal/ShaderModuleMTL.mm +++ b/src/backend/metal/ShaderModuleMTL.mm @@ -42,14 +42,14 @@ namespace metal { } ShaderModule::ShaderModule(ShaderModuleBuilder* builder) - : ShaderModuleBase(builder), spirv(builder->AcquireSpirv()) { - spirv_cross::CompilerMSL compiler(spirv); + : ShaderModuleBase(builder), mSpirv(builder->AcquireSpirv()) { + spirv_cross::CompilerMSL compiler(mSpirv); ExtractSpirvInfo(compiler); } ShaderModule::MetalFunctionData ShaderModule::GetFunction(const char* functionName, const PipelineLayout* layout) const { - spirv_cross::CompilerMSL compiler(spirv); + spirv_cross::CompilerMSL compiler(mSpirv); // By default SPIRV-Cross will give MSL resources indices in increasing order. // To make the MSL indices match the indices chosen in the PipelineLayout, we build diff --git a/src/backend/metal/TextureMTL.h b/src/backend/metal/TextureMTL.h index 155f7507a7..04822b23bd 100644 --- a/src/backend/metal/TextureMTL.h +++ b/src/backend/metal/TextureMTL.h @@ -35,7 +35,7 @@ namespace metal { void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override; private: - id mtlTexture = nil; + id mMtlTexture = nil; }; class TextureView : public TextureViewBase { diff --git a/src/backend/metal/TextureMTL.mm b/src/backend/metal/TextureMTL.mm index f71cc5cf1b..00755de084 100644 --- a/src/backend/metal/TextureMTL.mm +++ b/src/backend/metal/TextureMTL.mm @@ -74,20 +74,20 @@ namespace metal { desc.storageMode = MTLStorageModePrivate; auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice(); - mtlTexture = [mtlDevice newTextureWithDescriptor:desc]; + mMtlTexture = [mtlDevice newTextureWithDescriptor:desc]; } Texture::Texture(TextureBuilder* builder, id mtlTexture) - : TextureBase(builder), mtlTexture(mtlTexture) { - [mtlTexture retain]; + : TextureBase(builder), mMtlTexture(mtlTexture) { + [mMtlTexture retain]; } Texture::~Texture() { - [mtlTexture release]; + [mMtlTexture release]; } id Texture::GetMTLTexture() { - return mtlTexture; + return mMtlTexture; } void Texture::TransitionUsageImpl(nxt::TextureUsageBit, nxt::TextureUsageBit) {