d3d11: merge CommandRecordingContext::GetD3D11DeviceContext?()
Bug: 1938
Change-Id: I8602837e7e8b66d9bc8020355d331d873c14de35
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/157961
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/d3d11/BindGroupTrackerD3D11.cpp b/src/dawn/native/d3d11/BindGroupTrackerD3D11.cpp
index 51aa170..e9f192b 100644
--- a/src/dawn/native/d3d11/BindGroupTrackerD3D11.cpp
+++ b/src/dawn/native/d3d11/BindGroupTrackerD3D11.cpp
@@ -45,7 +45,7 @@
namespace {
bool CheckAllSlotsAreEmpty(CommandRecordingContext* commandContext) {
- ID3D11DeviceContext1* deviceContext1 = commandContext->GetD3D11DeviceContext1();
+ auto* deviceContext = commandContext->GetD3D11DeviceContext4();
// Reserve one slot for builtin constants.
constexpr uint32_t kReservedCBVSlots = 1;
@@ -54,47 +54,47 @@
for (UINT slot = 0;
slot < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - kReservedCBVSlots; ++slot) {
ID3D11Buffer* buffer = nullptr;
- deviceContext1->VSGetConstantBuffers1(slot, 1, &buffer, nullptr, nullptr);
+ deviceContext->VSGetConstantBuffers1(slot, 1, &buffer, nullptr, nullptr);
DAWN_ASSERT(buffer == nullptr);
- deviceContext1->PSGetConstantBuffers1(slot, 1, &buffer, nullptr, nullptr);
+ deviceContext->PSGetConstantBuffers1(slot, 1, &buffer, nullptr, nullptr);
DAWN_ASSERT(buffer == nullptr);
- deviceContext1->CSGetConstantBuffers1(slot, 1, &buffer, nullptr, nullptr);
+ deviceContext->CSGetConstantBuffers1(slot, 1, &buffer, nullptr, nullptr);
DAWN_ASSERT(buffer == nullptr);
}
// Check resource slots
for (UINT slot = 0; slot < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++slot) {
ID3D11ShaderResourceView* srv = nullptr;
- deviceContext1->VSGetShaderResources(slot, 1, &srv);
+ deviceContext->VSGetShaderResources(slot, 1, &srv);
DAWN_ASSERT(srv == nullptr);
- deviceContext1->PSGetShaderResources(slot, 1, &srv);
+ deviceContext->PSGetShaderResources(slot, 1, &srv);
DAWN_ASSERT(srv == nullptr);
- deviceContext1->CSGetShaderResources(slot, 1, &srv);
+ deviceContext->CSGetShaderResources(slot, 1, &srv);
DAWN_ASSERT(srv == nullptr);
}
// Check sampler slots
for (UINT slot = 0; slot < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++slot) {
ID3D11SamplerState* sampler = nullptr;
- deviceContext1->VSGetSamplers(slot, 1, &sampler);
+ deviceContext->VSGetSamplers(slot, 1, &sampler);
DAWN_ASSERT(sampler == nullptr);
- deviceContext1->PSGetSamplers(slot, 1, &sampler);
+ deviceContext->PSGetSamplers(slot, 1, &sampler);
DAWN_ASSERT(sampler == nullptr);
- deviceContext1->CSGetSamplers(slot, 1, &sampler);
+ deviceContext->CSGetSamplers(slot, 1, &sampler);
DAWN_ASSERT(sampler == nullptr);
}
// Check UAV slots for compute
for (UINT slot = 0; slot < D3D11_1_UAV_SLOT_COUNT; ++slot) {
ID3D11UnorderedAccessView* uav = nullptr;
- deviceContext1->CSGetUnorderedAccessViews(slot, 1, &uav);
+ deviceContext->CSGetUnorderedAccessViews(slot, 1, &uav);
DAWN_ASSERT(uav == nullptr);
}
// Check UAV slots for render
for (UINT slot = 0; slot < commandContext->GetDevice()->GetUAVSlotCount(); ++slot) {
ID3D11UnorderedAccessView* uav = nullptr;
- deviceContext1->OMGetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, slot, 1,
- &uav);
+ deviceContext->OMGetRenderTargetsAndUnorderedAccessViews(0, nullptr, nullptr, slot, 1,
+ &uav);
DAWN_ASSERT(uav == nullptr);
}
@@ -102,29 +102,29 @@
}
void ResetAllRenderSlots(CommandRecordingContext* commandContext) {
- ID3D11DeviceContext1* deviceContext1 = commandContext->GetD3D11DeviceContext1();
+ auto* deviceContext = commandContext->GetD3D11DeviceContext4();
// Reserve one slot for builtin constants.
constexpr uint32_t kReservedCBVSlots = 1;
ID3D11Buffer* d3d11Buffers[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT] = {};
uint32_t num = D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - kReservedCBVSlots;
- deviceContext1->VSSetConstantBuffers1(0, num, d3d11Buffers, nullptr, nullptr);
- deviceContext1->PSSetConstantBuffers1(0, num, d3d11Buffers, nullptr, nullptr);
+ deviceContext->VSSetConstantBuffers1(0, num, d3d11Buffers, nullptr, nullptr);
+ deviceContext->PSSetConstantBuffers1(0, num, d3d11Buffers, nullptr, nullptr);
ID3D11ShaderResourceView* d3d11SRVs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {};
num = D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT;
- deviceContext1->VSSetShaderResources(0, num, d3d11SRVs);
- deviceContext1->PSSetShaderResources(0, num, d3d11SRVs);
+ deviceContext->VSSetShaderResources(0, num, d3d11SRVs);
+ deviceContext->PSSetShaderResources(0, num, d3d11SRVs);
ID3D11SamplerState* d3d11Samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT] = {};
num = D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT;
- deviceContext1->VSSetSamplers(0, num, d3d11Samplers);
- deviceContext1->PSSetSamplers(0, num, d3d11Samplers);
+ deviceContext->VSSetSamplers(0, num, d3d11Samplers);
+ deviceContext->PSSetSamplers(0, num, d3d11Samplers);
ID3D11UnorderedAccessView* d3d11UAVs[D3D11_1_UAV_SLOT_COUNT] = {};
num = commandContext->GetDevice()->GetUAVSlotCount();
- deviceContext1->OMSetRenderTargetsAndUnorderedAccessViews(
+ deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(
D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, nullptr, nullptr, 0, num, d3d11UAVs, nullptr);
}
@@ -233,7 +233,7 @@
for (auto& uav : d3d11UAVs) {
views.push_back(uav.Get());
}
- mCommandContext->GetD3D11DeviceContext1()->OMSetRenderTargetsAndUnorderedAccessViews(
+ mCommandContext->GetD3D11DeviceContext4()->OMSetRenderTargetsAndUnorderedAccessViews(
D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, nullptr, nullptr,
uavSlotCount - d3d11UAVs.size(), d3d11UAVs.size(), views.data(), nullptr);
d3d11UAVs.clear();
@@ -266,7 +266,7 @@
}
MaybeError BindGroupTracker::ApplyBindGroup(BindGroupIndex index) {
- ID3D11DeviceContext1* deviceContext1 = mCommandContext->GetD3D11DeviceContext1();
+ auto* deviceContext = mCommandContext->GetD3D11DeviceContext4();
BindGroupBase* group = mBindGroups[index];
const ityp::vector<BindingIndex, uint64_t>& dynamicOffsets = mDynamicOffsets[index];
const auto& indices = ToBackend(mPipelineLayout)->GetBindingIndexInfo()[index];
@@ -304,16 +304,16 @@
binding.buffer->GetAllocatedSize());
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetConstantBuffers1(bindingSlot, 1, &d3d11Buffer,
- &firstConstant, &numConstants);
+ deviceContext->VSSetConstantBuffers1(bindingSlot, 1, &d3d11Buffer,
+ &firstConstant, &numConstants);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetConstantBuffers1(bindingSlot, 1, &d3d11Buffer,
- &firstConstant, &numConstants);
+ deviceContext->PSSetConstantBuffers1(bindingSlot, 1, &d3d11Buffer,
+ &firstConstant, &numConstants);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetConstantBuffers1(bindingSlot, 1, &d3d11Buffer,
- &firstConstant, &numConstants);
+ deviceContext->CSSetConstantBuffers1(bindingSlot, 1, &d3d11Buffer,
+ &firstConstant, &numConstants);
}
break;
}
@@ -328,7 +328,7 @@
->CreateD3D11UnorderedAccessView1(
offset, binding.size));
ToBackend(binding.buffer)->MarkMutated();
- deviceContext1->CSSetUnorderedAccessViews(
+ deviceContext->CSSetUnorderedAccessViews(
bindingSlot, 1, d3d11UAV.GetAddressOf(), nullptr);
}
break;
@@ -339,16 +339,16 @@
ToBackend(binding.buffer)
->CreateD3D11ShaderResourceView(offset, binding.size));
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetShaderResources(bindingSlot, 1,
- d3d11SRV.GetAddressOf());
+ deviceContext->VSSetShaderResources(bindingSlot, 1,
+ d3d11SRV.GetAddressOf());
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetShaderResources(bindingSlot, 1,
- d3d11SRV.GetAddressOf());
+ deviceContext->PSSetShaderResources(bindingSlot, 1,
+ d3d11SRV.GetAddressOf());
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetShaderResources(bindingSlot, 1,
- d3d11SRV.GetAddressOf());
+ deviceContext->CSSetShaderResources(bindingSlot, 1,
+ d3d11SRV.GetAddressOf());
}
break;
}
@@ -362,13 +362,13 @@
Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
ID3D11SamplerState* d3d11SamplerState = sampler->GetD3D11SamplerState();
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetSamplers(bindingSlot, 1, &d3d11SamplerState);
+ deviceContext->VSSetSamplers(bindingSlot, 1, &d3d11SamplerState);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetSamplers(bindingSlot, 1, &d3d11SamplerState);
+ deviceContext->PSSetSamplers(bindingSlot, 1, &d3d11SamplerState);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetSamplers(bindingSlot, 1, &d3d11SamplerState);
+ deviceContext->CSSetSamplers(bindingSlot, 1, &d3d11SamplerState);
}
break;
}
@@ -384,13 +384,13 @@
DAWN_TRY_ASSIGN(srv, view->GetOrCreateD3D11ShaderResourceView());
}
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetShaderResources(bindingSlot, 1, srv.GetAddressOf());
+ deviceContext->VSSetShaderResources(bindingSlot, 1, srv.GetAddressOf());
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetShaderResources(bindingSlot, 1, srv.GetAddressOf());
+ deviceContext->PSSetShaderResources(bindingSlot, 1, srv.GetAddressOf());
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetShaderResources(bindingSlot, 1, srv.GetAddressOf());
+ deviceContext->CSSetShaderResources(bindingSlot, 1, srv.GetAddressOf());
}
break;
}
@@ -403,8 +403,8 @@
ID3D11UnorderedAccessView* d3d11UAV = nullptr;
DAWN_TRY_ASSIGN(d3d11UAV, view->GetOrCreateD3D11UnorderedAccessView());
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetUnorderedAccessViews(bindingSlot, 1, &d3d11UAV,
- nullptr);
+ deviceContext->CSSetUnorderedAccessViews(bindingSlot, 1, &d3d11UAV,
+ nullptr);
}
break;
}
@@ -412,13 +412,13 @@
ID3D11ShaderResourceView* d3d11SRV = nullptr;
DAWN_TRY_ASSIGN(d3d11SRV, view->GetOrCreateD3D11ShaderResourceView());
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetShaderResources(bindingSlot, 1, &d3d11SRV);
+ deviceContext->VSSetShaderResources(bindingSlot, 1, &d3d11SRV);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetShaderResources(bindingSlot, 1, &d3d11SRV);
+ deviceContext->PSSetShaderResources(bindingSlot, 1, &d3d11SRV);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetShaderResources(bindingSlot, 1, &d3d11SRV);
+ deviceContext->CSSetShaderResources(bindingSlot, 1, &d3d11SRV);
}
break;
}
@@ -437,7 +437,7 @@
}
void BindGroupTracker::UnApplyBindGroup(BindGroupIndex index) {
- ID3D11DeviceContext1* deviceContext1 = mCommandContext->GetD3D11DeviceContext1();
+ auto* deviceContext = mCommandContext->GetD3D11DeviceContext4();
BindGroupLayoutInternalBase* groupLayout =
mLastAppliedPipelineLayout->GetBindGroupLayout(index);
const auto& indices = ToBackend(mLastAppliedPipelineLayout)->GetBindingIndexInfo()[index];
@@ -454,16 +454,16 @@
case wgpu::BufferBindingType::Uniform: {
ID3D11Buffer* nullBuffer = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
- nullptr, nullptr);
+ deviceContext->VSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
+ nullptr, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
- nullptr, nullptr);
+ deviceContext->PSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
+ nullptr, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
- nullptr, nullptr);
+ deviceContext->CSSetConstantBuffers1(bindingSlot, 1, &nullBuffer,
+ nullptr, nullptr);
}
break;
}
@@ -474,26 +474,26 @@
wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute));
ID3D11UnorderedAccessView* nullUAV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->OMSetRenderTargetsAndUnorderedAccessViews(
+ deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(
D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, nullptr, nullptr,
bindingSlot, 1, &nullUAV, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV,
- nullptr);
+ deviceContext->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV,
+ nullptr);
}
break;
}
case wgpu::BufferBindingType::ReadOnlyStorage: {
ID3D11ShaderResourceView* nullSRV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->VSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->PSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
}
break;
}
@@ -506,13 +506,13 @@
case BindingInfoType::Sampler: {
ID3D11SamplerState* nullSampler = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetSamplers(bindingSlot, 1, &nullSampler);
+ deviceContext->VSSetSamplers(bindingSlot, 1, &nullSampler);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetSamplers(bindingSlot, 1, &nullSampler);
+ deviceContext->PSSetSamplers(bindingSlot, 1, &nullSampler);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetSamplers(bindingSlot, 1, &nullSampler);
+ deviceContext->CSSetSamplers(bindingSlot, 1, &nullSampler);
}
break;
}
@@ -520,13 +520,13 @@
case BindingInfoType::Texture: {
ID3D11ShaderResourceView* nullSRV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->VSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->PSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
}
break;
}
@@ -537,26 +537,26 @@
case wgpu::StorageTextureAccess::ReadWrite: {
ID3D11UnorderedAccessView* nullUAV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->OMSetRenderTargetsAndUnorderedAccessViews(
+ deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(
D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, nullptr, nullptr,
bindingSlot, 1, &nullUAV, nullptr);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV,
- nullptr);
+ deviceContext->CSSetUnorderedAccessViews(bindingSlot, 1, &nullUAV,
+ nullptr);
}
break;
}
case wgpu::StorageTextureAccess::ReadOnly: {
ID3D11ShaderResourceView* nullSRV = nullptr;
if (bindingVisibility & wgpu::ShaderStage::Vertex) {
- deviceContext1->VSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->VSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Fragment) {
- deviceContext1->PSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->PSSetShaderResources(bindingSlot, 1, &nullSRV);
}
if (bindingVisibility & wgpu::ShaderStage::Compute) {
- deviceContext1->CSSetShaderResources(bindingSlot, 1, &nullSRV);
+ deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
}
break;
}
diff --git a/src/dawn/native/d3d11/BufferD3D11.cpp b/src/dawn/native/d3d11/BufferD3D11.cpp
index 355da4a..b9a83a3 100644
--- a/src/dawn/native/d3d11/BufferD3D11.cpp
+++ b/src/dawn/native/d3d11/BufferD3D11.cpp
@@ -252,9 +252,9 @@
// TODO(dawn:1705): investigate the performance impact of mapping with D3D11_MAP_READ_WRITE.
D3D11_MAPPED_SUBRESOURCE mappedResource;
DAWN_TRY(CheckHRESULT(
- commandContext->GetD3D11DeviceContext()->Map(mD3d11NonConstantBuffer.Get(),
- /*Subresource=*/0, D3D11_MAP_READ_WRITE,
- /*MapFlags=*/0, &mappedResource),
+ commandContext->GetD3D11DeviceContext4()->Map(mD3d11NonConstantBuffer.Get(),
+ /*Subresource=*/0, D3D11_MAP_READ_WRITE,
+ /*MapFlags=*/0, &mappedResource),
"ID3D11DeviceContext::Map"));
mMappedData = reinterpret_cast<uint8_t*>(mappedResource.pData);
@@ -265,8 +265,8 @@
DAWN_ASSERT(mMappedData);
CommandRecordingContext* commandContext = ToBackend(GetDevice())->GetPendingCommandContext();
- commandContext->GetD3D11DeviceContext()->Unmap(mD3d11NonConstantBuffer.Get(),
- /*Subresource=*/0);
+ commandContext->GetD3D11DeviceContext4()->Unmap(mD3d11NonConstantBuffer.Get(),
+ /*Subresource=*/0);
mMappedData = nullptr;
}
@@ -381,7 +381,7 @@
DAWN_ASSERT(mD3d11NonConstantBuffer);
DAWN_ASSERT(mD3d11ConstantBuffer);
- commandContext->GetD3D11DeviceContext1()->CopyResource(mD3d11ConstantBuffer.Get(),
+ commandContext->GetD3D11DeviceContext4()->CopyResource(mD3d11ConstantBuffer.Get(),
mD3d11NonConstantBuffer.Get());
mConstantBufferIsUpdated = true;
}
@@ -516,7 +516,7 @@
// UpdateSubresource can only be used to update non-mappable buffers.
DAWN_ASSERT(!IsMappable(GetUsage()));
- ID3D11DeviceContext1* d3d11DeviceContext1 = commandContext->GetD3D11DeviceContext1();
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
if (mD3d11NonConstantBuffer) {
D3D11_BOX box;
@@ -526,10 +526,10 @@
box.bottom = 1;
box.front = 0;
box.back = 1;
- d3d11DeviceContext1->UpdateSubresource(mD3d11NonConstantBuffer.Get(), /*DstSubresource=*/0,
- &box, data,
- /*SrcRowPitch=*/0,
- /*SrcDepthPitch*/ 0);
+ d3d11DeviceContext->UpdateSubresource(mD3d11NonConstantBuffer.Get(), /*DstSubresource=*/0,
+ &box, data,
+ /*SrcRowPitch=*/0,
+ /*SrcDepthPitch*/ 0);
if (!mD3d11ConstantBuffer) {
return {};
}
@@ -541,7 +541,7 @@
}
// Copy the modified part of the mD3d11NonConstantBuffer to mD3d11ConstantBuffer.
- d3d11DeviceContext1->CopySubresourceRegion(
+ d3d11DeviceContext->CopySubresourceRegion(
mD3d11ConstantBuffer.Get(), /*DstSubresource=*/0, /*DstX=*/offset,
/*DstY=*/0,
/*DstZ=*/0, mD3d11NonConstantBuffer.Get(), /*SrcSubresource=*/0, &box);
@@ -554,17 +554,17 @@
// For a full size write, UpdateSubresource() can be used to update mD3d11ConstantBuffer.
if (size == GetSize() && offset == 0) {
if (size == mAllocatedSize) {
- d3d11DeviceContext1->UpdateSubresource(mD3d11ConstantBuffer.Get(), /*DstSubresource=*/0,
- nullptr, data,
- /*SrcRowPitch=*/size,
- /*SrcDepthPitch*/ 0);
+ d3d11DeviceContext->UpdateSubresource(mD3d11ConstantBuffer.Get(), /*DstSubresource=*/0,
+ nullptr, data,
+ /*SrcRowPitch=*/size,
+ /*SrcDepthPitch*/ 0);
} else {
std::vector<uint8_t> allocatedData(mAllocatedSize, 0);
std::memcpy(allocatedData.data(), data, size);
- d3d11DeviceContext1->UpdateSubresource(mD3d11ConstantBuffer.Get(), /*DstSubresource=*/0,
- nullptr, allocatedData.data(),
- /*SrcRowPitch=*/mAllocatedSize,
- /*SrcDepthPitch*/ 0);
+ d3d11DeviceContext->UpdateSubresource(mD3d11ConstantBuffer.Get(), /*DstSubresource=*/0,
+ nullptr, allocatedData.data(),
+ /*SrcRowPitch=*/mAllocatedSize,
+ /*SrcDepthPitch*/ 0);
}
return {};
}
@@ -620,7 +620,7 @@
DAWN_ASSERT(d3d11SourceBuffer);
if (destination->mD3d11NonConstantBuffer) {
- commandContext->GetD3D11DeviceContext()->CopySubresourceRegion(
+ commandContext->GetD3D11DeviceContext4()->CopySubresourceRegion(
destination->mD3d11NonConstantBuffer.Get(), /*DstSubresource=*/0,
/*DstX=*/destinationOffset,
/*DstY=*/0,
@@ -634,7 +634,7 @@
}
if (destination->mD3d11ConstantBuffer) {
- commandContext->GetD3D11DeviceContext()->CopySubresourceRegion(
+ commandContext->GetD3D11DeviceContext4()->CopySubresourceRegion(
destination->mD3d11ConstantBuffer.Get(), /*DstSubresource=*/0,
/*DstX=*/destinationOffset,
/*DstY=*/0,
diff --git a/src/dawn/native/d3d11/CommandBufferD3D11.cpp b/src/dawn/native/d3d11/CommandBufferD3D11.cpp
index 2d295c8..065baac 100644
--- a/src/dawn/native/d3d11/CommandBufferD3D11.cpp
+++ b/src/dawn/native/d3d11/CommandBufferD3D11.cpp
@@ -74,7 +74,7 @@
mD3D11Buffers = {};
mStrides = {};
mOffsets = {};
- mCommandContext->GetD3D11DeviceContext()->IASetVertexBuffers(
+ mCommandContext->GetD3D11DeviceContext4()->IASetVertexBuffers(
0, kMaxVertexBuffers, mD3D11Buffers.data(), mStrides.data(), mOffsets.data());
}
@@ -95,7 +95,7 @@
}
}
- mCommandContext->GetD3D11DeviceContext()->IASetVertexBuffers(
+ mCommandContext->GetD3D11DeviceContext4()->IASetVertexBuffers(
0, kMaxVertexBuffers, mD3D11Buffers.data(), mStrides.data(), mOffsets.data());
}
@@ -410,8 +410,8 @@
DAWN_TRY(bindGroupTracker.Apply());
DAWN_TRY(RecordNumWorkgroupsForDispatch(lastPipeline, commandContext, dispatch));
- commandContext->GetD3D11DeviceContext()->Dispatch(dispatch->x, dispatch->y,
- dispatch->z);
+ commandContext->GetD3D11DeviceContext4()->Dispatch(dispatch->x, dispatch->y,
+ dispatch->z);
break;
}
@@ -430,7 +430,7 @@
0));
}
- commandContext->GetD3D11DeviceContext()->DispatchIndirect(
+ commandContext->GetD3D11DeviceContext4()->DispatchIndirect(
indirectBuffer->GetD3D11NonConstantBuffer(), dispatch->indirectOffset);
break;
@@ -480,7 +480,7 @@
MaybeError CommandBuffer::ExecuteRenderPass(BeginRenderPassCmd* renderPass,
CommandRecordingContext* commandContext) {
- ID3D11DeviceContext1* d3d11DeviceContext1 = commandContext->GetD3D11DeviceContext1();
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
// Hold ID3D11RenderTargetView ComPtr to make attachments alive.
ityp::array<ColorAttachmentIndex, ID3D11RenderTargetView*, kMaxColorAttachments>
@@ -495,8 +495,7 @@
if (renderPass->colorAttachments[i].loadOp == wgpu::LoadOp::Clear) {
std::array<float, 4> clearColor =
ConvertToFloatColor(renderPass->colorAttachments[i].clearColor);
- d3d11DeviceContext1->ClearRenderTargetView(d3d11RenderTargetViews[i],
- clearColor.data());
+ d3d11DeviceContext->ClearRenderTargetView(d3d11RenderTargetViews[i], clearColor.data());
}
attachmentCount = i;
attachmentCount++;
@@ -523,13 +522,13 @@
clearFlags |= D3D11_CLEAR_STENCIL;
}
- d3d11DeviceContext1->ClearDepthStencilView(d3d11DepthStencilView, clearFlags,
- attachmentInfo->clearDepth,
- attachmentInfo->clearStencil);
+ d3d11DeviceContext->ClearDepthStencilView(d3d11DepthStencilView, clearFlags,
+ attachmentInfo->clearDepth,
+ attachmentInfo->clearStencil);
}
- d3d11DeviceContext1->OMSetRenderTargets(static_cast<uint8_t>(attachmentCount),
- d3d11RenderTargetViews.data(), d3d11DepthStencilView);
+ d3d11DeviceContext->OMSetRenderTargets(static_cast<uint8_t>(attachmentCount),
+ d3d11RenderTargetViews.data(), d3d11DepthStencilView);
// Set viewport
D3D11_VIEWPORT defautViewport;
@@ -539,7 +538,7 @@
defautViewport.Height = renderPass->height;
defautViewport.MinDepth = 0.0f;
defautViewport.MaxDepth = 1.0f;
- d3d11DeviceContext1->RSSetViewports(1, &defautViewport);
+ d3d11DeviceContext->RSSetViewports(1, &defautViewport);
// Set scissor
D3D11_RECT scissor;
@@ -547,7 +546,7 @@
scissor.top = 0;
scissor.right = renderPass->width;
scissor.bottom = renderPass->height;
- d3d11DeviceContext1->RSSetScissorRects(1, &scissor);
+ d3d11DeviceContext->RSSetScissorRects(1, &scissor);
RenderPipeline* lastPipeline = nullptr;
BindGroupTracker bindGroupTracker(commandContext, /*isRenderPass=*/true);
@@ -564,7 +563,7 @@
vertexBufferTracker.Apply(lastPipeline);
DAWN_TRY(RecordFirstIndexOffset(lastPipeline, commandContext, draw->firstVertex,
draw->firstInstance));
- commandContext->GetD3D11DeviceContext()->DrawInstanced(
+ commandContext->GetD3D11DeviceContext4()->DrawInstanced(
draw->vertexCount, draw->instanceCount, draw->firstVertex, draw->firstInstance);
break;
@@ -577,7 +576,7 @@
vertexBufferTracker.Apply(lastPipeline);
DAWN_TRY(RecordFirstIndexOffset(lastPipeline, commandContext, draw->baseVertex,
draw->firstInstance));
- commandContext->GetD3D11DeviceContext()->DrawIndexedInstanced(
+ commandContext->GetD3D11DeviceContext4()->DrawIndexedInstanced(
draw->indexCount, draw->instanceCount, draw->firstIndex, draw->baseVertex,
draw->firstInstance);
@@ -604,7 +603,7 @@
0));
}
- commandContext->GetD3D11DeviceContext()->DrawInstancedIndirect(
+ commandContext->GetD3D11DeviceContext4()->DrawInstancedIndirect(
indirectBuffer->GetD3D11NonConstantBuffer(), draw->indirectOffset);
break;
@@ -630,7 +629,7 @@
0));
}
- commandContext->GetD3D11DeviceContext()->DrawIndexedInstancedIndirect(
+ commandContext->GetD3D11DeviceContext4()->DrawIndexedInstancedIndirect(
indirectBuffer->GetD3D11NonConstantBuffer(), draw->indirectOffset);
break;
@@ -665,7 +664,7 @@
UINT indexBufferBaseOffset = cmd->offset;
DXGI_FORMAT indexBufferFormat = DXGIIndexFormat(cmd->format);
- commandContext->GetD3D11DeviceContext()->IASetIndexBuffer(
+ commandContext->GetD3D11DeviceContext4()->IASetIndexBuffer(
ToBackend(cmd->buffer)->GetD3D11NonConstantBuffer(), indexBufferFormat,
indexBufferBaseOffset);
@@ -699,7 +698,6 @@
switch (type) {
case Command::EndRenderPass: {
mCommands.NextCommand<EndRenderPassCmd>();
- ID3D11DeviceContext* d3d11DeviceContext = commandContext->GetD3D11DeviceContext();
d3d11DeviceContext->OMSetRenderTargets(0, nullptr, nullptr);
if (renderPass->attachmentState->GetSampleCount() <= 1) {
@@ -753,7 +751,7 @@
viewport.Height = cmd->height;
viewport.MinDepth = cmd->minDepth;
viewport.MaxDepth = cmd->maxDepth;
- commandContext->GetD3D11DeviceContext()->RSSetViewports(1, &viewport);
+ commandContext->GetD3D11DeviceContext4()->RSSetViewports(1, &viewport);
break;
}
@@ -763,7 +761,7 @@
D3D11_RECT scissorRect = {static_cast<LONG>(cmd->x), static_cast<LONG>(cmd->y),
static_cast<LONG>(cmd->x + cmd->width),
static_cast<LONG>(cmd->y + cmd->height)};
- commandContext->GetD3D11DeviceContext()->RSSetScissorRects(1, &scissorRect);
+ commandContext->GetD3D11DeviceContext4()->RSSetScissorRects(1, &scissorRect);
break;
}
@@ -792,14 +790,14 @@
case Command::BeginOcclusionQuery: {
BeginOcclusionQueryCmd* cmd = mCommands.NextCommand<BeginOcclusionQueryCmd>();
QuerySet* querySet = ToBackend(cmd->querySet.Get());
- querySet->BeginQuery(commandContext->GetD3D11DeviceContext(), cmd->queryIndex);
+ querySet->BeginQuery(commandContext->GetD3D11DeviceContext4(), cmd->queryIndex);
break;
}
case Command::EndOcclusionQuery: {
EndOcclusionQueryCmd* cmd = mCommands.NextCommand<EndOcclusionQueryCmd>();
QuerySet* querySet = ToBackend(cmd->querySet.Get());
- querySet->EndQuery(commandContext->GetD3D11DeviceContext(), cmd->queryIndex);
+ querySet->EndQuery(commandContext->GetD3D11DeviceContext4(), cmd->queryIndex);
break;
}
diff --git a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp
index 81fe13ce..475e2aa 100644
--- a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp
+++ b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp
@@ -105,16 +105,6 @@
return mD3D11Device.Get();
}
-ID3D11DeviceContext* CommandRecordingContext::GetD3D11DeviceContext() const {
- DAWN_ASSERT(mDevice->IsLockedByCurrentThreadIfNeeded());
- return mD3D11DeviceContext4.Get();
-}
-
-ID3D11DeviceContext1* CommandRecordingContext::GetD3D11DeviceContext1() const {
- DAWN_ASSERT(mDevice->IsLockedByCurrentThreadIfNeeded());
- return mD3D11DeviceContext4.Get();
-}
-
ID3D11DeviceContext4* CommandRecordingContext::GetD3D11DeviceContext4() const {
DAWN_ASSERT(mDevice->IsLockedByCurrentThreadIfNeeded());
return mD3D11DeviceContext4.Get();
diff --git a/src/dawn/native/d3d11/CommandRecordingContextD3D11.h b/src/dawn/native/d3d11/CommandRecordingContextD3D11.h
index 106b6f2..005813e 100644
--- a/src/dawn/native/d3d11/CommandRecordingContextD3D11.h
+++ b/src/dawn/native/d3d11/CommandRecordingContextD3D11.h
@@ -50,8 +50,6 @@
MaybeError ExecuteCommandList(Device* device);
ID3D11Device* GetD3D11Device() const;
- ID3D11DeviceContext* GetD3D11DeviceContext() const;
- ID3D11DeviceContext1* GetD3D11DeviceContext1() const;
ID3D11DeviceContext4* GetD3D11DeviceContext4() const;
ID3DUserDefinedAnnotation* GetD3DUserDefinedAnnotation() const;
Buffer* GetUniformBuffer() const;
diff --git a/src/dawn/native/d3d11/ComputePipelineD3D11.cpp b/src/dawn/native/d3d11/ComputePipelineD3D11.cpp
index a3cfb3c..774caa3 100644
--- a/src/dawn/native/d3d11/ComputePipelineD3D11.cpp
+++ b/src/dawn/native/d3d11/ComputePipelineD3D11.cpp
@@ -88,8 +88,8 @@
}
void ComputePipeline::ApplyNow(CommandRecordingContext* commandContext) {
- ID3D11DeviceContext1* d3dDeviceContext1 = commandContext->GetD3D11DeviceContext1();
- d3dDeviceContext1->CSSetShader(mComputeShader.Get(), nullptr, 0);
+ auto* d3dDeviceContext = commandContext->GetD3D11DeviceContext4();
+ d3dDeviceContext->CSSetShader(mComputeShader.Get(), nullptr, 0);
}
void ComputePipeline::InitializeAsync(Ref<ComputePipelineBase> computePipeline,
diff --git a/src/dawn/native/d3d11/QuerySetD3D11.cpp b/src/dawn/native/d3d11/QuerySetD3D11.cpp
index 83957f2..655d4ca 100644
--- a/src/dawn/native/d3d11/QuerySetD3D11.cpp
+++ b/src/dawn/native/d3d11/QuerySetD3D11.cpp
@@ -93,7 +93,7 @@
uint64_t offset) {
DAWN_TRY(destination->Clear(commandContext, 0, offset, queryCount * sizeof(uint64_t)));
const auto& queryAvailability = GetQueryAvailability();
- ID3D11DeviceContext* d3d11DeviceContext = commandContext->GetD3D11DeviceContext();
+ ID3D11DeviceContext* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
for (uint32_t i = 0; i < queryCount; ++i) {
uint32_t queryIndex = i + firstQuery;
if (queryAvailability[queryIndex]) {
diff --git a/src/dawn/native/d3d11/RenderPipelineD3D11.cpp b/src/dawn/native/d3d11/RenderPipelineD3D11.cpp
index df16dd2..440cf2f 100644
--- a/src/dawn/native/d3d11/RenderPipelineD3D11.cpp
+++ b/src/dawn/native/d3d11/RenderPipelineD3D11.cpp
@@ -251,14 +251,14 @@
void RenderPipeline::ApplyNow(CommandRecordingContext* commandContext,
const std::array<float, 4>& blendColor,
uint32_t stencilReference) {
- ID3D11DeviceContext1* d3dDeviceContext1 = commandContext->GetD3D11DeviceContext1();
- d3dDeviceContext1->IASetPrimitiveTopology(mD3DPrimitiveTopology);
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
+ d3d11DeviceContext->IASetPrimitiveTopology(mD3DPrimitiveTopology);
// TODO(dawn:1753): deduplicate these objects in the backend eventually, and to avoid redundant
// state setting.
- d3dDeviceContext1->IASetInputLayout(mInputLayout.Get());
- d3dDeviceContext1->RSSetState(mRasterizerState.Get());
- d3dDeviceContext1->VSSetShader(mVertexShader.Get(), nullptr, 0);
- d3dDeviceContext1->PSSetShader(mPixelShader.Get(), nullptr, 0);
+ d3d11DeviceContext->IASetInputLayout(mInputLayout.Get());
+ d3d11DeviceContext->RSSetState(mRasterizerState.Get());
+ d3d11DeviceContext->VSSetShader(mVertexShader.Get(), nullptr, 0);
+ d3d11DeviceContext->PSSetShader(mPixelShader.Get(), nullptr, 0);
ApplyBlendState(commandContext, blendColor);
ApplyDepthStencilState(commandContext, stencilReference);
@@ -266,14 +266,14 @@
void RenderPipeline::ApplyBlendState(CommandRecordingContext* commandContext,
const std::array<float, 4>& blendColor) {
- ID3D11DeviceContext1* d3dDeviceContext1 = commandContext->GetD3D11DeviceContext1();
- d3dDeviceContext1->OMSetBlendState(mBlendState.Get(), blendColor.data(), GetSampleMask());
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
+ d3d11DeviceContext->OMSetBlendState(mBlendState.Get(), blendColor.data(), GetSampleMask());
}
void RenderPipeline::ApplyDepthStencilState(CommandRecordingContext* commandContext,
uint32_t stencilReference) {
- ID3D11DeviceContext1* d3dDeviceContext1 = commandContext->GetD3D11DeviceContext1();
- d3dDeviceContext1->OMSetDepthStencilState(mDepthStencilState.Get(), stencilReference);
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
+ d3d11DeviceContext->OMSetDepthStencilState(mDepthStencilState.Get(), stencilReference);
}
void RenderPipeline::SetLabelImpl() {
diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp
index 2b114da..65bd28e 100644
--- a/src/dawn/native/d3d11/TextureD3D11.cpp
+++ b/src/dawn/native/d3d11/TextureD3D11.cpp
@@ -361,12 +361,12 @@
DAWN_TRY(CheckHRESULT(d3dTexture.As(&d3d11Texture), "Query ID3D11Resource from IUnknown"));
CommandRecordingContext* commandContext = ToBackend(GetDevice())->GetPendingCommandContext();
- ID3D11DeviceContext4* d3d11DeviceContext4 = commandContext->GetD3D11DeviceContext4();
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
for (Ref<d3d::Fence>& fence : waitFences) {
- DAWN_TRY(CheckHRESULT(
- d3d11DeviceContext4->Wait(static_cast<Fence*>(fence.Get())->GetD3D11Fence(),
- fence->GetFenceValue()),
- "ID3D11DeviceContext4::Wait"));
+ DAWN_TRY(
+ CheckHRESULT(d3d11DeviceContext->Wait(static_cast<Fence*>(fence.Get())->GetD3D11Fence(),
+ fence->GetFenceValue()),
+ "ID3D11DeviceContext4::Wait"));
}
mD3d11Resource = std::move(d3d11Texture);
SetLabelHelper("Dawn_ExternalTexture");
@@ -508,7 +508,7 @@
const SubresourceRange& range,
TextureBase::ClearValue clearValue,
const D3D11ClearValue& d3d11ClearValue) {
- ID3D11DeviceContext* d3d11DeviceContext = commandContext->GetD3D11DeviceContext();
+ ID3D11DeviceContext* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
UINT clearFlags = 0;
if (GetFormat().HasDepth() && range.aspects & Aspect::Depth) {
@@ -667,7 +667,7 @@
// RESOURCE_MANIPULATION ERROR #280:COPYSUBRESOURCEREGION_INVALIDSOURCEBOX]
srcBox.right = physicalSize.width / blockInfo.width;
srcBox.bottom = physicalSize.height / blockInfo.height;
- commandContext->GetD3D11DeviceContext1()->CopySubresourceRegion(
+ commandContext->GetD3D11DeviceContext4()->CopySubresourceRegion(
GetD3D11Resource(), dstSubresource, 0, 0, 0, interimTexture->GetD3D11Resource(),
srcSubresource, &srcBox);
}
@@ -746,7 +746,7 @@
dstBox.back = origin.z + size.depthOrArrayLayers;
uint32_t subresource =
GetSubresourceIndex(subresources.baseMipLevel, 0, D3D11Aspect(subresources.aspects));
- commandContext->GetD3D11DeviceContext1()->UpdateSubresource(GetD3D11Resource(), subresource,
+ commandContext->GetD3D11DeviceContext4()->UpdateSubresource(GetD3D11Resource(), subresource,
&dstBox, data, bytesPerRow,
bytesPerRow * rowsPerImage);
} else {
@@ -757,7 +757,7 @@
GetSubresourceIndex(subresources.baseMipLevel, subresources.baseArrayLayer + layer,
D3D11Aspect(subresources.aspects));
D3D11_BOX* pDstBox = GetFormat().HasDepthOrStencil() ? nullptr : &dstBox;
- commandContext->GetD3D11DeviceContext1()->UpdateSubresource(
+ commandContext->GetD3D11DeviceContext4()->UpdateSubresource(
GetD3D11Resource(), subresource, pDstBox, data, bytesPerRow, 0);
data += rowsPerImage * bytesPerRow;
}
@@ -816,12 +816,12 @@
DepthStencilAspectLayout(d3d::DXGITextureFormat(GetFormat().format), subresources.aspects);
// Map and write to the staging texture.
- ID3D11DeviceContext1* d3d11DeviceContext1 = commandContext->GetD3D11DeviceContext1();
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
D3D11_MAPPED_SUBRESOURCE mappedResource;
const uint8_t* pSrcData = data;
for (uint32_t layer = 0; layer < size.depthOrArrayLayers; ++layer) {
- DAWN_TRY(CheckHRESULT(d3d11DeviceContext1->Map(stagingTexture->GetD3D11Resource(), layer,
- D3D11_MAP_READ, 0, &mappedResource),
+ DAWN_TRY(CheckHRESULT(d3d11DeviceContext->Map(stagingTexture->GetD3D11Resource(), layer,
+ D3D11_MAP_READ, 0, &mappedResource),
"D3D11 map staging texture"));
uint8_t* pDstData = static_cast<uint8_t*>(mappedResource.pData);
for (uint32_t y = 0; y < size.height; ++y) {
@@ -836,7 +836,7 @@
pDstData += mappedResource.RowPitch;
pSrcData += bytesPerRow;
}
- d3d11DeviceContext1->Unmap(stagingTexture->GetD3D11Resource(), layer);
+ d3d11DeviceContext->Unmap(stagingTexture->GetD3D11Resource(), layer);
DAWN_ASSERT(size.height <= rowsPerImage);
// Skip the padding rows.
pSrcData += (rowsPerImage - size.height) * bytesPerRow;
@@ -870,7 +870,7 @@
DAWN_ASSERT(subresources.baseArrayLayer == 0);
DAWN_ASSERT(origin.z == 0);
- ID3D11DeviceContext1* d3d11DeviceContext1 = commandContext->GetD3D11DeviceContext1();
+ auto* d3d11DeviceContext = commandContext->GetD3D11DeviceContext4();
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(subresources.aspects).block;
const bool hasStencil = GetFormat().HasStencil();
DAWN_ASSERT(size.width % blockInfo.width == 0);
@@ -884,8 +884,8 @@
// The Map() will block until the GPU is done with the texture.
// TODO(dawn:1705): avoid blocking the CPU.
D3D11_MAPPED_SUBRESOURCE mappedResource;
- DAWN_TRY(CheckHRESULT(d3d11DeviceContext1->Map(GetD3D11Resource(), layer,
- D3D11_MAP_READ, 0, &mappedResource),
+ DAWN_TRY(CheckHRESULT(d3d11DeviceContext->Map(GetD3D11Resource(), layer, D3D11_MAP_READ,
+ 0, &mappedResource),
"D3D11 map staging texture"));
uint8_t* pSrcData = static_cast<uint8_t*>(mappedResource.pData);
@@ -922,7 +922,7 @@
pSrcData += mappedResource.RowPitch;
}
}
- d3d11DeviceContext1->Unmap(GetD3D11Resource(), layer);
+ d3d11DeviceContext->Unmap(GetD3D11Resource(), layer);
}
return {};
}
@@ -933,7 +933,7 @@
// TODO(dawn:1705): avoid blocking the CPU.
D3D11_MAPPED_SUBRESOURCE mappedResource;
DAWN_TRY(CheckHRESULT(
- d3d11DeviceContext1->Map(GetD3D11Resource(), 0, D3D11_MAP_READ, 0, &mappedResource),
+ d3d11DeviceContext->Map(GetD3D11Resource(), 0, D3D11_MAP_READ, 0, &mappedResource),
"D3D11 map staging texture"));
for (uint32_t z = 0; z < size.depthOrArrayLayers; ++z) {
@@ -953,7 +953,7 @@
}
}
}
- d3d11DeviceContext1->Unmap(GetD3D11Resource(), 0);
+ d3d11DeviceContext->Unmap(GetD3D11Resource(), 0);
return {};
}
@@ -1075,7 +1075,7 @@
uint32_t dstSubresource =
dst.texture->GetSubresourceIndex(dst.mipLevel, dstSubresources.baseArrayLayer + layer,
D3D11Aspect(dstSubresources.aspects));
- commandContext->GetD3D11DeviceContext1()->CopySubresourceRegion(
+ commandContext->GetD3D11DeviceContext4()->CopySubresourceRegion(
ToBackend(dst.texture)->GetD3D11Resource(), dstSubresource, dst.origin.x, dst.origin.y,
dst.texture->GetDimension() == wgpu::TextureDimension::e3D ? dst.origin.z : 0,
ToBackend(src.texture)->GetD3D11Resource(), srcSubresource,