Skip to content

Commit

Permalink
xrRender_R4: use D3DCompiler_37.dll for Clear Sky in DX10 mode (#382)
Browse files Browse the repository at this point in the history
Addition to #627
  • Loading branch information
Xottab-DUTY committed Apr 4, 2021
1 parent 38a8e7f commit 8e07828
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
19 changes: 13 additions & 6 deletions src/Layers/xrRenderDX10/dx10HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ void CHW::CreateD3D()
R_CHK(createDXGIFactory(__uuidof(IDXGIFactory1), (void**)(&m_pFactory)));

R_CHK(m_pFactory->EnumAdapters1(0, &m_pAdapter));

if (ClearSkyMode)
{
d3dCompiler37 = XRay::LoadModule("d3dcompiler_37");
OldD3DCompile = static_cast<D3DCompileFunc>(d3dCompiler37->GetProcAddress("D3DCompileFromMemory"));
}
}

void CHW::DestroyD3D()
Expand Down Expand Up @@ -148,9 +142,22 @@ void CHW::CreateDevice(SDL_Window* sdlWnd)
pDevice->QueryInterface(__uuidof(ID3D11Device3), reinterpret_cast<void**>(&pDevice3));
#endif
if (FeatureLevel >= D3D_FEATURE_LEVEL_11_0)
{
D3DCompile = &::D3DCompile;
ComputeShadersSupported = true;
}
else
{
if (ClearSkyMode)
{
hD3DCompiler = XRay::LoadModule("d3dcompiler_37");
D3DCompile = static_cast<D3DCompileFunc>(hD3DCompiler->GetProcAddress("D3DCompileFromMemory"));
}
else
{
D3DCompile = &::D3DCompile;
}

D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS data;
pDevice->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS,
&data, sizeof(data));
Expand Down
7 changes: 4 additions & 3 deletions src/Layers/xrRenderDX10/dx10HW.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class CHW
bool SAD4ShaderInstructions;
bool ExtendedDoublesShaderInstructions;

using D3DCompileFunc = decltype(&D3DCompile);
D3DCompileFunc OldD3DCompile = nullptr;
bool DX10Only = false;
#ifdef HAS_DX11_2
IDXGISwapChain2* m_pSwapChain2 = nullptr;
Expand All @@ -84,12 +82,15 @@ class CHW
#endif
ID3D11DeviceContext1* pContext1 = nullptr;

using D3DCompileFunc = decltype(&D3DCompile);
D3DCompileFunc D3DCompile = nullptr;

#if !defined(_MAYA_EXPORT)
stats_manager stats_manager;
#endif
private:
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
XRay::Module d3dCompiler37;
XRay::Module hD3DCompiler;
XRay::Module hDXGI;
XRay::Module hD3D;
};
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R4/r4_shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ HRESULT CRender::shader_compile(pcstr name, IReader* fs, pcstr pFunctionName,
includer Includer;
LPD3DBLOB pShaderBuf = NULL;
LPD3DBLOB pErrorBuf = NULL;
_result = D3DCompile(fs->pointer(), fs->length(), "", options.data(),
_result = HW.D3DCompile(fs->pointer(), fs->length(), "", options.data(),
&Includer, pFunctionName, pTarget, Flags, 0, &pShaderBuf, &pErrorBuf);

if (FAILED(_result) && pErrorBuf)
Expand All @@ -560,7 +560,7 @@ HRESULT CRender::shader_compile(pcstr name, IReader* fs, pcstr pFunctionName,
{
pErrorBuf = nullptr;
Flags |= D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY;
_result = D3DCompile(fs->pointer(), fs->length(), "", options.data(),
_result = HW.D3DCompile(fs->pointer(), fs->length(), "", options.data(),
&Includer, pFunctionName, pTarget, Flags, 0, &pShaderBuf, &pErrorBuf);
}
}
Expand Down

0 comments on commit 8e07828

Please sign in to comment.