@@ -36,8 +36,6 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
3636 R_ASSERT (HW.pDevice && Name && Name[0 ] && w && h);
3737 _order = CPU::GetCLK (); // Device.GetTimerGlobal()->GetElapsed_clk();
3838
39- // HRESULT _hr;
40-
4139 dwWidth = w;
4240 dwHeight = h;
4341 fmt = f;
@@ -88,31 +86,24 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
8886 usage = D3DUSAGE_DEPTHSTENCIL;
8987 }
9088
91- bool bUseAsDepth = ( usage == D3DUSAGE_RENDERTARGET) ? false : true ;
89+ const bool useAsDepth = usage != D3DUSAGE_RENDERTARGET;
9290
9391 // Validate render-target usage
94- // _hr = HW.pD3D->CheckDeviceFormat(
95- // HW.DevAdapter,
96- // HW.m_DriverType,
97- // HW.Caps.fTarget,
98- // usage,
99- // D3DRTYPE_TEXTURE,
100- // f
101- // );
102- // TODO: DX10: implement format support check
103- // UINT FormatSupport;
104- // _hr = HW.pDevice->CheckFormatSupport( dx10FMT, &FormatSupport);
105- // if (FAILED(_hr)) return;
106- // if (!(
107- // (FormatSupport&D3Dxx_FORMAT_SUPPORT_TEXTURE2D)
108- // && (FormatSupport&(bUseAsDepth?D3Dxx_FORMAT_SUPPORT_DEPTH_STENCIL:D3Dxx_FORMAT_SUPPORT_RENDER_TARGET))
109- // ))
110- // return;
92+ UINT required = D3D_FORMAT_SUPPORT_TEXTURE2D;
93+
94+ if (useAsDepth)
95+ required |= D3D_FORMAT_SUPPORT_DEPTH_STENCIL;
96+ else
97+ required |= D3D_FORMAT_SUPPORT_RENDER_TARGET;
98+
99+ if (!HW.CheckFormatSupport (dx10FMT, required))
100+ return ;
111101
112102 // Try to create texture/surface
113103 RImplementation.Resources ->Evict ();
114104 // _hr = HW.pDevice->CreateTexture (w, h, 1, usage, f, D3DPOOL_DEFAULT, &pSurface,NULL);
115105 // if (FAILED(_hr) || (0==pSurface)) return;
106+
116107 // Create the render target texture
117108 D3D_TEXTURE2D_DESC desc;
118109 ZeroMemory (&desc, sizeof (desc));
@@ -124,18 +115,18 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
124115 desc.SampleDesc .Count = SampleCount;
125116 desc.Usage = D3D_USAGE_DEFAULT;
126117 if (SampleCount <= 1 )
127- desc.BindFlags = D3D_BIND_SHADER_RESOURCE | (bUseAsDepth ? D3D_BIND_DEPTH_STENCIL : D3D_BIND_RENDER_TARGET);
118+ desc.BindFlags = D3D_BIND_SHADER_RESOURCE | (useAsDepth ? D3D_BIND_DEPTH_STENCIL : D3D_BIND_RENDER_TARGET);
128119 else
129120 {
130- desc.BindFlags = (bUseAsDepth ? D3D_BIND_DEPTH_STENCIL : (D3D_BIND_SHADER_RESOURCE | D3D_BIND_RENDER_TARGET));
121+ desc.BindFlags = (useAsDepth ? D3D_BIND_DEPTH_STENCIL : (D3D_BIND_SHADER_RESOURCE | D3D_BIND_RENDER_TARGET));
131122 if (RImplementation.o .dx10_msaa_opt )
132123 {
133124 desc.SampleDesc .Quality = UINT (D3D_STANDARD_MULTISAMPLE_PATTERN);
134125 }
135126 }
136127
137128#ifdef USE_DX11
138- if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !bUseAsDepth && SampleCount == 1 && useUAV)
129+ if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !useAsDepth && SampleCount == 1 && useUAV)
139130 desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
140131#endif
141132
@@ -146,7 +137,7 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
146137 Msg (" * created RT(%s), %dx%d, format = %d samples = %d" , Name, w, h, dx10FMT, SampleCount);
147138#endif // DEBUG
148139 // R_CHK (pSurface->GetSurfaceLevel (0,&pRT));
149- if (bUseAsDepth )
140+ if (useAsDepth )
150141 {
151142 D3D_DEPTH_STENCIL_VIEW_DESC ViewDesc;
152143 ZeroMemory (&ViewDesc, sizeof (ViewDesc));
@@ -175,7 +166,7 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
175166 CHK_DX (HW.pDevice ->CreateRenderTargetView (pSurface, 0 , &pRT));
176167
177168#ifdef USE_DX11
178- if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !bUseAsDepth && SampleCount == 1 && useUAV)
169+ if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !useAsDepth && SampleCount == 1 && useUAV)
179170 {
180171 D3D11_UNORDERED_ACCESS_VIEW_DESC UAVDesc;
181172 ZeroMemory (&UAVDesc, sizeof (D3D11_UNORDERED_ACCESS_VIEW_DESC));
0 commit comments