Преглед на файлове

Added getShaderModel string to D3D11 for use with shader version macros.

rextimmy преди 8 години
родител
ревизия
86a95e748e
променени са 3 файла, в които са добавени 9 реда и са изтрити 3 реда
  1. 4 0
      Engine/source/gfx/D3D11/gfxD3D11Device.cpp
  2. 4 1
      Engine/source/gfx/D3D11/gfxD3D11Device.h
  3. 1 2
      Engine/source/gfx/D3D11/gfxD3D11Shader.cpp

+ 4 - 0
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");

+ 4 - 1
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; }

+ 1 - 2
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));