blob: 99509914e5db11e5b0123b0ad533bde6acf1db02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// slang-support.h
#pragma once
#include "render.h"
#include <slang.h>
#include "shader-input-layout.h"
#include "options.h"
namespace renderer_test {
struct ShaderCompilerUtil
{
struct Input
{
SlangCompileTarget target;
SlangSourceLanguage sourceLanguage;
SlangPassThrough passThrough;
PipelineType pipelineType = PipelineType::Unknown;
char const* profile;
const char** args;
int argCount;
};
struct Output
{
void set(PipelineType pipelineType, const ShaderProgram::KernelDesc* inKernelDescs, Slang::Index kernelDescCount)
{
kernelDescs.clear();
kernelDescs.addRange(inKernelDescs, kernelDescCount);
desc.pipelineType = pipelineType;
desc.kernels = kernelDescs.getBuffer();
desc.kernelCount = kernelDescCount;
}
void reset()
{
{
desc.pipelineType = PipelineType::Unknown;
desc.kernels = nullptr;
desc.kernelCount = 0;
}
kernelDescs.clear();
if (request && session)
{
spDestroyCompileRequest(request);
}
session = nullptr;
request = nullptr;
}
~Output()
{
if (request && session)
{
spDestroyCompileRequest(request);
}
}
Slang::Index findKernelDescIndex(gfx::StageType stage) const
{
for (Slang::Index i = 0; i < kernelDescs.getCount(); ++i)
{
if (kernelDescs[i].stage == stage)
{
return i;
}
}
return -1;
}
List<ShaderProgram::KernelDesc> kernelDescs;
ShaderProgram::Desc desc;
SlangCompileRequest* request = nullptr;
SlangSession* session = nullptr;
};
struct OutputAndLayout
{
Output output;
ShaderInputLayout layout;
Slang::String sourcePath;
};
static SlangResult compileWithLayout(SlangSession* session, const Options& options, const ShaderCompilerUtil::Input& input, OutputAndLayout& output);
static SlangResult readSource(const Slang::String& inSourcePath, List<char>& outSourceText);
static SlangResult compileProgram(SlangSession* session, const Input& input, const ShaderCompileRequest& request, Output& out);
};
} // renderer_test
|