Procházet zdrojové kódy

clearer param names for using gpu/impostors

Alexander Rose před 4 roky
rodič
revize
021fa7b79b

+ 4 - 4
src/mol-repr/structure/visual/bond-inter-unit-cylinder.ts

@@ -157,12 +157,12 @@ export const InterUnitBondCylinderParams = {
     ...BondCylinderParams,
     sizeFactor: PD.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
     sizeAspectRatio: PD.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }),
-    useImpostor: PD.Boolean(true),
+    tryUseImpostor: PD.Boolean(true),
 };
 export type InterUnitBondCylinderParams = typeof InterUnitBondCylinderParams
 
 export function InterUnitBondCylinderVisual(materialId: number, structure: Structure, props: PD.Values<InterUnitBondCylinderParams>, webgl?: WebGLContext) {
-    return props.useImpostor && webgl && webgl.extensions.fragDepth
+    return props.tryUseImpostor && webgl && webgl.extensions.fragDepth
         ? InterUnitBondCylinderImpostorVisual(materialId)
         : InterUnitBondCylinderMeshVisual(materialId);
 }
@@ -188,7 +188,7 @@ export function InterUnitBondCylinderImpostorVisual(materialId: number): Complex
             );
         },
         mustRecreate: (structure: Structure, props: PD.Values<InterUnitBondCylinderParams>, webgl?: WebGLContext) => {
-            return !props.useImpostor || !webgl;
+            return !props.tryUseImpostor || !webgl;
         }
     }, materialId);
 }
@@ -217,7 +217,7 @@ export function InterUnitBondCylinderMeshVisual(materialId: number): ComplexVisu
             );
         },
         mustRecreate: (structure: Structure, props: PD.Values<InterUnitBondCylinderParams>, webgl?: WebGLContext) => {
-            return props.useImpostor && !!webgl;
+            return props.tryUseImpostor && !!webgl;
         }
     }, materialId);
 }

+ 4 - 4
src/mol-repr/structure/visual/bond-intra-unit-cylinder.ts

@@ -141,12 +141,12 @@ export const IntraUnitBondCylinderParams = {
     ...BondCylinderParams,
     sizeFactor: PD.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
     sizeAspectRatio: PD.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }),
-    useImpostor: PD.Boolean(true),
+    tryUseImpostor: PD.Boolean(true),
 };
 export type IntraUnitBondCylinderParams = typeof IntraUnitBondCylinderParams
 
 export function IntraUnitBondCylinderVisual(materialId: number, structure: Structure, props: PD.Values<IntraUnitBondCylinderParams>, webgl?: WebGLContext) {
-    return props.useImpostor && webgl && webgl.extensions.fragDepth
+    return props.tryUseImpostor && webgl && webgl.extensions.fragDepth
         ? IntraUnitBondCylinderImpostorVisual(materialId)
         : IntraUnitBondCylinderMeshVisual(materialId);
 }
@@ -183,7 +183,7 @@ export function IntraUnitBondCylinderImpostorVisual(materialId: number): UnitsVi
             }
         },
         mustRecreate: (structureGroup: StructureGroup, props: PD.Values<IntraUnitBondCylinderParams>, webgl?: WebGLContext) => {
-            return !props.useImpostor || !webgl;
+            return !props.tryUseImpostor || !webgl;
         }
     }, materialId);
 }
@@ -223,7 +223,7 @@ export function IntraUnitBondCylinderMeshVisual(materialId: number): UnitsVisual
             }
         },
         mustRecreate: (structureGroup: StructureGroup, props: PD.Values<IntraUnitBondCylinderParams>, webgl?: WebGLContext) => {
-            return props.useImpostor && !!webgl;
+            return props.tryUseImpostor && !!webgl;
         }
     }, materialId);
 }

+ 4 - 4
src/mol-repr/structure/visual/element-sphere.ts

@@ -20,12 +20,12 @@ export const ElementSphereParams = {
     detail: PD.Numeric(0, { min: 0, max: 3, step: 1 }, BaseGeometry.CustomQualityParamInfo),
     ignoreHydrogens: PD.Boolean(false),
     traceOnly: PD.Boolean(false),
-    useImpostor: PD.Boolean(true),
+    tryUseImpostor: PD.Boolean(true),
 };
 export type ElementSphereParams = typeof ElementSphereParams
 
 export function ElementSphereVisual(materialId: number, structure: Structure, props: PD.Values<ElementSphereParams>, webgl?: WebGLContext) {
-    return props.useImpostor && webgl && webgl.extensions.fragDepth
+    return props.tryUseImpostor && webgl && webgl.extensions.fragDepth
         ? ElementSphereImpostorVisual(materialId)
         : ElementSphereMeshVisual(materialId);
 }
