D3D12: Remove ComPtr from d3d12::Buffer::GetD3D12Resource

Creating lots of SRVs needlessly refcounts and floods PIX traces.

BUG=dawn:155

Change-Id: I26fd1019c8c1326f0e6db3e94240a29e4d466be1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24002
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Bryan Bernhart 2020-06-29 08:50:03 +00:00 committed by Commit Bot service account
parent 330c272fc4
commit b7ece23ffc
10 changed files with 21 additions and 24 deletions

View File

@ -88,7 +88,7 @@ namespace dawn_native { namespace d3d12 {
desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
d3d12Device->CreateUnorderedAccessView(
ToBackend(binding.buffer)->GetD3D12Resource().Get(), nullptr, &desc,
ToBackend(binding.buffer)->GetD3D12Resource(), nullptr, &desc,
viewAllocation.OffsetFrom(viewSizeIncrement, bindingOffsets[bindingIndex]));
break;
}
@ -108,7 +108,7 @@ namespace dawn_native { namespace d3d12 {
desc.Buffer.StructureByteStride = 0;
desc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW;
d3d12Device->CreateShaderResourceView(
ToBackend(binding.buffer)->GetD3D12Resource().Get(), &desc,
ToBackend(binding.buffer)->GetD3D12Resource(), &desc,
viewAllocation.OffsetFrom(viewSizeIncrement, bindingOffsets[bindingIndex]));
break;
}

View File

@ -133,7 +133,7 @@ namespace dawn_native { namespace d3d12 {
DestroyInternal();
}
ComPtr<ID3D12Resource> Buffer::GetD3D12Resource() const {
ID3D12Resource* Buffer::GetD3D12Resource() const {
return mResourceAllocation.GetD3D12Resource();
}
@ -183,7 +183,7 @@ namespace dawn_native { namespace d3d12 {
if (needsUAVBarrier) {
barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier->UAV.pResource = GetD3D12Resource().Get();
barrier->UAV.pResource = GetD3D12Resource();
mLastUsage = newUsage;
return true;
@ -227,7 +227,7 @@ namespace dawn_native { namespace d3d12 {
barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
barrier->Transition.pResource = GetD3D12Resource().Get();
barrier->Transition.pResource = GetD3D12Resource();
barrier->Transition.StateBefore = lastState;
barrier->Transition.StateAfter = newState;
barrier->Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;

View File

@ -32,7 +32,7 @@ namespace dawn_native { namespace d3d12 {
MaybeError Initialize();
ComPtr<ID3D12Resource> GetD3D12Resource() const;
ID3D12Resource* GetD3D12Resource() const;
D3D12_GPU_VIRTUAL_ADDRESS GetVA() const;
bool TrackUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,

View File

@ -566,8 +566,8 @@ namespace dawn_native { namespace d3d12 {
wgpu::BufferUsage::CopyDst);
commandList->CopyBufferRegion(
dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset,
srcBuffer->GetD3D12Resource().Get(), copy->sourceOffset, copy->size);
dstBuffer->GetD3D12Resource(), copy->destinationOffset,
srcBuffer->GetD3D12Resource(), copy->sourceOffset, copy->size);
break;
}
@ -618,7 +618,7 @@ namespace dawn_native { namespace d3d12 {
D3D12_TEXTURE_COPY_LOCATION bufferLocation =
ComputeBufferLocationForCopyTextureRegion(
texture, buffer->GetD3D12Resource().Get(), info.bufferSize,
texture, buffer->GetD3D12Resource(), info.bufferSize,
copySplit.offset, copy->source.bytesPerRow);
D3D12_BOX sourceRegion =
ComputeD3D12BoxFromOffsetAndSize(info.bufferOffset, info.copySize);
@ -673,7 +673,7 @@ namespace dawn_native { namespace d3d12 {
D3D12_TEXTURE_COPY_LOCATION bufferLocation =
ComputeBufferLocationForCopyTextureRegion(
texture, buffer->GetD3D12Resource().Get(), info.bufferSize,
texture, buffer->GetD3D12Resource(), info.bufferSize,
copySplit.offset, copy->destination.bytesPerRow);
D3D12_BOX sourceRegion =
@ -787,8 +787,7 @@ namespace dawn_native { namespace d3d12 {
Buffer* buffer = ToBackend(dispatch->indirectBuffer.Get());
ComPtr<ID3D12CommandSignature> signature =
ToBackend(GetDevice())->GetDispatchIndirectSignature();
commandList->ExecuteIndirect(signature.Get(), 1,
buffer->GetD3D12Resource().Get(),
commandList->ExecuteIndirect(signature.Get(), 1, buffer->GetD3D12Resource(),
dispatch->indirectOffset, nullptr, 0);
break;
}
@ -1103,8 +1102,7 @@ namespace dawn_native { namespace d3d12 {
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
ComPtr<ID3D12CommandSignature> signature =
ToBackend(GetDevice())->GetDrawIndirectSignature();
commandList->ExecuteIndirect(signature.Get(), 1,
buffer->GetD3D12Resource().Get(),
commandList->ExecuteIndirect(signature.Get(), 1, buffer->GetD3D12Resource(),
draw->indirectOffset, nullptr, 0);
break;
}
@ -1118,8 +1116,7 @@ namespace dawn_native { namespace d3d12 {
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
ComPtr<ID3D12CommandSignature> signature =
ToBackend(GetDevice())->GetDrawIndexedIndirectSignature();
commandList->ExecuteIndirect(signature.Get(), 1,
buffer->GetD3D12Resource().Get(),
commandList->ExecuteIndirect(signature.Get(), 1, buffer->GetD3D12Resource(),
draw->indirectOffset, nullptr, 0);
break;
}

View File

@ -340,7 +340,7 @@ namespace dawn_native { namespace d3d12 {
dstBuffer->TrackUsageAndTransitionNow(commandRecordingContext, wgpu::BufferUsage::CopyDst);
commandRecordingContext->GetCommandList()->CopyBufferRegion(
dstBuffer->GetD3D12Resource().Get(), destinationOffset, srcBuffer->GetResource(),
dstBuffer->GetD3D12Resource(), destinationOffset, srcBuffer->GetResource(),
sourceOffset, size);
return {};

View File

@ -221,7 +221,7 @@ namespace dawn_native { namespace d3d12 {
// calls DeallocateMemory again using the same allocation.
allocation.Invalidate();
ASSERT(allocation.GetD3D12Resource().Get() == nullptr);
ASSERT(allocation.GetD3D12Resource() == nullptr);
}
void ResourceAllocatorManager::FreeMemory(ResourceHeapAllocation& allocation) {

View File

@ -32,8 +32,8 @@ namespace dawn_native { namespace d3d12 {
mResource.Reset();
}
ComPtr<ID3D12Resource> ResourceHeapAllocation::GetD3D12Resource() const {
return mResource;
ID3D12Resource* ResourceHeapAllocation::GetD3D12Resource() const {
return mResource.Get();
}
D3D12_GPU_VIRTUAL_ADDRESS ResourceHeapAllocation::GetGPUPointer() const {

View File

@ -33,7 +33,7 @@ namespace dawn_native { namespace d3d12 {
void Invalidate() override;
ComPtr<ID3D12Resource> GetD3D12Resource() const;
ID3D12Resource* GetD3D12Resource() const;
D3D12_GPU_VIRTUAL_ADDRESS GetGPUPointer() const;
private:

View File

@ -69,6 +69,6 @@ namespace dawn_native { namespace d3d12 {
}
ID3D12Resource* StagingBuffer::GetResource() const {
return mUploadHeap.GetD3D12Resource().Get();
return mUploadHeap.GetD3D12Resource();
}
}} // namespace dawn_native::d3d12

View File

@ -527,7 +527,7 @@ namespace dawn_native { namespace d3d12 {
if (mSwapChainTexture) {
ID3D12SharingContract* d3dSharingContract = device->GetSharingContract();
if (d3dSharingContract != nullptr) {
d3dSharingContract->Present(mResourceAllocation.GetD3D12Resource().Get(), 0, 0);
d3dSharingContract->Present(mResourceAllocation.GetD3D12Resource(), 0, 0);
}
}
@ -544,7 +544,7 @@ namespace dawn_native { namespace d3d12 {
}
ID3D12Resource* Texture::GetD3D12Resource() const {
return mResourceAllocation.GetD3D12Resource().Get();
return mResourceAllocation.GetD3D12Resource();
}
void Texture::TrackUsageAndTransitionNow(CommandRecordingContext* commandContext,