yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jarcherNVFix API changes from separate debugging support (#7397)9c8fab83a

master
5.8 KiB182 linesraw
1#ifndef SLANG_ENTRY_POINT_H
2#define SLANG_ENTRY_POINT_H
3
4#include "../../core/slang-dictionary.h"
5#include "../../core/slang-smart-pointer.h"
6#include "../../slang/slang-compiler.h"
7#include "record-manager.h"
8#include "slang-com-helper.h"
9#include "slang-com-ptr.h"
10#include "slang-component-type.h"
11#include "slang.h"
12
13namespace SlangRecord
14{
15using namespace Slang;
16class SessionRecorder;
17
18class IEntryPointRecorder : public slang::IEntryPoint, public RefObject
19{
20public:
21    // SLANG_COM_INTERFACE(0xf4c1e23d, 0xb321, 0x4931, { 0x8f, 0x37, 0xf1, 0x22, 0x6a, 0xf9, 0x20,
22    // 0x85 }) SLANG_REF_OBJECT_IUNKNOWN_ALL ISlangUnknown* getInterface(const Guid& guid) {
23    // (void)guid; return nullptr;}
24    SLANG_COM_INTERFACE(
25        0xf4c1e23d,
26        0xb321,
27        0x4931,
28        {0x8f, 0x37, 0xf1, 0x22, 0x6a, 0xf9, 0x20, 0x85})
29};
30
31class EntryPointRecorder : public IEntryPointRecorder, public IComponentTypeRecorder
32{
33    typedef IComponentTypeRecorder Super;
34
35public:
36    SLANG_REF_OBJECT_IUNKNOWN_ALL
37    ISlangUnknown* getInterface(const Guid& guid);
38
39    explicit EntryPointRecorder(
40        SessionRecorder* sessionRecorder,
41        slang::IEntryPoint* entryPoint,
42        RecordManager* recordManager);
43
44    // Interfaces for `IComponentType`
45    virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override
46    {
47        return Super::getSession();
48    }
49
50    virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL
51    getLayout(SlangInt targetIndex = 0, slang::IBlob** outDiagnostics = nullptr) override
52    {
53        return Super::getLayout(targetIndex, outDiagnostics);
54    }
55
56    virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override
57    {
58        return Super::getSpecializationParamCount();
59    }
60
61    virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
62        SlangInt entryPointIndex,
63        SlangInt targetIndex,
64        slang::IBlob** outCode,
65        slang::IBlob** outDiagnostics = nullptr) override
66    {
67        return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
68    }
69
70    virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode(
71        SlangInt targetIndex,
72        slang::IBlob** outCode,
73        slang::IBlob** outDiagnostics = nullptr) override
74    {
75        return Super::getTargetCode(targetIndex, outCode, outDiagnostics);
76    }
77
78    SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata(
79        SlangInt entryPointIndex,
80        SlangInt targetIndex,
81        slang::IMetadata** outMetadata,
82        slang::IBlob** outDiagnostics) SLANG_OVERRIDE
83    {
84        return Super::getEntryPointMetadata(
85            entryPointIndex,
86            targetIndex,
87            outMetadata,
88            outDiagnostics);
89    }
90
91    SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata(
92        SlangInt targetIndex,
93        slang::IMetadata** outMetadata,
94        slang::IBlob** outDiagnostics) SLANG_OVERRIDE
95    {
96        return Super::getTargetMetadata(targetIndex, outMetadata, outDiagnostics);
97    }
98
99    virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
100        SlangInt entryPointIndex,
101        SlangInt targetIndex,
102        ISlangMutableFileSystem** outFileSystem) override
103    {
104        return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
105    }
106
107    virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
108        SlangInt entryPointIndex,
109        SlangInt targetIndex,
110        slang::IBlob** outHash) override
111    {
112        return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash);
113    }
114
115    virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
116        slang::SpecializationArg const* specializationArgs,
117        SlangInt specializationArgCount,
118        slang::IComponentType** outSpecializedComponentType,
119        ISlangBlob** outDiagnostics = nullptr) override
120    {
121        return Super::specialize(
122            specializationArgs,
123            specializationArgCount,
124            outSpecializedComponentType,
125            outDiagnostics);
126    }
127
128    virtual SLANG_NO_THROW SlangResult SLANG_MCALL link(
129        slang::IComponentType** outLinkedComponentType,
130        ISlangBlob** outDiagnostics = nullptr) override
131    {
132        return Super::link(outLinkedComponentType, outDiagnostics);
133    }
134
135    virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
136        int entryPointIndex,
137        int targetIndex,
138        ISlangSharedLibrary** outSharedLibrary,
139        slang::IBlob** outDiagnostics = 0) override
140    {
141        return Super::getEntryPointHostCallable(
142            entryPointIndex,
143            targetIndex,
144            outSharedLibrary,
145            outDiagnostics);
146    }
147
148    virtual SLANG_NO_THROW SlangResult SLANG_MCALL
149    renameEntryPoint(const char* newName, IComponentType** outEntryPoint) override
150    {
151        return Super::renameEntryPoint(newName, outEntryPoint);
152    }
153
154    virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
155        IComponentType** outLinkedComponentType,
156        uint32_t compilerOptionEntryCount,
157        slang::CompilerOptionEntry* compilerOptionEntries,
158        ISlangBlob** outDiagnostics = nullptr) override
159    {
160        return Super::linkWithOptions(
161            outLinkedComponentType,
162            compilerOptionEntryCount,
163            compilerOptionEntries,
164            outDiagnostics);
165    }
166
167    // Interfaces for `IEntryPoint`
168    virtual SLANG_NO_THROW slang::FunctionReflection* SLANG_MCALL getFunctionReflection() override;
169
170    slang::IEntryPoint* getActualEntryPoint() const { return m_actualEntryPoint; }
171
172protected:
173    virtual ApiClassId getClassId() override { return ApiClassId::Class_IEntryPoint; }
174
175    virtual SessionRecorder* getSessionRecorder() override { return m_sessionRecorder; }
176
177private:
178    SessionRecorder* m_sessionRecorder;
179    Slang::ComPtr<slang::IEntryPoint> m_actualEntryPoint;
180};
181} // namespace SlangRecord
182#endif // SLANG_ENTRY_POINT_H