MCPcopy Create free account
hub / github.com/alecazam/kram / GetTypeName

Method GetTypeName

hlslparser/src/HLSLGenerator.cpp:18–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16namespace M4 {
17
18const char* HLSLGenerator::GetTypeName(const HLSLType& type)
19{
20 bool promote = ((type.flags & HLSLTypeFlag_NoPromote) == 0);
21
22 // number
23 bool isHalfNumerics = promote && !m_options.treatHalfAsFloat;
24 HLSLBaseType baseType = type.baseType;
25
26 // Note: these conversions should really be done during parsing
27 // so that casting gets applied.
28 if (!isHalfNumerics)
29 baseType = HalfToFloatBaseType(baseType);
30
31 // MSL doesn't support double, and many HLSL cards don't either.
32 //if (IsDouble(baseType))
33 // baseType = DoubleToFloatBaseType(baseType);
34
35 HLSLType remappedType(type);
36 remappedType.baseType = baseType;
37
38 // DONE: these can all just use a table entry, have another slot for MSL
39 // Functions can return void, especially with compute
40 if (IsTextureType(baseType) || IsSamplerType(baseType) || IsNumericType(baseType) || baseType == HLSLBaseType_Void || baseType == HLSLBaseType_UserDefined)
41 return GetTypeNameHLSL(remappedType);
42
43 Error("Unknown type");
44 return NULL;
45}
46
47// TODO: copied from MSLGenerator
48// @@ We could be a lot smarter removing parenthesis based on the operator precedence of the parent expression.

Callers

nothing calls this directly

Calls 5

HalfToFloatBaseTypeFunction · 0.85
IsTextureTypeFunction · 0.85
IsSamplerTypeFunction · 0.85
IsNumericTypeFunction · 0.85
GetTypeNameHLSLFunction · 0.85

Tested by

no test coverage detected