@@ -44,7 +44,7 @@ export function ElementSphereImpostorVisual(materialId: number): UnitsVisual<Ele
             );
         },
         mustRecreate: (structureGroup: StructureGroup, props: PD.Values<ElementSphereParams>, webgl?: WebGLContext) => {
-            return !props.useImpostor || !webgl;
+            return !props.tryUseImpostor || !webgl;
         }
     }, materialId);
 }
@@ -65,7 +65,7 @@ export function ElementSphereMeshVisual(materialId: number): UnitsVisual<Element
             );
         },
         mustRecreate: (structureGroup: StructureGroup, props: PD.Values<ElementSphereParams>, webgl?: WebGLContext) => {
-            return props.useImpostor && !!webgl;
+            return props.tryUseImpostor && !!webgl;
         }
     }, materialId);
 }

+ 2 - 4
src/mol-repr/structure/visual/gaussian-density-volume.ts

@@ -24,9 +24,8 @@ async function createGaussianDensityVolume(ctx: VisualContext, structure: Struct
         throw new Error('GaussianDensityVolume requires `webgl` and `blendMinMax` extension');
     }
 
-    const p = { ...props, useGpu: true };
     const oldTexture = directVolume ? directVolume.gridTexture.ref.value : undefined;
-    const densityTextureData = await computeStructureGaussianDensityTexture(structure, p, webgl, oldTexture).runInContext(runtime);
+    const densityTextureData = await computeStructureGaussianDensityTexture(structure, props, webgl, oldTexture).runInContext(runtime);
     const { transform, texture, bbox, gridDim } = densityTextureData;
     const stats = { min: 0, max: 1, mean: 0.04, sigma: 0.01 };
 
@@ -80,9 +79,8 @@ async function createUnitsGaussianDensityVolume(ctx: VisualContext, unit: Unit,
         throw new Error('GaussianDensityVolume requires `webgl`');
     }
 
-    const p = { ...props, useGpu: true };
     const oldTexture = directVolume ? directVolume.gridTexture.ref.value : undefined;
-    const densityTextureData = await computeUnitGaussianDensityTexture(structure, unit, p, webgl, oldTexture).runInContext(runtime);
+    const densityTextureData = await computeUnitGaussianDensityTexture(structure, unit, props, webgl, oldTexture).runInContext(runtime);
     const { transform, texture, bbox, gridDim } = densityTextureData;
     const stats = { min: 0, max: 1, mean: 0.04, sigma: 0.01 };
 

+ 7 - 7
src/mol-repr/structure/visual/gaussian-surface-mesh.ts

@@ -24,7 +24,7 @@ import { WebGLContext } from '../../../mol-gl/webgl/context';
 const SharedParams = {
     ...GaussianDensityParams,
     ignoreHydrogens: PD.Boolean(false),
-    useGpu: PD.Boolean(true, { label: 'Try Use GPU' }),
+    tryUseGpu: PD.Boolean(true),
 };
 type SharedParams = typeof SharedParams
 
@@ -58,14 +58,14 @@ function suitableForGpu(structure: Structure, props: PD.Values<SharedParams>, we
 }
 
 export function GaussianSurfaceVisual(materialId: number, structure: Structure, props: PD.Values<GaussianSurfaceMeshParams>, webgl?: WebGLContext) {
-    if (props.useGpu && webgl && gpuSupport(webgl) && suitableForGpu(structure, props, webgl)) {
+    if (props.tryUseGpu && webgl && gpuSupport(webgl) && suitableForGpu(structure, props, webgl)) {
         return GaussianSurfaceTextureMeshVisual(materialId);
     }
     return GaussianSurfaceMeshVisual(materialId);
 }
 
 export function StructureGaussianSurfaceVisual(materialId: number, structure: Structure, props: PD.Values<StructureGaussianSurfaceMeshParams>, webgl?: WebGLContext) {
-    if (props.useGpu && webgl && gpuSupport(webgl) && suitableForGpu(structure, props, webgl)) {
+    if (props.tryUseGpu && webgl && gpuSupport(webgl) && suitableForGpu(structure, props, webgl)) {
         return StructureGaussianSurfaceTextureMeshVisual(materialId);
     }
     return StructureGaussianSurfaceMeshVisual(materialId);
@@ -109,7 +109,7 @@ export function GaussianSurfaceMeshVisual(materialId: number): UnitsVisual<Gauss
             if (newProps.includeParent !== currentProps.includeParent) state.createGeometry = true;
         },
         mustRecreate: (structureGroup: StructureGroup, props: PD.Values<GaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
-            return props.useGpu && !!webgl && suitableForGpu(structureGroup.structure, props, webgl);
+            return props.tryUseGpu && !!webgl && suitableForGpu(structureGroup.structure, props, webgl);
         }
     }, materialId);
 }
