molstar
Version:
A comprehensive macromolecular library.
201 lines (200 loc) • 9.04 kB
JavaScript
"use strict";
/**
* Copyright (c) 2018-2025 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createExtensions = createExtensions;
exports.resetExtensions = resetExtensions;
const compat_1 = require("./compat");
const debug_1 = require("../../mol-util/debug");
const object_1 = require("../../mol-util/object");
function createExtensions(gl) {
const instancedArrays = (0, compat_1.getInstancedArrays)(gl);
if (instancedArrays === null) {
throw new Error('Could not find support for "instanced_arrays"');
}
const elementIndexUint = (0, compat_1.getElementIndexUint)(gl);
if (elementIndexUint === null) {
throw new Error('Could not find support for "element_index_uint"');
}
const standardDerivatives = (0, compat_1.getStandardDerivatives)(gl);
if (standardDerivatives === null) {
throw new Error('Could not find support for "standard_derivatives"');
}
const textureFloat = (0, compat_1.getTextureFloat)(gl);
if (debug_1.isDebugMode && textureFloat === null) {
console.log('Could not find support for "texture_float"');
}
const textureFloatLinear = (0, compat_1.getTextureFloatLinear)(gl);
if (debug_1.isDebugMode && textureFloatLinear === null) {
// TODO handle non-support downstream (no gpu gaussian calc, no gpu mc???)
// - can't be a required extension because it is not supported by `headless-gl`
console.log('Could not find support for "texture_float_linear"');
}
const textureHalfFloat = (0, compat_1.getTextureHalfFloat)(gl);
if (debug_1.isDebugMode && textureHalfFloat === null) {
console.log('Could not find support for "texture_half_float"');
}
const textureHalfFloatLinear = (0, compat_1.getTextureHalfFloatLinear)(gl);
if (debug_1.isDebugMode && textureHalfFloatLinear === null) {
// TODO handle non-support downstream (no gpu gaussian calc, no gpu mc???)
// - can't be a required extension because it is not supported by `headless-gl`
console.log('Could not find support for "texture_half_float_linear"');
}
const depthTexture = (0, compat_1.getDepthTexture)(gl);
if (debug_1.isDebugMode && depthTexture === null) {
console.log('Could not find support for "depth_texture"');
}
const blendMinMax = (0, compat_1.getBlendMinMax)(gl);
if (debug_1.isDebugMode && blendMinMax === null) {
// TODO handle non-support downstream (e.g. no gpu gaussian calc)
// - can't be a required extension because it is not supported by `headless-gl`
console.log('Could not find support for "blend_minmax"');
}
const vertexArrayObject = (0, compat_1.getVertexArrayObject)(gl);
if (debug_1.isDebugMode && vertexArrayObject === null) {
console.log('Could not find support for "vertex_array_object"');
}
const fragDepth = (0, compat_1.getFragDepth)(gl);
if (debug_1.isDebugMode && fragDepth === null) {
console.log('Could not find support for "frag_depth"');
}
const colorBufferFloat = (0, compat_1.getColorBufferFloat)(gl);
if (debug_1.isDebugMode && colorBufferFloat === null) {
console.log('Could not find support for "color_buffer_float"');
}
const colorBufferHalfFloat = (0, compat_1.getColorBufferHalfFloat)(gl);
if (debug_1.isDebugMode && colorBufferHalfFloat === null) {
console.log('Could not find support for "color_buffer_half_float"');
}
const drawBuffers = (0, compat_1.getDrawBuffers)(gl);
if (debug_1.isDebugMode && drawBuffers === null) {
console.log('Could not find support for "draw_buffers"');
}
const drawBuffersIndexed = (0, compat_1.getDrawBuffersIndexed)(gl);
if (debug_1.isDebugMode && drawBuffersIndexed === null) {
console.log('Could not find support for "draw_buffers_indexed"');
}
const shaderTextureLod = (0, compat_1.getShaderTextureLod)(gl);
if (debug_1.isDebugMode && shaderTextureLod === null) {
console.log('Could not find support for "shader_texture_lod"');
}
const sRGB = (0, compat_1.getSRGB)(gl);
if (debug_1.isDebugMode && sRGB === null) {
console.log('Could not find support for "sRGB"');
}
const disjointTimerQuery = (0, compat_1.getDisjointTimerQuery)(gl);
if (debug_1.isDebugMode && disjointTimerQuery === null) {
console.log('Could not find support for "disjoint_timer_query"');
}
const multiDraw = (0, compat_1.getMultiDraw)(gl);
if (debug_1.isDebugMode && multiDraw === null) {
console.log('Could not find support for "multi_draw"');
}
const drawInstancedBaseVertexBaseInstance = (0, compat_1.getDrawInstancedBaseVertexBaseInstance)(gl);
if (debug_1.isDebugMode && drawInstancedBaseVertexBaseInstance === null) {
console.log('Could not find support for "draw_instanced_base_vertex_base_instance"');
}
const multiDrawInstancedBaseVertexBaseInstance = (0, compat_1.getMultiDrawInstancedBaseVertexBaseInstance)(gl);
if (debug_1.isDebugMode && multiDrawInstancedBaseVertexBaseInstance === null) {
console.log('Could not find support for "multi_draw_instanced_base_vertex_base_instance"');
}
const parallelShaderCompile = (0, compat_1.getParallelShaderCompile)(gl);
if (debug_1.isDebugMode && parallelShaderCompile === null) {
console.log('Could not find support for "parallel_shader_compile"');
}
const fboRenderMipmap = (0, compat_1.getFboRenderMipmap)(gl);
if (debug_1.isDebugMode && fboRenderMipmap === null) {
console.log('Could not find support for "fbo_render_mipmap"');
}
const provokingVertex = (0, compat_1.getProvokingVertex)(gl);
if (debug_1.isDebugMode && provokingVertex === null) {
console.log('Could not find support for "provoking_vertex"');
}
const clipCullDistance = (0, compat_1.getClipCullDistance)(gl);
if (debug_1.isDebugMode && clipCullDistance === null) {
console.log('Could not find support for "clip_cull_distance"');
}
const conservativeDepth = (0, compat_1.getConservativeDepth)(gl);
if (debug_1.isDebugMode && conservativeDepth === null) {
console.log('Could not find support for "conservative_depth"');
}
const stencilTexturing = (0, compat_1.getStencilTexturing)(gl);
if (debug_1.isDebugMode && stencilTexturing === null) {
console.log('Could not find support for "stencil_texturing"');
}
const clipControl = (0, compat_1.getClipControl)(gl);
if (debug_1.isDebugMode && clipControl === null) {
console.log('Could not find support for "clip_control"');
}
const renderSnorm = (0, compat_1.getRenderSnorm)(gl);
if (debug_1.isDebugMode && renderSnorm === null) {
console.log('Could not find support for "render_snorm"');
}
const renderSharedExponent = (0, compat_1.getRenderSharedExponent)(gl);
if (debug_1.isDebugMode && renderSharedExponent === null) {
console.log('Could not find support for "render_shared_exponent"');
}
const textureNorm16 = (0, compat_1.getTextureNorm16)(gl);
if (debug_1.isDebugMode && textureNorm16 === null) {
console.log('Could not find support for "texture_norm16"');
}
const depthClamp = (0, compat_1.getDepthClamp)(gl);
if (debug_1.isDebugMode && depthClamp === null) {
console.log('Could not find support for "depth_clamp"');
}
const noNonInstancedActiveAttribs = (0, compat_1.getNoNonInstancedActiveAttribs)(gl);
return {
instancedArrays,
standardDerivatives,
elementIndexUint,
textureFloat,
textureFloatLinear,
textureHalfFloat,
textureHalfFloatLinear,
depthTexture,
blendMinMax,
vertexArrayObject,
fragDepth,
colorBufferFloat,
colorBufferHalfFloat,
drawBuffers,
drawBuffersIndexed,
shaderTextureLod,
sRGB,
disjointTimerQuery,
multiDraw,
drawInstancedBaseVertexBaseInstance,
multiDrawInstancedBaseVertexBaseInstance,
parallelShaderCompile,
fboRenderMipmap,
provokingVertex,
clipCullDistance,
conservativeDepth,
stencilTexturing,
clipControl,
renderSnorm,
renderSharedExponent,
textureNorm16,
depthClamp,
noNonInstancedActiveAttribs,
};
}
function resetExtensions(gl, extensions) {
const e = createExtensions(gl);
(0, object_1.objectForEach)(extensions, (v, k) => {
if (k === 'noNonInstancedActiveAttribs') {
extensions.noNonInstancedActiveAttribs = e.noNonInstancedActiveAttribs;
}
else if (v !== null) {
if (e[k] === null) {
extensions[k] = null;
}
else {
Object.assign(v, e[k]);
}
}
});
}