Merge pull request #1891 from rextimmy/dx11_shadermodel_fix

D3D11 shadermodel version fix
This commit is contained in:
Anis 2017-01-02 11:49:51 +01:00 committed by GitHub
commit 134ff42603
5 changed files with 26 additions and 4 deletions

View file

@ -47,12 +47,27 @@ void GFXD3D11CardProfiler::init()
mCardDescription = adapter.description; mCardDescription = adapter.description;
mChipSet = adapter.chipSet; mChipSet = adapter.chipSet;
mVersionString = adapter.driverVersion; mVersionString = _getFeatureLevelStr();
mVideoMemory = adapter.vram; mVideoMemory = adapter.vram;
} }
Parent::init(); Parent::init();
} }
String GFXD3D11CardProfiler::_getFeatureLevelStr()
{
switch (D3D11->getFeatureLevel())
{
case D3D_FEATURE_LEVEL_11_0:
return String("Feature level 11.0");
case D3D_FEATURE_LEVEL_10_1:
return String("Feature level 10.1");
case D3D_FEATURE_LEVEL_10_0:
return String("Feature level 10.0");
default:
return String("Unknown feature level");
}
}
void GFXD3D11CardProfiler::setupCardCapabilities() void GFXD3D11CardProfiler::setupCardCapabilities()
{ {
setCapability("maxTextureWidth", D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION); setCapability("maxTextureWidth", D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION);

View file

@ -41,6 +41,7 @@ protected:
void setupCardCapabilities(); void setupCardCapabilities();
bool _queryCardCap(const String &query, U32 &foundResult); bool _queryCardCap(const String &query, U32 &foundResult);
bool _queryFormat(const GFXFormat fmt, const GFXTextureProfile *profile, bool &inOutAutogenMips); bool _queryFormat(const GFXFormat fmt, const GFXTextureProfile *profile, bool &inOutAutogenMips);
String _getFeatureLevelStr();
}; };
#endif #endif

View file

@ -106,6 +106,7 @@ GFXD3D11Device::GFXD3D11Device(U32 index)
mVertexShaderTarget = String::EmptyString; mVertexShaderTarget = String::EmptyString;
mPixelShaderTarget = String::EmptyString; mPixelShaderTarget = String::EmptyString;
mShaderModel = String::EmptyString;
mDrawInstancesCount = 0; mDrawInstancesCount = 0;
@ -491,16 +492,19 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
mVertexShaderTarget = "vs_5_0"; mVertexShaderTarget = "vs_5_0";
mPixelShaderTarget = "ps_5_0"; mPixelShaderTarget = "ps_5_0";
mPixVersion = 5.0f; mPixVersion = 5.0f;
mShaderModel = "50";
break; break;
case D3D_FEATURE_LEVEL_10_1: case D3D_FEATURE_LEVEL_10_1:
mVertexShaderTarget = "vs_4_1"; mVertexShaderTarget = "vs_4_1";
mPixelShaderTarget = "ps_4_1"; mPixelShaderTarget = "ps_4_1";
mPixVersion = 4.1f; mPixVersion = 4.1f;
mShaderModel = "41";
break; break;
case D3D_FEATURE_LEVEL_10_0: case D3D_FEATURE_LEVEL_10_0:
mVertexShaderTarget = "vs_4_0"; mVertexShaderTarget = "vs_4_0";
mPixelShaderTarget = "ps_4_0"; mPixelShaderTarget = "ps_4_0";
mPixVersion = 4.0f; mPixVersion = 4.0f;
mShaderModel = "40";
break; break;
default: default:
AssertFatal(false, "GFXD3D11Device::init - We don't support this feature level"); AssertFatal(false, "GFXD3D11Device::init - We don't support this feature level");

View file

@ -140,6 +140,8 @@ protected:
// Shader Model targers // Shader Model targers
String mVertexShaderTarget; String mVertexShaderTarget;
String mPixelShaderTarget; String mPixelShaderTarget;
// String for use with shader macros in the form of shader model version * 10
String mShaderModel;
bool mDebugLayers; bool mDebugLayers;
@ -306,10 +308,11 @@ public:
DXGI_SAMPLE_DESC getMultisampleType() const { return mMultisampleDesc; } DXGI_SAMPLE_DESC getMultisampleType() const { return mMultisampleDesc; }
// Get feature level this gfx device supports // Get feature level this gfx device supports
D3D_FEATURE_LEVEL getFeatureLevel() const { mFeatureLevel; } D3D_FEATURE_LEVEL getFeatureLevel() const { return mFeatureLevel; }
// Shader Model targers // Shader Model targers
const String &getVertexShaderTarget() const { return mVertexShaderTarget; } const String &getVertexShaderTarget() const { return mVertexShaderTarget; }
const String &getPixelShaderTarget() const { return mPixelShaderTarget; } const String &getPixelShaderTarget() const { return mPixelShaderTarget; }
const String &getShaderModel() const { return mShaderModel; }
// grab the sampler map // grab the sampler map
const SamplerMap &getSamplersMap() const { return mSamplersMap; } const SamplerMap &getSamplersMap() const { return mSamplersMap; }

View file

@ -790,9 +790,8 @@ bool GFXD3D11Shader::_init()
d3dMacros[i+smGlobalMacros.size()].Definition = mMacros[i].value.c_str(); d3dMacros[i+smGlobalMacros.size()].Definition = mMacros[i].value.c_str();
} }
//TODO support D3D_FEATURE_LEVEL properly with shaders instead of hard coding at hlsl 5
d3dMacros[macroCount - 2].Name = "TORQUE_SM"; d3dMacros[macroCount - 2].Name = "TORQUE_SM";
d3dMacros[macroCount - 2].Definition = "50"; d3dMacros[macroCount - 2].Definition = D3D11->getShaderModel().c_str();
memset(&d3dMacros[macroCount - 1], 0, sizeof(D3D_SHADER_MACRO)); memset(&d3dMacros[macroCount - 1], 0, sizeof(D3D_SHADER_MACRO));