yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
2.1 KiB65 linesraw
1#ifndef SLANG_FILE_SYSTEM_H
2#define SLANG_FILE_SYSTEM_H
3
4#include "../../core/slang-com-object.h"
5#include "record-manager.h"
6#include "slang-com-helper.h"
7#include "slang-com-ptr.h"
8
9namespace SlangRecord
10{
11
12using namespace Slang;
13
14// slang always requires ISlangFileSystemExt interface, even if user only provides ISlangFileSystem,
15// slang will still wrap it with ISlangFileSystemExt. So we have to record ISlangFileSystemExt, even
16// though we only need to record loadFile() function.
17class FileSystemRecorder : public RefObject, public ISlangFileSystemExt
18{
19public:
20    explicit FileSystemRecorder(ISlangFileSystemExt* fileSystem, RecordManager* recordManager);
21
22    // ISlangUnknown
23    SLANG_REF_OBJECT_IUNKNOWN_ALL
24
25    ISlangUnknown* getInterface(const Slang::Guid& guid);
26
27    // ISlangCastable
28    virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const Slang::Guid& guid) override;
29
30    // ISlangFileSystem
31    virtual SLANG_NO_THROW SlangResult SLANG_MCALL
32    loadFile(char const* path, ISlangBlob** outBlob) override;
33
34    // ISlangFileSystemExt
35    virtual SLANG_NO_THROW SlangResult SLANG_MCALL
36    getFileUniqueIdentity(const char* path, ISlangBlob** outUniqueIdentity) override;
37
38    virtual SLANG_NO_THROW SlangResult SLANG_MCALL calcCombinedPath(
39        SlangPathType fromPathType,
40        const char* fromPath,
41        const char* path,
42        ISlangBlob** pathOut) override;
43
44    virtual SLANG_NO_THROW SlangResult SLANG_MCALL
45    getPathType(const char* path, SlangPathType* pathTypeOut) override;
46
47    virtual SLANG_NO_THROW SlangResult SLANG_MCALL
48    getPath(PathKind kind, const char* path, ISlangBlob** outPath) override;
49
50    virtual SLANG_NO_THROW void SLANG_MCALL clearCache() override;
51
52    virtual SLANG_NO_THROW SlangResult SLANG_MCALL enumeratePathContents(
53        const char* path,
54        FileSystemContentsCallBack callback,
55        void* userData) override;
56
57    virtual SLANG_NO_THROW OSPathKind SLANG_MCALL getOSPathKind() override;
58
59private:
60    Slang::ComPtr<ISlangFileSystemExt> m_actualFileSystem;
61    RecordManager* m_recordManager = nullptr;
62};
63
64} // namespace SlangRecord
65#endif