Skip to content

Commit

Permalink
feat: support depth and stencil
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxudong committed Nov 26, 2024
1 parent a7e8f9d commit 9b6d01b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions e2e/fixtures/originImage/Advance_multi-scene-no-clear.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions packages/rhi-webgl/src/WebGLGraphicDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
Texture2D,
Texture2DArray,
TextureCube,
TextureCubeFace
TextureCubeFace,
TextureFormat
} from "@galacean/engine-core";
import { IHardwareRenderer, IPlatformPrimitive } from "@galacean/engine-design";
import { Color, Vector4 } from "@galacean/engine-math";
Expand Down Expand Up @@ -395,10 +396,15 @@ export class WebGLGraphicDevice implements IHardwareRenderer {
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, srcFrameBuffer);
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFrameBuffer);

Check warning on line 397 in packages/rhi-webgl/src/WebGLGraphicDevice.ts

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L396-L397

Added lines #L396 - L397 were not covered by tests

const blitMask =
(clearFlags & CameraClearFlags.Color ? 0 : gl.COLOR_BUFFER_BIT) |
(clearFlags & CameraClearFlags.Depth ? 0 : gl.DEPTH_BUFFER_BIT) |
(clearFlags & CameraClearFlags.Stencil ? 0 : gl.STENCIL_BUFFER_BIT);
// @ts-ignore
const canBlitDepthStencil = !srcRT || srcRT._depthFormat === TextureFormat.Depth24Stencil8;

let blitMask = clearFlags & CameraClearFlags.Color ? 0 : gl.COLOR_BUFFER_BIT;

if (canBlitDepthStencil) {
blitMask |= clearFlags & CameraClearFlags.Depth ? 0 : gl.DEPTH_BUFFER_BIT;
blitMask |= clearFlags & CameraClearFlags.Stencil ? 0 : gl.STENCIL_BUFFER_BIT;
}

const xStart = viewport.x * srcWidth;
const xEnd = xStart + destWidth;

Check warning on line 410 in packages/rhi-webgl/src/WebGLGraphicDevice.ts

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L409-L410

Added lines #L409 - L410 were not covered by tests
Expand Down

0 comments on commit 9b6d01b

Please sign in to comment.