@@ -188,7 +188,7 @@ class WebglRenderTarget {
188
188
} else if ( target . _depth ) {
189
189
// --- Init a new depth/stencil buffer (optional) ---
190
190
// if device is a MSAA RT, and no buffer to resolve to, skip creating non-MSAA depth
191
- const willRenderMsaa = target . _samples > 1 && device . isWebGL2 ;
191
+ const willRenderMsaa = target . _samples > 1 ;
192
192
if ( ! willRenderMsaa ) {
193
193
if ( ! this . _glDepthBuffer ) {
194
194
this . _glDepthBuffer = gl . createRenderbuffer ( ) ;
@@ -198,8 +198,7 @@ class WebglRenderTarget {
198
198
gl . renderbufferStorage ( gl . RENDERBUFFER , gl . DEPTH_STENCIL , target . width , target . height ) ;
199
199
gl . framebufferRenderbuffer ( gl . FRAMEBUFFER , gl . DEPTH_STENCIL_ATTACHMENT , gl . RENDERBUFFER , this . _glDepthBuffer ) ;
200
200
} else {
201
- const depthFormat = device . isWebGL2 ? gl . DEPTH_COMPONENT32F : gl . DEPTH_COMPONENT16 ;
202
- gl . renderbufferStorage ( gl . RENDERBUFFER , depthFormat , target . width , target . height ) ;
201
+ gl . renderbufferStorage ( gl . RENDERBUFFER , gl . DEPTH_COMPONENT32F , target . width , target . height ) ;
203
202
gl . framebufferRenderbuffer ( gl . FRAMEBUFFER , gl . DEPTH_ATTACHMENT , gl . RENDERBUFFER , this . _glDepthBuffer ) ;
204
203
}
205
204
gl . bindRenderbuffer ( gl . RENDERBUFFER , null ) ;
@@ -209,8 +208,8 @@ class WebglRenderTarget {
209
208
Debug . call ( ( ) => this . _checkFbo ( device , target ) ) ;
210
209
}
211
210
212
- // ##### Create MSAA FBO (WebGL2 only) #####
213
- if ( device . isWebGL2 && target . _samples > 1 ) {
211
+ // ##### Create MSAA FBO #####
212
+ if ( target . _samples > 1 ) {
214
213
215
214
Debug . call ( ( ) => {
216
215
if ( target . width <= 0 || target . height <= 0 ) {
@@ -376,40 +375,37 @@ class WebglRenderTarget {
376
375
}
377
376
378
377
resolve ( device , target , color , depth ) {
379
- if ( device . isWebGL2 ) {
380
-
381
- const gl = device . gl ;
382
-
383
- // if MRT is used, we need to resolve each buffer individually
384
- if ( this . colorMrtFramebuffers ) {
378
+ const gl = device . gl ;
385
379
386
- // color
387
- if ( color ) {
388
- for ( let i = 0 ; i < this . colorMrtFramebuffers . length ; i ++ ) {
389
- const fbPair = this . colorMrtFramebuffers [ i ] ;
380
+ // if MRT is used, we need to resolve each buffer individually
381
+ if ( this . colorMrtFramebuffers ) {
390
382
391
- DebugGraphics . pushGpuMarker ( device , `RESOLVE-MRT${ i } ` ) ;
392
- this . internalResolve ( device , fbPair . msaaFB , fbPair . resolveFB , target , gl . COLOR_BUFFER_BIT ) ;
393
- DebugGraphics . popGpuMarker ( device ) ;
394
- }
395
- }
383
+ // color
384
+ if ( color ) {
385
+ for ( let i = 0 ; i < this . colorMrtFramebuffers . length ; i ++ ) {
386
+ const fbPair = this . colorMrtFramebuffers [ i ] ;
396
387
397
- // depth
398
- if ( depth ) {
399
- DebugGraphics . pushGpuMarker ( device , `RESOLVE-MRT-DEPTH` ) ;
400
- this . internalResolve ( device , this . _glFrameBuffer , this . _glResolveFrameBuffer , target , gl . DEPTH_BUFFER_BIT ) ;
388
+ DebugGraphics . pushGpuMarker ( device , `RESOLVE-MRT${ i } ` ) ;
389
+ this . internalResolve ( device , fbPair . msaaFB , fbPair . resolveFB , target , gl . COLOR_BUFFER_BIT ) ;
401
390
DebugGraphics . popGpuMarker ( device ) ;
402
391
}
392
+ }
403
393
404
- } else {
405
- DebugGraphics . pushGpuMarker ( device , `RESOLVE` ) ;
406
- this . internalResolve ( device , this . _glFrameBuffer , this . _glResolveFrameBuffer , target ,
407
- ( color ? gl . COLOR_BUFFER_BIT : 0 ) | ( depth ? gl . DEPTH_BUFFER_BIT : 0 ) ) ;
394
+ // depth
395
+ if ( depth ) {
396
+ DebugGraphics . pushGpuMarker ( device , `RESOLVE-MRT-DEPTH` ) ;
397
+ this . internalResolve ( device , this . _glFrameBuffer , this . _glResolveFrameBuffer , target , gl . DEPTH_BUFFER_BIT ) ;
408
398
DebugGraphics . popGpuMarker ( device ) ;
409
399
}
410
400
411
- gl . bindFramebuffer ( gl . FRAMEBUFFER , this . _glFrameBuffer ) ;
401
+ } else {
402
+ DebugGraphics . pushGpuMarker ( device , `RESOLVE` ) ;
403
+ this . internalResolve ( device , this . _glFrameBuffer , this . _glResolveFrameBuffer , target ,
404
+ ( color ? gl . COLOR_BUFFER_BIT : 0 ) | ( depth ? gl . DEPTH_BUFFER_BIT : 0 ) ) ;
405
+ DebugGraphics . popGpuMarker ( device ) ;
412
406
}
407
+
408
+ gl . bindFramebuffer ( gl . FRAMEBUFFER , this . _glFrameBuffer ) ;
413
409
}
414
410
}
415
411
0 commit comments