diff --git a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp index e25401085..fd2e2e58b 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp @@ -106,6 +106,7 @@ GFXD3D11Device::GFXD3D11Device(U32 index) mVertexShaderTarget = String::EmptyString; mPixelShaderTarget = String::EmptyString; + mShaderModel = String::EmptyString; mDrawInstancesCount = 0; @@ -491,16 +492,19 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window) mVertexShaderTarget = "vs_5_0"; mPixelShaderTarget = "ps_5_0"; mPixVersion = 5.0f; + mShaderModel = "50"; break; case D3D_FEATURE_LEVEL_10_1: mVertexShaderTarget = "vs_4_1"; mPixelShaderTarget = "ps_4_1"; mPixVersion = 4.1f; + mShaderModel = "41"; break; case D3D_FEATURE_LEVEL_10_0: mVertexShaderTarget = "vs_4_0"; mPixelShaderTarget = "ps_4_0"; mPixVersion = 4.0f; + mShaderModel = "40"; break; default: AssertFatal(false, "GFXD3D11Device::init - We don't support this feature level"); diff --git a/Engine/source/gfx/D3D11/gfxD3D11Device.h b/Engine/source/gfx/D3D11/gfxD3D11Device.h index acb04c461..2936ac2af 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Device.h +++ b/Engine/source/gfx/D3D11/gfxD3D11Device.h @@ -140,6 +140,8 @@ protected: // Shader Model targers String mVertexShaderTarget; String mPixelShaderTarget; + // String for use with shader macros in the form of shader model version * 10 + String mShaderModel; bool mDebugLayers; @@ -306,10 +308,11 @@ public: DXGI_SAMPLE_DESC getMultisampleType() const { return mMultisampleDesc; } // Get feature level this gfx device supports - D3D_FEATURE_LEVEL getFeatureLevel() const { mFeatureLevel; } + D3D_FEATURE_LEVEL getFeatureLevel() const { return mFeatureLevel; } // Shader Model targers const String &getVertexShaderTarget() const { return mVertexShaderTarget; } const String &getPixelShaderTarget() const { return mPixelShaderTarget; } + const String &getShaderModel() const { return mShaderModel; } // grab the sampler map const SamplerMap &getSamplersMap() const { return mSamplersMap; } diff --git a/Engine/source/gfx/D3D11/gfxD3D11Shader.cpp b/Engine/source/gfx/D3D11/gfxD3D11Shader.cpp index 1e132534c..054e19bc6 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Shader.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11Shader.cpp @@ -790,9 +790,8 @@ bool GFXD3D11Shader::_init() 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].Definition = "50"; + d3dMacros[macroCount - 2].Definition = D3D11->getShaderModel().c_str(); memset(&d3dMacros[macroCount - 1], 0, sizeof(D3D_SHADER_MACRO));