mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-30 03:01:27 +00:00
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:
parent
330c272fc4
commit
b7ece23ffc
@ -88,7 +88,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
|
desc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
|
||||||
|
|
||||||
d3d12Device->CreateUnorderedAccessView(
|
d3d12Device->CreateUnorderedAccessView(
|
||||||
ToBackend(binding.buffer)->GetD3D12Resource().Get(), nullptr, &desc,
|
ToBackend(binding.buffer)->GetD3D12Resource(), nullptr, &desc,
|
||||||
viewAllocation.OffsetFrom(viewSizeIncrement, bindingOffsets[bindingIndex]));
|
viewAllocation.OffsetFrom(viewSizeIncrement, bindingOffsets[bindingIndex]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
desc.Buffer.StructureByteStride = 0;
|
desc.Buffer.StructureByteStride = 0;
|
||||||
desc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW;
|
desc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW;
|
||||||
d3d12Device->CreateShaderResourceView(
|
d3d12Device->CreateShaderResourceView(
|
||||||
ToBackend(binding.buffer)->GetD3D12Resource().Get(), &desc,
|
ToBackend(binding.buffer)->GetD3D12Resource(), &desc,
|
||||||
viewAllocation.OffsetFrom(viewSizeIncrement, bindingOffsets[bindingIndex]));
|
viewAllocation.OffsetFrom(viewSizeIncrement, bindingOffsets[bindingIndex]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
DestroyInternal();
|
DestroyInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<ID3D12Resource> Buffer::GetD3D12Resource() const {
|
ID3D12Resource* Buffer::GetD3D12Resource() const {
|
||||||
return mResourceAllocation.GetD3D12Resource();
|
return mResourceAllocation.GetD3D12Resource();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
if (needsUAVBarrier) {
|
if (needsUAVBarrier) {
|
||||||
barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
|
barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
|
||||||
barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||||
barrier->UAV.pResource = GetD3D12Resource().Get();
|
barrier->UAV.pResource = GetD3D12Resource();
|
||||||
|
|
||||||
mLastUsage = newUsage;
|
mLastUsage = newUsage;
|
||||||
return true;
|
return true;
|
||||||
@ -227,7 +227,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
barrier->Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||||
barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
barrier->Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||||
barrier->Transition.pResource = GetD3D12Resource().Get();
|
barrier->Transition.pResource = GetD3D12Resource();
|
||||||
barrier->Transition.StateBefore = lastState;
|
barrier->Transition.StateBefore = lastState;
|
||||||
barrier->Transition.StateAfter = newState;
|
barrier->Transition.StateAfter = newState;
|
||||||
barrier->Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
barrier->Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
||||||
|
@ -32,7 +32,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
|
||||||
ComPtr<ID3D12Resource> GetD3D12Resource() const;
|
ID3D12Resource* GetD3D12Resource() const;
|
||||||
D3D12_GPU_VIRTUAL_ADDRESS GetVA() const;
|
D3D12_GPU_VIRTUAL_ADDRESS GetVA() const;
|
||||||
|
|
||||||
bool TrackUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
|
bool TrackUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
|
||||||
|
@ -566,8 +566,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
wgpu::BufferUsage::CopyDst);
|
wgpu::BufferUsage::CopyDst);
|
||||||
|
|
||||||
commandList->CopyBufferRegion(
|
commandList->CopyBufferRegion(
|
||||||
dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset,
|
dstBuffer->GetD3D12Resource(), copy->destinationOffset,
|
||||||
srcBuffer->GetD3D12Resource().Get(), copy->sourceOffset, copy->size);
|
srcBuffer->GetD3D12Resource(), copy->sourceOffset, copy->size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +618,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
||||||
ComputeBufferLocationForCopyTextureRegion(
|
ComputeBufferLocationForCopyTextureRegion(
|
||||||
texture, buffer->GetD3D12Resource().Get(), info.bufferSize,
|
texture, buffer->GetD3D12Resource(), info.bufferSize,
|
||||||
copySplit.offset, copy->source.bytesPerRow);
|
copySplit.offset, copy->source.bytesPerRow);
|
||||||
D3D12_BOX sourceRegion =
|
D3D12_BOX sourceRegion =
|
||||||
ComputeD3D12BoxFromOffsetAndSize(info.bufferOffset, info.copySize);
|
ComputeD3D12BoxFromOffsetAndSize(info.bufferOffset, info.copySize);
|
||||||
@ -673,7 +673,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
||||||
ComputeBufferLocationForCopyTextureRegion(
|
ComputeBufferLocationForCopyTextureRegion(
|
||||||
texture, buffer->GetD3D12Resource().Get(), info.bufferSize,
|
texture, buffer->GetD3D12Resource(), info.bufferSize,
|
||||||
copySplit.offset, copy->destination.bytesPerRow);
|
copySplit.offset, copy->destination.bytesPerRow);
|
||||||
|
|
||||||
D3D12_BOX sourceRegion =
|
D3D12_BOX sourceRegion =
|
||||||
@ -787,8 +787,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
Buffer* buffer = ToBackend(dispatch->indirectBuffer.Get());
|
Buffer* buffer = ToBackend(dispatch->indirectBuffer.Get());
|
||||||
ComPtr<ID3D12CommandSignature> signature =
|
ComPtr<ID3D12CommandSignature> signature =
|
||||||
ToBackend(GetDevice())->GetDispatchIndirectSignature();
|
ToBackend(GetDevice())->GetDispatchIndirectSignature();
|
||||||
commandList->ExecuteIndirect(signature.Get(), 1,
|
commandList->ExecuteIndirect(signature.Get(), 1, buffer->GetD3D12Resource(),
|
||||||
buffer->GetD3D12Resource().Get(),
|
|
||||||
dispatch->indirectOffset, nullptr, 0);
|
dispatch->indirectOffset, nullptr, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1103,8 +1102,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
|
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
|
||||||
ComPtr<ID3D12CommandSignature> signature =
|
ComPtr<ID3D12CommandSignature> signature =
|
||||||
ToBackend(GetDevice())->GetDrawIndirectSignature();
|
ToBackend(GetDevice())->GetDrawIndirectSignature();
|
||||||
commandList->ExecuteIndirect(signature.Get(), 1,
|
commandList->ExecuteIndirect(signature.Get(), 1, buffer->GetD3D12Resource(),
|
||||||
buffer->GetD3D12Resource().Get(),
|
|
||||||
draw->indirectOffset, nullptr, 0);
|
draw->indirectOffset, nullptr, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1118,8 +1116,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
|
Buffer* buffer = ToBackend(draw->indirectBuffer.Get());
|
||||||
ComPtr<ID3D12CommandSignature> signature =
|
ComPtr<ID3D12CommandSignature> signature =
|
||||||
ToBackend(GetDevice())->GetDrawIndexedIndirectSignature();
|
ToBackend(GetDevice())->GetDrawIndexedIndirectSignature();
|
||||||
commandList->ExecuteIndirect(signature.Get(), 1,
|
commandList->ExecuteIndirect(signature.Get(), 1, buffer->GetD3D12Resource(),
|
||||||
buffer->GetD3D12Resource().Get(),
|
|
||||||
draw->indirectOffset, nullptr, 0);
|
draw->indirectOffset, nullptr, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
dstBuffer->TrackUsageAndTransitionNow(commandRecordingContext, wgpu::BufferUsage::CopyDst);
|
dstBuffer->TrackUsageAndTransitionNow(commandRecordingContext, wgpu::BufferUsage::CopyDst);
|
||||||
|
|
||||||
commandRecordingContext->GetCommandList()->CopyBufferRegion(
|
commandRecordingContext->GetCommandList()->CopyBufferRegion(
|
||||||
dstBuffer->GetD3D12Resource().Get(), destinationOffset, srcBuffer->GetResource(),
|
dstBuffer->GetD3D12Resource(), destinationOffset, srcBuffer->GetResource(),
|
||||||
sourceOffset, size);
|
sourceOffset, size);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -221,7 +221,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
// calls DeallocateMemory again using the same allocation.
|
// calls DeallocateMemory again using the same allocation.
|
||||||
allocation.Invalidate();
|
allocation.Invalidate();
|
||||||
|
|
||||||
ASSERT(allocation.GetD3D12Resource().Get() == nullptr);
|
ASSERT(allocation.GetD3D12Resource() == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceAllocatorManager::FreeMemory(ResourceHeapAllocation& allocation) {
|
void ResourceAllocatorManager::FreeMemory(ResourceHeapAllocation& allocation) {
|
||||||
|
@ -32,8 +32,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
mResource.Reset();
|
mResource.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<ID3D12Resource> ResourceHeapAllocation::GetD3D12Resource() const {
|
ID3D12Resource* ResourceHeapAllocation::GetD3D12Resource() const {
|
||||||
return mResource;
|
return mResource.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_GPU_VIRTUAL_ADDRESS ResourceHeapAllocation::GetGPUPointer() const {
|
D3D12_GPU_VIRTUAL_ADDRESS ResourceHeapAllocation::GetGPUPointer() const {
|
||||||
|
@ -33,7 +33,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
|
|
||||||
void Invalidate() override;
|
void Invalidate() override;
|
||||||
|
|
||||||
ComPtr<ID3D12Resource> GetD3D12Resource() const;
|
ID3D12Resource* GetD3D12Resource() const;
|
||||||
D3D12_GPU_VIRTUAL_ADDRESS GetGPUPointer() const;
|
D3D12_GPU_VIRTUAL_ADDRESS GetGPUPointer() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -69,6 +69,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ID3D12Resource* StagingBuffer::GetResource() const {
|
ID3D12Resource* StagingBuffer::GetResource() const {
|
||||||
return mUploadHeap.GetD3D12Resource().Get();
|
return mUploadHeap.GetD3D12Resource();
|
||||||
}
|
}
|
||||||
}} // namespace dawn_native::d3d12
|
}} // namespace dawn_native::d3d12
|
||||||
|
@ -527,7 +527,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
if (mSwapChainTexture) {
|
if (mSwapChainTexture) {
|
||||||
ID3D12SharingContract* d3dSharingContract = device->GetSharingContract();
|
ID3D12SharingContract* d3dSharingContract = device->GetSharingContract();
|
||||||
if (d3dSharingContract != nullptr) {
|
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 {
|
ID3D12Resource* Texture::GetD3D12Resource() const {
|
||||||
return mResourceAllocation.GetD3D12Resource().Get();
|
return mResourceAllocation.GetD3D12Resource();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::TrackUsageAndTransitionNow(CommandRecordingContext* commandContext,
|
void Texture::TrackUsageAndTransitionNow(CommandRecordingContext* commandContext,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user