/*---------------------------------------------------------------------------------------------
* 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
 */
import { TextureUnit } from "../RenderFlags";
import { Texture2DHandle } from "../Texture";
import { createViewportQuadBuilder } from "./ViewportQuad";
const computeBaseColor = "return vec4(1.0);";
const assignFragData = `
  FragColor0 = TEXTURE(u_pickFeatureId, v_texCoord);
  FragColor1 = TEXTURE(u_pickDepthAndOrder, v_texCoord);
`;
/** @internal */
export function createCopyPickBuffersProgram(context) {
    const builder = 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) => {
            Texture2DHandle.bindSampler(uniform, params.geometry.featureId, TextureUnit.Zero);
        });
    }, 3 /* VariablePrecision.High */);
    frag.addUniform("u_pickDepthAndOrder", 8 /* VariableType.Sampler2D */, (prog) => {
        prog.addGraphicUniform("u_pickDepthAndOrder", (uniform, params) => {
            Texture2DHandle.bindSampler(uniform, params.geometry.depthAndOrder, TextureUnit.One);
        });
    }, 3 /* VariablePrecision.High */);
    frag.addDrawBuffersExtension(2);
    frag.set(17 /* FragmentShaderComponent.AssignFragData */, assignFragData);
    builder.vert.headerComment = "//!V! CopyPickBuffers";
    builder.frag.headerComment = "//!F! CopyPickBuffers";
    return builder.buildProgram(context);
}
//# sourceMappingURL=CopyPickBuffers.js.map