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