@@ -1845,28 +1845,46 @@ class WebGLBackend extends Backend {
1845
1845
1846
1846
for ( const binding of bindGroup . bindings ) {
1847
1847
1848
+ const map = this . get ( binding ) ;
1849
+
1848
1850
if ( binding . isUniformsGroup || binding . isUniformBuffer ) {
1849
1851
1850
1852
const data = binding . buffer ;
1851
- const bufferGPU = gl . createBuffer ( ) ;
1853
+ let { bufferGPU } = this . get ( data ) ;
1852
1854
1853
- gl . bindBuffer ( gl . UNIFORM_BUFFER , bufferGPU ) ;
1854
- gl . bufferData ( gl . UNIFORM_BUFFER , data , gl . DYNAMIC_DRAW ) ;
1855
+ if ( bufferGPU === undefined ) {
1855
1856
1856
- this . set ( binding , {
1857
- index : i ++ ,
1858
- bufferGPU
1859
- } ) ;
1857
+ // create
1858
+
1859
+ bufferGPU = gl . createBuffer ( ) ;
1860
+ gl . bindBuffer ( gl . UNIFORM_BUFFER , bufferGPU ) ;
1861
+ gl . bufferData ( gl . UNIFORM_BUFFER , data , gl . DYNAMIC_DRAW ) ;
1862
+
1863
+ this . set ( data , { bufferGPU } ) ;
1864
+
1865
+ } else {
1866
+
1867
+ // update
1868
+
1869
+ gl . bindBuffer ( gl . UNIFORM_BUFFER , bufferGPU ) ;
1870
+ gl . bufferSubData ( gl . UNIFORM_BUFFER , 0 , data ) ;
1871
+
1872
+ }
1873
+
1874
+ map . index = i ++ ;
1875
+ map . bufferGPU = bufferGPU ;
1876
+
1877
+ this . set ( binding , map ) ;
1860
1878
1861
1879
} else if ( binding . isSampledTexture ) {
1862
1880
1863
1881
const { textureGPU, glTextureType } = this . get ( binding . texture ) ;
1864
1882
1865
- this . set ( binding , {
1866
- index : t ++ ,
1867
- textureGPU ,
1868
- glTextureType
1869
- } ) ;
1883
+ map . index = t ++ ;
1884
+ map . textureGPU = textureGPU ;
1885
+ map . glTextureType = glTextureType ;
1886
+
1887
+ this . set ( binding , map ) ;
1870
1888
1871
1889
}
1872
1890
0 commit comments