|
5 | 5 | #include "slang-ir-util.h"
|
6 | 6 | #include "slang-ir-clone.h"
|
7 | 7 | #include "slang-ir-specialize-address-space.h"
|
| 8 | +#include "slang-parameter-binding.h" |
8 | 9 | #include "slang-ir-legalize-varying-params.h"
|
9 | 10 |
|
10 | 11 | namespace Slang
|
@@ -237,13 +238,15 @@ namespace Slang
|
237 | 238 | return builder.getVectorType(builder.getBasicType(BaseType::UInt), builder.getIntValue(builder.getIntType(), 3));
|
238 | 239 | }
|
239 | 240 |
|
240 |
| - MetalSystemValueInfo getSystemValueInfo(IRBuilder& builder, String semanticName, UInt attrIndex) |
| 241 | + MetalSystemValueInfo getSystemValueInfo(IRBuilder& builder, String inSemanticName) |
241 | 242 | {
|
242 |
| - SLANG_UNUSED(attrIndex); |
| 243 | + inSemanticName = inSemanticName.toLower(); |
243 | 244 |
|
244 |
| - MetalSystemValueInfo result = {}; |
| 245 | + UnownedStringSlice semanticName; |
| 246 | + UnownedStringSlice semanticIndex; |
| 247 | + splitNameAndIndex(inSemanticName.getUnownedSlice(), semanticName, semanticIndex); |
245 | 248 |
|
246 |
| - semanticName = semanticName.toLower(); |
| 249 | + MetalSystemValueInfo result = {}; |
247 | 250 |
|
248 | 251 | if (semanticName == "sv_position")
|
249 | 252 | {
|
@@ -374,9 +377,12 @@ namespace Slang
|
374 | 377 | result.requiredType = builder.getBasicType(BaseType::UInt);
|
375 | 378 | result.altRequiredType = builder.getBasicType(BaseType::UInt16);
|
376 | 379 | }
|
377 |
| - else if (semanticName == "sv_target") |
| 380 | + else if (semanticName.startsWith("sv_target")) |
378 | 381 | {
|
379 |
| - result.metalSystemValueName = (StringBuilder() << "color(" << String(attrIndex) << ")").produceString(); |
| 382 | + |
| 383 | + result.metalSystemValueName = (StringBuilder() << "color(" |
| 384 | + << (semanticIndex.getLength() != 0 ? semanticIndex : toSlice("0")) |
| 385 | + << ")").produceString(); |
380 | 386 | }
|
381 | 387 | else
|
382 | 388 | {
|
@@ -404,7 +410,7 @@ namespace Slang
|
404 | 410 | {
|
405 | 411 | if (semanticDecor->getSemanticName().startsWithCaseInsensitive(toSlice("sv_")))
|
406 | 412 | {
|
407 |
| - auto sysValInfo = getSystemValueInfo(builder, semanticDecor->getSemanticName(), semanticDecor->getSemanticIndex()); |
| 413 | + auto sysValInfo = getSystemValueInfo(builder, semanticDecor->getSemanticName()); |
408 | 414 | if (sysValInfo.isUnsupported || sysValInfo.isSpecial)
|
409 | 415 | {
|
410 | 416 | reportUnsupportedSystemAttribute(sink, field, semanticDecor->getSemanticName());
|
@@ -670,9 +676,8 @@ namespace Slang
|
670 | 676 |
|
671 | 677 | auto param = workItem.param;
|
672 | 678 | auto semanticName = workItem.attrName;
|
673 |
| - auto sysAttrIndex = workItem.attrIndex; |
674 | 679 |
|
675 |
| - auto info = getSystemValueInfo(builder, semanticName, sysAttrIndex); |
| 680 | + auto info = getSystemValueInfo(builder, semanticName); |
676 | 681 | if (info.isSpecial)
|
677 | 682 | {
|
678 | 683 | if (semanticName == "sv_innercoverage")
|
|
0 commit comments