HLSL: Add min*{float,int,uint} types

These HLSL types are guaranteed to have at least the given number of bits, but may have more.

min{16,10}float is mapped to EbtFloat at medium precision -> SPIRV RelaxedPrecision
min{16,12}int and min16uint are mapped to mediump -> SPIR-V RelaxedPrecision
This commit is contained in:
steve-lunarg
2016-10-26 19:18:55 -06:00
parent e19e68d431
commit 3226b0835c
6 changed files with 428 additions and 2 deletions

View File

@@ -465,7 +465,7 @@ bool HlslGrammar::acceptFullySpecifiedType(TType& type)
// whatever comes from acceptQualifier.
assert(qualifier.layoutFormat == ElfNone);
qualifier.layoutFormat = type.getQualifier().layoutFormat;
qualifier.precision = type.getQualifier().precision;
type.getQualifier() = qualifier;
}
@@ -967,6 +967,14 @@ bool HlslGrammar::acceptTextureType(TType& type)
// Otherwise, return false, and don't advance
bool HlslGrammar::acceptType(TType& type)
{
// Basic types for min* types, broken out here in case of future
// changes, e.g, to use native halfs.
static const TBasicType min16float_bt = EbtFloat;
static const TBasicType min10float_bt = EbtFloat;
static const TBasicType min16int_bt = EbtInt;
static const TBasicType min12int_bt = EbtInt;
static const TBasicType min16uint_bt = EbtUint;
switch (peek()) {
case EHTokVector:
return acceptVectorTemplateType(type);
@@ -1118,6 +1126,91 @@ bool HlslGrammar::acceptType(TType& type)
new(&type) TType(EbtBool, EvqTemporary, 4);
break;
case EHTokMin16float:
new(&type) TType(min16float_bt, EvqTemporary, EpqMedium);
break;
case EHTokMin16float1:
new(&type) TType(min16float_bt, EvqTemporary, EpqMedium);
type.makeVector();
break;
case EHTokMin16float2:
new(&type) TType(min16float_bt, EvqTemporary, EpqMedium, 2);
break;
case EHTokMin16float3:
new(&type) TType(min16float_bt, EvqTemporary, EpqMedium, 3);
break;
case EHTokMin16float4:
new(&type) TType(min16float_bt, EvqTemporary, EpqMedium, 4);
break;
case EHTokMin10float:
new(&type) TType(min10float_bt, EvqTemporary, EpqMedium);
break;
case EHTokMin10float1:
new(&type) TType(min10float_bt, EvqTemporary, EpqMedium);
type.makeVector();
break;
case EHTokMin10float2:
new(&type) TType(min10float_bt, EvqTemporary, EpqMedium, 2);
break;
case EHTokMin10float3:
new(&type) TType(min10float_bt, EvqTemporary, EpqMedium, 3);
break;
case EHTokMin10float4:
new(&type) TType(min10float_bt, EvqTemporary, EpqMedium, 4);
break;
case EHTokMin16int:
new(&type) TType(min16int_bt, EvqTemporary, EpqMedium);
break;
case EHTokMin16int1:
new(&type) TType(min16int_bt, EvqTemporary, EpqMedium);
type.makeVector();
break;
case EHTokMin16int2:
new(&type) TType(min16int_bt, EvqTemporary, EpqMedium, 2);
break;
case EHTokMin16int3:
new(&type) TType(min16int_bt, EvqTemporary, EpqMedium, 3);
break;
case EHTokMin16int4:
new(&type) TType(min16int_bt, EvqTemporary, EpqMedium, 4);
break;
case EHTokMin12int:
new(&type) TType(min12int_bt, EvqTemporary, EpqMedium);
break;
case EHTokMin12int1:
new(&type) TType(min12int_bt, EvqTemporary, EpqMedium);
type.makeVector();
break;
case EHTokMin12int2:
new(&type) TType(min12int_bt, EvqTemporary, EpqMedium, 2);
break;
case EHTokMin12int3:
new(&type) TType(min12int_bt, EvqTemporary, EpqMedium, 3);
break;
case EHTokMin12int4:
new(&type) TType(min12int_bt, EvqTemporary, EpqMedium, 4);
break;
case EHTokMin16uint:
new(&type) TType(min16uint_bt, EvqTemporary, EpqMedium);
break;
case EHTokMin16uint1:
new(&type) TType(min16uint_bt, EvqTemporary, EpqMedium);
type.makeVector();
break;
case EHTokMin16uint2:
new(&type) TType(min16uint_bt, EvqTemporary, EpqMedium, 2);
break;
case EHTokMin16uint3:
new(&type) TType(min16uint_bt, EvqTemporary, EpqMedium, 3);
break;
case EHTokMin16uint4:
new(&type) TType(min16uint_bt, EvqTemporary, EpqMedium, 4);
break;
case EHTokInt1x1:
new(&type) TType(EbtInt, EvqTemporary, 0, 1, 1);
break;

View File

@@ -136,7 +136,7 @@ void HlslScanContext::fillInKeywordMap()
(*KeywordMap)["min10float"] = EHTokMin10float;
(*KeywordMap)["min16int"] = EHTokMin16int;
(*KeywordMap)["min12int"] = EHTokMin12int;
(*KeywordMap)["min16uint"] = EHTokMin16int;
(*KeywordMap)["min16uint"] = EHTokMin16uint;
(*KeywordMap)["bool1"] = EHTokBool1;
(*KeywordMap)["bool2"] = EHTokBool2;
@@ -159,6 +159,27 @@ void HlslScanContext::fillInKeywordMap()
(*KeywordMap)["uint3"] = EHTokUint3;
(*KeywordMap)["uint4"] = EHTokUint4;
(*KeywordMap)["min16float1"] = EHTokMin16float1;
(*KeywordMap)["min16float2"] = EHTokMin16float2;
(*KeywordMap)["min16float3"] = EHTokMin16float3;
(*KeywordMap)["min16float4"] = EHTokMin16float4;
(*KeywordMap)["min10float1"] = EHTokMin10float1;
(*KeywordMap)["min10float2"] = EHTokMin10float2;
(*KeywordMap)["min10float3"] = EHTokMin10float3;
(*KeywordMap)["min10float4"] = EHTokMin10float4;
(*KeywordMap)["min16int1"] = EHTokMin16int1;
(*KeywordMap)["min16int2"] = EHTokMin16int2;
(*KeywordMap)["min16int3"] = EHTokMin16int3;
(*KeywordMap)["min16int4"] = EHTokMin16int4;
(*KeywordMap)["min12int1"] = EHTokMin12int1;
(*KeywordMap)["min12int2"] = EHTokMin12int2;
(*KeywordMap)["min12int3"] = EHTokMin12int3;
(*KeywordMap)["min12int4"] = EHTokMin12int4;
(*KeywordMap)["min16uint1"] = EHTokMin16uint1;
(*KeywordMap)["min16uint2"] = EHTokMin16uint2;
(*KeywordMap)["min16uint3"] = EHTokMin16uint3;
(*KeywordMap)["min16uint4"] = EHTokMin16uint4;
(*KeywordMap)["int1x1"] = EHTokInt1x1;
(*KeywordMap)["int1x2"] = EHTokInt1x2;
(*KeywordMap)["int1x3"] = EHTokInt1x3;
@@ -518,6 +539,26 @@ EHlslTokenClass HlslScanContext::tokenizeIdentifier()
case EHTokUint2:
case EHTokUint3:
case EHTokUint4:
case EHTokMin16float1:
case EHTokMin16float2:
case EHTokMin16float3:
case EHTokMin16float4:
case EHTokMin10float1:
case EHTokMin10float2:
case EHTokMin10float3:
case EHTokMin10float4:
case EHTokMin16int1:
case EHTokMin16int2:
case EHTokMin16int3:
case EHTokMin16int4:
case EHTokMin12int1:
case EHTokMin12int2:
case EHTokMin12int3:
case EHTokMin12int4:
case EHTokMin16uint1:
case EHTokMin16uint2:
case EHTokMin16uint3:
case EHTokMin16uint4:
// matrix types
case EHTokInt1x1:

View File

@@ -108,6 +108,26 @@ enum EHlslTokenClass {
EHTokUint2,
EHTokUint3,
EHTokUint4,
EHTokMin16float1,
EHTokMin16float2,
EHTokMin16float3,
EHTokMin16float4,
EHTokMin10float1,
EHTokMin10float2,
EHTokMin10float3,
EHTokMin10float4,
EHTokMin16int1,
EHTokMin16int2,
EHTokMin16int3,
EHTokMin16int4,
EHTokMin12int1,
EHTokMin12int2,
EHTokMin12int3,
EHTokMin12int4,
EHTokMin16uint1,
EHTokMin16uint2,
EHTokMin16uint3,
EHTokMin16uint4,
// matrix types
EHTokInt1x1,