@@ -451,6 +451,9 @@ void CHW::DestroyDevice()
451451
452452 _SHOW_REF (" refCount:pBaseRT" , pBaseRT);
453453 _RELEASE (pBaseRT);
454+
455+ pBaseTEXZB->Release ();
456+
454457 // #ifdef DEBUG
455458 // _SHOW_REF ("refCount:dwDebugSB",dwDebugSB);
456459 // _RELEASE (dwDebugSB);
@@ -516,6 +519,8 @@ void CHW::Reset(HWND hwnd)
516519 _RELEASE (pBaseZB);
517520 _RELEASE (pBaseRT);
518521
522+ pBaseTEXZB->Release ();
523+
519524 CHK_DX (m_pSwapChain->ResizeBuffers (
520525 cd.BufferCount ,
521526 desc.Width ,
@@ -1029,31 +1034,31 @@ void CHW::UpdateViews()
10291034 pBuffer->Release ();
10301035 R_CHK (R);
10311036
1032- // Create Depth/stencil buffer
1033- // HACK: DX10: hard depth buffer format
1034- // R_CHK (pDevice->GetDepthStencilSurface (&pBaseZB));
1035- ID3DTexture2D* pDepthStencil = NULL ;
1036- D3D_TEXTURE2D_DESC descDepth;
1037- descDepth.Width = sd.BufferDesc .Width ;
1038- descDepth.Height = sd.BufferDesc .Height ;
1039- descDepth.MipLevels = 1 ;
1040- descDepth.ArraySize = 1 ;
1041- descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
1042- descDepth.SampleDesc .Count = 1 ;
1043- descDepth.SampleDesc .Quality = 0 ;
1044- descDepth.Usage = D3D_USAGE_DEFAULT;
1045- descDepth.BindFlags = D3D_BIND_DEPTH_STENCIL;
1046- descDepth.CPUAccessFlags = 0 ;
1047- descDepth.MiscFlags = 0 ;
1048- R = pDevice->CreateTexture2D (&descDepth, // Texture desc
1049- NULL , // Initial data
1050- &pDepthStencil); // [out] Texture
1051- R_CHK (R);
1052-
1053- // Create Depth/stencil view
1054- R = pDevice->CreateDepthStencilView (pDepthStencil, NULL , &pBaseZB);
1055- R_CHK (R);
1037+ // Create texture resource
1038+ ID3D11Texture2D* pBaseTEXZB;
1039+ D3D_TEXTURE2D_DESC texDesc;
1040+ texDesc.Width = sd.BufferDesc .Width ;
1041+ texDesc.Height = sd.BufferDesc .Height ;
1042+ texDesc.MipLevels = 1 ;
1043+ texDesc.ArraySize = 1 ;
1044+ texDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
1045+ texDesc.SampleDesc .Count = 1 ;
1046+ texDesc.SampleDesc .Quality = 0 ;
1047+ texDesc.Usage = D3D_USAGE_DEFAULT;
1048+ texDesc.BindFlags = D3D_BIND_DEPTH_STENCIL | D3D_BIND_SHADER_RESOURCE | D3D_BIND_RENDER_TARGET;
1049+ texDesc.CPUAccessFlags = 0 ;
1050+ texDesc.MiscFlags = 0 ;
1051+
1052+ // Create DSV
1053+ D3D_DEPTH_STENCIL_VIEW_DESC dsvDesc;
1054+ #if defined(USE_DX11) // dirty hack so it doesnt crash DX10
1055+ dsvDesc.Flags = 0 ;
1056+ #endif
1057+ dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
1058+ dsvDesc.ViewDimension = D3D_DSV_DIMENSION_TEXTURE2D;
1059+ dsvDesc.Texture2D .MipSlice = 0 ;
10561060
1057- pDepthStencil->Release ();
1061+ R_CHK (pDevice->CreateTexture2D (&texDesc, NULL , &pBaseTEXZB));
1062+ R_CHK (pDevice->CreateDepthStencilView (pBaseTEXZB, &dsvDesc, &pBaseZB));
10581063}
10591064#endif
0 commit comments