yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
2.0 KiB61 linesraw
1#ifndef SLANG_SOURCE_EMBED_UTIL_H
2#define SLANG_SOURCE_EMBED_UTIL_H
3
4#include "../core/slang-basic.h"
5#include "../core/slang-name-value.h"
6#include "slang-artifact.h"
7#include "slang-com-ptr.h"
8#include "slang-diagnostic-sink.h"
9
10namespace Slang
11{
12
13
14struct SourceEmbedUtil
15{
16    enum class Style : uint32_t
17    {
18        None,    ///< No embedding
19        Default, ///< Default embedding for the type
20        Text, ///< Embed as text. May change line endings. If output isn't text will use 'default'.
21              ///< Size will *not* contain terminating 0
22        BinaryText, ///< Embed as text assuming contents is binary.
23        U8,         ///< Embed as unsigned bytes
24        U16,        ///< Embed as uint16_t
25        U32,        ///< Embed as uint32_t
26        U64,        ///< Embed as uint64_t
27        CountOf,
28    };
29
30    struct Options
31    {
32        Style style = Style::Default; ///< Style of embedding
33        Count lineLength = 120; ///< The line length, lines can be larger for some styles, but will
34                                ///< aim to keep within range
35        SlangSourceLanguage language = SLANG_SOURCE_LANGUAGE_C; ///< The language to output for
36        String variableName;                                    ///< The name to give the variable
37        String indent = "    ";                                 ///< Indenting
38    };
39
40    /// Get the style infos
41    static ConstArrayView<NamesDescriptionValue> getStyleInfos();
42
43    /// Given an artifact and
44    static SlangResult createEmbedded(
45        IArtifact* artifact,
46        const Options& options,
47        ComPtr<IArtifact>& outArtifact);
48
49    /// Returns the default style for the desc
50    static Style getDefaultStyle(const ArtifactDesc& desc);
51
52    /// Returns true if supports the specified language for embedding
53    static bool isSupported(SlangSourceLanguage lang);
54
55    /// Given the path return the output path. If no path is available return the empty string
56    static String getPath(const String& path, const Options& options);
57};
58
59} // namespace Slang
60
61#endif