Skip to content

Commit

Permalink
Add support force setup dx10 render mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ForserX authored and Drombeys committed Sep 29, 2024
1 parent 5f6a716 commit ea8fae1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/xrEngine/Device_create_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void ResizeBuffersD3D9(u16 Width, u16 Height);
void DestroyD3D9();

#ifndef _EDITOR
bool CreateD3D11();
bool CreateD3D11(bool ReturnToDX10);
bool UpdateBuffersD3D11();
void ResizeBuffersD3D11(u16 Width, u16 Height);
void DestroyD3D11();
Expand Down Expand Up @@ -285,8 +285,9 @@ bool CRenderDevice::InitRenderDevice(APILevel API)
break;

#ifndef _EDITOR
case APILevel::DX10:
case APILevel::DX11:
if (!CreateD3D11()) {
if (!CreateD3D11(API == APILevel::DX10)) {
return false;
}
break;
Expand Down
12 changes: 8 additions & 4 deletions src/xrEngine/Device_create_render_dx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void CreateRDoc()
}
}

bool CreateD3D11()
bool CreateD3D11(bool ReturnToDX10)
{
CreateRDoc();

Expand Down Expand Up @@ -157,16 +157,20 @@ bool CreateD3D11()
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
}

const D3D_FEATURE_LEVEL pFeatureLevels[] = {
constexpr D3D_FEATURE_LEVEL pFeatureLevels10[] = {
D3D_FEATURE_LEVEL_10_1
};

constexpr D3D_FEATURE_LEVEL pFeatureLevels[] = {
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};

HRESULT R = D3D11CreateDeviceAndSwapChain(
0, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, pFeatureLevels,
std::size(pFeatureLevels), D3D11_SDK_VERSION, &sd, (IDXGISwapChain**)&HWSwapchain,
0, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, ReturnToDX10 ? pFeatureLevels10 : pFeatureLevels,
ReturnToDX10 ? std::size(pFeatureLevels10) : std::size(pFeatureLevels), D3D11_SDK_VERSION, &sd, (IDXGISwapChain**)&HWSwapchain,
(ID3D11Device**)&HWRenderDevice, &FeatureLevel, (ID3D11DeviceContext**)&HWRenderContext
);

Expand Down
7 changes: 6 additions & 1 deletion src/xrEngine/EngineAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void CEngineAPI::CreateRendererList()
}
if (bSupports_r4)
{
_tmp.push_back(xr_strdup("renderer_r4_dx10"));
_tmp.push_back(xr_strdup("renderer_r4"));
}

Expand All @@ -237,7 +238,11 @@ void CEngineAPI::CreateRendererList()

APILevel CEngineAPI::GetAPI()
{
if (psDeviceFlags.test(rsR4))
if (psDeviceFlags.test(rsR4low))
{
return APILevel::DX10;
}
else if (psDeviceFlags.test(rsR4))
{
return APILevel::DX11;
}
Expand Down
5 changes: 3 additions & 2 deletions src/xrEngine/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ enum {
rsCameraPos = (1ul<<18ul),
rsR2 = (1ul<<19ul),
rsR4 = (1ul<<20ul),
rsR4low = (1ul<<21ul),

rsDeviceActive = (1ul<<21ul),
// 22-32 bit - reserved to Editor
rsDeviceActive = (1ul<<22ul),
// 23-32 bit - reserved to Editor
};

// psGameFlags
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ union SDL_Event;
enum class APILevel
{
DX9,
DX10,
DX11
};

Expand Down
5 changes: 4 additions & 1 deletion src/xrEngine/xr_ioc_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,11 @@ class CCC_r2 : public CCC_Token
// 0 - r1
// 1..3 - r2
// 4 - r3
bool IsDX11On10Render = std::string("renderer_r4_dx10") == tokens[renderer_value].name;
bool IsDX11Render = xr_string(tokens[renderer_value].name).Contains("renderer_r4");// || IsDX11On10Render;
psDeviceFlags.set(rsR2, std::string("renderer_r2") == tokens[renderer_value].name);
psDeviceFlags.set(rsR4, std::string("renderer_r4") == tokens[renderer_value].name);
psDeviceFlags.set(rsR4, IsDX11Render);
psDeviceFlags.set(rsR4low, IsDX11On10Render);
}

virtual void Save (IWriter *F)
Expand Down

0 comments on commit ea8fae1

Please sign in to comment.