Skip to content

Commit

Permalink
fix: If using multiview rendering, call ensureCanvasSize before rende…
Browse files Browse the repository at this point in the history
…ring (pixijs#11058)

* If using multiview rendering, call ensureCanvasSize before rendering
(fixes pixijs#10972)

* move to a prerender function

---------

Co-authored-by: Mat Groves <[email protected]>
Co-authored-by: Zyie <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent 6a88679 commit decb807
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/rendering/renderers/gl/renderTarget/GlRenderTargetAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,17 @@ export class GlRenderTargetAdaptor implements RenderTargetAdaptor<GlRenderTarget
}
}

public prerender(renderTarget: RenderTarget)
{
const resource = renderTarget.colorTexture.resource;

// if the render target is a canvas, ensure its size matches the source
if (this._renderer.context.multiView && CanvasSource.test(resource))
{
this._renderer.context.ensureCanvasSize(resource);
}
}

public postrender(renderTarget: RenderTarget)
{
// if multiView is not enabled, we don't need to do anything
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ export interface RenderTargetAdaptor<RENDER_TARGET extends GlRenderTarget | GpuR
finishRenderPass(renderTarget: RenderTarget): void

/** called after the render pass is finished */
postrender?(renderTarget: RenderTarget,): void;
postrender?(renderTarget: RenderTarget): void;

/** called before the render main pass is started */
prerender?(renderTarget: RenderTarget): void;

/**
* initializes a gpu render target. Both renderers use this function to initialize a gpu render target
Expand Down Expand Up @@ -232,6 +235,8 @@ export class RenderTargetSystem<RENDER_TARGET extends GlRenderTarget | GpuRender
this.rootViewPort.copyFrom(this.viewport);
this.rootRenderTarget = this.renderTarget;
this.renderingToScreen = isRenderingToScreen(this.rootRenderTarget);

this.adaptor.prerender?.(this.rootRenderTarget);
}

public postrender()
Expand Down

0 comments on commit decb807

Please sign in to comment.