1#!amber
2# Copyright 2020 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https:#www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16SET ENGINE_DATA fence_timeout_ms 1000000
17
18VIRTUAL_FILE "vs.hlsl"
19struct VS_OUTPUT {
20  float4 pos : SV_POSITION;
21  float4 color : COLOR;
22};
23
24VS_OUTPUT main(float4 pos : POSITION,
25               float4 color : COLOR) {
26  VS_OUTPUT vout;
27  vout.pos = pos;
28  vout.color = color;
29  return vout;
30}
31END
32
33VIRTUAL_FILE "fs.hlsl"
34float4 main(float4 color : COLOR) : SV_TARGET {
35  return color;
36}
37END
38
39SHADER vertex   vtex_shader HLSL VIRTUAL_FILE "vs.hlsl"
40SHADER fragment frag_shader HLSL VIRTUAL_FILE "fs.hlsl"
41
42BUFFER position_buf DATA_TYPE R8G8_SNORM DATA
43# Full frame
44-128 -128
45 127  127
46-128  127
47-128 -128
48 127  127
49 127 -128
50END
51
52BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA
53255   0   0 255
54255   0   0 255
55255   0   0 255
56255   0   0 255
57255   0   0 255
58255   0   0 255
59
60  0 255   0 255
61  0 255   0 255
62  0 255   0 255
63  0 255   0 255
64  0 255   0 255
65  0 255   0 255
66
67  0   0 255 255
68  0   0 255 255
69  0   0 255 255
70  0   0 255 255
71  0   0 255 255
72  0   0 255 255
73
74127 127 127 255
75127 127 127 255
76127 127 127 255
77127 127 127 255
78127 127 127 255
79127 127 127 255
80END
81
82BUFFER framebuffer FORMAT B8G8R8A8_UNORM
83
84PIPELINE graphics pipeline
85  FRAMEBUFFER_SIZE 32 32
86
87  ATTACH vtex_shader
88  SHADER_OPTIMIZATION vtex_shader
89    --inline-entry-points-exhaustive
90    --eliminate-dead-functions
91  END
92
93  ATTACH frag_shader
94  SHADER_OPTIMIZATION frag_shader
95    --inline-entry-points-exhaustive
96    --eliminate-dead-functions
97  END
98
99  VERTEX_DATA position_buf LOCATION 0
100  VERTEX_DATA vert_color LOCATION 1
101
102  BIND BUFFER framebuffer AS color LOCATION 0
103END
104
105CLEAR pipeline
106
107DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6
108    THREAD VERTEX_INDEX 0
109        EXPECT LOCATION "vs.hlsl" 9 "  vout.pos = pos;"
110        EXPECT LOCAL "pos.x" EQ -1.000000
111        EXPECT LOCAL "pos.y" EQ -1.000000
112        EXPECT LOCAL "pos.z" EQ 0.000000
113        EXPECT LOCAL "color.x" EQ 1.000000
114        EXPECT LOCAL "color.y" EQ 0.000000
115        EXPECT LOCAL "color.z" EQ 0.000000
116        STEP_IN
117        EXPECT LOCAL "vout.pos.x" EQ -1.000000
118        EXPECT LOCAL "vout.pos.y" EQ -1.000000
119        EXPECT LOCAL "vout.pos.z" EQ 0.000000
120        EXPECT LOCATION "vs.hlsl" 10 "  vout.color = color;"
121        STEP_IN
122        EXPECT LOCAL "vout.color.x" EQ 1.000000
123        EXPECT LOCAL "vout.color.y" EQ 0.000000
124        EXPECT LOCAL "vout.color.z" EQ 0.000000
125        EXPECT LOCATION "vs.hlsl" 11 "  return vout;"
126        CONTINUE
127    END
128END
129
130EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGB 255 0 0
131