summaryrefslogtreecommitdiff
path: root/source/slang/core.meta.slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/core.meta.slang')
-rw-r--r--source/slang/core.meta.slang28
1 files changed, 16 insertions, 12 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index b395bd08b..d54eea94d 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -1,5 +1,9 @@
// Slang `core` library
+// Modifier for variables that must resolve to compile-time constants
+// as part of translation.
+syntax constexpr : ConstExprModifier;
+
// A type that can be used as an operand for builtins
interface __BuiltinType {}
@@ -623,7 +627,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
{
sb << ", int sampleIndex";
}
- sb << ", int" << loadCoordCount << " offset";
+ sb << ", constexpr int" << loadCoordCount << " offset";
sb << ");\n";
@@ -633,7 +637,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
{
sb << ", int sampleIndex";
}
- sb << ", int" << kBaseTextureTypes[tt].coordCount << " offset";
+ sb << ", constexpr int" << kBaseTextureTypes[tt].coordCount << " offset";
sb << ", out uint status";
sb << ");\n";
}
@@ -699,14 +703,14 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "__target_intrinsic(glsl, \"textureOffset($$p, $2, $3)\")\n";
sb << "T Sample(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
}
sb << "T Sample(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
if( baseShape != TextureType::ShapeCube )
{
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset, ";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset, ";
}
sb << "float clamp);\n";
@@ -714,7 +718,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
if( baseShape != TextureType::ShapeCube )
{
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset, ";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset, ";
}
sb << "float clamp, out uint status);\n";
@@ -729,7 +733,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "__target_intrinsic(glsl, \"textureOffset($$p, $2, $3, $4)\")\n";
sb << "T SampleBias(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, float bias, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
}
// `SampleCmp()` and `SampleCmpLevelZero`
@@ -796,12 +800,12 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "T SampleCmp(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
sb << "float compareValue, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
sb << "T SampleCmpLevelZero(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
sb << "float compareValue, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
}
@@ -821,7 +825,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
sb << "float" << kBaseTextureTypes[tt].coordCount << " gradX, ";
sb << "float" << kBaseTextureTypes[tt].coordCount << " gradY, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
}
// `SampleLevel`
@@ -837,7 +841,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "T SampleLevel(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
sb << "float level, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
}
}
@@ -908,12 +912,12 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
sb << "__target_intrinsic(glsl, \"textureGatherOffset($$p, $2, $3, " << componentIndex << ")\")\n";
sb << "vector<T, 4> Gather" << componentName << "(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount << " location, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
EMIT_LINE_DIRECTIVE();
sb << "vector<T, 4> Gather" << componentName << "(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount << " location, ";
- sb << "int" << kBaseTextureTypes[tt].coordCount << " offset, ";
+ sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset, ";
sb << "out uint status);\n";
EMIT_LINE_DIRECTIVE();