diff --git a/src/mol-gl/webgl/context.ts b/src/mol-gl/webgl/context.ts index 91e391d20980f8e2831160e1a31244c2e595445d..fb59101169f71f72df25ad976ee3fe2f7933b523 100644 --- a/src/mol-gl/webgl/context.ts +++ b/src/mol-gl/webgl/context.ts @@ -9,7 +9,7 @@ import { createShaderCache, ShaderCache } from './shader' import { GLRenderingContext, COMPAT_instanced_arrays, COMPAT_standard_derivatives, COMPAT_vertex_array_object, getInstancedArrays, getStandardDerivatives, getVertexArrayObject, isWebGL2, COMPAT_element_index_uint, getElementIndexUint, COMPAT_texture_float, getTextureFloat, COMPAT_texture_float_linear, getTextureFloatLinear, COMPAT_blend_minmax, getBlendMinMax, getFragDepth, COMPAT_frag_depth, COMPAT_color_buffer_float, getColorBufferFloat, COMPAT_draw_buffers, getDrawBuffers } from './compat'; import { createFramebufferCache, FramebufferCache, checkFramebufferStatus } from './framebuffer'; import { Scheduler } from 'mol-task'; -import { isProductionMode } from 'mol-util/debug'; +import { isDebugMode } from 'mol-util/debug'; export function getGLContext(canvas: HTMLCanvasElement, contextAttributes?: WebGLContextAttributes): GLRenderingContext | null { function getContext(contextId: 'webgl' | 'experimental-webgl' | 'webgl2') { @@ -121,13 +121,13 @@ function waitForGpuCommandsCompleteSync(gl: GLRenderingContext): void { } function readPixels(gl: GLRenderingContext, x: number, y: number, width: number, height: number, buffer: Uint8Array | Float32Array) { - if (!isProductionMode) checkFramebufferStatus(gl) + if (isDebugMode) checkFramebufferStatus(gl) if (buffer instanceof Uint8Array) { gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buffer) } else { gl.readPixels(x, y, width, height, gl.RGBA, gl.FLOAT, buffer) } - if (!isProductionMode) checkError(gl) + if (isDebugMode) checkError(gl) } export function createImageData(buffer: ArrayLike<number>, width: number, height: number) { diff --git a/src/mol-gl/webgl/program.ts b/src/mol-gl/webgl/program.ts index 5c0faeb017e8b87e839d6a47fec01e1e5c93e8b8..34bf101c9abe6c4bc1322ed9c1af5c77d8eb1837 100644 --- a/src/mol-gl/webgl/program.ts +++ b/src/mol-gl/webgl/program.ts @@ -13,7 +13,7 @@ import { createReferenceCache, ReferenceCache } from 'mol-util/reference-cache'; import { idFactory } from 'mol-util/id-factory'; import { RenderableSchema } from '../renderable/schema'; import { hashFnv32a, hashString } from 'mol-data/util'; -import { isProductionMode } from 'mol-util/debug'; +import { isDebugMode } from 'mol-util/debug'; import { GLRenderingContext } from './compat'; import { ShaderCache } from './shader'; @@ -134,7 +134,7 @@ export function createProgram(gl: GLRenderingContext, state: WebGLState, extensi vertShaderRef.value.attach(program) fragShaderRef.value.attach(program) gl.linkProgram(program) - if (!isProductionMode) { + if (isDebugMode) { // no-op in FF on Mac, see https://bugzilla.mozilla.org/show_bug.cgi?id=1284425 // gl.validateProgram(program) if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { @@ -145,7 +145,7 @@ export function createProgram(gl: GLRenderingContext, state: WebGLState, extensi const locations = getLocations(gl, program, schema) const uniformSetters = getUniformSetters(schema) - if (!isProductionMode) { + if (isDebugMode) { checkActiveAttributes(gl, program, schema) checkActiveUniforms(gl, program, schema) } diff --git a/src/mol-gl/webgl/render-item.ts b/src/mol-gl/webgl/render-item.ts index edd4dce49eb0d01815268a328cfe1a00f0cd4941..e196b6ee08935a2975a435a47cb4bdce311a48bd 100644 --- a/src/mol-gl/webgl/render-item.ts +++ b/src/mol-gl/webgl/render-item.ts @@ -16,7 +16,7 @@ import { ValueCell } from 'mol-util'; import { ReferenceItem } from 'mol-util/reference-cache'; import { TextureImage, TextureVolume } from 'mol-gl/renderable/util'; import { checkFramebufferStatus } from './framebuffer'; -import { isProductionMode } from 'mol-util/debug'; +import { isDebugMode } from 'mol-util/debug'; const getNextRenderItemId = idFactory() @@ -184,7 +184,7 @@ export function createRenderItem<T extends RenderVariantDefines, S extends keyof if (elementsBuffer) elementsBuffer.bind() program.bindAttributes(attributeBuffers) } - if (!isProductionMode) { + if (isDebugMode) { checkFramebufferStatus(ctx.gl) } if (elementsBuffer) { @@ -192,7 +192,7 @@ export function createRenderItem<T extends RenderVariantDefines, S extends keyof } else { instancedArrays.drawArraysInstanced(glDrawMode, 0, drawCount, instanceCount) } - if (!isProductionMode) { + if (isDebugMode) { try { checkError(ctx.gl) } catch (e) { diff --git a/src/mol-gl/webgl/shader.ts b/src/mol-gl/webgl/shader.ts index 216c6026deec2e3faa0973dfea3982a0f981a13d..546ba0328b185ddbf452181fadea06887112e9ed 100644 --- a/src/mol-gl/webgl/shader.ts +++ b/src/mol-gl/webgl/shader.ts @@ -7,7 +7,7 @@ import { createReferenceCache, ReferenceCache } from 'mol-util/reference-cache'; import { idFactory } from 'mol-util/id-factory'; import { GLRenderingContext } from './compat'; -import { isProductionMode } from 'mol-util/debug'; +import { isDebugMode } from 'mol-util/debug'; const getNextShaderId = idFactory() @@ -38,7 +38,7 @@ function createShader(gl: GLRenderingContext, props: ShaderProps): Shader { gl.shaderSource(shader, source) gl.compileShader(shader) - if (!isProductionMode && gl.getShaderParameter(shader, gl.COMPILE_STATUS) === false) { + if (isDebugMode && gl.getShaderParameter(shader, gl.COMPILE_STATUS) === false) { console.warn(`'${type}' shader info log '${gl.getShaderInfoLog(shader)}'\n${addLineNumbers(source)}`) throw new Error(`Error compiling ${type} shader`) } diff --git a/src/mol-util/debug.ts b/src/mol-util/debug.ts index 39fca88a29dad4c7408388f4f8e9505c6e077773..3f9334cd84030372556afd95b430113faf23fba3 100644 --- a/src/mol-util/debug.ts +++ b/src/mol-util/debug.ts @@ -10,4 +10,10 @@ */ const isProductionMode = process.env.NODE_ENV === 'production' -export { isProductionMode } \ No newline at end of file +/** + * set to true to enable more comprehensive checks and assertions, + * moslty used in `mol-gl` + */ +const isDebugMode = false + +export { isProductionMode, isDebugMode } \ No newline at end of file