Skip to content

Commit

Permalink
chore: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxudong committed Dec 2, 2024
1 parent c45b295 commit 5d4e3f7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
14 changes: 13 additions & 1 deletion packages/core/src/RenderPipeline/BasicRenderPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,26 @@ export class BasicRenderPipeline {

// Check if need to create internal color texture or grab texture
if (independentCanvasEnabled) {
let depthFormat: TextureFormat;
if (camera.renderTarget) {
depthFormat = camera.renderTarget._depthFormat;

Check warning on line 127 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L127

Added line #L127 was not covered by tests
} else if (rhi.context.depth && rhi.context.stencil) {
depthFormat = TextureFormat.Depth24Stencil8;

Check warning on line 129 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L129

Added line #L129 was not covered by tests
} else if (rhi.context.depth) {
depthFormat = TextureFormat.Depth24;

Check warning on line 131 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L131

Added line #L131 was not covered by tests
} else if (rhi.context.stencil) {
depthFormat = TextureFormat.Stencil;

Check warning on line 133 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L133

Added line #L133 was not covered by tests
} else {
depthFormat = null;

Check warning on line 135 in packages/core/src/RenderPipeline/BasicRenderPipeline.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/RenderPipeline/BasicRenderPipeline.ts#L135

Added line #L135 was not covered by tests
}
const viewport = camera.pixelViewport;
const internalColorTarget = PipelineUtils.recreateRenderTargetIfNeeded(
engine,
this._internalColorTarget,
viewport.width,
viewport.height,
camera._getInternalColorTextureFormat(),
camera.renderTarget ? camera.renderTarget._depthFormat : TextureFormat.Depth24Stencil8,
depthFormat,
false,
false,
msaaSamples,
Expand Down
36 changes: 32 additions & 4 deletions packages/rhi-webgl/src/WebGLGraphicDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,38 @@ export class WebGLGraphicDevice implements IHardwareRenderer {
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, srcFrameBuffer);
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFrameBuffer);

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

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L404-L405

Added lines #L404 - L405 were not covered by tests

const blitMask =
(needBlitColor ? gl.COLOR_BUFFER_BIT : 0) |
(needBlitDepth ? gl.DEPTH_BUFFER_BIT : 0) |
(needBlitStencil ? gl.STENCIL_BUFFER_BIT : 0);
let blitMask = needBlitColor ? gl.COLOR_BUFFER_BIT : 0;

if (needBlitDepth || needBlitStencil) {
// @ts-ignore
const depthFormat = destRT._depthFormat;

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

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L411

Added line #L411 was not covered by tests

if (needBlitDepth) {
if (
depthFormat === TextureFormat.Depth ||
(depthFormat >= TextureFormat.DepthStencil && depthFormat <= TextureFormat.Depth32Stencil8)
) {
blitMask |= gl.DEPTH_BUFFER_BIT;

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

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L418

Added line #L418 was not covered by tests
} else {
Logger.warn(`Do not clear depth, or set depth format of target which is ${TextureFormat[depthFormat]} now.`);

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

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L420

Added line #L420 was not covered by tests
}
}

if (needBlitStencil) {
if (
depthFormat === TextureFormat.Stencil ||
depthFormat === TextureFormat.DepthStencil ||
depthFormat >= TextureFormat.Depth24Stencil8 ||
depthFormat >= TextureFormat.Depth32Stencil8
) {
blitMask |= gl.STENCIL_BUFFER_BIT;

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

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L431

Added line #L431 was not covered by tests
} else {
Logger.warn(

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

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L433

Added line #L433 was not covered by tests
`Do not clear stencil, or set stencil format of target which is ${TextureFormat[depthFormat]} now.`
);
}
}
}

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

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

View check run for this annotation

Codecov / codecov/patch

packages/rhi-webgl/src/WebGLGraphicDevice.ts#L440-L441

Added lines #L440 - L441 were not covered by tests
Expand Down

0 comments on commit 5d4e3f7

Please sign in to comment.