MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / translateDeclaration

Method translateDeclaration

src/HLSLCompiler.cpp:1289–1374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1287 }
1288
1289 void HLSLCompiler::translateDeclaration(M4::HLSLDeclaration* declr)
1290 {
1291 bool isReadTextureType = M4::IsReadTextureType(declr->type);
1292
1293 // local
1294 if (m_curFuncData != nullptr) {
1295 HLSLCompiler::ExpressionType lType = m_convertType(declr->type);
1296
1297 m_locals[m_currentFunction].push_back(declr->name);
1298 m_localTypes[m_currentFunction][std::string(declr->name)] = lType.Name;
1299
1300 if (declr->type.array) {
1301 translateExpression(declr->type.arraySize);
1302 u8 dim = 0;
1303 M4::HLSLExpression* expr = declr->type.arraySize;
1304 while (expr != nullptr) {
1305 expr = expr->nextExpression;
1306 dim++;
1307 }
1308 m_gen.Function.NewArray(dim);
1309 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
1310 }
1311 else if (declr->assignment) {
1312 translateExpression(declr->assignment);
1313
1314 HLSLCompiler::ExpressionType rType = m_convertType(declr->assignment->expressionType);
1315 if (lType != rType)
1316 m_generateConvert(lType);
1317
1318 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
1319 }
1320 else if (m_isTypeActuallyStruct(lType)) {
1321 m_gen.Function.NewObjectByName(lType.Name);
1322 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
1323 }
1324 else {
1325 m_gen.Function.PushStack(0);
1326 m_generateConvert(lType);
1327 m_gen.Function.SetLocal(m_locals[m_currentFunction].size() - 1);
1328 }
1329 }
1330 // global
1331 else {
1332 const M4::HLSLType type = declr->type;
1333
1334 m_globals.push_back(Variable());
1335
1336 Variable& var = m_globals[m_globals.size() - 1];
1337 var.InputSlot = declr->registerName ? std::stoi(declr->registerName + 1) : 0;
1338 var.IsArray = type.array;
1339 var.Smooth = true;
1340 var.Flat = false;
1341 var.NoPerspective = false;
1342 var.Storage = Variable::StorageType::Constant;
1343 var.Name = declr->name;
1344
1345 // Interpolation modifiers.
1346 if (type.flags & M4::HLSLTypeFlag_Centroid) { }

Callers

nothing calls this directly

Calls 4

VariableClass · 0.85
IsBasicTextureFunction · 0.85
sizeMethod · 0.80
AddGlobalMethod · 0.80

Tested by

no test coverage detected