Skip to content

Commit

Permalink
xrRenderDX10/dx10SH_RT.cpp: enabled format support check
Browse files Browse the repository at this point in the history
Renamed bUseAsDepth -> useAsDepth
  • Loading branch information
Xottab-DUTY committed Oct 2, 2018
1 parent 3cb7820 commit 0d2c68b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
4 changes: 4 additions & 0 deletions src/Layers/xrRenderDX10/DXCommonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ typedef ID3D11DeviceContext ID3DDeviceContext;
#define D3D_FILL_WIREFRAME D3D11_FILL_WIREFRAME

#define D3D_FORMAT_SUPPORT D3D11_FORMAT_SUPPORT
#define D3D_FORMAT_SUPPORT_TEXTURE2D D3D11_FORMAT_SUPPORT_TEXTURE2D
#define D3D_FORMAT_SUPPORT_RENDER_TARGET D3D11_FORMAT_SUPPORT_RENDER_TARGET
#define D3D_FORMAT_SUPPORT_DEPTH_STENCIL D3D11_FORMAT_SUPPORT_DEPTH_STENCIL
#define D3D_FORMAT_SUPPORT_DISPLAY D3D11_FORMAT_SUPPORT_DISPLAY

Expand Down Expand Up @@ -410,6 +412,8 @@ typedef ID3D10Resource ID3DResource;
#define D3D_FILL_WIREFRAME D3D10_FILL_WIREFRAME

#define D3D_FORMAT_SUPPORT D3D10_FORMAT_SUPPORT
#define D3D_FORMAT_SUPPORT_TEXTURE2D D3D10_FORMAT_SUPPORT_TEXTURE2D
#define D3D_FORMAT_SUPPORT_RENDER_TARGET D3D10_FORMAT_SUPPORT_RENDER_TARGET
#define D3D_FORMAT_SUPPORT_DEPTH_STENCIL D3D10_FORMAT_SUPPORT_DEPTH_STENCIL
#define D3D_FORMAT_SUPPORT_DISPLAY D3D10_FORMAT_SUPPORT_DISPLAY

Expand Down
41 changes: 16 additions & 25 deletions src/Layers/xrRenderDX10/dx10SH_RT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
R_ASSERT(HW.pDevice && Name && Name[0] && w && h);
_order = CPU::GetCLK(); // Device.GetTimerGlobal()->GetElapsed_clk();

// HRESULT _hr;

dwWidth = w;
dwHeight = h;
fmt = f;
Expand Down Expand Up @@ -88,31 +86,24 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
usage = D3DUSAGE_DEPTHSTENCIL;
}

bool bUseAsDepth = (usage == D3DUSAGE_RENDERTARGET) ? false : true;
const bool useAsDepth = usage != D3DUSAGE_RENDERTARGET;

// Validate render-target usage
//_hr = HW.pD3D->CheckDeviceFormat(
// HW.DevAdapter,
// HW.m_DriverType,
// HW.Caps.fTarget,
// usage,
// D3DRTYPE_TEXTURE,
// f
//);
// TODO: DX10: implement format support check
// UINT FormatSupport;
//_hr = HW.pDevice->CheckFormatSupport( dx10FMT, &FormatSupport);
// if (FAILED(_hr)) return;
// if (!(
//(FormatSupport&D3Dxx_FORMAT_SUPPORT_TEXTURE2D)
//&& (FormatSupport&(bUseAsDepth?D3Dxx_FORMAT_SUPPORT_DEPTH_STENCIL:D3Dxx_FORMAT_SUPPORT_RENDER_TARGET))
//))
// return;
UINT required = D3D_FORMAT_SUPPORT_TEXTURE2D;

if (useAsDepth)
required |= D3D_FORMAT_SUPPORT_DEPTH_STENCIL;
else
required |= D3D_FORMAT_SUPPORT_RENDER_TARGET;

if (!HW.CheckFormatSupport(dx10FMT, required))
return;

// Try to create texture/surface
RImplementation.Resources->Evict();
//_hr = HW.pDevice->CreateTexture (w, h, 1, usage, f, D3DPOOL_DEFAULT, &pSurface,NULL);
// if (FAILED(_hr) || (0==pSurface)) return;

// Create the render target texture
D3D_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(desc));
Expand All @@ -124,18 +115,18 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
desc.SampleDesc.Count = SampleCount;
desc.Usage = D3D_USAGE_DEFAULT;
if (SampleCount <= 1)
desc.BindFlags = D3D_BIND_SHADER_RESOURCE | (bUseAsDepth ? D3D_BIND_DEPTH_STENCIL : D3D_BIND_RENDER_TARGET);
desc.BindFlags = D3D_BIND_SHADER_RESOURCE | (useAsDepth ? D3D_BIND_DEPTH_STENCIL : D3D_BIND_RENDER_TARGET);
else
{
desc.BindFlags = (bUseAsDepth ? D3D_BIND_DEPTH_STENCIL : (D3D_BIND_SHADER_RESOURCE | D3D_BIND_RENDER_TARGET));
desc.BindFlags = (useAsDepth ? D3D_BIND_DEPTH_STENCIL : (D3D_BIND_SHADER_RESOURCE | D3D_BIND_RENDER_TARGET));
if (RImplementation.o.dx10_msaa_opt)
{
desc.SampleDesc.Quality = UINT(D3D_STANDARD_MULTISAMPLE_PATTERN);
}
}

#ifdef USE_DX11
if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !bUseAsDepth && SampleCount == 1 && useUAV)
if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !useAsDepth && SampleCount == 1 && useUAV)
desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
#endif

Expand All @@ -146,7 +137,7 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
Msg("* created RT(%s), %dx%d, format = %d samples = %d", Name, w, h, dx10FMT, SampleCount);
#endif // DEBUG
// R_CHK (pSurface->GetSurfaceLevel (0,&pRT));
if (bUseAsDepth)
if (useAsDepth)
{
D3D_DEPTH_STENCIL_VIEW_DESC ViewDesc;
ZeroMemory(&ViewDesc, sizeof(ViewDesc));
Expand Down Expand Up @@ -175,7 +166,7 @@ void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
CHK_DX(HW.pDevice->CreateRenderTargetView(pSurface, 0, &pRT));

#ifdef USE_DX11
if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !bUseAsDepth && SampleCount == 1 && useUAV)
if (HW.FeatureLevel >= D3D_FEATURE_LEVEL_11_0 && !useAsDepth && SampleCount == 1 && useUAV)
{
D3D11_UNORDERED_ACCESS_VIEW_DESC UAVDesc;
ZeroMemory(&UAVDesc, sizeof(D3D11_UNORDERED_ACCESS_VIEW_DESC));
Expand Down

0 comments on commit 0d2c68b

Please sign in to comment.