Skip to content

Commit 49984e9

Browse files
committed
[D3D12] Fix 3D-to-2D texture crash under Wine/VKD3D
1 parent 9f86969 commit 49984e9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/xenia/gpu/d3d12/d3d12_texture_cache.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,12 +2144,21 @@ ID3D12Resource* D3D12TextureCache::D3D12Texture::GetOrCreate3DAs2DResource(
21442144
d3d12_cache.command_processor_.GetD3D12Provider();
21452145
ID3D12Device* device = provider.GetDevice();
21462146

2147-
D3D12_RESOURCE_DESC source_desc = resource_->GetDesc();
2148-
D3D12_RESOURCE_DESC desc = source_desc;
2147+
// Build the 2D resource desc from scratch rather than copying from the 3D
2148+
// resource's GetDesc(), as inherited internal state can cause issues with
2149+
// VKD3D (D3D12 over Vulkan translation used by Wine).
2150+
D3D12_RESOURCE_DESC desc = {};
21492151
desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
2152+
desc.Width = key().GetWidth();
2153+
desc.Height = key().GetHeight();
21502154
desc.DepthOrArraySize = 1;
21512155
desc.MipLevels = 1;
2152-
desc.Alignment = 0;
2156+
desc.Format = d3d12_cache.GetDXGIResourceFormat(key());
2157+
if (desc.Format == DXGI_FORMAT_UNKNOWN) {
2158+
return nullptr;
2159+
}
2160+
desc.SampleDesc.Count = 1;
2161+
desc.SampleDesc.Quality = 0;
21532162
desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
21542163
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
21552164

0 commit comments

Comments
 (0)