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

Method OutputDeclaration

hlslparser/src/HLSLGenerator.cpp:922–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920}
921
922void HLSLGenerator::OutputDeclaration(HLSLDeclaration* declaration)
923{
924 if (IsSamplerType(declaration->type)) {
925 int reg = -1;
926 if (declaration->registerName != NULL) {
927 sscanf(declaration->registerName, "s%d", &reg);
928 }
929
930 // sampler
931 const char* samplerTypeName = GetTypeName(declaration->type);
932 if (samplerTypeName) {
933 if (reg != -1) {
934 m_writer.Write("%s %s : register(s%d)", samplerTypeName, declaration->name, reg);
935 }
936 else {
937 m_writer.Write("%s %s", samplerTypeName, declaration->name);
938 }
939 }
940 return;
941 }
942 if (IsTextureType(declaration->type)) {
943 int reg = -1;
944 if (declaration->registerName != NULL) {
945 sscanf(declaration->registerName, "t%d", &reg);
946 }
947
948 HLSLBaseType formatType = declaration->type.formatType;
949 if (m_options.treatHalfAsFloat && IsHalf(formatType))
950 formatType = HalfToFloatBaseType(formatType);
951
952 const char* formatTypeName = GetFormatName(declaration->type.baseType, formatType);
953
954 // texture carts the dimension and format
955 const char* textureTypeName = GetTypeName(declaration->type);
956
957 if (textureTypeName != NULL) {
958 if (reg != -1) {
959 m_writer.Write("%s<%s> %s : register(t%d)", textureTypeName, formatTypeName, declaration->name, reg);
960 }
961 else {
962 m_writer.Write("%s<%s> %s", textureTypeName, formatTypeName, declaration->name);
963 }
964 }
965 return;
966 }
967
968 OutputDeclarationType(declaration->type);
969 OutputDeclarationBody(declaration->type, declaration->name, declaration->semantic, declaration->registerName, declaration->assignment);
970 declaration = declaration->nextDeclaration;
971
972 while (declaration != NULL) {
973 m_writer.Write(", ");
974 OutputDeclarationBody(declaration->type, declaration->name, declaration->semantic, declaration->registerName, declaration->assignment);
975 declaration = declaration->nextDeclaration;
976 };
977}
978
979void HLSLGenerator::OutputDeclarationType(const HLSLType& type, bool isTypeCast)

Callers

nothing calls this directly

Calls 5

IsSamplerTypeFunction · 0.85
IsTextureTypeFunction · 0.85
IsHalfFunction · 0.85
HalfToFloatBaseTypeFunction · 0.85
WriteMethod · 0.80

Tested by

no test coverage detected