Skip to content

Commit

Permalink
Add experimental support for feature_level_10_0
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiyansKing committed Sep 14, 2021
1 parent 3f8a87f commit 203bc6c
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 42 deletions.
6 changes: 6 additions & 0 deletions D3D11Engine/D2DSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ XRESULT D2DSettingsDialog::InitControls() {
hbaoCheckbox->AlignUnder( numpadCheckbox, 5 );
hbaoCheckbox->SetPosition( D2D1::Point2F( 5, hbaoCheckbox->GetPosition().y ) );
hbaoCheckbox->SetChecked( Engine::GAPI->GetRendererState().RendererSettings.HbaoSettings.Enabled );
if ( FeatureLevel10Compatibility ) {
hbaoCheckbox->SetDisabled( true );
}

SV_Checkbox* vsyncCheckbox = new SV_Checkbox( MainView, MainPanel );
vsyncCheckbox->SetSize( D2D1::SizeF( 160, 20 ) );
Expand Down Expand Up @@ -155,6 +158,9 @@ XRESULT D2DSettingsDialog::InitControls() {
smaaCheckbox->AlignUnder( godraysCheckbox, 5 );
smaaCheckbox->SetPosition( D2D1::Point2F( 5, smaaCheckbox->GetPosition().y ) );
smaaCheckbox->SetChecked( Engine::GAPI->GetRendererState().RendererSettings.EnableSMAA );
if ( FeatureLevel10Compatibility ) {
smaaCheckbox->SetDisabled( true );
}

/*SV_Checkbox* tesselationCheckbox = new SV_Checkbox(MainView, MainPanel);
tesselationCheckbox->SetSize(D2D1::SizeF(160, 20));
Expand Down
4 changes: 2 additions & 2 deletions D3D11Engine/D3D11GShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ XRESULT D3D11GShader::LoadShader( const char* geometryShader, const std::vector<

if ( !createStreamOutFromVS ) {
// Compile shaders
if ( FAILED( CompileShaderFromFile( geometryShader, "GSMain", "gs_5_0", gsBlob.GetAddressOf(), makros ) ) ) {
if ( FAILED( CompileShaderFromFile( geometryShader, "GSMain", "gs_4_0", gsBlob.GetAddressOf(), makros ) ) ) {
return XR_FAILED;
}

// Create the shader
LE( engine->GetDevice()->CreateGeometryShader( gsBlob->GetBufferPointer(), gsBlob->GetBufferSize(), nullptr, GeometryShader.GetAddressOf() ) );
} else {
// Compile vertexshader
if ( FAILED( CompileShaderFromFile( geometryShader, "VSMain", "vs_5_0", gsBlob.GetAddressOf(), makros ) ) ) {
if ( FAILED( CompileShaderFromFile( geometryShader, "VSMain", "vs_4_0", gsBlob.GetAddressOf(), makros ) ) ) {
return XR_FAILED;
}

Expand Down
42 changes: 25 additions & 17 deletions D3D11Engine/D3D11GraphicsEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ XRESULT D3D11GraphicsEngine::Init() {

if ( !haveAdapter ) {
LogErrorBox() << "Couldn't find any suitable GPU on your device, so it can't run GD3D11!\n"
"It has to be at least Featurelevel 11.0 compatible, "
"It has to be at least Featurelevel 10.0 compatible, "
"which requires at least:\n"
" * Nvidia GeForce GTX4xx or higher\n"
" * AMD Radeon 5xxx or higher\n\n"
" * Nvidia GeForce 8xxx or higher\n"
" * AMD Radeon HD 2xxx or higher\n\n"
"The game will now close.";
exit( 2 );
}
Expand All @@ -225,15 +225,25 @@ XRESULT D3D11GraphicsEngine::Init() {
DeviceDescription = deviceDescription;
LogInfo() << "Rendering on: " << deviceDescription.c_str();

int flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

D3D_FEATURE_LEVEL maxFeatureLevel = D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_9_1;
if ( FAILED( hr = CheckD3D11FeatureLevel( &maxFeatureLevel ) ) ) {
LogInfo() << "Could not determine D3D_FEATURE_LEVEL";
} else {
PrintD3DFeatureLevel( maxFeatureLevel );
}
if ( maxFeatureLevel < D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_10_0 ) {
LogErrorBox() << "Your GPU (" << deviceDescription.c_str()
<< ") does not support Direct3D 11, so it can't run GD3D11!\n"
"It has to be at least Featurelevel 10.0 compatible, "
"which requires at least:\n"
" * Nvidia GeForce 8xxx or higher\n"
" * AMD Radeon HD 2xxx or higher\n\n"
"The game will now close.";
exit( 2 );
}

// Create D3D11-Device
int flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifndef DEBUG_D3D11
LE( D3D11CreateDevice( DXGIAdapter2.Get(), D3D_DRIVER_TYPE_UNKNOWN, nullptr, flags, &maxFeatureLevel, 1, D3D11_SDK_VERSION, Device11.GetAddressOf(), nullptr, Context11.GetAddressOf() ) );
#else
Expand All @@ -242,19 +252,9 @@ XRESULT D3D11GraphicsEngine::Init() {
Device11.As( &Device );
Context11.As( &Context );

if ( hr == DXGI_ERROR_UNSUPPORTED ) {
LogErrorBox() << "Your GPU (" << deviceDescription.c_str()
<< ") does not support Direct3D 11, so it can't run GD3D11!\n"
"It has to be at least Featurelevel 11.0 compatible, "
"which requires at least:\n"
" * Nvidia GeForce GTX4xx or higher\n"
" * AMD Radeon 5xxx or higher\n\n"
"The game will now close.";
exit( 2 );
}

LE( GetDevice()->CreateDeferredContext1( 0, DeferredContext.GetAddressOf() ) ); // Used for multithreaded texture loading

FeatureLevel10Compatibility = (maxFeatureLevel < D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_11_0);
LogInfo() << "Creating ShaderManager";

ShaderManager = std::make_unique<D3D11ShaderManager>();
Expand Down Expand Up @@ -1702,6 +1702,14 @@ XRESULT D3D11GraphicsEngine::OnStartWorldRendering() {
// return XR_SUCCESS;
if ( PresentPending ) return XR_SUCCESS;

if ( FeatureLevel10Compatibility ) {
// Disable here what we can't draw in feature level 10 compatibility
Engine::GAPI->GetRendererState().RendererSettings.HbaoSettings.Enabled = false;
Engine::GAPI->GetRendererState().RendererSettings.EnableSMAA = false;
Engine::GAPI->GetRendererState().RendererSettings.EnableTesselation = false;
Engine::GAPI->GetRendererState().RendererSettings.AllowWorldMeshTesselation = false;
}

D3D11_VIEWPORT vp;
vp.TopLeftX = 0.0f;
vp.TopLeftY = 0.0f;
Expand Down Expand Up @@ -2641,7 +2649,7 @@ void D3D11GraphicsEngine::DrawWaterSurfaces() {
}

// Draw Ocean
if ( Engine::GAPI->GetOcean() ) Engine::GAPI->GetOcean()->Draw();
if ( !FeatureLevel10Compatibility && Engine::GAPI->GetOcean() ) Engine::GAPI->GetOcean()->Draw();

GetContext()->OMSetRenderTargets( 1, HDRBackBuffer->GetRenderTargetView().GetAddressOf(),
DepthStencilBuffer->GetDepthStencilView().Get() );
Expand Down
1 change: 0 additions & 1 deletion D3D11Engine/D3D11PFX_SMAA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ D3D11PFX_SMAA::D3D11PFX_SMAA( D3D11PfxRenderer* rnd ) : D3D11PFX_Effect( rnd ) {
Init();
}


D3D11PFX_SMAA::~D3D11PFX_SMAA() {
delete EdgesTex;
delete BlendTex;
Expand Down
2 changes: 1 addition & 1 deletion D3D11Engine/D3D11PShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ XRESULT D3D11PShader::LoadShader( const char* pixelShader, const std::vector<D3D
File = pixelShader;

// Compile shaders
if ( FAILED( CompileShaderFromFile( pixelShader, "PSMain", "ps_5_0", psBlob.GetAddressOf(), makros ) ) ) {
if ( FAILED( CompileShaderFromFile( pixelShader, "PSMain", "ps_4_0", psBlob.GetAddressOf(), makros ) ) ) {
return XR_FAILED;
}

Expand Down
14 changes: 9 additions & 5 deletions D3D11Engine/D3D11PfxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ D3D11PfxRenderer::D3D11PfxRenderer() {
FX_HeightFog = std::make_unique<D3D11PFX_HeightFog>( this );
//FX_DistanceBlur = new D3D11PFX_DistanceBlur(this);
FX_HDR = std::make_unique<D3D11PFX_HDR>( this );
FX_SMAA = std::make_unique<D3D11PFX_SMAA>( this );

FX_GodRays = std::make_unique<D3D11PFX_GodRays>( this );

NvHBAO = std::make_unique<D3D11NVHBAO>();
NvHBAO->Init();
if ( !FeatureLevel10Compatibility ) {
FX_SMAA = std::make_unique<D3D11PFX_SMAA>( this );

NvHBAO = std::make_unique<D3D11NVHBAO>();
NvHBAO->Init();
}
}


Expand Down Expand Up @@ -165,7 +167,9 @@ XRESULT D3D11PfxRenderer::OnResize( const INT2& newResolution ) {
TempBufferDS4_1.reset( new RenderToTextureBuffer( engine->GetDevice(), newResolution.x / 4, newResolution.y / 4, bbufferFormat, nullptr ) );
TempBufferDS4_2.reset( new RenderToTextureBuffer( engine->GetDevice(), newResolution.x / 4, newResolution.y / 4, bbufferFormat, nullptr ) );

FX_SMAA->OnResize( newResolution );
if ( !FeatureLevel10Compatibility ) {
FX_SMAA->OnResize( newResolution );
}

return XR_SUCCESS;
}
Expand Down
27 changes: 13 additions & 14 deletions D3D11Engine/D3D11ShaderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,6 @@ XRESULT D3D11ShaderManager::Init() {
Shaders.back().cBufferSizes.push_back( sizeof( DS_ScreenQuadConstantBuffer ) );
Shaders.back().cBufferSizes.push_back( sizeof( AtmosphereConstantBuffer ) );

// UNUSED
//Shaders.push_back( ShaderInfo( "DefaultTess", "DefaultTess.hlsl", "hd" ) );
//Shaders.back().cBufferSizes.push_back( sizeof( DefaultHullShaderConstantBuffer ) );

Shaders.push_back( ShaderInfo( "OceanTess", "OceanTess.hlsl", "hd" ) );
Shaders.back().cBufferSizes.push_back( sizeof( DefaultHullShaderConstantBuffer ) );
Shaders.back().cBufferSizes.push_back( sizeof( OceanSettingsConstantBuffer ) );

Shaders.push_back( ShaderInfo( "PNAEN_Tesselation", "PNAEN_Tesselation.hlsl", "hd" ) );
Shaders.back().cBufferSizes.push_back( sizeof( PNAENConstantBuffer ) );

Shaders.push_back( ShaderInfo( "Water_Tesselation", "Water_Tesselation.hlsl", "hd" ) );
Shaders.back().cBufferSizes.push_back( sizeof( VisualTesselationSettings::Buffer ) );

Shaders.push_back( ShaderInfo( "GS_Billboard", "GS_Billboard.hlsl", "g" ) );
Shaders.back().cBufferSizes.push_back( sizeof( ParticleGSInfoConstantBuffer ) );

Expand Down Expand Up @@ -446,8 +432,21 @@ XRESULT D3D11ShaderManager::Init() {
Shaders.back().cBufferSizes.push_back( sizeof( MaterialInfo::Buffer ) );
Shaders.back().cBufferSizes.push_back( sizeof( PerObjectState ) );

if ( !FeatureLevel10Compatibility ) {
// UNUSED
//Shaders.push_back( ShaderInfo( "DefaultTess", "DefaultTess.hlsl", "hd" ) );
//Shaders.back().cBufferSizes.push_back( sizeof( DefaultHullShaderConstantBuffer ) );

Shaders.push_back( ShaderInfo( "OceanTess", "OceanTess.hlsl", "hd" ) );
Shaders.back().cBufferSizes.push_back( sizeof( DefaultHullShaderConstantBuffer ) );
Shaders.back().cBufferSizes.push_back( sizeof( OceanSettingsConstantBuffer ) );

Shaders.push_back( ShaderInfo( "PNAEN_Tesselation", "PNAEN_Tesselation.hlsl", "hd" ) );
Shaders.back().cBufferSizes.push_back( sizeof( PNAENConstantBuffer ) );

Shaders.push_back( ShaderInfo( "Water_Tesselation", "Water_Tesselation.hlsl", "hd" ) );
Shaders.back().cBufferSizes.push_back( sizeof( VisualTesselationSettings::Buffer ) );
}

return XR_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion D3D11Engine/D3D11VShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ XRESULT D3D11VShader::LoadShader( const char* vertexShader, int layout, const st


// Compile shader
if ( FAILED( CompileShaderFromFile( vertexShader, "VSMain", "vs_5_0", vsBlob.GetAddressOf(), makros ) ) ) {
if ( FAILED( CompileShaderFromFile( vertexShader, "VSMain", "vs_4_0", vsBlob.GetAddressOf(), makros ) ) ) {
return XR_FAILED;
}

Expand Down
1 change: 1 addition & 0 deletions D3D11Engine/DLLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ using WinMainFunc = decltype(&WinMain);
WinMainFunc originalWinMain;
#endif

bool FeatureLevel10Compatibility = false;
bool GMPModeActive = false;

void SignalHandler( int signal ) {
Expand Down
3 changes: 2 additions & 1 deletion D3D11Engine/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
#define stdext std
#endif

#define VERSION_NUMBER "17.7-dev22"
#define VERSION_NUMBER "17.7-dev23"
__declspec(selectany) const char* VERSION_NUMBER_STR = VERSION_NUMBER;

extern bool FeatureLevel10Compatibility;
extern bool GMPModeActive;

/** D3D7-Call logging */
Expand Down

0 comments on commit 203bc6c

Please sign in to comment.