Commit 0c45ef90 authored by D-AIRY's avatar D-AIRY

New material system (continue)

parent 06e70699
......@@ -550,6 +550,10 @@ static void GetAllDefines(Array<CMaterialSystem::MaterialDefine> &aAllDefines, A
static bool EvalCondition(CLogicExpression *pExpr, Array<CMaterialSystem::MaterialDefine*> &aStaticList)
{
if(!pExpr)
{
return(true);
}
pExpr->resetParams();
for(UINT j = 0, jl = aStaticList.size(); j < jl; ++j)
{
......@@ -558,7 +562,8 @@ static bool EvalCondition(CLogicExpression *pExpr, Array<CMaterialSystem::Materi
return(pExpr->evaluate());
}
static void ParseTexturesConstants(Array<CMaterialSystem::MaterialProperty> &aProperties, Array<CMaterialSystem::MaterialDefine*> &aStaticList)
static void ParseTexturesConstants(Array<CMaterialSystem::MaterialProperty> &aProperties, Array<CMaterialSystem::MaterialDefine*> &aStaticList,
Array<const char*> &aTextures, Array<CMaterialSystem::MaterialShaderConstants> &aConstants)
{
for(UINT i = 0, l = aProperties.size(); i < l; ++i)
{
......@@ -572,19 +577,14 @@ static void ParseTexturesConstants(Array<CMaterialSystem::MaterialProperty> &aPr
{
if(EvalCondition(pProp->pCondition, aStaticList))
{
// $aTextures[] = $param['key'];
aTextures.push_back(pProp->prop.szKey);
}
}
else if(pProp->prop.varType != GXDECLTYPE_UNUSED)
{
if(EvalCondition(pProp->pCondition, aStaticList))
{
/*
$aConstants[] = [
'key' => $param['key'],
'type' => $param['var_type'],
];
*/
aConstants.push_back({pProp->prop.szKey, pProp->prop.varType});
}
}
}
......@@ -758,8 +758,17 @@ void CMaterialSystem::updateReferences()
aVariantDefines.push_back({aStaticList[j]->szName, "1"});
}
ParseTexturesConstants(pShader->aProperties, aStaticList);
ParseTexturesConstants(pPass->aProperties, aStaticList);
Array<const char*> aTextures;
Array<CMaterialSystem::MaterialShaderConstants> aConstants;
ParseTexturesConstants(pShader->aProperties, aStaticList, aTextures, aConstants);
ParseTexturesConstants(pPass->aProperties, aStaticList, aTextures, aConstants);
aConstants.quickSort([this](const MaterialShaderConstants &a, const MaterialShaderConstants &b){
return(this->getTypeSize(a.type) > this->getTypeSize(b.type));
});
int a = 0;
}
}
}
......
......@@ -207,6 +207,12 @@ protected:
Array<MaterialProperty> aProperties;
};
struct MaterialShaderConstants
{
const char *szKey;
GXDECLTYPE type;
};
AssotiativeArray<String, VertexFormatData> m_mVertexFormats;
MemAlloc<VertexShaderData> m_poolVSdata;
MemAlloc<GeometryShader> m_poolGSdata;
......@@ -222,7 +228,8 @@ protected:
friend void CopyProps(XMaterialProperty *pProperties, Array<CMaterialSystem::MaterialProperty> &aTarget, const char *szShaderName);
friend void GetAllDefines(Array<MaterialDefine> &aAllDefines, Array<MaterialProperty> &aProperties);
friend void ParseTexturesConstants(Array<MaterialProperty> &aProperties, Array<MaterialDefine*> &aStaticList);
friend void ParseTexturesConstants(Array<MaterialProperty> &aProperties, Array<MaterialDefine*> &aStaticList,
Array<const char*> &aTextures, Array<MaterialShaderConstants> &aConstants);
friend bool EvalCondition(CLogicExpression *pExpr, Array<MaterialDefine*> &aStaticList);
const char* getHLSLType(GXDECLTYPE type)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment