D3D11 Feature level 10 support and D3D11 device cleanup.

This commit is contained in:
rextimmy 2016-12-23 15:00:07 +10:00
parent 38bf2b8175
commit 983b3211ed
4 changed files with 211 additions and 144 deletions

View file

@ -206,7 +206,6 @@ bool GFXD3D11ConstBufferLayout::setMatrix(const ParamDesc& pd, const GFXShaderCo
}
else if (pd.constType == GFXSCT_Float4x3)
{
F32 buffer[4 * 4];
const U32 csize = 48;
// Loop through and copy
@ -811,18 +810,21 @@ bool GFXD3D11Shader::_init()
mSamplerDescriptions.clear();
mShaderConsts.clear();
String vertTarget = D3D11->getVertexShaderTarget();
String pixTarget = D3D11->getPixelShaderTarget();
if ( !Con::getBoolVariable( "$shaders::forceLoadCSF", false ) )
{
if (!mVertexFile.isEmpty() && !_compileShader( mVertexFile, "vs_5_0", d3dMacros, mVertexConstBufferLayout, mSamplerDescriptions ) )
if (!mVertexFile.isEmpty() && !_compileShader( mVertexFile, vertTarget, d3dMacros, mVertexConstBufferLayout, mSamplerDescriptions ) )
return false;
if (!mPixelFile.isEmpty() && !_compileShader( mPixelFile, "ps_5_0", d3dMacros, mPixelConstBufferLayout, mSamplerDescriptions ) )
if (!mPixelFile.isEmpty() && !_compileShader( mPixelFile, pixTarget, d3dMacros, mPixelConstBufferLayout, mSamplerDescriptions ) )
return false;
}
else
{
if ( !_loadCompiledOutput( mVertexFile, "vs_5_0", mVertexConstBufferLayout, mSamplerDescriptions ) )
if ( !_loadCompiledOutput( mVertexFile, vertTarget, mVertexConstBufferLayout, mSamplerDescriptions ) )
{
if ( smLogErrors )
Con::errorf( "GFXD3D11Shader::init - Unable to load precompiled vertex shader for '%s'.", mVertexFile.getFullPath().c_str() );
@ -830,7 +832,7 @@ bool GFXD3D11Shader::_init()
return false;
}
if ( !_loadCompiledOutput( mPixelFile, "ps_5_0", mPixelConstBufferLayout, mSamplerDescriptions ) )
if ( !_loadCompiledOutput( mPixelFile, pixTarget, mPixelConstBufferLayout, mSamplerDescriptions ) )
{
if ( smLogErrors )
Con::errorf( "GFXD3D11Shader::init - Unable to load precompiled pixel shader for '%s'.", mPixelFile.getFullPath().c_str() );
@ -1053,20 +1055,20 @@ bool GFXD3D11Shader::_compileShader( const Torque::Path &filePath,
return result;
}
void GFXD3D11Shader::_getShaderConstants( ID3D11ShaderReflection *table,
void GFXD3D11Shader::_getShaderConstants( ID3D11ShaderReflection *pTable,
GenericConstBufferLayout *bufferLayoutIn,
Vector<GFXShaderConstDesc> &samplerDescriptions )
{
PROFILE_SCOPE( GFXD3D11Shader_GetShaderConstants );
AssertFatal(table, "NULL constant table not allowed, is this an assembly shader?");
AssertFatal(pTable, "NULL constant table not allowed, is this an assembly shader?");
GFXD3D11ConstBufferLayout *bufferLayout = (GFXD3D11ConstBufferLayout*)bufferLayoutIn;
Vector<ConstSubBufferDesc> &subBuffers = bufferLayout->getSubBufferDesc();
subBuffers.clear();
D3D11_SHADER_DESC tableDesc;
HRESULT hr = table->GetDesc(&tableDesc);
HRESULT hr = pTable->GetDesc(&tableDesc);
if (FAILED(hr))
{
AssertFatal(false, "Shader Reflection table unable to be created");
@ -1076,7 +1078,7 @@ void GFXD3D11Shader::_getShaderConstants( ID3D11ShaderReflection *table,
U32 bufferOffset = 0;
for (U32 i = 0; i < tableDesc.ConstantBuffers; i++)
{
ID3D11ShaderReflectionConstantBuffer* constantBuffer = table->GetConstantBufferByIndex(i);
ID3D11ShaderReflectionConstantBuffer* constantBuffer = pTable->GetConstantBufferByIndex(i);
D3D11_SHADER_BUFFER_DESC constantBufferDesc;
if (constantBuffer->GetDesc(&constantBufferDesc) == S_OK)
@ -1161,7 +1163,7 @@ void GFXD3D11Shader::_getShaderConstants( ID3D11ShaderReflection *table,
{
GFXShaderConstDesc desc;
D3D11_SHADER_INPUT_BIND_DESC bindDesc;
table->GetResourceBindingDesc(i, &bindDesc);
pTable->GetResourceBindingDesc(i, &bindDesc);
switch (bindDesc.Type)
{