diff options
| author | Yong He <yonghe@outlook.com> | 2021-08-26 10:30:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-26 10:30:35 -0700 |
| commit | b2ad8e99a82884bb157e1be76b1ad7eb0e481457 (patch) | |
| tree | 3f5357083b5972761d516b70cb51a4fa7ab72cd5 /slang.h | |
| parent | 33f7e1599cbecb32c23787b37b2bf3b34bdd5c84 (diff) | |
Add API to control interface specialization. (#1925)
Diffstat (limited to 'slang.h')
| -rw-r--r-- | slang.h | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -3050,6 +3050,7 @@ namespace slang typedef ISlangBlob IBlob; struct IComponentType; + struct ITypeConformance; struct IGlobalSession; struct IModule; struct ISession; @@ -4023,6 +4024,32 @@ namespace slang */ virtual SLANG_NO_THROW SlangResult SLANG_MCALL createCompileRequest( SlangCompileRequest** outCompileRequest) = 0; + + + /** Creates a `IComponentType` that represents a type's conformance to an interface. + The retrieved `ITypeConformance` objects can be included in a composite `IComponentType` + to explicitly specify which implementation types should be included in the final compiled + code. For example, if an module defines `IMaterial` interface and `AMaterial`, + `BMaterial`, `CMaterial` types that implements the interface, the user can exclude + `CMaterial` implementation from the resulting shader code by explcitly adding + `AMaterial:IMaterial` and `BMaterial:IMaterial` conformances to a composite + `IComponentType` and get entry point code from it. The resulting code will not have + anything related to `CMaterial` in the dynamic dispatch logic. If the user does not + explicitly include any `TypeConformances` to an interface type, all implementations to + that interface will be included by default. By linking a `ITypeConformance`, the user is + also given the opportunity to specify the dispatch ID of the implementation type. If + `conformanceIdOverride` is -1, there will be no override behavior and Slang will + automatically assign IDs to implementation types. The automatically assigned IDs can be + queried via `ISession::getTypeConformanceWitnessSequentialID`. + + Returns SLANG_OK if succeeds, or SLANG_FAIL if `type` does not conform to `interfaceType`. + */ + virtual SLANG_NO_THROW SlangResult SLANG_MCALL createTypeConformanceComponentType( + slang::TypeReflection* type, + slang::TypeReflection* interfaceType, + ITypeConformance** outConformance, + SlangInt conformanceIdOverride, + ISlangBlob** outDiagnostics) = 0; }; #define SLANG_UUID_ISession ISession::getTypeGuid() @@ -4204,6 +4231,12 @@ namespace slang #define SLANG_UUID_IEntryPoint IEntryPoint::getTypeGuid() + struct ITypeConformance : public IComponentType + { + SLANG_COM_INTERFACE(0x73eb3147, 0xe544, 0x41b5, { 0xb8, 0xf0, 0xa2, 0x44, 0xdf, 0x21, 0x94, 0xb }) + }; + #define SLANG_UUID_ITypeConformance ITypeConformance::getTypeGuid() + /** A module is the granularity of shader code compilation and loading. In most cases a module corresponds to a single compile "translation unit." |
