summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-metal-legalize.cpp23
-rw-r--r--source/slang/slang-parameter-binding.cpp4
-rw-r--r--source/slang/slang-parameter-binding.h8
3 files changed, 23 insertions, 12 deletions
diff --git a/source/slang/slang-ir-metal-legalize.cpp b/source/slang/slang-ir-metal-legalize.cpp
index f771f7a33..01bcb0295 100644
--- a/source/slang/slang-ir-metal-legalize.cpp
+++ b/source/slang/slang-ir-metal-legalize.cpp
@@ -5,6 +5,7 @@
#include "slang-ir-util.h"
#include "slang-ir-clone.h"
#include "slang-ir-specialize-address-space.h"
+#include "slang-parameter-binding.h"
#include "slang-ir-legalize-varying-params.h"
namespace Slang
@@ -237,13 +238,15 @@ namespace Slang
return builder.getVectorType(builder.getBasicType(BaseType::UInt), builder.getIntValue(builder.getIntType(), 3));
}
- MetalSystemValueInfo getSystemValueInfo(IRBuilder& builder, String semanticName, UInt attrIndex)
+ MetalSystemValueInfo getSystemValueInfo(IRBuilder& builder, String inSemanticName)
{
- SLANG_UNUSED(attrIndex);
+ inSemanticName = inSemanticName.toLower();
- MetalSystemValueInfo result = {};
+ UnownedStringSlice semanticName;
+ UnownedStringSlice semanticIndex;
+ splitNameAndIndex(inSemanticName.getUnownedSlice(), semanticName, semanticIndex);
- semanticName = semanticName.toLower();
+ MetalSystemValueInfo result = {};
if (semanticName == "sv_position")
{
@@ -374,9 +377,12 @@ namespace Slang
result.requiredType = builder.getBasicType(BaseType::UInt);
result.altRequiredType = builder.getBasicType(BaseType::UInt16);
}
- else if (semanticName == "sv_target")
+ else if (semanticName.startsWith("sv_target"))
{
- result.metalSystemValueName = (StringBuilder() << "color(" << String(attrIndex) << ")").produceString();
+
+ result.metalSystemValueName = (StringBuilder() << "color("
+ << (semanticIndex.getLength() != 0 ? semanticIndex : toSlice("0"))
+ << ")").produceString();
}
else
{
@@ -404,7 +410,7 @@ namespace Slang
{
if (semanticDecor->getSemanticName().startsWithCaseInsensitive(toSlice("sv_")))
{
- auto sysValInfo = getSystemValueInfo(builder, semanticDecor->getSemanticName(), semanticDecor->getSemanticIndex());
+ auto sysValInfo = getSystemValueInfo(builder, semanticDecor->getSemanticName());
if (sysValInfo.isUnsupported || sysValInfo.isSpecial)
{
reportUnsupportedSystemAttribute(sink, field, semanticDecor->getSemanticName());
@@ -670,9 +676,8 @@ namespace Slang
auto param = workItem.param;
auto semanticName = workItem.attrName;
- auto sysAttrIndex = workItem.attrIndex;
- auto info = getSystemValueInfo(builder, semanticName, sysAttrIndex);
+ auto info = getSystemValueInfo(builder, semanticName);
if (info.isSpecial)
{
if (semanticName == "sv_innercoverage")
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index ca0de9802..d76dda4e1 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -480,9 +480,7 @@ static bool isDigit(char c)
return (c >= '0') && (c <= '9');
}
-/// Given a string that specifies a name and index (e.g., `COLOR0`),
-/// split it into slices for the name part and the index part.
-static void splitNameAndIndex(
+void splitNameAndIndex(
UnownedStringSlice const& text,
UnownedStringSlice& outName,
UnownedStringSlice& outDigits)
diff --git a/source/slang/slang-parameter-binding.h b/source/slang/slang-parameter-binding.h
index 139064680..3c0949e37 100644
--- a/source/slang/slang-parameter-binding.h
+++ b/source/slang/slang-parameter-binding.h
@@ -29,6 +29,14 @@ void generateParameterBindings(
TargetRequest* targetReq,
DiagnosticSink* sink);
+/// Given a string that specifies a name and index (e.g., `COLOR0`),
+/// split it into slices for the name part and the index part.
+///
+void splitNameAndIndex(
+ UnownedStringSlice const& text,
+ UnownedStringSlice& outName,
+ UnownedStringSlice& outDigits);
+
}
#endif