@@ -151,7 +151,7 @@ export function StructureGaussianSurfaceMeshVisual(materialId: number): ComplexV
             if (newProps.traceOnly !== currentProps.traceOnly) state.createGeometry = true;
         },
         mustRecreate: (structure: Structure, props: PD.Values<StructureGaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
-            return props.useGpu && !!webgl && suitableForGpu(structure, props, webgl);
+            return props.tryUseGpu && !!webgl && suitableForGpu(structure, props, webgl);
         }
     }, materialId);
 }
@@ -205,7 +205,7 @@ export function GaussianSurfaceTextureMeshVisual(materialId: number): UnitsVisua
             if (newProps.includeParent !== currentProps.includeParent) state.createGeometry = true;
         },
         mustRecreate: (structureGroup: StructureGroup, props: PD.Values<GaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
-            return !props.useGpu || !webgl || !suitableForGpu(structureGroup.structure, props, webgl);
+            return !props.tryUseGpu || !webgl || !suitableForGpu(structureGroup.structure, props, webgl);
         },
         dispose: (geometry: TextureMesh) => {
             geometry.vertexTexture.ref.value.destroy();
@@ -261,7 +261,7 @@ export function StructureGaussianSurfaceTextureMeshVisual(materialId: number): C
             if (newProps.traceOnly !== currentProps.traceOnly) state.createGeometry = true;
         },
         mustRecreate: (structure: Structure, props: PD.Values<StructureGaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
-            return !props.useGpu || !webgl || !suitableForGpu(structure, props, webgl);
+            return !props.tryUseGpu || !webgl || !suitableForGpu(structure, props, webgl);
         },
         dispose: (geometry: TextureMesh) => {
             geometry.vertexTexture.ref.value.destroy();

+ 4 - 4
src/mol-repr/volume/isosurface.ts

@@ -48,7 +48,7 @@ function suitableForGpu(volume: Volume, webgl: WebGLContext) {
 }
 
 export function IsosurfaceVisual(materialId: number, volume: Volume, props: PD.Values<IsosurfaceMeshParams>, webgl?: WebGLContext) {
-    if (props.useGpu && webgl && gpuSupport(webgl) && suitableForGpu(volume, webgl)) {
+    if (props.tryUseGpu && webgl && gpuSupport(webgl) && suitableForGpu(volume, webgl)) {
         return IsosurfaceTextureMeshVisual(materialId);
     }
     return IsosurfaceMeshVisual(materialId);
@@ -101,7 +101,7 @@ export const IsosurfaceMeshParams = {
     ...TextureMesh.Params,
     ...VolumeIsosurfaceParams,
     quality: { ...Mesh.Params.quality, isEssential: false },
-    useGpu: PD.Boolean(true, { label: 'Try Use GPU' }),
+    tryUseGpu: PD.Boolean(true),
 };
 export type IsosurfaceMeshParams = typeof IsosurfaceMeshParams
 
@@ -117,7 +117,7 @@ export function IsosurfaceMeshVisual(materialId: number): VolumeVisual<Isosurfac
         },
         geometryUtils: Mesh.Utils,
         mustRecreate: (volume: Volume, props: PD.Values<IsosurfaceMeshParams>, webgl?: WebGLContext) => {
-            return props.useGpu && !!webgl && suitableForGpu(volume, webgl);
+            return props.tryUseGpu && !!webgl && suitableForGpu(volume, webgl);
         }
     }, materialId);
 }
@@ -194,7 +194,7 @@ export function IsosurfaceTextureMeshVisual(materialId: number): VolumeVisual<Is
         },
         geometryUtils: TextureMesh.Utils,
         mustRecreate: (volume: Volume, props: PD.Values<IsosurfaceMeshParams>, webgl?: WebGLContext) => {
-            return !props.useGpu || !webgl || !suitableForGpu(volume, webgl);
+            return !props.tryUseGpu || !webgl || !suitableForGpu(volume, webgl);
         },
         dispose: (geometry: TextureMesh) => {
             geometry.vertexTexture.ref.value.destroy();