Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for getGPUTier method in cornerstone.init #633

Merged
merged 9 commits into from
Jul 4, 2023
2 changes: 2 additions & 0 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import vtkImageSlice from '@kitware/vtk.js/Rendering/Core/ImageSlice';
import type { vtkObject } from '@kitware/vtk.js/interfaces';
import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
import type vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
import type { GetGPUTier } from 'detect-gpu';

// @public (undocumented)
type Actor = vtkActor;
Expand Down Expand Up @@ -210,6 +211,7 @@ enum ContourType {
// @public (undocumented)
type Cornerstone3DConfig = {
detectGPU: any;
getGPUTierConfig: GetGPUTier;
rendering: {
preferSizeOverAccuracy: boolean;
useNorm16Texture: boolean;
Expand Down
2 changes: 2 additions & 0 deletions common/reviews/api/streaming-image-volume-loader.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import type { vtkImageData } from '@kitware/vtk.js/Common/DataModel/ImageData';
import vtkImageSlice from '@kitware/vtk.js/Rendering/Core/ImageSlice';
import type vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
import type { GetGPUTier } from 'detect-gpu';

// @public (undocumented)
type Actor = vtkActor;
Expand Down Expand Up @@ -94,6 +95,7 @@ enum ContourType {
// @public (undocumented)
type Cornerstone3DConfig = {
detectGPU: any;
getGPUTierConfig: GetGPUTier;
rendering: {
// vtk.js supports 8bit integer textures and 32bit float textures.
// However, if the client has norm16 textures (it can be seen by visiting
Expand Down
2 changes: 2 additions & 0 deletions common/reviews/api/tools.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { vtkImageData } from '@kitware/vtk.js/Common/DataModel/ImageData';
import vtkImageSlice from '@kitware/vtk.js/Rendering/Core/ImageSlice';
import type { vtkPiecewiseFunction } from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction';
import type vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
import type { GetGPUTier } from 'detect-gpu';

declare namespace activeSegmentation {
export {
Expand Down Expand Up @@ -914,6 +915,7 @@ function copyPointsList(points: ITouchPoints[]): ITouchPoints[];
// @public (undocumented)
type Cornerstone3DConfig = {
detectGPU: any;
getGPUTierConfig: GetGPUTier;
rendering: {
// vtk.js supports 8bit integer textures and 32bit float textures.
// However, if the client has norm16 textures (it can be seen by visiting
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Cornerstone3DConfig } from './types';
// TODO: change config into a class with methods to better control get/set
const defaultConfig = {
detectGPU: {},
getGPUTierConfig: {},
rendering: {
useCPURendering: false,
// GPU rendering options
Expand All @@ -23,6 +24,7 @@ const defaultConfig = {

let config = {
detectGPU: {},
getGPUTierConfig: {},
rendering: {
useCPURendering: false,
// GPU rendering options
Expand Down Expand Up @@ -112,7 +114,7 @@ async function init(configuration = {}): Promise<boolean> {
console.log('CornerstoneRender: GPU not detected, using CPU rendering');
config.rendering.useCPURendering = true;
} else {
const gpuTier = await getGPUTier();
const gpuTier = await getGPUTier(config.getGPUTierConfig);
config.detectGPU = gpuTier;
console.log(
'CornerstoneRender: Using detect-gpu to get the GPU benchmark:',
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/types/Cornerstone3DConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { GetGPUTier } from 'detect-gpu';

type Cornerstone3DConfig = {
detectGPU: any;
getGPUTierConfig: GetGPUTier;
rendering: {
// vtk.js supports 8bit integer textures and 32bit float textures.
// However, if the client has norm16 textures (it can be seen by visiting
Expand Down