Skip to content

Commit b74562d

Browse files
mvaligurskyMartin Valigursky
andauthored
Removed few remaining .isWebGL2 tests that are now true (#6873)
Co-authored-by: Martin Valigursky <[email protected]>
1 parent 3c1d835 commit b74562d

File tree

6 files changed

+39
-48
lines changed

6 files changed

+39
-48
lines changed

src/platform/graphics/webgl/webgl-buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class WebglBuffer {
3737
glUsage = gl.STREAM_DRAW;
3838
break;
3939
case BUFFER_GPUDYNAMIC:
40-
glUsage = device.isWebGL2 ? gl.DYNAMIC_COPY : gl.STATIC_DRAW;
40+
glUsage = gl.DYNAMIC_COPY;
4141
break;
4242
}
4343

src/platform/graphics/webgl/webgl-render-target.js

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class WebglRenderTarget {
188188
} else if (target._depth) {
189189
// --- Init a new depth/stencil buffer (optional) ---
190190
// 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;
192192
if (!willRenderMsaa) {
193193
if (!this._glDepthBuffer) {
194194
this._glDepthBuffer = gl.createRenderbuffer();
@@ -198,8 +198,7 @@ class WebglRenderTarget {
198198
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, target.width, target.height);
199199
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this._glDepthBuffer);
200200
} 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);
203202
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._glDepthBuffer);
204203
}
205204
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
@@ -209,8 +208,8 @@ class WebglRenderTarget {
209208
Debug.call(() => this._checkFbo(device, target));
210209
}
211210

212-
// ##### Create MSAA FBO (WebGL2 only) #####
213-
if (device.isWebGL2 && target._samples > 1) {
211+
// ##### Create MSAA FBO #####
212+
if (target._samples > 1) {
214213

215214
Debug.call(() => {
216215
if (target.width <= 0 || target.height <= 0) {
@@ -376,40 +375,37 @@ class WebglRenderTarget {
376375
}
377376

378377
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;
385379

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) {
390382

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];
396387

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);
401390
DebugGraphics.popGpuMarker(device);
402391
}
392+
}
403393

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);
408398
DebugGraphics.popGpuMarker(device);
409399
}
410400

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);
412406
}
407+
408+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._glFrameBuffer);
413409
}
414410
}
415411

src/scene/graphics/render-pass-color-grab.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ class RenderPassColorGrab extends RenderPass {
4343
allocateRenderTarget(renderTarget, sourceRenderTarget, device, format) {
4444

4545
// allocate texture buffer
46-
const mipmaps = device.isWebGL2;
4746
const texture = new Texture(device, {
4847
name: _colorUniformName,
4948
format,
5049
width: sourceRenderTarget ? sourceRenderTarget.colorBuffer.width : device.width,
5150
height: sourceRenderTarget ? sourceRenderTarget.colorBuffer.height : device.height,
52-
mipmaps,
53-
minFilter: mipmaps ? FILTER_LINEAR_MIPMAP_LINEAR : FILTER_LINEAR,
51+
mipmaps: true,
52+
minFilter: FILTER_LINEAR_MIPMAP_LINEAR,
5453
magFilter: FILTER_LINEAR,
5554
addressU: ADDRESS_CLAMP_TO_EDGE,
5655
addressV: ADDRESS_CLAMP_TO_EDGE
@@ -122,7 +121,7 @@ class RenderPassColorGrab extends RenderPass {
122121
// generate mipmaps
123122
device.mipmapRenderer.generate(this.colorRenderTarget.colorBuffer.impl);
124123

125-
} else if (device.isWebGL2) {
124+
} else {
126125

127126
device.copyRenderTarget(sourceRt, this.colorRenderTarget, true, false);
128127

src/scene/light.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -886,16 +886,13 @@ class Light {
886886
}
887887

888888
_updateShadowBias() {
889-
const device = this.device;
890-
if (device.isWebGL2 || device.isWebGPU) {
891-
if (this._type === LIGHTTYPE_OMNI && !this.clusteredLighting) {
892-
this.shadowDepthState.depthBias = 0;
893-
this.shadowDepthState.depthBiasSlope = 0;
894-
} else {
895-
const bias = this.shadowBias * -1000.0;
896-
this.shadowDepthState.depthBias = bias;
897-
this.shadowDepthState.depthBiasSlope = bias;
898-
}
889+
if (this._type === LIGHTTYPE_OMNI && !this.clusteredLighting) {
890+
this.shadowDepthState.depthBias = 0;
891+
this.shadowDepthState.depthBiasSlope = 0;
892+
} else {
893+
const bias = this.shadowBias * -1000.0;
894+
this.shadowDepthState.depthBias = bias;
895+
this.shadowDepthState.depthBiasSlope = bias;
899896
}
900897
}
901898

src/scene/renderer/shadow-renderer.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,9 @@ class ShadowRenderer {
210210

211211
// Set standard shadowmap states
212212
const isClustered = this.renderer.scene.clusteredLightingEnabled;
213-
const gpuOrGl2 = device.isWebGL2 || device.isWebGPU;
214213
const useShadowSampler = isClustered ?
215-
light._isPcf && gpuOrGl2 : // both spot and omni light are using shadow sampler on webgl2 when clustered
216-
light._isPcf && gpuOrGl2 && light._type !== LIGHTTYPE_OMNI; // for non-clustered, point light is using depth encoded in color buffer (should change to shadow sampler)
214+
light._isPcf : // both spot and omni light are using shadow sampler when clustered
215+
light._isPcf && light._type !== LIGHTTYPE_OMNI; // for non-clustered, point light is using depth encoded in color buffer (should change to shadow sampler)
217216

218217
device.setBlendState(useShadowSampler ? this.blendStateNoWrite : this.blendStateWrite);
219218
device.setDepthState(light.shadowDepthState);

src/scene/shader-lib/programs/lit-shader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ class LitShader {
11761176
if (lightType === LIGHTTYPE_DIRECTIONAL) {
11771177
func.append("#define SHADOW_SAMPLE_ORTHO");
11781178
}
1179-
if ((pcfShadows || pcssShadows) && device.isWebGL2 || device.isWebGPU) {
1179+
if ((pcfShadows || pcssShadows) || device.isWebGPU) {
11801180
func.append("#define SHADOW_SAMPLE_SOURCE_ZBUFFER");
11811181
}
11821182
if (lightType === LIGHTTYPE_OMNI) {

0 commit comments

Comments
 (0)