diff --git a/src/backend/d3d12/BindGroupD3D12.cpp b/src/backend/d3d12/BindGroupD3D12.cpp index 4367cc5c12..f572aff9a8 100644 --- a/src/backend/d3d12/BindGroupD3D12.cpp +++ b/src/backend/d3d12/BindGroupD3D12.cpp @@ -25,22 +25,22 @@ namespace backend { namespace d3d12 { BindGroup::BindGroup(Device* device, BindGroupBuilder* builder) - : BindGroupBase(builder), device(device) { + : BindGroupBase(builder), mDevice(device) { } void BindGroup::RecordDescriptors(const DescriptorHeapHandle &cbvUavSrvHeapStart, uint32_t* cbvUavSrvHeapOffset, const DescriptorHeapHandle &samplerHeapStart, uint32_t* samplerHeapOffset, uint64_t serial) { - heapSerial = serial; + mHeapSerial = serial; const auto* bgl = ToBackend(GetLayout()); const auto& layout = bgl->GetBindingInfo(); // Save the offset to the start of the descriptor table in the heap - this->cbvUavSrvHeapOffset = *cbvUavSrvHeapOffset; - this->samplerHeapOffset = *samplerHeapOffset; + mCbvUavSrvHeapOffset = *cbvUavSrvHeapOffset; + mSamplerHeapOffset = *samplerHeapOffset; const auto& bindingOffsets = bgl->GetBindingOffsets(); - auto d3d12Device = device->GetD3D12Device(); + auto d3d12Device = mDevice->GetD3D12Device(); for (uint32_t binding : IterateBitSet(layout.mask)) { switch (layout.types[binding]) { case nxt::BindingType::UniformBuffer: @@ -80,15 +80,15 @@ namespace d3d12 { } uint32_t BindGroup::GetCbvUavSrvHeapOffset() const { - return cbvUavSrvHeapOffset; + return mCbvUavSrvHeapOffset; } uint32_t BindGroup::GetSamplerHeapOffset() const { - return samplerHeapOffset; + return mSamplerHeapOffset; } uint64_t BindGroup::GetHeapSerial() const { - return heapSerial; + return mHeapSerial; } } diff --git a/src/backend/d3d12/BindGroupD3D12.h b/src/backend/d3d12/BindGroupD3D12.h index 4b38c8632d..5f366621d0 100644 --- a/src/backend/d3d12/BindGroupD3D12.h +++ b/src/backend/d3d12/BindGroupD3D12.h @@ -36,12 +36,12 @@ namespace d3d12 { uint64_t GetHeapSerial() const; private: - Device* device; - uint32_t cbvUavSrvHeapOffset; - uint32_t samplerHeapOffset; - uint32_t cbvUavSrvCount = 0; - uint32_t samplerCount = 0; - uint64_t heapSerial = 0; + Device* mDevice; + uint32_t mCbvUavSrvHeapOffset; + uint32_t mSamplerHeapOffset; + uint32_t mCbvUavSrvCount = 0; + uint32_t mSamplerCount = 0; + uint64_t mHeapSerial = 0; }; } diff --git a/src/backend/d3d12/BindGroupLayoutD3D12.cpp b/src/backend/d3d12/BindGroupLayoutD3D12.cpp index 65db74bd22..38b68c077f 100644 --- a/src/backend/d3d12/BindGroupLayoutD3D12.cpp +++ b/src/backend/d3d12/BindGroupLayoutD3D12.cpp @@ -21,23 +21,23 @@ namespace backend { namespace d3d12 { BindGroupLayout::BindGroupLayout(Device* device, BindGroupLayoutBuilder* builder) - : BindGroupLayoutBase(builder), device(device), descriptorCounts {} { + : BindGroupLayoutBase(builder), mDevice(device), mDescriptorCounts {} { const auto& groupInfo = GetBindingInfo(); for (uint32_t binding : IterateBitSet(groupInfo.mask)) { switch (groupInfo.types[binding]) { case nxt::BindingType::UniformBuffer: - bindingOffsets[binding] = descriptorCounts[CBV]++; + mBindingOffsets[binding] = mDescriptorCounts[CBV]++; break; case nxt::BindingType::StorageBuffer: - bindingOffsets[binding] = descriptorCounts[UAV]++; + mBindingOffsets[binding] = mDescriptorCounts[UAV]++; break; case nxt::BindingType::SampledTexture: - bindingOffsets[binding] = descriptorCounts[SRV]++; + mBindingOffsets[binding] = mDescriptorCounts[SRV]++; break; case nxt::BindingType::Sampler: - bindingOffsets[binding] = descriptorCounts[Sampler]++; + mBindingOffsets[binding] = mDescriptorCounts[Sampler]++; break; } } @@ -47,7 +47,7 @@ namespace d3d12 { return false; } - auto& range = ranges[index]; + auto& range = mRanges[index]; range.RangeType = type; range.NumDescriptors = count; range.RegisterSpace = 0; @@ -60,72 +60,72 @@ namespace d3d12 { // Ranges 0-2 contain the CBV, UAV, and SRV ranges, if they exist, tightly packed // Range 3 contains the Sampler range, if there is one - if (SetDescriptorRange(rangeIndex, descriptorCounts[CBV], D3D12_DESCRIPTOR_RANGE_TYPE_CBV)) { + if (SetDescriptorRange(rangeIndex, mDescriptorCounts[CBV], D3D12_DESCRIPTOR_RANGE_TYPE_CBV)) { rangeIndex++; } - if (SetDescriptorRange(rangeIndex, descriptorCounts[UAV], D3D12_DESCRIPTOR_RANGE_TYPE_UAV)) { + if (SetDescriptorRange(rangeIndex, mDescriptorCounts[UAV], D3D12_DESCRIPTOR_RANGE_TYPE_UAV)) { rangeIndex++; } - if (SetDescriptorRange(rangeIndex, descriptorCounts[SRV], D3D12_DESCRIPTOR_RANGE_TYPE_SRV)) { + if (SetDescriptorRange(rangeIndex, mDescriptorCounts[SRV], D3D12_DESCRIPTOR_RANGE_TYPE_SRV)) { rangeIndex++; } - SetDescriptorRange(Sampler, descriptorCounts[Sampler], D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER); + SetDescriptorRange(Sampler, mDescriptorCounts[Sampler], D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER); // descriptors ranges are offset by the offset + size of the previous range std::array descriptorOffsets; descriptorOffsets[CBV] = 0; - descriptorOffsets[UAV] = descriptorOffsets[CBV] + descriptorCounts[CBV]; - descriptorOffsets[SRV] = descriptorOffsets[UAV] + descriptorCounts[UAV]; + descriptorOffsets[UAV] = descriptorOffsets[CBV] + mDescriptorCounts[CBV]; + descriptorOffsets[SRV] = descriptorOffsets[UAV] + mDescriptorCounts[UAV]; descriptorOffsets[Sampler] = 0; // samplers are in a different heap for (uint32_t binding : IterateBitSet(groupInfo.mask)) { switch (groupInfo.types[binding]) { case nxt::BindingType::UniformBuffer: - bindingOffsets[binding] += descriptorOffsets[CBV]; + mBindingOffsets[binding] += descriptorOffsets[CBV]; break; case nxt::BindingType::StorageBuffer: - bindingOffsets[binding] += descriptorOffsets[UAV]; + mBindingOffsets[binding] += descriptorOffsets[UAV]; break; case nxt::BindingType::SampledTexture: - bindingOffsets[binding] += descriptorOffsets[SRV]; + mBindingOffsets[binding] += descriptorOffsets[SRV]; break; case nxt::BindingType::Sampler: - bindingOffsets[binding] += descriptorOffsets[Sampler]; + mBindingOffsets[binding] += descriptorOffsets[Sampler]; break; } } } const std::array& BindGroupLayout::GetBindingOffsets() const { - return bindingOffsets; + return mBindingOffsets; } uint32_t BindGroupLayout::GetCbvUavSrvDescriptorTableSize() const { return ( - static_cast(descriptorCounts[CBV] > 0) + - static_cast(descriptorCounts[UAV] > 0) + - static_cast(descriptorCounts[SRV] > 0) + static_cast(mDescriptorCounts[CBV] > 0) + + static_cast(mDescriptorCounts[UAV] > 0) + + static_cast(mDescriptorCounts[SRV] > 0) ); } uint32_t BindGroupLayout::GetSamplerDescriptorTableSize() const { - return descriptorCounts[Sampler] > 0; + return mDescriptorCounts[Sampler] > 0; } uint32_t BindGroupLayout::GetCbvUavSrvDescriptorCount() const { - return descriptorCounts[CBV] + descriptorCounts[UAV] + descriptorCounts[SRV]; + return mDescriptorCounts[CBV] + mDescriptorCounts[UAV] + mDescriptorCounts[SRV]; } uint32_t BindGroupLayout::GetSamplerDescriptorCount() const { - return descriptorCounts[Sampler]; + return mDescriptorCounts[Sampler]; } const D3D12_DESCRIPTOR_RANGE* BindGroupLayout::GetCbvUavSrvDescriptorRanges() const { - return ranges; + return mRanges; } const D3D12_DESCRIPTOR_RANGE* BindGroupLayout::GetSamplerDescriptorRanges() const { - return &ranges[Sampler]; + return &mRanges[Sampler]; } } diff --git a/src/backend/d3d12/BindGroupLayoutD3D12.h b/src/backend/d3d12/BindGroupLayoutD3D12.h index 96bd2ec0d4..c4a57b6388 100644 --- a/src/backend/d3d12/BindGroupLayoutD3D12.h +++ b/src/backend/d3d12/BindGroupLayoutD3D12.h @@ -45,10 +45,10 @@ namespace d3d12 { const D3D12_DESCRIPTOR_RANGE* GetSamplerDescriptorRanges() const; private: - Device* device; - std::array bindingOffsets; - std::array descriptorCounts; - D3D12_DESCRIPTOR_RANGE ranges[DescriptorType::Count]; + Device* mDevice; + std::array mBindingOffsets; + std::array mDescriptorCounts; + D3D12_DESCRIPTOR_RANGE mRanges[DescriptorType::Count]; }; } diff --git a/src/backend/d3d12/BlendStateD3D12.cpp b/src/backend/d3d12/BlendStateD3D12.cpp index c1176219ca..c0ac790361 100644 --- a/src/backend/d3d12/BlendStateD3D12.cpp +++ b/src/backend/d3d12/BlendStateD3D12.cpp @@ -82,20 +82,20 @@ namespace d3d12 { BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) { auto& info = GetBlendInfo(); - blendDesc.BlendEnable = info.blendEnabled; - blendDesc.SrcBlend = D3D12Blend(info.colorBlend.srcFactor); - blendDesc.DestBlend = D3D12Blend(info.colorBlend.dstFactor); - blendDesc.BlendOp = D3D12BlendOperation(info.colorBlend.operation); - blendDesc.SrcBlendAlpha = D3D12Blend(info.alphaBlend.srcFactor); - blendDesc.DestBlendAlpha = D3D12Blend(info.alphaBlend.dstFactor); - blendDesc.BlendOpAlpha = D3D12BlendOperation(info.alphaBlend.operation); - blendDesc.RenderTargetWriteMask = D3D12RenderTargetWriteMask(info.colorWriteMask); - blendDesc.LogicOpEnable = false; - blendDesc.LogicOp = D3D12_LOGIC_OP_NOOP; + mBlendDesc.BlendEnable = info.blendEnabled; + mBlendDesc.SrcBlend = D3D12Blend(info.colorBlend.srcFactor); + mBlendDesc.DestBlend = D3D12Blend(info.colorBlend.dstFactor); + mBlendDesc.BlendOp = D3D12BlendOperation(info.colorBlend.operation); + mBlendDesc.SrcBlendAlpha = D3D12Blend(info.alphaBlend.srcFactor); + mBlendDesc.DestBlendAlpha = D3D12Blend(info.alphaBlend.dstFactor); + mBlendDesc.BlendOpAlpha = D3D12BlendOperation(info.alphaBlend.operation); + mBlendDesc.RenderTargetWriteMask = D3D12RenderTargetWriteMask(info.colorWriteMask); + mBlendDesc.LogicOpEnable = false; + mBlendDesc.LogicOp = D3D12_LOGIC_OP_NOOP; } const D3D12_RENDER_TARGET_BLEND_DESC& BlendState::GetD3D12BlendDesc() const { - return blendDesc; + return mBlendDesc; } } diff --git a/src/backend/d3d12/BlendStateD3D12.h b/src/backend/d3d12/BlendStateD3D12.h index 315cb6f34a..4569ffbc41 100644 --- a/src/backend/d3d12/BlendStateD3D12.h +++ b/src/backend/d3d12/BlendStateD3D12.h @@ -29,7 +29,7 @@ namespace d3d12 { const D3D12_RENDER_TARGET_BLEND_DESC& GetD3D12BlendDesc() const; private: - D3D12_RENDER_TARGET_BLEND_DESC blendDesc; + D3D12_RENDER_TARGET_BLEND_DESC mBlendDesc; }; } diff --git a/src/backend/d3d12/BufferD3D12.cpp b/src/backend/d3d12/BufferD3D12.cpp index c0e03b4b81..a088b4ac66 100644 --- a/src/backend/d3d12/BufferD3D12.cpp +++ b/src/backend/d3d12/BufferD3D12.cpp @@ -69,7 +69,7 @@ namespace d3d12 { } Buffer::Buffer(Device* device, BufferBuilder* builder) - : BufferBase(builder), device(device) { + : BufferBase(builder), mDevice(device) { D3D12_RESOURCE_DESC resourceDescriptor; resourceDescriptor.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; @@ -97,11 +97,11 @@ namespace d3d12 { bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ; } - resource = device->GetResourceAllocator()->Allocate(heapType, resourceDescriptor, bufferUsage); + mResource = device->GetResourceAllocator()->Allocate(heapType, resourceDescriptor, bufferUsage); } Buffer::~Buffer() { - device->GetResourceAllocator()->Release(resource); + mDevice->GetResourceAllocator()->Release(mResource); } uint32_t Buffer::GetD3D12Size() const { @@ -110,7 +110,7 @@ namespace d3d12 { } ComPtr Buffer::GetD3D12Resource() { - return resource; + return mResource; } bool Buffer::GetResourceTransitionBarrier(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage, D3D12_RESOURCE_BARRIER* barrier) { @@ -129,7 +129,7 @@ namespace d3d12 { barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrier->Transition.pResource = resource.Get(); + barrier->Transition.pResource = mResource.Get(); barrier->Transition.StateBefore = stateBefore; barrier->Transition.StateAfter = stateAfter; barrier->Transition.Subresource = 0; @@ -138,7 +138,7 @@ namespace d3d12 { } D3D12_GPU_VIRTUAL_ADDRESS Buffer::GetVA() const { - return resource->GetGPUVirtualAddress(); + return mResource->GetGPUVirtualAddress(); } void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data) { @@ -146,13 +146,13 @@ namespace d3d12 { } void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) { - device->GetResourceUploader()->BufferSubData(resource, start * sizeof(uint32_t), count * sizeof(uint32_t), data); + mDevice->GetResourceUploader()->BufferSubData(mResource, start * sizeof(uint32_t), count * sizeof(uint32_t), data); } void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) { D3D12_RANGE readRange = { start, start + count }; char* data = nullptr; - ASSERT_SUCCESS(resource->Map(0, &readRange, reinterpret_cast(&data))); + ASSERT_SUCCESS(mResource->Map(0, &readRange, reinterpret_cast(&data))); MapReadRequestTracker* tracker = ToBackend(GetDevice())->GetMapReadRequestTracker(); tracker->Track(this, serial, data + start); @@ -161,30 +161,30 @@ namespace d3d12 { void Buffer::UnmapImpl() { // TODO(enga@google.com): When MapWrite is implemented, this should state the range that was modified D3D12_RANGE writeRange = {}; - resource->Unmap(0, &writeRange); - device->GetResourceAllocator()->Release(resource); + mResource->Unmap(0, &writeRange); + mDevice->GetResourceAllocator()->Release(mResource); } void Buffer::TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) { D3D12_RESOURCE_BARRIER barrier; if (GetResourceTransitionBarrier(currentUsage, targetUsage, &barrier)) { - device->GetPendingCommandList()->ResourceBarrier(1, &barrier); + mDevice->GetPendingCommandList()->ResourceBarrier(1, &barrier); } } BufferView::BufferView(BufferViewBuilder* builder) : BufferViewBase(builder) { - cbvDesc.BufferLocation = ToBackend(GetBuffer())->GetVA() + GetOffset(); - cbvDesc.SizeInBytes = GetD3D12Size(); + mCbvDesc.BufferLocation = ToBackend(GetBuffer())->GetVA() + GetOffset(); + mCbvDesc.SizeInBytes = GetD3D12Size(); - uavDesc.Format = DXGI_FORMAT_UNKNOWN; - uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; - uavDesc.Buffer.FirstElement = GetOffset(); - uavDesc.Buffer.NumElements = GetD3D12Size(); - uavDesc.Buffer.StructureByteStride = 1; - uavDesc.Buffer.CounterOffsetInBytes = 0; - uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; + mUavDesc.Format = DXGI_FORMAT_UNKNOWN; + mUavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; + mUavDesc.Buffer.FirstElement = GetOffset(); + mUavDesc.Buffer.NumElements = GetD3D12Size(); + mUavDesc.Buffer.StructureByteStride = 1; + mUavDesc.Buffer.CounterOffsetInBytes = 0; + mUavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; } uint32_t BufferView::GetD3D12Size() const { @@ -193,19 +193,19 @@ namespace d3d12 { } const D3D12_CONSTANT_BUFFER_VIEW_DESC& BufferView::GetCBVDescriptor() const { - return cbvDesc; + return mCbvDesc; } const D3D12_UNORDERED_ACCESS_VIEW_DESC& BufferView::GetUAVDescriptor() const { - return uavDesc; + return mUavDesc; } MapReadRequestTracker::MapReadRequestTracker(Device* device) - : device(device) { + : mDevice(device) { } MapReadRequestTracker::~MapReadRequestTracker() { - ASSERT(inflightRequests.Empty()); + ASSERT(mInflightRequests.Empty()); } void MapReadRequestTracker::Track(Buffer* buffer, uint32_t mapSerial, const void* data) { @@ -214,14 +214,14 @@ namespace d3d12 { request.mapSerial = mapSerial; request.data = data; - inflightRequests.Enqueue(std::move(request), device->GetSerial()); + mInflightRequests.Enqueue(std::move(request), mDevice->GetSerial()); } void MapReadRequestTracker::Tick(Serial finishedSerial) { - for (auto& request : inflightRequests.IterateUpTo(finishedSerial)) { + for (auto& request : mInflightRequests.IterateUpTo(finishedSerial)) { request.buffer->OnMapReadCommandSerialFinished(request.mapSerial, request.data); } - inflightRequests.ClearUpTo(finishedSerial); + mInflightRequests.ClearUpTo(finishedSerial); } } diff --git a/src/backend/d3d12/BufferD3D12.h b/src/backend/d3d12/BufferD3D12.h index dd7ef07cd1..df9eacd914 100644 --- a/src/backend/d3d12/BufferD3D12.h +++ b/src/backend/d3d12/BufferD3D12.h @@ -37,8 +37,8 @@ namespace d3d12 { void OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data); private: - Device* device; - ComPtr resource; + Device* mDevice; + ComPtr mResource; // NXT API void SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) override; @@ -57,8 +57,8 @@ namespace d3d12 { const D3D12_UNORDERED_ACCESS_VIEW_DESC& GetUAVDescriptor() const; private: - D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc; - D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc; + D3D12_CONSTANT_BUFFER_VIEW_DESC mCbvDesc; + D3D12_UNORDERED_ACCESS_VIEW_DESC mUavDesc; }; class MapReadRequestTracker { @@ -70,14 +70,14 @@ namespace d3d12 { void Tick(Serial finishedSerial); private: - Device* device; + Device* mDevice; struct Request { Ref buffer; uint32_t mapSerial; const void* data; }; - SerialQueue inflightRequests; + SerialQueue mInflightRequests; }; } diff --git a/src/backend/d3d12/CommandAllocatorManager.cpp b/src/backend/d3d12/CommandAllocatorManager.cpp index 9c08f65b7d..89cf1df3bd 100644 --- a/src/backend/d3d12/CommandAllocatorManager.cpp +++ b/src/backend/d3d12/CommandAllocatorManager.cpp @@ -22,45 +22,45 @@ namespace backend { namespace d3d12 { - CommandAllocatorManager::CommandAllocatorManager(Device* device) : device(device), allocatorCount(0) { - freeAllocators.set(); + CommandAllocatorManager::CommandAllocatorManager(Device* device) : device(device), mAllocatorCount(0) { + mFreeAllocators.set(); } ComPtr CommandAllocatorManager::ReserveCommandAllocator() { // If there are no free allocators, get the oldest serial in flight and wait on it - if (freeAllocators.none()) { - const uint64_t firstSerial = inFlightCommandAllocators.FirstSerial(); + if (mFreeAllocators.none()) { + const uint64_t firstSerial = mInFlightCommandAllocators.FirstSerial(); device->WaitForSerial(firstSerial); Tick(firstSerial); } - ASSERT(freeAllocators.any()); + ASSERT(mFreeAllocators.any()); // Get the index of the first free allocator from the bitset - unsigned int firstFreeIndex = *(IterateBitSet(freeAllocators).begin()); + unsigned int firstFreeIndex = *(IterateBitSet(mFreeAllocators).begin()); - if (firstFreeIndex >= allocatorCount) { - ASSERT(firstFreeIndex == allocatorCount); - allocatorCount++; - ASSERT_SUCCESS(device->GetD3D12Device()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&commandAllocators[firstFreeIndex]))); + if (firstFreeIndex >= mAllocatorCount) { + ASSERT(firstFreeIndex == mAllocatorCount); + mAllocatorCount++; + ASSERT_SUCCESS(device->GetD3D12Device()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&mCommandAllocators[firstFreeIndex]))); } // Mark the command allocator as used - freeAllocators.reset(firstFreeIndex); + mFreeAllocators.reset(firstFreeIndex); // Enqueue the command allocator. It will be scheduled for reset after the next ExecuteCommandLists - inFlightCommandAllocators.Enqueue({commandAllocators[firstFreeIndex], firstFreeIndex}, device->GetSerial()); + mInFlightCommandAllocators.Enqueue({mCommandAllocators[firstFreeIndex], firstFreeIndex}, device->GetSerial()); - return commandAllocators[firstFreeIndex]; + return mCommandAllocators[firstFreeIndex]; } void CommandAllocatorManager::Tick(uint64_t lastCompletedSerial) { // Reset all command allocators that are no longer in flight - for (auto it : inFlightCommandAllocators.IterateUpTo(lastCompletedSerial)) { + for (auto it : mInFlightCommandAllocators.IterateUpTo(lastCompletedSerial)) { ASSERT_SUCCESS(it.commandAllocator->Reset()); - freeAllocators.set(it.index); + mFreeAllocators.set(it.index); } - inFlightCommandAllocators.ClearUpTo(lastCompletedSerial); + mInFlightCommandAllocators.ClearUpTo(lastCompletedSerial); } } diff --git a/src/backend/d3d12/CommandAllocatorManager.h b/src/backend/d3d12/CommandAllocatorManager.h index 33817c7fbb..957c435880 100644 --- a/src/backend/d3d12/CommandAllocatorManager.h +++ b/src/backend/d3d12/CommandAllocatorManager.h @@ -40,16 +40,16 @@ namespace d3d12 { // This must be at least 2 because the Device and Queue use separate command allocators static constexpr unsigned int kMaxCommandAllocators = 32; - unsigned int allocatorCount; + unsigned int mAllocatorCount; struct IndexedCommandAllocator { ComPtr commandAllocator; unsigned int index; }; - ComPtr commandAllocators[kMaxCommandAllocators]; - std::bitset freeAllocators; - SerialQueue inFlightCommandAllocators; + ComPtr mCommandAllocators[kMaxCommandAllocators]; + std::bitset mFreeAllocators; + SerialQueue mInFlightCommandAllocators; }; } diff --git a/src/backend/d3d12/CommandBufferD3D12.cpp b/src/backend/d3d12/CommandBufferD3D12.cpp index 74f1b8fe67..94420d08e8 100644 --- a/src/backend/d3d12/CommandBufferD3D12.cpp +++ b/src/backend/d3d12/CommandBufferD3D12.cpp @@ -61,8 +61,8 @@ namespace d3d12 { BindGroupStateTracker(Device* device) : device(device) { } - void SetInComputePass(bool inCompute) { - this->inCompute = inCompute; + void SetInComputePass(bool inCompute_) { + inCompute = inCompute_; } void TrackSetBindGroup(BindGroup* group, uint32_t index) { @@ -205,16 +205,16 @@ namespace d3d12 { } CommandBuffer::CommandBuffer(Device* device, CommandBufferBuilder* builder) - : CommandBufferBase(builder), device(device), commands(builder->AcquireCommands()) { + : CommandBufferBase(builder), mDevice(device), mCommands(builder->AcquireCommands()) { } CommandBuffer::~CommandBuffer() { - FreeCommands(&commands); + FreeCommands(&mCommands); } void CommandBuffer::FillCommands(ComPtr commandList) { - BindGroupStateTracker bindingTracker(device); - AllocateAndSetDescriptorHeaps(device, &bindingTracker, &commands); + BindGroupStateTracker bindingTracker(mDevice); + AllocateAndSetDescriptorHeaps(mDevice, &bindingTracker, &mCommands); bindingTracker.Reset(); ID3D12DescriptorHeap* descriptorHeaps[2] = { bindingTracker.cbvSrvUavGPUDescriptorHeap.Get(), bindingTracker.samplerGPUDescriptorHeap.Get() }; @@ -234,18 +234,18 @@ namespace d3d12 { Framebuffer* currentFramebuffer = nullptr; uint32_t currentSubpass = 0; - while(commands.NextCommandId(&type)) { + while(mCommands.NextCommandId(&type)) { switch (type) { case Command::BeginComputePass: { - commands.NextCommand(); + mCommands.NextCommand(); bindingTracker.SetInComputePass(true); } break; case Command::BeginRenderPass: { - BeginRenderPassCmd* beginRenderPassCmd = commands.NextCommand(); + BeginRenderPassCmd* beginRenderPassCmd = mCommands.NextCommand(); currentRenderPass = ToBackend(beginRenderPassCmd->renderPass.Get()); currentFramebuffer = ToBackend(beginRenderPassCmd->framebuffer.Get()); currentSubpass = 0; @@ -261,7 +261,7 @@ namespace d3d12 { case Command::BeginRenderSubpass: { - commands.NextCommand(); + mCommands.NextCommand(); const auto& subpass = currentRenderPass->GetSubpassInfo(currentSubpass); Framebuffer::OMSetRenderTargetArgs args = currentFramebuffer->GetSubpassOMSetRenderTargetArgs(currentSubpass); @@ -332,7 +332,7 @@ namespace d3d12 { case Command::CopyBufferToBuffer: { - CopyBufferToBufferCmd* copy = commands.NextCommand(); + CopyBufferToBufferCmd* copy = mCommands.NextCommand(); auto src = ToBackend(copy->source.buffer.Get())->GetD3D12Resource(); auto dst = ToBackend(copy->destination.buffer.Get())->GetD3D12Resource(); commandList->CopyBufferRegion(dst.Get(), copy->destination.offset, src.Get(), copy->source.offset, copy->size); @@ -341,7 +341,7 @@ namespace d3d12 { case Command::CopyBufferToTexture: { - CopyBufferToTextureCmd* copy = commands.NextCommand(); + CopyBufferToTextureCmd* copy = mCommands.NextCommand(); Buffer* buffer = ToBackend(copy->source.buffer.Get()); Texture* texture = ToBackend(copy->destination.texture.Get()); @@ -390,7 +390,7 @@ namespace d3d12 { case Command::CopyTextureToBuffer: { - CopyTextureToBufferCmd* copy = commands.NextCommand(); + CopyTextureToBufferCmd* copy = mCommands.NextCommand(); Texture* texture = ToBackend(copy->source.texture.Get()); Buffer* buffer = ToBackend(copy->destination.buffer.Get()); @@ -439,14 +439,14 @@ namespace d3d12 { case Command::Dispatch: { - DispatchCmd* dispatch = commands.NextCommand(); + DispatchCmd* dispatch = mCommands.NextCommand(); commandList->Dispatch(dispatch->x, dispatch->y, dispatch->z); } break; case Command::DrawArrays: { - DrawArraysCmd* draw = commands.NextCommand(); + DrawArraysCmd* draw = mCommands.NextCommand(); commandList->DrawInstanced( draw->vertexCount, draw->instanceCount, @@ -458,7 +458,7 @@ namespace d3d12 { case Command::DrawElements: { - DrawElementsCmd* draw = commands.NextCommand(); + DrawElementsCmd* draw = mCommands.NextCommand(); commandList->DrawIndexedInstanced( draw->indexCount, @@ -472,27 +472,27 @@ namespace d3d12 { case Command::EndComputePass: { - commands.NextCommand(); + mCommands.NextCommand(); bindingTracker.SetInComputePass(false); } break; case Command::EndRenderPass: { - commands.NextCommand(); + mCommands.NextCommand(); } break; case Command::EndRenderSubpass: { - commands.NextCommand(); + mCommands.NextCommand(); currentSubpass += 1; } break; case Command::SetComputePipeline: { - SetComputePipelineCmd* cmd = commands.NextCommand(); + SetComputePipelineCmd* cmd = mCommands.NextCommand(); ComputePipeline* pipeline = ToBackend(cmd->pipeline).Get(); PipelineLayout* layout = ToBackend(pipeline->GetLayout()); @@ -507,7 +507,7 @@ namespace d3d12 { case Command::SetRenderPipeline: { - SetRenderPipelineCmd* cmd = commands.NextCommand(); + SetRenderPipelineCmd* cmd = mCommands.NextCommand(); RenderPipeline* pipeline = ToBackend(cmd->pipeline).Get(); PipelineLayout* layout = ToBackend(pipeline->GetLayout()); @@ -524,13 +524,13 @@ namespace d3d12 { case Command::SetPushConstants: { - commands.NextCommand(); + mCommands.NextCommand(); } break; case Command::SetStencilReference: { - SetStencilReferenceCmd *cmd = commands.NextCommand(); + SetStencilReferenceCmd *cmd = mCommands.NextCommand(); commandList->OMSetStencilRef(cmd->reference); } @@ -538,7 +538,7 @@ namespace d3d12 { case Command::SetBlendColor: { - SetBlendColorCmd* cmd = commands.NextCommand(); + SetBlendColorCmd* cmd = mCommands.NextCommand(); ASSERT(lastRenderPipeline); commandList->OMSetBlendFactor(static_cast(&cmd->r)); } @@ -546,7 +546,7 @@ namespace d3d12 { case Command::SetBindGroup: { - SetBindGroupCmd* cmd = commands.NextCommand(); + SetBindGroupCmd* cmd = mCommands.NextCommand(); BindGroup* group = ToBackend(cmd->group.Get()); bindingTracker.SetBindGroup(commandList, lastLayout, group, cmd->index); } @@ -554,7 +554,7 @@ namespace d3d12 { case Command::SetIndexBuffer: { - SetIndexBufferCmd* cmd = commands.NextCommand(); + SetIndexBufferCmd* cmd = mCommands.NextCommand(); Buffer* buffer = ToBackend(cmd->buffer.Get()); D3D12_INDEX_BUFFER_VIEW bufferView; @@ -571,9 +571,9 @@ namespace d3d12 { 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); auto inputState = ToBackend(lastRenderPipeline->GetInputState()); @@ -592,7 +592,7 @@ namespace d3d12 { case Command::TransitionBufferUsage: { - TransitionBufferUsageCmd* cmd = commands.NextCommand(); + TransitionBufferUsageCmd* cmd = mCommands.NextCommand(); Buffer* buffer = ToBackend(cmd->buffer.Get()); @@ -607,7 +607,7 @@ namespace d3d12 { case Command::TransitionTextureUsage: { - TransitionTextureUsageCmd* cmd = commands.NextCommand(); + TransitionTextureUsageCmd* cmd = mCommands.NextCommand(); Texture* texture = ToBackend(cmd->texture.Get()); diff --git a/src/backend/d3d12/CommandBufferD3D12.h b/src/backend/d3d12/CommandBufferD3D12.h index de2c3fb491..fb4f329293 100644 --- a/src/backend/d3d12/CommandBufferD3D12.h +++ b/src/backend/d3d12/CommandBufferD3D12.h @@ -33,8 +33,8 @@ namespace d3d12 { void FillCommands(ComPtr commandList); private: - Device* device; - CommandIterator commands; + Device* mDevice; + CommandIterator mCommands; }; } } diff --git a/src/backend/d3d12/ComputePipelineD3D12.cpp b/src/backend/d3d12/ComputePipelineD3D12.cpp index 2559230db7..3e1dccd24e 100644 --- a/src/backend/d3d12/ComputePipelineD3D12.cpp +++ b/src/backend/d3d12/ComputePipelineD3D12.cpp @@ -64,11 +64,11 @@ namespace d3d12 { descriptor.CS.BytecodeLength = compiledShader->GetBufferSize(); Device* device = ToBackend(builder->GetDevice()); - device->GetD3D12Device()->CreateComputePipelineState(&descriptor, IID_PPV_ARGS(&pipelineState)); + device->GetD3D12Device()->CreateComputePipelineState(&descriptor, IID_PPV_ARGS(&mPipelineState)); } ComPtr ComputePipeline::GetPipelineState() { - return pipelineState; + return mPipelineState; } } diff --git a/src/backend/d3d12/ComputePipelineD3D12.h b/src/backend/d3d12/ComputePipelineD3D12.h index 7f9e424d66..0fc470709b 100644 --- a/src/backend/d3d12/ComputePipelineD3D12.h +++ b/src/backend/d3d12/ComputePipelineD3D12.h @@ -29,7 +29,7 @@ namespace backend { ComPtr GetPipelineState(); private: - ComPtr pipelineState; + ComPtr mPipelineState; }; } diff --git a/src/backend/d3d12/D3D12Backend.cpp b/src/backend/d3d12/D3D12Backend.cpp index 3f5c0df62f..16ee44d5bd 100644 --- a/src/backend/d3d12/D3D12Backend.cpp +++ b/src/backend/d3d12/D3D12Backend.cpp @@ -83,21 +83,21 @@ namespace d3d12 { } Device::Device(ComPtr d3d12Device) - : d3d12Device(d3d12Device), - commandAllocatorManager(new CommandAllocatorManager(this)), - descriptorHeapAllocator(new DescriptorHeapAllocator(this)), - mapReadRequestTracker(new MapReadRequestTracker(this)), - resourceAllocator(new ResourceAllocator(this)), - resourceUploader(new ResourceUploader(this)) { + : mD3d12Device(d3d12Device), + mCommandAllocatorManager(new CommandAllocatorManager(this)), + mDescriptorHeapAllocator(new DescriptorHeapAllocator(this)), + mMapReadRequestTracker(new MapReadRequestTracker(this)), + mResourceAllocator(new ResourceAllocator(this)), + mResourceUploader(new ResourceUploader(this)) { D3D12_COMMAND_QUEUE_DESC queueDesc = {}; queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - ASSERT_SUCCESS(d3d12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&commandQueue))); + ASSERT_SUCCESS(d3d12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&mCommandQueue))); - ASSERT_SUCCESS(d3d12Device->CreateFence(serial, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence))); - fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); - ASSERT(fenceEvent != nullptr); + ASSERT_SUCCESS(d3d12Device->CreateFence(mSerial, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&mFence))); + mFenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); + ASSERT(mFenceEvent != nullptr); NextSerial(); } @@ -107,100 +107,100 @@ namespace d3d12 { NextSerial(); WaitForSerial(currentSerial); // Wait for all in-flight commands to finish executing TickImpl(); // Call tick one last time so resources are cleaned up - delete commandAllocatorManager; - delete descriptorHeapAllocator; - delete mapReadRequestTracker; - delete resourceAllocator; - delete resourceUploader; + delete mCommandAllocatorManager; + delete mDescriptorHeapAllocator; + delete mMapReadRequestTracker; + delete mResourceAllocator; + delete mResourceUploader; } ComPtr Device::GetD3D12Device() { - return d3d12Device; + return mD3d12Device; } ComPtr Device::GetCommandQueue() { - return commandQueue; + return mCommandQueue; } DescriptorHeapAllocator* Device::GetDescriptorHeapAllocator() { - return descriptorHeapAllocator; + return mDescriptorHeapAllocator; } MapReadRequestTracker* Device::GetMapReadRequestTracker() const { - return mapReadRequestTracker; + return mMapReadRequestTracker; } ResourceAllocator* Device::GetResourceAllocator() { - return resourceAllocator; + return mResourceAllocator; } ResourceUploader* Device::GetResourceUploader() { - return resourceUploader; + return mResourceUploader; } void Device::OpenCommandList(ComPtr* commandList) { ComPtr &cmdList = *commandList; if (!cmdList) { - ASSERT_SUCCESS(d3d12Device->CreateCommandList( + ASSERT_SUCCESS(mD3d12Device->CreateCommandList( 0, D3D12_COMMAND_LIST_TYPE_DIRECT, - commandAllocatorManager->ReserveCommandAllocator().Get(), + mCommandAllocatorManager->ReserveCommandAllocator().Get(), nullptr, IID_PPV_ARGS(&cmdList) )); } else { - ASSERT_SUCCESS(cmdList->Reset(commandAllocatorManager->ReserveCommandAllocator().Get(), nullptr)); + ASSERT_SUCCESS(cmdList->Reset(mCommandAllocatorManager->ReserveCommandAllocator().Get(), nullptr)); } } ComPtr Device::GetPendingCommandList() { // Callers of GetPendingCommandList do so to record commands. Only reserve a command allocator when it is needed so we don't submit empty command lists - if (!pendingCommands.open) { - OpenCommandList(&pendingCommands.commandList); - pendingCommands.open = true; + if (!mPendingCommands.open) { + OpenCommandList(&mPendingCommands.commandList); + mPendingCommands.open = true; } - return pendingCommands.commandList; + return mPendingCommands.commandList; } void Device::TickImpl() { // Perform cleanup operations to free unused objects - const uint64_t lastCompletedSerial = fence->GetCompletedValue(); - resourceAllocator->Tick(lastCompletedSerial); - commandAllocatorManager->Tick(lastCompletedSerial); - descriptorHeapAllocator->Tick(lastCompletedSerial); - mapReadRequestTracker->Tick(lastCompletedSerial); + const uint64_t lastCompletedSerial = mFence->GetCompletedValue(); + mResourceAllocator->Tick(lastCompletedSerial); + mCommandAllocatorManager->Tick(lastCompletedSerial); + mDescriptorHeapAllocator->Tick(lastCompletedSerial); + mMapReadRequestTracker->Tick(lastCompletedSerial); ExecuteCommandLists({}); NextSerial(); } uint64_t Device::GetSerial() const { - return serial; + return mSerial; } void Device::NextSerial() { - ASSERT_SUCCESS(commandQueue->Signal(fence.Get(), serial++)); + ASSERT_SUCCESS(mCommandQueue->Signal(mFence.Get(), mSerial++)); } void Device::WaitForSerial(uint64_t serial) { - const uint64_t lastCompletedSerial = fence->GetCompletedValue(); + const uint64_t lastCompletedSerial = mFence->GetCompletedValue(); if (lastCompletedSerial < serial) { - ASSERT_SUCCESS(fence->SetEventOnCompletion(serial, fenceEvent)); - WaitForSingleObject(fenceEvent, INFINITE); + ASSERT_SUCCESS(mFence->SetEventOnCompletion(serial, mFenceEvent)); + WaitForSingleObject(mFenceEvent, INFINITE); } } void Device::ExecuteCommandLists(std::initializer_list commandLists) { // If there are pending commands, prepend them to ExecuteCommandLists - if (pendingCommands.open) { + if (mPendingCommands.open) { std::vector lists(commandLists.size() + 1); - pendingCommands.commandList->Close(); - pendingCommands.open = false; - lists[0] = pendingCommands.commandList.Get(); + mPendingCommands.commandList->Close(); + mPendingCommands.open = false; + lists[0] = mPendingCommands.commandList.Get(); std::copy(commandLists.begin(), commandLists.end(), lists.begin() + 1); - commandQueue->ExecuteCommandLists(static_cast(commandLists.size() + 1), lists.data()); + mCommandQueue->ExecuteCommandLists(static_cast(commandLists.size() + 1), lists.data()); } else { std::vector lists(commandLists); - commandQueue->ExecuteCommandLists(static_cast(commandLists.size()), lists.data()); + mCommandQueue->ExecuteCommandLists(static_cast(commandLists.size()), lists.data()); } } @@ -265,7 +265,7 @@ namespace d3d12 { // RenderPass RenderPass::RenderPass(Device* device, RenderPassBuilder* builder) - : RenderPassBase(builder), device(device) { + : RenderPassBase(builder), mDevice(device) { } } diff --git a/src/backend/d3d12/D3D12Backend.h b/src/backend/d3d12/D3D12Backend.h index dacb2399af..591b5091a1 100644 --- a/src/backend/d3d12/D3D12Backend.h +++ b/src/backend/d3d12/D3D12Backend.h @@ -130,23 +130,23 @@ namespace d3d12 { void ExecuteCommandLists(std::initializer_list commandLists); private: - uint64_t serial = 0; - ComPtr fence; - HANDLE fenceEvent; + uint64_t mSerial = 0; + ComPtr mFence; + HANDLE mFenceEvent; - ComPtr d3d12Device; - ComPtr commandQueue; + ComPtr mD3d12Device; + ComPtr mCommandQueue; - CommandAllocatorManager* commandAllocatorManager; - DescriptorHeapAllocator* descriptorHeapAllocator; - MapReadRequestTracker* mapReadRequestTracker; - ResourceAllocator* resourceAllocator; - ResourceUploader* resourceUploader; + CommandAllocatorManager* mCommandAllocatorManager; + DescriptorHeapAllocator* mDescriptorHeapAllocator; + MapReadRequestTracker* mMapReadRequestTracker; + ResourceAllocator* mResourceAllocator; + ResourceUploader* mResourceUploader; struct PendingCommandList { ComPtr commandList; bool open = false; - } pendingCommands; + } mPendingCommands; }; class RenderPass : public RenderPassBase { @@ -154,7 +154,7 @@ namespace d3d12 { RenderPass(Device* device, RenderPassBuilder* builder); private: - Device* device; + Device* mDevice; }; } diff --git a/src/backend/d3d12/DepthStencilStateD3D12.cpp b/src/backend/d3d12/DepthStencilStateD3D12.cpp index 60c81a6a80..ea5e39fc5b 100644 --- a/src/backend/d3d12/DepthStencilStateD3D12.cpp +++ b/src/backend/d3d12/DepthStencilStateD3D12.cpp @@ -78,22 +78,22 @@ namespace d3d12 { } DepthStencilState::DepthStencilState(Device* device, DepthStencilStateBuilder* builder) - : DepthStencilStateBase(builder), device(device) { + : DepthStencilStateBase(builder), mDevice(device) { - depthStencilDescriptor.DepthEnable = TRUE; - depthStencilDescriptor.DepthWriteMask = GetDepth().depthWriteEnabled ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; - depthStencilDescriptor.DepthFunc = ComparisonFunc(GetDepth().compareFunction); + mDepthStencilDescriptor.DepthEnable = TRUE; + mDepthStencilDescriptor.DepthWriteMask = GetDepth().depthWriteEnabled ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; + mDepthStencilDescriptor.DepthFunc = ComparisonFunc(GetDepth().compareFunction); - depthStencilDescriptor.StencilEnable = StencilTestEnabled() ? TRUE : FALSE; - depthStencilDescriptor.StencilReadMask = static_cast(GetStencil().readMask); - depthStencilDescriptor.StencilWriteMask = static_cast(GetStencil().writeMask); + mDepthStencilDescriptor.StencilEnable = StencilTestEnabled() ? TRUE : FALSE; + mDepthStencilDescriptor.StencilReadMask = static_cast(GetStencil().readMask); + mDepthStencilDescriptor.StencilWriteMask = static_cast(GetStencil().writeMask); - depthStencilDescriptor.FrontFace = StencilOpDesc(GetStencil().front); - depthStencilDescriptor.BackFace = StencilOpDesc(GetStencil().back); + mDepthStencilDescriptor.FrontFace = StencilOpDesc(GetStencil().front); + mDepthStencilDescriptor.BackFace = StencilOpDesc(GetStencil().back); } const D3D12_DEPTH_STENCIL_DESC& DepthStencilState::GetD3D12DepthStencilDescriptor() const { - return depthStencilDescriptor; + return mDepthStencilDescriptor; } } diff --git a/src/backend/d3d12/DepthStencilStateD3D12.h b/src/backend/d3d12/DepthStencilStateD3D12.h index ca040b6f7d..4020c568b1 100644 --- a/src/backend/d3d12/DepthStencilStateD3D12.h +++ b/src/backend/d3d12/DepthStencilStateD3D12.h @@ -31,8 +31,8 @@ namespace d3d12 { const D3D12_DEPTH_STENCIL_DESC& GetD3D12DepthStencilDescriptor() const; private: - Device* device; - D3D12_DEPTH_STENCIL_DESC depthStencilDescriptor; + Device* mDevice; + D3D12_DEPTH_STENCIL_DESC mDepthStencilDescriptor; }; } diff --git a/src/backend/d3d12/DescriptorHeapAllocator.cpp b/src/backend/d3d12/DescriptorHeapAllocator.cpp index 3d0bdf011f..0cd97cfc6d 100644 --- a/src/backend/d3d12/DescriptorHeapAllocator.cpp +++ b/src/backend/d3d12/DescriptorHeapAllocator.cpp @@ -21,35 +21,35 @@ namespace backend { namespace d3d12 { DescriptorHeapHandle::DescriptorHeapHandle() - : descriptorHeap(nullptr), sizeIncrement(0), offset(0) { + : mDescriptorHeap(nullptr), mSizeIncrement(0), mOffset(0) { } DescriptorHeapHandle::DescriptorHeapHandle(ComPtr descriptorHeap, uint32_t sizeIncrement, uint32_t offset) - : descriptorHeap(descriptorHeap), sizeIncrement(sizeIncrement), offset(offset) { + : mDescriptorHeap(descriptorHeap), mSizeIncrement(sizeIncrement), mOffset(offset) { } ID3D12DescriptorHeap* DescriptorHeapHandle::Get() const { - return descriptorHeap.Get(); + return mDescriptorHeap.Get(); } D3D12_CPU_DESCRIPTOR_HANDLE DescriptorHeapHandle::GetCPUHandle(uint32_t index) const { - ASSERT(descriptorHeap); - auto handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart(); - handle.ptr += sizeIncrement * (index + offset); + ASSERT(mDescriptorHeap); + auto handle = mDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); + handle.ptr += mSizeIncrement * (index + mOffset); return handle; } D3D12_GPU_DESCRIPTOR_HANDLE DescriptorHeapHandle::GetGPUHandle(uint32_t index) const { - ASSERT(descriptorHeap); - auto handle = descriptorHeap->GetGPUDescriptorHandleForHeapStart(); - handle.ptr += sizeIncrement * (index + offset); + ASSERT(mDescriptorHeap); + auto handle = mDescriptorHeap->GetGPUDescriptorHandleForHeapStart(); + handle.ptr += mSizeIncrement * (index + mOffset); return handle; } DescriptorHeapAllocator::DescriptorHeapAllocator(Device* device) - : device(device), - sizeIncrements { + : mDevice(device), + mSizeIncrements { device->GetD3D12Device()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV), device->GetD3D12Device()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER), device->GetD3D12Device()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV), @@ -68,7 +68,7 @@ namespace d3d12 { // If the current pool for this type has space, linearly allocate count bytes in the pool auto& allocationInfo = heapInfo->second; if (allocationInfo.remaining >= count) { - DescriptorHeapHandle handle(heapInfo->first, sizeIncrements[type], allocationInfo.size - allocationInfo.remaining); + DescriptorHeapHandle handle(heapInfo->first, mSizeIncrements[type], allocationInfo.size - allocationInfo.remaining); allocationInfo.remaining -= count; Release(handle); return handle; @@ -83,32 +83,32 @@ namespace d3d12 { heapDescriptor.Flags = flags; heapDescriptor.NodeMask = 0; ComPtr heap; - ASSERT_SUCCESS(device->GetD3D12Device()->CreateDescriptorHeap(&heapDescriptor, IID_PPV_ARGS(&heap))); + ASSERT_SUCCESS(mDevice->GetD3D12Device()->CreateDescriptorHeap(&heapDescriptor, IID_PPV_ARGS(&heap))); AllocationInfo allocationInfo = { allocationSize, allocationSize - count }; *heapInfo = std::make_pair(heap, allocationInfo); - DescriptorHeapHandle handle(heap, sizeIncrements[type], 0); + DescriptorHeapHandle handle(heap, mSizeIncrements[type], 0); Release(handle); return handle; } DescriptorHeapHandle DescriptorHeapAllocator::AllocateCPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t count) { - return Allocate(type, count, count, &cpuDescriptorHeapInfos[type], D3D12_DESCRIPTOR_HEAP_FLAG_NONE); + return Allocate(type, count, count, &mCpuDescriptorHeapInfos[type], D3D12_DESCRIPTOR_HEAP_FLAG_NONE); } DescriptorHeapHandle DescriptorHeapAllocator::AllocateGPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t count) { ASSERT(type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV || type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); unsigned int heapSize = (type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ? kMaxCbvUavSrvHeapSize : kMaxSamplerHeapSize); - return Allocate(type, count, heapSize, &gpuDescriptorHeapInfos[type], D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE); + return Allocate(type, count, heapSize, &mGpuDescriptorHeapInfos[type], D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE); } void DescriptorHeapAllocator::Tick(uint64_t lastCompletedSerial) { - releasedHandles.ClearUpTo(lastCompletedSerial); + mReleasedHandles.ClearUpTo(lastCompletedSerial); } void DescriptorHeapAllocator::Release(DescriptorHeapHandle handle) { - releasedHandles.Enqueue(handle, device->GetSerial()); + mReleasedHandles.Enqueue(handle, mDevice->GetSerial()); } } } diff --git a/src/backend/d3d12/DescriptorHeapAllocator.h b/src/backend/d3d12/DescriptorHeapAllocator.h index 9de0dd7396..41cd46baf1 100644 --- a/src/backend/d3d12/DescriptorHeapAllocator.h +++ b/src/backend/d3d12/DescriptorHeapAllocator.h @@ -37,9 +37,9 @@ namespace d3d12 { D3D12_GPU_DESCRIPTOR_HANDLE GetGPUHandle(uint32_t index) const; private: - ComPtr descriptorHeap; - uint32_t sizeIncrement; - uint32_t offset; + ComPtr mDescriptorHeap; + uint32_t mSizeIncrement; + uint32_t mOffset; }; class DescriptorHeapAllocator { @@ -65,12 +65,12 @@ namespace d3d12 { DescriptorHeapHandle Allocate(D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t count, uint32_t allocationSize, DescriptorHeapInfo* heapInfo, D3D12_DESCRIPTOR_HEAP_FLAGS flags); void Release(DescriptorHeapHandle handle); - Device* device; + Device* mDevice; - std::array sizeIncrements; - std::array cpuDescriptorHeapInfos; - std::array gpuDescriptorHeapInfos; - SerialQueue releasedHandles; + std::array mSizeIncrements; + std::array mCpuDescriptorHeapInfos; + std::array mGpuDescriptorHeapInfos; + SerialQueue mReleasedHandles; }; } diff --git a/src/backend/d3d12/FramebufferD3D12.cpp b/src/backend/d3d12/FramebufferD3D12.cpp index 06140a0a36..e45d6e577c 100644 --- a/src/backend/d3d12/FramebufferD3D12.cpp +++ b/src/backend/d3d12/FramebufferD3D12.cpp @@ -22,42 +22,42 @@ namespace backend { namespace d3d12 { Framebuffer::Framebuffer(Device* device, FramebufferBuilder* builder) - : FramebufferBase(builder), device(device) { + : FramebufferBase(builder), mDevice(device) { RenderPass* renderPass = ToBackend(GetRenderPass()); uint32_t rtvCount = 0, dsvCount = 0; - attachmentHeapIndices.resize(renderPass->GetAttachmentCount()); + mAttachmentHeapIndices.resize(renderPass->GetAttachmentCount()); for (uint32_t attachment = 0; attachment < renderPass->GetAttachmentCount(); ++attachment) { auto* textureView = GetTextureView(attachment); auto format = textureView->GetTexture()->GetFormat(); if (TextureFormatHasDepth(format) || TextureFormatHasStencil(format)) { - attachmentHeapIndices[attachment] = dsvCount++; + mAttachmentHeapIndices[attachment] = dsvCount++; } else { - attachmentHeapIndices[attachment] = rtvCount++; + mAttachmentHeapIndices[attachment] = rtvCount++; } } if (rtvCount) { - rtvHeap = device->GetDescriptorHeapAllocator()->AllocateCPUHeap( + mRtvHeap = device->GetDescriptorHeapAllocator()->AllocateCPUHeap( D3D12_DESCRIPTOR_HEAP_TYPE_RTV, rtvCount); } if (dsvCount) { - dsvHeap = device->GetDescriptorHeapAllocator()->AllocateCPUHeap( + mDsvHeap = device->GetDescriptorHeapAllocator()->AllocateCPUHeap( D3D12_DESCRIPTOR_HEAP_TYPE_DSV, dsvCount); } for (uint32_t attachment = 0; attachment < renderPass->GetAttachmentCount(); ++attachment) { - uint32_t heapIndex = attachmentHeapIndices[attachment]; + uint32_t heapIndex = mAttachmentHeapIndices[attachment]; auto* textureView = GetTextureView(attachment); ComPtr texture = ToBackend(textureView->GetTexture())->GetD3D12Resource(); auto format = textureView->GetTexture()->GetFormat(); if (TextureFormatHasDepth(format) || TextureFormatHasStencil(format)) { - D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = dsvHeap.GetCPUHandle(heapIndex); + D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = mDsvHeap.GetCPUHandle(heapIndex); D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = ToBackend(textureView)->GetDSVDescriptor(); device->GetD3D12Device()->CreateDepthStencilView(texture.Get(), &dsvDesc, dsvHandle); } else { - D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = rtvHeap.GetCPUHandle(heapIndex); + D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = mRtvHeap.GetCPUHandle(heapIndex); D3D12_RENDER_TARGET_VIEW_DESC rtvDesc = ToBackend(textureView)->GetRTVDescriptor(); device->GetD3D12Device()->CreateRenderTargetView(texture.Get(), &rtvDesc, rtvHandle); } @@ -82,11 +82,11 @@ namespace d3d12 { } D3D12_CPU_DESCRIPTOR_HANDLE Framebuffer::GetRTVDescriptor(uint32_t attachmentSlot) { - return rtvHeap.GetCPUHandle(attachmentHeapIndices[attachmentSlot]); + return mRtvHeap.GetCPUHandle(mAttachmentHeapIndices[attachmentSlot]); } D3D12_CPU_DESCRIPTOR_HANDLE Framebuffer::GetDSVDescriptor(uint32_t attachmentSlot) { - return dsvHeap.GetCPUHandle(attachmentHeapIndices[attachmentSlot]); + return mDsvHeap.GetCPUHandle(mAttachmentHeapIndices[attachmentSlot]); } } diff --git a/src/backend/d3d12/FramebufferD3D12.h b/src/backend/d3d12/FramebufferD3D12.h index 677b21bef5..5855654287 100644 --- a/src/backend/d3d12/FramebufferD3D12.h +++ b/src/backend/d3d12/FramebufferD3D12.h @@ -43,12 +43,12 @@ namespace d3d12 { D3D12_CPU_DESCRIPTOR_HANDLE GetDSVDescriptor(uint32_t attachmentSlot); private: - Device* device = nullptr; - DescriptorHeapHandle rtvHeap = {}; - DescriptorHeapHandle dsvHeap = {}; + Device* mDevice = nullptr; + DescriptorHeapHandle mRtvHeap = {}; + DescriptorHeapHandle mDsvHeap = {}; // Indices into either the RTV or DSV heap, depending on texture format. - std::vector attachmentHeapIndices; + std::vector mAttachmentHeapIndices; }; } diff --git a/src/backend/d3d12/InputStateD3D12.cpp b/src/backend/d3d12/InputStateD3D12.cpp index a02cd73332..592f64c10c 100644 --- a/src/backend/d3d12/InputStateD3D12.cpp +++ b/src/backend/d3d12/InputStateD3D12.cpp @@ -46,7 +46,7 @@ namespace d3d12 { } InputState::InputState(Device* device, InputStateBuilder* builder) - : InputStateBase(builder), device(device) { + : InputStateBase(builder), mDevice(device) { const auto& attributesSetMask = GetAttributesSetMask(); @@ -56,7 +56,7 @@ namespace d3d12 { continue; } - D3D12_INPUT_ELEMENT_DESC& inputElementDescriptor = inputElementDescriptors[count++]; + D3D12_INPUT_ELEMENT_DESC& inputElementDescriptor = mInputElementDescriptors[count++]; const AttributeInfo& attribute = GetAttribute(i); @@ -77,13 +77,13 @@ namespace d3d12 { } } - inputLayoutDescriptor.pInputElementDescs = inputElementDescriptors; - inputLayoutDescriptor.NumElements = count; + mInputLayoutDescriptor.pInputElementDescs = mInputElementDescriptors; + mInputLayoutDescriptor.NumElements = count; } const D3D12_INPUT_LAYOUT_DESC& InputState::GetD3D12InputLayoutDescriptor() const { - return inputLayoutDescriptor; + return mInputLayoutDescriptor; } } diff --git a/src/backend/d3d12/InputStateD3D12.h b/src/backend/d3d12/InputStateD3D12.h index be48238da8..9f1a1d3685 100644 --- a/src/backend/d3d12/InputStateD3D12.h +++ b/src/backend/d3d12/InputStateD3D12.h @@ -31,9 +31,9 @@ namespace d3d12 { const D3D12_INPUT_LAYOUT_DESC& GetD3D12InputLayoutDescriptor() const; private: - Device* device; - D3D12_INPUT_LAYOUT_DESC inputLayoutDescriptor; - D3D12_INPUT_ELEMENT_DESC inputElementDescriptors[kMaxVertexAttributes]; + Device* mDevice; + D3D12_INPUT_LAYOUT_DESC mInputLayoutDescriptor; + D3D12_INPUT_ELEMENT_DESC mInputElementDescriptors[kMaxVertexAttributes]; }; } diff --git a/src/backend/d3d12/PipelineLayoutD3D12.cpp b/src/backend/d3d12/PipelineLayoutD3D12.cpp index 5f3a232530..090f46242b 100644 --- a/src/backend/d3d12/PipelineLayoutD3D12.cpp +++ b/src/backend/d3d12/PipelineLayoutD3D12.cpp @@ -24,7 +24,7 @@ namespace backend { namespace d3d12 { PipelineLayout::PipelineLayout(Device* device, PipelineLayoutBuilder* builder) - : PipelineLayoutBase(builder), device(device) { + : PipelineLayoutBase(builder), mDevice(device) { D3D12_ROOT_PARAMETER rootParameters[kMaxBindGroups * 2]; @@ -70,11 +70,11 @@ namespace d3d12 { }; if (SetRootDescriptorTable(bindGroupLayout->GetCbvUavSrvDescriptorTableSize(), bindGroupLayout->GetCbvUavSrvDescriptorRanges())) { - cbvUavSrvRootParameterInfo[group] = parameterIndex++; + mCbvUavSrvRootParameterInfo[group] = parameterIndex++; } if (SetRootDescriptorTable(bindGroupLayout->GetSamplerDescriptorTableSize(), bindGroupLayout->GetSamplerDescriptorRanges())) { - samplerRootParameterInfo[group] = parameterIndex++; + mSamplerRootParameterInfo[group] = parameterIndex++; } } @@ -88,22 +88,22 @@ namespace d3d12 { ComPtr signature; ComPtr error; ASSERT_SUCCESS(D3D12SerializeRootSignature(&rootSignatureDescriptor, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error)); - ASSERT_SUCCESS(device->GetD3D12Device()->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&rootSignature))); + ASSERT_SUCCESS(device->GetD3D12Device()->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&mRootSignature))); } uint32_t PipelineLayout::GetCbvUavSrvRootParameterIndex(uint32_t group) const { ASSERT(group < kMaxBindGroups); - return cbvUavSrvRootParameterInfo[group]; + return mCbvUavSrvRootParameterInfo[group]; } uint32_t PipelineLayout::GetSamplerRootParameterIndex(uint32_t group) const { ASSERT(group < kMaxBindGroups); - return samplerRootParameterInfo[group]; + return mSamplerRootParameterInfo[group]; } ComPtr PipelineLayout::GetRootSignature() { - return rootSignature; + return mRootSignature; } } } diff --git a/src/backend/d3d12/PipelineLayoutD3D12.h b/src/backend/d3d12/PipelineLayoutD3D12.h index 8309c66096..ff80944971 100644 --- a/src/backend/d3d12/PipelineLayoutD3D12.h +++ b/src/backend/d3d12/PipelineLayoutD3D12.h @@ -34,12 +34,12 @@ namespace d3d12 { ComPtr GetRootSignature(); private: - Device* device; + Device* mDevice; - std::array cbvUavSrvRootParameterInfo; - std::array samplerRootParameterInfo; + std::array mCbvUavSrvRootParameterInfo; + std::array mSamplerRootParameterInfo; - ComPtr rootSignature; + ComPtr mRootSignature; }; } diff --git a/src/backend/d3d12/QueueD3D12.cpp b/src/backend/d3d12/QueueD3D12.cpp index 48ef895adb..ba3f860d2e 100644 --- a/src/backend/d3d12/QueueD3D12.cpp +++ b/src/backend/d3d12/QueueD3D12.cpp @@ -21,21 +21,21 @@ namespace backend { namespace d3d12 { Queue::Queue(Device* device, QueueBuilder* builder) - : QueueBase(builder), device(device) { + : QueueBase(builder), mDevice(device) { } void Queue::Submit(uint32_t numCommands, CommandBuffer* const * commands) { - device->Tick(); + mDevice->Tick(); - device->OpenCommandList(&commandList); + mDevice->OpenCommandList(&mCommandList); for (uint32_t i = 0; i < numCommands; ++i) { - commands[i]->FillCommands(commandList); + commands[i]->FillCommands(mCommandList); } - ASSERT_SUCCESS(commandList->Close()); + ASSERT_SUCCESS(mCommandList->Close()); - device->ExecuteCommandLists({ commandList.Get() }); + mDevice->ExecuteCommandLists({ mCommandList.Get() }); - device->NextSerial(); + mDevice->NextSerial(); } } diff --git a/src/backend/d3d12/QueueD3D12.h b/src/backend/d3d12/QueueD3D12.h index 839bb91761..668b3b74e4 100644 --- a/src/backend/d3d12/QueueD3D12.h +++ b/src/backend/d3d12/QueueD3D12.h @@ -33,9 +33,9 @@ namespace d3d12 { void Submit(uint32_t numCommands, CommandBuffer* const * commands); private: - Device* device; + Device* mDevice; - ComPtr commandList; + ComPtr mCommandList; }; } diff --git a/src/backend/d3d12/RenderPipelineD3D12.cpp b/src/backend/d3d12/RenderPipelineD3D12.cpp index 8a4744752c..d400eb5d8a 100644 --- a/src/backend/d3d12/RenderPipelineD3D12.cpp +++ b/src/backend/d3d12/RenderPipelineD3D12.cpp @@ -63,7 +63,7 @@ namespace d3d12 { } RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder) - : RenderPipelineBase(builder), d3d12PrimitiveTopology(D3D12PrimitiveTopology(GetPrimitiveTopology())) { + : RenderPipelineBase(builder), mD3d12PrimitiveTopology(D3D12PrimitiveTopology(GetPrimitiveTopology())) { uint32_t compileFlags = 0; #if defined(_DEBUG) // Enable better shader debugging with the graphics debugging tools. @@ -174,15 +174,15 @@ namespace d3d12 { descriptor.SampleDesc.Count = 1; Device* device = ToBackend(builder->GetDevice()); - ASSERT_SUCCESS(device->GetD3D12Device()->CreateGraphicsPipelineState(&descriptor, IID_PPV_ARGS(&pipelineState))); + ASSERT_SUCCESS(device->GetD3D12Device()->CreateGraphicsPipelineState(&descriptor, IID_PPV_ARGS(&mPipelineState))); } D3D12_PRIMITIVE_TOPOLOGY RenderPipeline::GetD3D12PrimitiveTopology() const { - return d3d12PrimitiveTopology; + return mD3d12PrimitiveTopology; } ComPtr RenderPipeline::GetPipelineState() { - return pipelineState; + return mPipelineState; } } diff --git a/src/backend/d3d12/RenderPipelineD3D12.h b/src/backend/d3d12/RenderPipelineD3D12.h index 81cdf7c85c..e27ec37952 100644 --- a/src/backend/d3d12/RenderPipelineD3D12.h +++ b/src/backend/d3d12/RenderPipelineD3D12.h @@ -30,8 +30,8 @@ namespace d3d12 { ComPtr GetPipelineState(); private: - D3D12_PRIMITIVE_TOPOLOGY d3d12PrimitiveTopology; - ComPtr pipelineState; + D3D12_PRIMITIVE_TOPOLOGY mD3d12PrimitiveTopology; + ComPtr mPipelineState; }; } diff --git a/src/backend/d3d12/ResourceAllocator.cpp b/src/backend/d3d12/ResourceAllocator.cpp index cbad3996ac..edfde70e1b 100644 --- a/src/backend/d3d12/ResourceAllocator.cpp +++ b/src/backend/d3d12/ResourceAllocator.cpp @@ -45,7 +45,7 @@ namespace d3d12 { }; } - ResourceAllocator::ResourceAllocator(Device* device) : device(device) { + ResourceAllocator::ResourceAllocator(Device* device) : mDevice(device) { } ComPtr ResourceAllocator::Allocate(D3D12_HEAP_TYPE heapType, const D3D12_RESOURCE_DESC &resourceDescriptor, D3D12_RESOURCE_STATES initialUsage) { @@ -67,7 +67,7 @@ namespace d3d12 { ComPtr resource; // TODO(enga@google.com): Use CreatePlacedResource - ASSERT_SUCCESS(device->GetD3D12Device()->CreateCommittedResource( + ASSERT_SUCCESS(mDevice->GetD3D12Device()->CreateCommittedResource( heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDescriptor, @@ -81,11 +81,11 @@ namespace d3d12 { void ResourceAllocator::Release(ComPtr resource) { // Resources may still be in use on the GPU. Enqueue them so that we hold onto them until GPU execution has completed - releasedResources.Enqueue(resource, device->GetSerial()); + mReleasedResources.Enqueue(resource, mDevice->GetSerial()); } void ResourceAllocator::Tick(uint64_t lastCompletedSerial) { - releasedResources.ClearUpTo(lastCompletedSerial); + mReleasedResources.ClearUpTo(lastCompletedSerial); } } diff --git a/src/backend/d3d12/ResourceAllocator.h b/src/backend/d3d12/ResourceAllocator.h index 63823d388d..287619fb9f 100644 --- a/src/backend/d3d12/ResourceAllocator.h +++ b/src/backend/d3d12/ResourceAllocator.h @@ -34,9 +34,9 @@ namespace d3d12 { void Tick(uint64_t lastCompletedSerial); private: - Device* device; + Device* mDevice; - SerialQueue> releasedResources; + SerialQueue> mReleasedResources; }; } diff --git a/src/backend/d3d12/ResourceUploader.cpp b/src/backend/d3d12/ResourceUploader.cpp index 972b615371..19be7c266b 100644 --- a/src/backend/d3d12/ResourceUploader.cpp +++ b/src/backend/d3d12/ResourceUploader.cpp @@ -20,7 +20,7 @@ namespace backend { namespace d3d12 { - ResourceUploader::ResourceUploader(Device* device) : device(device) { + ResourceUploader::ResourceUploader(Device* device) : mDevice(device) { } void ResourceUploader::BufferSubData(ComPtr resource, uint32_t start, uint32_t count, const void* data) { @@ -28,7 +28,7 @@ namespace d3d12 { // Alternatively, the SerialQueue could be used to track which last point of the ringbuffer is in use, and start reusing chunks of it that aren't in flight. UploadHandle uploadHandle = GetUploadBuffer(count); memcpy(uploadHandle.mappedBuffer, data, count); - device->GetPendingCommandList()->CopyBufferRegion(resource.Get(), start, uploadHandle.resource.Get(), 0, count); + mDevice->GetPendingCommandList()->CopyBufferRegion(resource.Get(), start, uploadHandle.resource.Get(), 0, count); Release(uploadHandle); } @@ -48,7 +48,7 @@ namespace d3d12 { resourceDescriptor.Flags = D3D12_RESOURCE_FLAG_NONE; UploadHandle uploadHandle; - uploadHandle.resource = device->GetResourceAllocator()->Allocate(D3D12_HEAP_TYPE_UPLOAD, resourceDescriptor, D3D12_RESOURCE_STATE_GENERIC_READ); + uploadHandle.resource = mDevice->GetResourceAllocator()->Allocate(D3D12_HEAP_TYPE_UPLOAD, resourceDescriptor, D3D12_RESOURCE_STATE_GENERIC_READ); D3D12_RANGE readRange; readRange.Begin = 0; readRange.End = 0; @@ -59,7 +59,7 @@ namespace d3d12 { void ResourceUploader::Release(UploadHandle uploadHandle) { uploadHandle.resource->Unmap(0, nullptr); - device->GetResourceAllocator()->Release(uploadHandle.resource); + mDevice->GetResourceAllocator()->Release(uploadHandle.resource); } } diff --git a/src/backend/d3d12/ResourceUploader.h b/src/backend/d3d12/ResourceUploader.h index 25506251d1..cdcb372d49 100644 --- a/src/backend/d3d12/ResourceUploader.h +++ b/src/backend/d3d12/ResourceUploader.h @@ -39,7 +39,7 @@ namespace d3d12 { UploadHandle GetUploadBuffer(uint32_t requiredSize); void Release(UploadHandle uploadHandle); - Device* device; + Device* mDevice; }; } } diff --git a/src/backend/d3d12/SamplerD3D12.cpp b/src/backend/d3d12/SamplerD3D12.cpp index 67e5d91017..18f8e854c7 100644 --- a/src/backend/d3d12/SamplerD3D12.cpp +++ b/src/backend/d3d12/SamplerD3D12.cpp @@ -62,21 +62,21 @@ namespace d3d12 { break; } - samplerDesc.Filter = static_cast(mode); - samplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - samplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - samplerDesc.MipLODBias = 0.f; - samplerDesc.MaxAnisotropy = 1; - samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; - samplerDesc.BorderColor[0] = samplerDesc.BorderColor[1] = samplerDesc.BorderColor[2] = samplerDesc.BorderColor[3] = 0; - samplerDesc.MinLOD = 0; - samplerDesc.MaxLOD = D3D12_FLOAT32_MAX; + mSamplerDesc.Filter = static_cast(mode); + mSamplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; + mSamplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP; + mSamplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; + mSamplerDesc.MipLODBias = 0.f; + mSamplerDesc.MaxAnisotropy = 1; + mSamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; + mSamplerDesc.BorderColor[0] = mSamplerDesc.BorderColor[1] = mSamplerDesc.BorderColor[2] = mSamplerDesc.BorderColor[3] = 0; + mSamplerDesc.MinLOD = 0; + mSamplerDesc.MaxLOD = D3D12_FLOAT32_MAX; } const D3D12_SAMPLER_DESC& Sampler::GetSamplerDescriptor() const { - return samplerDesc; + return mSamplerDesc; } } diff --git a/src/backend/d3d12/SamplerD3D12.h b/src/backend/d3d12/SamplerD3D12.h index 9201cd3d9c..153a531d24 100644 --- a/src/backend/d3d12/SamplerD3D12.h +++ b/src/backend/d3d12/SamplerD3D12.h @@ -29,7 +29,7 @@ namespace d3d12 { const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const; private: - D3D12_SAMPLER_DESC samplerDesc; + D3D12_SAMPLER_DESC mSamplerDesc; }; } diff --git a/src/backend/d3d12/ShaderModuleD3D12.cpp b/src/backend/d3d12/ShaderModuleD3D12.cpp index 2e7c7c73ea..3056875149 100644 --- a/src/backend/d3d12/ShaderModuleD3D12.cpp +++ b/src/backend/d3d12/ShaderModuleD3D12.cpp @@ -20,7 +20,7 @@ namespace backend { namespace d3d12 { ShaderModule::ShaderModule(Device* device, ShaderModuleBuilder* builder) - : ShaderModuleBase(builder), device(device) { + : ShaderModuleBase(builder), mDevice(device) { spirv_cross::CompilerHLSL compiler(builder->AcquireSpirv()); spirv_cross::CompilerGLSL::Options options_glsl; @@ -52,11 +52,11 @@ namespace d3d12 { RenumberBindings(resources.separate_images); // t RenumberBindings(resources.separate_samplers); // s - hlslSource = compiler.compile(); + mHlslSource = compiler.compile(); } const std::string& ShaderModule::GetHLSLSource() const { - return hlslSource; + return mHlslSource; } } diff --git a/src/backend/d3d12/ShaderModuleD3D12.h b/src/backend/d3d12/ShaderModuleD3D12.h index 4670f827c6..cba2fc4210 100644 --- a/src/backend/d3d12/ShaderModuleD3D12.h +++ b/src/backend/d3d12/ShaderModuleD3D12.h @@ -29,9 +29,9 @@ namespace d3d12 { const std::string& GetHLSLSource() const; private: - Device* device; + Device* mDevice; - std::string hlslSource; + std::string mHlslSource; }; } diff --git a/src/backend/d3d12/TextureD3D12.cpp b/src/backend/d3d12/TextureD3D12.cpp index 5c7fb78a40..ad701de662 100644 --- a/src/backend/d3d12/TextureD3D12.cpp +++ b/src/backend/d3d12/TextureD3D12.cpp @@ -93,7 +93,7 @@ namespace d3d12 { } Texture::Texture(TextureBuilder* builder) - : TextureBase(builder), device(ToBackend(builder->GetDevice())) { + : TextureBase(builder), mDevice(ToBackend(builder->GetDevice())) { D3D12_RESOURCE_DESC resourceDescriptor; resourceDescriptor.Dimension = D3D12TextureDimension(GetDimension()); @@ -108,20 +108,20 @@ namespace d3d12 { resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; resourceDescriptor.Flags = D3D12ResourceFlags(GetAllowedUsage(), GetFormat()); - resource = device->GetResourceAllocator()->Allocate(D3D12_HEAP_TYPE_DEFAULT, resourceDescriptor, D3D12TextureUsage(GetUsage(), GetFormat())); - resourcePtr = resource.Get(); + mResource = mDevice->GetResourceAllocator()->Allocate(D3D12_HEAP_TYPE_DEFAULT, resourceDescriptor, D3D12TextureUsage(GetUsage(), GetFormat())); + mResourcePtr = mResource.Get(); } // With this constructor, the lifetime of the ID3D12Resource is externally managed. Texture::Texture(TextureBuilder* builder, ID3D12Resource* nativeTexture) - : TextureBase(builder), device(ToBackend(builder->GetDevice())), - resourcePtr(nativeTexture) { + : TextureBase(builder), mDevice(ToBackend(builder->GetDevice())), + mResourcePtr(nativeTexture) { } Texture::~Texture() { - if (resource) { + if (mResource) { // If we own the resource, release it. - device->GetResourceAllocator()->Release(resource); + mDevice->GetResourceAllocator()->Release(mResource); } } @@ -130,7 +130,7 @@ namespace d3d12 { } ID3D12Resource* Texture::GetD3D12Resource() { - return resourcePtr; + return mResourcePtr; } bool Texture::GetResourceTransitionBarrier(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage, D3D12_RESOURCE_BARRIER* barrier) { @@ -143,7 +143,7 @@ namespace d3d12 { barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrier->Transition.pResource = resourcePtr; + barrier->Transition.pResource = mResourcePtr; barrier->Transition.StateBefore = stateBefore; barrier->Transition.StateAfter = stateAfter; barrier->Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; @@ -154,28 +154,28 @@ namespace d3d12 { void Texture::TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) { D3D12_RESOURCE_BARRIER barrier; if (GetResourceTransitionBarrier(currentUsage, targetUsage, &barrier)) { - device->GetPendingCommandList()->ResourceBarrier(1, &barrier); + mDevice->GetPendingCommandList()->ResourceBarrier(1, &barrier); } } TextureView::TextureView(TextureViewBuilder* builder) : TextureViewBase(builder) { - srvDesc.Format = D3D12TextureFormat(GetTexture()->GetFormat()); - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + mSrvDesc.Format = D3D12TextureFormat(GetTexture()->GetFormat()); + mSrvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; switch (GetTexture()->GetDimension()) { case nxt::TextureDimension::e2D: - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MostDetailedMip = 0; - srvDesc.Texture2D.MipLevels = GetTexture()->GetNumMipLevels(); - srvDesc.Texture2D.PlaneSlice = 0; - srvDesc.Texture2D.ResourceMinLODClamp = 0; + mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + mSrvDesc.Texture2D.MostDetailedMip = 0; + mSrvDesc.Texture2D.MipLevels = GetTexture()->GetNumMipLevels(); + mSrvDesc.Texture2D.PlaneSlice = 0; + mSrvDesc.Texture2D.ResourceMinLODClamp = 0; break; } } const D3D12_SHADER_RESOURCE_VIEW_DESC& TextureView::GetSRVDescriptor() const { - return srvDesc; + return mSrvDesc; } D3D12_RENDER_TARGET_VIEW_DESC TextureView::GetRTVDescriptor() { diff --git a/src/backend/d3d12/TextureD3D12.h b/src/backend/d3d12/TextureD3D12.h index 670ee43147..d9fcfd48be 100644 --- a/src/backend/d3d12/TextureD3D12.h +++ b/src/backend/d3d12/TextureD3D12.h @@ -39,9 +39,9 @@ namespace d3d12 { void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override; private: - Device* device; - ComPtr resource = {}; - ID3D12Resource* resourcePtr = nullptr; + Device* mDevice; + ComPtr mResource = {}; + ID3D12Resource* mResourcePtr = nullptr; }; class TextureView : public TextureViewBase { @@ -53,7 +53,7 @@ namespace d3d12 { D3D12_DEPTH_STENCIL_VIEW_DESC GetDSVDescriptor(); private: - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc; + D3D12_SHADER_RESOURCE_VIEW_DESC mSrvDesc; }; } }