import {} from "./RenderDevice.js";
import {} from "./ShaderLibrary.js";
import { reflectShaderSources } from "./ShaderReflection.js";
export class ShaderModule {
    source;
    program = null;
    reflection;
    constructor(source) {
        this.source = source;
        this.reflection = reflectShaderSources(source);
    }
    static fromLibrary(library, name) {
        return new ShaderModule(library.compileSource(name));
    }
    static fromLibraryVariant(library, name, variantName) {
        return new ShaderModule(library.compileVariant(name, variantName));
    }
    compile(device) {
        if (!this.program || this.program.disposed) {
            this.program = device.createShaderProgram({
                label: this.source.label,
                marker: this.source.marker,
                vertex: this.source.vertex,
                fragment: this.source.fragment
            });
        }
        return this.program;
    }
    dispose() {
        this.program?.dispose();
    }
}
//# sourceMappingURL=ShaderModule.js.map