Dies ist das Repository meines kleinen Portfolios.
Im Hintergrund läuft eine Planetensimulation, geschrieben in JavaScript und Three.js.
Die zu sehenden Texturen stammen von:
https://www.solarsystemscope.com/textures/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.1 KiB
65 lines
1.1 KiB
import WebGPUProgrammableStage from './WebGPUProgrammableStage.js'; |
|
|
|
class WebGPUComputePipelines { |
|
|
|
constructor( device ) { |
|
|
|
this.device = device; |
|
|
|
this.pipelines = new WeakMap(); |
|
this.stages = { |
|
compute: new WeakMap() |
|
}; |
|
|
|
} |
|
|
|
get( param ) { |
|
|
|
let pipeline = this.pipelines.get( param ); |
|
|
|
// @TODO: Reuse compute pipeline if possible, introduce WebGPUComputePipeline |
|
|
|
if ( pipeline === undefined ) { |
|
|
|
const device = this.device; |
|
|
|
const shader = { |
|
computeShader: param.shader |
|
}; |
|
|
|
// programmable stage |
|
|
|
let stageCompute = this.stages.compute.get( shader ); |
|
|
|
if ( stageCompute === undefined ) { |
|
|
|
stageCompute = new WebGPUProgrammableStage( device, shader.computeShader, 'compute' ); |
|
|
|
this.stages.compute.set( shader, stageCompute ); |
|
|
|
} |
|
|
|
pipeline = device.createComputePipeline( { |
|
compute: stageCompute.stage |
|
} ); |
|
|
|
this.pipelines.set( param, pipeline ); |
|
|
|
} |
|
|
|
return pipeline; |
|
|
|
} |
|
|
|
dispose() { |
|
|
|
this.pipelines = new WeakMap(); |
|
this.stages = { |
|
compute: new WeakMap() |
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
export default WebGPUComputePipelines;
|
|
|