From 52bdcf557e524a16e48fefe98b141ad43a563818 Mon Sep 17 00:00:00 2001 From: 9ballsyndrome <9.ball.syndrome@gmail.com> Date: Mon, 22 Apr 2019 01:37:41 +0900 Subject: [PATCH] Fix SSBO buffer usage --- webgl-compute-bitonicSort/js/script.js | 2 +- webgl-compute-boids/dist/js/bundle.js | 4 ++-- webgl-compute-boids/src/Main.ts | 4 ++-- webgl-compute-simple/js/script.js | 2 +- webgl-compute-vertex/js/script.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/webgl-compute-bitonicSort/js/script.js b/webgl-compute-bitonicSort/js/script.js index 82c17f6..638d5dd 100644 --- a/webgl-compute-bitonicSort/js/script.js +++ b/webgl-compute-bitonicSort/js/script.js @@ -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 diff --git a/webgl-compute-boids/dist/js/bundle.js b/webgl-compute-boids/dist/js/bundle.js index 9f33d71..3f8282b 100644 --- a/webgl-compute-boids/dist/js/bundle.js +++ b/webgl-compute-boids/dist/js/bundle.js @@ -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); diff --git a/webgl-compute-boids/src/Main.ts b/webgl-compute-boids/src/Main.ts index d70e54f..10a4354 100644 --- a/webgl-compute-boids/src/Main.ts +++ b/webgl-compute-boids/src/Main.ts @@ -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); diff --git a/webgl-compute-simple/js/script.js b/webgl-compute-simple/js/script.js index b182e44..5f3b8cc 100644 --- a/webgl-compute-simple/js/script.js +++ b/webgl-compute-simple/js/script.js @@ -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 diff --git a/webgl-compute-vertex/js/script.js b/webgl-compute-vertex/js/script.js index 5556758..3cc5f93 100644 --- a/webgl-compute-vertex/js/script.js +++ b/webgl-compute-vertex/js/script.js @@ -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