TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing) { if (structure.symbolType() == SymbolType::Empty) { return ""; } TString prefix = ""; // Structs packed with row-major matrices in HLSL are prefixed with "rm" // GLSL column-major maps to HLSL row-major, and the converse is true if (useStd140Packing) { prefix += "std_"; } if (useHLSLRowMajorPacking) { prefix += "rm_"; } return prefix + StructNameString(structure); }
FName FStructureEditorUtils::MakeUniqueStructName(UBlueprint* Blueprint, const FString& BaseName) { FString StructNameString(BaseName); FName StructName(*StructNameString); FKismetNameValidator NameValidator(Blueprint); int32 Index = 0; while ((NameValidator.IsValid(StructName) != EValidatorResult::Ok) || !IsUniqueObjectName(StructName, Blueprint->GetOutermost())) { StructName = FName(*FString::Printf(TEXT("%s%i"), *StructNameString, Index)); ++Index; } return StructName; }
TString TypeString(const TType &type) { const TStructure *structure = type.getStruct(); if (structure) { if (structure->symbolType() != SymbolType::Empty) { return StructNameString(*structure); } else // Nameless structure, define in place { return StructureHLSL::defineNameless(*structure); } } else if (type.isMatrix()) { int cols = type.getCols(); int rows = type.getRows(); return "float" + str(cols) + "x" + str(rows); } else { switch (type.getBasicType()) { case EbtFloat: switch (type.getNominalSize()) { case 1: return "float"; case 2: return "float2"; case 3: return "float3"; case 4: return "float4"; } case EbtInt: switch (type.getNominalSize()) { case 1: return "int"; case 2: return "int2"; case 3: return "int3"; case 4: return "int4"; } case EbtUInt: switch (type.getNominalSize()) { case 1: return "uint"; case 2: return "uint2"; case 3: return "uint3"; case 4: return "uint4"; } case EbtBool: switch (type.getNominalSize()) { case 1: return "bool"; case 2: return "bool2"; case 3: return "bool3"; case 4: return "bool4"; } case EbtVoid: return "void"; case EbtSampler2D: case EbtISampler2D: case EbtUSampler2D: case EbtSampler2DArray: case EbtISampler2DArray: case EbtUSampler2DArray: return "sampler2D"; case EbtSamplerCube: case EbtISamplerCube: case EbtUSamplerCube: return "samplerCUBE"; case EbtSamplerExternalOES: return "sampler2D"; case EbtAtomicCounter: // Multiple atomic_uints will be implemented as a single RWByteAddressBuffer return "RWByteAddressBuffer"; default: break; } } UNREACHABLE(); return "<unknown type>"; }
TString TypeString(const TType &type) { const TStructure* structure = type.getStruct(); if (structure) { const TString& typeName = structure->name(); if (typeName != "") { return StructNameString(*structure); } else // Nameless structure, define in place { return StructureHLSL::defineNameless(*structure); } } else if (type.isMatrix()) { int cols = type.getCols(); int rows = type.getRows(); return "float" + str(cols) + "x" + str(rows); } else { switch (type.getBasicType()) { case EbtFloat: switch (type.getNominalSize()) { case 1: return "float"; case 2: return "float2"; case 3: return "float3"; case 4: return "float4"; } case EbtInt: switch (type.getNominalSize()) { case 1: return "int"; case 2: return "int2"; case 3: return "int3"; case 4: return "int4"; } case EbtUInt: switch (type.getNominalSize()) { case 1: return "uint"; case 2: return "uint2"; case 3: return "uint3"; case 4: return "uint4"; } case EbtBool: switch (type.getNominalSize()) { case 1: return "bool"; case 2: return "bool2"; case 3: return "bool3"; case 4: return "bool4"; } case EbtVoid: return "void"; case EbtSampler2D: case EbtISampler2D: case EbtUSampler2D: case EbtSampler2DArray: case EbtISampler2DArray: case EbtUSampler2DArray: return "sampler2D"; case EbtSamplerCube: case EbtISamplerCube: case EbtUSamplerCube: return "samplerCUBE"; case EbtSamplerExternalOES: return "sampler2D"; default: break; } } UNREACHABLE(); return "<unknown type>"; }