summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/slang-reflection-json.cpp18
-rw-r--r--tests/reflection/attribute.slang2
-rw-r--r--tests/reflection/attribute.slang.expected10
3 files changed, 29 insertions, 1 deletions
diff --git a/source/slang/slang-reflection-json.cpp b/source/slang/slang-reflection-json.cpp
index be6539246..993832ad6 100644
--- a/source/slang/slang-reflection-json.cpp
+++ b/source/slang/slang-reflection-json.cpp
@@ -328,6 +328,22 @@ static void emitUserAttributes(PrettyWriter& writer, slang::VariableReflection*
writer << "]";
}
}
+static void emitUserAttributes(PrettyWriter& writer, slang::FunctionReflection* func)
+{
+ auto attribCount = func->getUserAttributeCount();
+ if (attribCount)
+ {
+ writer << ",\n\"userAttribs\": [";
+ for (unsigned int i = 0; i < attribCount; i++)
+ {
+ if (i > 0)
+ writer << ",\n";
+ auto attrib = func->getUserAttributeByIndex(i);
+ emitUserAttributeJSON(writer, attrib);
+ }
+ writer << "]";
+ }
+}
static void emitReflectionVarLayoutJSON(PrettyWriter& writer, slang::VariableLayoutReflection* var)
{
@@ -1091,6 +1107,8 @@ static void emitReflectionEntryPointJSON(
writer << "\n]";
}
+ emitUserAttributes(writer, entryPoint->getFunction());
+
writer.dedent();
writer << "\n}";
}
diff --git a/tests/reflection/attribute.slang b/tests/reflection/attribute.slang
index e0739643c..0157f67d0 100644
--- a/tests/reflection/attribute.slang
+++ b/tests/reflection/attribute.slang
@@ -5,6 +5,7 @@
//TEST:REFLECTION:-stage compute -entry main -target hlsl -no-codegen
[__AttributeUsage(_AttributeTargets.Struct)]
+[__AttributeUsage(_AttributeTargets.Function)]
struct MyStructAttribute
{
int iParam;
@@ -58,6 +59,7 @@ D param3;
[StructVarParam(1)] int globalInt2;
+[MyStruct(2, 3.0)]
[numthreads(1, 1, 1)]
void main(
uint3 dispatchThreadID : SV_DispatchThreadID,
diff --git a/tests/reflection/attribute.slang.expected b/tests/reflection/attribute.slang.expected
index ee48b466c..978d43d43 100644
--- a/tests/reflection/attribute.slang.expected
+++ b/tests/reflection/attribute.slang.expected
@@ -310,7 +310,15 @@ standard output = {
}
}
],
- "threadGroupSize": [1, 1, 1]
+ "threadGroupSize": [1, 1, 1],
+ "userAttribs": [{
+ "name": "MyStruct",
+ "arguments": [
+ 2,
+ 3.000000
+ ]
+ }
+ ]
}
]
}