"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WebGL
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCopyPickBuffersProgram = void 0;
const RenderFlags_1 = require("../RenderFlags");
const Texture_1 = require("../Texture");
const ViewportQuad_1 = require("./ViewportQuad");
const computeBaseColor = "return vec4(1.0);";
const assignFragData = `
  FragColor0 = TEXTURE(u_pickFeatureId, v_texCoord);
  FragColor1 = TEXTURE(u_pickDepthAndOrder, v_texCoord);
`;
/** @internal */
function createCopyPickBuffersProgram(context) {
    const builder = (0, ViewportQuad_1.createViewportQuadBuilder)(true);
    const frag = builder.frag;
    frag.set(1 /* FragmentShaderComponent.ComputeBaseColor */, computeBaseColor);
    frag.addUniform("u_pickFeatureId", 8 /* VariableType.Sampler2D */, (prog) => {
        prog.addGraphicUniform("u_pickFeatureId", (uniform, params) => {
            Texture_1.Texture2DHandle.bindSampler(uniform, params.geometry.featureId, RenderFlags_1.TextureUnit.Zero);
        });
    }, 3 /* VariablePrecision.High */);
    frag.addUniform("u_pickDepthAndOrder", 8 /* VariableType.Sampler2D */, (prog) => {
        prog.addGraphicUniform("u_pickDepthAndOrder", (uniform, params) => {
            Texture_1.Texture2DHandle.bindSampler(uniform, params.geometry.depthAndOrder, RenderFlags_1.TextureUnit.One);
        });
    }, 3 /* VariablePrecision.High */);
    frag.addDrawBuffersExtension(2);
    frag.set(16 /* FragmentShaderComponent.AssignFragData */, assignFragData);
    builder.vert.headerComment = "//!V! CopyPickBuffers";
    builder.frag.headerComment = "//!F! CopyPickBuffers";
    return builder.buildProgram(context);
}
exports.createCopyPickBuffersProgram = createCopyPickBuffersProgram;
//# sourceMappingURL=CopyPickBuffers.js.map