D3D11: Always use custom device context state.

Currently we only use a custom device context state when we share the
D3D11 device. We swap in & activate it during render pass, compute pass'
executions. The purpose is to avoid Dawn messing up the D3D state of
other modules such as ANGLE, video decoder, etc.

However, this makes the behavior inconsistent between tests and chrome
use cases which share the D3D11 device.

This CL forces D3D11 backend to always use the custom device context
state. It will make the tests easier.

Bug: 413000772
Change-Id: I1baaa4f30919d699f5c0fba82b9b3a769a812a3c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/238794
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp
index 628b2d7..9524c64 100644
--- a/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp
+++ b/src/dawn/native/d3d11/CommandRecordingContextD3D11.cpp
@@ -162,18 +162,13 @@
 
 ScopedSwapStateCommandRecordingContext::ScopedSwapStateCommandRecordingContext(
     CommandRecordingContextGuard&& guard)
-    : ScopedCommandRecordingContext(std::move(guard)),
-      mSwapContextState(ToBackend(Get()->mDevice->GetPhysicalDevice())->IsSharedD3D11Device()) {
-    if (mSwapContextState) {
-        Get()->mD3D11DeviceContext3->SwapDeviceContextState(Get()->mD3D11DeviceContextState.Get(),
-                                                            &mPreviousState);
-    }
+    : ScopedCommandRecordingContext(std::move(guard)) {
+    Get()->mD3D11DeviceContext3->SwapDeviceContextState(Get()->mD3D11DeviceContextState.Get(),
+                                                        &mPreviousState);
 }
 
 ScopedSwapStateCommandRecordingContext::~ScopedSwapStateCommandRecordingContext() {
-    if (mSwapContextState) {
-        Get()->mD3D11DeviceContext3->SwapDeviceContextState(mPreviousState.Get(), nullptr);
-    }
+    Get()->mD3D11DeviceContext3->SwapDeviceContextState(mPreviousState.Get(), nullptr);
 }
 
 ID3D11Device* ScopedSwapStateCommandRecordingContext::GetD3D11Device() const {
@@ -216,7 +211,7 @@
 
     ID3D11Device3* d3d11Device = device->GetD3D11Device3();
 
-    if (ToBackend(device->GetPhysicalDevice())->IsSharedD3D11Device()) {
+    {
         const D3D_FEATURE_LEVEL featureLevels[] = {D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0};
 
         HRESULT hr = S_OK;
diff --git a/src/dawn/native/d3d11/CommandRecordingContextD3D11.h b/src/dawn/native/d3d11/CommandRecordingContextD3D11.h
index efe83ff..15988f3 100644
--- a/src/dawn/native/d3d11/CommandRecordingContextD3D11.h
+++ b/src/dawn/native/d3d11/CommandRecordingContextD3D11.h
@@ -193,7 +193,6 @@
     MaybeError SetInternalUniformBuffer(Ref<BufferBase> uniformBuffer);
 
   private:
-    const bool mSwapContextState;
     ComPtr<ID3DDeviceContextState> mPreviousState;
 };