public static IntPtr CreatePipeline(IntPtr bindGroupLayout) { // Load shaders var vertMod = CreateShader(triangleVert); //var vertMod = TriangleCPP.createVertShader(); var fragMod = CreateShader(triangleFrag); //var fragMod = TriangleCPP.createFragShader(); WGPUPipelineLayoutDescriptor layoutDesc = new WGPUPipelineLayoutDescriptor { bindGroupLayoutCount = 1, bindGroupLayouts = &bindGroupLayout }; IntPtr pipelineLayout = WebGPUNative.wgpuDeviceCreatePipelineLayout(Device, &layoutDesc); // begin pipeline set-up WGPURenderPipelineDescriptor desc = new WGPURenderPipelineDescriptor { layout = pipelineLayout, vertexStage = new WGPUProgrammableStageDescriptor() { module = vertMod, entryPoint = str_entrypoint } }; WGPUProgrammableStageDescriptor fragStage = new WGPUProgrammableStageDescriptor { module = fragMod, entryPoint = str_entrypoint }; desc.fragmentStage = &fragStage; // describe buffer layouts var vertAttrs = stackalloc WGPUVertexAttributeDescriptor[2]; vertAttrs[0] = new WGPUVertexAttributeDescriptor { format = WGPUVertexFormat.WGPUVertexFormat_Float2, offset = 0, shaderLocation = 0 }; vertAttrs[1] = new WGPUVertexAttributeDescriptor { format = WGPUVertexFormat.WGPUVertexFormat_Float3, offset = 2 * sizeof(float), shaderLocation = 1 }; WGPUVertexBufferLayoutDescriptor vertDesc = new WGPUVertexBufferLayoutDescriptor { arrayStride = 5 * sizeof(float), attributeCount = 2, attributes = vertAttrs }; WGPUVertexStateDescriptor vertState = new WGPUVertexStateDescriptor { ////indexFormat = WGPUIndexFormat.WGPUIndexFormat_Uint16, vertexBufferCount = 1, vertexBuffers = &vertDesc }; desc.vertexState = &vertState; desc.primitiveTopology = WGPUPrimitiveTopology.WGPUPrimitiveTopology_TriangleList; desc.sampleCount = 1; // describe blend WGPUBlendDescriptor blendDesc = new WGPUBlendDescriptor { operation = WGPUBlendOperation.WGPUBlendOperation_Add, srcFactor = WGPUBlendFactor.WGPUBlendFactor_SrcAlpha, dstFactor = WGPUBlendFactor.WGPUBlendFactor_OneMinusSrcAlpha }; WGPUColorStateDescriptor colorDesc = new WGPUColorStateDescriptor { format = Dawn.getSwapChainFormat(Device), alphaBlend = blendDesc, colorBlend = blendDesc, writeMask = WGPUColorWriteMask.WGPUColorWriteMask_All }; desc.colorStateCount = 1; desc.colorStates = &colorDesc; desc.sampleMask = 0xFFFFFFFF; // <-- Note: this currently causes Emscripten to fail (sampleMask ends up as -1, which trips an assert) IntPtr _pipeline = WebGPUNative.wgpuDeviceCreateRenderPipeline(Device, ref desc); // partial clean-up (just move to the end, no?) WebGPUNative.wgpuPipelineLayoutRelease(pipelineLayout); WebGPUNative.wgpuShaderModuleRelease(fragMod); WebGPUNative.wgpuShaderModuleRelease(vertMod); return(_pipeline); }