Handles driver version mismatch errors when creating D3D12 pipelines
Bug: dawn:1878
Change-Id: I3b92f5dbbf26e4a758a7449533fbe381130728f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/141761
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/d3d12/ComputePipelineD3D12.cpp b/src/dawn/native/d3d12/ComputePipelineD3D12.cpp
index db3de1b..6b962a5 100644
--- a/src/dawn/native/d3d12/ComputePipelineD3D12.cpp
+++ b/src/dawn/native/d3d12/ComputePipelineD3D12.cpp
@@ -60,7 +60,6 @@
D3D12_COMPUTE_PIPELINE_STATE_DESC d3dDesc = {};
d3dDesc.pRootSignature = ToBackend(GetLayout())->GetRootSignature();
- // TODO(dawn:549): Compile shader everytime before we implement compiled shader cache
d3d::CompiledShader compiledShader;
DAWN_TRY_ASSIGN(compiledShader, module->Compile(computeStage, SingleShaderStage::Compute,
ToBackend(GetLayout()), compileFlags));
@@ -70,7 +69,7 @@
// Try to see if we have anything in the blob cache.
Blob blob = device->LoadCachedBlob(GetCacheKey());
- const bool cacheHit = !blob.Empty();
+ bool cacheHit = !blob.Empty();
if (cacheHit) {
// Cache hits, attach cached blob to descriptor.
d3dDesc.CachedPSO.pCachedBlob = blob.Data();
@@ -78,9 +77,16 @@
}
auto* d3d12Device = device->GetD3D12Device();
- DAWN_TRY(CheckHRESULT(
- d3d12Device->CreateComputePipelineState(&d3dDesc, IID_PPV_ARGS(&mPipelineState)),
- "D3D12 creating pipeline state"));
+ HRESULT result =
+ d3d12Device->CreateComputePipelineState(&d3dDesc, IID_PPV_ARGS(&mPipelineState));
+ if (cacheHit && result == D3D12_ERROR_DRIVER_VERSION_MISMATCH) {
+ // See dawn:1878 where it is possible for the PSO creation to fail with this error.
+ cacheHit = false;
+ d3dDesc.CachedPSO.pCachedBlob = nullptr;
+ d3dDesc.CachedPSO.CachedBlobSizeInBytes = 0;
+ result = d3d12Device->CreateComputePipelineState(&d3dDesc, IID_PPV_ARGS(&mPipelineState));
+ }
+ DAWN_TRY(CheckHRESULT(result, "D3D12 creating pipeline state"));
if (!cacheHit) {
// Cache misses, need to get pipeline cached blob and store.
diff --git a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
index 781c713..2782205 100644
--- a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
+++ b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
@@ -399,16 +399,24 @@
// Try to see if we have anything in the blob cache.
Blob blob = device->LoadCachedBlob(GetCacheKey());
- const bool cacheHit = !blob.Empty();
+ bool cacheHit = !blob.Empty();
if (cacheHit) {
// Cache hits, attach cached blob to descriptor.
descriptorD3D12.CachedPSO.pCachedBlob = blob.Data();
descriptorD3D12.CachedPSO.CachedBlobSizeInBytes = blob.Size();
}
- DAWN_TRY(CheckHRESULT(device->GetD3D12Device()->CreateGraphicsPipelineState(
- &descriptorD3D12, IID_PPV_ARGS(&mPipelineState)),
- "D3D12 create graphics pipeline state"));
+ HRESULT result = device->GetD3D12Device()->CreateGraphicsPipelineState(
+ &descriptorD3D12, IID_PPV_ARGS(&mPipelineState));
+ if (cacheHit && result == D3D12_ERROR_DRIVER_VERSION_MISMATCH) {
+ // See dawn:1878 where it is possible for the PSO creation to fail with this error.
+ cacheHit = false;
+ descriptorD3D12.CachedPSO.pCachedBlob = nullptr;
+ descriptorD3D12.CachedPSO.CachedBlobSizeInBytes = 0;
+ result = device->GetD3D12Device()->CreateGraphicsPipelineState(
+ &descriptorD3D12, IID_PPV_ARGS(&mPipelineState));
+ }
+ DAWN_TRY(CheckHRESULT(result, "D3D12 create graphics pipeline state"));
if (!cacheHit) {
// Cache misses, need to get pipeline cached blob and store.