[WHLSL] Pointers should have automatically-generated equality checks
[WebKit-https.git] / Tools / WebGPUShadingLanguageRI / SPIRV.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style>
5 td {
6     border: solid black 1px;
7 }
8 </style>
9     <!-- FIXME: Migrate to ES6 modules -->
10     <script src="Node.js"></script>
11     <script src="Type.js"></script>
12     <script src="ReferenceType.js"></script>
13     <script src="Value.js"></script>
14     <script src="Expression.js"></script>
15     <script src="Rewriter.js"></script>
16     <script src="Visitor.js"></script>
17     <script src="CreateLiteral.js"></script>
18     <script src="CreateLiteralType.js"></script>
19     <script src="PropertyAccessExpression.js"></script>
20     <script src="NativeType.js"></script>
21     <script src="Semantic.js"></script>
22
23     <script src="AddressSpace.js"></script>
24     <script src="AllocateAtEntryPoints.js"></script>
25     <script src="AnonymousVariable.js"></script>
26     <script src="ArrayRefType.js"></script>
27     <script src="ArrayType.js"></script>
28     <script src="Assignment.js"></script>
29     <script src="AutoWrapper.js"></script>
30     <script src="Block.js"></script>
31     <script src="BoolLiteral.js"></script>
32     <script src="Break.js"></script>
33     <script src="BuiltInSemantic.js"></script>
34     <script src="BuiltinMatrixGetter.js"></script>
35     <script src="BuiltinMatrixSetter.js"></script>
36     <script src="BuiltinVectorGetter.js"></script>
37     <script src="BuiltinVectorSetter.js"></script>
38     <script src="CallExpression.js"></script>
39     <script src="CallFunction.js"></script>
40     <script src="Casts.js"></script>
41     <script src="Check.js"></script>
42     <script src="CheckLiteralTypes.js"></script>
43     <script src="CheckLoops.js"></script>
44     <script src="CheckNativeFuncStages.js"></script>
45     <script src="CheckRecursion.js"></script>
46     <script src="CheckRecursiveTypes.js"></script>
47     <script src="CheckReturns.js"></script>
48     <script src="CheckTypesWithArguments.js"></script>
49     <script src="CheckUnreachableCode.js"></script>
50     <script src="CheckWrapped.js"></script>
51     <script src="Checker.js"></script>
52     <script src="CloneProgram.js"></script>
53     <script src="CommaExpression.js"></script>
54     <script src="ConstexprFolder.js"></script>
55     <script src="Continue.js"></script>
56     <script src="ConvertPtrToArrayRefExpression.js"></script>
57     <script src="DoWhileLoop.js"></script>
58     <script src="DotExpression.js"></script>
59     <script src="DereferenceExpression.js"></script>
60     <script src="EArrayRef.js"></script>
61     <script src="EBuffer.js"></script>
62     <script src="EBufferBuilder.js"></script>
63     <script src="EPtr.js"></script>
64     <script src="EnumLiteral.js"></script>
65     <script src="EnumMember.js"></script>
66     <script src="EnumType.js"></script>
67     <script src="EvaluationCommon.js"></script>
68     <script src="Evaluator.js"></script>
69     <script src="ExpressionFinder.js"></script>
70     <script src="ExternalOrigin.js"></script>
71     <script src="Field.js"></script>
72     <script src="FindHighZombies.js"></script>
73     <script src="FlattenedStructOffsetGatherer.js"></script>
74     <script src="FloatLiteral.js"></script>
75     <script src="FloatLiteralType.js"></script>
76     <script src="FoldConstexprs.js"></script>
77     <script src="ForLoop.js"></script>
78     <script src="Func.js"></script>
79     <script src="FuncAttribute.js"></script>
80     <script src="FuncDef.js"></script>
81     <script src="FuncNumThreadsAttribute.js"></script>
82     <script src="FuncParameter.js"></script>
83     <script src="FunctionLikeBlock.js"></script>
84     <script src="HighZombieFinder.js"></script>
85     <script src="IdentityExpression.js"></script>
86     <script src="IfStatement.js"></script>
87     <script src="IndexExpression.js"></script>
88     <script src="InferTypesForCall.js"></script>
89     <script src="Inline.js"></script>
90     <script src="Inliner.js"></script>
91     <script src="IntLiteral.js"></script>
92     <script src="IntLiteralType.js"></script>
93     <script src="Intrinsics.js"></script>
94     <script src="LayoutBuffers.js"></script>
95     <script src="Lexer.js"></script>
96     <script src="LexerToken.js"></script>
97     <script src="LiteralTypeChecker.js"></script>
98     <script src="LogicalExpression.js"></script>
99     <script src="LogicalNot.js"></script>
100     <script src="LoopChecker.js"></script>
101     <script src="MakeArrayRefExpression.js"></script>
102     <script src="MakePtrExpression.js"></script>
103     <script src="MatrixType.js"></script>
104     <script src="NameContext.js"></script>
105     <script src="NameFinder.js"></script>
106     <script src="NameResolver.js"></script>
107     <script src="NativeFunc.js"></script>
108     <script src="NormalUsePropertyResolver.js"></script>
109     <script src="NullLiteral.js"></script>
110     <script src="NullType.js"></script>
111     <script src="OperatorAnderIndexer.js"></script>
112     <script src="OperatorArrayRefLength.js"></script>
113     <script src="OriginKind.js"></script>
114     <script src="OverloadResolutionFailure.js"></script>
115     <script src="Parse.js"></script>
116     <script src="Prepare.js"></script>
117     <script src="PropertyResolver.js"></script>
118     <script src="Program.js"></script>
119     <script src="ProgramWithUnnecessaryThingsRemoved.js"></script>
120     <script src="PtrType.js"></script>
121     <script src="ReadModifyWriteExpression.js"></script>
122     <script src="RecursionChecker.js"></script>
123     <script src="RecursiveTypeChecker.js"></script>
124     <script src="ResolveNames.js"></script>
125     <script src="ResolveOverloadImpl.js"></script>
126     <script src="ResolveProperties.js"></script>
127     <script src="ResolveTypeDefs.js"></script>
128     <script src="ResourceSemantic.js"></script>
129     <script src="Return.js"></script>
130     <script src="ReturnChecker.js"></script>
131     <script src="ReturnException.js"></script>
132     <script src="Sampler.js"></script>
133     <script src="SpecializationConstantSemantic.js"></script>
134     <script src="StageInOutSemantic.js"></script>
135     <script src="StandardLibrary.js"></script>
136     <script src="StatementCloner.js"></script>
137     <script src="StructLayoutBuilder.js"></script>
138     <script src="StructType.js"></script>
139     <script src="SwitchCase.js"></script>
140     <script src="SwitchStatement.js"></script>
141     <script src="SynthesizeArrayOperatorLength.js"></script>
142     <script src="SynthesizeEnumFunctions.js"></script>
143     <script src="SynthesizeStructAccessors.js"></script>
144     <script src="SynthesizeCopyConstructorOperator.js"></script>
145     <script src="SynthesizeDefaultConstructorOperator.js"></script>
146     <script src="TernaryExpression.js"></script>
147     <script src="Texture.js"></script>
148     <script src="TextureOperations.js"></script>
149     <script src="TrapStatement.js"></script>
150     <script src="TypeDef.js"></script>
151     <script src="TypeDefResolver.js"></script>
152     <script src="TypeRef.js"></script>
153     <script src="TypeOverloadResolutionFailure.js"></script>
154     <script src="TypedValue.js"></script>
155     <script src="UintLiteral.js"></script>
156     <script src="UintLiteralType.js"></script>
157     <script src="UnificationContext.js"></script>
158     <script src="UnreachableCodeChecker.js"></script>
159     <script src="VariableDecl.js"></script>
160     <script src="VariableRef.js"></script>
161     <script src="VectorType.js"></script>
162     <script src="VisitingSet.js"></script>
163     <script src="WLexicalError.js"></script>
164     <script src="WSyntaxError.js"></script>
165     <script src="WTrapError.js"></script>
166     <script src="WTypeError.js"></script>
167     <script src="WhileLoop.js"></script>
168     <script src="WrapChecker.js"></script>
169 <script>
170     let code = `
171 struct VertexInput {
172     float2 position;
173     float3 color;
174 }
175
176 struct VertexOutput {
177     float4 wsl_Position;
178     float4 color;
179 }
180
181 struct FragmentOutput {
182     float4 wsl_Color;
183 }
184
185 vertex VertexOutput vertexShader(VertexInput vertexInput) {
186     VertexOutput result;
187     result.wsl_Position = float4(vertexInput.position, 0., 1.);
188     result.color = float4(vertexInput.color, 1);
189     
190     int[10] a;
191     int[10u] b;
192     return result;
193 }
194
195 fragment FragmentOutput fragmentShader(VertexOutput stageIn) {
196     FragmentOutput result;
197     result.wsl_Color = stageIn.color;
198     return result;
199 }`;
200
201     window.addEventListener("load", function () {
202         fetch("spirv.core.grammar.json").then(response => response.json()).then(function (json) {
203             let spirv = SPIRV(json);
204             let program = prepare("/internal/test", 0, code);
205             let result = generateSPIRV(spirv, program);
206             return result;
207         }).then(function(result) {
208             let resultElement = document.getElementById("Result");
209             while (resultElement.childNodes.length != 0)
210                 resultElement.removeChild(resultElement.childNodes[0]);
211             let anchor = document.createElement("a");
212             let blob = new Blob([result.file], { type: "application/octet-binary" });
213             anchor.href = URL.createObjectURL(blob);
214             anchor.download = "result.spv";
215             anchor.textContent = "Download generated SPIR-V";
216             resultElement.appendChild(anchor);
217
218             let table = document.createElement("table");
219             let tableHeader = document.createElement("thead");
220             let headerRow = document.createElement("tr");
221             let nameHeader = document.createElement("th");
222             nameHeader.textContent = "Attribute name";
223             let locationHeader = document.createElement("th");
224             locationHeader.textContent = "Location";
225             headerRow.appendChild(nameHeader);
226             headerRow.appendChild(locationHeader);
227             tableHeader.appendChild(headerRow);
228             table.appendChild(tableHeader);
229             for (let location of result.locations) {
230                 let tableRow = document.createElement("tr");
231                 let nameElement = document.createElement("td");
232                 nameElement.textContent = location.name;
233                 let locationElement = document.createElement("td");
234                 locationElement.textContent = location.location;
235                 tableRow.appendChild(nameElement);
236                 tableRow.appendChild(locationElement);
237                 table.appendChild(tableRow);
238             }
239             resultElement.appendChild(table);
240         }).then(undefined, function () {
241             let resultElement = document.getElementById("Result");
242             while (resultElement.childNodes.length != 0)
243                 resultElement.removeChild(resultElement.childNodes[0]);
244             resultElement.textContent = "Load failed.";
245         });
246     });
247 </script>
248 </head>
249 <body>
250     <div id="Result">Loading...</div>
251 </body>
252 </html>