summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorTheresa Foley <10618364+tangent-vector@users.noreply.github.com>2024-12-12 13:30:43 -0800
committerGitHub <noreply@github.com>2024-12-12 13:30:43 -0800
commit1fb79ac4f922c3f9c3ecf8f4533c12ec7bdeb37d (patch)
treef44c62a7e88dd7b44fa5b36a02345305a169e6f5 /include
parent9c82ed36946941eb1df3186f00903593aab556c3 (diff)
Add an example for using the reflection API (#5839)
* Add an example for using the reflection API The example program is meant to accompany a document that goes into more detail about the mental model behind the reflection API and the way this program drives it. Ideally this program can land before the document goes live, and then the document can be published with a link to the example. After that, the example could be updated to include links into the live document. Along with adding the example program, this change also adds some convenience functions to the reflection API to avoid cases where the program would otherwise need to cast between `slang::ParameterCategory` and `SlangParameterCategory`. * format code * fixup: error noticed by clang --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'include')
-rw-r--r--include/slang.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/include/slang.h b/include/slang.h
index 24db0a6ff..05fb78775 100644
--- a/include/slang.h
+++ b/include/slang.h
@@ -800,6 +800,8 @@ typedef uint32_t SlangSizeT;
SLANG_STAGE_CALLABLE,
SLANG_STAGE_MESH,
SLANG_STAGE_AMPLIFICATION,
+ //
+ SLANG_STAGE_COUNT,
// alias:
SLANG_STAGE_PIXEL = SLANG_STAGE_FRAGMENT,
@@ -2428,21 +2430,43 @@ struct TypeLayoutReflection
(SlangReflectionTypeLayout*)this);
}
- size_t getSize(SlangParameterCategory category = SLANG_PARAMETER_CATEGORY_UNIFORM)
+ size_t getSize(SlangParameterCategory category)
{
return spReflectionTypeLayout_GetSize((SlangReflectionTypeLayout*)this, category);
}
- size_t getStride(SlangParameterCategory category = SLANG_PARAMETER_CATEGORY_UNIFORM)
+ size_t getStride(SlangParameterCategory category)
{
return spReflectionTypeLayout_GetStride((SlangReflectionTypeLayout*)this, category);
}
- int32_t getAlignment(SlangParameterCategory category = SLANG_PARAMETER_CATEGORY_UNIFORM)
+ int32_t getAlignment(SlangParameterCategory category)
{
return spReflectionTypeLayout_getAlignment((SlangReflectionTypeLayout*)this, category);
}
+ size_t getSize(slang::ParameterCategory category = slang::ParameterCategory::Uniform)
+ {
+ return spReflectionTypeLayout_GetSize(
+ (SlangReflectionTypeLayout*)this,
+ (SlangParameterCategory)category);
+ }
+
+ size_t getStride(slang::ParameterCategory category = slang::ParameterCategory::Uniform)
+ {
+ return spReflectionTypeLayout_GetStride(
+ (SlangReflectionTypeLayout*)this,
+ (SlangParameterCategory)category);
+ }
+
+ int32_t getAlignment(slang::ParameterCategory category = slang::ParameterCategory::Uniform)
+ {
+ return spReflectionTypeLayout_getAlignment(
+ (SlangReflectionTypeLayout*)this,
+ (SlangParameterCategory)category);
+ }
+
+
unsigned int getFieldCount()
{
return spReflectionTypeLayout_GetFieldCount((SlangReflectionTypeLayout*)this);
@@ -2848,10 +2872,17 @@ struct VariableLayoutReflection
}
- size_t getOffset(SlangParameterCategory category = SLANG_PARAMETER_CATEGORY_UNIFORM)
+ size_t getOffset(SlangParameterCategory category)
{
return spReflectionVariableLayout_GetOffset((SlangReflectionVariableLayout*)this, category);
}
+ size_t getOffset(slang::ParameterCategory category = slang::ParameterCategory::Uniform)
+ {
+ return spReflectionVariableLayout_GetOffset(
+ (SlangReflectionVariableLayout*)this,
+ (SlangParameterCategory)category);
+ }
+
TypeReflection* getType() { return getVariable()->getType(); }
@@ -2869,6 +2900,12 @@ struct VariableLayoutReflection
{
return spReflectionVariableLayout_GetSpace((SlangReflectionVariableLayout*)this, category);
}
+ size_t getBindingSpace(slang::ParameterCategory category)
+ {
+ return spReflectionVariableLayout_GetSpace(
+ (SlangReflectionVariableLayout*)this,
+ (SlangParameterCategory)category);
+ }
char const* getSemanticName()
{