<!DOCTYPE html>
<html>
<head>
<script src="../js/webgpu-functions.js"></script>
</head>
<body>
<canvas id="canvas" width="400" height="400"></canvas>
<script>
const shaderSource = `
vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position {
    return position;
}

struct Foo {
    float x;
}

float operator.y(Foo f) {
    return f.x;
}

fragment float4 fragmentShader() : SV_Target 0 {
    Foo f;
    f.x = 1.0;
    return float4(f.y, f.y, f.y, 1.0);
}
`;

const canvas = document.getElementById("canvas");

async function start(device) {
    const shaderModule = device.createShaderModule({code: shaderSource, isWHLSL: true});
    const vertexStage = {module: shaderModule, entryPoint: "vertexShader"};
    const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"};
    const primitiveTopology = "triangle-strip";
    const rasterizationState = {frontFace: "cw", cullMode: "none"};
    const alphaBlend = {};
    const colorBlend = {};
    const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
    const depthStencilState = null;
    
    const attribute0 = {shaderLocation: 0, format: "float4"};
    const input0 = {stride: 16, attributeSet: [attribute0]};
    const inputs = [input0];
    const vertexInput = {vertexBuffers: inputs};

    const pipelineLayoutDescriptor = {bindGroupLayouts: []};
    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);

    const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout};
    const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);

    const vertexBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE};
    const vertexBuffer = device.createBuffer(vertexBufferDescriptor);
    const vertexBufferArrayBuffer = await vertexBuffer.mapWriteAsync();
    const vertexBufferFloat32Array = new Float32Array(vertexBufferArrayBuffer);
    vertexBufferFloat32Array[0] = -0.5;
    vertexBufferFloat32Array[1] = -0.5;
    vertexBufferFloat32Array[2] = 1.0;
    vertexBufferFloat32Array[3] = 1;
    vertexBufferFloat32Array[4] = -0.5;
    vertexBufferFloat32Array[5] = 0.5;
    vertexBufferFloat32Array[6] = 1.0;
    vertexBufferFloat32Array[7] = 1;
    vertexBufferFloat32Array[8] = 0.5;
    vertexBufferFloat32Array[9] = -0.5;
    vertexBufferFloat32Array[10] = 1.0;
    vertexBufferFloat32Array[11] = 1;
    vertexBufferFloat32Array[12] = 0.5;
    vertexBufferFloat32Array[13] = 0.5;
    vertexBufferFloat32Array[14] = 1.0;
    vertexBufferFloat32Array[15] = 1;
    vertexBuffer.unmap();

    const context = canvas.getContext("gpu");
    const swapChainDescriptor = {device, format: "bgra8unorm"};
    const swapChain = context.configureSwapChain(swapChainDescriptor);
    const outputTexture = swapChain.getCurrentTexture();
    const outputTextureView = outputTexture.createDefaultView();

    const commandEncoder = device.createCommandEncoder(); // {}
    const red = {r: 0, g: 0, b: 1, a: 1};
    const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor: red}];
    const depthStencilAttachment = null;
    const renderPassDescriptor = {colorAttachments, depthStencilAttachment};
    const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
    renderPassEncoder.setPipeline(renderPipeline);
    renderPassEncoder.setVertexBuffers(0, [vertexBuffer], [0]);
    renderPassEncoder.draw(4, 1, 0, 0);
    renderPassEncoder.endPass();
    const commandBuffer = commandEncoder.finish();
    device.getQueue().submit([commandBuffer]);
}
if (window.testRunner)
    testRunner.waitUntilDone();
getBasicDevice().then(function(device) {
    start(device).then(function() {
        if (window.testRunner)
            testRunner.notifyDone();
    }, function() {
        if (window.testRunner)
            testRunner.notifyDone();
    });
}, function() {
    drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
    if (window.testRunner)
        testRunner.notifyDone();
});
</script>
</body>
</html>
