moved Check()/Comp()/From() to .cpp from ShaderVariableType.h
This commit is contained in:
parent
f741825ab7
commit
5ba5a331a5
@ -156,89 +156,9 @@ namespace hgl
|
||||
array_size=count;
|
||||
}
|
||||
|
||||
const bool Check()const
|
||||
{
|
||||
if(!RangeCheck(base_type))return(false);
|
||||
const bool Check()const;
|
||||
|
||||
RANGE_CHECK_RETURN_FALSE(base_type)
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return(true);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
if(vector.vec_size<2||vector.vec_size>4)return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
if(matrix.m==0)
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
if(matrix.m<2||matrix.m>4)return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return RangeCheck(sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return RangeCheck(image.type);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
int Comp(const ShaderVariableType &svt)const
|
||||
{
|
||||
int off=(int)base_type-(int)svt.base_type;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return int(scalar.type)-int(svt.scalar.type);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
off=int(vector.type)-int(svt.vector.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=vector.vec_size-svt.vector.vec_size;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return int(vector.type)-int(svt.vector.type);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
off=int(matrix.type)-int(svt.matrix.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=matrix.n-svt.matrix.n;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return matrix.m-svt.matrix.m;
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return int(sampler.type)-int(svt.sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return int(image.type)-int(svt.image.type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
int Comp(const ShaderVariableType &svt)const;
|
||||
|
||||
CompOperator(const ShaderVariableType &,Comp)
|
||||
|
||||
@ -254,29 +174,7 @@ namespace hgl
|
||||
return Check();
|
||||
}
|
||||
|
||||
const bool From(const VAType &vat,const uint16 count=1)
|
||||
{
|
||||
array_size=count;
|
||||
|
||||
if(vat.vec_size==1)
|
||||
{
|
||||
base_type=SVBaseType::Scalar;
|
||||
scalar.type=vat.basetype;
|
||||
|
||||
return(true);
|
||||
}
|
||||
else if(vat.vec_size<=4)
|
||||
{
|
||||
base_type=SVBaseType::Vector;
|
||||
|
||||
vector.type=vat.basetype;
|
||||
vector.vec_size=vat.vec_size;
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
const bool From(const VAType &vat,const uint16 count=1);
|
||||
|
||||
static const ShaderVariableType Scalar(const VABaseType &vabt,const uint count=1)
|
||||
{
|
||||
|
@ -45,6 +45,90 @@ namespace
|
||||
constexpr const char AtomicCounterTypename[]="atomic_uint";
|
||||
}//namespace
|
||||
|
||||
const bool ShaderVariableType::Check()const
|
||||
{
|
||||
if(!RangeCheck(base_type))return(false);
|
||||
|
||||
RANGE_CHECK_RETURN_FALSE(base_type)
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return(true);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
if(vector.vec_size<2||vector.vec_size>4)return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
if(matrix.m==0)
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(matrix.n<2||matrix.n>4)return(false);
|
||||
if(matrix.m<2||matrix.m>4)return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return RangeCheck(sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return RangeCheck(image.type);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
int ShaderVariableType::Comp(const ShaderVariableType &svt)const
|
||||
{
|
||||
int off=(int)base_type-(int)svt.base_type;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
return int(scalar.type)-int(svt.scalar.type);
|
||||
|
||||
if(base_type==SVBaseType::Vector)
|
||||
{
|
||||
off=int(vector.type)-int(svt.vector.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=vector.vec_size-svt.vector.vec_size;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return int(vector.type)-int(svt.vector.type);
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Matrix)
|
||||
{
|
||||
off=int(matrix.type)-int(svt.matrix.type);
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
off=matrix.n-svt.matrix.n;
|
||||
|
||||
if(off)return(off);
|
||||
|
||||
return matrix.m-svt.matrix.m;
|
||||
}
|
||||
|
||||
if(base_type==SVBaseType::Sampler)
|
||||
return int(sampler.type)-int(svt.sampler.type);
|
||||
|
||||
if(base_type==SVBaseType::Image)
|
||||
return int(image.type)-int(svt.image.type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *ShaderVariableType::GetTypename()const
|
||||
{
|
||||
if(base_type==SVBaseType::Scalar)
|
||||
@ -268,4 +352,28 @@ bool ShaderVariableType::ParseTypeString(const char *str)
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
const bool ShaderVariableType::From(const VAType &vat,const uint16 count)
|
||||
{
|
||||
array_size=count;
|
||||
|
||||
if(vat.vec_size==1)
|
||||
{
|
||||
base_type=SVBaseType::Scalar;
|
||||
scalar.type=vat.basetype;
|
||||
|
||||
return(true);
|
||||
}
|
||||
else if(vat.vec_size<=4)
|
||||
{
|
||||
base_type=SVBaseType::Vector;
|
||||
|
||||
vector.type=vat.basetype;
|
||||
vector.vec_size=vat.vec_size;
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
Loading…
x
Reference in New Issue
Block a user