blob: e94d957198ab00d41607a5077ffc4982f2d58af9 (
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
|
//TEST:SIMPLE(filecheck=CHECK): -target spirv
// CHECK: OpEntryPoint
__generic <Scalar : __BuiltinFloatingPointType, int Mode>
struct Spectrum
{
static const int Samples = Mode & 0xFF;
typealias VecT = vector<Scalar, Samples>;
VecT data;
static const bool IsRGB = (Mode & 0x100) != 0;
__generic <Float : __BuiltinFloatingPointType>
__init(vector<Float, Samples> v)
{
this.data = VecT(v);
}
static This MakeFromRGB<Float : __BuiltinFloatingPointType>(vector<Float, 3> rgb)
{
if(IsRGB)
{
return (Spectrum<Scalar, 0x103>(rgb) as This).value;
}
else
{
return {};
}
}
}
static const int DefaultMode = 0x103;
typealias Spec = Spectrum<float, DefaultMode>;
[shader("vertex")]
Spec main(float3 vertex_color : COLOR0) : COLOR0
{
return Spec::MakeFromRGB(vertex_color);
}
|