From fc948d8b2753e0bf7f1e9607e35d0401f43283cd Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Mon, 19 Dec 2022 14:41:12 -0800 Subject: [PATCH] fix gpu mc use of float16 --- CHANGELOG.md | 1 + src/mol-gl/compute/histogram-pyramid/reduction.ts | 3 +-- src/mol-gl/compute/marching-cubes/isosurface.ts | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ee4e47af..f317290b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Note that since we don't clearly distinguish between a public and private interf - Add `Segmentation` custom volume property - Add `SegmentRepresentation` representation - Add `volume-segment` color theme +- Fix GPU marching cubes failing for large meshes with webgl2 (due to use of float16) ## [v3.27.0] - 2022-12-15 diff --git a/src/mol-gl/compute/histogram-pyramid/reduction.ts b/src/mol-gl/compute/histogram-pyramid/reduction.ts index 43aaddf29..cd6ec8301 100644 --- a/src/mol-gl/compute/histogram-pyramid/reduction.ts +++ b/src/mol-gl/compute/histogram-pyramid/reduction.ts @@ -204,8 +204,7 @@ export function createHistogramPyramid(ctx: WebGLContext, inputTexture: Texture, // return at least a count of one to avoid issues downstram const count = Math.max(1, getHistopyramidSum(ctx, levelTexturesFramebuffers[0].texture)); const height = Math.ceil(count / Math.pow(2, levels)); - // const scale = Vec2.create(maxSize / inputTexture.width, maxSize / inputTexture.height); - // console.log('height', height, 'finalCount', count, 'scale', scale); + // console.log({ height, count, scale }); return { pyramidTex, count, height, levels, scale }; } \ No newline at end of file diff --git a/src/mol-gl/compute/marching-cubes/isosurface.ts b/src/mol-gl/compute/marching-cubes/isosurface.ts index 62af9563c..3f495d3ed 100644 --- a/src/mol-gl/compute/marching-cubes/isosurface.ts +++ b/src/mol-gl/compute/marching-cubes/isosurface.ts @@ -142,9 +142,7 @@ export function createIsosurfaceBuffers(ctx: WebGLContext, activeVoxelsBase: Tex if (isWebGL2(gl)) { if (!vertexTexture) { - vertexTexture = extensions.colorBufferHalfFloat && extensions.textureHalfFloat - ? resources.texture('image-float16', 'rgba', 'fp16', 'nearest') - : resources.texture('image-float32', 'rgba', 'float', 'nearest'); + vertexTexture = resources.texture('image-float32', 'rgba', 'float', 'nearest'); } if (!groupTexture) { @@ -199,9 +197,9 @@ export function createIsosurfaceBuffers(ctx: WebGLContext, activeVoxelsBase: Tex gl.finish(); if (isTimingMode) ctx.timer.markEnd('createIsosurfaceBuffers'); - // printTextureImage(readTexture(ctx, vertexTexture, new Float32Array(width * height * 4)), { scale: 0.75 }); - // printTextureImage(readTexture(ctx, groupTexture, new Uint8Array(width * height * 4)), { scale: 0.75 }); - // printTextureImage(readTexture(ctx, normalTexture, new Float32Array(width * height * 4)), { scale: 0.75 }); + // printTextureImage(readTexture(ctx, vertexTexture, new Float32Array(width * height * 4)), { scale: 0.75, normalize: true }); + // printTextureImage(readTexture(ctx, groupTexture, new Uint8Array(width * height * 4)), { scale: 0.75, normalize: true }); + // printTextureImage(readTexture(ctx, normalTexture, new Float32Array(width * height * 4)), { scale: 0.75, normalize: true }); return { vertexTexture, groupTexture, normalTexture, vertexCount: count }; } -- GitLab