[WHLSL] Rewrite all tests to use WHLSL and delete the isWHLSL flag
[WebKit-https.git] / LayoutTests / webgpu / whlsl / separate-shader-modules / separate-shader-modules-4.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../js/webgpu-functions.js"></script>
5 <script src="../../../resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <script>
9 const vertexShaderSource = `
10 typedef Foo = int;
11 vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position {
12     return position;
13 }`;
14
15 const fragmentShaderSource = `
16 fragment float4 fragmentShader(float4 position : SV_Position) : SV_Target 0 {
17     Foo x;
18     return float4(1, 1, 1, 1);
19 }
20 `;
21
22 async function start(device) {
23     const vertexShaderModule = device.createShaderModule({code: vertexShaderSource});
24     const fragmentShaderModule = device.createShaderModule({code: fragmentShaderSource});
25     const vertexStage = {module: vertexShaderModule, entryPoint: "vertexShader"};
26     const fragmentStage = {module: fragmentShaderModule, entryPoint: "fragmentShader"};
27     const primitiveTopology = "triangle-strip";
28     const rasterizationState = {frontFace: "cw", cullMode: "none"};
29     const alphaBlend = {};
30     const colorBlend = {};
31     const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
32     const depthStencilState = null;
33     
34     const attribute = {shaderLocation: 0, format: "float4"};
35     const input = {stride: 16, attributeSet: [attribute]};
36     const inputs = [input];
37     const vertexInput = {vertexBuffers: inputs};
38
39     const pipelineLayoutDescriptor = {bindGroupLayouts: []};
40     const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
41
42     device.pushErrorScope("validation");
43     const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout};
44     const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);
45     return device.popErrorScope();
46 }
47 window.jsTestIsAsync = true;
48 getBasicDevice().then(function(device) {
49     start(device).then(function(x) {
50         if (x)
51             testPassed("");
52         else
53             testFailed("");
54         finishJSTest();
55     }, function() {
56         testFailed("");
57         finishJSTest();
58     });
59 }, function() {
60     testPassed();
61     finishJSTest();
62 });
63 </script>
64 <script src="../../../resources/js-test-post.js"></script>
65 </body>
66 </html>