This commit is contained in:
parent
6bc125be1c
commit
ed5a4379db
76 changed files with 1418 additions and 988 deletions
|
|
@ -2,8 +2,8 @@ import { vec2 } from 'gl-matrix';
|
|||
|
||||
import { appConfig } from '../../config';
|
||||
import {
|
||||
createCachedFloat32BufferWrite,
|
||||
writeFloat32BufferIfChanged,
|
||||
createCachedBufferWrite,
|
||||
writeBufferIfChanged,
|
||||
} from '../../utils/graphics/cached-buffer-write';
|
||||
import { generateNoise } from '../../utils/graphics/noise';
|
||||
|
||||
|
|
@ -12,10 +12,10 @@ export class CommonState {
|
|||
|
||||
private readonly uniforms: GPUBuffer;
|
||||
private readonly uniformValues = new Float32Array(CommonState.UNIFORM_COUNT);
|
||||
private readonly uniformCache = createCachedFloat32BufferWrite(
|
||||
CommonState.UNIFORM_COUNT
|
||||
private readonly uniformCache = createCachedBufferWrite(
|
||||
CommonState.UNIFORM_COUNT * Float32Array.BYTES_PER_ELEMENT
|
||||
);
|
||||
private readonly noise: GPUTextureView;
|
||||
private readonly noise: GPUTexture;
|
||||
private readonly bindGroup: GPUBindGroup;
|
||||
|
||||
public readonly bindGroupLayout: GPUBindGroupLayout;
|
||||
|
|
@ -37,11 +37,12 @@ export class CommonState {
|
|||
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
||||
});
|
||||
|
||||
this.noise = generateNoise({
|
||||
const noise = generateNoise({
|
||||
device,
|
||||
width: appConfig.pipelines.common.noiseTextureSize,
|
||||
height: appConfig.pipelines.common.noiseTextureSize,
|
||||
});
|
||||
this.noise = noise.texture;
|
||||
|
||||
this.bindGroupLayout = device.createBindGroupLayout({
|
||||
entries: [
|
||||
|
|
@ -90,7 +91,7 @@ export class CommonState {
|
|||
},
|
||||
{
|
||||
binding: 2,
|
||||
resource: this.noise,
|
||||
resource: noise.view,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
@ -99,7 +100,7 @@ export class CommonState {
|
|||
public setParameters({ canvasSize }: { canvasSize: vec2 }) {
|
||||
this.uniformValues[0] = canvasSize[0];
|
||||
this.uniformValues[1] = canvasSize[1];
|
||||
writeFloat32BufferIfChanged(
|
||||
writeBufferIfChanged(
|
||||
this.device,
|
||||
this.uniforms,
|
||||
this.uniformValues,
|
||||
|
|
@ -113,5 +114,6 @@ export class CommonState {
|
|||
|
||||
public destroy() {
|
||||
this.uniforms.destroy();
|
||||
this.noise.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue