Skip to content

Commit 0d2c68b

Browse files
committed
xrRenderDX10/dx10SH_RT.cpp: enabled format support check
Renamed bUseAsDepth -> useAsDepth
1 parent 3cb7820 commit 0d2c68b

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

src/Layers/xrRenderDX10/DXCommonTypes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ typedef ID3D11DeviceContext ID3DDeviceContext;
150150
#define D3D_FILL_WIREFRAME D3D11_FILL_WIREFRAME
151151

152152
#define D3D_FORMAT_SUPPORT D3D11_FORMAT_SUPPORT
153+
#define D3D_FORMAT_SUPPORT_TEXTURE2D D3D11_FORMAT_SUPPORT_TEXTURE2D
154+
#define D3D_FORMAT_SUPPORT_RENDER_TARGET D3D11_FORMAT_SUPPORT_RENDER_TARGET
153155
#define D3D_FORMAT_SUPPORT_DEPTH_STENCIL D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
154156
#define D3D_FORMAT_SUPPORT_DISPLAY D3D11_FORMAT_SUPPORT_DISPLAY
155157

@@ -410,6 +412,8 @@ typedef ID3D10Resource ID3DResource;
410412
#define D3D_FILL_WIREFRAME D3D10_FILL_WIREFRAME
411413

412414
#define D3D_FORMAT_SUPPORT D3D10_FORMAT_SUPPORT
415+
#define D3D_FORMAT_SUPPORT_TEXTURE2D D3D10_FORMAT_SUPPORT_TEXTURE2D
416+
#define D3D_FORMAT_SUPPORT_RENDER_TARGET D3D10_FORMAT_SUPPORT_RENDER_TARGET
413417
#define D3D_FORMAT_SUPPORT_DEPTH_STENCIL D3D10_FORMAT_SUPPORT_DEPTH_STENCIL
414418
#define D3D_FORMAT_SUPPORT_DISPLAY D3D10_FORMAT_SUPPORT_DISPLAY
415419

src/Layers/xrRenderDX10/dx10SH_RT.cpp

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)