summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-06-04 13:05:58 -0700
committerGitHub <noreply@github.com>2025-06-04 13:05:58 -0700
commit812e478989e27983b8dea7ab11964de751654ba2 (patch)
treee6db6def9c7896ee48c5fe42926856644e81c0e6 /include
parentb9dc21d362f65f22bc707bede733a9537b80460a (diff)
Make interface types non c-style in Slang2026. (#7260)
* Make interface types non c-style. * Make Optional<T> work with autodiff and existential types. * Fix. * patch behind slang 2026. * Fix warnings. * cleanup. * Fix tests. * Fix. * Fix com interface lowering. * Add comment to test. * regenerate command line reference * Add test for passing `none` to autodiff function. * Fix recording of `getDynamicObjectRTTIBytes`. * Fix nested Optional types. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'include')
-rw-r--r--include/slang.h45
1 files changed, 39 insertions, 6 deletions
diff --git a/include/slang.h b/include/slang.h
index dc52e80b3..11538bcac 100644
--- a/include/slang.h
+++ b/include/slang.h
@@ -906,7 +906,6 @@ typedef uint32_t SlangSizeT;
DisableSourceMap, // bool
UnscopedEnum, // bool
PreserveParameters, // bool: preserve all resource parameters in the output code.
-
// Target
Capability, // intValue0: CapabilityName
@@ -998,8 +997,13 @@ typedef uint32_t SlangSizeT;
TrackLiveness,
LoopInversion, // bool, enable loop inversion optimization
- // Deprecated
- ParameterBlocksUseRegisterSpaces,
+ ParameterBlocksUseRegisterSpaces, // Deprecated
+ LanguageVersion, // intValue0: SlangLanguageVersion
+ TypeConformance, // stringValue0: additional type conformance to link, in the format of
+ // "<TypeName>:<IInterfaceName>[=<sequentialId>]", for example
+ // "Impl:IFoo=3" or "Impl:IFoo".
+ EnableExperimentalDynamicDispatch, // bool, experimental
+ EmitReflectionJSON, // bool
CountOfParsableOptions,
@@ -1016,14 +1020,11 @@ typedef uint32_t SlangSizeT;
// Setting of EmitSpirvDirectly or EmitSpirvViaGLSL will turn into this option internally.
EmitSpirvMethod, // enum SlangEmitSpirvMethod
- EmitReflectionJSON, // bool
SaveGLSLModuleBinSource,
SkipDownstreamLinking, // bool, experimental
DumpModule,
- EnableExperimentalDynamicDispatch, // bool, experimental
- LanguageVersion, // intValue0: SlangLanguageVersion
CountOf,
};
@@ -4052,6 +4053,7 @@ struct ISession : public ISlangUnknown
ISlangBlob** outNameBlob) = 0;
/** Get the sequential ID used to identify a type witness in a dynamic object.
+ The sequential ID is part of the RTTI bytes returned by `getDynamicObjectRTTIBytes`.
*/
virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTypeConformanceWitnessSequentialID(
slang::TypeReflection* type,
@@ -4113,6 +4115,37 @@ struct ISession : public ISlangUnknown
const char* path,
const char* string,
slang::IBlob** outDiagnostics = nullptr) = 0;
+
+
+ /** Get the 16-byte RTTI header to fill into a dynamic object.
+ This header is used to identify the type of the object for dynamic dispatch purpose.
+ For example, given the following shader:
+
+ ```slang
+ [anyValueSize(32)] dyn interface IFoo { int eval(); }
+ struct Impl : IFoo { int eval() { return 1; } }
+
+ ConstantBuffer<dyn IFoo> cb0;
+
+ [numthreads(1,1,1)
+ void main()
+ {
+ cb0.eval();
+ }
+ ```
+
+ The constant buffer `cb0` should be filled with 16+32=48 bytes of data, where the first
+ 16 bytes should be the RTTI bytes returned by calling `getDynamicObjectRTTIBytes(type_Impl,
+ type_IFoo)`, and the rest 32 bytes should hold the actual data of the dynamic object (in
+ this case, fields in the `Impl` type).
+
+ `bufferSizeInBytes` must be greater than 16.
+ */
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL getDynamicObjectRTTIBytes(
+ slang::TypeReflection* type,
+ slang::TypeReflection* interfaceType,
+ uint32_t* outRTTIDataBuffer,
+ uint32_t bufferSizeInBytes) = 0;
};
#define SLANG_UUID_ISession ISession::getTypeGuid()