()
| 476 | } |
| 477 | |
| 478 | build() { |
| 479 | if (this.built) return; |
| 480 | this.initExtensions(); |
| 481 | this.validateSettings(arguments); |
| 482 | this.setupConstants(arguments); |
| 483 | if (this.fallbackRequested) return; |
| 484 | this.setupArguments(arguments); |
| 485 | if (this.fallbackRequested) return; |
| 486 | this.updateMaxTexSize(); |
| 487 | this.translateSource(); |
| 488 | const failureResult = this.pickRenderStrategy(arguments); |
| 489 | if (failureResult) { |
| 490 | return failureResult; |
| 491 | } |
| 492 | const { texSize, context: gl, canvas } = this; |
| 493 | gl.enable(gl.SCISSOR_TEST); |
| 494 | if (this.pipeline && this.precision === 'single') { |
| 495 | gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]); |
| 496 | canvas.width = this.maxTexSize[0]; |
| 497 | canvas.height = this.maxTexSize[1]; |
| 498 | } else { |
| 499 | gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]); |
| 500 | canvas.width = this.maxTexSize[0]; |
| 501 | canvas.height = this.maxTexSize[1]; |
| 502 | } |
| 503 | const threadDim = this.threadDim = Array.from(this.output); |
| 504 | while (threadDim.length < 3) { |
| 505 | threadDim.push(1); |
| 506 | } |
| 507 | |
| 508 | const compiledVertexShader = this.getVertexShader(arguments); |
| 509 | const vertShader = gl.createShader(gl.VERTEX_SHADER); |
| 510 | gl.shaderSource(vertShader, compiledVertexShader); |
| 511 | gl.compileShader(vertShader); |
| 512 | this.vertShader = vertShader; |
| 513 | |
| 514 | const compiledFragmentShader = this.getFragmentShader(arguments); |
| 515 | const fragShader = gl.createShader(gl.FRAGMENT_SHADER); |
| 516 | gl.shaderSource(fragShader, compiledFragmentShader); |
| 517 | gl.compileShader(fragShader); |
| 518 | this.fragShader = fragShader; |
| 519 | |
| 520 | if (this.debug) { |
| 521 | console.log('GLSL Shader Output:'); |
| 522 | console.log(compiledFragmentShader); |
| 523 | } |
| 524 | |
| 525 | if (!gl.getShaderParameter(vertShader, gl.COMPILE_STATUS)) { |
| 526 | throw new Error('Error compiling vertex shader: ' + gl.getShaderInfoLog(vertShader)); |
| 527 | } |
| 528 | if (!gl.getShaderParameter(fragShader, gl.COMPILE_STATUS)) { |
| 529 | throw new Error('Error compiling fragment shader: ' + gl.getShaderInfoLog(fragShader)); |
| 530 | } |
| 531 | |
| 532 | const program = this.program = gl.createProgram(); |
| 533 | gl.attachShader(program, vertShader); |
| 534 | gl.attachShader(program, fragShader); |
| 535 | gl.linkProgram(program); |
nothing calls this directly
no test coverage detected