Skip to content

Commit

Permalink
Fix SSBO buffer usage
Browse files Browse the repository at this point in the history
  • Loading branch information
9ballsyndrome committed Apr 21, 2019
1 parent 5f75961 commit 52bdcf5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion webgl-compute-bitonicSort/js/script.js
Expand Up @@ -83,7 +83,7 @@ const computeGPU = async (arr) => {
// create ShaderStorageBuffer
const ssbo = context.createBuffer();
context.bindBuffer(context.SHADER_STORAGE_BUFFER, ssbo);
context.bufferData(context.SHADER_STORAGE_BUFFER, arr, context.STATIC_DRAW);
context.bufferData(context.SHADER_STORAGE_BUFFER, arr, context.DYNAMIC_COPY);
context.bindBufferBase(context.SHADER_STORAGE_BUFFER, 0, ssbo);

// execute ComputeShader
Expand Down
4 changes: 2 additions & 2 deletions webgl-compute-boids/dist/js/bundle.js
Expand Up @@ -7304,11 +7304,11 @@ class Main_Main {
}
const instanceAttribute = this.model.getVertexBuffer('instancePosition').buffer;
context.bindBuffer(context.ARRAY_BUFFER, instanceAttribute);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.STATIC_DRAW);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.DYNAMIC_COPY);
this.ssboIn = instanceAttribute;
this.ssboOut = context.createBuffer();
context.bindBuffer(context.ARRAY_BUFFER, this.ssboOut);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.STATIC_DRAW);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.DYNAMIC_COPY);
const instanceColor = this.model.getVertexBuffer('instanceColor').buffer;
context.bindBuffer(context.ARRAY_BUFFER, instanceColor);
context.bufferData(context.ARRAY_BUFFER, instanceColorData, this.context.STATIC_DRAW);
Expand Down
4 changes: 2 additions & 2 deletions webgl-compute-boids/src/Main.ts
Expand Up @@ -337,11 +337,11 @@ export class Main
}
const instanceAttribute:WebGLBuffer = this.model.getVertexBuffer('instancePosition').buffer;
context.bindBuffer(context.ARRAY_BUFFER, instanceAttribute);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.STATIC_DRAW);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.DYNAMIC_COPY);
this.ssboIn = instanceAttribute;
this.ssboOut = context.createBuffer();
context.bindBuffer(context.ARRAY_BUFFER, this.ssboOut);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.STATIC_DRAW);
context.bufferData(context.ARRAY_BUFFER, instanceAttributeData, this.context.DYNAMIC_COPY);

const instanceColor:WebGLBuffer = this.model.getVertexBuffer('instanceColor').buffer;
context.bindBuffer(context.ARRAY_BUFFER, instanceColor);
Expand Down
2 changes: 1 addition & 1 deletion webgl-compute-simple/js/script.js
Expand Up @@ -49,7 +49,7 @@ const script = async () => {
// create ShaderStorageBuffer
const ssbo = context.createBuffer();
context.bindBuffer(context.SHADER_STORAGE_BUFFER, ssbo);
context.bufferData(context.SHADER_STORAGE_BUFFER, input, context.STATIC_DRAW);
context.bufferData(context.SHADER_STORAGE_BUFFER, input, context.DYNAMIC_COPY);
context.bindBufferBase(context.SHADER_STORAGE_BUFFER, 0, ssbo);

// execute ComputeShader
Expand Down
2 changes: 1 addition & 1 deletion webgl-compute-vertex/js/script.js
Expand Up @@ -69,7 +69,7 @@ const script = async () => {
// create ShaderStorageBuffer
ssbo = context.createBuffer();
context.bindBuffer(context.SHADER_STORAGE_BUFFER, ssbo);
context.bufferData(context.SHADER_STORAGE_BUFFER, new Float32Array(NUM_PARTICLES * 2), context.STATIC_DRAW);
context.bufferData(context.SHADER_STORAGE_BUFFER, new Float32Array(NUM_PARTICLES * 2), context.DYNAMIC_COPY);
context.bindBufferBase(context.SHADER_STORAGE_BUFFER, 0, ssbo);

// VertexShader source
Expand Down

0 comments on commit 52bdcf5

Please sign in to comment.