yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyMerge pull request #3 from tfoleyNV/rename-testsce90fec1c

master
943 B49 linesraw
1//TEST:SIMPLE:
2// test that `struct` decls work
3
4// Note(tfoley): disabled during syntax transition
5// #include "pipeline-simple.slang.h"
6
7// struct declaration
8struct Foo
9{
10	float3 a;
11	float3 b;
12};
13
14// function on a struct
15Foo makeFoo(float x, float y)
16{
17	// local of struct type
18	Foo foo;
19	foo.a = float3(x);
20	foo.b = float3(y);
21	return foo;
22}
23
24/* Note(tfoley): disabled during syntax transition
25
26template shader Test()
27//    targets StandardPipeline
28{
29	// Uniform of struct type
30	param Foo foo1;
31
32    @MeshVertex float3 position;
33    @MeshVertex float3 color;
34
35    param mat4 modelViewProjection;
36
37    public vec4 projCoord = modelViewProjection * vec4(position, 1.0);
38
39    // Component of struct type
40    // Note(tfoley): use of `public` here required to work around parser limitations
41    public Foo foo2 = makeFoo(color.x, color.y);
42
43    //
44    float3 result = foo1.a + foo2.b;
45
46    out @Fragment vec4 colorTarget = vec4(result,1);
47}
48
49*/