Hash :
9b63700b
Author :
Date :
2023-07-11T10:25:40
Translator: Reorganize files This change makes the translator files more organized by: - Grouping files that are specific to a certain output under their own directory, - Moving transformations under tree_ops - Removing Direct from metal translation now that that SPIR-V Cross path is removed Bug: angleproject:6394 Change-Id: Iaf5bb8d5604b84748dece029821b1f77b2813967 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4678780 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
//
// Copyright 2002 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#if defined(_MSC_VER)
# pragma warning(disable : 4718)
#endif
#include "compiler/translator/msl/UtilsMSL.h"
#include <algorithm>
#include <climits>
#include "compiler/translator/HashNames.h"
#include "compiler/translator/ImmutableString.h"
#include "compiler/translator/InfoSink.h"
#include "compiler/translator/IntermNode.h"
#include "compiler/translator/SymbolTable.h"
#include "compiler/translator/Types.h"
namespace sh
{
const char *getBasicMetalString(const TType *t)
{
switch (t->getBasicType())
{
case EbtVoid:
return "void";
case EbtFloat:
return "float";
case EbtInt:
return "int";
case EbtUInt:
return "uint32_t";
case EbtBool:
return "bool";
case EbtYuvCscStandardEXT:
return "yuvCscStandardEXT";
case EbtSampler2D:
return "sampler2D";
case EbtSampler3D:
return "sampler3D";
case EbtSamplerCube:
return "samplerCube";
case EbtSamplerExternalOES:
return "samplerExternalOES";
case EbtSamplerExternal2DY2YEXT:
return "__samplerExternal2DY2YEXT";
case EbtSampler2DRect:
return "sampler2DRect";
case EbtSampler2DArray:
return "sampler2DArray";
case EbtSampler2DMS:
return "sampler2DMS";
case EbtSampler2DMSArray:
return "sampler2DMSArray";
case EbtSamplerCubeArray:
return "samplerCubeArray";
case EbtISampler2D:
return "isampler2D";
case EbtISampler3D:
return "isampler3D";
case EbtISamplerCube:
return "isamplerCube";
case EbtISampler2DArray:
return "isampler2DArray";
case EbtISampler2DMS:
return "isampler2DMS";
case EbtISampler2DMSArray:
return "isampler2DMSArray";
case EbtISamplerCubeArray:
return "isamplerCubeArray";
case EbtUSampler2D:
return "usampler2D";
case EbtUSampler3D:
return "usampler3D";
case EbtUSamplerCube:
return "usamplerCube";
case EbtUSampler2DArray:
return "usampler2DArray";
case EbtUSampler2DMS:
return "usampler2DMS";
case EbtUSampler2DMSArray:
return "usampler2DMSArray";
case EbtUSamplerCubeArray:
return "usamplerCubeArray";
case EbtSampler2DShadow:
return "sampler2DShadow";
case EbtSamplerCubeShadow:
return "samplerCubeShadow";
case EbtSampler2DArrayShadow:
return "sampler2DArrayShadow";
case EbtSamplerCubeArrayShadow:
return "samplerCubeArrayShadow";
case EbtStruct:
return "structure";
case EbtInterfaceBlock:
return "interface block";
case EbtImage2D:
return "texture2d";
case EbtIImage2D:
return "texture2d<int>";
case EbtUImage2D:
return "texture2d<uint32_t>";
case EbtImage3D:
return "texture3d";
case EbtIImage3D:
return "texture3d<int>";
case EbtUImage3D:
return "texture3d<uint32_t>";
case EbtImage2DArray:
if (t->isUnsizedArray())
{
return "array_ref<texture2d>";
}
else
{
return "NOT_IMPLEMENTED";
}
case EbtIImage2DArray:
if (t->isUnsizedArray())
{
return "array_ref<texture2d<int>>";
}
else
{
return "NOT_IMPLEMENTED";
}
case EbtUImage2DArray:
if (t->isUnsizedArray())
{
return "array_ref<texture2d<uint32_t>>";
}
else
{
return "NOT_IMPLEMENTED";
}
case EbtImageCube:
return "texturecube";
case EbtIImageCube:
return "texturecube<int>";
case EbtUImageCube:
return "texturecube<uint32_t>";
case EbtImageCubeArray:
if (t->isUnsizedArray())
{
return "array_ref<texturecube>";
}
else
{
return "NOT_IMPLEMENTED";
}
case EbtIImageCubeArray:
if (t->isUnsizedArray())
{
return "array_ref<texturecube<int>>";
}
else
{
return "NOT_IMPLEMENTED";
}
case EbtUImageCubeArray:
if (t->isUnsizedArray())
{
return "array_ref<texturecube<uint32_t>>";
}
else
{
return "NOT_IMPLEMENTED";
}
case EbtAtomicCounter:
return "atomic_uint";
case EbtSamplerVideoWEBGL:
return "$samplerVideoWEBGL";
default:
UNREACHABLE();
return "unknown type";
}
}
const char *getBuiltInMetalTypeNameString(const TType *t)
{
if (t->isMatrix())
{
switch (t->getCols())
{
case 2:
switch (t->getRows())
{
case 2:
return "float2";
case 3:
return "float2x3";
case 4:
return "float2x4";
default:
UNREACHABLE();
return nullptr;
}
case 3:
switch (t->getRows())
{
case 2:
return "float3x2";
case 3:
return "float3";
case 4:
return "float3x4";
default:
UNREACHABLE();
return nullptr;
}
case 4:
switch (t->getRows())
{
case 2:
return "float4x2";
case 3:
return "float4x3";
case 4:
return "float4";
default:
UNREACHABLE();
return nullptr;
}
default:
UNREACHABLE();
return nullptr;
}
}
if (t->isVector())
{
switch (t->getBasicType())
{
case EbtFloat:
switch (t->getNominalSize())
{
case 2:
return "float2";
case 3:
return "float3";
case 4:
return "float4";
default:
UNREACHABLE();
return nullptr;
}
case EbtInt:
switch (t->getNominalSize())
{
case 2:
return "int2";
case 3:
return "int3";
case 4:
return "int4";
default:
UNREACHABLE();
return nullptr;
}
case EbtBool:
switch (t->getNominalSize())
{
case 2:
return "bool2";
case 3:
return "bool3";
case 4:
return "bool4";
default:
UNREACHABLE();
return nullptr;
}
case EbtUInt:
switch (t->getNominalSize())
{
case 2:
return "uint2";
case 3:
return "uint3";
case 4:
return "uint4";
default:
UNREACHABLE();
return nullptr;
}
default:
UNREACHABLE();
return nullptr;
}
}
ASSERT(t->getBasicType() != EbtStruct);
ASSERT(t->getBasicType() != EbtInterfaceBlock);
return getBasicMetalString(t);
}
ImmutableString GetMetalTypeName(const TType &type, ShHashFunction64 hashFunction, NameMap *nameMap)
{
if (type.getBasicType() == EbtStruct)
return HashName(type.getStruct(), hashFunction, nameMap);
else
return ImmutableString(getBuiltInMetalTypeNameString(&type));
}
} // namespace sh