Hardware Skinning Support

- Supports GL, D3D9 & D3D11
- Extends vertex formats & shadergen to support blend indices and weights
- Adds basic support for using 4x3 matrices for shader constants
- Supports software fallback
This commit is contained in:
James Urquhart 2015-01-10 19:41:25 +00:00
parent 507c239a87
commit 3496c549b5
72 changed files with 2533 additions and 1327 deletions

View file

@ -32,7 +32,20 @@ Var * ShaderConnectorHLSL::getElement( RegisterType type,
U32 numElements,
U32 numRegisters )
{
Var *ret = getIndexedElement( mCurTexElem, type, numElements, numRegisters );
Var *ret = NULL;
if ( type == RT_BLENDINDICES )
{
ret = getIndexedElement( mCurBlendIndicesElem, type, numElements, numRegisters );
}
else if ( type == RT_BLENDWEIGHT )
{
ret = getIndexedElement( mCurBlendWeightsElem, type, numElements, numRegisters );
}
else
{
ret = getIndexedElement( mCurTexElem, type, numElements, numRegisters );
}
// Adjust texture offset if this is a texcoord type
if( type == RT_TEXCOORD )
@ -42,6 +55,20 @@ Var * ShaderConnectorHLSL::getElement( RegisterType type,
else
mCurTexElem += numElements;
}
else if ( type == RT_BLENDINDICES )
{
if ( numRegisters != -1 )
mCurBlendIndicesElem += numRegisters;
else
mCurBlendIndicesElem += numElements;
}
else if ( type == RT_BLENDWEIGHT )
{
if ( numRegisters != -1 )
mCurBlendWeightsElem += numRegisters;
else
mCurBlendWeightsElem += numElements;
}
return ret;
}
@ -133,6 +160,46 @@ Var * ShaderConnectorHLSL::getIndexedElement( U32 index, RegisterType type, U32
return newVar;
}
case RT_BLENDINDICES:
{
Var *newVar = new Var;
mElementList.push_back( newVar );
// This was needed for hardware instancing, but
// i don't really remember why right now.
if ( index > mCurBlendIndicesElem )
mCurBlendIndicesElem = index + 1;
char out[32];
dSprintf( (char*)out, sizeof(out), "BLENDINDICES%d", index );
newVar->setConnectName( out );
newVar->constNum = index;
newVar->arraySize = numElements;
return newVar;
}
case RT_BLENDWEIGHT:
{
Var *newVar = new Var;
mElementList.push_back( newVar );
// This was needed for hardware instancing, but
// i don't really remember why right now.
if ( index > mCurBlendWeightsElem )
mCurBlendWeightsElem = index + 1;
char out[32];
dSprintf( (char*)out, sizeof(out), "BLENDWEIGHT%d", index );
newVar->setConnectName( out );
newVar->constNum = index;
newVar->arraySize = numElements;
return newVar;
}
default:
break;
}
@ -177,6 +244,8 @@ void ShaderConnectorHLSL::reset()
mElementList.setSize( 0 );
mCurTexElem = 0;
mCurBlendIndicesElem = 0;
mCurBlendWeightsElem = 0;
}
void ShaderConnectorHLSL::print( Stream &stream, bool isVertexShader )
@ -231,12 +300,23 @@ void ParamsDefHLSL::assignConstantNumbers()
if (dStrcmp((const char*)var->type, "float4x4") == 0)
{
mCurrConst += (4 * var->arraySize);
} else {
}
else
{
if (dStrcmp((const char*)var->type, "float3x3") == 0)
{
mCurrConst += (3 * var->arraySize);
} else {
mCurrConst += var->arraySize;
}
else
{
if (dStrcmp((const char*)var->type, "float4x3") == 0)
{
mCurrConst += (3 * var->arraySize);
}
else
{
mCurrConst += var->arraySize;
}
}
}
}